Initial Checking with all 820 MLMs

This commit is contained in:
2020-02-02 00:54:01 -05:00
parent c59dc6de2e
commit 840d0432f4
828 changed files with 239162 additions and 0 deletions

View File

@@ -0,0 +1,103 @@
maintenance:
title: ACS_DUPLICATE_REFERENCE_LAB_ALERT;;
filename: ACS_DUPLICATE_REFERENCE_LAB_ALERT;;
arden: version 2.5;;
version: 16.30;;
institution: Allscripts;;
author: Allscripts;;
specialist: St Clair - Maria Pest;;
date: 2017-12-21;;
validation: testing;;
library:
purpose:
Hard stop alert upon entry of Reference lab order that has already been ordered this admission.
;;
explanation:
Only fire for Inpatient Visits
Identify which orders should not be duplicated during an admission by the order name ending in any of the following:
(Mayo)
(ITxM)
(Prometheus)
(Quest)
(UPMC)
Current Visit - Any Order which ends with this, check to see if it (the exact order) already exists, and stop its duplication.
;;
keywords: Alert , Referenc Lab , Duplicate
;;
knowledge:
type: data-driven;;
data:
hardStop := true;
// Evoking Events
OrderInitEvent := event { OrderInit User Order:
where Name matches pattern "%(Mayo)"
OR Name matches pattern "%(ITxM)"
OR Name matches pattern "%(Prometheus)"
OR Name matches pattern "%(Quest)"
OR Name matches pattern "%(UPMC)"
};
// Defining the Evoking Object as ClientVisit.
if called_by_editor then
EvokingObject := read last
{Order: This
where Name matches pattern "%(Mayo)"
OR Name matches pattern "%(ITxM)"
OR Name matches pattern "%(Prometheus)"
OR Name matches pattern "%(Quest)"
OR Name matches pattern "%(UPMC)"
};
endif;
/* An alert is stored into the database */
Msg_alert:= Destination { Alert } with
[
alert_type := warning ,
short_message := "Duplicate Reference Lab Order" ,
priority := "medium" ,
scope := "chart" ,
rule_group := "Duplicate Order" ,
rule_number := 1011 ,
Alert_dialog_settings := "" ,
Display_alert := True
];
if(hardStop)then
Msg_alert.Alert_dialog_settings := "No Override Allowed";
endif;
MyMessage := "Reference lab order (" || EvokingObject.Name || ") has already been ordered this admission.";
query := "select count(*) from CV3Order where ClientGUID = " || EvokingObject.ClientGUID || " and ChartGUID = " || EvokingObject.ChartGUID || " and ClientVisitGUID = " || EvokingObject.ClientVisitGUID || " and Active = 1 and OrderStatusLevelNum not in (69,70) and Name = " || SQL(EvokingObject.Name);
ExisitingDuplicateOrderCnt := read last {"" || query};
;;
priority: 50
;;
evoke:
OrderInitEvent ;
;;
logic:
If ExisitingDuplicateOrderCnt > 0
Then
conclude true;
Else
conclude false;
Endif;
;;
action:
WRITE MyMessage At Msg_alert;
;;
Urgency: 80;;
end:

View File

@@ -0,0 +1,839 @@
maintenance:
title: Generic Lookup;;
mlmname: ACS_generic_Lookup ;;
arden: version 2.5;;
version: 5.50;;
institution: Allscripts;;
author: ACS;;
specialist: Allscripts Custom Services;;
date: 2011-12-05;;
validation: testing;;
library:
purpose: Generic tool to lookup past patient data, based upon passed parameters.
;;
explanation:
Change history
05.01.2014 DW CSR# 32070 - Add Admit Date to PN LOS text box
19.05.2015 DW CSR# 32982 - Add Skipped Doses to {{{SINGLE-QUOTE}}}Medication and Allergies{{{SINGLE-QUOTE}}}=> {{{SINGLE-QUOTE}}}Active Medications with detail{{{SINGLE-QUOTE}}} radio button
;;
keywords:
;;
knowledge:
type: data-driven;;
data:
/******************************* Make Changes Here *************************************/
///*** REM - change current to NOW - 24 hours
////*** when data ready is ready to be within last 24 hours
current := Now - 24 hours;
/****************** Make Your code stretch NO WIDER THAN THIS! *************************/
(This_communicationobj,
Client_guid,
Client_visit_guid,
Client_chart_guid,
Getdata_from,//“historical” or “current” (use SQL or current object navigation)
Data_value_type,//Object to retrieve (“HealthIssue”, “order”, etc.)
Data_item,//Attribute to retrieve (“name”, “itemname”, “typecode”, “code”, etc.)
Filterable_item,//Filterable attribute (“name”, “itemname”, “typecode”, “code”, etc.)
Filterable_operator,//Filterable operator (“=”, “<>”, “in”, “matches pattern”, etc.)
Filterable_value,//Filterable value(s)(“chronic”, “atb”,“(480.00,480.30)", etc.)
Additional_condition)//Additional condition(s)
:= ARGUMENT;
// Initialize
Return_Data_item :=();//List object attributes retrieved
Return_Data_item_value :=();//List of values for the attribute(s)
Return_UOM_or_code :=();//List of UOMs (units of measure) for the attributes
Return_relevant_time :=();//List of medically relevant times
Return_start_or_alt_name:=();//List of start times (if relevant)
Return_stop_or_alt_code :=();//List of stop times (if relevant)
Return_user_or_other :=();//List of userguids who entered data.
Return_Significant_data:=();//List of other “significant data” as a text field.
Return_Sig_count := (); //list of significant COUNT data.
Return_Sig_Nt_count := (); //list of Non significant COUNT data.... Added By Shivprasad Jadhav For CSR : 32982
strUser_guid :="";
strSQL :="";
strWhere :="";
strFilterSQL :="";
IF exist This_communicationobj THEN
strUser_guid := This_communicationobj.UserGUID;
ENDIF;
if called_by_editor then
Data_value_type := "Vitals"; //"Orders"; //"Lab Results";
strUser_guid := read last {userinfo: guid};
data_item := "ocmi.name"; // "Lab Results"; //"hi.shortname + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + hi.description";
Filterable_item:= "ocmi.name"; // "ch.code"; //"o.name"; ///,
Filterable_operator:= "IN"; // "like"; // (“=”, “<>”, “in”, “matches pattern”, etc.)
Filterable_value:=
"{{{SINGLE-QUOTE}}}SCH_vs_pulse ox saturation{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Resp Rate{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}L/min{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Noninvasive Systolic BP{{{SINGLE-QUOTE}}},"
||"{{{SINGLE-QUOTE}}}Noninvasive Diastolic BP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Farenheit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Heart Rate{{{SINGLE-QUOTE}}}";
// " {{{SINGLE-QUOTE}}}Basic Metabolic Panel{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Electrolytes{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Liver Panel{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Hemoglobin and Hemtocrit{{{SINGLE-QUOTE}}},"
// ||"{{{SINGLE-QUOTE}}}Prothrombin/INR{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}APTT{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}CBC (Includes Diff){{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}CBC with Manual Diff{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Creatinine{{{SINGLE-QUOTE}}}" ;
//"{{{SINGLE-QUOTE}}}Pulmonary Health Education Consult{{{SINGLE-QUOTE}}}";
(client_guid, client_visit_guid, client_chart_guid) :=
read last {clientvisit: clientguid, guid, chartguid};
Getdata_from := "Historical";
// Additional_condition:="ALL"; //o.OrderStatusLevelNum >= {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} " ; //"all";
endif;
IF Getdata_from = "Historical" THEN // assemble the main condition
strWhere := " where ClientGUID = " || SQL(Client_guid);
IF any(exists Filterable_item AND (not (Filterable_item is in ("", "No"))))
AND any(exists Filterable_operator AND (not(Filterable_operator is in ("", "No"))))
AND any(exists Filterable_value AND (not (Filterable_value is in ("", "No")))) THEN
strFilterSQL := " ( " || Filterable_item||" "||Filterable_operator||" ";
IF Filterable_operator = "IN" THEN
strFilterSQL := strFilterSQL ||"("|| Filterable_value||")";
ELSEIF Filterable_operator = "LIKE" THEN
if count Filterable_value = 1 then
strFilterSQL := strFilterSQL || "{{{SINGLE-QUOTE}}}%" || Filterable_value|| "%{{{SINGLE-QUOTE}}}";
else // enable multiple LIKEs in SQL
strFilterSQL := strFilterSQL ||"{{{SINGLE-QUOTE}}}%"|| Filterable_value[1] || "%{{{SINGLE-QUOTE}}}";
for m in 2 seqto count Filterable_value do
strFilterSQL := strFilterSQL || " or "
|| Filterable_item || " " || Filterable_operator|| " "
||"{{{SINGLE-QUOTE}}}%"|| Filterable_value[m] || "%{{{SINGLE-QUOTE}}}" ;
enddo;
endif;
ELSE
strFilterSQL := strFilterSQL || SQL(Filterable_value);
ENDIF; // Filterable_operator ="IN"
strFilterSQL := strFilterSQL || " ) ";
ENDIF; // any(exists Filterable_item AND ...
// CASE STMT FOR POSSIBLE HISTORICAL LOOKUPS
// HEALTH ISSUES ####################################################################
IF Data_value_type ="HealthIssue" THEN // create main SQL
strSQL := " SELECT "|| Data_item ||", ch.code, hi.TouchedWhen, hi.CreatedBy "
||" FROM CV3HealthIssueDeclaration hi"
||" left outer join CV3CodedHealthIssue ch "
||" on ch.GUID = hi.CodedHealthIssueGUID "
;
// apend the condition
strWhere := strWhere || " AND Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} AND hi.Active = 1 ";
IF strFilterSQL <>"" THEN
strSQL := strSQL || strWhere || " AND "|| strFilterSQL ;
ENDIF;
// get the returnable data
(Return_Data_item, Return_Data_item_value, Return_relevant_time,
Return_user_or_other) := read{ "" ||strSql|| " " };
IF NOT EXISTS Return_Data_item THEN
Return_Data_item := "\b No Problems Listed. \b0" ;
ENDIF;
// SERVICE ##########################################################################
ELSEIF Data_value_type = "Service" THEN // create main SQL
IF strUser_guid <> "" THEN
/*(Return_Data_item_value):= read last
{"SELECT Discipline FROM CV3CareProvider where "
|| " GUID =" || SQL(strUser_guid)
|| " AND Active = 1 " };*/
// Below New SQL Added By Shivprasad for CSR : 32338
(Return_Data_item_value):= read last {" Select Stuff (( Select {{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}+ d.Code "
|| " From cv3Careprovider cp (Nolock) Inner Join SXAAMCareProviderSpecialtyXREF cpx"
|| " On cp.GUID=cpx.CareProviderGUID "
|| " Inner Join CV3Discipline d (Nolock) On d.GUID=cpx.DisciplineGUID "
|| " Where cp.GUID =" || SQL(strUser_guid)
|| " AND cp.Active = 1 Order by d.TouchedWhen "
|| " FOR XML PATH({{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}), TYPE).value({{{SINGLE-QUOTE}}}.{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}varchar(max){{{SINGLE-QUOTE}}}), 1, 1, {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}) as Discipline " } ;
IF NOT Exists Return_Data_item_value Then
Return_Data_item_value := "\b No Service Data Available. \b0" ;
EndIf;
ENDIF;
// LOS ##############################################################################
ELSEIF Data_value_type ="LOS" THEN
(admit_date, admit_date_modified) := read last
{"SELECT v.AdmitDtm, CONVERT(char (10),v.AdmitDtm,101) "
|| " FROM cv3clientvisit v "
|| " WHERE v.clientGUID = " || sql(Client_guid)
|| " and v.guid = " || sql(Client_visit_guid)
|| " and v.active = 1 " //non-closed visits
, primarytime = admitdtm};
hospital_hour:= INT((NOW - admit_date) / 1 hour) ;
hospital_day := INT(hospital_hour /24 ) + 1 ;
Formatted_NOW := NOW FORMATTED WITH "%.4t";
IF Exists hospital_day Then
Return_Data_item_value:= Return_Data_item_value, "\b Date of Admission: \b0 " || admit_date_modified || "\n\b Hospital Day: \b0 # "
|| hospital_day || ", Hour # " || hospital_hour
|| " (current date and time : " || Formatted_NOW || ")" ;
ELSE
Return_Data_item_value := "\b No LOS Data Available. \b0" ;
ENDIF;
// VITAL SIGNS ######################################################################
ELSEIF Data_value_type = "Vitals" THEN
/////// 021512 - added to fetch all Lines not just last 24 hrs ////////////
if Additional_condition matches pattern "Line Access%"
then
current:= NOW - 30 days;
endif;
///////////////////////////////////////////////
strSQL := " select ocmi.name, isnull(sp.valuetext, SOBS.value) vs_vals, "
||" sp.obsuom, " //ob.unitofmeasure , "
||" convert(char(16), sp.recordeddtm, 110) + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} "
||" + convert(char(5), sp.recordeddtm, 14), "
||" d.documentname, ocmi.leftjustifiedlabel "
||" from cv3clientdocument d "
||" JOIN SXACDObservationParameter sp "
||" ON d.ClientGUID = sp.ClientGUID "
||" and d.ChartGUID = sp.ChartGUID "
||" and d.guid = sp.ownerguid "
||" and d.PatCareDocGUID = sp.PatCareDocGUID "
||" JOIN CV3ObsCatalogMasterItem ocmi "
||" ON ocmi.GUID = sp.ObsMasterItemGUID "
/* ||" join cv3observationDocument o "
||" on o.ownerguid = d.guid "
||" and o.ObservationDocumentGUID = sp.ObservationDocumentGUID "
||" and o.ObsMasterItemGUID = ocmi.guid "
||" and o.active = 1 "
||" left outer join cv3observation ob "
||" on sp.ObservationGUID = ob.GUID "
*/
||" LEFT outer JOIN SCMObsFSListValues SOBS "
||" on sp.ClientGUID = SOBS.ClientGUID "
||" and sp.ObservationDocumentGUID = SOBS.ParentGUID "
||" AND SOBS.Active = 1 "
|| " and SOBS.ClientGUID =" || sql(Client_guid)
||" WHERE d.clientGUID = " || sql(Client_guid)
||" and d.chartguid = " || sql(client_chart_guid)
||" and d.clientvisitguid = " || sql(Client_visit_guid)
||" and sp.recordeddtm >= " || sql(current)
;
/// 041912 - added "and SOBS.ClientGUID =" || sql(Client_guid) to the sql above
IF strFilterSQL <> "" THEN // append filter
strSQL := strSQL || " AND " || strFilterSQL ;
ENDIF;
(vs_names, vs_vals, vs_uoms ,vs_times, vs_docs, vs_labels) := read
{ "" || strSQL
|| "order by sp.RecordedDtm "
};
if exists vs_vals then // set return values
Return_Data_item:= vs_names;
Return_Data_item_value:= vs_vals;
Return_UOM_or_code := vs_uoms;
Return_relevant_time:= vs_times;
Return_start_or_alt_name:= "";
Return_stop_or_alt_code:= "";
Return_user_or_other:= "";
Return_Significant_data:= vs_labels;
Return_Sig_Count := "";
endif;
IF NOT Exists Return_Data_item_value Then
Return_Data_item_value := "\b No Vital Sign Data Available. \b0" ;
EndIf;
// I & O ############################################################################
ELSEIF Data_value_type is in ("IO_Drains_shift", "IO_NG_shift") THEN
strSQL := " select ocmi.name, x.outvalue, sp.obsuom, " //ob.unitofmeasure ,
||" sp.RecordedDtm , d.documentname "
||" , case "
||" when sp.shiftdailyhourlytotal = 1 then {{{SINGLE-QUOTE}}}Shift total{{{SINGLE-QUOTE}}} "
||" when sp.shiftdailyhourlytotal = 2 then {{{SINGLE-QUOTE}}}Daily total{{{SINGLE-QUOTE}}} "
||" when sp.shiftdailyhourlytotal = 3 then {{{SINGLE-QUOTE}}}Hourly total{{{SINGLE-QUOTE}}} "
||" else {{{SINGLE-QUOTE}}}unknown{{{SINGLE-QUOTE}}} "
||" end as shift_daily_hourly "
||" from cv3clientdocument d "
/* ||" join cv3observationDocument o "
||" on o.ownerguid = d.guid "
||" and o.active = 1 "
*/
||" JOIN SXACDObservationParameter sp "
||" ON d.ClientGUID = sp.ClientGUID "
||" and d.ChartGUID = sp.ChartGUID "
||" and d.PatCareDocGUID = sp.PatCareDocGUID "
||" and d.guid = sp.ownerguid "
// ||" and o.ObservationDocumentGUID = sp.ObservationDocumentGUID "
||" JOIN CV3ObsCatalogMasterItem ocmi "
||" ON ocmi.GUID = sp.ObsMasterItemGUID "
||" left outer join CV3ClientObsEntryItem oei on oei.GUID = sp.ParameterGUID "
||" and oei.IsUpdate = 1 " //get latest item only
/* ||" join cv3observation ob "
||" on sp.ObservationGUID = ob.GUID "
||" and ob.shiftdailyhourlytotal = 1 " // shift total only
*/
||" join cv3observationxinfo x "
||" on sp.ObservationGUID = x.observationxinfoguid "
||" WHERE d.clientGUID = " || sql(Client_guid)
||" and d.chartguid = " || sql(client_chart_guid)
||" and d.clientvisitguid = " || sql(Client_visit_guid)
||" and sp.shiftdailyhourlytotal = 1 " // shift total only
;
IF strFilterSQL <> "" THEN // append condition
strSQL := strSQL || " AND " || strFilterSQL ;
ENDIF;
(io_names, io_vals, io_uoms, io_times, io_docs, io_sdh_tots) := read
{ "" || strSQL
|| "", primarytime = recordeddtm};
if exists io_times then // get the latest recorded values
latest_shft_io_time := max (io_times);
latest_shft_io_vals := io_vals where((time of io_vals) = latest_shft_io_time);
latest_shft_io_names := io_names
where((time of io_names) = latest_shft_io_time);
latest_shft_io_sdh_tots := io_sdh_tots
where((time of io_sdh_tots) = latest_shft_io_time);
latest_shft_total := sum (latest_shft_io_vals as number);
// set return values
Return_Data_item:= ,Data_value_type;
Return_Data_item_value:= ,latest_shft_total;
Return_UOM_or_code := ,(first io_uoms);
Return_relevant_time:= ,latest_shft_io_time;
Return_start_or_alt_name:= "";
Return_stop_or_alt_code:= "";
Return_user_or_other:= "";
Return_Significant_data:= "";
Return_Sig_Count := "";
endif;
IF NOT Exists Return_Data_item_value Then
Return_Data_item_value := "\b No Shift I&O Data Available for \b0"
|| Data_value_type ;
EndIf;
//Added below elseif section for IO_NG_shift_NB in Newborn Assessment and Discharge Summary document (CSR-33427) (Vikas)
ELSEIF Data_value_type is in ("IO_NG_shift_NB") THEN
//break;
strSQL := " select ocmi.name, isnull(x.outvalue,x.invalue) as outvalue, sp.obsuom, " //ob.unitofmeasure ,
||" sp.RecordedDtm , d.documentname "
||" , case "
||" when sp.shiftdailyhourlytotal = 1 then {{{SINGLE-QUOTE}}}Shift total{{{SINGLE-QUOTE}}} "
||" when sp.shiftdailyhourlytotal = 2 then {{{SINGLE-QUOTE}}}Daily total{{{SINGLE-QUOTE}}} "
||" when sp.shiftdailyhourlytotal = 3 then {{{SINGLE-QUOTE}}}Hourly total{{{SINGLE-QUOTE}}} "
||" else {{{SINGLE-QUOTE}}}unknown{{{SINGLE-QUOTE}}} "
||" end as shift_daily_hourly "
||" from cv3clientdocument d "
/* ||" join cv3observationDocument o "
||" on o.ownerguid = d.guid "
||" and o.active = 1 "
*/
||" JOIN SXACDObservationParameter sp "
||" ON d.ClientGUID = sp.ClientGUID "
||" and d.ChartGUID = sp.ChartGUID "
||" and d.PatCareDocGUID = sp.PatCareDocGUID "
||" and d.guid = sp.ownerguid "
||" and d.DocumentName = {{{SINGLE-QUOTE}}}B2. Newborn Intake and Output{{{SINGLE-QUOTE}}} "
// ||" and o.ObservationDocumentGUID = sp.ObservationDocumentGUID "
||" JOIN CV3ObsCatalogMasterItem ocmi "
||" ON ocmi.GUID = sp.ObsMasterItemGUID "
||" left outer join CV3ClientObsEntryItem oei on oei.GUID = sp.ParameterGUID "
||" and oei.IsUpdate = 1 " //get latest item only
/* ||" join cv3observation ob "
||" on sp.ObservationGUID = ob.GUID "
||" and ob.shiftdailyhourlytotal = 1 " // shift total only
*/
||" join cv3observationxinfo x "
||" on sp.ObservationGUID = x.observationxinfoguid "
||" WHERE d.clientGUID = " || sql(Client_guid)
||" and d.chartguid = " || sql(client_chart_guid)
||" and d.clientvisitguid = " || sql(Client_visit_guid)
||" and sp.shiftdailyhourlytotal = 1 " // shift total only
;
IF strFilterSQL <> "" THEN // append condition
strSQL := strSQL || " AND " || strFilterSQL ;
ENDIF;
//Break;
(io_names, io_vals, io_uoms, io_times, io_docs, io_sdh_tots) := read
{ "" || strSQL
|| "", primarytime = recordeddtm};
if exists io_times then // get the latest recorded values
latest_shft_io_time := max (io_times);
latest_shft_io_vals := io_vals where((time of io_vals) = latest_shft_io_time);
latest_shft_io_names := io_names
where((time of io_names) = latest_shft_io_time);
latest_shft_io_sdh_tots := io_sdh_tots
where((time of io_sdh_tots) = latest_shft_io_time);
latest_shft_total := sum (latest_shft_io_vals as number);
// set return values
Return_Data_item:= ,Data_value_type;
Return_Data_item_value:= ,latest_shft_total;
Return_UOM_or_code := ,(first io_uoms);
Return_relevant_time:= ,latest_shft_io_time;
Return_start_or_alt_name:= "";
Return_stop_or_alt_code:= "";
Return_user_or_other:= "";
Return_Significant_data:= "";
Return_Sig_Count := "";
endif;
IF NOT Exists Return_Data_item_value Then
Return_Data_item_value := "\b No Shift I&O Data Available for \b0"
|| Data_value_type ;
EndIf;
ELSEIF Data_value_type is in ( "IO24", "IOSOC") THEN
IF Data_value_type = "IO24" THEN
sql_last_24hr := " AND RecordedDateTime >= getDate() - 1 ";
else
sql_last_24hr := " ";
endif;
(All_IO_RecDTm, All_IO_TotIT, All_IO_TotOP, All_IO_Tot24 ) := READ
{" SELECT RecordedDateTime,TotalIntake,TotalOutput,Total24hr "
|| " FROM SCMObsFSGrandTotals "
|| " WHERE ClientGUID = " || SQL(client_guid)
|| " and chartguid = " || sql(client_chart_guid)
|| " AND ShIftDailyHourlyTotal = 1 " //shift total
|| " AND TotalType = 3 " //grand total
|| " AND Active = 1 "
|| sql_last_24hr
|| " order by RecordedDateTime desc "
};
IF Data_value_type = "IO24" THEN
All_IO_RecDTm := first 4 from All_IO_RecDTm;
All_IO_TotIT := first 4 from All_IO_TotIT;
All_IO_TotOP := first 4 from All_IO_TotOP;
All_IO_Tot24 := first 4 from All_IO_Tot24;
endif;
//Variables for total
Intake_Total:= 0 As NUMBER ;
Output_Total:= 0 As NUMBER ;
Fluid_Balance:= 0 As NUMBER;
max_io_time := first(All_IO_RecDTm);
min_io_time := last(All_IO_RecDTm);
For ictr IN 1 seqto count All_IO_RecDTm Do
//Calculating Total Intake AND OutPut
If Exists All_IO_TotIT[ictr] Then Intake_Total :=
Intake_Total + ( All_IO_TotIT[ictr] As Number );
EndIF;
If Exists All_IO_TotOP[ictr] Then Output_Total :=
Output_Total + (All_IO_TotOP[ictr] As NUMBER ) ;
EndIF;
EndDo;
Fluid_Balance := Intake_Total - Output_Total;
if exists All_IO_RecDTm then
Return_Data_item:= ("Intake Total","Output Totalr","Fluid Balance") ;
Return_Data_item_value:= Intake_Total, Output_Total, Fluid_Balance ;
Return_UOM_or_code := ("mL", "mL", "mL");
Return_relevant_time:= (max_io_time, max_io_time, max_io_time);
Return_start_or_alt_name:= (min_io_time, min_io_time, min_io_time);
Return_stop_or_alt_code:= (max_io_time, max_io_time, max_io_time);
Return_user_or_other:= "";
Return_Significant_data:= "";
Return_Sig_Count := "";
endif;
IF NOT Exists Return_Data_item_value Then
Return_Data_item_value := "\b No I&O Summary Data Available. \b0" ;
EndIf;
/* // Orders #################################################################
ELSEIF Data_value_type = "Orders" THEN
strSQL := " select o.name, isnull(o.summaryline,{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}), requesteddtm "
||" , OTO.TaskName, therapeuticcategory, therapeuticcategoryID "
||" , max(OTO.PerformedFromDtm) "
||" from cv3order o "
||" left outer join cv3ordertaskoccurrence oto "
||" on oto.clientguid = o.clientguid "
||" and oto.orderguid = o.guid "
||" AND OTO.TaskStatusCode = {{{SINGLE-QUOTE}}}Performed{{{SINGLE-QUOTE}}} "
||" and oto.active = 1 "
||" join cv3ordercatalogmasteritem ocmi"
||" on ocmi.guid = o.ordercatalogmasteritemguid"
||" WHERE o.Active = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} "
||" and o.OrderStatusLevelNum <= {{{SINGLE-QUOTE}}}50{{{SINGLE-QUOTE}}}"
||" and o.IsSuspended = {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} "
||" and o.IsHeld = {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} "
|| " and o.clientGUID = " || sql(Client_guid)
||" and o.chartguid = " || sql(client_chart_guid)
||" and o.clientvisitguid = " || sql(Client_visit_guid) ;
IF strFilterSQL <> "" THEN // append condition
strSQL := strSQL || " AND " || strFilterSQL ;
ENDIF;
IF Additional_condition <> "" THEN
strSQL := strSQL || " AND " || Additional_condition ;
ENDIF;
strSQL := strSQL
|| " group by o.name, o.summaryline, requesteddtm, OTO.TaskName ";
(ord_names, ord_summs, ord_times, task_names, cl_val, cl_code, task_times) :=
read { "" || strSQL
, primarytime = requesteddtm };
if exists ord_names then
Return_Data_item:= ord_names;
Return_Data_item_value:= ord_summs;
Return_UOM_or_code := "";
Return_relevant_time:= ord_times;
Return_start_or_alt_name:= "";
Return_stop_or_alt_code:= "";
Return_user_or_other:= "";
Return_Significant_data:= task_times;
endif;
IF NOT Exists Return_Data_item then
Return_Data_item_value := "\b No Active Order Data Available. \b0" ;
EndIf;
*/
// Orders ############################################################
// ELSEIF Data_value_type = "Therap_Cat_Orders" THEN //"Abx Orders" THEN
ELSEIF Data_value_type = "Orders" THEN
/*
//// Previous fetch of Antibiotics done by ClassType
strsql:="select o.name,o.SummaryLine, tv.value, ct.code, requesteddtm "
||" from CV3ORder o"
||" join cv3catalogclasstypevalue tv"
||" on tv.catalogmasterguid = o.ordercatalogmasteritemguid"
||" inner join cv3classtype ct"
||" On tv.classtypeguid = ct.guid"
||" WHERE o.Active = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} "
||" and o.OrderStatusLevelNum <= {{{SINGLE-QUOTE}}}50{{{SINGLE-QUOTE}}}"
||" and o.IsSuspended = {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} "
||" and o.IsHeld = {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} "
||" and o.clientguid = " || sql(Client_guid) //{{{SINGLE-QUOTE}}}9000001864400200{{{SINGLE-QUOTE}}}"
||" and o.ChartGUID = " || sql(Client_chart_guid)
||" and o.ClientVisitGUID = " || sql(Client_visit_guid) ;
//||" and ct.code = {{{SINGLE-QUOTE}}}PN_Antibiotics{{{SINGLE-QUOTE}}}" ;
*/
/* if Additional_condition <> "All" then
strsql:="select o.name,o.SummaryLine, therapeuticcategory, "
||" therapeuticcategoryID, "
||" requesteddtm, OTO.TaskName, max(OTO.PerformedFromDtm) "
||" from CV3ORder o"
||" left outer join cv3ordertaskoccurrence oto "
||" on oto.clientguid = o.clientguid "
||" and oto.orderguid = o.guid "
||" AND OTO.TaskStatusCode = {{{SINGLE-QUOTE}}}Performed{{{SINGLE-QUOTE}}} "
||" and oto.active = 1 "
||" join cv3ordercatalogmasteritem ocmi"
||" on ocmi.guid = o.ordercatalogmasteritemguid"
||" WHERE o.Active = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} "
||" and o.OrderStatusLevelNum <= {{{SINGLE-QUOTE}}}50{{{SINGLE-QUOTE}}}"
||" and o.IsSuspended = {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} "
||" and o.IsHeld = {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} "
||" and o.clientguid = " || sql(Client_guid)
||" and o.ChartGUID = " || sql(Client_chart_guid)
||" and o.ClientVisitGUID = " || sql(Client_visit_guid) ;
elseif
Additional_condition = "All"
then
*/
//Hide Start: By Shivprasad
/* strsql := "select o.name,o.SummaryLine, ocmi.therapeuticcategory, "
||" therapeuticcategoryID, requesteddtm, OTO.TaskName, "
||" max(OTO.PerformedFromDtm), OrderStatusCode, StopDate "
||" , e.admininstructions, count(OTO.PerformedFromDtm) "
||" from CV3ORder o"
||" left outer join cv3ordertaskoccurrence oto "
||" on oto.clientguid = o.clientguid "
||" and oto.orderguid = o.guid "
||" AND OTO.TaskStatusCode = {{{SINGLE-QUOTE}}}Performed{{{SINGLE-QUOTE}}} "
||" and oto.active = 1 "
||" join cv3ordercatalogmasteritem ocmi "
||" on ocmi.guid = o.ordercatalogmasteritemguid "
//||" WHERE o.Active = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} "
//||" and o.OrderStatusLevelNum <= {{{SINGLE-QUOTE}}}50{{{SINGLE-QUOTE}}}"
||" left outer join CV3MedicationExtension e "
||" on e.ClientGUID = o.ClientGUID "
||" and e.GUID = o.GUID "
||" WHERE o.clientguid = " || sql(Client_guid)
||" and o.ChartGUID = " || sql(Client_chart_guid)
||" and o.ClientVisitGUID = " || sql(Client_visit_guid)
||" and o.IsSuspended = {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} "
||" and o.IsHeld = {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} ";
// endif;
if Additional_condition <> "All" then
strsql := strsql || " and o.Active = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} "
|| " and o.OrderStatusLevelNum <= {{{SINGLE-QUOTE}}}60{{{SINGLE-QUOTE}}}";
IF Additional_condition <> "" THEN
strSQL := strSQL || " AND " || Additional_condition ;
endif;
endif;
IF strFilterSQL <> "" THEN
strSQL := strSQL || " AND "|| strFilterSQL ;
endif;
strSQL := strSQL || " group by o.name, o.summaryline, requesteddtm, "
||" ocmi.therapeuticcategory, therapeuticcategoryID, OTO.TaskName, "
||" OrderStatusCode, Stopdate "
||" , e.admininstructions "
; */ //Hide End : By Shivprasad
//Added By Shivprasad Jadhav For CSR : 32982
strsql := "select o.guid , o.name,o.SummaryLine, ocmi.therapeuticcategory, "
||" therapeuticcategoryID, requesteddtm, OTO.TaskName, "
||" max(OTO.PerformedFromDtm) as PerformDate, OrderStatusCode, StopDate "
||" , e.admininstructions, count(OTO.PerformedFromDtm) as cntPerformed ,0 as cntNotPerformed "
||" Into #Temp1 "
||" from CV3ORder o"
||" left outer join cv3ordertaskoccurrence oto "
||" on oto.clientguid = o.clientguid "
||" and oto.orderguid = o.guid "
||" AND OTO.TaskStatusCode = {{{SINGLE-QUOTE}}}Performed{{{SINGLE-QUOTE}}} "
||" and oto.active = 1 "
||" join cv3ordercatalogmasteritem ocmi "
||" on ocmi.guid = o.ordercatalogmasteritemguid "
||" left outer join CV3MedicationExtension e "
||" on e.ClientGUID = o.ClientGUID "
||" and e.GUID = o.GUID "
||" WHERE o.clientguid = " || sql(Client_guid)
||" and o.ChartGUID = " || sql(Client_chart_guid)
||" and o.ClientVisitGUID = " || sql(Client_visit_guid)
||" and o.IsSuspended = {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} "
||" and o.IsHeld = {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} ";
// endif;
if Additional_condition <> "All" then
strsql := strsql || " and o.Active = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} "
|| " and o.OrderStatusLevelNum <= {{{SINGLE-QUOTE}}}60{{{SINGLE-QUOTE}}}";
IF Additional_condition <> "" THEN
strSQL := strSQL || " AND " || Additional_condition ;
endif;
endif;
IF strFilterSQL <> "" THEN
strSQL := strSQL || " AND "|| strFilterSQL ;
endif;
strSQL := strSQL || " group by o.guid ,o.name, o.summaryline, requesteddtm, "
||" ocmi.therapeuticcategory, therapeuticcategoryID, OTO.TaskName, "
||" OrderStatusCode, Stopdate "
||" , e.admininstructions "
;
strsql1 := "select o.guid ,o.name,o.SummaryLine, ocmi.therapeuticcategory, "
||" therapeuticcategoryID, requesteddtm, OTO.TaskName, "
||" max(OTO.PerformedFromDtm) as PerformDate , OrderStatusCode, StopDate "
||" , e.admininstructions, IsNull (Case When ( OTO.TaskStatusCode = {{{SINGLE-QUOTE}}}Overdue{{{SINGLE-QUOTE}}}) Then COUNT(OTO.TaskStatusCode)End, 0) as cntNonPerformed "
||" Into #Temp2 "
||" from CV3ORder o"
||" left outer join cv3ordertaskoccurrence oto "
||" on oto.clientguid = o.clientguid "
||" and oto.orderguid = o.guid "
||" AND OTO.TaskStatusCode in( {{{SINGLE-QUOTE}}}Overdue{{{SINGLE-QUOTE}}}) "
||" and oto.active = 1 "
||" join cv3ordercatalogmasteritem ocmi "
||" on ocmi.guid = o.ordercatalogmasteritemguid "
||" left outer join CV3MedicationExtension e "
||" on e.ClientGUID = o.ClientGUID "
||" and e.GUID = o.GUID "
||" WHERE o.clientguid = " || sql(Client_guid)
||" and o.ChartGUID = " || sql(Client_chart_guid)
||" and o.ClientVisitGUID = " || sql(Client_visit_guid)
||" and o.IsSuspended = {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} "
||" and o.IsHeld = {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} ";
// endif;
if Additional_condition <> "All" then
strsql1 := strsql1 || " and o.Active = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} "
|| " and o.OrderStatusLevelNum <= {{{SINGLE-QUOTE}}}60{{{SINGLE-QUOTE}}}";
IF Additional_condition <> "" THEN
strSQL1 := strSQL1 || " AND " || Additional_condition ;
endif;
endif;
IF strFilterSQL <> "" THEN
strSQL1 := strSQL1 || " AND "|| strFilterSQL ;
endif;
strSQL1 := strSQL1 || " group by o.guid ,o.name, o.summaryline, requesteddtm, "
||" ocmi.therapeuticcategory, therapeuticcategoryID, OTO.TaskName, OTO.TaskStatusCode, "
||" OrderStatusCode, Stopdate "
||" , e.admininstructions "
;
strsql2 := "select o.guid ,o.name,o.SummaryLine, ocmi.therapeuticcategory, "
||" therapeuticcategoryID, requesteddtm, OTO.TaskName, "
||" max(OTO.PerformedFromDtm) as PerformDate , OrderStatusCode, StopDate "
||" , e.admininstructions, IsNull (Case When (OTO.TaskStatusCode = {{{SINGLE-QUOTE}}}Not Performed{{{SINGLE-QUOTE}}} ) Then COUNT(OTO.TaskStatusCode)End, 0) as cntNonPerformed "
||" Into #Temp3 "
||" from CV3ORder o"
||" left outer join cv3ordertaskoccurrence oto "
||" on oto.clientguid = o.clientguid "
||" and oto.orderguid = o.guid "
||" AND OTO.TaskStatusCode = {{{SINGLE-QUOTE}}}Not Performed{{{SINGLE-QUOTE}}} "
||" and oto.active = 1 "
||" join cv3ordercatalogmasteritem ocmi "
||" on ocmi.guid = o.ordercatalogmasteritemguid "
||" left outer join CV3MedicationExtension e "
||" on e.ClientGUID = o.ClientGUID "
||" and e.GUID = o.GUID "
||" WHERE o.clientguid = " || sql(Client_guid)
||" and o.ChartGUID = " || sql(Client_chart_guid)
||" and o.ClientVisitGUID = " || sql(Client_visit_guid)
||" and o.IsSuspended = {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} "
||" and o.IsHeld = {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} ";
// endif;
if Additional_condition <> "All" then
strsql2 := strsql2 || " and o.Active = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} "
|| " and o.OrderStatusLevelNum <= {{{SINGLE-QUOTE}}}60{{{SINGLE-QUOTE}}}";
IF Additional_condition <> "" THEN
strSQL2 := strSQL2 || " AND " || Additional_condition ;
endif;
endif;
IF strFilterSQL <> "" THEN
strSQL2 := strSQL2 || " AND "|| strFilterSQL ;
endif;
strSQL2 := strSQL2 || " group by o.guid ,o.name, o.summaryline, requesteddtm, "
||" ocmi.therapeuticcategory, therapeuticcategoryID, OTO.TaskName, OTO.TaskStatusCode, "
||" OrderStatusCode, Stopdate "
||" , e.admininstructions "
;
// strSQL := strSQL || strSQL1 || " " || " Update p set p.cntNotPerformed=np.cntNonPerformed from #Temp1 p join #Temp2 np on p.Name=np.Name "
// || " Select * from #Temp1 Drop Table #Temp1 Drop Table #Temp2 ";
strSQL := strSQL || strSQL1 || strSQL2 || " " || " Update p set p.cntNotPerformed=(np.cntNonPerformed + np1.cntNonPerformed)from #Temp1 p join #Temp2 np on p.guid=np.guid join #Temp3 np1 on p.guid=np1.guid "
|| " Select name,SummaryLine, therapeuticcategory,therapeuticcategoryID, requesteddtm, TaskName, PerformDate , OrderStatusCode, StopDate ,admininstructions, cntPerformed , cntNotPerformed from #Temp1 Drop Table #Temp1, #Temp2 , #Temp3 ";
//name,SummaryLine, therapeuticcategory,therapeuticcategoryID, requesteddtm, TaskName, PerformDate , OrderStatusCode, StopDate ,admininstructions, cntPerformed , cntNotPerformed
// End : Shivprasad Code
(ord_names, ord_summs, cl_val, cl_code, ord_times, task_names, task_times,
o_stat, Stop_d, ord_admin_inst, num_given, Num_Nt_given) := read //Num_Nt_given Addedby Shivprasad for CSR:32982
{ "" || strSQL
, primarytime = requesteddtm };
if exists ord_summs then
Return_Data_item:= ord_names;
Return_Data_item_value:= ord_summs;
Return_UOM_or_code:= cl_val; // therapeuticcategory
Return_relevant_time:= ord_times;
// Return_start_or_alt_name:= "";
Return_start_or_alt_name:= ord_admin_inst;
Return_stop_or_alt_code:= stop_d;
Return_user_or_other:= o_stat;
Return_Significant_data:= task_times;
Return_Sig_Count := num_given;
Return_Sig_nt_Count := Num_Nt_given ; //Added By Shivprasad Jadhav For CSR : 32982
endif;
IF NOT Exists Return_Data_item_value Then
Return_Data_item_value := "\b No Active Antibiotic Data Available. \b0" ;
EndIf;
//LAb Results ###############################################################
ELSEIF Data_value_type IN ( "Lab Results", "Micro Results") THEN
strsql:= "select o.Name, o.GUID, o.PerformedDtm, bo.ItemName, bo.Value, "
||" bo.ResultItemCode, bo.entered, tol.Text, bo.unitofmeasure "
||" from CV3Order o "
||" join CV3BasicObservation bo on bo.clientguid = o.clientguid "
||" and bo.chartguid = o.chartguid "
||" and bo.clientvisitguid = o.clientvisitguid "
||" and o.GUID = bo.OrderGUID "
||" left outer join CV3TextualObservationLine tol "
||" on bo.clientguid = tol.clientguid "
||" and bo.GUID = tol.ObservationGUID"
||" where o.clientguid = "|| sql(Client_guid)
||" and o.ChartGUID = " ||sql(Client_chart_guid)
||" and bo.entered >= "|| sql(current)
||" and IsHistory = 0 " ;
//||" order by o.Name desc";
IF strFilterSQL <> "" THEN
strSQL := strSQL || " AND "|| strFilterSQL ;
endif;
if data_value_type = "Lab Results" then
strSQL := strSQL || " group by o.Name , o.GUID, o.PerformedDtm, bo.ItemName, "
||" bo.Value, bo.ResultItemCode, bo.entered, tol.Text, bo.unitofmeasure ";
endif;
(ord_names, ord_guids, ord_times, cl_names, cl_vals,
cl_codes, cl_enter, cl_text, cl_uom ) := read
{ "" || strSQL
|| "order by o.name desc" };
if exists ord_names then
Return_Data_item:= ord_names;
Return_Data_item_value:= cl_vals;
Return_UOM_or_code := cl_uom;
Return_relevant_time:= ord_times;
Return_start_or_alt_name:= cl_names;
Return_stop_or_alt_code:= cl_codes;
Return_user_or_other:= ord_guids;
Return_Significant_data:= cl_text;
Return_Sig_Count := "";
endif;
IF NOT Exists Return_Data_item Then
Return_Data_item_value := "\b No Results. \b0" ;
EndIf;
ENDIF; // CASE STMT FOR POSSIBLE HISTORICAL LOOKUPS
ENDIF; // Getdata_from = "Historical"
;;
priority: 50
;;
evoke:
;;
logic: conclude true;
;;
action:
return
Return_Data_item,
Return_Data_item_value,
Return_UOM_or_code ,
Return_relevant_time,
Return_start_or_alt_name,
Return_stop_or_alt_code,
Return_user_or_other,
Return_Significant_data,
This_communicationobj,
Return_sig_count,
Return_Sig_nt_Count; // Added By Shivprasad Jadhav For CSR : 32982
;;
Urgency: 50;;
end:

View File

@@ -0,0 +1,149 @@
maintenance:
title: ACS_obs_select_func_on_lookup ;;
mlmname: ACS_obs_select_func_on_lookup;;
arden: version 2.5;;
version: 5.50;;
institution: St Clair;;
author: Allscripts Custom Services;;
specialist: ;;
date: 2011-11-30;;
validation: testing;;
library:
purpose: Select an observation item (list item) based on other provided data
;;
explanation:
Change history
05.01.2012 CSR# 26409 & 26930 DW Altered per CHF Core Measure requirements and Prism Enhancements
;;
keywords:
;;
knowledge:
type: data-driven;;
data:
/******************Make Changes To Spelling And Flags In This Section************************************/
//Set to true if a decision.log is needed for diagnostic purposes.
log_execution_info:= false;
standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}};
include standard_libs;
using "ObjectsPlusXA.SCM.Forms";
using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms";
// Master list for driving the logic. Items in the list MUST follow the pattern:
// "<DOC_NAME>$<CORE_MEASURE>$<FILTER_VALUE_NOT_FOUND>$<OBS_CAT_ITEM_NAME>$<OBSFSLIST_VAL>"
master_list := (
"<DOC_NAME>$<CORE_MEASURE>$<FILTER_VALUE_NOT_FOUND>$<OBS_CAT_ITEM_NAME>$<OBSFSLIST_VAL>",
//Enter your values below..........
// Heart failure
"Physician Progress Note$|cm_chf|$cardiovascular agents | angiotensin converting enzyme inhibitors"
||"$SCH_MDPN_CM_HF_Orders ACE$no",
"Physician Progress Note$|cm_chf|$cardiovascular agents | angiotensin II inhibitors"
||"$SCH_MDPN_CM_HF_Orders ACE$no",
// Acute Myocardial Infarction
"Physician Progress Note$|cm_ami|$cardiovascular agents | angiotensin converting enzyme inhibitors"
||"$SCH_MDPN_CM_AMI ACE unknown$-",
"Physician Progress Note$|cm_ami|$cardiovascular agents | angiotensin II inhibitors"
||"$SCH_MDPN_CM_AMI ARB unknown$-",
"Physician Progress Note$|cm_ami|$cardiovascular agents | beta-adrenergic blocking agents"
||"$SCH_MDPN_CM_AMI BetaB unknown$-",
"Physician Progress Note$|cm_ami|$metabolic agents | antihyperlipidemic agents"
||"$SCH_MDPN_CM_AMI Statin unknown$-",
// Stroke
"Physician Progress Note$|cm_stroke|$(ANY)$SCH_MDPN_CM_Stroke Antithromb unknown$-",
// Venous Thromboembolism
"Physician Progress Note$|cm_VTE|$(ANY)$SCH_MDPN_CM_VTE Prohylaxis unknown$-"
);
/***************************************** End of Changes Section****************************************/
(This_communicationobj, //initial pointer to doc object
core_measure, //Core measure used by calling MLM
filter_vals_not_found) //data NOT found by calling MLM
:= argument;
// initialize vars:
doc_name_list := (); //document name (1st value in the delimited value set)
core_meas_list := (); //core measure (2nd value in the delimited value set)
filt_val_list := (); //filter values (4rd value in the delimited value set)
obs_cat_i_list := (); //catalog item name (second value in the delimited value set)
ofs_l_val_list := (); //OBS FS List value (Third value in the delimited value set)
//Initialize MLM pointers:
str_parse := mlm {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; // For parsing meds_mod_list
WriteToNote := MLM {{{SINGLE-QUOTE}}}STD_DOC_FUNC_CHART_OBSERVATION_HELPER_JAB{{{SINGLE-QUOTE}}};
// Object needed to declare in the calling the above MLM (for listitems only)
SelectedList := OBJECT[ ListGUID, SelectedValues, SuggestiveText];
newValue :=(); // initialize list of items for selection
PN_sel_list := NEW SelectedList; //instantiate NewValue for ListItems
if called_by_editor then
core_measure := "|cm_chf|";
filter_vals_not_found := ("metabolic agents | antihyperlipidemic agents","cardiovascular agents | angiotensin II inhibitors");
endif;
// get document subobjects
(this_structuredNoteDoc) := This_communicationobj.DocumentConfigurationObj;
(this_chartedObservationsList) := this_structuredNoteDoc.ChartedObservationsList;
(this_parameters) := this_structuredNoteDoc.ParametersList;
//Create the sequence matched lists for looping
for j in 1 seqto count(master_list) do
m_item := master_list[j];
m_i_list := call str_parse with m_item, "$"; // parse into separate lists
doc_name_list := doc_name_list, m_i_list[1]; //document name
core_meas_list := core_meas_list, m_i_list[2]; //core measure
filt_val_list := filt_val_list, m_i_list[3]; //filter list
obs_cat_i_list := obs_cat_i_list, m_i_list[4]; //catalog item name
ofs_l_val_list := ofs_l_val_list, m_i_list[5]; //OBS FS List value
enddo;
for i_f_v_not_found in filter_vals_not_found do
if i_f_v_not_found <> "(ANY)" then
target_filt_vals := first of (filt_val_list where (core_meas_list = core_measure and filt_val_list = i_f_v_not_found) ) ;
target_obs := first of (obs_cat_i_list where (core_meas_list = core_measure and filt_val_list = i_f_v_not_found) ) ;
target_list_item := first of (ofs_l_val_list where (core_meas_list = core_measure and filt_val_list = i_f_v_not_found) ) ;
else
target_filt_vals := first of (filt_val_list where (core_meas_list = core_measure and filt_val_list = "(ANY)" ) ) ;
target_obs := first of (obs_cat_i_list where (core_meas_list = core_measure and filt_val_list = "(ANY)" ) ) ;
target_list_item := first of (ofs_l_val_list where (core_meas_list = core_measure and filt_val_list = "(ANY)" ) ) ;
endif;
// get target observation list for changing
target_param := first of (this_parameters where this_parameters.name = target_obs );
target_list_obs := FIRST OF (this_ChartedObservationsList WHERE this_ChartedObservationsList.parameterGUID = target_param.parameterGUID);
// create the selection list for helper MLM
PN_sel_list.ListGUID := target_param.configurationobj.listguid;
list_name := target_obs;
newValue := newValue, target_list_item ;
PN_sel_list.SelectedValues := newvalue; //value to select
PN_sel_list.SuggestiveText := null; //optional text
if exists newvalue then //limit updates, otherwise copyforward will not work properly!
This_communicationobj := CALL WriteToNote WITH (This_communicationobj, list_name , PN_sel_list);
endif;
enddo;
;;
priority: 50
;;
evoke:
;;
logic: conclude true;
;;
action: return This_communicationobj;
;;
Urgency: 50;;
end:

View File

@@ -0,0 +1,230 @@
maintenance:
title: Generic Lookup;;
mlmname: ACS_result_impression_Lookup;;
arden: version 2.5;;
version: 5.00;;
institution: Allscripts;;
author: Allscripts Custom Services;;
specialist: Allscripts Custom Services;;
date: 2011-11-05;;
validation: testing;;
library:
purpose: lookup and parse out the "IMPRESSION" from a set of patient{{{SINGLE-QUOTE}}}s results.
;;
explanation:
;;
keywords:
;;
knowledge:
type: data-driven;;
data:
/****************** Make Your code stretch NO WIDER THAN THIS! *************************/
(Client_guid,
Client_visit_guid,
Client_chart_guid,
Getdata_from,//“historical” or “current” (use SQL or current object navigation)
Data_value_type,//Object to retrieve (“HealthIssue”, “order”, etc.)
Data_item,//Attribute to retrieve (“name”, “itemname”, “typecode”, “code”, etc.)
Filterable_item,//Filterable attribute (“name”, “itemname”, “typecode”, “code”, etc.)
Filterable_operator,//Filterable operator (“=”, “<>”, “in”, “matches pattern”, etc.)
Filterable_value,//Filterable value(s)(“chronic”, “atb”,“(480.00,480.30)", etc.)
Additional_condition)//Additional condition(s)
//(“orderstatuslevelnum between 55 and 60”,
//“performedtm > dateadd(-24, hh, getdate()”, etc.)
:= ARGUMENT;
//setting for
current:= Now - 8 years ; //24 hours;
//initialize
strFilterSQL :="";
if called_by_editor then
(client_guid, client_visit_guid, client_chart_guid) :=
read last {clientvisit: clientguid, guid, chartguid};
Getdata_from := "Historical";
Data_value_type := "Results";
Data_item := "text_val";
Filterable_item := "r.code"; // "itemname";
filterable_operator := "="; // "like";
filterable_value := "Medical Imaging"; // "chest";
endif;
IF any(exists Filterable_item AND (not (Filterable_item is in ("", "No"))))
AND any(exists Filterable_operator AND (not(Filterable_operator is in ("", "No"))))
AND any(exists Filterable_value AND (not (Filterable_value is in ("", "No")))) THEN
strFilterSQL := Filterable_item || " " || Filterable_operator || " ";
IF Filterable_operator = "IN" THEN
strFilterSQL := strFilterSQL || "(" || Filterable_value || ")";
ELSEIF Filterable_operator ="LIKE" THEN
strFilterSQL := strFilterSQL || "{{{SINGLE-QUOTE}}}%" || Filterable_value|| "%{{{SINGLE-QUOTE}}}";
ELSE
strFilterSQL := strFilterSQL || SQL(Filterable_value);
ENDIF;
ENDIF;
if any(exists Additional_condition AND (not (Additional_condition is in ("", "No")))) then
strFilterSQL := strFilterSQL || " and " ||Additional_condition;
endif;
// add filter for time, if not present
if not(strFilterSQL matches pattern "%where%performeddtm%") then
strFilterSQL := strFilterSQL || " and b.entered >= " || sql(current) ;
endif;
(result_items, result_times, result_impressions) := read
// set up (temporary) tables for data entry
{" declare @txt_src table (titem varchar(125), "
||" tguid numeric(16,0), ttime datetime, tln int, ttext varchar(255)) "
||" declare @maxln table (tguid numeric(16,0), mln int) "
||" declare @txt_imp table "
||" (id numeric(16,0) not null, "
||" item varchar(125) null, "
||" obs_time datetime null, "
||" min_line_num int null, "
||" curr_line_num int null, "
||" max_line_num int null, "
||" obs_text varchar(8000) null) "
// pull patient specific data for processing
||" insert @txt_src "
||" select b.itemname, t.ObservationGUID, o.performeddtm, t.LineNum, t.text "
||" from CV3BasicObservation b "
||" join CV3TextualObservationLine t on t.ClientGUID = b.ClientGUID "
||" and b.GUID = t.ObservationGUID "
||" join cv3order o on o.clientguid = b.clientguid "
||" and o.chartguid = b.chartguid "
||" and o.clientvisitguid = b.clientvisitguid "
||" and o.guid = b.orderguid "
||" join cv3ordercatalogmasteritem ocmi on ocmi.GUID = o.OrderCatalogMasterItemGUID "
||" left outer join CV3OrderReviewCategory r on r.GUID = ocmi.OrderReviewCategoryGUID "
||" where b.ClientGUID = " || sql(client_guid)
||" and b.ChartGUID = " || sql(client_chart_guid)
||" and b.ClientVisitGUID = " || sql(client_visit_guid)
// ||" and b.entered >= " || sql(current)
||" and b.IsTextual = 1 "
||" and b.IsHistory = 0 "
||" and " || strFilterSQL
// remove white spaces
||" while (select max(patindex({{{SINGLE-QUOTE}}}%{{{SINGLE-QUOTE}}}+char(10)+{{{SINGLE-QUOTE}}}%{{{SINGLE-QUOTE}}}, ttext)) from @txt_src) > 0 "
||" begin "
||" update @txt_src " // remove the carriage return
||" set ttext = stuff(ttext, patindex({{{SINGLE-QUOTE}}}%{{{SINGLE-QUOTE}}}+char(10)+{{{SINGLE-QUOTE}}}%{{{SINGLE-QUOTE}}}, ttext), 1, null) "
||" where patindex({{{SINGLE-QUOTE}}}%{{{SINGLE-QUOTE}}}+char(10)+{{{SINGLE-QUOTE}}}%{{{SINGLE-QUOTE}}}, ttext) > 0 "
||" end "
// initialize the table
||" insert @txt_imp " // get starting line
||" select distinct tguid, titem, ttime, 0,0, null, {{{SINGLE-QUOTE}}}(no IMPRESSION found){{{SINGLE-QUOTE}}} "
||" from @txt_src "
// get only the impression fragment, starting at {{{SINGLE-QUOTE}}}IMPRESSION:{{{SINGLE-QUOTE}}}
||" update @txt_imp " // get starting line
||" set min_line_num = tln, curr_line_num = tln, obs_text = "
||" substring(tTEXT, PATINDEX({{{SINGLE-QUOTE}}}%impression%{{{SINGLE-QUOTE}}}, ttext), DATALENGTH(ttext) "
||" - PATINDEX({{{SINGLE-QUOTE}}}%impression%{{{SINGLE-QUOTE}}}, ttext)) "
||" from @txt_src "
||" where tguid = id "
||" and tTEXT like {{{SINGLE-QUOTE}}}%impression%{{{SINGLE-QUOTE}}} "
// update the max_line_num to the {{{SINGLE-QUOTE}}}dictated by{{{SINGLE-QUOTE}}} end, if exist
||" update @txt_imp "
||" set max_line_num = tln "
||" from @txt_src "
||" where id = tguid "
||" and tln > min_line_num "
// ||" and obs_text like {{{SINGLE-QUOTE}}}%dictated%{{{SINGLE-QUOTE}}} "
||" and obs_text like {{{SINGLE-QUOTE}}}%dictat%{{{SINGLE-QUOTE}}} " // Added By Shivprasad CSR : 32844
||" and not (obs_text = {{{SINGLE-QUOTE}}}(no IMPRESSION found){{{SINGLE-QUOTE}}}) "
// if no {{{SINGLE-QUOTE}}}dictated by{{{SINGLE-QUOTE}}} ending, go to end of blob
||" insert @maxln "
||" select tguid, mln = MAX(tln) "
||" from @txt_src "
||" group by tguid "
// no {{{SINGLE-QUOTE}}}dictated{{{SINGLE-QUOTE}}} found: set max_line_num to end of blob
||" update @txt_imp "
||" set max_line_num = mln "
||" from @maxln "
||" where id = tguid "
||" and max_line_num is null "
||" and not (obs_text = {{{SINGLE-QUOTE}}}(no IMPRESSION found){{{SINGLE-QUOTE}}}) "
// iterate/append all lines between min and max line numbers
||" while (select count(*) "
||" from @txt_imp where (max_line_num - curr_line_num) > 0 ) > 0 "
||" begin "
||" update @txt_imp "
||" set curr_line_num = tln, "
||" obs_text = obs_text + tTEXT "
||" from @txt_src "
||" where id = tguid "
||" and curr_line_num < max_line_num "
||" and tln = curr_line_num + 1 "
||" end "
// truncate text to {{{SINGLE-QUOTE}}}dictated{{{SINGLE-QUOTE}}}
||" update @txt_imp "
// ||" set obs_text = SUBSTRING(obs_text, 1, patindex({{{SINGLE-QUOTE}}}%dictated%{{{SINGLE-QUOTE}}}, obs_text) + 7) "
// ||" where patindex({{{SINGLE-QUOTE}}}%dictated%{{{SINGLE-QUOTE}}}, obs_text) > 0 "
||" set obs_text = SUBSTRING(obs_text, 1, patindex({{{SINGLE-QUOTE}}}%dictat%{{{SINGLE-QUOTE}}}, obs_text) + 8 ) " // Added By Shivprasad CSR : 32844
||" where patindex({{{SINGLE-QUOTE}}}%dictat%{{{SINGLE-QUOTE}}}, obs_text) > 0 "
||" and not (obs_text = {{{SINGLE-QUOTE}}}(no IMPRESSION found){{{SINGLE-QUOTE}}}) "
// Now add the addendum, if it exists, useing the same logic as above
||" update @txt_imp "
||" set min_line_num = tln, curr_line_num = tln, max_line_num = null, "
||" obs_text = obs_text + {{{SINGLE-QUOTE}}} +++++{{{SINGLE-QUOTE}}} + "
||" substring(tTEXT, PATINDEX({{{SINGLE-QUOTE}}}%ADDENDUM%{{{SINGLE-QUOTE}}}, ttext), "
||" DATALENGTH(ttext) - PATINDEX({{{SINGLE-QUOTE}}}%ADDENDUM%{{{SINGLE-QUOTE}}}, ttext)) "
||" from @txt_src "
||" where id = tguid "
||" and tln >= curr_line_num "
||" and tTEXT like {{{SINGLE-QUOTE}}}%ADDENDUM%{{{SINGLE-QUOTE}}} "
||" and not (obs_text = {{{SINGLE-QUOTE}}}(no IMPRESSION found){{{SINGLE-QUOTE}}}) "
||" update @txt_imp "
||" set max_line_num = tln "
||" from @txt_src "
||" where id = tguid "
||" and tln >= curr_line_num "
||" and tTEXT like {{{SINGLE-QUOTE}}}%LAST PAGE%{{{SINGLE-QUOTE}}} " // never found this...
||" and not (obs_text = {{{SINGLE-QUOTE}}}(no IMPRESSION found){{{SINGLE-QUOTE}}}) "
||" update @txt_imp "
||" set max_line_num = mln "
||" from @maxln "
||" where id = tguid "
||" and max_line_num is null "
||" and not (obs_text = {{{SINGLE-QUOTE}}}(no IMPRESSION found){{{SINGLE-QUOTE}}}) "
||" while (select count(*) "
||" from @txt_imp where (max_line_num - curr_line_num) > 0 ) > 0 "
||" begin "
||" update @txt_imp "
||" set curr_line_num = tln, "
||" obs_text = obs_text + tTEXT "
||" from @txt_src "
||" where id = tguid "
||" and curr_line_num < max_line_num "
||" and tln = curr_line_num + 1 "
||" end "
||" select item, obs_time, obs_text "
||" from @txt_imp "
};
//break;
;;
priority: 50
;;
evoke:
;;
logic: conclude true;
;;
action: return result_items, result_times, result_impressions;
;;
Urgency: 50;;
end: