maintenance: title: Results retrieved for matching result name within a given interval;; mlmname: STD_FUNC_RETRIEVE_MATCHING_RESULTS;; arden: version 2.5;; version: 18.4;; institution: Allscripts, Standard MLM;; author: Allscripts Healthcare Solutions, Inc.;; specialist: ;; date: 2018-10-26;; validation: testing;; /* P r o p r i e t a r y N o t i c e */ /* Unpublished (c) 2013 - 2018 Allscripts Healthcare, LLC. and/or its affiliates. All Rights Reserved. P r o p r i e t a r y N o t i c e: This software has been provided pursuant to a License Agreement, with Allscripts Healthcare, LLC. and/or its affiliates, containing restrictions on its use. This software contains valuable trade secrets and proprietary information of Allscripts Healthcare, LLC. and/or its affiliates and is protected by trade secret and copyright law. This software may not be copied or distributed in any form or medium, disclosed to any third parties, or used in any manner not provided for in said License Agreement except with prior written authorization from Allscripts Healthcare, LLC. and/or its affiliates. Notice to U.S. Government Users: This software is {{{SINGLE-QUOTE}}}Commercial Computer Software{{{SINGLE-QUOTE}}}. All product names are the trademarks or registered trademarks of Allscripts Healthcare, LLC. and/or its affiliates. */ /* P r o p r i e t a r y N o t i c e */ library: purpose: Retrieves a list of valid numeric results to return to the calling MLM. Note, values such as "specimen hemolyzed", ">500", or "2+" are not considered valid numeric results. ;; explanation: This MLM processes information received to return matching results from the database or the current result returned via HL7. The retrieval is performed based on a SQL query or a pointer to the object. If a pointer is sent in from the calling MLM, an object query for the current result is performed. If a pointer is not sent, then a SQL query is performed based on the chart guid, visit guid, present time and past interval. This information is sent by the calling MLM in the following parameters: - client guid used for SQL search - chart guid used for SQL search, - visit guid used for SQL search - start range for SQL search - end range for SQL search - result name string used for SQL query OR pointer used for Object - result scope whether all charts, this visit or this chart This MLM returns lists of result information that contain: - the result guid, - chart guid for that result, - visit guid for that result, - the result name, - the performed date and time for the result, - any text for the result, - the unit of measure for the result, - the result value as a string, - the most recent result found in the database as a number, - the current result as just received via HL7 as a number; ;; keywords: ;; knowledge: type: data-driven;; data: (client_guid, // Client guid used for SQL search chart_guid, // Chart guid used for SQL search, client_visit_guid, // Visit guid used for SQL search present_time, // End range for SQL search, could be the last PerformedDtm past_time, // Start range for SQL search, could be the first PerformedDtm result_info, // String used for SQL query (result item name) or pointer used for Object result_scope, // Indicator to check all visits, this visit, or this chart. include_community // Indicator to include community results. Only applicable to "All" scope ) := ARGUMENT; if exists include_community then local_include_community := include_community; else local_include_community := FALSE; endif; if result_info is string then // Get result data from database using SQL (result_guid, result_name, result_dtm, result_str, result_uom, result_value_str, result_community_source) := read { "Execute CV3ResultsForCDSMatchingFnSelPr " || " @ClientGUID = " || SQL(client_guid) || ", @ChartGUID = " || SQL(chart_guid) || ", @ClientvisitGUID = " || SQL(client_visit_guid) || ", @Scope= " || sql(result_scope) || ", @PerformedDtmFrom = " || sql(past_time) || ", @ItemName = " || sql(result_info) ||", @IncludeCmty = " || sql(local_include_community), PrimaryTime = PerformedDtm}; // Convert result values in string to number converted_results := result_value_str as number; // Set found index to positions where valid numeric result is found found_valid_result := converted_results is number; // Set lists to inlcude data for only valid numeric results result_guid := result_guid where found_valid_result; result_name := result_name where found_valid_result; result_dtm := result_dtm where found_valid_result; result_str := result_str where found_valid_result; result_uom := result_uom where found_valid_result; result_value_str := result_value_str where found_valid_result; result_community_source := result_community_source where found_valid_result; // Set most recent result; recent_last_result := last(result_value_str) as number; elseif exist result_info then // Get result information from the object (result_guid, result_chart_guid, result_visit_guid, result_name, result_dtm, result_str, result_uom, result_value_str) := read last {Observation: GUID, ChartGUID, ClientVisitGUID, Itemname, PerformedDtm, Text, UnitOfMeasure, Value REFERENCING result_info}; // Convert current result value in string to number current_result := result_value_str as number; endif; ;; evoke: ;; logic: if exist result_info then conclude TRUE; else conclude FALSE; endif; ;; action: return result_guid, result_chart_guid, result_visit_guid, result_name, result_dtm, result_str, result_uom, result_value_str, recent_last_result, current_result, result_community_source; ;; end: