diff --git a/MLMStripper/.vs/MLMStripper/v14/.suo b/MLMStripper/.vs/MLMStripper/v14/.suo index b8ab5bd..107649b 100644 Binary files a/MLMStripper/.vs/MLMStripper/v14/.suo and b/MLMStripper/.vs/MLMStripper/v14/.suo differ diff --git a/MLMStripper/MLMStripper.csproj.user b/MLMStripper/MLMStripper.csproj.user new file mode 100644 index 0000000..ffc5982 --- /dev/null +++ b/MLMStripper/MLMStripper.csproj.user @@ -0,0 +1,7 @@ + + + + cv3mlm_full.sql + C:\gitprojects\St.Clair\MLMStripper\bin\Debug + + \ No newline at end of file diff --git a/MLMStripper/Program.cs b/MLMStripper/Program.cs index fbbc5e1..3924daf 100644 --- a/MLMStripper/Program.cs +++ b/MLMStripper/Program.cs @@ -1,15 +1,202 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; +using IO = System.IO; + namespace MLMStripper { class Program { + + static string INSERT_SQL = "INSERT [dbo].[CV3MLM] ([SiteID], [RepFlags], [Build], [TouchedBy], [TouchedWhen], [CreatedBy], [CreatedWhen], [Active], [GUID], [ID], [Name], [Description], [Status], [Logic], [MSrepl_tran_version], [UsageType], [Title], [ArdenVersion], [MLMVersion], [MLMDate], [MSReplrowguid]) VALUES ("; + + // # Readin and Process all Lines + static string curTitle; + static List ReadInLines = new List(); + static bool LinesInBuffer { get { return ReadInLines.Count > 0; } } + + #region Simple Getters + static string GetTitle(string line) + { + string s = line.Substring(INSERT_SQL.Length); + string[] split = s.Split(','); + + string title = split[11].Trim().Substring(2); // removing starting 'N and last ' + return title.Substring(0, title.Length - 1); + } + + static int GetStatus(string line) + { + string s = line.Substring(INSERT_SQL.Length); + string[] split = s.Split(','); + + int status = int.Parse(split[13].Trim()); + return status; + } + + static int GetActive(string line) + { + string s = line.Substring(INSERT_SQL.Length); + string[] split = s.Split(','); + + int active = int.Parse(split[7].Trim()); + return active; + } + #endregion + + static int nPosFindIn(string startswithToLower, List contents) + { + for (int i = contents.Count - 1; i >= 0; i--) + { + string s = contents[i].Trim(); + if (s.ToLower().StartsWith(startswithToLower.ToLower())) + { + return i; + } + } + return -1; + } + + static void CleanupEndOfFile(List contents) + { + bool bAddEnd = false; + + int nPos = nPosFindIn("end:", contents); + if (nPos == -1) + { + nPos = nPosFindIn("urgency:", contents); + bAddEnd = true; + } + + if (nPos == -1) + { + for (int i = contents.Count - 1; i >= 0; i--) + { + string s = contents[i].Trim(); + if (string.IsNullOrEmpty(s)) + { + contents.RemoveAt(i); + } + else + { + break; + } + } + } + else + { + contents.RemoveRange(nPos + 1, (contents.Count - nPos - 1)); + } + + if (bAddEnd) + contents.Add("end:"); + } + + static void WriteOutFile() + { + + // write out contents - remove last line and cleanup end + ReadInLines.RemoveAt(ReadInLines.Count - 1); + + CleanupEndOfFile(ReadInLines); + + // Now do the actual work + string dirpath = IO.Directory.GetCurrentDirectory() + "\\" + curTitle.Split('_')[0]; + if (!IO.Directory.Exists(dirpath)) + IO.Directory.CreateDirectory(dirpath); + + string FileNameNPath = dirpath + "\\" + curTitle + ".mlm"; + if(IO.File.Exists(FileNameNPath)) + { + int i = 44; + } + using (IO.FileStream fs = new IO.FileStream(FileNameNPath, IO.FileMode.Create)) + using (IO.StreamWriter sw = new IO.StreamWriter(fs, Encoding.UTF8)) + { + foreach (string line in ReadInLines) + sw.WriteLine(line); + sw.Flush(); + } + + // done + ReadInLines.Clear(); + curTitle = String.Empty; + } + static void Main(string[] args) { + if (args == null || string.IsNullOrEmpty(args[0])) + { + Console.WriteLine("Provide Filename"); + return; + } + + string Filename = args[0]; + if (!IO.File.Exists(Filename)) + { + Console.WriteLine("File does not exist"); + return; + } + + // # Readin and Process all Lines + using (IO.FileStream fs = new IO.FileStream(Filename, IO.FileMode.Open)) + using (IO.StreamReader reader = new IO.StreamReader(fs, Encoding.UTF8)) + { + // Ignore the first two lines + reader.ReadLine(); + reader.ReadLine(); + + int filecount = 0; + // # Iterate thru all the rest of the lines in the File + for (string Line = reader.ReadLine(); Line != null; Line = reader.ReadLine()) + { + + if (Line.StartsWith(INSERT_SQL)) + { + + if (LinesInBuffer) + { + WriteOutFile(); + } + + // we need active and status of 4 + int active = GetActive(Line); + int status = GetStatus(Line); + //Trace.WriteLine(String.Format("Active:{0} - Status:{1} - FileCount:{2}", active, status, ++filecount)); + if (active != 1 || status != 4) + continue; + + // Begin Parsing this file + curTitle = GetTitle(Line); + //if (curTitle == "SCH_OUTPATIENT_STATUS_BOARD_COLUMN_UPDATE_2") + //{ + // int i = 44; + //} + Trace.WriteLine(String.Format("{0} - FileCount:{1}", curTitle, ++filecount)); + + // clear buffer + ReadInLines.Clear(); + ReadInLines.Add("maintenance:\n"); // begining new file + continue; + } + else if (!String.IsNullOrEmpty(curTitle)) + { + ReadInLines.Add(Line); + } + + } + + if (LinesInBuffer) + { + WriteOutFile(); + } + + } + } } } diff --git a/MLMStripper/bin/Debug/ACS/ACS_DUPLICATE_REFERENCE_LAB_ALERT.mlm b/MLMStripper/bin/Debug/ACS/ACS_DUPLICATE_REFERENCE_LAB_ALERT.mlm new file mode 100644 index 0000000..6e70040 --- /dev/null +++ b/MLMStripper/bin/Debug/ACS/ACS_DUPLICATE_REFERENCE_LAB_ALERT.mlm @@ -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: diff --git a/MLMStripper/bin/Debug/ACS/ACS_GENERIC_LOOKUP.mlm b/MLMStripper/bin/Debug/ACS/ACS_GENERIC_LOOKUP.mlm new file mode 100644 index 0000000..0968a61 --- /dev/null +++ b/MLMStripper/bin/Debug/ACS/ACS_GENERIC_LOOKUP.mlm @@ -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: diff --git a/MLMStripper/bin/Debug/ACS/ACS_OBS_SELECT_FUNC_ON_LOOKUP.mlm b/MLMStripper/bin/Debug/ACS/ACS_OBS_SELECT_FUNC_ON_LOOKUP.mlm new file mode 100644 index 0000000..6d9d9de --- /dev/null +++ b/MLMStripper/bin/Debug/ACS/ACS_OBS_SELECT_FUNC_ON_LOOKUP.mlm @@ -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: +// "$$$$" +master_list := ( +"$$$$", + +//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: diff --git a/MLMStripper/bin/Debug/ACS/ACS_RESULT_IMPRESSION_LOOKUP.mlm b/MLMStripper/bin/Debug/ACS/ACS_RESULT_IMPRESSION_LOOKUP.mlm new file mode 100644 index 0000000..e4d5f6c --- /dev/null +++ b/MLMStripper/bin/Debug/ACS/ACS_RESULT_IMPRESSION_LOOKUP.mlm @@ -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: diff --git a/MLMStripper/bin/Debug/CALLED/CALLED_DOC_FS_DEFINITION_MLM.mlm b/MLMStripper/bin/Debug/CALLED/CALLED_DOC_FS_DEFINITION_MLM.mlm new file mode 100644 index 0000000..0605a59 --- /dev/null +++ b/MLMStripper/bin/Debug/CALLED/CALLED_DOC_FS_DEFINITION_MLM.mlm @@ -0,0 +1,140 @@ +maintenance: + + title: CALLED_DOC_FS_DEFINITION_MLM;; + mlmname: CALLED_DOC_FS_DEFINITION_MLM;; + arden: version 2.5;; + version: 5.50;; + institution: St. Clair Hospital;; + author: Juliet M. Law;; + specialist: ;; + date: 2011-09-22;; + validation: testing;; + +library: + purpose: Standardize the document mlm responsible for variable assignment and debugging. + Specific to flowsheets. + ;; + explanation: + ;; + keywords: RTF, Document Called MLM , list, debug, displayMessageFlag + ;; +knowledge: + type: data-driven;; + data: + (this_documentCommunication) := argument; + + log_execution_info := false; + + (displayMessageFlag) := false; + (client_guid) := this_documentCommunication.ClientGUID; + (client_visit_guid) := this_documentCommunication.ClientVisitGUID; + (chart_guid) := this_documentCommunication.ChartGUID; + (user_guid) := this_documentCommunication.UserGUID; + (document_type) := this_documentCommunication.DocumentType; + (document_name) := this_documentCommunication.DocumentName; + (event_type) := this_documentCommunication.EventType; + (configuration_guid) := this_documentCommunication.ConfigurationGUID; + (this_currentObs) := this_documentCommunication.CurrentObservationObj; + (CancelEventFlag) := this_documentCommunication.CancelEvent; + (this_fs_doc) := this_documentCommunication.DocumentConfigurationObj; + + (authored_by_guid) := this_fs_doc.AuthoredByGUID; + (isIOFlowsheetFlag) := this_fs_doc.IsIOFlowsheet; + (client_document_guid) := this_fs_doc.CurrentColumn.ClientDocumentGUID; + (this_parameters) := this_fs_doc.ParametersList; + (this_columnList) := this_fs_doc.ColumnsList; + (this_currentColumn) := this_fs_doc.CurrentColumn; + (this_chartedObservationsList) := this_fs_doc.CurrentColumn.ChartedObservationsList; + + (this_parameters_displayName) := this_parameters.DisplayName; + + if (event_type = "DocumentClosing") then + current_parameter := first of (this_parameters WHERE + this_parameters.ParameterGUID = this_currentObs.ParameterGUID); + current_parameter_name := current_parameter.Name; + current_parameter_guid := current_parameter.ParameterGUID; + current_parameter_datatype := current_parameter.DataType; + + if (current_parameter_datatype IS IN ("FreeTextValue", "NumericValue", "DateValue")) then + current_value := this_currentObs.ValueObj.Value; + elseif (current_parameter_datatype = "ListValue") then + selectedItems := (this_currentObs.ValueObj.ListItemsList + WHERE this_currentObs.ValueObj.ListItemsList.IsSelected = true); + + selectedItems_Value := selectedItems.Value; + countOf_selectedItems := count of selectedItems_Value; + current_value := first of selectedItems_Value; + endif; + + if (current_parameter_name = "debug_message" AND exists current_value) then + displayMessageFlag := true; + endif; + endif; + + diagnostic_message := ("CALLED_DOC_FS_DEFINITION_MLM \n" + || "\n client guid: " || client_guid + || "\n client visit guid: " || client_visit_guid + || "\n chart guid: " || chart_guid + || "\n user guid: " || user_guid + || "\n document type: " || document_type + || "\n document name: " || document_name + || "\n event type: " || event_type + || "\n configuration guid: " || configuration_guid + || "\n current obs: " || this_currentObs + || "\n cancel event flag: " || CancelEventFlag + || "\n this flowsheet doc: " || this_fs_doc + || "\n authored by guid: " || authored_by_guid + || "\n IO flowsheet flag: " || isIOFlowsheetFlag + || "\n client document guid: " || client_document_guid + || "\n current parameter: " || current_parameter + || "\n current parameter name: " || current_parameter_name + || "\n current parameter guid: " || current_parameter_guid + || "\n current parameter datatype: " || current_parameter_datatype + || "\n current value: " || current_value + || "\n selected items: " || selectedItems + || "\n selected items value: " || selectedItems_Value + || "\n count of selected items value: " || countOf_selectedItems + || "\n" + ); + ;; + priority: 50 + ;; + evoke: + ;; + logic: + conclude true; + ;; + action: + return (this_documentCommunication, + client_guid, + client_visit_guid, + chart_guid, + user_guid, + document_type, + document_name, + event_type, + configuration_guid, + this_currentObs, + CancelEventFlag, + this_fs_doc, + authored_by_guid, + isIOFlowsheetFlag, + client_document_guid, + this_parameters, + this_columnList, + this_currentColumn, + this_chartedObservationsList, + this_parameters_displayName, + current_parameter, + current_parameter_name, + current_parameter_guid, + current_parameter_datatype, + selectedItems, + selectedItems_Value, + current_value, + diagnostic_message, + displayMessageFlag + ); + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/CALLED/CALLED_DOC_FS_OBS_VALUE_MLM.mlm b/MLMStripper/bin/Debug/CALLED/CALLED_DOC_FS_OBS_VALUE_MLM.mlm new file mode 100644 index 0000000..316aa4b --- /dev/null +++ b/MLMStripper/bin/Debug/CALLED/CALLED_DOC_FS_OBS_VALUE_MLM.mlm @@ -0,0 +1,73 @@ +maintenance: + + title: CALLED_DOC_FS_OBS_VALUE_MLM;; + mlmname: CALLED_DOC_FS_OBS_VALUE_MLM;; + arden: version 2.5;; + version: 5.50;; + institution: St. Clair Hospital;; + author: Juliet M. Law;; + specialist: ;; + date: 2011-09-22;; + validation: testing;; + +library: + purpose: Identify the current observation in a flowsheet and return the value. + ;; + explanation: + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + (this_documentCommunication, parameter_name, UpdateType) := argument; + + // .Net assemblies need to be loaded for ObjectsPlus + standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + log_execution_info := false; + + (this_fs_doc) := this_documentCommunication.DocumentConfigurationObj; + (this_parameters) := this_fs_doc.ParametersList; + (this_columnList) := this_fs_doc.ColumnsList; + (this_currentColumn) := this_fs_doc.CurrentColumn; + (this_currentObs) := this_documentCommunication.CurrentObservationObj; + (this_chartedObservationsList) := this_fs_doc.CurrentColumn.ChartedObservationsList; + + if (not exists UpdateType OR UpdateType NOT IN ("Update","Read")) then + UpdateType := "Read"; + endif; + + if (this_documentCommunication.EventType = "DocumentClosing") then + theParameter := first of (this_parameters WHERE this_parameters.Name = parameter_name); + + (theCurrentColumn) := first of (this_columnList + WHERE this_columnList.ClientDocumentGUID = this_currentObs.ClientDocumentGUID); + (theObservation) := first of (theCurrentColumn.ChartedObservationsList + WHERE theCurrentColumn.ChartedObservationsList.ParameterGUID = theParameter.ParameterGUID); + + if (exists theParameter AND exists theObservation) then + + if (theParameter.DataType = "ListValue") then + selectedValue := (theObservation.ValueObj.ListItemsList.Value + WHERE theObservation.ValueObj.ListItemsList.IsSelected = true); + + else + currentValue := theObservation.ValueObj.Value; + endif; + endif; + endif; + ;; + priority: 50 + ;; + evoke: + ;; + logic: + conclude true; + ;; + action: + return (this_documentCommunication, selectedValue, currentValue); + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/CALLED/CALLED_DOM_CCC.mlm b/MLMStripper/bin/Debug/CALLED/CALLED_DOM_CCC.mlm new file mode 100644 index 0000000..bdc045c --- /dev/null +++ b/MLMStripper/bin/Debug/CALLED/CALLED_DOM_CCC.mlm @@ -0,0 +1,259 @@ +maintenance: + + title: CALLED_DOM_CCC;; + mlmname: CALLED_DOM_CCC;; + arden: VERSION 2.5;; + version: 7.02;; + institution: Allscripts;; + author: Allscripts;; + specialist: Allscripts;; + date: 2014-09-22;; + validation: TESTING;; + + /* P r o p r i e t a r y N o t i c e */ + /* Unpublished (c) 2013 - 2014 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 "Commercial Computer Software". + + 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: +;; + explanation: + /*### SCM Release Version: 6.1, 14.3, 15.1 ###*/ + + VERSION DATE AUTHOR REVISION + --------------------------------------------------------------------------------------------------------- + V6.10 2011-05-01 Initial Inclusion. + V7.00 2014-04-16 SMS Incremented version. + V7.01 2014-04-21 SMS Added IF block to allow charting to FS in addition to SN. + V7.02 2014-09-22 SMS Added IF block to check if .ValueObj EXISTS and if it doesn{{{SINGLE-QUOTE}}}t, create it. + + This is a helper MLM that you can use to chart an observation by passing in the required parameters. +;; + keywords: RTF, Document Called MLM , list, multi-select +;; +knowledge: + type: data-driven +;; + data: + (this_documentCommunication, parameter_name, newValue, sugg_txt_value, UpdateType, pListGUID) := ARGUMENT; + /*******************Make Changes To Spelling And Flags In This Section******************/ + //*** Variable and Constant Declaration ***// + + // Document Types + FLOWSHEET := "Flowsheet"; + STRUCTUREDNOTE := "StructuredNote"; + + (this_structuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (this_parameters) := this_structuredNoteDoc.ParametersList; + (this_chartedObservationsList) := this_structuredNoteDoc.ChartedObservationsList; + + IF this_documentCommunication.DocumentType = FLOWSHEET THEN + (this_columnsList) := this_structuredNoteDoc.ColumnsList; + (this_currentColumn) := this_structuredNoteDoc.CurrentColumn; + (this_ClientDocumentGUID) := this_currentColumn.ClientDocumentGUID; + (this_chartedObservationsList) := this_structuredNoteDoc.CurrentColumn.ChartedObservationsList; + ELSEIF this_documentCommunication.DocumentType = STRUCTUREDNOTE THEN + (this_ClientDocumentGUID) := this_structuredNoteDoc.ClientDocumentGUID; + (this_chartedObservationsList) := this_structuredNoteDoc.ChartedObservationsList; + ENDIF; + + this_DocumentType := this_documentCommunication.DocumentType; + + //if the parameter type is a text and the observation already exist the new data may be a + //Replace of Append to current valueObj.Value + IF NOT EXISTS UpdateType OR UpdateType NOT IN("Append","Replace") THEN + UpdateType := "Replace"; + ENDIF; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + //*** Data Structures ***// + //The following data structures can be used to create new objects within the MLM itself. + //Not all data structures are represented here, only ones that can be created in the MLM. + + // Parameter Types + NUMERICVALUE := "NumericValue"; + FREETEXTVALUE := "FreeTextValue"; + LISTVALUE := "ListValue"; + LISTSETVALUE := "ListSetValue"; + DATEVALUE := "DateValue"; + IOVALUE := "IOValue"; + GENERICDRIPVALUE := "GenericDripValue"; + DRIPVALUE := "DripValue"; + + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + ListValueType := OBJECT [ListGUID, ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + DateValueType := OBJECT [Value]; + FreeTextValueType := OBJECT [Value]; + NumericValueType := OBJECT [Value]; + ListSetValueType := OBJECT [ListValuesList]; + // + // This section of code will demonstrate how to write to FreeTextValue, DateValue,NumericValue and ListValue + parameter := FIRST OF (this_Parameters WHERE this_Parameters.Name = parameter_name); + IF EXISTS parameter THEN + //****************************************************************************************************** + // Check for existing object + //******************************************************************************************************* + obs := FIRST OF(this_ChartedObservationsList WHERE this_ChartedObservationsList.parameterGUID = parameter.parameterGUID); + IF NOT EXISTS obs THEN + //Create a new Observation for the list + obs := NEW ObservationType; + //obs.ClientDocumentGUID := this_documentCommunication.DocumentConfigurationObj.ClientDocumentGUID; //2014-04-21 SMS + obs.ClientDocumentGUID := this_ClientDocumentGUID; + obs.ParameterGUID := parameter.ParameterGUID; + obs.DataType := parameter.DataType; + ENDIF; //2014-09-22 SMS + + IF NOT EXISTS obs.ValueObj THEN //2014-09-22 SMS + // Based on the parameter.DataType create the ValueObj Type and set the valueObj.value for (FREETEXTVALUETYPE,DATEVALUETYPE,NUMERICVALUETYPE) + // If the DataType is LISTVALUE then creat the valueObj of LISTVALUETYPE ABD ASSIGN THE paramter.configurationObj.ListGUID + IF parameter.DataType = FREETEXTVALUE THEN + obs.ValueObj := NEW FreeTextValueType; + ELSEIF parameter.DataType = DATEVALUE THEN + obs.ValueObj := NEW DateValueType; + ELSEIF parameter.DataType = NUMERICVALUE THEN + obs.ValueObj := NEW NumericValueType; + ELSEIF parameter.DataType = LISTVALUE THEN + obs.ValueObj := NEW ListValueType; + obs.ValueObj.ListGUID := parameter.ConfigurationObj.ListGUID; + ELSEIF parameter.DataType = LISTSETVALUE THEN + obs.ValueObj := NEW ListSetValueType; + ENDIF; // if parameter.DataType = FREETEXTVALUE then + //APPEND obs to the ChartedObservationsList + ENDIF; + + IF parameter.DataType = FREETEXTVALUE AND UpdateType = "Append" THEN + IF LENGTH OF obs.ValueObj.Value > 0 THEN + obs.ValueObj.Value := obs.ValueObj.Value || "\n" || newValue; + ELSE + obs.ValueObj.Value := newValue; + ENDIF; +//break; + ELSEIF parameter.DataType = FREETEXTVALUE AND UpdateType = "Replace" THEN + IF EXISTS newValue THEN +//break; + obs.ValueObj.Value := newValue; + ELSE + obs.ValueObj := null; + ENDIF; +//break; + ELSEIF parameter.DataType IN(DATEVALUE,NUMERICVALUE) THEN + IF EXISTS newValue THEN // new code added by Stve Abel from Roswell Park + obs.ValueObj.Value := newValue; +//break; + ELSE + obs.ValueObj := null; + ENDIF; + // obs.ValueObj.Value := newValue; This was the code before Steve Abel addition + ELSEIF parameter.DataType = LISTVALUE THEN + //Populate the ListItemsList in the new observation object (obs) + // loop through each item in the parameter.ConfugurationObj.ListItemsList using "item"and append the item to the newly created object ListValueListItemType + //assign the item.listItemGUID to the selectedItem.ListItemGUID, the Item.value to the selectedItem.Value and set the SelectedItem.IsSelected := true + listItems := (); + + IF newValue = "" THEN + newValue := NULL; + ENDIF; + + IF sugg_txt_value = "" THEN + sugg_txt_value := NULL; + ENDIF; + + IF (NOT EXISTS newValue) AND (NOT EXISTS sugg_txt_value) THEN + obs.ValueObj := null; + ELSE + IF EXISTS newValue THEN + + FOR k IN 1 SEQTO COUNT OF parameter.ConfigurationObj.ListItemsList DO + item := parameter.ConfigurationObj.ListItemsList[k]; + parm := FIRST OF(newValue WHERE newValue.ListValue = item.Value); + + IF EXISTS parm THEN + //Create a list item object for the selected list item + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := parm.ListValue; + selectedItem.IsSelected := parm.IsSelected; + // Arden list append statement appending the new object to the listItems object of the ListValueListItemType Object + listItems := (listItems, selectedItem); + // set the obs.valueObj.ListItemsList := listItems list object + Obs.ValueObj.ListItemsList := listItems; + + ENDIF; + ENDDO; + ENDIF; + + + IF EXISTS sugg_txt_value THEN + obs.ValueObj.SuggestedTextValue := sugg_txt_value; + ENDIF; + ENDIF; + ELSEIF parameter.DataType = LISTSETVALUE THEN + newListValue := NEW ListValueType; + newListValue.ListGUID := pListGUID; + + k := 0; + listItems := (); + ii := 0; + + FOR i IN 1 SEQTO COUNT OF parameter.ConfigurationObj.ListConfigurationList DO + IF parameter.ConfigurationObj.ListConfigurationList[i].ListGUID = pListGUID THEN + ii := i; + ENDIF; + ENDDO; + + FOR pItem IN parameter.ConfigurationObj.ListConfigurationList[ii].ListItemsList DO + k := k + 1; + parm := FIRST OF(newValue WHERE newValue.ListValue = pItem.Value); + IF EXISTS parm THEN + newItem := NEW ListValueListItemType; + newItem.ListItemGUID := pItem.ListItemGUID; + newItem.Value := parm.ListValue; + newItem.IsSelected := parm.IsSelected; + + listItems := (listItems, newItem); + ENDIF; + ENDDO; + + newListValue.ListItemsList := (newListValue.ListItemsList, listItems); + Obs.ValueObj.ListValuesList := (Obs.ValueObj.ListValuesList, newListValue); + + IF EXISTS sugg_txt_value THEN + newListValue.SuggestedTextValue := sugg_txt_value; + ENDIF; + ENDIF; + + IF EXISTS obs THEN //2014-04-21 SMS + IF this_DocumentType = FLOWSHEET THEN + this_documentCommunication.DocumentConfigurationObj.CurrentColumn.ChartedObservationsList := this_documentCommunication.DocumentConfigurationObj.CurrentColumn.ChartedObservationsList, obs; + ELSEIF this_DocumentType = STRUCTUREDNOTE THEN + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := (this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs); + ENDIF; + ENDIF; + ENDIF; //IF EXISTS parameter THEN + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +;; + evoke: +;; + logic: + CONCLUDE TRUE; +;; + action: + RETURN this_documentCommunication; +;; +Urgency: 50 +end: diff --git a/MLMStripper/bin/Debug/CALLED/CALLED_LAUNCH_LISTBOX_MULTI_SELECT_ACS.mlm b/MLMStripper/bin/Debug/CALLED/CALLED_LAUNCH_LISTBOX_MULTI_SELECT_ACS.mlm new file mode 100644 index 0000000..f8362f0 --- /dev/null +++ b/MLMStripper/bin/Debug/CALLED/CALLED_LAUNCH_LISTBOX_MULTI_SELECT_ACS.mlm @@ -0,0 +1,288 @@ +maintenance: + + title: CALLED_LAUNCH_LISTBOX_MULTI_SELECT_ACS;; + mlmname: CALLED_LAUNCH_LISTBOX_MULTI_SELECT_ACS;; + arden: VERSION 2.5;; + version: 7.00;; + institution: Allscripts;; + author: Allscripts;; + specialist: Allscripts;; + date: 2014-03-27;; + validation: TESTING;; + + /* P r o p r i e t a r y N o t i c e */ + /* Unpublished (c) 2013 - 2014 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 "Commercial Computer Software". + + 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: + Create a dynamic, multiselect List Window without a dll. + ;; + explanation: + + DEPENDENCIES: + ------------- + .NET 4 + + + + This MLM takes an Arden List and puts it into a dropdown list that will overlay over the current form or document. + The dropdown will close when the user successfully chooses an item in the list. + + There is a flag in the code (it{{{SINGLE-QUOTE}}}s commented out) if you want to give the user the ability to close the window + with the red x. This MLM only requires .NET 4 be installed. + + The MLM returns the values selected by the user as an Arden List. + ;; + keywords: + .NET 4, UDDD, Dynamic + ;; +knowledge: + type: data-driven;; + data: + (listItems, SelectionMode, WindowTitle) := ARGUMENT; + + if called_by_editor and not exists listItems then + listItems := ("one","two","three","four","five","six","$even","Eight","n!n3"); + endif; + + using "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; + using "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; + using "System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; + using "System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; + using "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; + using "System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; + using "System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; + using "System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; + using "WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"; + using "PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"; + using "PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"; + using "System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; + using "System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; + using "SCMLib"; + + using namespace "System"; + using namespace "System.Reflection"; + using namespace "System.Reflection.Emit"; + using namespace "System.Collections.Generic"; + using namespace "System.Text"; + using namespace "System.Windows"; + using namespace "System.Windows.Controls"; + using namespace "System.Windows.Data"; + using namespace "System.Windows.Documents"; + using namespace "System.Windows.Input"; + using namespace "System.Windows.Media"; + using namespace "System.Windows.Media.Imaging"; + using namespace "System.Windows.Navigation"; + using namespace "System.Windows.Shapes"; + using namespace "System.Data.SqlClient"; + using namespace "SCMLib.PObj"; + using namespace "SCMLib.Context"; + + // SET UP THE WINDOW AND IT{{{SINGLE-QUOTE}}}s SETTINGS + mouse := {{{SINGLE-QUOTE}}}System.Windows.Forms.Control{{{SINGLE-QUOTE}}}.MousePosition; + window := NEW NET_OBJECT {{{SINGLE-QUOTE}}}Window{{{SINGLE-QUOTE}}}; + //window.WindowStyle := {{{SINGLE-QUOTE}}}System.Windows.WindowStyle{{{SINGLE-QUOTE}}}.None; // Comment this out if you want all the buttons in the top right of the window. + window.WindowStyle := {{{SINGLE-QUOTE}}}System.Windows.WindowStyle{{{SINGLE-QUOTE}}}.ToolWindow; // Uncomment this to get a tool window that only has the red x. + // Make sure to change the height + //window.Width := 40; // Defines how wide the ListBox is + //window.Height := 38; // Defines how tall the ListBox is + + window.MinWidth := 200; // Defines how wide the ListBox is + window.MinHeight := 100; // Defines how tall the ListBox is + window.MaxWidth := 600; // Defines how wide the ListBox is + window.MaxHeight := 580; // Defines how tall the ListBox is + window.SizeToContent := "WidthAndHeight"; + window.WindowStartupLocation := "CenterScreen"; + if(exists(WindowTitle) and WindowTitle <> "")then + window.Title := WindowTitle; + endif; + + + //window.Left := mouse.X /*- (window.Width/2)*/; // if you uncomment this the window will be horizontally centered to the cursor + // window.Top := mouse.Y /* - (window.Height/2)*/; // if you uncomment this the window will be vertically centered to the cursor + uri := NEW NET_OBJECT {{{SINGLE-QUOTE}}}Uri{{{SINGLE-QUOTE}}} WITH "/PresentationFramework.Aero;v4.0.0.0;31bf3856ad364e35;component/themes/aero.normalcolor.xaml", {{{SINGLE-QUOTE}}}UriKind{{{SINGLE-QUOTE}}}.Relative; + window.Resources.Source := uri; + + // SET UP THE ListBox + ListBox := NEW NET_OBJECT {{{SINGLE-QUOTE}}}ListBox{{{SINGLE-QUOTE}}}; + ListBox.HorizontalAlignment := {{{SINGLE-QUOTE}}}System.Windows.HorizontalAlignment{{{SINGLE-QUOTE}}}.Stretch; + ListBox.VerticalAlignment := {{{SINGLE-QUOTE}}}System.Windows.VerticalAlignment{{{SINGLE-QUOTE}}}.Stretch; + if(SelectionMode = "Multiple")then + ListBox.SelectionMode := "Multiple"; + endif; + ListBox.MaxHeight := 375; + + //Set Up the Buttons + //OK + ButtonOk := NEW NET_OBJECT {{{SINGLE-QUOTE}}}Button{{{SINGLE-QUOTE}}}; + ButtonOk.Content := "OK" as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}; + ButtonOk.Margin := 5; + + //Cancel + ButtonCancel := NEW NET_OBJECT {{{SINGLE-QUOTE}}}Button{{{SINGLE-QUOTE}}}; + ButtonCancel.Content := "Cancel" as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}; + ButtonCancel.Margin := 5; + + //container + StackPanel_Buttons := NEW NET_OBJECT {{{SINGLE-QUOTE}}}StackPanel{{{SINGLE-QUOTE}}}; + StackPanel_Buttons.Orientation := {{{SINGLE-QUOTE}}}Orientation{{{SINGLE-QUOTE}}}.Horizontal; + StackPanel_Buttons.HorizontalAlignment := {{{SINGLE-QUOTE}}}HorizontalAlignment{{{SINGLE-QUOTE}}}.Right; + void := call StackPanel_Buttons.Children.Add with ButtonOk; + void := call StackPanel_Buttons.Children.Add with ButtonCancel; + + + //create a container + StackPanel := NEW NET_OBJECT {{{SINGLE-QUOTE}}}StackPanel{{{SINGLE-QUOTE}}}; + void := call StackPanel.Children.Add with ListBox; + void := call StackPanel.Children.Add with StackPanel_Buttons; + + window.Content := StackPanel; + + + parameters := NEW NET_OBJECT {{{SINGLE-QUOTE}}}List{{{SINGLE-QUOTE}}}; + obj := new NET_OBJECT {{{SINGLE-QUOTE}}}Object{{{SINGLE-QUOTE}}}; + objType := CALL obj.GetType; + void := CALL parameters.Add WITH objType AS {{{SINGLE-QUOTE}}}Type{{{SINGLE-QUOTE}}}; + a1 := CALL {{{SINGLE-QUOTE}}}Assembly{{{SINGLE-QUOTE}}}.Load WITH "PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"; + a2 := CALL {{{SINGLE-QUOTE}}}Assembly{{{SINGLE-QUOTE}}}.Load WITH "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; + a3 := CALL {{{SINGLE-QUOTE}}}Assembly{{{SINGLE-QUOTE}}}.Load WITH "WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"; + a4 := CALL {{{SINGLE-QUOTE}}}Assembly{{{SINGLE-QUOTE}}}.Load WITH "System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; + + ClickEventArgsType := CALL {{{SINGLE-QUOTE}}}Type{{{SINGLE-QUOTE}}}.GetType WITH "System.Windows.RoutedEventArgs, PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", true, false; + ClickEventHandlerType := CALL {{{SINGLE-QUOTE}}}Type{{{SINGLE-QUOTE}}}.GetType WITH "System.Windows.RoutedEventHandler, PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", true, false; + + FrameworkElementType := CALL {{{SINGLE-QUOTE}}}Type{{{SINGLE-QUOTE}}}.GetType WITH "System.Windows.FrameworkElement, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", true, false; + WindowType := CALL window.GetType; + ButtonType := CALL ButtonOk.GetType; + StackPanelType := {{{SINGLE-QUOTE}}}System.Windows.Controls.StackPanel{{{SINGLE-QUOTE}}}; + ListBoxType := CALL ListBox.GetType; + ItemCollectionType := {{{SINGLE-QUOTE}}}System.Windows.Controls.ItemCollection{{{SINGLE-QUOTE}}}; + void := CALL parameters.Add WITH ClickEventArgsType AS {{{SINGLE-QUOTE}}}Type{{{SINGLE-QUOTE}}}; + paramArray := CALL parameters.ToArray; + + eventHandler := NEW NET_OBJECT {{{SINGLE-QUOTE}}}DynamicMethod{{{SINGLE-QUOTE}}} WITH "Button_Click", {{{SINGLE-QUOTE}}}Void{{{SINGLE-QUOTE}}}, paramArray; + + + method1 := CALL FrameworkElementType.GetMethod WITH "get_Parent"; + method2 := CALL WindowType.GetMethod WITH "Close"; + + method6Property := CALL ButtonType.GetProperty WITH "Content"; + method6 := CALL method6Property.GetSetMethod; + stringValue := "Clicked" as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}; + + generator := CALL eventHandler.GetILGenerator; + + //Change the selected buttons Text, so we can tell which button was clicked + void := CALL generator.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Nop; + void := CALL generator.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Ldarg_0; + void := CALL generator.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Castclass, ButtonType; + void := CALL generator.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Ldstr, stringValue; + void := CALL generator.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Call, method6; + + void := CALL generator.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Nop; + void := CALL generator.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Ldarg_0; + void := CALL generator.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Castclass, ButtonType; + void := CALL generator.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Callvirt, method1; + void := CALL generator.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Castclass, StackPanelType; + void := CALL generator.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Callvirt, method1; + void := CALL generator.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Castclass, StackPanelType; + void := CALL generator.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Callvirt, method1; + void := CALL generator.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Castclass, WindowType; + void := CALL generator.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Callvirt, method2; + void := CALL generator.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Nop; + void := CALL generator.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Ret; + + buttonEvent := {{{SINGLE-QUOTE}}}Button{{{SINGLE-QUOTE}}}.ClickEvent; + + delegate := CALL eventHandler.CreateDelegate WITH ClickEventHandlerType; + void := CALL ButtonOk.AddHandler WITH buttonEvent, delegate; + + + //close Button + eventHandler2 := NEW NET_OBJECT {{{SINGLE-QUOTE}}}DynamicMethod{{{SINGLE-QUOTE}}} WITH "ButtonClear_Click", {{{SINGLE-QUOTE}}}Void{{{SINGLE-QUOTE}}}, paramArray; + generator2 := CALL eventHandler2.GetILGenerator; + + //Change the selected buttons Text, so we can tell which button was clicked + void := CALL generator2.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Nop; + void := CALL generator2.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Ldarg_0; + void := CALL generator2.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Castclass, ButtonType; + void := CALL generator2.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Ldstr, stringValue; + void := CALL generator2.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Call, method6; + + void := CALL generator2.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Nop; + void := CALL generator2.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Ldarg_0; + void := CALL generator2.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Castclass, ButtonType; + void := CALL generator2.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Callvirt, method1; + void := CALL generator2.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Castclass, StackPanelType; + void := CALL generator2.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Callvirt, method1; + void := CALL generator2.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Castclass, StackPanelType; + void := CALL generator2.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Callvirt, method1; + void := CALL generator2.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Castclass, WindowType; + void := CALL generator2.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Callvirt, method2; + void := CALL generator2.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Nop; + void := CALL generator2.Emit WITH {{{SINGLE-QUOTE}}}OpCodes{{{SINGLE-QUOTE}}}.Ret; + + delegate := CALL eventHandler2.CreateDelegate WITH ClickEventHandlerType; + void := CALL ButtonCancel.AddHandler WITH buttonEvent, delegate; + + + itemList := NEW NET_OBJECT {{{SINGLE-QUOTE}}}List{{{SINGLE-QUOTE}}}; + for item in ListItems do + void := CALL itemList.Add WITH item as string; + enddo; + + value := (); + IF itemList.Count > 0 THEN + ListBox.ItemsSource := itemList; + try + void := CALL window.ShowDialog; + + buttonClicked := ""; + if(ButtonCancel.Content = "Clicked")then + buttonClicked := "Cancel"; + endif; + if(ButtonOk.Content = "Clicked")then + buttonClicked := "Ok"; + endif; + + if(buttonClicked = "Ok")then + for i in (1 seqto ListBox.SelectedItems.Count)do + value := (value,ListBox.SelectedItems[i]); + enddo; + endif; + + + + endtry; + catch exception ex + void := CALL {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with ex as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}; + endcatch; + ENDIF; + + + ;; + priority: 50 + ;; + evoke: //MLM is called not evoked + ;; + logic: + CONCLUDE TRUE; + ;; + action: + RETURN value AS STRING; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/CALLED/CALLED_RPM_DOM_GET_DEFINITION_MLM.mlm b/MLMStripper/bin/Debug/CALLED/CALLED_RPM_DOM_GET_DEFINITION_MLM.mlm new file mode 100644 index 0000000..6028b06 --- /dev/null +++ b/MLMStripper/bin/Debug/CALLED/CALLED_RPM_DOM_GET_DEFINITION_MLM.mlm @@ -0,0 +1,230 @@ +maintenance: + + title: Called_RPM_DOM_Get_Definition_MLM ;; + mlmname: Called_RPM_DOM_Get_Definition_MLM ;; + arden: version 2.5;; + version: 5.20;; + institution: RPM, Sample Document Called MLM;; + author: Rick Mansour ;; + specialist: ;; + date: 2010-11-08;; + validation: testing;; + +library: + purpose: Standardize the document mlm responsible for variable assignment and debugging. + The 5.2 version adds in the CoSigner1, CoSigner2 and the DocumentTopic + ;; + explanation: + + ;; + keywords: RTF, Document Called MLM , list, debug, displayMessageFlag, + ;; +knowledge: + type: data-driven;; + data: + (this_documentCommunication) := argument; + /*******************Make Changes To Spelling And Flags In This Section******************/ + /* Set to true if a decision.log is needed.*/ + log_execution_info := false; + /***************************************************************************************/ + // This disarticulation of the this_DocumentCommunication is needed for most document mlms + //*** Variable and Constant Declaration ***// + (displayMessageFlag) := FALSE ; + (client_guid) := this_documentCommunication.ClientGUID; + (client_visit_guid) := this_documentCommunication.ClientVisitGUID; + (client_chart_guid) := this_documentCommunication.ChartGUID; + (user_guid) := this_documentCommunication.UserGUID; + (document_type) := this_documentCommunication.DocumentType; + (document_name) := this_documentCommunication.DocumentName; + (event_type) := this_documentCommunication.EventType; + (configuration_guid) := this_documentCommunication.ConfigurationGUID ; + (this_currentObj) := this_documentCommunication.CurrentObservationObj; + (CancelEventFlag) := this_documentCommunication.CancelEvent; + (this_structuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + + (authored_date_time) := this_structuredNoteDoc.AuthoredDateTime; + (authored_by_guid) := this_structuredNoteDoc.AuthoredByGuid; + (client_document_guid) := this_structuredNoteDoc.ClientDocumentGUID; + (document_date_time) := this_structuredNoteDoc.DateTime; + (isNewFlag) := this_structuredNoteDoc.IsNew; + (isIncompleteFlag) := this_structuredNoteDoc.IsIncomplete; + (isResultsPendingFlag) := this_structuredNoteDoc.IsResultsPending; + (isPriorityFlag) := this_structuredNoteDoc.IsPriority; + (this_parameters) := this_structuredNoteDoc.ParametersList; + (this_chartedObservationsList) := this_structuredNoteDoc.ChartedObservationsList; + (CoSigner1) := this_structuredNoteDoc.CoSigner1; // (Read Only) + (CoSigner2) := this_structuredNoteDoc.CoSigner2; // (Read Only) + (DocumentTopic) := this_structuredNoteDoc.DocumentTopic; // (Read/Write) + + (this_parameters_display_name) := this_parameters.DisplayName; + + + // The "ChartObservation" EventType is associated with the charted information + // and the parameter_name. This code dissects the information. + + IF event_type = "ChartObservation" THEN + // could be "DocumentOpening", "ChartObservation", OR "DocumentClosing" + current_parameter := FIRST OF (this_Parameters + WHERE this_parameters.ParameterGUID = this_CurrentObj.ParameterGUID); + current_parameter_name := current_parameter.name; + current_parameter_guid := current_parameter.ParameterGuid; + current_parameter_DataType := current_parameter.DataType; + + IF current_parameter_DataType IS IN("FreeTextValue","NumericValue","DateValue") THEN + current_value := this_currentObj.ValueObj.value; + ELSEIF current_parameter_DataType = "ListValue" THEN + selectedItems := (this_currentObj.ValueObj.ListItemsList + WHERE this_currentObj.ValueObj.ListItemsList.IsSelected = + true); + selectedItems_value := selectedItems.value; + countOf_selectedItems := count of selectedItems_value; + current_value := FIRST OF selectedItems_value; + ENDIF; + + // This code looks for a specific charted observation used for debugging + // By setting the displayMessageFlag := True the entire contents of the + // document will show up as a message + if current_parameter_name = "debug_message" and exist current_value then + displayMessageFlag := TRUE; + endif; + + ENDIF; + + // A structured note has parameters that are assinged to the mlm function and some + // are charted. This code loops through all of the mlm assigned parameters and + // creates a list of those which have charted values and those without charted values. + // This will help detect parameter name spelling errors in the mlm + // The message will show when the displayMessageFlag = TRUE + + param_info_charted:=""; param_info_empty:=""; + ictr_charted:=0; ictr_empty := 0 ; + obs_value:=""; + obs_value_list:=(); + this_Parameters_Sorted := sort(this_Parameters.name); + for param_Obj_Name IN this_Parameters_Sorted DO + param_Obj := first of (this_Parameters + WHERE this_Parameters.name = param_Obj_Name); + param_Obs_Obj := first of (this_ChartedObservationsList + WHERE this_ChartedObservationsList.ParameterGUID = param_Obj.ParameterGUID); + if exist param_Obs_Obj then + if param_Obj.DataType = "ListValue" then + obs_value_list := param_Obs_Obj.valueObj.ListItemsList.value + WHERE param_Obs_Obj.valueObj.ListItemsList.IsSelected = TRUE ; + if NOT EXIST obs_value_list then obs_value := "not charted"; + else obs_value := obs_value_list; + endif; + else + obs_value := param_Obs_Obj.valueObj.value ; + endif; + else + obs_value := "not charted" ; + endif;//if exist param_Obs_Obj then + + if obs_value = "not charted" then + ictr_empty := ictr_empty + 1; + param_info_empty := param_info_empty || ictr_empty || ". " || param_Obj.Name + || " " || param_Obj.DataType || "\n"; + param_info_empty := param_info_empty || ictr_empty || "a. " + || param_Obj.DisplayName || " " || obs_value || "\n\n"; + else + ictr_charted := ictr_charted + 1; + param_info_charted := param_info_charted || ictr_charted || ". " + || param_Obj.Name || " " || param_Obj.DataType || "\n"; + param_info_charted := param_info_charted || ictr_charted || "a. " + || param_Obj.DisplayName || " " || obs_value || "\n\n"; + endif; + enddo; + + diagnosticMessage:= ("Called_RPM_DOM_GetDefinition_MLM \n" + || "\n client_guid: " || client_guid + || "\n client_visit_guid: " || client_Visit_guid + || "\n client_chart_guid: " || client_chart_guid + || "\n user_guid: " || user_guid // + || "\n document_type: " || document_type // + || "\n document_name: " || document_name + || "\n event_type: " || event_type + || "\n configuration_guid: " || configuration_guid + || "\n this_currentObj: " || this_currentObj + || "\n this_CancelEvent: " || CancelEventFlag + || "\n this_structuredNoteDoc: " || this_structuredNoteDoc + || "\n authored_date_time: " || authored_date_time + || "\n authored_by_guid: " || authored_by_guid + || "\n client_document_guid: " || client_document_guid + || "\n document_date_time: " || document_date_time + || "\n isNewFlag: " || isNewFlag + || "\n isIncompleteFlag: " || isIncompleteFlag + || "\n isResultsPendingFlag: " || isResultsPendingFlag + || "\n isPriorityFlag: " || isPriorityFlag + || "\n current_parameter: " || current_parameter + || "\n current_parameter_name: " || current_parameter_name + || "\n current_parameter_guid: " || current_parameter_guid + || "\n current_parameter_DataType: " || current_parameter_DataType + || "\n current_value: " || current_value + || "\n selectedItems: " || selectedItems + || "\n selectedItems_value: " || selectedItems_value + || "\n countOf_selectedItems: " || countOf_selectedItems + || "\n current_value: " || current_value +// || "\n this_Parameters.name: " || this_Parameters_Sorted + || "\n" + || "\n The information below returns all of the " + || "\n parameters assigned to document mlm function " + || "\n in the structured note editor." + || "\n The this_ChartedObservationsList return is limited to " + || "\n the parameter assigned in the Structured Note editor " + || "\n" + || "\n Parameter Information CHARTED: \n\n" || param_info_charted + || "\n" + || "\n Parameter Information NOT CHARTED: \n\n" || param_info_empty + ); + + // this_documentCommunication.DisplayMessage := FALSE ; + // this_documentCommunication.Message := + // "Called_RPM_DOM_GetDefinition_MLM \n" || diagnosticMessage ; + ;; + evoke: + ;; + logic: + conclude true; + ;; + action: + // All of these variable are returned to the + // calling mlm including the diagnosticMessage used for debuging. + return (this_documentCommunication, + client_guid, + client_visit_guid, + client_chart_guid, + user_guid, + document_type, + document_name, + event_type, + configuration_guid, + this_currentObj, + CancelEventFlag, + this_structuredNoteDoc, + authored_date_time, + authored_by_guid, + client_document_guid, + document_date_time, + isNewFlag, + isIncompleteFlag, + isResultsPendingFlag, + isPriorityFlag, + this_parameters, + this_chartedObservationsList, + this_parameters_display_name, + current_parameter, + current_parameter_name, + current_parameter_guid, + current_parameter_DataType, + selectedItems, + selectedItems_value, + current_value, + diagnosticMessage, + displayMessageFlag, + CoSigner1, + CoSigner2, + DocumentTopic) ; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/CALLED/CALLED_RPM_DOM_MLM.mlm b/MLMStripper/bin/Debug/CALLED/CALLED_RPM_DOM_MLM.mlm new file mode 100644 index 0000000..57abf8d --- /dev/null +++ b/MLMStripper/bin/Debug/CALLED/CALLED_RPM_DOM_MLM.mlm @@ -0,0 +1,165 @@ +maintenance: + + title: CALLED_RPM_DOM_MLM ;; + mlmname: CALLED_RPM_DOM_MLM ;; + arden: version 2.5;; + version: 6.00;; + institution: RPM, Sample Document Called MLM;; + author: Rick Mansour with addition from Steve Abel;; + specialist: ;; + date: 2010-11-03;; + validation: testing;; + +library: + purpose: Demonstrate the ability to identify the current Observation in a structured + document and instantiate the parameter. + ;; + explanation: This is your basic starter mlms for all standard document mlms. + + ;; + keywords: RTF, Document Called MLM , list, multi-select + ;; +knowledge: + type: data-driven;; + data: + (this_documentCommunication, + parameter_name,newValue, + sugg_txt_value,UpdateType) := argument; + /*******************Make Changes To Spelling And Flags In This Section******************/ + + /* Set to true if a decision.log is needed.*/ + log_execution_info := false; + /* Create variable for tab*/ +// TAB := 9 formatted with "%c" ; + /***************************************************************************************/ + + //*** Variable and Constant Declaration ***// + + (this_structuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (this_parameters) := this_structuredNoteDoc.ParametersList; + (this_chartedObservationsList) := this_structuredNoteDoc.ChartedObservationsList; + + // if the parameter type is a text and the observation already exist the new data may be a + // Replace of Append to current valueObj.Value + if not exists UpdateType OR UpdateType NOT IN("Append","Replace") then + UpdateType := "Replace"; + endif; + +///////////////////////////////////////////////////////////////////////////////////////////////// + //*** Data Structures ***// + //The following data structures can be used to create new objects within the MLM itself. + //Not all data structures are represented here, only ones that can be created in the MLM. + // Parameter Types + NUMERICVALUE := "NumericValue"; + FREETEXTVALUE := "FreeTextValue"; + LISTVALUE := "ListValue"; + LISTSETVALUE := "ListSetValue"; + DATEVALUE := "DateValue"; + IOVALUE := "IOValue" ; + GENERICDRIPVALUE := "GenericDripValue" ; + DRIPVALUE := "DripValue" ; + + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj]; + ListValueType := OBJECT [ListGUID,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + DateValueType := OBJECT [Value]; + FreeTextValueType := OBJECT [Value]; + NumericValueType := OBJECT [Value]; + // +// This section of code will demonstrate how to write to FreeTextValue, DateValue,NumericValue +// and ListValue +parameter := FIRST OF (this_Parameters WHERE this_Parameters.Name = parameter_name ); +IF EXISTS parameter THEN + + //*************************************************************************************** + // Check for existing object + //*************************************************************************************** + obs := first of(this_ChartedObservationsList + WHERE this_ChartedObservationsList.parameterGUID = parameter.parameterGUID) ; + if not exist obs then + //Create a new Observation for the list + obs := NEW ObservationType; + obs.ClientDocumentGUID := + this_documentCommunication.DocumentConfigurationObj.ClientDocumentGUID; + obs.ParameterGUID := parameter.ParameterGUID; + obs.DataType := parameter.DataType; + // Based on the parameter.DataType create the ValueObj Type and set the + // valueObj.value for (FREETEXTVALUETYPE,DATEVALUETYPE,NUMERICVALUETYPE) + // If the DataType is LISTVALUE then creat the valueObj of LISTVALUETYPE + // ABD ASSIGN THE paramter.configurationObj.ListGUID + if parameter.DataType = FREETEXTVALUE then + obs.ValueObj := NEW FreeTextValueType ; + elseif parameter.DataType = DATEVALUE then + obs.ValueObj := NEW DateValueType ; + elseif parameter.DataType = NUMERICVALUE then + obs.ValueObj := NEW NumericValueType ; + elseif parameter.DataType = LISTVALUE then + obs.ValueObj := NEW ListValueType; + obs.ValueObj.ListGUID := parameter.ConfigurationObj.ListGUID; + endif; // if parameter.DataType = FREETEXTVALUE then + // APPEND obs to the ChartedObservationsList + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList + := (this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, + obs); + endif; + if parameter.DataType = FREETEXTVALUE AND UpdateType = "Append" then + if length of obs.ValueObj.Value > 0 then + obs.ValueObj.Value := obs.ValueObj.Value || "\n" || newValue ; + else + obs.ValueObj.Value := newValue ; + endif; + + elseif parameter.DataType = FREETEXTVALUE AND UpdateType = "Replace" then + + obs.ValueObj.Value := newValue ; + + elseif parameter.DataType IN(DATEVALUE,NUMERICVALUE) then + if exists newValue then // new code added by Stve Abel from Roswell Park + obs.ValueObj.Value := newValue ; + else + obs.ValueObj := null; + endif; + // obs.ValueObj.Value := newValue; This was the code before Steve Abel addition + + elseif parameter.DataType = LISTVALUE then + //Populate the ListItemsList in the new observation object (obs) + // loop through each item in the parameter.ConfugurationObj.ListItemsList using + // "item"and append the item to the newly created object ListValueListItemType + // assign the item.listItemGUID to the selectedItem.ListItemGUID, the Item.value + // to the selectedItem.Value and set the SelectedItem.IsSelected := true + listItems := (); + FOR item IN parameter.ConfigurationObj.ListItemsList DO + IF item.Value IN newValue THEN + //Create a list item object for the selected list item + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := true; + // Arden list append statement appending the new object to the listItems + // object of the ListValueListItemType Object + listItems := (listItems, selectedItem); + ENDIF; + // set the obs.valueObj.ListItemsList := listItems list object + Obs.ValueObj.ListItemsList := listItems; + if exists sugg_txt_value then + obs.ValueObj.SuggestedTextValue := sugg_txt_value ; + endif ; + ENDDO; + endif; //if parameter.DataType = LISTVALUE then + + ENDIF; //IF EXISTS parameter THEN + +///////////////////////////////////////////////////////////////////////////////////////////////// + + ;; + evoke: + ;; + logic: + conclude true; + ;; + action: + return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/CLINSUM/CLINSUM_COMMENT_INFO.mlm b/MLMStripper/bin/Debug/CLINSUM/CLINSUM_COMMENT_INFO.mlm new file mode 100644 index 0000000..116b7ee --- /dev/null +++ b/MLMStripper/bin/Debug/CLINSUM/CLINSUM_COMMENT_INFO.mlm @@ -0,0 +1,97 @@ +maintenance: + + title: CLINSUM_COMMENT_INFO ;; + mlmname: CLINSUM_COMMENT_INFO ;; + arden: version 2.5;; + version: 1.00;; + institution: St. Clair Hospital ;; + author: Shivprasad Jadhav ;; + specialist: Shivprasad Jadhav , Allscripts;; + date: 2015-07-14;; + validation: testing;; + +library: + purpose: + Populate a Clinical Summary Tile for Comment Value as a Significant Indicator ;; + explanation: + Change history + + 07-14.2014 DW CSR# 32230 Created By GOS for Comment for Resist Organism Value in Clinical Summary Chart + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + (session_id, user_GUID, client_GUID, chart_GUID, visit_GUID, from_date, to_date) := argument; + + if called_by_editor then + client_GUID:= read last{ClientInfo:GUID}; + visit_GUID:= read last{ClientVisit:GUID}; + chart_GUID:= read last{ClientVisit:ChartGUID}; + endif; + + // Column definition. More column properties may be added. Any changes to the defintion must be reflected in MLM STD_FUNC_CLINSUM_TRANSLATE. + + colDefinition_def := object + [ + FieldName, // The name of the field in the data row that contains the column{{{SINGLE-QUOTE}}}s value + ColumnHeader, // The text for the column header + DisplaySeqNum, // left-to-right sequence number in which to display the column + DataType, // The .net type name of the value + DisplayFormat, // format string to apply to the column + WidthDefaultPixel, // default width of the column, in pixels + WidthMinPixel, // Min width of the column, in pixels + WidthMaxPixel, // Max width of the column, in pixels + IsVisible, // Is the column visible + IsSortable // Is the column sortable + ]; + + // Use column definition to define a row. Used by C# code to create the grid + + rowDefinition_obj:= (new colDefinition_def with "TypeCode", "Type",0, "String", "", 50, 20, 50, true, false ), + (new colDefinition_def with "Text", "Comments", 1, "String", "", 50, 20, 50, true, false ), + (new colDefinition_def with "TouchedWhen", "Entered Date", 2, "String", "", 50, 20, 50, true, false ) + ; + rowValue_def := OBJECT [TypeCode,Text,TouchedWhen]; + + // Populate the row with data. + + + + rows_obj :=(); + TypeCode1,Text1,TouchedWhen1 := read first { " Select cd.TypeCode, cd.Text, cd.TouchedWhen " + || " from CV3CommentDeclaration cd " + || " Where cd.ClientGUID = " || Sql(client_GUID) + || " And cd.TypeCode = {{{SINGLE-QUOTE}}}Resist Organism{{{SINGLE-QUOTE}}} " + || " And cd.Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " }; + + singleRow_obj := new rowValue_def; + singleRow_obj.TypeCode := TypeCode1 ;//AS STRING); + singleRow_obj.Text := (Text1 AS STRING); + singleRow_obj.TouchedWhen := (TouchedWhen1 AS STRING); + + rows_obj := rows_obj || singleRow_obj; + + + // Once the rows have been defined & populated this MLM Function will tranlate the OBJECT(s) + // into CDSDataObjects which can be read by the C# code that called this MLM. + + translator := MLM {{{SINGLE-QUOTE}}}STD_FUNC_CLINSUM_TRANSLATE{{{SINGLE-QUOTE}}}; + (rowDefintion_dataObj, rows_dataObj) := call translator with rowDefinition_obj, singleRow_obj ; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: + conclude true; + ;; + action: + return rowDefintion_dataObj, rows_dataObj; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/CLINSUM/CLINSUM_STATUS_BOARD_STATUS_TIMES.mlm b/MLMStripper/bin/Debug/CLINSUM/CLINSUM_STATUS_BOARD_STATUS_TIMES.mlm new file mode 100644 index 0000000..f64255b --- /dev/null +++ b/MLMStripper/bin/Debug/CLINSUM/CLINSUM_STATUS_BOARD_STATUS_TIMES.mlm @@ -0,0 +1,99 @@ +maintenance: + + title: CLINSUM_STATUS_BOARD_STATUS_TIMES ;; + mlmname: CLINSUM_STATUS_BOARD_STATUS_TIMES ;; + arden: version 2.5;; + version: 1.00;; + institution: ;; + author: Amanda Kirsopp ;; + specialist: Don Warnick ;; + date: 2013-06-07;; + validation: testing;; + +library: + purpose: + Populate a Clinical Summary Tile for ED Status Board Status times. To be used by the MR Coders + ;; + explanation: + Change history + + 11.28.2012 DW CSR# 31622 Created for Quality Blue requirement + 04.02.2014 DW CSR# 32326 Remove TBADM from the Medical Records Clinical Summary Tab + 05.03.2018 JML CSR# 36699 Added column "Updated By Provider" to display user who updated status on board. + 06.06.2018 DW CSR# 36857 Add PEIP to the Medical Records Clinical Summary Tab (go forward name of TIP) + 07.02.2018 DW CSR# 36891 Add credentials to the name of the physician displayed in the tile + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + (session_id, user_GUID, client_GUID, chart_GUID, visit_GUID, from_date, to_date) := argument; + + if called_by_editor then + client_GUID:= read last{ClientInfo:GUID}; + visit_GUID:= read last{ClientVisit:GUID}; + chart_GUID:= read last{ClientVisit:ChartGUID}; + endif; + + // Column definition. More column properties may be added. Any changes to the defintion must be reflected in MLM STD_FUNC_CLINSUM_TRANSLATE. + + colDefinition_def := object + [ + FieldName, // The name of the field in the data row that contains the column{{{SINGLE-QUOTE}}}s value + ColumnHeader, // The text for the column header + DisplaySeqNum, // left-to-right sequence number in which to display the column + DataType, // The .net type name of the value + DisplayFormat, // format string to apply to the column + WidthDefaultPixel, // default width of the column, in pixels + WidthMinPixel, // Min width of the column, in pixels + WidthMaxPixel, // Max width of the column, in pixels + IsVisible, // Is the column visible + IsSortable // Is the column sortable + ]; + + // Use column definition to define a row. Used by C# code to create the grid + + rowDefinition_obj:= (new colDefinition_def with "ScheduledDtm", "Time",0, "DateTime", "", 120, 120, 120, true, true ), + (new colDefinition_def with "OrderName", "Status", 1, "String", "", 180, 180, 180, true, true ), + (new colDefinition_def with "TouchedBy", "Updated By Provider", 2, "String", "", 200, 200, 200, true, true ) + ; + rowValue_def := OBJECT [ScheduledDtm,OrderName,TouchedBy]; + + // Populate the row with data. + + rows_obj :=(); + singleRow_obj:= read as rowValue_def { " SET CONCAT_NULL_YIELDS_NULL off select a.touchedwhen, " + || " case when a.columnnewvalue = {{{SINGLE-QUOTE}}}tip{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}Provider Exam in Progress{{{SINGLE-QUOTE}}} " + || " when a.columnnewvalue = {{{SINGLE-QUOTE}}}peip{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}Provider Exam in Progress{{{SINGLE-QUOTE}}} " + || " when a.columnnewvalue = {{{SINGLE-QUOTE}}}tbaor{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}To be Admitted Orders Received{{{SINGLE-QUOTE}}} end " + || " , (SELECT u.DisplayName + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + u.occupationcode FROM CV3USER u WHERE u.IDCode = RIGHT( a.TouchedBy, ( LEN(a.TOUCHEDBY) - CHARINDEX({{{SINGLE-QUOTE}}}_{{{SINGLE-QUOTE}}}, a.TouchedBy) ) ) ) " + || " from sxaedlocationaudit a (nolock) " + || " join cv3location l on l.guid = a.locationguid " + || " where a.clientvisitguid = " || sql(visit_GUID) + || " and a.columnnewvalue in ({{{SINGLE-QUOTE}}}tip{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}peip{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}tbaor{{{SINGLE-QUOTE}}}) " + || " and l.code like {{{SINGLE-QUOTE}}}%|ED %{{{SINGLE-QUOTE}}} order by a.touchedwhen " + }; + rows_obj := singleRow_obj; + + // Once the rows have been defined & populated this MLM Function will tranlate the OBJECT(s) + // into CDSDataObjects which can be read by the C# code that called this MLM. + + translator := MLM {{{SINGLE-QUOTE}}}STD_FUNC_CLINSUM_TRANSLATE{{{SINGLE-QUOTE}}}; + (rowDefintion_dataObj, rows_dataObj) := call translator with rowDefinition_obj, rows_obj + + ;; + priority: 50 + ;; + evoke: + ;; + logic: + conclude true; + ;; + action: + return rowDefintion_dataObj, rows_dataObj; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_ACS_DOM_PE_ALL_DEFAULTS.mlm b/MLMStripper/bin/Debug/DOC/DOC_ACS_DOM_PE_ALL_DEFAULTS.mlm new file mode 100644 index 0000000..068718b --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_ACS_DOM_PE_ALL_DEFAULTS.mlm @@ -0,0 +1,404 @@ +maintenance: + + title: DOC_ACS_DOM_PE_All_Defaults ;; + mlmname: DOC_ACS_DOM_PE_All_Defaults ;; + arden: version 2.5;; + version: 5.50;; + institution: RPM, Sample ;; + author: Rick Mansour ;; + specialist: Allscripts Custom Services;; + date: 2011-10-08 ;; + validation: testing;; + +library: + purpose: Uses a select restricted list to populate a Physical exam. + + + Change history + + 20111116 ACS: Edited for St. Clair and 5.5 + + 09.04.2012 CSR# 30963 DW Prism Enhancements - Add a new PE (Newborn) + + 10.16.2012 Added check for Active records ONLY in the SQL Query (CV3FlowsheetVersion and CV3ObservationEntryItem) + that retrieves all default normal values + for Physical Exam sections; this was a code correction based on default normals not populating + for "Skin","HEENT", etc. observations. + + + ;; + explanation: This mlm is to use with a physical examination. + * This mlm calls the following MLMs: + - Called_RPM_DOM_Get_Definition_MLM and + - STD_DOC_FUNC_CHART_OBSERVATION_HELPER_JAB + * Negative inserts the structured note defaults + * Copy last inserts the last value for this Parameter/Observation from the most recent + document of this name. + * Copy my last inserts the last value for the Parameter/Observation in a any document + authored by the current user + * If any above returns null or the selected item is "not examined" or "clear" then the + valueObj is set to null which erases the value in the observation on the form. + + This mlm uses a naming convention. The example is + current_parameter_name := "rpm_pe_constitutional_st" ;//LISTVALUE type of parameter. + target_parameter_DisplayName := "rpm_pe_constitutional"; //TEXTVALUE type of parameter + + After the list is clicked, it becomes the current parameter and the follwoing code + finds the paired "target_parameter": + len_current_parameter_name := length of current_parameter_name ; + target_parameter_name := substring (len_current_parameter_name-3) characters + starting at 1 from current_parameter_name ; + + This mlm sends the this_documentCommunicaiton to + Called_RPM_DOM_Get_Definition_MLM + and gets back the values of all of the important attributes of the object + + This mlm calls the STD_DOC_FUNC_CHART_OBSERVATION_HELPER_JAB in order to write + to the note when charting an observation with the mlm. + ;; + keywords: RTF, Document Called MLM , list, multi-select + ;; +knowledge: + type: data-driven;; + data: + (this_documentCommunication) := argument; + /*******************Make Changes To Spelling And Flags In This Section******************/ + // This code BELOW is sample code and should be changed for all new mlms + /* Set to true if a decision.log is needed.*/ + log_execution_info := false; + + // The MLM will display the diagnosticMessage Varaible if the + // displayMessageFlag is set to TRUE + displayMessageFlag := false ; + + // observation names of the GLOBAL default choices + major_default_obs_names := ( "SCH_MDPN_PE_nl", "SCH_MDPN_PE_my nl", + "SCH_MDPN_PE_my last", "SCH_MDPN_PE_save"); + + // Observation names of the LIST iteems (radio buttons) for setting individual findings + pe_list_st:= + ("SCH_MDPN_PE_Gen", + "SCH_MDPN_PE_Mental Status", + "SCH_MDPN_PE_ENMT", + "SCH_MDPN_PE_Cardio", + "SCH_MDPN_PE_Resp", + "SCH_MDPN_PE_Gastro", + "SCH_MDPN_PE_GU", + "SCH_MDPN_PE_Neuro", + "SCH_MDPN_PE_Musculo", + "SCH_MDPN_PE_Rectal", + "SCH_MDPN_PE_Skin", + "SCH_MDPN_PE_Vascul", + "SCH_MDPN_PE_Newborn" + ); + +/* ("rpm_pe_Respiratory_st", + "rpm_pe_Constitutional_st", + "rpm_pe_CVS_Heart_st", + "rpm_pe_Skin_st", + "rpm_pe_Abdomen_st", + "rpm_pe_Psychiatric_st", + "rpm_pe_Eyes_st", + "rpm_pe_ENMT_st", + "rpm_pe_CVS_Pulses_st", + "rpm_pe_Lymphatic_st", + "rpm_pe_Musculoskeletal_st", + "rpm_pe_Neurologic_st", + "rpm_pe_Edema_Varicosities_st", + "rpm_pe_Neck_Thyroid_st"); +*/ + // Observation names of the TEXT items (to be written to) + // These should correspond, respectively to the LIST item observations, above + pe_list:= + ("SCH_MDPN_PE General", + "SCH_MDPN_PE Mental Status", + "SCH_MDPN_PE ENMT", + "SCH_MDPN_PE Cardiovascular", + "SCH_MDPN_PE Respiratory", + "SCH_MDPN_PE Gastro", + "SCH_MDPN_PE GU", + "SCH_MDPN_PE Neuro", + "SCH_MDPN_PE Musculoskeletal", + "SCH_MDPN_PE Rectal", + "SCH_MDPN_PE Skin", + "SCH_MDPN_PE Vascular", + "SCH_MDPN_PE Newborn" + ); + +/* ("rpm_pe_Respiratory", + "rpm_pe_Constitutional", + "rpm_pe_CVS_Heart", + "rpm_pe_Skin", + "rpm_pe_Abdomen", + "rpm_pe_Psychiatric", + "rpm_pe_Eyes", + "rpm_pe_ENMT", + "rpm_pe_CVS_Pulses", + "rpm_pe_Lymphatic", + "rpm_pe_Musculoskeletal", + "rpm_pe_Neurologic", + "rpm_pe_Edema_Varicosities", + "rpm_pe_Neck_Thyroid"); +*/ + // This is the only part of this mlms that you will need to change! + + /******************************END of Changes********************************************/ + + //Section 1 Variable and Constant Declaration DO NOT CHANGE THIS SECTION !!!!!!!!!!!!!!! + // Variable declarations + WriteToNote_MLM := MLM {{{SINGLE-QUOTE}}}STD_DOC_FUNC_CHART_OBSERVATION_HELPER_JAB{{{SINGLE-QUOTE}}}; //{{{SINGLE-QUOTE}}}Called_RPM_DOM_MLM{{{SINGLE-QUOTE}}}; +// get_Object := MLM {{{SINGLE-QUOTE}}}CALLED_RETURN_OBJECT{{{SINGLE-QUOTE}}}; + Get_Variable_Values := MLM {{{SINGLE-QUOTE}}}Called_RPM_DOM_Get_Definition_MLM{{{SINGLE-QUOTE}}}; + + + // .Net assemblies need to be loaded for ObjectsPlus + standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + target_parameter_name := "" ; + target_list := (); + newValue:= "" ; +// sugg_txt_value:=""; + UpdateType := "Replace"; + + // Object needed to declare in the calling the above MLM (for listitems only) + SelectedList := OBJECT[ ListGUID, SelectedValues, SuggestiveText]; + // Create the new selection list object for selection + PN_sel_list := NEW SelectedList; + + // this mlm will assign values to the document objects. + (this_documentCommunication, + client_guid, client_visit_guid, client_chart_guid, + user_guid, document_type, document_name, + event_type, configuration_guid, this_currentObj, + CancelEventFlag, this_structuredNoteDoc, authored_date_time, + authored_by_guid, client_document_guid, document_date_time, + isNewFlag, isIncompleteFlag, isResultsPendingFlag, + isPriorityFlag, this_parameters, this_chartedObservationsList, + this_parameters_display_name, current_parameter, + current_parameter_name, current_parameter_guid, current_parameter_DataType, + selectedItems, selectedItems_value, current_value, + diagnosticMessage, displayMessageFlag2, CoSigner1, + CoSigner2, DocumentTopic) + := CALL Get_Variable_Values WITH (this_documentCommunication); + //Variable and Constant Declaration + //DO NOT CHANGE THE ABOVE SEQUENCE. IT MATCHES THE SEQUENCE IN THE CALLED MLM !!!!!!!!! // + + if called_by_editor then + target_parameter_name := "" ; + current_parameter_name := "SCH_MDPN_PE_Gen"; + document_name := "Physician Progress Note"; + current_value := "my last"; //"normal"; + newValue:= "" ; + user_guid := "8000001053119001"; //(peggy karish) + (client_guid, client_chart_guid, client_visit_guid):= read last + {ClientVisit: ClientGUID, ChartGUID, GUID}; + endif; //if called_by_editor then + + // In this section of the MLM the newValue should be determined through logic + // or SQL retrieved data or calling another mlm for the return value + + // get the target_parameter_name and target_parameter_DisplayName + (PCDocGUID) := this_structuredNoteDoc.PatientCareDocumentGUID ; + if not exists client_document_guid then + client_document_guid := 0 ; + endif ; + +// len_current_parameter_name := length of current_parameter_name ; + target_param_root := "SCH_MDPN_PE "; + len_tpr := length of target_param_root; + len_cpn:= length of current_parameter_name; + len_diff_tpr_cpn := len_cpn - len_tpr; + if len_diff_tpr_cpn < 3 then + str_span := len_diff_tpr_cpn; + else + str_span := 3; + endif; +// target_parameter_name := substring (len_current_parameter_name-3) characters +// starting at 1 from current_parameter_name ; + target_parameter_name := target_param_root || (substring str_span characters + starting at (len_tpr + 1) from current_parameter_name) || "%" ; + //target_parameter := first of (this_Parameters + // WHERE this_Parameters.Name = target_parameter_name) ; + + targetObject := first of (this_parameters where this_parameters.name = + target_parameter_name); +// targetObject := CALL get_Object WITH (this_documentCommunication,target_parameter_name) ; + target_parameter_DisplayName := targetObject.DisplayName ; + + if any(PE_list matches pattern target_parameter_name) then + target_parameter_name := first (PE_list + where it matches pattern target_parameter_name); + target_list := , target_parameter_name; + elseif current_parameter_name is in major_default_obs_names then + target_list := (PE_list) ; + endif; + + FOR target_parameter_name IN(target_list) DO + + if current_value IN( "Negative+", "my normal") then +// sugg_txt_value:= "" ; +// UpdateType:= "Replace" ; // either "Replace" or "Append" + newValue:= read last + { " SELECT UserSpecificDefault " + || " FROM ACS_PE_UserDefaults " + || " WHERE UserGUID = " || sql(user_guid) + || " AND OCMI_ObservationName = " || sql(target_parameter_name) + || " AND Active = 1 " + }; + + elseif current_value IN( "Negative", "normal") then +// sugg_txt_value:= "" ; +// UpdateType:= "Replace" ; // either "Replace" or "Append" + newValue:= read last + { " SELECT FSVI.SpecificDefault " + || " FROM CV3PatientCareDocument PCD " + || " JOIN CV3FlowsheetVersion FSV " + || " ON FSV.FlowsheetGUID = PCD.KTreeRootGUID " + || " JOIN CV3FlowsheetVersionItem FSVI " + || " ON FSVI.VersionGUID = FSV.GUID " + || " JOIN CV3ObservationEntryItem OEI " + || " ON OEI.GUID = FSVI.ObsEntryItemGUID " + || " JOIN CV3ObsCatalogMasterItem OCMI " + || " ON OCMI.GUID = OEI.ObsMasterItemGUID " + || " WHERE PCD.GUID = " || PCDocGUID + || " AND OCMI.Name = " || sql(target_parameter_name) + || " AND FSVI.Active = 1" //JML: 10.16.2012 code correction (see history above) + || " AND OEI.Active = 1" //JML: 10.16.2012 code correction (see history above) + }; + + elseif current_value IN ("copy last", "last") then + // sugg_txt_value:= "" ; +// UpdateType:= "Replace" ; // either "Replace" or "Append" + newValue:= read last + { " SELECT TOP 1 Obs.ValueText " + || " FROM CV3ClientDocument CD " + || " JOIN SXACDObservationParameter sp " //this is the new table in 5.5 + || " ON CD.ClientGUID = sp.ClientGUID " + || " and CD.ChartGUID = sp.ChartGUID " + || " and sp.OwnerGUID = cd.guid " //IMPORTANT limiter condition! + || " and CD.PatCareDocGUID = sp.PatCareDocGUID " + || " JOIN CV3Observation Obs " + || " ON sp.ObservationGUID = Obs.GUID " + || " JOIN CV3ObsCatalogMasterItem OCMI " + || " ON OCMI.GUID = sp.ObsMasterItemGUID " + || " WHERE CD.ClientGUID = " || sql(client_guid) + || " AND cd.DocumentName like ({{{SINGLE-QUOTE}}}%{{{SINGLE-QUOTE}}} + " || sql( Document_Name ) || " + {{{SINGLE-QUOTE}}}%{{{SINGLE-QUOTE}}})" + || " AND OCMI.Name = " || sql(target_parameter_name) + || " AND CD.GUID <> " || sql(client_document_guid) + || " ORDER BY CD.Entered DESC " + }; + + elseif current_value IN("copy my last","my last") then +// sugg_txt_value:= "" ; +// UpdateType:= "Replace" ; // either "Replace" or "Append" + newValue:= read last + { " SELECT TOP 1 Obs.ValueText " + || " FROM CV3ClientDocument CD " + || " JOIN SXACDObservationParameter sp " //this is the new table in 5.5 + || " ON CD.ClientGUID = sp.ClientGUID " + || " and CD.ChartGUID = sp.ChartGUID " + || " and sp.OwnerGUID = cd.guid " //IMPORTANT limiter condition! + || " and CD.PatCareDocGUID = sp.PatCareDocGUID " + || " JOIN CV3Observation Obs " + || " ON sp.ObservationGUID = Obs.GUID " + || " JOIN CV3ObsCatalogMasterItem OCMI " + || " ON OCMI.GUID = sp.ObsMasterItemGUID " + || " WHERE CD.ClientGUID = " || sql(client_guid) + || " AND CD.AuthoredProviderGUID = " || sql(user_guid) + || " AND OCMI.Name = " || sql(target_parameter_name) + || " AND CD.GUID <> " || sql(client_document_guid) + || " ORDER BY CD.Entered DESC " + }; + endif; + + if (current_value IN ("my last") AND not exist newValue) + or (current_value = "clear") then + newValue := ""; // no old value found, replace with blank + endif; + //SET OBS TEXT VALUES////////////////////////////////////////////////////////////////// + if exists target_parameter_name and exists newValue then + this_documentCommunication := CALL WriteToNote_MLM + WITH (this_documentCommunication, target_parameter_name, +// newValue, sugg_txt_value,UpdateType); + (newValue, UpdateType)); + endif ; + ENDDO; + //SET OBS LIST VALUES////////////////////////////////////////////////////////////////////// + // Set the non-selected radion button list values + + // Set the non-chosen GLOBAL list values to {{{SINGLE-QUOTE}}}isselected = false{{{SINGLE-QUOTE}}} + other_param_names := major_default_obs_names where it <> current_parameter_name; + newValue:=""; +// sugg_txt_value:=""; + PN_sel_list.SelectedValues := , newvalue; //value to select + PN_sel_list.SuggestiveText := null; //optional text +// UpdateType:="Replace"; + FOR target_parameter_name IN(other_param_names) DO // LIST Values + if exists target_parameter_name and exists newValue then // Set the LIST values + target_param := first of (this_parameters + where this_parameters.name = target_parameter_name); + target_config_obj := target_param.ConfigurationObj; + // create the selection list for helper MLM + PN_sel_list.ListGUID := target_config_obj.listguid; + // SELECT THE RADIO BUTTON(s) + this_documentCommunication := CALL WriteToNote_MLM + WITH (this_documentCommunication, target_parameter_name, + PN_sel_list); +// newValue, sugg_txt_value, UpdateType); + endif ; + ENDDO; // target_parameter_name IN(other_param_names) + + // Set the INDIVIDUAL list values to match the global list choice + if current_parameter_name is in major_default_obs_names then + newValue:= current_value ; + PN_sel_list.SelectedValues := , newvalue; //value to select + PN_sel_list.SuggestiveText := null; //optional text + FOR target_parameter_name IN (PE_List_st) DO // LIST Values + if exists target_parameter_name and exists newValue then // Set the LIST values + target_param := first of (this_parameters + where this_parameters.name = target_parameter_name); + target_config_obj := target_param.ConfigurationObj; + // create the selection list for helper MLM + PN_sel_list.ListGUID := target_config_obj.listguid; + // SELECT THE RADIO BUTTON(s) + this_documentCommunication := CALL WriteToNote_MLM + WITH (this_documentCommunication, target_parameter_name, + PN_sel_list); +// newValue, sugg_txt_value, UpdateType); + endif ; // target_parameter_name IN(PE_List_st) + ENDDO; + endif; // current_parameter_name is in major_default_obs_names + + ////////////////////////////////////////////////////////////////////////////////////////// + // If the state of the isIncomplete, isPriority and isResultsPending + // need to be changed in the note + // set one or more of these flags := TRUE + // isIncompleteFlag := TRUE ; + // isResultsPendingFlag := TRUE ; + // isPriorityFlag := TRUE ; + + // This code sets the checkboxes to checked or unchecked. + // DO NOT CHANGE THIS CODE BELOW + this_structuredNoteDoc.IsIncomplete := isIncompleteFlag ; + this_structuredNoteDoc.IsResultsPending := isResultsPendingFlag ; + this_structuredNoteDoc.IsPriority := isPriorityFlag ; + // ThE ABOVE code sets the checkboxes to checked or unchecked. + // DO NOT CHANGE THIS CODE ABOVE + + // The code below will display the diagnosticMessage Varaible if the + // displayMessageFlag is set to TRUE displayMesssaageFlag:=TRUE; + this_documentCommunication.DisplayMessage := displayMessageFlag; + this_documentCommunication.Message := "Diagnostic Message : " + ||diagnosticMessage || "\n\nTargetObject\n\n" || targetObject || ""; + ////////////////////////////////////////////////////////////////////////////////////////// + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_ACS_DOM_SET_USER_DEFAULTS.mlm b/MLMStripper/bin/Debug/DOC/DOC_ACS_DOM_SET_USER_DEFAULTS.mlm new file mode 100644 index 0000000..897d8cd --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_ACS_DOM_SET_USER_DEFAULTS.mlm @@ -0,0 +1,166 @@ +maintenance: + + title: DOC_ACS_DOM_Set_User_Defaults ;; + mlmname: DOC_ACS_DOM_Set_User_Defaults ;; + arden: version 2.5;; + version: 5.50;; + institution: St. Clair ;; + author: Rick Mansour ;; + specialist: Allscripts Custom Services;; + date: 2011-10-09 ;; + validation: testing;; + +library: + purpose: Uses a select restricted list to populate a Physical exam. + ;; + explanation: This mlm is to use with a physical examination. + This mlm set UserDefaultSpecific filed values + + + Change history + + 20111117 ACS : changed for St. Clair and SQL performance + + 09.04.2012 CSR# 30963 DW Prism Enhancements - Add a new PE (Newborn) + + + This MLM uses a custom table with the following schema: + + CREATE TABLE [dbo].[ACS_PE_UserDefaults]( + [UserGUID] [dbo].[HVCIDdt] NOT NULL, + [OCMI_ObservationName] [varchar](200) NOT NULL, + [PatCareDocName] [varchar](200) NOT NULL, + [UserSpecificDefault] [varchar](2000) NOT NULL, + [CreatedWhen] [datetime] NOT NULL, + [TouchedWhen] [datetime] NOT NULL, + [Active] [bit] NOT NULL CONSTRAINT [DF_rpmCDUserDefaults_Active] DEFAULT ((0)) + ) ON [PRIMARY] + CREATE UNIQUE CLUSTERED INDEX ACS_PE_UD_INDX on + ACS_PE_UserDefaults (userguid, PatCareDocName, ocmi_observationname) + ;; + keywords: RTF, Document Called MLM , list, multi-select + ;; +knowledge: + type: data-driven;; + data: + (this_documentCommunication) := argument; + /*******************Make Changes To Spelling And Flags In This Section******************/ + + // Set to true if a decision.log is needed. + log_execution_info := false; + + //This is the only part of this mlms that you will need to change + default_parameter_list := + ("SCH_MDPN_PE General", + "SCH_MDPN_PE Mental Status", + "SCH_MDPN_PE ENMT", + "SCH_MDPN_PE Cardiovascular", + "SCH_MDPN_PE Respiratory", + "SCH_MDPN_PE Gastro", + "SCH_MDPN_PE GU", + "SCH_MDPN_PE Neuro", + "SCH_MDPN_PE Musculoskeletal", + "SCH_MDPN_PE Rectal", + "SCH_MDPN_PE Skin", + "SCH_MDPN_PE Vascular", + "SCH_MDPN_PE Newborn" + ); + /* + ("rpm_pe_constitutional","rpm_pe_eyes","rpm_pe_ENMT", + "rpm_pe_neck_thyroid","rpm_pe_CVS_Heart","rpm_pe_CVS_Pulses", + "rpm_pe_Abdomen","rpm_pe_Breast","rpm_pe_Edema_Varicosities", + "rpm_pe_Neurologic","rpm_pe_Musculoskeletal","rpm_pe_Skin", + "rpm_pe_Lymphatic","rpm_pe_Psychiatric","rpm_pe_Respiratory" + ); +*/ + /**********************************END OF CHANGES****************************************/ + //Section 1 Variable and Constant Declaration + Get_Variable_Values := MLM {{{SINGLE-QUOTE}}}Called_RPM_DOM_Get_Definition_MLM{{{SINGLE-QUOTE}}}; + + //Variable and Constant Declaration + sql_insert_list := (); + + // DO NOT CHANGE THIS SECTION !!!!!!!!!!!!!! // + // this mlm will assign values to the document objects. + (this_documentCommunication, + client_guid, client_visit_guid, client_chart_guid, + user_guid, document_type, document_name, + event_type, configuration_guid, this_currentObj, + CancelEventFlag, this_structuredNoteDoc, authored_date_time, + authored_by_guid, client_document_guid, document_date_time, + isNewFlag, isIncompleteFlag, isResultsPendingFlag, + isPriorityFlag, this_parameters, this_chartedObservationsList, + this_parameters_display_name, current_parameter, + current_parameter_name, current_parameter_guid, current_parameter_DataType, + selectedItems, selectedItems_value, current_value, + diagnosticMessage, displayMessageFlag, CoSigner1, + CoSigner2, DocumentTopic) + := CALL Get_Variable_Values WITH (this_documentCommunication); + //DO NOT CHANGE THE ABOVE SEQUENCE. IT MATCHES THE SEQUENCE IN THE CALLED MLM !!!!!!!! // + + if called_by_editor then + current_value := "save defaults"; + client_guid := read last {ClientInfo: GUID}; + user_guid := read last {userinfo: guid}; + document_name := "PN doc"; + sql_insert_list := + "(" || sql(user_guid) || ", {{{SINGLE-QUOTE}}}general{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}PN doc{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}gen nl.{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}1-1-2012{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}1-1-2013{{{SINGLE-QUOTE}}}, 1)", + "(" || sql(user_guid) || ", {{{SINGLE-QUOTE}}}neuro{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}PN doc{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}crazy{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}1-1-2014{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}1-1-2015{{{SINGLE-QUOTE}}}, 2)" + ; + current_parameter_name := "SCH_MDPN_PE General"; // "rpm_pe_constitutional" ; + endif; + + if current_value is in ("save", "save defaults") then + FOR system_name IN default_parameter_list DO + save_parameter:= first of (this_parameters + WHERE this_parameters.Name = system_name) ; + if exists save_parameter then + save_parameterObs := first of (this_ChartedObservationsList WHERE + this_ChartedObservationsList.parameterGUID = save_parameter.parameterGUID); + if exists save_parameterObs and save_parameterObs.valueObj.value <> "" then + new_SpecificDefault := save_parameterObs.valueObj.value ; + + sql_insert_list := sql_insert_list, + "(" || sql(user_guid) || "," + || sql(system_name) || "," + || sql(document_name) || "," + || sql(new_SpecificDefault) || "," + || sql(NOW) || "," + || sql(NOW) || ",1)" ; + endif; + endif; + ENDDO; + delete_default:= read last + { " DELETE FROM ACS_PE_UserDefaults " + || " WHERE UserGUID = " || sql(user_guid) + || " AND PatCareDocName = " || sql(document_name) + }; + insert_default:= read last + { " INSERT INTO ACS_PE_UserDefaults " + || " (UserGUID,OCMI_ObservationName,PatCareDocName, " + || " UserSpecificDefault,CreatedWhen,TouchedWhen,Active) " + || " Values " || sql_insert_list + }; + ENDIF; + + sMessage := user_guid || "\n" || system_name || "\n" || document_name + || "\n" || new_SpecificDefault || "\n" || NOW + + ; + // this_documentCommunication.DisplayMessage := TRUE; + this_documentCommunication.Message := sMessage ; + + +////////////////////////////////////////////////////////////////////////////////////// + + ;; + evoke: + ;; + logic: + conclude true; + ;; + action: + return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_ACS_PROBLEM_ASSESSMENT_PLAN_REORDER.mlm b/MLMStripper/bin/Debug/DOC/DOC_ACS_PROBLEM_ASSESSMENT_PLAN_REORDER.mlm new file mode 100644 index 0000000..faaddd9 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_ACS_PROBLEM_ASSESSMENT_PLAN_REORDER.mlm @@ -0,0 +1,726 @@ +maintenance: + + title: DOC_ACS_Problem_Assessment_Plan_Reorder ;; + mlmname: DOC_ACS_Problem_Assessment_Plan_Reorder ;; + arden: version 2.5;; + version: 1.00;; + institution: RPM, Sample Document Called MLM;; + author: Your name ;; + specialist: ;; + date: 2010-12-31;; + validation: testing;; + +library: + purpose: Standardize the document mlm responsible for reordering problems and assessments + ;; + explanation: + + Change history + + 20101231 : Original MLM created by Dr. Mansour + 20110930 : updated by Allscripts Custom Services (ACS) + 20120109 : added button deselection per request (ACS) + 20120418: changed "ClientGUID like " to "ClientGUID =" in 2 places in the HI sql statement + + 08.27.2012 DW CSR# 30963 - Prism Enhancements - Copy last saved note from user with same discipline + 08.12.2013 DW CSR# 31472 - Add a Clear Plan button CSR#31743 - Create a Problem List Selector app + 03.19.2015 DW CSR# 32616 - Develop Application to allow for communication between clinical documentation specialist + 04.23.2015 DW CSR# 32359 - Physician Charging (appended the ICD Code to the visit problems imported into the A/P section) + 09.24.2015 DW CSR# 23359 - ICD10 + 09/14/2016 DW HD# 2198672- We found that the 08.27.2012 change above opened the SQL to pulling SNs and FSs that had no problems. I listed the documents that have problems + 07/31/2019 JML 18.4 Upgrade - Modified SQL so Copy Last function will work + + + ;; + keywords: RTF, Document Called MLM , list + ;; +knowledge: + type: data-driven;; + data: + + + (this_documentCommunication) := argument; + /*******************Make Changes To Spelling And Flags In This Section******************/ + + /* Set to true if a decision.log is needed.*/ + log_execution_info := false; + + // specifiy the count of problem/assessment-plan text fields, for iteration + count_prob_obs := 14; + + // assuming that all similar obs have been configured in the same way + // provide the root names of each + button_root := "SCH_MDPN_AP_Sort "; //"button_move_"; + problem_root:= "SCH_MDPN_Problem "; //"Problem_"; + ass_plan_root:= "SCH_MDPN_Assessment / Plans "; //"Assessment_Plan_"; + + // These variables are to handle the placeholder (tens place) in the obs names + // for the first nine named items (i.e. if "1" to "9" then placeholder is ""; + // if "01" to "09" then placeholder is "0"; + button_tens_placeholder := ""; + problem_tens_placeholder := ""; + ass_plan_tens_placeholder := "0"; + + // Observation containing copy problem list buttons: + copy_prob_buttons_obs := "SCH_MDPN_AP_Copy"; + + // specify the button mappings to SQL compatible lists of problem types: + // use "" (no single quotes) to specify copying from the recorded note + // NOTE: THE RELATIVE ORDER OF ITEMS MUST BE MAINTAINED WITHIN LISTS!!! + // MUST HAVE THE FOLLOWING ORDER FOR EACH ELEMENT ITEM: + // "BUTTON_NAME|{{{SINGLE-QUOTE}}}HEALTH_ISSUE_TYPE1{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}HEALTH_ISSUE_TYPE2{{{SINGLE-QUOTE}}},etc" + button_hi_map_list := + ( + "Copy Problem-Visit|{{{SINGLE-QUOTE}}}Problem-Visit{{{SINGLE-QUOTE}}}", + "Copy Problem-Proced|{{{SINGLE-QUOTE}}}Problem-Proced{{{SINGLE-QUOTE}}}", + "Copy Problem-Chronic|{{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}}", + "Copy All|{{{SINGLE-QUOTE}}}Problem-Visit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Proced{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}}", + "Copy last saved note|", + "Launch Problem Selector|Launch Problem Selector", + "Clear All|" + ); + + + /***************************************************************************************/ + + //Initialize MLM pointers: + str_parse := mlm {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; + WriteToNote_MLM := MLM {{{SINGLE-QUOTE}}}STD_DOC_FUNC_CHART_OBSERVATION_HELPER_JAB{{{SINGLE-QUOTE}}}; + // this mlm will assign values to the document objects. + Get_Variable_Values := MLM {{{SINGLE-QUOTE}}}Called_RPM_DOM_Get_Definition_MLM{{{SINGLE-QUOTE}}}; + + // ACS-20120109: added per request of P Karish - button deselection + + (this_structuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (this_observations) := this_structuredNoteDoc.ChartedObservationsList; + (this_parameters) := this_structuredNoteDoc.ParametersList; + (this_currentObj) := this_documentCommunication.CurrentObservationObj; + current_parameter := FIRST OF (this_Parameters WHERE this_parameters.ParameterGUID = this_CurrentObj.ParameterGUID); + current_parameter_name := current_parameter.name ; + current_parameter_guid := current_parameter.ParameterGuid ; + current_parameter_DataType := current_parameter.DataType ; + modifier_observation := first of (this_observations where this_observations.ParameterGUID = current_parameter_guid); + + IF exists modifier_observation THEN + IF exists modifier_observation.ValueObj THEN + //Calculate the modifier value based on the selected items lowest numeric equivalent value + FOR chartedListItem IN modifier_observation.ValueObj.ListItemsList DO + IF chartedListItem.IsSelected = true THEN + chartedListItem.IsSelected := false; + ENDIF; + ENDDO; + ENDIF; + ENDIF; + + // Initialize Variables + msg := ""; + target_parameter_name := "" ; + newValue:= "" ; + sugg_txt_value:=""; + button_name_list := (); + problem_name_list := (); + ass_plan_name_list := (); + index_list := (); + last_prob_index := 0; + REPLACE_APPEND := "Replace"; + THIS_MLM_NAME:= "DOC_RPM_Problem_Assessment_Plan_Reorder"; + + //Section 1 Variable and Constant Declaration DO NOT CHANGE THIS SECTION !!!!!!!!!!!!! + (this_documentCommunication, + client_guid, client_visit_guid, client_chart_guid, + user_guid, document_type, document_name, + event_type, configuration_guid, this_currentObj, + CancelEventFlag, this_structuredNoteDoc, authored_date_time, + authored_by_guid, client_document_guid, document_date_time, + isNewFlag, isIncompleteFlag, isResultsPendingFlag, + isPriorityFlag, this_parameters, this_chartedObservationsList, + this_parameters_display_name, current_parameter, + current_parameter_name, current_parameter_guid, + current_parameter_DataType, selectedItems, + selectedItems_value, current_value, + diagnosticMessage, displayMessageFlag, + CoSigner1, CoSigner2,DocumentTopic) + := CALL Get_Variable_Values WITH (this_documentCommunication); + //Variable and Constant Declaration DO NOT CHANGE THE ABOVE SEQUENCE. + //IT MATCHES THE SEQUENCE IN THE CALLED MLM !!!!!!!!!!!!!!!!!!!!!! // + + /* In this section of the MLM the newValue should be determined through logic */ + /* or SQL retrieved data or calling another mlm for the return value */ + /***************************************************************************/ + if called_by_editor then + current_parameter_name := "SCH_MDPN_AP_Copy"; //"SCH_MDPN_AP_Sort 2"; + //"button_move_2"; + current_value := "Copy last saved note"; + //"Copy Problem-Visit"; //"down"; + //"Copy all"; + document_name := "Physician Progress Note"; + (client_guid, client_chart_guid, client_visit_guid) := + READ LAST{ClientVisit:clientguid, ChartGUID, guid}; + endif; + + // gather user discipline + + (user_discipline) := read last { + " SELECT cp.discipline " + || " FROM CV3User u with (nolock)" + || " join CV3CareProvider cp with (nolock) on cp.GUID = u.GUID " + || " WHERE u.GUID = " || Sql(user_guid) + || " AND u.Active = 1 " + }; + + // get string lengths of parameters for parsing + + len_button_root := length of button_root; + len_Problem_root := length of Problem_root; + len_ass_plan_root := length of ass_plan_root; + len_current_parameter_name := length of current_parameter_name; + + for i in 1 seqto count_prob_obs do + index_list := index_list , i; + + if button_tens_placeholder <> "" and i < 10 then + button_name_i := button_root || button_tens_placeholder || i; + else + button_name_i := button_root || i; + endif; + + button_name_list := button_name_list, button_name_i; + + if problem_tens_placeholder <> "" and i < 10 then + problem_name_i := problem_root || problem_tens_placeholder || i; + else + problem_name_i := problem_root || i; + endif; + + problem_name_list := problem_name_list, problem_name_i; + + if ass_plan_tens_placeholder <> "" and i < 10 then + ass_plan_name_i := ass_plan_root || ass_plan_tens_placeholder || i; + else + ass_plan_name_i := ass_plan_root || i; + endif; + + ass_plan_name_list := ass_plan_name_list, ass_plan_name_i; + + enddo; // for i in 1 seqto count_prob_obs + + + // MOVE UP/DOWN OR CLEAR + + if current_parameter_name matches pattern (button_root || "%") then + current_index := first(index_list where button_name_list = current_parameter_name); + curr_prob_parm_name := problem_name_list[current_index]; + curr_ap_parm_name := ass_plan_name_list[current_index]; + curr_prob_parm := first of (this_parameters WHERE this_parameters.Name = curr_prob_parm_name); + curr_ap_parm := first of (this_parameters WHERE this_parameters.Name = curr_ap_parm_name); + + IF EXIST curr_prob_parm OR EXIST curr_ap_parm THEN + curr_prob_obs := first of (this_ChartedObservationsList WHERE this_ChartedObservationsList.ParameterGUID = curr_prob_parm.ParameterGUID); + curr_ap_obs := first of (this_ChartedObservationsList WHERE this_ChartedObservationsList.ParameterGUID = curr_ap_parm.ParameterGUID); + + IF EXIST curr_prob_obs or exist curr_ap_obs then + if length of curr_prob_obs.valueObj.value > 0 then + curr_prob_newValue := curr_prob_obs.valueObj.value; + else + curr_prob_newValue := ""; + endif; + + if length of curr_ap_obs.valueObj.value > 0 then + curr_ap_newValue := curr_ap_obs.valueObj.value; + else + curr_ap_newValue := ""; + endif; + + endif; + + endif; + + + // Up/Down/Bottom/Top Buttons Section + + + if current_value IN("up","down","bottom","top") then //determine digits place + + if current_value = "bottom" then + // get the last entered problem by scanning in reverse order + for j in 1 seqto count_prob_obs do + if last_prob_index = 0 then //haven{{{SINGLE-QUOTE}}}t found last prob yet + last_prob_name := problem_name_list [ count_prob_obs -J + 1]; + last_prob_parm := first of (this_parameters WHERE this_parameters.Name = last_prob_name ); + + IF EXIST last_prob_parm THEN //found param, now get obs + last_prob_obs := first of (this_ChartedObservationsList WHERE this_ChartedObservationsList.ParameterGUID + = last_prob_parm.ParameterGUID); + + IF EXIST last_prob_obs then // check to see if there is a problem + + if length of last_prob_obs.valueObj.value > 0 then + last_prob_index := count_prob_obs -J + 1; + endif; + + endif; // EXIST last_prob_obs + + endif; // EXIST last_prob_parm + + endif; // last_prob_index = 0 + + enddo; // j in 1 seqto count_prob_obs + + endif; // current_value = "bottom" + + + if current_value = "top" then + max_index := current_index - 1; + top_index := 1; + i_multiplier := 1; + + elseif current_value = "up" then + max_index := 1; + top_index := current_index - 1; + i_multiplier := 1; + + elseif current_value = "down" then + max_index := 1; + top_index := current_index + 1; + i_multiplier := -1; + + elseif current_value = "bottom" then + max_index := last_prob_index - current_index; // count_prob_obs - current_index; + top_index := last_prob_index; // count_prob_obs; + i_multiplier := -1; + + endif; + + for i in 1 seqto (max_index ) do + next_prob_parm_name := problem_name_list[current_index - (i * i_multiplier)]; + next_ap_parm_name := ass_plan_name_list[current_index - (i * i_multiplier)]; + next_prob_parm := first of (this_parameters WHERE this_parameters.Name = next_prob_parm_name); + next_ap_parm := first of (this_parameters WHERE this_parameters.Name = next_ap_parm_name); + + IF EXIST next_prob_parm OR EXIST next_ap_parm THEN + next_prob_obs := first of (this_ChartedObservationsList WHERE this_ChartedObservationsList.ParameterGUID = next_prob_parm.ParameterGUID); + next_ap_obs := first of (this_ChartedObservationsList WHERE this_ChartedObservationsList.ParameterGUID = next_ap_parm.ParameterGUID); + + IF EXIST next_prob_obs or exist next_ap_obs then + + if length of next_prob_obs.valueObj.value > 0 then + next_prob_newValue := next_prob_obs.valueObj.value; + else + next_prob_newValue := ""; + endif; + + if length of next_ap_obs.valueObj.value > 0 then + next_ap_newValue := next_ap_obs.valueObj.value; + else + next_ap_newValue := ""; + endif; + + else + next_prob_newValue := ""; + next_ap_newValue := ""; + endif; + + endif; + + this_documentCommunication := CALL WriteToNote_MLM + WITH (this_documentCommunication, curr_prob_parm_name,(next_prob_newValue, REPLACE_APPEND) ); + this_documentCommunication := CALL WriteToNote_MLM + WITH (this_documentCommunication, curr_ap_parm_name, (next_ap_newValue, REPLACE_APPEND) ); + + curr_prob_parm_name := next_prob_parm_name; + curr_ap_parm_name := next_ap_parm_name; + + enddo; + + top_prob_parm_name := problem_name_list[top_index]; + top_ap_parm_name := ass_plan_name_list[top_index]; + + this_documentCommunication := CALL WriteToNote_MLM + WITH (this_documentCommunication, top_prob_parm_name,(curr_prob_newValue, REPLACE_APPEND) ); + this_documentCommunication := CALL WriteToNote_MLM + WITH (this_documentCommunication, top_ap_parm_name, (curr_ap_newValue, REPLACE_APPEND) ); + + + // Clear Problem and Plan Button Section + + + elseif current_value = "clear both" THEN + + this_documentCommunication := CALL WriteToNote_MLM + WITH (this_documentCommunication, curr_prob_parm_name,("", REPLACE_APPEND) ); + this_documentCommunication := CALL WriteToNote_MLM + WITH (this_documentCommunication, curr_ap_parm_name,("", REPLACE_APPEND) ); + + + // Clear Plan Button Section + + elseif current_value = "clear plan (AP)" THEN + + this_documentCommunication := CALL WriteToNote_MLM + WITH (this_documentCommunication, curr_ap_parm_name,("", REPLACE_APPEND) ); + + + endif; // current_value IN("up","down","bottom","top") + + endif; // current_parameter_name matches pattern (button_root || "%") + + + + + // Copy Buttons Section + + + + if current_parameter_name = copy_prob_buttons_obs then //"button_copy_problem_list" + + // Parse Buttons + + for j in 1 seqto count button_hi_map_list do + // parse the button mapper: + b_hi_element_list := call str_parse with button_hi_map_list[j], "|"; + button_i := b_hi_element_list[1]; + hi_sql_list_i := b_hi_element_list[2]; + + + // Copy HI Buttons Section (Problem-Visit/Copy Problem-Proced/Copy Problem-Chronic/Copy All) + + + if current_value = button_i and hi_sql_list_i <> "" and hi_sql_list_i <> "" and hi_sql_list_i <> "Launch Problem Selector" then + + HI_Object := OBJECT [ ShortName,TypeCode,ScopeLevel ]; + + //041812 - changed "ClientGUID like " to "ClientGUID =" in 2 places in the HI sql statement + // 04.23.2015 DW CSR# 32359 - Physician Charging (appended the ICD Code to the visit problems imported into the A/P section) + + + /* Replaced with ICD10 project + + OBjrs:= READ AS HI_Object + {" SELECT ShortName + {{{SINGLE-QUOTE}}} [{{{SINGLE-QUOTE}}} + isnull(code, {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}) + {{{SINGLE-QUOTE}}}]{{{SINGLE-QUOTE}}},TypeCode,ScopeLevel " + || " FROM CV3HealthIssueDeclaration " + || " WHERE (ClientGUID = " || sql(client_guid) + || " AND ChartGUID = " || sql(client_chart_guid) + || " AND ScopeLevel IN ({{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}3{{{SINGLE-QUOTE}}}) " + || " AND Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " + || " AND TypeCode IN ( " || hi_sql_list_i || ") )" + || " OR (ClientGUID = " || sql(client_guid) + || " AND ChartGUID <> " || sql(client_chart_guid) + || " AND ScopeLevel = {{{SINGLE-QUOTE}}}3{{{SINGLE-QUOTE}}} " + || " AND Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " + || " AND TypeCode IN ( " || hi_sql_list_i || ") )" + || " ORDER By ShortName " + }; + */ + + OBjrs:= READ AS HI_Object + {" SELECT ShortName + {{{SINGLE-QUOTE}}} [{{{SINGLE-QUOTE}}} + isnull(code, {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}) + {{{SINGLE-QUOTE}}}]{{{SINGLE-QUOTE}}},TypeCode,ScopeLevel " + || " FROM CV3HealthIssueDeclaration " + || " WHERE " + || " ( " + || " (ClientGUID = " || sql(client_guid) + || " AND ChartGUID = " || sql(client_chart_guid) + || " AND ScopeLevel IN ({{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}3{{{SINGLE-QUOTE}}}) " + || " AND Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " + || " AND TypeCode IN ( " || hi_sql_list_i || ") )" + || " OR " + || " (ClientGUID = " || sql(client_guid) + || " AND ChartGUID <> " || sql(client_chart_guid) + || " AND ScopeLevel = {{{SINGLE-QUOTE}}}3{{{SINGLE-QUOTE}}} " + || " AND Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " + || " AND TypeCode IN ( " || hi_sql_list_i || ") )" + || " ) " + || " and CodingScheme = {{{SINGLE-QUOTE}}}ICD10{{{SINGLE-QUOTE}}} ORDER By ShortName " + }; + + + + IF EXIST OBjrs THEN + + target_parameter_name_list := problem_name_list; + empty_target_parameter_name_list :=(); + + FOR ictr IN 1 SEQTO COUNT OF target_parameter_name_list DO + candidate_parameter_name := target_parameter_name_list[ictr] ; + candidate_parameter := first of (this_Parameters WHERE this_Parameters.Name = candidate_parameter_name) ; + if exists candidate_parameter then + candidate_parameter_Obs := first of (this_ChartedObservationsList WHERE this_ChartedObservationsList.ParameterGUID = candidate_parameter.ParameterGUID); + + if candidate_parameter_Obs.valueObj.value is NULL then + empty_target_parameter_name_list := (empty_target_parameter_name_list, candidate_parameter_name); + endif; //if exists candidate_parameter_Obs AND Length OF ... + + endif; //if exists candidate_parameter then + + ENDDO; //FOR ictr IN 1 SEQTO COUNT OF target_parameter_name_list DO + + ParameterGUIDs_List :=(this_Parameters.ParameterGUID WHERE this_Parameters.Name IN (target_parameter_name_list)); + Problems_list := (this_ChartedObservationsList.valueObj.Value WHERE this_ChartedObservationsList.ParameterGUID IN (ParameterGUIDs_List) ); + missing_problems_list :=(); + + for ictr IN 1 SEQTO COUNT OF OBjrs do + problem_member := OBjrs[ictr].ShortName ; + + if problem_member NOT IN (Problems_List) then + missing_problems_list := missing_problems_list,problem_member ; + endif; //if problem_member NOT IN(Problems_List) + + enddo; // for problem_member IN Problems_List + + Count_Of_Missing_Problems := COUNT OF missing_problems_list ; + + if Count_Of_Missing_Problems > count_prob_obs then + Count_Of_Missing_Problems := count_prob_obs ; + endif; // if Count_Of_Missing_Problems > 10 then + + for ictr IN 1 SEQTO Count_Of_Missing_Problems do + target_parameter_name := empty_target_parameter_name_list[ictr]; + newValue := missing_problems_list[ictr]; + this_documentCommunication := CALL WriteToNote_MLM + WITH (this_documentCommunication, target_parameter_name,(newValue, REPLACE_APPEND) ); + enddo; + + ENDIF; //if exist OBjrs THEN SCH_MDPN_AP_Copy + + + // Call Launch Problem List Builder Section + + elseif current_value = button_i and hi_sql_list_i = "Launch Problem Selector" + then + LaunchProblemSelectorMLM := MLM {{{SINGLE-QUOTE}}}Doc_Func_Launch_Progress_Notes_Problem_List_Builder{{{SINGLE-QUOTE}}}; + this_documentCommunication := CALL LaunchProblemSelectorMLM WITH (this_documentCommunication,button_i ); + + + + // Copy Last Saved Note Section + + + + elseif current_value = button_i and hi_sql_list_i = "" then + + + // Find last document authored by a user with the same discipline as the current user + + // ** 08.27.2012 CSR# 30963 DW commented out prior document name fiter (we need to pull the data element from any document) + // 09/14/2016 HD# 2198672 - We found that the change above opened the SQL to pulling SNs and FSs that had no problems. I listed the documents that have problems + + (last_document_guid):= read last + { " SELECT TOP 1 CD.GUID " + || " FROM CV3ClientDocument CD with (nolock)" + || " Join CV3User u with (nolock) on u.guid = CD.UserGUID " + || " Join CV3CareProvider cp with (nolock) on cp.GUID = u.GUID " + || " WHERE CD.ClientGUID = " || sql(client_GUID) + || " AND CD.ClientVisitGUID = " || sql(client_visit_GUID) + || " AND CD.ChartGUID = " || sql(client_chart_GUID) + // || " AND CD.DocumentName like {{{SINGLE-QUOTE}}}" || document_name || "%{{{SINGLE-QUOTE}}} " + || " and ( cd.DocumentName like {{{SINGLE-QUOTE}}}History and Physical%{{{SINGLE-QUOTE}}} or cd.DocumentName like {{{SINGLE-QUOTE}}}Day of Discharge Summary eNote%{{{SINGLE-QUOTE}}} or cd.DocumentName like {{{SINGLE-QUOTE}}}Consult eNote%{{{SINGLE-QUOTE}}} or cd.DocumentName like {{{SINGLE-QUOTE}}}Physician Progress Note%{{{SINGLE-QUOTE}}} ) " + || " AND CD.Active = 1 " + || " AND cp.discipline = " || sql(user_discipline) + || " ORDER BY CD.Entered DESC " + }; + + parameter_name_list := problem_name_list, ass_plan_name_list; + + sql_parameter_name_list :=(); + + for parameter_name IN parameter_name_list DO + sql_parameter_name_list := sql_parameter_name_list , sql(parameter_name); + enddo; + + + // Find data on last document authored by a user with the same discipline as the current user + + + (ObsName,ValueText) := read + {" SELECT OCMI.Name, sp.ValueText" + ||" FROM SXACDObservationParameter sp with (nolock) " + || " Inner Join CV3ObsCatalogMasterItem OCMI with (nolock) " + || " ON OCMI.Guid = sp.ObsMasterItemGUID " + || " join CV3Observation o with (nolock) on o.GUID = sp.ObservationGUID " + || " join CV3User u with (nolock) on u.guid = o.UserGUID " + || " join CV3CareProvider cp with (nolock) on cp.GUID = u.GUID " + || " WHERE sp.clientguid = " || sql(client_GUID) + || " AND sp.ChartGUID = " || sql(client_chart_GUID) + || " AND sp.ClientVisitGUID = " || sql(client_visit_GUID) + || " AND sp.OwnerGUID = " || sql(last_document_guid) + || " AND OCMI.Name IN(" || sql_parameter_name_list ||")" + }; + + // If Prior Notes are found on the document, then write them + + if exists ObsName then + + + + // DW 03.19.2015 CSR# 32616 (Clinical Documentation Specialist) - This routine was re-written copy the probs/plans are copied into the open fields + + + +/* Routine disabled - DW 03.19.2015 CSR# 32616 + + // This routine blanks out the 14 Problem and Plan fields + FOR target_parameter_name IN parameter_name_list DO + newValue := ""; + this_documentCommunication := CALL WriteToNote_MLM WITH (this_documentCommunication, target_parameter_name,(newValue, REPLACE_APPEND) ); + ENDDO; +*/ + + + // Find the number value of the first open problem field + + + firstopenfield := 0; + for openctr IN 1 SEQTO 14 DO + fieldname := "SCH_MDPN_Problem " || openctr; + + theParameter := first of (this_parameters where this_parameters.Name = fieldname ); + theObservation:= first of (this_observations where this_observations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + + if thisfield is null and firstopenfield = 0 + then + firstopenfield := openctr; + endif; + enddo; + + + for ictr IN 1 SEQTO COUNT OF ObsName DO + + target_parameter_name := ObsName[ictr]; + + // Gather the last character (or last 2 chars if >=10) of the field name to be copied in + + fldlength := length(target_parameter_name); + nexttolast := SUBSTRING 1 CHARACTERS STARTING AT (fldlength -1) FROM target_parameter_name; + + if nexttolast = " " or nexttolast = "0" + then suffix := SUBSTRING 1 CHARACTERS STARTING AT (fldlength) FROM target_parameter_name as number; + else suffix := SUBSTRING 2 CHARACTERS STARTING AT (fldlength -1) FROM target_parameter_name as number; + endif; + + newsuffix := suffix + firstopenfield -1; // Add the last character(s) of the field name to the # of the first open field + + + // Create the new field name to be copied into (these are the blank fields) + + + if target_parameter_name matches pattern "SCH_MDPN_Problem%" + then + target_parameter_name := "SCH_MDPN_Problem " || newsuffix; + else + if newsuffix <= 9 + then + target_parameter_name := "SCH_MDPN_Assessment / Plans 0" || newsuffix; + else + target_parameter_name := "SCH_MDPN_Assessment / Plans " || newsuffix; + endif; + endif; + + + // Write to the fields + + if ValueText[ictr] is not null then + newValue := ValueText[ictr] || " "; + this_documentCommunication := CALL WriteToNote_MLM WITH (this_documentCommunication, target_parameter_name,(newValue, REPLACE_APPEND) ); + endif; + + + enddo; // for ictr IN 1 SEQTO COUNT OF ObsName + + +//// + + + endif; // If Prior Notes are found on the document + + + + + // Find "Dispostion - Discharge Plan" on last document authored by a user with the same discipline as the current user + + + if exists ValueText then + + (ValueText) := read + {" SELECT sp.ValueText " + ||" FROM SXACDObservationParameter sp with (nolock) " + || " Inner Join CV3ObsCatalogMasterItem OCMI with (nolock) " + || " ON OCMI.Guid = sp.ObsMasterItemGUID " + || " join CV3Observation o with (nolock) on o.GUID = sp.ObservationGUID " + || " join CV3User u with (nolock) on u.guid = o.UserGUID " + || " join CV3CareProvider cp with (nolock) on cp.GUID = u.GUID " + || " WHERE sp.clientguid = " || sql(client_GUID) + || " AND sp.ChartGUID = " || sql(client_chart_GUID) + || " AND sp.ClientVisitGUID = " || sql(client_visit_GUID) + || " AND sp.OwnerGUID = " || sql(last_document_guid) + || " AND OCMI.Name = {{{SINGLE-QUOTE}}}SCH_MDPN_DischargePlan{{{SINGLE-QUOTE}}} " + }; + + this_documentCommunication := CALL WriteToNote_MLM + WITH (this_documentCommunication, "SCH_MDPN_DischargePlan",(ValueText, REPLACE_APPEND) ); + endif; + + // Clear All fields Section + + + elseif current_value = button_i and hi_sql_list_i = "" then + + + current_index :=1; + max_index := count_prob_obs; + + for i in 1 seqto (max_index ) do + next_prob_parm_name := problem_name_list[current_index]; + next_ap_parm_name := ass_plan_name_list[current_index]; + + this_documentCommunication := CALL WriteToNote_MLM + WITH (this_documentCommunication, next_prob_parm_name,("", REPLACE_APPEND) ); + this_documentCommunication := CALL WriteToNote_MLM + WITH (this_documentCommunication, next_ap_parm_name,("", REPLACE_APPEND) ); + + current_index := current_index + 1; + enddo; + + endif; // Copy Buttons Rules by Type Section + + enddo; // Parse Copy Buttons Section + + endif; // Copy Buttons Section + + //uncomment for debugging: +/* msg := msg + ||"\nFINAL:2" + ||"\nlast_prob_index = " || last_prob_index + ||"\nlast_prob_name = " || last_prob_name + ||"this_ChartedObservationsList.valueObj.Value " + || this_ChartedObservationsList.valueObj.Value || "\n\n" + ||"PN_sel_list = "|| PN_sel_list || "\n\n" + ||"current_parameter.configurationobj.listguid = " + || current_parameter.configurationobj.listguid + ||"\n\ncurrent_value = "|| current_value + || "\n\nnewValue = " || newValue || "\n\n" + ||"this_documentCommunication.CurrentObservationObj.ValueObj.ListItemsList = " + ||this_documentCommunication.CurrentObservationObj.ValueObj.ListItemsList.records__ + || "\n\n" + || "Problems_List " || Problems_List|| "\n\n" + || "missing_problems_list " || missing_problems_list || "\n\n" + || "Count_Of_Missing_Problems = " || Count_Of_Missing_Problems + || "\nempty_target_parameter_name_list " + || empty_target_parameter_name_list || "\n\n" + || "this_Parameters.Name " || this_Parameters.Name + ; +*/ + if msg <> "" then //display message to user + this_documentCommunication.DisplayMessage := true; + this_documentCommunication.Message := msg; + endif; + ;; + evoke: + ;; + logic: + conclude true; + ;; + action: + return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_ACS_PROGRESS_NOTE_DAILY_ASSESSMENT_PLAN_REVIEW.mlm b/MLMStripper/bin/Debug/DOC/DOC_ACS_PROGRESS_NOTE_DAILY_ASSESSMENT_PLAN_REVIEW.mlm new file mode 100644 index 0000000..242aabf --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_ACS_PROGRESS_NOTE_DAILY_ASSESSMENT_PLAN_REVIEW.mlm @@ -0,0 +1,236 @@ +maintenance: + + title: DOC_ACS_Progress_Note_Daily_Assessment_Plan_Review ;; + mlmname: DOC_ACS_Progress_Note_Daily_Assessment_Plan_Review ;; + arden: version 2.5;; + version: 5.50;; + institution: RPM, Sample Document Called MLM;; + author: Rick Mansour, MD ;; + specialist: Allscripts Custom Services;; + date: 2011-01-16;; + validation: testing;; + +library: + purpose: Standardize the document mlm responsible for initiation. + The 5.2 version adds in the CoSigner1, CoSigner2 and the DocumentTopic + 20111115 ACS: MLM adapted for use at St. Clair Hospital + 2019.07.30 JML Modified SQL logic so plan and problems will show in note + ;; + explanation: none + ;; + keywords: RTF, Document Called MLM , list + ;; +knowledge: + type: data-driven;; + data: + (this_documentCommunication) := argument; + /*******************Make Changes To Spelling And Flags In This Section******************/ + // THIS IS THE ONLY SECTION OF THIS MLM THAT REQUIRES CHANGES // + /* Set to true if a decision.log is needed.*/ + log_execution_info := false; + + // Put the list of alternating HISTORICAL problems and plans in this list for lookup + CF_Parameter_Name_List := + ("SCH_MDPN_Problem 1", "SCH_MDPN_Assessment / Plans 01", + "SCH_MDPN_Problem 2", "SCH_MDPN_Assessment / Plans 02", + "SCH_MDPN_Problem 3", "SCH_MDPN_Assessment / Plans 03", + "SCH_MDPN_Problem 4", "SCH_MDPN_Assessment / Plans 04", + "SCH_MDPN_Problem 5", "SCH_MDPN_Assessment / Plans 05", + "SCH_MDPN_Problem 6", "SCH_MDPN_Assessment / Plans 06", + "SCH_MDPN_Problem 7", "SCH_MDPN_Assessment / Plans 07", + "SCH_MDPN_Problem 8", "SCH_MDPN_Assessment / Plans 08", + "SCH_MDPN_Problem 9", "SCH_MDPN_Assessment / Plans 09", + "SCH_MDPN_Problem 10", "SCH_MDPN_Assessment / Plans 10", + "SCH_MDPN_Problem 11", "SCH_MDPN_Assessment / Plans 11", + "SCH_MDPN_Problem 12", "SCH_MDPN_Assessment / Plans 12", + "SCH_MDPN_Problem 13", "SCH_MDPN_Assessment / Plans 13", + "SCH_MDPN_Problem 14", "SCH_MDPN_Assessment / Plans 14" + ); + + /* ("LargeTextRTF", + "Problem_1","Assessment_Plan_1", + "Problem_2","Assessment_Plan_2", + "Problem_3","Assessment_Plan_3", + "Problem_4","Assessment_Plan_4", + "Problem_5","Assessment_Plan_5", + "Problem_6","Assessment_Plan_6", + "Problem_7","Assessment_Plan_7", + "Problem_8","Assessment_Plan_8", + "Problem_9","Assessment_Plan_9", + "Problem_10","Assessment_Plan_10"); + */ + + // Target text observation that this MLM will write to + target_parameter_name := "SCH_MDPN_AP_Review FT"; //"Progress_Note_Assessment_Plan"; + // THIS FLAG CONTROLS THE DEBUG MESSAGE + displayMessageFlag := FALSE ; + + /********************************END OF CHANGES******************************************/ + + // Variable and Constant Declaration + WriteToNote_MLM := MLM {{{SINGLE-QUOTE}}}STD_DOC_FUNC_CHART_OBSERVATION_HELPER_JAB{{{SINGLE-QUOTE}}}; + //{{{SINGLE-QUOTE}}}Called_RPM_DOM_MLM{{{SINGLE-QUOTE}}}; + newValue:= "" ; + sugg_txt_value:=""; + REPLACE_APPEND := "Replace"; + THIS_MLM_NAME:= "DOC_ACS_Progress_Note_Daily_Assessment_Plan"; + + //Section 1 Gather Document and Observation Info DO NOT CHANGE THIS SECTION !!!!!!!!!!! // + Get_Variable_Values := MLM {{{SINGLE-QUOTE}}}Called_RPM_DOM_Get_Definition_MLM{{{SINGLE-QUOTE}}}; + // this mlm will assign values to the document objects. + (this_documentCommunication, + client_guid, client_visit_guid, client_chart_guid, + user_guid, document_type, document_name, + event_type, configuration_guid, this_currentObj, + CancelEventFlag, this_structuredNoteDoc, authored_date_time, + authored_by_guid, client_document_guid, document_date_time, + isNewFlag, isIncompleteFlag, isResultsPendingFlag, + isPriorityFlag, this_parameters, this_chartedObservationsList, + this_parameters_display_name, current_parameter, + current_parameter_name, current_parameter_guid, current_parameter_DataType, + selectedItems, selectedItems_value, current_value, + diagnosticMessage, displayMessageFlag, CoSigner1, + CoSigner2, DocumentTopic) + := CALL Get_Variable_Values WITH (this_documentCommunication); + //DO NOT CHANGE THE ABOVE SEQUENCE. IT MATCHES THE SEQUENCE IN THE CALLED MLM !!!!!!!! // + + // In this section of the MLM the newValue should be determined through logic + // or SQL retrieved data or calling another mlm for the return value + + // Make CF_Parameter_Name_List work with IN Operatore in the SQL Statement + // Following code inserts an apostrophe inside the quotes ie "{{{SINGLE-QUOTE}}}Problem_1{{{SINGLE-QUOTE}}}" + SQL_Parameter_Name_List:=(); + FOR CF_Parameter_Name IN CF_Parameter_Name_List DO + SQL_Parameter_Name_List := (SQL_Parameter_Name_List,sql(CF_Parameter_Name)); + ENDDO; + + // CHANGE THE THREE VARIABLE ASSIGNMENTS ABOVE TO MAKE THIS WORK ON THE HANDOFF NOTE // + if called_by_editor then + (client_guid, client_visit_guid, client_chart_guid) := read last + {ClientVisit:clientguid, GUID, chartguid}; + current_value := 3 ; //radio button val = 1 - LAST note problems + Document_Name := "Physician Progress Note"; //"Progress Note - Daily"; + endif; + + // Get the historical documents that match the current document + (document_guids_list,authored_provider_guids_list, AuthoredDtm_list):=Read + {" SELECT GUID, AuthoredProviderGUID, AuthoredDtm " + || " FROM CV3ClientDocument " + || " WHERE ClientGUID = " || sql(client_GUID) + || " AND ChartGUID = " || sql(client_chart_GUID) + || " AND ClientVisitGUID = " || sql(client_visit_GUID) +// || " AND DocumentName = " || sql(Document_Name) + || " AND DocumentName like ({{{SINGLE-QUOTE}}}%{{{SINGLE-QUOTE}}} + " || sql( Document_Name ) || " + {{{SINGLE-QUOTE}}}%{{{SINGLE-QUOTE}}})" + || " ORDER BY AuthoredDtm DESC " + }; + + IF EXIST document_guids_list THEN // there are historical matching docs + document_guids_list_count := COUNT OF document_guids_list; + current_value := current_value AS number; // radio button choice (1,2,3,...etc) + + if current_value <= document_guids_list_count and current_value > 0 then + // Get the historical document that correspondes to the user{{{SINGLE-QUOTE}}}s choice + target_document_guid := document_guids_list[current_value] ; + authored_provider_guid := authored_provider_guids_list[current_value]; + authoredDtm := AuthoredDtm_list[current_value]; + + // Get the author{{{SINGLE-QUOTE}}}s information and create the preface + (first_name,last_name):= read last + {" SELECT FirstName, LastName " + ||" FROM CV3User " + ||" WHERE GUID = " || sql(authored_provider_guid)}; + PAP_Value := "Assessment Entered By " ||first_name || " " + || last_name || " Entered Date: " || authoredDtm || "\n\n" ; + + // Create an object for holding the problem information + recordset_object := Object [ Name, Description, ValueText ]; + + // get the list of historical problem(s) on the chosen note + objrs := read AS recordset_object + {" SELECT OCMI.Name, OCMI.Description, O.ValueText " + || " FROM CV3ClientDocument CD " + || " JOIN SXACDObservationParameter sp " //this is the new table in 5.5 + || " ON CD.ClientGUID = sp.ClientGUID " + || " and CD.ChartGUID = sp.ChartGUID " + || " and sp.OwnerGUID = cd.guid " //IMPORTANT limiter condition! + || " and CD.PatCareDocGUID = sp.PatCareDocGUID " +// || " JOIN CV3ObservationDocument OD " +// || " on OD.ObservationDocumentGUID = sp.ObservationDocumentGUID " +// || " ON OD.OwnerGUID = CD.GUID " + || " JOIN CV3Observation o " + || " ON sp.observationGUID = o.guid " + || " JOIN CV3ObsCatalogMasterItem OCMI " + || " ON OCMI.GUID = sp.ObsMasterItemGUID " +// || " ON OCMI.Guid = OD.ObsMasterItemGUID " + || " WHERE CD.ClientGUID = " || sql(client_guid) + || " AND CD.ChartGUID = " || sql(client_chart_guid) + || " AND CD.GUID = " || sql(target_document_guid) + || " AND OCMI.Name IN(" || SQL_Parameter_Name_List || ")" + || " AND CD.Active = 1 " +// || " AND OD.Active = 1 " + || " AND O.VAlueTExt IS NOT NULL " + }; + + // Loop to rearrange the problems according to the original list + FOR ictr IN 1 SEQTO COUNT OF CF_Parameter_Name_List DO + temp_data := NEW recordset_object; + temp_data := (objrs WHERE objrs.Name = CF_Parameter_Name_List[ictr]); + + // Prepare the Text for output in the current note + if exists temp_data[1].Description then + if temp_data[1].Description matches pattern "%problem%" then + // this is for a PROBLEM + PAP_Value := PAP_Value || "\b1 " || temp_data[1].ValueText || "\b0 \n"; + else // this is for a PLAN + PAP_Value := PAP_Value || temp_data[1].ValueText || "\n"; + endif; + endif; // exists temp_data[1].Description + ENDDO; // FOR ictr IN 1 SEQTO COUNT OF CF_Parameter_Name_List DO + newValue := PAP_Value; + else // user radio button choice is greater than # of historical matching docs + newValue :="There is no assessment and plan for this number " || current_value ; + endif; //if current_value <= list_count and current_value > 0 AND ... + ENDIF; // IF EXIST document_guids_list THEN + + if exists newValue and exists target_parameter_name then + // This section calls the MLM to populate the observation object. + // It should be repeated each time an observation is poopulated. + // It will not work in a loop // + this_documentCommunication := CALL WriteToNote_MLM + WITH (this_documentCommunication, target_parameter_name,newValue, +// sugg_txt_value,REPLACE_APPEND); + REPLACE_APPEND); + endif; + ////////////////////////////////////////////////////////////////////////// + // If the state of note the isIncomplete, isPriority and isResultsPending + // need to be changed in the note// + // set one or more of these flags := TRUE// + // isIncompleteFlag := TRUE ; + // isResultsPendingFlag := TRUE ; + // isPriorityFlag := TRUE ; + ////////////////////////////////////////////////////////////////////////// + + // This code sets the checkboxes to checked or unchecked. + // DO NOT CHANGE THIS CODE BELOW + this_structuredNoteDoc.IsIncomplete := isIncompleteFlag ; + this_structuredNoteDoc.IsResultsPending := isResultsPendingFlag ; + this_structuredNoteDoc.IsPriority := isPriorityFlag ; + // ThE ABOVE code sets the checkboxes to checked or unchecked. + // DO NOT CHANGE THIS CODE ABOVE + + // The code below will display the diagnosticMessage Varaible if + // the displayMessageFlag is set to TRUE + this_documentCommunication.DisplayMessage := displayMessageFlag; + // this_documentCommunication.Message := + // "MLM Name : " || THIS_MLM_NAME || "\n\n" ||diagnosticMessage ; + this_documentCommunication.Message := newValue || " goes into " + || target_parameter_name ; + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_ACS_RECIPROCAL_MULTI_SELECT.mlm b/MLMStripper/bin/Debug/DOC/DOC_ACS_RECIPROCAL_MULTI_SELECT.mlm new file mode 100644 index 0000000..bf7bfeb --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_ACS_RECIPROCAL_MULTI_SELECT.mlm @@ -0,0 +1,185 @@ +maintenance: + + title: DOC_ACS_Reciprocal_Multi_Select ;; + mlmname: DOC_ACS_Reciprocal_Multi_Select ;; + arden: version 2.5;; + version: 5.50;; + institution: RPM, Sample Document Called MLM;; + author: Rick Mansour and Allscripts Custom Services;; + specialist: ;; + date: 2011-07-16;; + validation: testing;; + +library: + purpose: Demonstrate the ability to select a list if the first item "all" is selected + Deselect the list if all items are selected and "all" is selected + Reciprocating relationship between two lists with a name relationship + ;; + explanation: + It is common for sites to create two lists with the same list values- one to chart + the patient has that symptom (+) and one to document the patient does not have that + symptom (-). Charting the same item in both lists would result in the document + saying the patient both has and doesn’t have the symptom. This MLM will be used + across two lists to ensure that contradicting values do not get charted. + If a contradicting value is individually selected, then the first item will be + unselected. HOWEVER if the entire list is selected with a select all type function + then the list member will be skipped if the reciprocal already checked on the + reciprocal list. + + "all" is the first member of each list. If all is checked the the entire list is + checked except "all" and any members of the opposite list that are checked. + If "all" is checked when all other members of the list are already checked then + the mlm sets the list to all unchecked. + + this mlm assumes a naming convention: + 1. "ros_gi_pos"/"ros_gi_neg" are reciprical pairs" + 2. "ros_gi_" is the root of both parameter names + 3. "neg" and "pos" are the variable parts of the paired opposites list. + 4. the list members are the same in "list value" + 5. for readability of the note the "cell value" in the pos list is in UPPERCASE + This assumption makes this a generic mlm. An alternative if to use an if then else + statement to finds named pairs. + ;; + keywords: RTF, Document Called MLM , list, multi-select + ;; +knowledge: + type: data-driven;; + data: + + (this_documentCommunication) := argument; + + // CALLED MLMS used by this mlm + WriteToNote := MLM {{{SINGLE-QUOTE}}}STD_DOC_FUNC_CHART_OBSERVATION_HELPER_JAB{{{SINGLE-QUOTE}}}; // {{{SINGLE-QUOTE}}}CALLED_RPM_DOM_MLM{{{SINGLE-QUOTE}}}; +// get_Object := MLM{{{SINGLE-QUOTE}}}CALLED_RETURN_OBJECT{{{SINGLE-QUOTE}}}; + + /* Set to true if a decision.log is needed.*/ + log_execution_info := false; + + /***************************************************************************************/ + + //*** Variable and Constant Declaration ***// + //The following variables are references to various points in the + //DocumentCommunication object model. + // + (this_structuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (this_chartedObservationsList) := this_structuredNoteDoc.ChartedObservationsList; + (this_parameters) := this_structuredNoteDoc.ParametersList; + + // this_documentCommunication.CurrentObservationObj is the observation that changed + // and trigered the mlm. It shares a parameterguid with its Parameter (a member of + // the observation catalog) + this_currentObj := this_documentCommunication.CurrentObservationObj; + parameter := FIRST OF (this_Parameters + WHERE this_parameters.ParameterGUID = this_CurrentObj.ParameterGUID); + parameter_name := parameter.name ; + parameter_guid := parameter.ParameterGuid ; + + // Object needed to declare in the calling the above MLM (for listitems only) + SelectedList := OBJECT[ ListGUID, SelectedValues, SuggestiveText]; + + if called_by_editor then + parameter_name := "ros_rpm_gi_pos" ; + endif; + + // This code determines the recirpocal paramter name + IF UPPERCASE parameter_name MATCHES PATTERN "%POS%" THEN + reciprocal_parameter_name := (SUBSTRING (FIND "POS" + IN STRING UPPERCASE parameter_name)-1 CHARACTERS FROM STRING parameter_name) + || "neg"; + ELSEIF UPPERCASE parameter_name MATCHES PATTERN "%NEG%" THEN + reciprocal_parameter_name := (SUBSTRING (FIND "NEG" + IN STRING UPPERCASE parameter_name)-1 CHARACTERS FROM STRING parameter_name) + || "pos"; + ENDIF; + + //Get the parameter(s) and observations + curr_param := first of (this_parameters where this_parameters.name = parameter_name ); + recip_param := first of (this_parameters + where this_parameters.name = reciprocal_parameter_name ); + reciprocal_obs := FIRST OF (this_ChartedObservationsList + WHERE this_ChartedObservationsList.parameterGUID = recip_param.parameterGUID); + curr_obs:= FIRST OF (this_ChartedObservationsList + WHERE this_ChartedObservationsList.parameterGUID = curr_param.parameterGUID); + + //Get the ListConfiguration object of the parameter + currentObj_parameterObj := curr_param.configurationobj; +// currentObj_parameterObj := CALL get_Object WITH (this_documentCommunication,parameter_name); + + //get the selected items + currentObj_selected_items := (this_currentObj.valueobj.listitemslist.value + where this_currentObj.valueobj.listitemslist.isselected = true); +// currentObj_selected_items := currentObj_parameterObj.Obs_SelectedListValues; + + reciprocal_selected_items := (reciprocal_obs.valueobj.listitemslist.value + where reciprocal_obs.valueobj.listitemslist.isselected = true); +// reciprocal_parameterObj := CALL get_Object +// WITH (this_documentCommunication,reciprocal_parameter_name) ; +// reciprocal_selected_items := reciprocal_parameterObj.Obs_SelectedListValues; + +///////////////////////////////////////////////////////////////////////////////////////////////////// + count_current_config_items := (count of currentObj_parameterObj.listitemslist.value) +// count_current_config_items := (count of currentObj_parameterObj.ConfigurationObjValues) + AS NUMBER ; + count_current_selected_items := (count of currentObj_selected_items) AS NUMBER ; + newValue :=(); // initialize list of items for selection + PN_sel_list := NEW SelectedList; //instantiate NewValue for ListItems + + IF "all" IN currentObj_selected_items THEN + if count_current_selected_items = count_current_config_items then + newValue := ""; //no need to select any more list items + else + for item IN currentObj_parameterObj.listitemslist.value do +// for item IN currentObj_parameterObj.ConfigurationObjValues do + if item <> "all" and item NOT IN reciprocal_selected_items then + newValue := newValue, item ; + endif; // if item <> "all" and item NOT IN reciprocal_selected_items + enddo; // for item IN currentObj_parameterObj.listitemslist.value + endif; // if count_current_selected_items = count_current_config_items + + // create the selection list for helper MLM + PN_sel_list.ListGUID := currentObj_parameterObj.listguid; //guid for list + list_name := parameter_name; + ELSE // IF "all" NOT IN currentObj_selected_items THEN + for item IN reciprocal_selected_items do + if item <> "all" and item NOT IN currentObj_selected_items then + newValue := newValue, item ; + endif; // if item <> "all" and item NOT IN reciprocal_selected_items + enddo; // for item IN reciprocal_selected_items + + // create the selection list for helper MLM + PN_sel_list.ListGUID := recip_param.configurationobj.listguid; + list_name := reciprocal_parameter_name; + ENDIF; //if "all" IN currentObj_selected_items then + + 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_documentCommunication := CALL WriteToNote + WITH (this_documentCommunication, list_name , + PN_sel_list); +// newValue,"",""); + endif; + + // uncomment for debugging +/* sMessage := parameter_name + || "\nnewvalue = " || newvalue + || "\ncurrentObj_selected_items = " || currentObj_selected_items.records__ + ||"\nPN_sel_list = " || PN_sel_list + || "\nreciprocal_selected_items = " || reciprocal_selected_items.records__ + ; + //Tell DocumentCommunication to Display the Message + this_documentCommunication.DisplayMessage := TRUE; + this_documentCommunication.Message := sMessage ; +*/ + +//////////////////////////////////////////////////////////////////////////////////////////////////// + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_ADULT_ASSESSMENT_CLOSE.mlm b/MLMStripper/bin/Debug/DOC/DOC_ADULT_ASSESSMENT_CLOSE.mlm new file mode 100644 index 0000000..3cee891 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_ADULT_ASSESSMENT_CLOSE.mlm @@ -0,0 +1,66 @@ +maintenance: + + title: DOC_ADULT_ASSESSMENT_CLOSE;; + mlmname: DOC_ADULT_ASSESSMENT_CLOSE;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Juliet M. Law;; + specialist: ;; + date: 2011-09-02;; + validation: testing;; + +library: + purpose: + ;; + explanation: + + + Change history + + 09.02.2011 JML Created; copied from DOC_MD_PROGRESSNOTE + 03.03.2015 JML CSR 32519: Changed MLM name for braden risk. + 4.29.2016 STH CSR#: 33207: Added call to new MLM DOC_FUNC_IV_HALDOL_STATUSBOARD used for status board column update of IV Haldol given within last 24hrs. {Go-Live 6/1/2016} + 08.01.2017 SAcharya CSR# 35187: Added call to new MLM "DOC_SCH_CREATE_ORDER_DECREASE_FUNCTION" which will generate "Decrease Function" Order. (Go-Live 08/22/2017) + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Receive arguments from the flowsheet + (thisDocumentCommunication) := argument; + + DocBradenScaleAlert := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_BRADEN_SCALE_CHANGE_ALERT{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocBradenScaleAlert WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + + // Call MLM to determine if Braden Calculated Value deems a Dietitian Consult Order created. + DocBradenObs := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_CREATE_DIETITIAN_CONSULT_FROM_ADULT_ASSESS_OBS{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocBradenObs WITH thisDocumentCommunication; + + //Reset to receive arguments from the flowsheet + (thisDocumentCommunication) := argument; + + // Call MLM to determine if a dressing change order needs created + DocDressingObs := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_CREATE_DRESSING_CHANGE_FROM_LINE_INSERTION_OBS{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocDressingObs WITH thisDocumentCommunication; + + //Call MLM to update status board IV Haldol dosage amount when charting the cardiac rhythm + IVHaldolStatusBoardUpdate := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_IV_HALDOL_STATUSBOARD{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL IVHaldolStatusBoardUpdate WITH thisDocumentCommunication; + + //Call MLM to create Order "Decrease Function" Order + DecreaseFunctionOrder := MLM {{{SINGLE-QUOTE}}}DOC_SCH_CREATE_ORDER_DECREASE_FUNCTION{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DecreaseFunctionOrder WITH thisDocumentCommunication; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_ADULT_ASSESSMENT_OPEN.mlm b/MLMStripper/bin/Debug/DOC/DOC_ADULT_ASSESSMENT_OPEN.mlm new file mode 100644 index 0000000..cdf889a --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_ADULT_ASSESSMENT_OPEN.mlm @@ -0,0 +1,66 @@ +maintenance: + + title: DOC_ADULT_ASSESSMENT_OPEN;; + mlmname: DOC_ADULT_ASSESSMENT_OPEN;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Juliet M. Law;; + specialist: ;; + date: 2014-03-24;; + validation: testing;; + +library: + purpose: + ;; + explanation: + + + Change history + + 03.24.2014 JML Created; copied from DOC_ADULT_ASSESSMENT_CLOSE + 01.25.2016 JML CSR 33953: Call MLM on flowsheet close to alert if catheter risk not charted. + 05.10.2016 DJW CSR#34412 Advance Directive Follow Up + 02.17.2017 STH CSR#: 35129 - ADDED CALL TO DOC_FUNC_HEP_C_SCREENING + 10.23.2017 jml CSR# 26413: Call to DOC_FUNC_POLST_FOLLOWUP_CHARTING_REMINDER + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Receive arguments from the flowsheet + (thisDocumentCommunication) := argument; + + // Call MLM to determine if a dressing change order needs created + Doc_Anticoag_Platelet_Alert := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_ANTICOAG_PLATELET_ALERT{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL Doc_Anticoag_Platelet_Alert WITH thisDocumentCommunication; + + Doc_VTE_Override := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_VTE_PHYSICIAN_OVERRIDE{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL Doc_VTE_Override WITH thisDocumentCommunication; + + //Call MLM to alert on urinary catheter risk assessment + DocCatheterRiskObs := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_URINARY_CATHETER_CHART_ALERT{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocCatheterRiskObs WITH thisDocumentCommunication; + + //Call MLM to alert on advance directive follow up + DocAdvDirFollowup := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_ADVANCE_DIRECTIVE_FOLLOWUP_CHARTING_REMINDER{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocAdvDirFollowup WITH thisDocumentCommunication; + + //Call MLM to alert on POLST follow up + DocPOLSTFollowUp := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_POLST_FOLLOWUP_CHARTING_REMINDER{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocPOLSTFollowUp WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + HepScreen := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_HEP_C_SCREENING{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL HepScreen with thisDocumentCommunication; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_BIPAP_CPAP.mlm b/MLMStripper/bin/Debug/DOC/DOC_BIPAP_CPAP.mlm new file mode 100644 index 0000000..b06400d --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_BIPAP_CPAP.mlm @@ -0,0 +1,141 @@ +maintenance: + + title: DOC_BIPAP_CPAP ;; + mlmname: DOC_BIPAP_CPAP ;; + arden: version 2.5;; + version: 6.00;; + institution: St. Clair Hospital ;; + author: Shivprasad Jadhav;; + specialist: Shubha Rai;; + date: 2015-11-16;; + validation: testing;; + +library: + purpose: When BiPAP or CPAP is selected, auto select the instruction to patient to bring in home device in [Adult Patient Profile], [Pediatric Patient Profile],[OB Patient Profile];; + explanation: + Change History + ------------------------------------------------- + 18-11-2015 GOS MLM Created CSR :33757- BIPAP/CPAP change in [Adult Patient Profile],[Adult Patient Profile-Behavirol Health], + [Pediatric Patient Profile],[OB Patient Profile] + + ;; + keywords: + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + (this_documentCommunication) := argument; + + // Extract interesting parts of the object model + DocumentName := this_documentCommunication.DocumentName ; + (thisStructuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + (UserGUID) := this_documentCommunication.UserGUID ; + (this_curr_valobj) := this_currentObs.valueobj; + // Get the client and visit GUIDs + clientGuid := this_documentCommunication.ClientGUID; + visitGuid := this_documentCommunication.ClientVisitGUID; + chartGuid := this_documentCommunication.ChartGUID; + Client_Document_GUID := this_FS_doc.ClientDocumentGUID; + + //z:=thisParameters.Records__; + If ( DocumentName = "Adult Patient Profile" ) or ( DocumentName = "Adult Patient Profile - Behavioral Health" ) Then + this_parametername := first of (thisParameters where thisParameters.Name = "PRO resp device"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = this_parametername.ParameterGUID); + + If true in (theObservation.ValueObj.ListItemsList.IsSelected where + theObservation.ValueObj.ListItemsList.Value = "BiPAP..." ) then chronic := "BIPAP"; + Endif; + If chronic Is Null Then + If true in (theObservation.ValueObj.ListItemsList.IsSelected where + theObservation.ValueObj.ListItemsList.Value = "CPAP..." ) then chronic := "CPAP"; + Endif; + EndIf; + + If chronic in ("BIPAP","CPAP") Then + MLM_DIPA := MLM {{{SINGLE-QUOTE}}}UTIL_OBJECT_Customize_DIPA_MLM{{{SINGLE-QUOTE}}}; + + prm_Resp_Device := First of (thisParameters where thisParameters.Name = "SCH_resp home device instruction"); + Var1 := "Instructed patient to bring in home device."; + + If exists Var1 then + + Obs_Comf_Vi := CALL MLM_DIPA WITH this_DocumentCommunication,prm_Resp_Device, Var1 as string ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList,Obs_Comf_Vi ); + Endif; + + Endif; + ElseIf DocumentName = "Pediatric Patient Profile" Then + + this_parametername := first of (thisParameters where thisParameters.Name = "PRO resp device peds"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = this_parametername.ParameterGUID); + + If true in (theObservation.ValueObj.ListItemsList.IsSelected where + theObservation.ValueObj.ListItemsList.Value = "BiPAP..." ) then chronic := "BIPAP"; + Endif; + If chronic Is Null Then + If true in (theObservation.ValueObj.ListItemsList.IsSelected where + theObservation.ValueObj.ListItemsList.Value = "CPAP..." ) then chronic := "CPAP"; + Endif; + EndIf; + + If chronic in ("BIPAP","CPAP") Then + MLM_DIPA := MLM {{{SINGLE-QUOTE}}}UTIL_OBJECT_Customize_DIPA_MLM{{{SINGLE-QUOTE}}}; + + prm_Resp_Device := First of (thisParameters where thisParameters.Name = "SCHCK_PRO resp home device ped"); + Var1 := "Instructed patient to bring in home device."; + + if exists Var1 then + + Obs_Comf_Vi := CALL MLM_DIPA WITH this_DocumentCommunication,prm_Resp_Device, Var1 as string ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList,Obs_Comf_Vi ); + Endif; + + Endif; + ElseIf DocumentName = "OB Patient Profile" Then + + this_parametername := first of (thisParameters where thisParameters.Name = "PRO resp device ob"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = this_parametername.ParameterGUID); + + If true in (theObservation.ValueObj.ListItemsList.IsSelected where + theObservation.ValueObj.ListItemsList.Value = "BiPAP..." ) then chronic := "BIPAP"; + Endif; + If chronic Is Null Then + If true in (theObservation.ValueObj.ListItemsList.IsSelected where + theObservation.ValueObj.ListItemsList.Value = "CPAP..." ) then chronic := "CPAP"; + Endif; + EndIf; + + If chronic in ("BIPAP","CPAP") Then + MLM_DIPA := MLM {{{SINGLE-QUOTE}}}UTIL_OBJECT_Customize_DIPA_MLM{{{SINGLE-QUOTE}}}; + + prm_Resp_Device := First of (thisParameters where thisParameters.Name = "SCHCK_PRO resp home device OB"); + Var1 := "Instructed patient to bring in home device."; + + if exists Var1 then + + Obs_Comf_Vi := CALL MLM_DIPA WITH this_DocumentCommunication,prm_Resp_Device, Var1 as string ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList,Obs_Comf_Vi ); + Endif; + + Endif; + EndIf; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_BIPAP_CPAP_HI_ORDER.mlm b/MLMStripper/bin/Debug/DOC/DOC_BIPAP_CPAP_HI_ORDER.mlm new file mode 100644 index 0000000..6731ed2 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_BIPAP_CPAP_HI_ORDER.mlm @@ -0,0 +1,225 @@ +maintenance: + + title: DOC_BIPAP_CPAP_HI_ORDER ;; + mlmname: DOC_BIPAP_CPAP_HI_ORDER;; + arden: version 2.5;; + version: 1.00;; + institution: St.Clair Hospital ;; + author: Sandy Zhang ;; + specialist: ;; + date: 2017-06-05;; + validation: testing;; + +library: + purpose: When user selects “BIPAP" and/or "CPAP” from the below structured notes, then auto generate the “Respiratory consult" order and Health issue for "Sleep Apnea” + These structured notes have this MLM attached to the {{{SINGLE-QUOTE}}}Respiratory Device/Implant{{{SINGLE-QUOTE}}} attribute: + 1) Adult Patient Profile (KBC Adult Patient Profile 2.0) + 2) Adult Patient Profile - Behavioral Health + 3) OB Patient Profile (KBC OB Patient Profile 2.0) + ;; + explanation: + + Change History + + 06.05.2017 SZ CSR# 35226 - Project started - BiPAP and CPAP Health Issue and Respiratory Consult Order creation + + ;; + keywords: BiPAP, CPAP, Health Issue, Respiratory Consult Order + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + + + (this_documentCommunication) := argument; + + DocumentName := this_documentCommunication.DocumentName ; + thisStructuredNoteDoc := this_documentCommunication.DocumentConfigurationObj; + + //grab values we are interested in + clientGuid := this_documentCommunication.ClientGUID; + visitGuid := this_documentCommunication.ClientVisitGUID; + chartGuid := this_documentCommunication.ChartGUID; + + Current_Obs_Obj := this_documentCommunication.CurrentObservationObj; + Val_Obj := Current_Obs_Obj.ValueObj; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + + // Only trigger MLM if document name matches + If DocumentName in ("Adult Patient Profile", "Adult Patient Profile - Behavioral Health", "OB Patient Profile" ) Then + + (Bipap_values) := last(Val_Obj.ListItemsList where (Val_Obj.ListItemsList.Value = "BiPAP") or (Val_Obj.ListItemsList.Value = "BiPAP...")); + (Cpap_values) := last(Val_Obj.ListItemsList where (Val_Obj.ListItemsList.Value = "CPAP") or (Val_Obj.ListItemsList.Value = "CPAP...")); + + // when {{{SINGLE-QUOTE}}}BiPAP{{{SINGLE-QUOTE}}} or {{{SINGLE-QUOTE}}}CPAP{{{SINGLE-QUOTE}}} is selected then execute a check for sleep apnea health issue and respiatory consult order + If (Bipap_values.IsSelected = true) or (Cpap_values.IsSelected = true) then + + // SQL checks if patient has a current ICD10 Health Issue of Sleep Apnea + (SleepApneaHI) := read last { + "select shortname" + ||" from cv3healthissuedeclaration " + ||" where clientguid = " || sql(clientGuid) + ||" and active = 1 and status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} And ICD10Code is not null" + ||" and typecode = {{{SINGLE-QUOTE}}}problem-Chronic{{{SINGLE-QUOTE}}} and shortname like {{{SINGLE-QUOTE}}}%Sleep apnea%{{{SINGLE-QUOTE}}}" + }; + + // SQL checks if patient has an active respiatory consult order + (RespiratoryConsult_Order) := read last { + "select ocmi.Name" + ||" from cv3ordercatalogmasteritem ocmi with (nolock)" + ||" join cv3order o with (nolock) on o.ordercatalogmasteritemguid = ocmi.guid" + ||" where" + ||" o.clientguid = " || sql(clientGuid) + ||" and o.chartguid = " || sql(chartGuid) + ||" and o.clientvisitguid = " || sql(visitGuid) + ||" and o.OrderStatusLevelNum >= 15 and o.OrderStatusLevelNum not in (69, 70) " + ||" and ocmi.Name = {{{SINGLE-QUOTE}}}Respiratory Consult{{{SINGLE-QUOTE}}}" + }; + + // if patient is missing {{{SINGLE-QUOTE}}}sleep apnea{{{SINGLE-QUOTE}}} health issue and/or {{{SINGLE-QUOTE}}}respiratory consult{{{SINGLE-QUOTE}}}, + // then create a dialog box to see if user would like to create them + If (SleepApneaHI is null) or (RespiratoryConsult_Order is null) then + + // dialog box asks if user would like to create health issue and respiratory consult order + dlg_result := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with + "\n This selection will create a chronic health issue of {{{SINGLE-QUOTE}}}Sleep Apnea{{{SINGLE-QUOTE}}} and {{{SINGLE-QUOTE}}}Respiratory Consult{{{SINGLE-QUOTE}}} order " || + "\n\n Click {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to confirm your selection. " || + "\n\n Click {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} if you wish to change your selection. " || + "\n " + ,"BiPAP/CPAP Documentation ", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + // If {{{SINGLE-QUOTE}}}yes{{{SINGLE-QUOTE}}} button is selected then we check if the Health Issue exists, + // if it {{{SINGLE-QUOTE}}}does exist{{{SINGLE-QUOTE}}} then move on to check for Resp Consult order exists, if it {{{SINGLE-QUOTE}}}doesn{{{SINGLE-QUOTE}}}t exist{{{SINGLE-QUOTE}}} then create a sleep apnea HI. + // Then check if Resp Consult order exists, if yes then move on, if no then create it. + + If (dlg_result as string) = "Yes" then + + If (SleepApneaHI is null) then + + /********************* create a chronic health issue of {{{SINGLE-QUOTE}}}Sleep Apnea{{{SINGLE-QUOTE}}} here *******************************/ + hitype := "Problem-Chronic"; + hiname := "Sleep apnea"; + hinumber:= "G47.30" ; + hischeme:= "ICD10" ; + hitext := "Please see Adult Patient Profile document for BiPAP/CPAP Settings. *Created from Patient Profile information.* " ; + + Func_Create_HI_MLM := mlm {{{SINGLE-QUOTE}}}SCH_Func_Create_Health_Issue{{{SINGLE-QUOTE}}}; + void := call Func_Create_HI_MLM with (visitGuid,hiname,hinumber,hitext,hitype,hischeme); + + HI_created := "HI for sleep apnea was created"; + endif; + + + If (RespiratoryConsult_Order is null) then + + /********************* create a general order for {{{SINGLE-QUOTE}}}Respiratory Consult{{{SINGLE-QUOTE}}} here *******************************/ + + // setup to generate our {{{SINGLE-QUOTE}}}Respiratory Consult{{{SINGLE-QUOTE}}} order + try + locationGuid := read last { + "SELECT CurrentLocationGUID, touchedWhen" + || " FROM CV3ClientVisit with (nolock)" + || " WHERE GUID = " || Sql(visitGuid) + || " AND ClientGUID = " || Sql(clientGuid) + , primaryTime = touchedWhen + }; + + care_provider_guid, care_provider_name := read last { + " SELECT cp.guid, cp.DisplayName" + ||" FROM CV3ClientVisit cv with (nolock)" + ||" join cv3careprovider cp on cp.displayname = cv.providerdisplayname" + ||" WHERE cv.GUID = " || Sql(visitGuid) + ||" AND cv.ClientGUID = " || Sql(clientGuid) + ||" AND cp.Active = 1" + }; + + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + care_provider_obj:= call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((care_provider_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((locationGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + + Order_Creation_Reason := "Created per protocol"; + RequestingSource := ""; + SessionType := "Standard"; + SessionReason := ""; + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}CommonData: {{-R}}\n" || ex.Message || "\n\n"; + + if location_obj IS NOT Null then void := call location_obj.Dispose; location_obj := null; endif; + if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif; + if client_visit_obj IS NOT Null then void := call client_visit_obj.Dispose; client_visit_obj := null; endif; + endcatch; + + + // this generates our {{{SINGLE-QUOTE}}}Respiratory Consult{{{SINGLE-QUOTE}}} order + try + order_catalog_obj:= call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with ("Respiratory Consult"); + + Order_Obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder + with client_visit_obj, // good + order_catalog_obj, // good + Order_Creation_Reason, // good + care_provider_obj, // good + RequestingSource, // good + SessionType, // good + SessionReason, // good + location_obj, // good + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; + + order_obj.SpecialInstructions := "Please see Adult Patient Profile document for BiPAP/CPAP Settings. *Created from Patient Profile information.*" ; + + retval := call order_obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with "NUR_NotifyType", "Physician" ; + check_box := call Order_Obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with "Using CPAP/BiPAP home",true; + additional_comments := call Order_Obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with "NUR_GenAdditionalTxt","Please see Patient Profile document for BiPAP/CPAP Settings. *Created from Patient Profile information.*"; + + void := call Order_Obj.Save; + + if order_catalog_obj IS NOT Null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}New Other Order: {{-R}}\n" || ex.Message || "\n\n"; + if Order_Obj IS NOT Null then void := call Order_Obj.Dispose; Order_Obj := null; endif; + endcatch; + + // Dispose of the objects + if location_obj IS NOT Null then void := call location_obj.Dispose; location_obj := null; endif; + if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif; + if client_visit_obj IS NOT Null then void := call client_visit_obj.Dispose; client_visit_obj := null; endif; + create_respcon_order := "respiratory consult order creation was attempted"; + + endif; // creates RespiratoryConsult_Order if it doesn{{{SINGLE-QUOTE}}}t exist + endif; // If "Yes" or "No" selected + + + endif; // if (SleepApneaHI is null) - If HI doesn{{{SINGLE-QUOTE}}}t exist then execute + endif; // if bipap or cpap is selected + endif; // If DocumentName is {{{SINGLE-QUOTE}}}adult patient profile{{{SINGLE-QUOTE}}} ...... + + + + + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_BIPAP_CPAP_UNIVERSAL.mlm b/MLMStripper/bin/Debug/DOC/DOC_BIPAP_CPAP_UNIVERSAL.mlm new file mode 100644 index 0000000..f4bc686 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_BIPAP_CPAP_UNIVERSAL.mlm @@ -0,0 +1,56 @@ +maintenance: + + title: DOC_BIPAP_CPAP_UNIVERSAL ;; + mlmname: DOC_BIPAP_CPAP_UNIVERSAL;; + arden: version 2.5;; + version: 1.00;; + institution: St.Clair Hospital;; + author: Sandy Zhang ;; + specialist: Debbie Eiler ;; + date: 2017-06-12;; + validation: testing;; + +library: + purpose: calls MLMs below when any of the {{{SINGLE-QUOTE}}}Respiratory Device/Implant{{{SINGLE-QUOTE}}} checkbox options are modified + attached to: 1) {{{SINGLE-QUOTE}}}KBC Adult Patient Profile 2.0{{{SINGLE-QUOTE}}} + 2) Adult Patient Profile - Behavioral Health + 3) KBC OB Patient Profile 2.0 + + and attribute {{{SINGLE-QUOTE}}}! REVIEW OF SYSTEMS (Prior to Admission){{{SINGLE-QUOTE}}} -> {{{SINGLE-QUOTE}}}PRO Respiratory QA{{{SINGLE-QUOTE}}} -> {{{SINGLE-QUOTE}}}PRO resp device{{{SINGLE-QUOTE}}} + and attribute {{{SINGLE-QUOTE}}}Review of Systems (Prior to Admission){{{SINGLE-QUOTE}}} -> {{{SINGLE-QUOTE}}}PRO Respiratory OB QA{{{SINGLE-QUOTE}}} -> {{{SINGLE-QUOTE}}}PRO resp device ob{{{SINGLE-QUOTE}}} + + ;; + explanation: + + Change History + + 06.12.2017 SZ CSR# 35226 BiPAP and CPAP Health Issue and Respiratory Consult Order creation + + ;; + keywords: + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + + (thisDocumentCommunication) := argument; + autoselect_CPAP_BiPAP_instructions := MLM {{{SINGLE-QUOTE}}}DOC_BIPAP_CPAP{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL autoselect_CPAP_BiPAP_instructions WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + BiPAP_CPAP_HI_order_creation := MLM {{{SINGLE-QUOTE}}}DOC_BIPAP_CPAP_HI_ORDER{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL BiPAP_CPAP_HI_order_creation WITH thisDocumentCommunication; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_CALL_MED_REC.mlm b/MLMStripper/bin/Debug/DOC/DOC_CALL_MED_REC.mlm new file mode 100644 index 0000000..8a116ba --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_CALL_MED_REC.mlm @@ -0,0 +1,122 @@ +maintenance: + + title: Call Med Rec;; + filename: Doc_Call_Med_Rec;; + arden: version 2;; + version: 1.00;; + institution: Eclipsys Corp;; + author: Eclipsys Corp;; + specialist: ;; + date: 2008-11-18;; + validation: testing;; + +library: + purpose: This mlm open Orders Reconciliation Manager from a document + ;; + explanation: + + 05.31.2019 JML 18.4 Upgrade modification; Launch ORM radio button not unchecking + if observation exists in more than one section on structured note + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + (this_documentCommunication) := argument; + /*******************Make Changes To Spelling And Flags In This Section*******************/ + + /* Set to true if a decision.log is needed.*/ + log_execution_info := FALSE; + + /****** Place all your reading and updating here **********/ + + // Include MLM to reference assemblies needed for this MLM. + // This MLM specifically uses the assemblies mscorlib and + // ObjectsPlusXA.SCM.Forms + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + +// SCH_DI OrdRec Launch + launchordrec := false; + theParameterx := ( thisParameters where thisParameters.Name = "SCH_DI Launch Ord Rec" ); + + if ( exists theParameterx ) then + + //Determine if Obs exists more than once on Note + for i IN 1 seqto count theParameterx do + //this_parametername := first of (thisParameters where thisParameters.Name = "SCH_DI Launch Ord Rec"); + this_parametername := theParameterx[i]; + + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + selectedItem.IsSelected := false; + + listItems := (listItems, selectedItem); + + ENDDO; + + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentObj); + enddo; + + endif; + + + + visit_guid := this_documentCommunication.ClientVisitGUID; + try + // Create the Order Reconciliation Manager object + + order_rec_mgr_obj := new NET_OBJECT {{{SINGLE-QUOTE}}}OrderReconciliationManager{{{SINGLE-QUOTE}}}; + order_rec_mgr_obj.ClientVisitPrimaryKey := (( visit_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + void := call order_rec_mgr_obj.ShowDialog; + + endtry; + catch exception ex + if ( order_rec_mgr_obj is NOT NULL ) then + void:= call order_rec_mgr_obj.Dispose; + order_rec_mgr_obj:= NULL; + endif; + endcatch; + + + ;; + evoke: // No evoke statement + ;; + logic: + conclude true; // always concludes TRUE + ;; + action: + return this_documentCommunication; + + ;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_CALL_SPECIMEN_PATHOLOGY.mlm b/MLMStripper/bin/Debug/DOC/DOC_CALL_SPECIMEN_PATHOLOGY.mlm new file mode 100644 index 0000000..ca21886 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_CALL_SPECIMEN_PATHOLOGY.mlm @@ -0,0 +1,200 @@ +maintenance: + + title: DOC_CALL_SPECIMEN_PATHOLOGY ;; + mlmname: DOC_CALL_SPECIMEN_PATHOLOGY;; + arden: version 2.5;; + version: 0.00;; + institution: ;; + author: Brijesh Chauhan (Allscripts) ;; + specialist: ;; + date: 2017-08-16;; + validation: testing;; + +library: + purpose: Print Speciment Pathology report after document will complete + ;; + explanation: + + **Change History** + 1) 08/16/2017 New MLM created + 2) 10/9/2018 STH CSR#: 37482 - Modified original and updated to work. {Go-Live 10/29/2018} + ;; + keywords: + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + + mlm_name := "DOC_CALL_SPECIMEN_PATHOLOGY"; + + standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "SCMLib"; + using "SCM.Common.Interfaces"; + using namespace "SCMLib"; + using namespace "SCM.Common.Interfaces"; + + + error_destination := destination { Alert } with [ + alert_type := "warning", + short_message := "ObjectsPlus Error from MLM", + priority := "low", + scope := "chart", + Rule_group := "ObjectsPlus Error from MLM", + Rule_number := 1003, + Rule_subgroup := "", + Send_alert_with_order := "", + Alert_dialog_settings := "", + Display_alert := true ]; + error_dtl := ""; + client_doc_enter := EVENT { ClientDocumentEnter USER ClientDocument : WHERE DocumentName IN ("Endo IntraOp Nursing Note","MLSC IntraOp Nursing Note","IntraOp Nursing Note")}; + client_doc_modify := EVENT { ClientDocumentModify USER ClientDocument : WHERE DocumentName IN ("Endo IntraOp Nursing Note","MLSC IntraOp Nursing Note","IntraOp Nursing Note")}; + + + ClientGUID := EVOKINGOBJECT.ClientGUID; + ChartGUID := EVOKINGOBJECT.ChartGUID; + VisitGUID := EVOKINGOBJECT.ClientVisitGUID; + CD_GUID := EVOKINGOBJECT.GUID; + errhndl := false; + tstinfo := EVOKINGOBJECT.ClientObservationDocument; + tstinfo2 := tstinfo.ClientObservation; + + + (CD_IsIncomplete, CD_Name) := read last {"SELECT + cd.isincomplete,cd.DocumentName + FROM CV3ClientVisit cv with (nolock) + + INNER JOIN SXACDObservationParameter ObsParam with (nolock) + ON cv.ClientGUID = ObsParam.ClientGUID + AND cv.ChartGUID = ObsParam.ChartGUID + AND ObsParam.IsCanceled = 0 + + INNER JOIN CV3ClientDocument CD with (nolock) + on ObsParam.clientguid = cd.clientguid + and ObsParam.chartguid = cd.ChartGUID + and ObsParam.ClientVisitGUID = cd.ClientVisitGUID + and cd.GUID = ObsParam.OwnerGUID + + LEFT OUTER JOIN SCMObsFSListValues with (nolock) + ON cv.ClientGUID = SCMObsFSListValues.ClientGUID + AND ObsParam.ObservationDocumentGUID = SCMObsFSListValues.ParentGUID + + INNER JOIN CV3ObsCatalogMasterItem ocmi with (nolock) + on obsparam.ObsMasterItemGUID = ocmi.GUID + and ocmi.name like {{{SINGLE-QUOTE}}}SCH OR specimen description[0-9]%{{{SINGLE-QUOTE}}} + + where cv.ClientGUID = " || sql(ClientGUID) + || " and cv.ChartGUID =" || sql(ChartGUID) + || " and cv.guid = " || sql(VisitGUID) + || " and ObsParam.OwnerGUID = " || sql(CD_GUID) || " "}; + //If there client document (structured note) does not contain at least 1 specimen AND/OR the client document is saved as incomplete the MLM will skip all the below logic and do nothing. + if((count(CD_Name)>0) and (CD_IsIncomplete = false)) then + + //Get the CaseID from thew end of the clientdocumentname to pass into the HVCLine1 parameter of the report parameters + dash_CDName := find "-" in string CD_Name; + if(dash_CDName > 0) then + Len_CaseID := (length of CD_Name) - (dash_CDName); + CaseID := substring (Len_CaseID) characters starting at (dash_CDName + 1) from CD_Name; + endif; + + //DEFAULT BROADCAST PRINTER TO PDFHIS + //If the structured note starts with ENDO print to ENDO printer, if the document starts with MLSC print to MLSC printer otherwise print to OR printer. + BroadcastPrinter := "PDFHIS"; + Printcopies := 2; + if(CD_Name matches pattern "Endo%") then + BroadcastPrinter := "ENDO - GE LAB BACK"; + Printcopies := 1; + elseif (CD_Name matches pattern "MLSC%") then + BroadcastPrinter := "MLSC Surgical"; + else + BroadcastPrinter := "OR"; + endif; + + //Make sure we got a valid case ID from the end of the structured note. If the IntraOp note was entered in Acute Care (instead of surgical care) there will be no case identifier added to end of note. + if(caseID <> "" and caseID is not null) then + try + //Start building the report call object based on the report version name SCH_Specimen_Pathology_MLM + report_request_obj := call {{{SINGLE-QUOTE}}}ObjectsPlusXA.SunriseClinicalManager.ReportRequest{{{SINGLE-QUOTE}}}.CreateReportRequest with ("SCH_Specimen_Pathology_MLM" as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}); + + //Make sure a valid report object was created, and if so create a list containg the report parameters availble. + if (report_request_obj.Parameters is not null and report_request_obj.Parameters.Count > 0) + then + report_parameter_list := (); + for parameterIndex in (1 seqto report_request_obj.Parameters.Count) + do + report_parameter_list := report_parameter_list, report_request_obj.Parameters[parameterIndex]; + enddo; + endif; + //set variables equal to the report parameters from the list that we need to modify for the report to run against proper patient and note. + param_VisitGUID := first(report_parameter_list where report_parameter_list.Label = "ClientVisitGUID"); + param_ClientDocGUID := first (report_parameter_list where report_parameter_list.Label = "DocumentGUID"); + param_CaseID := first (report_parameter_list where report_parameter_list.Label = "Case Identifier:"); + + //make sure the parameters are set to allow modification, and if so set the parater values equal to the proper case ID, Visit guid and document guid + if param_CaseID.AllowModification then + void := call param_CaseID.{{{SINGLE-QUOTE}}}SetValue{{{SINGLE-QUOTE}}} with STRING(CaseID) as {{{SINGLE-QUOTE}}}System.String{{{SINGLE-QUOTE}}}; + endif; + if param_VisitGUID.AllowModification then + void := call param_VisitGUID.{{{SINGLE-QUOTE}}}SetValue{{{SINGLE-QUOTE}}} with STRING(VisitGUID) as {{{SINGLE-QUOTE}}}System.String{{{SINGLE-QUOTE}}}; + endif; + + if param_ClientDocGUID.AllowModification then + void := call param_ClientDocGUID.{{{SINGLE-QUOTE}}}SetValue{{{SINGLE-QUOTE}}} with STRING(CD_GUID) as {{{SINGLE-QUOTE}}}System.String{{{SINGLE-QUOTE}}}; + endif; + + //set the report object to use broadcast print and set the proper printer based on the structured note name defined above. + report_request_obj.PrintPolicy := 4; + report_request_obj.NumberOfCopies := Printcopies; + report_request_obj.PrintJobDestination := BroadcastPrinter; + + + // print the report + void := call report_request_obj.Save; + + // Call Dispose on report_request_obj to clean it up + if report_request_obj is not null + then + void := call report_request_obj.Dispose; + report_request_obj := null; + endif; + + endtry; + catch exception ex + error_dtl := ex; + errhndl := true; + if report_request_obj is not null + then + void := call report_request_obj.Dispose; + report_request_obj := null; + endif; + endcatch; + endif; + + endif; + ;; + priority: 50 + ;; + evoke: + + 3 seconds after time of client_doc_enter; + 3 seconds after time of client_doc_modify; + ;; + logic: + conclude true; + ;; + action: + if errhndl then + write "An error has occured in the MLM {{+B}}" || mlm_name || "{{-B}} " + ||"Please notify your System Administrators that an error message has " + ||"occurred for this patient. They will review the following error " + ||"message: \n\n" || "Case ID: " || CaseID + || "\n VisitGUID: " || VisitGUID + || "\n CD_GUID: " || CD_GUID + || "\n\nERROR: " || error_dtl at error_destination; + endif; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_CAM_SCORE_ADULT_ASESSMENT.mlm b/MLMStripper/bin/Debug/DOC/DOC_CAM_SCORE_ADULT_ASESSMENT.mlm new file mode 100644 index 0000000..2a87672 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_CAM_SCORE_ADULT_ASESSMENT.mlm @@ -0,0 +1,110 @@ +maintenance: + + title: DOC_CAM_SCORE_ADULT_ASESSMENT;; + mlmname: DOC_CAM_SCORE_ADULT_ASESSMENT;; + arden: version 6.1;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Shivprasad Jadhav ;; + specialist: Shivprasad Jadha, Allscripts Corporation;; + date: 2015-01-10;; + validation: testing;; + +library: + purpose: + ;; + explanation: + + Change history + + 2015-01-10JML CSR 33048: Create date. + + 2016-06-24 - STH - CSR#: 34407 - Modified flowsheet observations to individual items with yes/no answers and changes CAM score to be + positive or negative instead of a number. {Go-Live 7/12/2016} + + 2016-06-24 - STH - CSR#: 34407 (CA Service Desk Ticket #: 2249594 ) - Issue reported if all no{{{SINGLE-QUOTE}}}s selected the score is not populating with Negative. + There was logic originally if all were unanswered to not populate an answer; however all no{{{SINGLE-QUOTE}}}s also was causing no + answer. Changed logic to always populate negative unless 1,2 are selected and 3 and/or 4 is also selected then + it will be positive. + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // Receive arguments from the structured note + (this_documentCommunication) := argument; + + //Get The Flowsheet Name + (this_FS_doc) := this_documentCommunication.DocumentConfigurationObj; + //Get the Parameter List + (this_parms) := this_FS_doc.ParametersList; + //Paramters defination + (this_curr_col) := this_FS_doc.Currentcolumn; + + (this_currentObs) := this_documentCommunication.CurrentObservationObj; + + + this_observations := this_curr_col.chartedobservationslist; + + + //Document Types + STRUCTUREDNOTE := "StructuredNote"; + + //Event Types + DOCUMENTCLOSING := "DocumentClosing"; + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTOPENING := "DocumentOpening"; + AcuteOnset := false; + Inattention := false; + Disorganized := false; + AlteredLOC := false; + //Setting debugFlag to True will allow popup dialogs containing debug information to appear + debugFlag := false; + CAM_Parameters := ("SCH_AI_Acute onset/ fluctuating course","SCH_AI_Inattention","SCH_AI_Disorganized Speech","SCH_AI_Altered LOC"); + CAM_Param_List := (this_parms where this_parms.Name in CAM_Parameters); + for x in 1 seqto count(CAM_Param_List) do + CAM_Obs := first of (this_observations where this_observations.ParameterGUID in CAM_Param_List[x].ParameterGUID ); + CAM_Value := first of (CAM_Obs.ValueObj.ListItemsList.Value where CAM_Obs.ValueObj.ListItemsList.isselected = true); + if(CAM_Value = "yes") then + if(CAM_Param_list[x].Name = "SCH_AI_Acute onset/ fluctuating course") then + AcuteOnset := true; + elseif(CAM_Param_list[x].Name = "SCH_AI_Inattention") then + Inattention := true; + elseif(CAM_Param_list[x].Name = "SCH_AI_Disorganized Speech") then + Disorganized := true; + elseif(CAM_Param_list[x].Name = "SCH_AI_Altered LOC") then + AlteredLOC := true; + endif; + endif; + enddo; + MLM_DIPA := MLM {{{SINGLE-QUOTE}}}UTIL_OBJECT_DIPA_MLM{{{SINGLE-QUOTE}}}; + + prm_edr := First of (this_parms where this_parms.Name = "AS confusion assess FT"); + + If ((AcuteOnset = true and Inattention = true and Disorganized = true) + or (AcuteOnset = true and Inattention = true and AlteredLOC = true)) then + Val := "Positive"; + else + Val := "Negative"; + endif; + + + + Obs_edr := CALL MLM_DIPA WITH this_DocumentCommunication,prm_edr, Val as string ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, + Obs_edr); + + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_CLINICAL_SCALES_FLOWSHEET.mlm b/MLMStripper/bin/Debug/DOC/DOC_CLINICAL_SCALES_FLOWSHEET.mlm new file mode 100644 index 0000000..7497a94 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_CLINICAL_SCALES_FLOWSHEET.mlm @@ -0,0 +1,181 @@ +maintenance: + + title: DOC_Clinical_Scales_Flowsheet;; + mlmname: DOC_Clinical_Scales_Flowsheet;; + arden: version 2.5;; + version: 1.02;; //Release 5.5 SP1/FP1 and 6.0/6.1 SU2 and higher + institution: St. Clair, Allscrtips;; + author: Shawn Head;; + specialist: Janit Nordin;; + date: 2016-04-12;; + validation: testing;; + +library: + purpose: + + This MLM will automatically populate values based on the clinical scales values for PHQ-9 and PHQ-7 + ;; + explanation: + + Modification history: + + 04.12.2016 - STH CSR#: 33982 - created + 07.23.2019 - TMS CSR#: 37676 - Change log_execution_info to false per upgrade analysis. + ;; +keywords: Objects Plus, Education Log, Worklist, ARRA + ;; +knowledge: + type: data-driven;; + data: + + mlm_name := "DOC_EDUCATION_FS_PRECHECK"; + + CR := 13 formatted with "%c"; + LF := 10 formatted with "%c"; + CRLF:= CR||LF; + + //Set to true if a decision.log is needed for diagnostic purposes. Please refer to the CDS Authoring Guides for more information + log_execution_info:= false; + + // Specify which .NET assemblies need to be loaded for ObjectsPlus + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + set_cds_vars := MLM {{{SINGLE-QUOTE}}}CALLED_DOC_FS_DEFINITION_MLM{{{SINGLE-QUOTE}}}; + + + //--------------------------------------------------------------- + // Error destination + //--------------------------------------------------------------- +//"SYSTEM ALERT", +send_alert := "DoNotSend"; +error_destination := destination { Alert: warning, "ObjectsPlus Error from MLM", low, chart, "ObjectsPlus Error from MLM", 1003, send_alert, "No Override Allowed" }; + + // Receive arguments from the structured note + (this_DocumentCommunication) := argument; + + // Get the user, chart, client and visit GUIDs + if called_by_editor then + userguid := ""; + clientGuid := "9000001860200200"; //Admission, Holly + clientvisitguid := "9000003613200270";//Admission, Holly + chartguid := "9000003613100170";//Admission, Holly + else + userGuid := this_DocumentCommunication.UserGUID; + clientGuid := this_DocumentCommunication.ClientGUID; + clientvisitGuid := this_DocumentCommunication.ClientVisitGUID; + chartGuid := this_DocumentCommunication.ChartGUID; + endif; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + NumericValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid, ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + //Document Type + FLOWSHEET := "FlowSheet"; + + //Event Types + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTCLOSING := "DocumentClosing"; + DOCUMENTOPENING := "DocumentOpening"; + + (this_documentCommunication, client_guid, client_visit_guid, chart_guid, + user_guid, document_type, document_name, event_type, + configuration_guid, this_currentObs, CancelEventFlag, this_fs_doc, + authored_by_guid, isIOFlowsheetFlag, client_document_guid, this_parameters, + this_columnList, this_currentColumn, this_chartedObservationsList, + this_parameters_displayName, current_parameter, current_parameter_name, current_parameter_guid, + current_parameter_datatype, selectedItems, selectedItems_Value, current_value, + diagnostic_message, displayMessageFlag) := CALL set_cds_vars WITH (this_documentCommunication); + + Error_occurred := false; + //create a list of charted parameters that exist in the list of observartion names created above. + charted_parameters := (this_parameters where this_parameters.Name is in ("SCH_PHP_GAD Score","SCH_PHP_ PHQ")); + + for x in (1 seqto(count(charted_parameters))) do + Education_obs := charted_parameters[x]; + theCurrentColumn := first of ( this_columnList WHERE this_columnList.ClientDocumentGUID = this_currentObs.ClientDocumentGUID); + current_obs := first of ( theCurrentColumn.ChartedObservationsList WHERE theCurrentColumn.ChartedObservationsList.ParameterGUID = Education_obs.ParameterGUID); + + if(charted_parameters[x].Name = "SCH_PHP_ PHQ") then + PHQScore := (current_obs.ValueObj.Value as number); + if((PHQScore >= 0) and (PHQScore <= 4)) then + Depression_Severity := "Minimal"; + Recommend_action := "none"; + elseif((PHQScore >= 5) and (PHQScore <= 9)) then + Depression_Severity := "Mild"; + Recommend_action := "Watchful waiting, repeat at follow up"; + elseif((PHQScore >= 10) and (PHQScore <= 14)) then + Depression_Severity := "Moderate"; + Recommend_action := "Treatment plan, considering counseling, follow-up and/or pharmacotherapy"; + elseif((PHQScore >= 15) and (PHQScore <= 19)) then + Depression_Severity := "Moderately Severe"; + Recommend_action := "Active treatment with pharmacotherapy and/or psychotherapy"; + elseif((PHQScore >= 20)) then + Depression_Severity := "Severe"; + Recommend_action := "Immediate initiation of pharmacotherapy and, if severe impairment or poor response to therapy, expedited referral to a mental health specialist for psychotherapy and/or collaborative management "; + endif; + Depression_Param := first of (this_parameters WHERE this_parameters.Name = "SCH_PHP_PHQ Depression Severity"); + this_currentObj1 := NEW ObservationType; + this_currentObj1.ClientDocumentGUID := this_fs_doc.ClientDocumentGUID; + this_currentObj1.ParameterGUID := Depression_Param.ParameterGUID; + this_currentObj1.DataType := "FreeTextValue"; + this_currentObj1.ValueObj := NEW FreeTextValueType; + this_currentObj1.ValueObj.Value := Depression_Severity AS STRING; + + this_fs_doc.CurrentColumn.ChartedObservationsList := (this_fs_doc.CurrentColumn.ChartedObservationsList, this_currentObj1); + + Recomend_Param := first of (this_parameters WHERE this_parameters.Name = "SCH_PHP_PHQ Recommendations"); + this_currentObj2 := NEW ObservationType; + this_currentObj2.ClientDocumentGUID := this_currentObs.ClientDocumentGUID; + this_currentObj2.ParameterGUID := Recomend_Param.ParameterGUID; + this_currentObj2.DataType := "FreeTextValue"; + this_currentObj2.ValueObj := NEW FreeTextValueType; + this_currentObj2.ValueObj.Value := Recommend_action AS STRING; + + this_fs_doc.CurrentColumn.ChartedObservationsList := (this_fs_doc.CurrentColumn.ChartedObservationsList, this_currentObj2); + + elseif((charted_parameters[x].Name = "SCH_PHP_GAD Score") and ((current_obs.ValueObj.Value as number)>=0)) then + GADScore := (current_obs.ValueObj.Value as number); + + if((GADScore >= 0) and (GADScore <= 4)) then + Anxiety := "Minimal"; + elseif((GADScore >= 5) and (GADScore <= 9)) then + Anxiety := "Mild"; + elseif((GADScore >= 10) and (GADScore <= 14)) then + Anxiety := "Moderate"; + elseif((GADScore >= 15) /*and (PHQScore <= 27)*/) then + Anxiety := "Severe"; + endif; + Anxiety_Param := first of (this_parameters WHERE this_parameters.Name = "SCH_PHP_GAD Anxiety Severity"); + this_currentObj3 := NEW ObservationType; + this_currentObj3.ClientDocumentGUID := this_currentObs.ClientDocumentGUID; + this_currentObj3.ParameterGUID := Anxiety_Param.ParameterGUID; + this_currentObj3.DataType := Anxiety_Param.DataType; + this_currentObj3.ValueObj := NEW FreeTextValueType; + this_currentObj3.ValueObj.Value := Anxiety AS STRING; + + this_fs_doc.CurrentColumn.ChartedObservationsList := (this_fs_doc.CurrentColumn.ChartedObservationsList, this_currentObj3); + + endif; + enddo; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: + + conclude true; + + ;; + action: +return this_DocumentCommunication; ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_CLIN_DOC_SPECIALIST_SN.mlm b/MLMStripper/bin/Debug/DOC/DOC_CLIN_DOC_SPECIALIST_SN.mlm new file mode 100644 index 0000000..1db52a9 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_CLIN_DOC_SPECIALIST_SN.mlm @@ -0,0 +1,140 @@ +maintenance: + + title: DOC_CLIN_DOC_SPECIALIST_SN;; + mlmname: DOC_CLIN_DOC_SPECIALIST_SN;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Rich Schaeffer;; + specialist: Don Warnick;; + date: 2015-02-02;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 02.12.2015 DW CSR# 32616 Develop Application to allow for communication between clinical documentation specialist + 11.09.2015 DW CSR# 33624 Add Clairfication to Day of Discharge Note + 08.01.2017 DW CSR# 33968 CDS Improvements + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + ThisDocumentGuid := thisStructuredNoteDoc.ClientDocumentGUID; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + +// DOCUMENT OPEN + + if thisdocumentCommunication.EventType = "DocumentOpening" + then + + + (obsNamesList, obsNameValue, obsGuid) := read + { + " SET CONCAT_NULL_YIELDS_NULL off " + || " Select ocmi.name , o.ValueText, cd.guid " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " " + || " and cd.iscanceled = 0 " + || " and (cd.DocumentName like {{{SINGLE-QUOTE}}}Physician Progress%{{{SINGLE-QUOTE}}} or cd.DocumentName like {{{SINGLE-QUOTE}}}Day of Discharge Summary eNote%{{{SINGLE-QUOTE}}}) " + || " and ocmi.name like {{{SINGLE-QUOTE}}}SCH_CDA_Doc Response MLM%{{{SINGLE-QUOTE}}} " + || " order by ocmi.name desc " + }; + + +// || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + + + indexList2 := 1 seqto count (obsNamesList); + for j in indexList2 do + obsValue := last (first j from obsNameValue); + + CDSGuid:= SUBSTRING 16 CHARACTERS STARTING AT 3 FROM obsValue; + + if CDSGuid = ThisDocumentGuid + then + responsenumber:= SUBSTRING 1 CHARACTERS STARTING AT 1 FROM obsValue; + userdatestamp := SUBSTRING 100 CHARACTERS STARTING AT 19 FROM obsValue; + + if responsenumber = "1" then formattedText1 := "Agreed"; + elseif responsenumber = "2" then formattedText1 := "Disagreed"; + elseif responsenumber = "3" then formattedText1 := "Need to Discuss"; + elseif responsenumber = "4" then formattedText1 := "Reviewed"; + endif; + + formattedText2 := userdatestamp ; + endif; + + enddo; + + + // Write to the Structured Note Text Box + + + If formattedText1 is not null + + then + + formattedText1 := formattedText1 || " " || formattedText2; + + vitalSignsHL := first of (thisParameters where thisParameters.Name = "SCH_CDA_Response"); + + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := vitalSignsHL.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := formattedText1; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + + endif; + + endif; // Document Open + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_DIET_KBC_ADULT_ASSESSMENT.mlm b/MLMStripper/bin/Debug/DOC/DOC_DIET_KBC_ADULT_ASSESSMENT.mlm new file mode 100644 index 0000000..c76ea8a --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_DIET_KBC_ADULT_ASSESSMENT.mlm @@ -0,0 +1,250 @@ +maintenance: + + title: DOC_DIET_KBC_ADULT_ASSESSMENT ;; + mlmname: DOC_DIET_KBC_ADULT_ASSESSMENT;; + arden: version 6.1;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Shivprasad Jadhav ;; + specialist: Shivprasad Jadhav, Allscripts Corporation;; + date: 2015-09-01;; + validation: testing;; + +library: + purpose: + 1st senario-When user select criteria i.e {1-Patient consuming <50% of meals x 3days or 2-NPO or clear liquids >3days} + from [2."Adult Assessment/Intervention"flowsheet when selecting [Risk assessment/Screenings] observation in "Nutrition Risk Screen" then MLM should creat + a Dietitian Consult for the charted observation which has mention. + + 2nd Senario- If there is an active "Dietitian consult order with this indication i.e{1-Patient consuming <50% of meals x3 days} or {2- NPO or clear liquids >3 days} + has present or charted previously and "Dietitian Consult order was created previously then MLM should not create a 2nd order for Dietitian consult . + + 3rd Senario- If user select othere criteria except given criteria i.e {1-Patient consuming <50% of meals x3 days} or {2- NPO or clear liquids >3 days} then MLM should not creat + any "Dietitian Consult Order. + + ;; + explanation: + + Change history + + 10-01-2015 SJ CSR 32400 : Created date. + 09-28-2016 DJW HD#2113751 - Provide a message box to confirm the choice before automatically creating a Dietitian Consult Order + + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + + standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + // Receive arguments from the structured note + (this_documentCommunication) := argument; + + //Get The Flowsheet Name + (this_FS_doc) := this_documentCommunication.DocumentConfigurationObj; + (this_parms) := this_FS_doc.ParametersList; + (this_curr_col) := this_FS_doc.Currentcolumn; + + (this_currentObs) := this_documentCommunication.CurrentObservationObj; + this_observations := this_curr_col.chartedobservationslist; + (ClientGuid) := this_documentCommunication.ClientGUID; + (ChartGuid) := this_documentCommunication.ChartGUID; + (ClientVisitGuid) := this_documentCommunication.ClientVisitGUID; + (UserGuid) := this_DocumentCommunication.UserGUID ; + LocationGuid := read last {"SELECT CurrentLocationGUID FROM CV3ClientVisit where ClientGUID = " || ClientGuid}; +// read First {" Select cv.CurrentLocationGUID from Cv3ClientVisit cv With (nolock) Where cv.guid= "||SQL(ClientVisitGuid) ||" "} ; + CatalogItemName := "Dietitian Consult"; + + prm_med := First of (this_parms where this_parms.Name = "AS nut risk screen"); + Obs_med := first of (this_observations where this_observations.ParameterGUID = prm_med.ParameterGUID ); + val_med := Obs_med.ValueObj.listitemslist where Obs_med.ValueObj.listitemslist.isselected = true ; + + + /*a:=val_med[1].Value; + b:=val_med[2].Value; + DataItem1:=val_med[3].Value; + DataItem2:=val_med[4].Value; + e:=val_med[5].Value; */ + + + indexList := 1 seqto count (val_med); + + for i in indexList do + If val_med[i].Value="patient consuming <50% of meals x 3 days" Then + DataItem1 := "patient consuming <50% of meals x 3 days"; + Elseif val_med[i].Value="NPO or clear liquids > 3 days" Then + DataItem2 := "NPO or clear liquids > 3 days"; + Else DataItem1 := Null ; DataItem2 := Null ; + Endif; + enddo; + + UserData := Read first { "Select Top 1 o.name " + || " from cv3ClientVisit cv (nolock) Join cv3Order o (nolock) " + || " On cv.guid =o.ClientVisitGUID And cv.ClientGUID=o.ClientGUID " + || " Join cv3OrderUserData ud On ud.OrderGUID=o.GUID And ud.ClientGUID=cv.ClientGUID " + || " And ud.UserDataCode in ({{{SINGLE-QUOTE}}}NUTR_Consult Reasons{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}NUTR_Consult Reason 2{{{SINGLE-QUOTE}}}) " + || " And o.Name = {{{SINGLE-QUOTE}}}Dietitian Consult{{{SINGLE-QUOTE}}} And o.orderstatuslevelnum < 55 " + || " and o.OrderStatusCode = {{{SINGLE-QUOTE}}}AUA1{{{SINGLE-QUOTE}}} And o.ClientVisitGUID = " || ClientVisitGuid + || " Where ud.Value in ({{{SINGLE-QUOTE}}}Patient consuming <50% of meals x 3 days{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}NPO or Clear Liquids > 3 days{{{SINGLE-QUOTE}}}) "}; + + + If UserData is Null Then + + If (DataItem1 is Not Null) or ( DataItem2 is Not Null ) Then + + dlg_result := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with + "\n This choice will create a Dietitian Consult {{{SINGLE-QUOTE}}}" || + "\n\n Click {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to confirm your choice " || + "\n\n Click {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} if you wish to change your choice " || + "\n " + ,"Create a Dietitian Consult Order ? ", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + + + If (dlg_result as string) = "Yes" then + + + + error_destination := destination { IntermediateMessage } with [ + alert_type := "Warning", + short_message := "Auto Order MLM", + priority := "low", + scope := "chart", + Rule_group := "Auto Order MLM", + Rule_number := 1001, + Rule_subgroup := "", + Send_alert_with_order := "", + Alert_dialog_settings := "", + Display_alert := true ]; + + + user_IDType := "Edstan Number (physician)"; + user_IDCode := read last {"SELECT IDCode FROM CV3CAREPROVIDERID " || " where ProviderGUID = " || UserGUID + || " and ProviderIDTypeCode = {{{SINGLE-QUOTE}}}Edstan Number (physician){{{SINGLE-QUOTE}}}"}; + order_Creation_Reason := "Order Created Form MLM"; + + try + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((ClientVisitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + WSSessionType := "Standard"; + WSSessionReason := ""; + WSRequestedBySource := ""; + WSRequestedBy_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindById with ( user_IDType, (user_IDCode as STRING) ); + WSlocation_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((LocationGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + + endtry; + catch Exception ex + error_occurred := true; + error_message := "{{+R}}Common Data:{{-R}}\n" || + ex.Message || "\n\n"; + + if ( client_visit_obj is NOT NULL ) then + void:= call client_visit_obj.Dispose; + client_visit_obj:= null; + endif; + + if ( WSRequestedBy_obj is NOT NULL ) then + void:= call WSRequestedBy_obj.Dispose; + WSRequestedBy_obj:= null; + endif; + + if ( WSlocation_obj is NOT NULL ) then + void:= call WSlocation_obj.Dispose; + WSlocation_obj:= null; + endif; + endcatch; + + + try + // get OrderCatalogMasterItem ObjectsPlus object + general_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with CatalogItemName; + + // Create the prefilled General order + GeneralOrder2_obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder + with + client_visit_obj, // ClientVisit ObjectsPlus object + general_catalog_item, // OrderCatalogMasterItem ObjectsPlus object + order_Creation_Reason, // CreateReason + wsRequestedBy_obj, // RequestedBy ObjectsPlus object + wsRequestedBySource, // string RequestedBySource (must be in dictionary) + wsSessionType, // string SessionType + wsSessionReason, // string SessionReason + wslocation_obj, // Location ReleaseLocGrpID + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; // AvailabilityOverride + + + IF (EXISTS DataItem1 AND DataItem1 IS NOT NULL ) or (EXISTS DataItem2 AND DataItem2 IS NOT NULL ) THEN + If DataItem1 is not Null Then Val := DataItem1 ; Else Val := DataItem2; Endif; + Value := call GeneralOrder2_obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with + "NUTR_Consult Reasons" , Val ; + ENDIF; + + IF (EXISTS DataItem1 AND DataItem1 IS NOT NULL ) And (EXISTS DataItem2 AND DataItem2 IS NOT NULL ) THEN + Value := call GeneralOrder2_obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with + "NUTR_Consult Reason 2" , DataItem2 ; + ENDIF; + + + if ( general_catalog_item is NOT NULL ) then + void:= call general_catalog_item.Dispose; + general_catalog_item:= null; + endif; + + //GeneralOrder2_dest.ObjectsPlus := GeneralOrder2_obj; + empty := Call GeneralOrder2_obj.save; + + endtry; + catch Exception ex + error_occurred := true; + error_message := error_message || "{{+R}}New general order:{{-R}}\n" || + ex.Message || "\n\n"; + + if ( general_catalog_item is NOT NULL ) then + void:= call general_catalog_item.Dispose; + general_catalog_item:= null; + endif; + + if ( GeneralOrder2_obj is NOT NULL ) then + void:= call GeneralOrder2_obj.Dispose; + GeneralOrder2_obj:= null; + endif; + + endcatch; + + if ( client_visit_obj is NOT NULL ) then + void:= call client_visit_obj.Dispose; + client_visit_obj:= null; + endif; + if ( WSRequestedBy_obj is NOT NULL ) then + void:= call WSRequestedBy_obj.Dispose; + WSRequestedBy_obj:= null; + endif; + if ( WSlocation_obj is NOT NULL ) then + void:= call WSlocation_obj.Dispose; + WSlocation_obj:= null; + endif; + + + endif; // Proceed with the consult order? + + + Endif; + +Endif; + + + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_DISCHARGE_INSTRUCTIONS_OPEN.mlm b/MLMStripper/bin/Debug/DOC/DOC_DISCHARGE_INSTRUCTIONS_OPEN.mlm new file mode 100644 index 0000000..4bc531e --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_DISCHARGE_INSTRUCTIONS_OPEN.mlm @@ -0,0 +1,45 @@ +maintenance: + + title: DOC_DISCHARGE_INSTRUCTIONS_OPEN;; + mlmname: DOC_DISCHARGE_INSTRUCTIONS_OPEN;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Don Warnick;; + specialist: ;; + date: 2014-04-30;; + validation: testing;; + +library: + purpose: + ;; + explanation: This MLM will call functional MLMs to be run upon open of the Discharge Instructions Structued Note + + + Change history + + 04.30.2014 DW CSR# 31688 - Created + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + (thisDocumentCommunication) := argument; + DocInfluenza := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_DISCHARGE_DIAG{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocInfluenza WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + DocPneumovax := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_CCDA_DATA{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocPneumovax WITH thisDocumentCommunication; + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_EDUCATION_FS_PRECHECK.mlm b/MLMStripper/bin/Debug/DOC/DOC_EDUCATION_FS_PRECHECK.mlm new file mode 100644 index 0000000..c95a17b --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_EDUCATION_FS_PRECHECK.mlm @@ -0,0 +1,133 @@ +maintenance: + + title: DOC_EDUCATION_FS_PRECHECK;; + mlmname: DOC_EDUCATION_FS_PRECHECK;; + arden: version 2.5;; + version: 1.02;; //Release 5.5 SP1/FP1 and 6.0/6.1 SU2 and higher + institution: St. Clair, Allscrtips;; + author: Shawn Head;; + specialist: Debbie Eiler;; + date: 2016-04-12;; + validation: testing;; + +library: + purpose: + + This MLM will automatically select values in the education section based on which education flowsheet the user is on. + ;; + explanation: + + Modification history: + + 4.12.2016 - STH CSR#: 33982 - created + 5.6.2016 - STH CSR#: 33982 - CA Service Desk Ticket #: 2157915 - 2 new observation values where added to the generic teaching observation list. Need to have MLM uncheck these on all flowsheets. + ;; +keywords: Objects Plus, Education Log, Worklist, ARRA + ;; +knowledge: + type: data-driven;; + data: + + mlm_name := "DOC_EDUCATION_FS_PRECHECK"; + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + //Include ObjectsPlus Assemblies + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + (thisDocumentCommunication) := argument; + + /**************Make Changes To Spelling And Flags In This Section**************/ + //Set up variables; initialize + fire_on_param := "ED_Generic Teaching"; + + //Document Type + FLOWSHEET := "FlowSheet"; + + //Event Types + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTCLOSING := "DocumentClosing"; + /******************************************************************************/ + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid, ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + //Set Flowsheet DocumentCommunication object model variables via Called MLM + (this_fs_doc) := thisDocumentCommunication.DocumentConfigurationObj; + (this_parameters) := this_fs_doc.ParametersList; + (this_currentObs) := thisDocumentCommunication.CurrentObservationObj; + (this_cols) := this_fs_doc.ColumnsList; + (this_curr_col) := this_fs_doc.CurrentColumn; + (this_chartedObs) := this_curr_col.ChartedObservationsList; + + document_type := thisDocumentCommunication.DocumentType; + event_type := thisDocumentCommunication.EventType; + + client_guid := thisDocumentCommunication.ClientGUID; + visit_guid := thisDocumentCommunication.ClientVisitGUID; + chart_guid := thisDocumentCommunication.ChartGUID; + + if(thisDocumentCommunication.DocumentName matches pattern "%Adult Education Outcome%") then + DeslectItems := (1,3,4,15,16,21); + elseif(thisDocumentCommunication.DocumentName matches pattern "%OB Education Outcome%") then + DeslectItems := (1,3,7,9,14,15,16,21); + elseif(thisDocumentCommunication.DocumentName matches pattern "%Pediatric Education Outcome%") then + DeslectItems := (1,4,13,14,15,16,21); + elseif(thisDocumentCommunication.DocumentName matches pattern "%Newborn Education Outcome%") then + DeslectItems := (1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,21); + endif; + + if (document_type = FLOWSHEET) then // AND event_type = CHARTOBSERVATION) then + + //*************** UNIVERSAL INTERVENTIONS ************************** + //Autocheck all values under "Universal Interventions" Observation + univIndParameter := first of (this_parameters WHERE this_parameters.Name = fire_on_param); + + if (exists univIndParameter) then + //Define parameter ConfigurationObj to extract Suggested Text value + univIndListConfiguration := univIndParameter.ConfigurationObj; + + univIndObs := first of ( this_chartedObs WHERE this_chartedObs.ParameterGUID = univIndParameter.ParameterGUID); + Education_ListItemsList := univIndObs.ValueObj.ListValuesList.ListItemsList; + + EducationLists := Education_ListItemsList.IsSelected; + lst1stitemselected := Education_ListItemsList[1].IsSelected[1]; + if(lst1stitemselected) then + + totalitemct := 0; + for x in (1 seqto(count(EducationLists))) do + selectedlist := EducationLists[x]; + ctselst := count(selectedlist); + + for y in (1 seqto(count(selectedlist))) do + totalitemct := totalitemct + 1; + if(totalitemct in DeslectItems) then + selectedlist[y] := false; + else + selectedlist[y] := true; + endif; + enddo; + EducationLists[x] := selectedlist; + enddo; + Education_ListItemsList.IsSelected := EducationLists; + endif; + endif; + endif; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: + return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_ED_DISCHARGE_INSTRUCTIONS_CLOSE.mlm b/MLMStripper/bin/Debug/DOC/DOC_ED_DISCHARGE_INSTRUCTIONS_CLOSE.mlm new file mode 100644 index 0000000..c3a5cf0 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_ED_DISCHARGE_INSTRUCTIONS_CLOSE.mlm @@ -0,0 +1,45 @@ +maintenance: + + title: DOC_ED_DISCHARGE_INSTRUCTIONS_CLOSE;; + mlmname: DOC_ED_DISCHARGE_INSTRUCTIONS_CLOSE;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Don Warnick;; + specialist: Prggy Karish;; + date: 2017-06-07;; + validation: testing;; + +library: + purpose: + ;; + explanation: This MLM will call functional MLMs to be run upon close of the ED Discharge Instructions Structued Note + + + Change history + + 07.07.2017 DW CSR# 35436 - PDMP Improvements + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + (thisDocumentCommunication) := argument; + PrintEDDischInst := MLM {{{SINGLE-QUOTE}}}DOC_PRINT_ED_DCINST{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL PrintEDDischInst WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + SavePDMPSearchData := MLM {{{SINGLE-QUOTE}}}Doc_Launch_PDMP_Search{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL SavePDMPSearchData WITH thisDocumentCommunication; + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_ED_TRIAGE_NOTE_CLOSE.mlm b/MLMStripper/bin/Debug/DOC/DOC_ED_TRIAGE_NOTE_CLOSE.mlm new file mode 100644 index 0000000..9f70361 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_ED_TRIAGE_NOTE_CLOSE.mlm @@ -0,0 +1,61 @@ +maintenance: + + title: DOC_ED_TRIAGE_NOTE_CLOSE;; + mlmname: DOC_ED_TRIAGE_NOTE_CLOSE;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Don Warnick;; + specialist: Don Warnick;; + date: 2016-08-23;; + validation: testing;; + +library: + purpose: Call upon close of the ED Triage Note + ;; + explanation: + + + Change history + + 08.22.2016 DJW CSR# 34849 Patient Header Visit Count Readmission Monitoring - Created + 04.21.2017 SZ CSR# 35113 SIRS Sepsis Alert ED + 05.23.2018 DW CSR# 36510 Harm to Self or Others - Created + 03.05.2019 DW CSR# 38048 - Alert to mitigate Daylight Savings Time issue present 16.3 CU10 PR54 (corrected later) + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + (thisDocumentCommunication) := argument; + StrokeLastKnownWell := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_STROKE_LAST_KNOWN_WELL_CALC{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL StrokeLastKnownWell WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + DocPatientHeaderVisitCount := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_PATIENT_HEADER_VISIT_COUNT{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocPatientHeaderVisitCount WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + SepsisColumnUpdate := MLM {{{SINGLE-QUOTE}}}DOC_SEPSIS_STATUS_BOARD_COLUMN_ED{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL SepsisColumnUpdate WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + SuicidalOrViolent := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_SUICIDAL_OR_VIOLENT{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL SuicidalOrViolent WITH thisDocumentCommunication; + + //Call MLM to alert that mitigates Daylight Savings Time issue present 16.3 CU10 PR54 (corrected later) + DSTAlert := MLM {{{SINGLE-QUOTE}}}DOC_SMP_CHECK_DAYLIGHT_SAVINGS_TIME{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DSTAlert WITH thisDocumentCommunication; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_ED_TRIAGE_NOTE_OPEN.mlm b/MLMStripper/bin/Debug/DOC/DOC_ED_TRIAGE_NOTE_OPEN.mlm new file mode 100644 index 0000000..cb93e52 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_ED_TRIAGE_NOTE_OPEN.mlm @@ -0,0 +1,50 @@ +maintenance: + + title: DOC_ED_TRIAGE_NOTE_OPEN;; + mlmname: DOC_ED_TRIAGE_NOTE_OPEN;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Don Warnick;; + specialist: Don Warnick;; + date: 2016-08-23;; + validation: testing;; + +library: + purpose: Call MLMs upon open of the ED Triage Note + ;; + explanation: + + + Change history + + 05.23.2018 DW CSR# 36510 Harm to Self or Others - Created + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + (thisDocumentCommunication) := argument; + StrokeLastKnownWell := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_STROKE_LAST_KNOWN_WELL_CALC{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL StrokeLastKnownWell WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + SuicidalOrViolent := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_SUICIDAL_OR_VIOLENT{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL SuicidalOrViolent WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + DocDTAP := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_GENERIC_MANDATORY_BY_OCCUPATION{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocDTAP WITH thisDocumentCommunication; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_ED_VITAL_SIGNS_CLOSE.mlm b/MLMStripper/bin/Debug/DOC/DOC_ED_VITAL_SIGNS_CLOSE.mlm new file mode 100644 index 0000000..cad2a39 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_ED_VITAL_SIGNS_CLOSE.mlm @@ -0,0 +1,51 @@ +maintenance: + + title: DOC_ED_VITAL_SIGNS_CLOSE;; + mlmname: DOC_ED_VITAL_SIGNS_CLOSE;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Peggy Karish;; + specialist: Sandy Zhang;; + date: 2017-05-03;; + validation: testing;; + +library: + purpose: + ;; + explanation: + + + Change history + + 05.03.2017 SZ CSR: 35113 Created this universal MLM for closing of Flowsheet known as Doc. Cat. - Flowsheet: "1. Vital Signs - ED" + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Receive arguments from the flowsheet + (thisDocumentCommunication) := argument; + + DressingChangeAlert := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_CREATE_DRESSING_CHANGE_FROM_LINE_INSERTION_OBS{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DressingChangeAlert WITH thisDocumentCommunication; + + + //Reset to receive arguments from the flowsheet + (thisDocumentCommunication) := argument; + + SIRSAlert := MLM {{{SINGLE-QUOTE}}}DOC_SEPSIS_STATUS_BOARD_COLUMN_ED{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL SIRSAlert WITH thisDocumentCommunication; + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_ABUSE_SCREEN_SOCIAL_SERVICE_REFERRAL.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_ABUSE_SCREEN_SOCIAL_SERVICE_REFERRAL.mlm new file mode 100644 index 0000000..32f526b --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_ABUSE_SCREEN_SOCIAL_SERVICE_REFERRAL.mlm @@ -0,0 +1,262 @@ +maintenance: + + title: DOC_FUNC_ABUSE_SCREEN_SOCIAL_SERVICE_REFERRAL;; + mlmname: DOC_FUNC_ABUSE_SCREEN_SOCIAL_SERVICE_REFERRAL;; + arden: version 2.50;; + version: 18.4;; + institution: St.Clair Hospital;; + author: Juliet M. Law;; + specialist: Courtney Carr;; + date: 2019-09-04;; + validation: testing;; + +library: + purpose: Automatically order a Social Service Referral (Non Psych) when {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} is answered to any question under the Abuse section + on the Adult Patient Profile. + ;; + explanation: This MLM will trigger off the user answering {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to any question under the Abuse section on the Adult Patient Profile. + The Referral order will only be placed once. + + Change history + + 09.04.2019 JML CSR# 38606 Created. + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // RS ADD Message box + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + documentName := thisDocumentCommunication.DocumentName; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + locationGuid := read last {"SELECT CurrentLocationGUID FROM CV3ClientVisit WITH(NOLOCK) WHERE GUID = " || SQL(visitGuid)}; + + if ( documentName = "Adult Patient Profile" ) then + + abuseParamName := ( "PRO abuse screen threat fam yn" + , "PRO abuse screen advantage yn" + , "PRO abuse screen unsafe at home yn"); + + orderName := "Social Service Referral (Non Psych)"; + + elseif ( documentName = "Adult Patient Profile - Behavioral Health" ) then + + abuseParamName := ( "PRO Abuse Screen trauma_BH profile" + , "PRO Abuse Screen advantage_BH profile" + , "PRO abuse screen limit contact_BH profile" + , "PRO abuse screen threat anyone_BH profile" + , "PRO abuse screen do you feel safe" + , "PRO abuse screen making feel unsafe" + , "PRO abuse screen unsafe at home_BH profile" ); + + orderName := "Psych Social Service Referral"; + endif; + + paramCount := 0; + + //Required Objects+ Variables + SessionType := "Standard"; + SessionReason := ""; + RequestingSource := ""; + Order_Creation_Reason := "Abuse Screen - Created from MLM"; + mlm_name := "DOC_FUNC_ABUSE_SCREEN_SOCIAL_SERVICE_REFERRAL"; + + errorOccurred := false; + errorMsg := ""; + + if ( thisDocumentCommunication.EventType = "ChartObservation" ) then + + for var IN 1 seqto count abuseParamName do + + abuseParam := first of ( thisParameters WHERE thisParameters.Name = abuseParamName[var] ); + + if ( exists abuseParam ) then + + abuseObs := first of ( thisObservations WHERE thisObservations.ParameterGUID = abuseParam.ParameterGUID ); + + if ( exists abuseObs ) then + + selectedYes := exists ( abuseObs.ValueObj.ListItemsList.Value + WHERE ( abuseObs.ValueObj.ListItemsList.Value = "yes" + OR abuseObs.ValueObj.ListItemsList.Value = "yes..." ) + AND abuseObs.ValueObj.ListItemsList.IsSelected = true ); + + if ( selectedYes ) then + paramCount := paramCount + 1; + endif; + endif; + endif; + enddo; + + if ( paramCount = 1 ) then + + //Check for Social Service Referral existence + orderExists := READ LAST { "SELECT o.Name" + || " FROM CV3Order as o with (nolock) JOIN CV3OrderCatalogMasterItem AS ocmi with (nolock)" + || " ON o.OrderCatalogMasterItemGUID = ocmi.GUID" + || " WHERE o.ClientGUID = " || SQL(clientGuid) + || " AND o.ClientVisitGUID = " || SQL(visitGuid) + || " AND o.ChartGUID = " || SQL(chartGuid) + || " AND o.Name = " || SQL(orderName) + || " AND ((o.OrderStatusLevelNum > 15" + || " AND o.OrderStatusLevelNum NOT IN ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}100{{{SINGLE-QUOTE}}}))" + || " OR o.OrderStatusCode = {{{SINGLE-QUOTE}}}HOLD{{{SINGLE-QUOTE}}})" }; + + if ( NOT ( exists orderExists ) ) then + + msg_hi := "This selection will create a " || orderName || " order."; + msg_hi := msg_hi || "\n\nClick {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to confirm your selection. "; + msg_hi := msg_hi || "\n\nClick {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} if you wish to change your selection."; + + dialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show WITH msg_hi, "Confirm Abuse Screening Selection", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}, "Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + if ( ( dialogRes as String ) = "Yes" ) then + + try + //Retrieve .Net version of client visit object + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey + with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + //Use current user as default care provider + care_provider_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey + with ((userGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + //Get Location Obj + location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey + with ((locationGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + //Get the OrderCatalogMasterItem Obj + order_catalog_obj := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName + with (orderName); + + endtry; + catch Exception ex + errorOccurred := true; + errorMsg := "{{+R}}CommonData: {{-R}}\n" || + ex.Message || "\n\n"; + + //Clean up + if order_catalog_obj is NOT Null then + void := call order_catalog_obj.Dispose; + order_catalog_obj := null; + endif; + + if location_obj IS NOT Null then + void := call location_obj.Dispose; + location_obj := null; + endif; + + if care_provider_obj IS NOT Null then + void := call care_provider_obj.Dispose; + care_provider_obj := null; + endif; + + if client_visit_obj IS NOT Null then + void := call client_visit_obj.Dispose; + client_visit_obj := null; + endif; + endcatch; + + try + //Generate the Dietitian Consult Order + Order_Obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder + with client_visit_obj, + order_catalog_obj, + Order_Creation_Reason, + care_provider_obj, + RequestingSource, + SessionType, + SessionReason, + location_obj, + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; + endtry; + catch Exception ex + errorOccurred := true; + errorMsg := "{{+R}}New Other Order: {{-R}}\n" || + ex.Message || "\n\n"; + + if Order_Obj IS NOT Null then + void := call Order_Obj.Dispose; + Order_Obj := null; + endif; + + endcatch; + + + if ( documentName = "Adult Patient Profile" ) then + //Set UDDI field value on order (Indication for Consult) + ret_val := call Order_Obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} + with "SS_Consult Reasons","Abuse and neglect"; + endif; + + //Save order + void := call Order_Obj.Save; + + //CleanUp + if order_catalog_obj IS NOT Null then + void := call order_catalog_obj.Dispose; + order_catalog_obj := null; + endif; + + if location_obj IS NOT Null then + void := call location_obj.Dispose; + location_obj := null; + endif; + + if care_provider_obj IS NOT Null then + void := call care_provider_obj.Dispose; + care_provider_obj := null; + endif; + + if client_visit_obj IS NOT Null then + void := call client_visit_obj.Dispose; + client_visit_obj := null; + endif; + + if errorOccurred then + thisDocumentCommunication.DisplayMessage := true; + thisDocumentCommunication.Message := errorMsg; + endif; + endif; + endif; + endif; + endif; + ;; + evoke: + ;; + logic: + + conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_ACUTE_CHF_CRITERIA.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_ACUTE_CHF_CRITERIA.mlm new file mode 100644 index 0000000..1d5e38f --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_ACUTE_CHF_CRITERIA.mlm @@ -0,0 +1,336 @@ +maintenance: + + title: DOC_FUNC_ACUTE_CHF_CRITERIA ;; + mlmname: DOC_FUNC_ACUTE_CHF_CRITERIA ;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Shivprasad Jadhav ;; + specialist: Shivprasad Jadhav, GOS Allscripts;; + date: 2015-08-12;; + validation: testing;; + +library: + purpose: On Document save MLM look for the [Acute CHF] or [CHF] Selection in structured note Or look for the HI Depend on HI type and its scope of [ Acute CHF or CHF]. + Then it will look for Mail send history. As we are creating comment when mail sent earlier. If Mail not sent earlier then it send mail to [#patient Registration-Pharmacy@StClair.org ] + ;; + explanation: + Change history + + 08.12.2015 SSJ CSR# 33338 - Created + 07.20.2016 SSJ CSR#333338- Added filter for patient Typecode [Inpatient and Observation] only + 08.16.2016 Shivprasad - CSR #333338- Made changes as per new specs to sent mail and added logic to create HI for CHF, COPD, Renal And Diabetes. + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + DocGuid := thisStructuredNoteDoc.ClientDocumentGUID ; + + HI_MLM := MLM {{{SINGLE-QUOTE}}}SCH_Func_Create_Health_Issue{{{SINGLE-QUOTE}}}; + + VST_Code := Read last {"Select cv.Typecode from cv3ClientVisit cv (nolock) Where cv.Guid = " || visitGuid || " And cv.ClientGUID = " || clientGuid } ; + +(LocationLevelCode) := read last { " Select Top 1 case when cc.typecode = {{{SINGLE-QUOTE}}}unit{{{SINGLE-QUOTE}}} then cc.levelcode when b.typecode={{{SINGLE-QUOTE}}}unit{{{SINGLE-QUOTE}}} then b.levelcode + when a.typecode={{{SINGLE-QUOTE}}}unit{{{SINGLE-QUOTE}}} then a.levelcode when cv3l.typecode={{{SINGLE-QUOTE}}}unit{{{SINGLE-QUOTE}}} then cv3l.levelcode else null end as Unit + From CV3ClientVisit CV With (Nolock) Left Join CV3Location CV3L On CV3L.GUID=CV.CurrentLocationGUID + Left Join CV3Location a With (Nolock) on CV3L.parentguid= a.guid Left Join CV3Location b With (Nolock) on a.parentguid = b.guid + left join cv3location cc With (Nolock) on b.parentguid = cc.guid WHERE CV.GUID = "|| visitGuid }; + +// DOCUMENT CLOSING SECTION + + + IF thisdocumentCommunication.EventType = "DocumentClosing" then + + errormessage := ""; + // Determine if the Acute CHF button is selected + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Chronic_Conditions"); //SCH_CK_Diagnosis Risk + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + +//------For Adult Patient Profile Observation Only--------------------------------------------------------------------------- + theParameter1 := first of (thisparameters where thisparameters.Name = "SCH_CK_Diagnosis Risk"); //SCH_CK_Diagnosis Risk + theObservation1 := first of (thisobservations where thisobservations.ParameterGUID = theParameter1.ParameterGUID); +//-------------------------------------------------------------------------------------------------------------------------- + // To get user selections for Observation + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "CHF") + then + HI_CHF :="CHF"; + else + HI_CHF :=""; + endif; +//------For Adult Patient Profile Observation Only--------------------------------------------------------------------------- + if true in (theObservation1.ValueObj.ListItemsList.IsSelected where theObservation1.ValueObj.ListItemsList.Value = "Acute CHF") then + HI_CHF :="CHF"; + elseIf False in (theObservation1.ValueObj.ListItemsList.IsSelected where theObservation1.ValueObj.ListItemsList.Value = "Acute CHF") Then + HI_CHF :=""; + endif; +//-------------------------------------------------------------------------------------------------------------- + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "COPD") + then + HI_COPD :="COPD"; + else + HI_COPD :=""; + endif; + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Diabetes") + then + HI_Diabetes :="Diabetes"; + else + HI_Diabetes :=""; + endif; + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Renal Failure") + then + HI_Renal :="Renal Failure"; + else + HI_Renal :=""; + endif; + + //Health Issue Variable + CHF_Created := "No"; + COPD_Created := "No"; + Diabetes_Created := "No"; + Renal_Created := "No"; + + +//To Create health Issue Filter Criteria based on user selection on St. Note. + + If (HI_CHF <> "" ) or (HI_COPD <> "" ) or (HI_Diabetes <> "") or ( HI_Renal <> "") Then + + //Message to User for Health Issue Creation + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "A Health Issue has been created for this Condition. ", "Important Alert","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + +/*************************** Health Issue for CHF ******************************/ + If HI_CHF <> "" Then + // HI CHF Information + HI_Name := "CHF (congestive heart failure)"; + HI_9Code := "428.0"; + HI_10Code := "I50.9"; + CodingScheme:= "ICD10"; + HI_TYPE := "Problem-Chronic"; + IssueText := "Created from {{{SINGLE-QUOTE}}}Pharmacy Insurance Information MLM{{{SINGLE-QUOTE}}}. " ; + + (CurrentVisit_CHF) := read last { "select distinct hi.shortname , hi.ScopeLevel, hi.typecode " + || " from Cv3ClientVisit cv With (Nolock) Join cv3healthissuedeclaration hi with (nolock) " + || " on cv.guid= hi.ClientVisitGUID And cv.ClientGuid =Hi.ClientGUID " + || " join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID" + || " where cv.GUID = " || visitGuid + || " And cv.clientguid = " || clientGuid || " and hi.active = 1 " + || " and hi.typecode in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Visit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}}) " + || " and ((Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}"|| HI_9Code ||"{{{SINGLE-QUOTE}}}) or (Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD10{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}"|| HI_10Code ||"{{{SINGLE-QUOTE}}}) ) " }; + + If Not exist CurrentVisit_CHF Then + Void := Call HI_MLM With (visitGuid, HI_Name, HI_10Code, IssueText,HI_TYPE,CodingScheme); //(visitGuid,issuename,issuecode,issuetext,issuetype,issuescheme) + CHF_Created := "Yes"; + EndIf; + + Endif; + +/*************************** Health Issue for COPD ******************************/ + If HI_COPD <> "" Then + + HI_Name := "Chronic Obstructive Pulmonary Desease"; + HI_9Code := "496"; + HI_10Code := "J44.9"; + CodingScheme := "ICD10"; + HI_TYPE := "Problem-Chronic"; + IssueText := "Created from {{{SINGLE-QUOTE}}}Pharmacy Insurance Information MLM{{{SINGLE-QUOTE}}}. " ; + + (CurrentVisit_COPD) := read last { "select distinct hi.shortname , hi.ScopeLevel, hi.typecode " + || " from Cv3ClientVisit cv With (Nolock) Join cv3healthissuedeclaration hi with (nolock) " + || " on cv.guid= hi.ClientVisitGUID And cv.ClientGuid =Hi.ClientGUID " + || " join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID" + || " where cv.GUID = " || visitGuid + || " And cv.clientguid = " || clientGuid || " and hi.active = 1 " + || " and hi.typecode in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Visit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}}) " + || " and ((Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}"|| HI_9Code ||"{{{SINGLE-QUOTE}}}) + or (Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD10{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}"|| HI_10Code ||"{{{SINGLE-QUOTE}}}) ) " }; + + If Not exist CurrentVisit_COPD Then + + Void := Call HI_MLM With (visitGuid, HI_Name, HI_10Code, IssueText,HI_TYPE,CodingScheme); //(visitGuid,issuename,issuecode,issuetext,issuetype,issuescheme) + COPD_Created := "Yes"; + Endif; + + EndIf; +/*************************** Health Issue for Diabetes ******************************/ + If HI_Diabetes <> "" Then + + HI_Name := "Diabetes"; + HI_9Code := "250.00"; + HI_10Code := "E11.9"; + CodingScheme := "ICD10"; + HI_TYPE := "Problem-Chronic"; + IssueText := "Created from {{{SINGLE-QUOTE}}}Pharmacy Insurance Information MLM{{{SINGLE-QUOTE}}}. " ; + + + + (CurrentVisit_Diabetes) := read last { "select distinct hi.shortname , hi.ScopeLevel, hi.typecode " + || " from Cv3ClientVisit cv With (Nolock) Join cv3healthissuedeclaration hi with (nolock) " + || " on cv.guid= hi.ClientVisitGUID And cv.ClientGuid =Hi.ClientGUID " + || " join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID" + || " where cv.GUID = " || visitGuid + || " And cv.clientguid = " || clientGuid || " and hi.active = 1 " + || " and hi.typecode in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Visit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}}) " + || " and ((Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}"|| HI_9Code ||"{{{SINGLE-QUOTE}}}) + or (Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD10{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}"|| HI_10Code ||"{{{SINGLE-QUOTE}}}) ) " }; + + If Not exist CurrentVisit_Diabetes Then + + Void := Call HI_MLM With (visitGuid, HI_Name, HI_10Code, IssueText,HI_TYPE,CodingScheme); //(visitGuid,issuename,issuecode,issuetext,issuetype,issuescheme) + Diabetes_Created := "Yes"; + Endif; + + EndIf; + /*************************** Health Issue for renal Chronic ******************************/ + If HI_Renal <> "" Then + + HI_Name := "Chronic renal failure"; + HI_9Code := "585.9"; + HI_10Code := "N18.9"; + CodingScheme := "ICD10"; + HI_TYPE := "Problem-Chronic"; + IssueText := "Created from {{{SINGLE-QUOTE}}}Pharmacy Insurance Information MLM{{{SINGLE-QUOTE}}}. " ; + + + + (CurrentVisit_Renal) := read last { "select distinct hi.shortname , hi.ScopeLevel, hi.typecode " + || " from Cv3ClientVisit cv With (Nolock) Join cv3healthissuedeclaration hi with (nolock) " + || " on cv.guid= hi.ClientVisitGUID And cv.ClientGuid =Hi.ClientGUID " + || " join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID" + || " where cv.GUID = " || visitGuid + || " And cv.clientguid = " || clientGuid || " and hi.active = 1 " + || " and hi.typecode in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Visit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}}) " + || " and ((Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}"|| HI_9Code ||"{{{SINGLE-QUOTE}}}) + or (Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD10{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}"|| HI_10Code ||"{{{SINGLE-QUOTE}}}) ) " }; + + If Not exist CurrentVisit_Renal Then + + Void := Call HI_MLM With (visitGuid, HI_Name, HI_10Code, IssueText,HI_TYPE,CodingScheme); //(visitGuid,issuename,issuecode,issuetext,issuetype,issuescheme) + Renal_Created := "Yes"; + + Endif; + + Endif; + +/*************************** Health Issue Creation Completed **************************************************** ******************************/ +// To get Last observation value charted on patient or current Values for {{{SINGLE-QUOTE}}}SCHCK_Chronic_Conditions{{{SINGLE-QUOTE}}} Observation +/* + If DocGuid Is not Null Then + LastObsVal := read First {"SELECT oflv.value " + || " FROM CV3ClientDocument cd WITH (NOLOCK) INNER JOIN cv3ClientVisit cv WITH (NOLOCK) ON cv.GUID = cd.ClientVisitGUID And cv.clientguid = cd.ClientGUID " + || " AND cv.chartguid = cd.ChartGUID AND cd.iscanceled = 0 And cd.Active = 1 AND cd.DocumentName in ( {{{SINGLE-QUOTE}}}Adult Patient Profile{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Adult Patient Profile - Observation{{{SINGLE-QUOTE}}}) " + || " INNER JOIN SXACDObservationParameter OP WITH (NOLOCK) ON OP.ClientGUID = cd.ClientGUID AND OP.ChartGUID = cd.ChartGUID " + || " AND OP.PatCareDocGUID = cd.PatCareDocGUID AND OP.RecordedDtm = cd.AuthoredDtm " + || " INNER JOIN CV3ObsCatalogMasterItem omi WITH (NOLOCK) ON omi.GUID = op.ObsMasterItemGUID And omi.name in ({{{SINGLE-QUOTE}}}SCHCK_Chronic_Conditions{{{SINGLE-QUOTE}}}) " + || " LEFT JOIN SCMObsFSListValues oflv WITH (NOLOCK) ON oflv.ParentGUID = op.ObservationDocumentGUID AND oflv.Active = 1 AND cd.ClientGUID = oflv.ClientGUID " + || " AND oflv.ClientGUID = cd.ClientGUID " + || " Where cv.guid = " || visitGuid + || " And cd.guid = " || thisStructuredNoteDoc.ClientDocumentGUID + || " And oflv.value in ({{{SINGLE-QUOTE}}}CHF{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}COPD{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Diabetes{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Renal Failure{{{SINGLE-QUOTE}}}) " }; + Else + + LastObsVal := read First {"SELECT oflv.value " + || " FROM CV3ClientDocument cd WITH (NOLOCK) INNER JOIN cv3ClientVisit cv WITH (NOLOCK) ON cv.GUID = cd.ClientVisitGUID And cv.clientguid = cd.ClientGUID " + || " AND cv.chartguid = cd.ChartGUID AND cd.iscanceled = 0 And cd.Active = 1 AND cd.DocumentName in ( {{{SINGLE-QUOTE}}}Adult Patient Profile{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Adult Patient Profile - Observation{{{SINGLE-QUOTE}}}) " + || " INNER JOIN SXACDObservationParameter OP WITH (NOLOCK) ON OP.ClientGUID = cd.ClientGUID AND OP.ChartGUID = cd.ChartGUID " + || " AND OP.PatCareDocGUID = cd.PatCareDocGUID AND OP.RecordedDtm = cd.AuthoredDtm " + || " INNER JOIN CV3ObsCatalogMasterItem omi WITH (NOLOCK) ON omi.GUID = op.ObsMasterItemGUID And omi.name in ({{{SINGLE-QUOTE}}}SCHCK_Chronic_Conditions{{{SINGLE-QUOTE}}}) " + || " LEFT JOIN SCMObsFSListValues oflv WITH (NOLOCK) ON oflv.ParentGUID = op.ObservationDocumentGUID AND oflv.Active = 1 AND cd.ClientGUID = oflv.ClientGUID " + || " AND oflv.ClientGUID = cd.ClientGUID " + || " Where cv.guid = " || visitGuid + //|| " And cd.guid = " || thisStructuredNoteDoc.ClientDocumentGUID + || " And oflv.value in ({{{SINGLE-QUOTE}}}CHF{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}COPD{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Diabetes{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Renal Failure{{{SINGLE-QUOTE}}}) " }; + Endif; + +*/ +// To identify the Existing Email Sent or Not + + LastMLMSent := read First {"Select cd.text from cv3ClientVisit cv With (Nolock) Join CV3CommentDeclaration cd With (Nolock) + On cv.guid=cd.ClientVisitGUID And cd.ClientGUID=cv.ClientGUID and cd.ChartGUID= cv.ChartGUID + And cd.Typecode= {{{SINGLE-QUOTE}}}Reg Notified of CHF{{{SINGLE-QUOTE}}} And cd.Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} And cd.ClientVisitGUID = " || visitGuid || ""}; + +//------------------------------------------------------------------------------------------------------- + + If LocationLevelCode In ("4B","5A","5B","5E","5F","5G","6E","6F","CCU1","CCU2","CVSU","ICU","ICU Pod 2","IMC") Then + If ((HI_CHF <> "" ) or (HI_COPD <> "" ) or (HI_Diabetes <> "") or ( HI_Renal <> "") ) + // And (CHF_Created = "Yes" or COPD_Created = "Yes" or Diabetes_Created = "Yes" or Renal_Created = "Yes" ) + Then // To Value selection and HI Creation confirmation + + //If (LastObsVal is Null ) And (LastMLMSent is Null ) Then // To Restrict One Time to send this message + If (LastMLMSent is Null ) Then // To Restrict One Time to send this message + + If (VST_Code Matches Pattern "%Inpatient%") or (VST_Code Matches Pattern "%Observation%") Then + + (PatientName , MRN, VisitIDCode, DOA) := Read First {" Select ClientDisplayName, IDCode, VisitIDCode, FORMAT( AdmitDtm ,{{{SINGLE-QUOTE}}}MM/dd/yyyy{{{SINGLE-QUOTE}}}) as DOA from cv3CLientVisit Where Guid = " || visitGuid || " "}; + + // Send a Text Message Section + PhoneNumber := read last {" select p.PhoneNumber from CV3User u with (nolock) join Cv3Phone p with (nolock) on p.PersonGUID = u.GUID " || + " where u.displayname = {{{SINGLE-QUOTE}}}SCM, Text Messaging{{{SINGLE-QUOTE}}} and p.PhoneNote = {{{SINGLE-QUOTE}}}Outpatient Pharmacy Prescription Request{{{SINGLE-QUOTE}}} And p.Active =1 "}; + //PhoneNumber := "Shivprasad.Jadhav@stclair.org;" ; + If PhoneNumber ="#Patient Registration-Pharmacy" Then + PhoneNumber := " #PatientRegistrationPharmacy@stclair.org" ; + EndIf; + //PhoneNumber := PhoneNumber,"Shivprasad.jadhav@stclair.org;"; + + Page_MLM := mlm {{{SINGLE-QUOTE}}}SCH_FUNC_PAGE{{{SINGLE-QUOTE}}}; + MessageSubject:= "Pharmacy Insurance Information"; + MessageBody := " Please enter this patients Pharmacy Insurance information into the Registration system. \n " + || "Patient Name: "|| PatientName || " \n " + || "Medical Record Number: "|| MRN || " \n " + || "Account Number: "|| VisitIDCode || " \n " + || "Date of Admission: "|| DOA || " \n " ; + PPMvoid := call Page_MLM with(PhoneNumber, MessageSubject, MessageBody); + + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + CommentTypeCode := "Reg Notified of CHF"; + PatientComment_Obj := call {{{SINGLE-QUOTE}}}PatientComment{{{SINGLE-QUOTE}}}.CreatePatientComment with client_visit_obj, CommentTypeCode; + PatientComment_Obj.text := "Mail Sent"; + Void := Call PatientComment_Obj.Save; + + EndIf; + Endif; + EndIf; + Endif; + + + endif; // End of Close Document +Endif; + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_ADULT_PATIENT_PROFILE_CHF.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_ADULT_PATIENT_PROFILE_CHF.mlm new file mode 100644 index 0000000..4236545 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_ADULT_PATIENT_PROFILE_CHF.mlm @@ -0,0 +1,109 @@ +maintenance: + + title: DOC_FUNC_ADULT_PATIENT_PROFILE_CHF;; + mlmname: DOC_FUNC_ADULT_PATIENT_PROFILE_CHF;; + arden: version 2.50;; + version: 5.50;; + institution: St.Clair Hospital;; + author: Juliet M. Law;; + specialist: Dean Miklavic;; + date: 2012-06-25;; + validation: testing;; + +library: + purpose: Populate CHF column on the TICU Status Board with value contained in hidden observation on the Adult Patient Profile + for patients with CHF health issue. + ;; + explanation: This MLM inserts a value of "CHF" into a hidden observation on the Adult Patient Profile when a patient has a health issue + of type "Problem-Chronic", "Problem-Proced", "Problem-Visit", or "Pt-Stated" with a value of CHF. A column on the + TICU Status Board will be populated based on the contents of the hidden observation on the Adult Patient Profile. + + + Change history + + 06.25.2012 JML CSR# 26414 Created. + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + if (thisDocumentCommunication.EventType = "DocumentOpening") then + //Determine if Patient has a CHF Health Issue + (chfHI) := read {"SELECT chi.Description, chi.TouchedWhen, hid.TypeCode" + || " FROM CV3HealthIssueDeclaration hid JOIN CV3CodedHealthIssue chi" + || " ON chi.guid = hid.codedhealthissueguid" + || " WHERE hid.ClientGUID = " || Sql(clientGuid) + || " AND hid.TypeCode IN ({{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Proced{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}Problem-Visit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Pt-Stated Hx{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Pt Stated HX{{{SINGLE-QUOTE}}})" + || " AND (hid.ShortName LIKE {{{SINGLE-QUOTE}}}%CHF%{{{SINGLE-QUOTE}}}" + || " OR hid.ShortName LIKE {{{SINGLE-QUOTE}}}%CONGESTIVE HEART FAILURE%{{{SINGLE-QUOTE}}}" + || " OR hid.ShortName LIKE {{{SINGLE-QUOTE}}}%CONGESTIVE CARDIAC FAILURE%{{{SINGLE-QUOTE}}})" + || " AND hid.Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}}" + || " AND hid.Active = 1"}; + + if (exists chfHI) then + //Patient has CHF health issue + //Update observation on Patient Profile + chfHIValue := "CHF"; + else + chfHIValue := ""; + endif; + + //Retrieve observation + TicuStatusBoardParameterName := "SCHCK_Health Issue_Status Board"; + TicuStatusBoardParameter := first of (thisParameters WHERE thisParameters.Name = TicuStatusBoardParameterName); + + if (exists TicuStatusBoardParameter) then + this_currentTicuStatusBoardObs := NEW ObservationType; + this_currentTicuStatusBoardObs.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentTicuStatusBoardObs.ParameterGUID := TicuStatusBoardParameter.ParameterGUID; + this_currentTicuStatusBoardObs.DataType := "FreeTextValue"; + this_currentTicuStatusBoardObs.ValueObj := NEW FreeTextValueType; + this_currentTicuStatusBoardObs.ValueObj.Value := chfHIValue; + + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentTicuStatusBoardObs); + endif; + + endif; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_ADULT_PATIENT_PROFILE_URINARY_CATHETER_ALERT.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_ADULT_PATIENT_PROFILE_URINARY_CATHETER_ALERT.mlm new file mode 100644 index 0000000..9c81bf9 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_ADULT_PATIENT_PROFILE_URINARY_CATHETER_ALERT.mlm @@ -0,0 +1,122 @@ +maintenance: + + title: DOC_FUNC_ADULT_PATIENT_PROFILE_URINARY_CATHETER_ALERT;; + mlmname: DOC_FUNC_ADULT_PATIENT_PROFILE_URINARY_CATHETER_ALERT;; + arden: version 2.50;; + version: 5.50;; + institution: St.Clair Hospital;; + author: Juliet M. Law;; + specialist: Janet Nordin;; + date: 2016-02-03;; + validation: testing;; + +library: + purpose: Display alert if user answers that patient has an indwelling urinary catheter but no order exists on patient{{{SINGLE-QUOTE}}}s chart. + ;; + explanation: This MLM will trigger off the user answering {{{SINGLE-QUOTE}}}Yes...{{{SINGLE-QUOTE}}} to the patient having an Indwelling Urinary Catheter. + This MLM will determine if one of the following catheter orders exist: + * Catheter: Foley + * Catheter: Indwelling Double Lumen + * Catheter: Indwelling Triple Lumen + If one of the above orders does not exist, then this MLM will display an alert informing the user to enter one of the above orders. + + + + Change history + + 02.03.2016 JML CSR# 33953 Created. + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + urinaryCathParamName := "SCH_CK_Indwelling Urinary Catheter"; + foley_order_lst := ("{{{SINGLE-QUOTE}}}Catheter: Foley{{{SINGLE-QUOTE}}}", + "{{{SINGLE-QUOTE}}}Catheter: Indwelling Double Lumen{{{SINGLE-QUOTE}}}", + "{{{SINGLE-QUOTE}}}Catheter: Indwelling Triple Lumen{{{SINGLE-QUOTE}}}"); + + missingCathMsg := "This patient does not have a current order for an Indwelling Urinary Catheter. Please obtain order."; + + if ( thisDocumentCommunication.EventType = "ChartObservation" ) then + //Retrieve parameter + urinaryCathParam := first of ( thisParameters WHERE thisParameters.Name = urinaryCathParamName ); + + if ( exists urinaryCathParam ) then + //Read Observation Value + urinaryCathObs := first of ( thisObservations WHERE thisObservations.ParameterGUID = urinaryCathParam.ParameterGUID ); + + if ( exists urinaryCathObs ) then + if ( thisDocumentCommunication.CurrentObservationObj.ParameterGUID = urinaryCathParam.ParameterGUID ) then + selectedYes := exists ( urinaryCathObs.ValueObj.ListItemsList.Value + WHERE urinaryCathObs.ValueObj.ListItemsList.Value = "Yes..." + AND urinaryCathObs.ValueObj.ListItemsList.IsSelected = true); + + if ( selectedYes ) then + //Determine if patient has a catheter order + cathOrderExists := read last {"SELECT 1" + || " FROM CV3Order as o with (nolock) JOIN CV3OrderCatalogMasterItem AS ocmi with (nolock)" + || " ON o.OrderCatalogMasterItemGUID = ocmi.GUID" + || " JOIN CV3OrderUserData oud WITH (NOLOCK)" + || " ON o.GUID = oud.OrderGUID" + || " AND o.ClientGUID = oud.ClientGUID" + || " WHERE o.ClientGUID = " || Sql(clientGuid) + || " AND o.ClientVisitGUID = " || Sql(visitGuid) + || " AND o.ChartGUID = " || Sql(chartGuid) + || " AND o.Name IN ( " || foley_order_lst || " )" + || " AND ((o.OrderStatusLevelNum > 15" + || " AND o.OrderStatusLevelNum NOT IN ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}100{{{SINGLE-QUOTE}}}))" + || " OR o.OrderStatusCode = {{{SINGLE-QUOTE}}}HOLD{{{SINGLE-QUOTE}}})"}; + + if ( NOT ( exists cathOrderExists ) ) then + //thisDocumentCommunication.Message := missingCathMsg; + //thisDocumentCommunication.DisplayMessage := true; + + dialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with missingCathMsg, "Missing Catheter Order", "Ok" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}, "Exclamation" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + endif; + endif; + endif; + endif; + endif; + endif; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_ADVANCE_DIRECTIVE.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_ADVANCE_DIRECTIVE.mlm new file mode 100644 index 0000000..c8c1fe5 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_ADVANCE_DIRECTIVE.mlm @@ -0,0 +1,303 @@ +maintenance: + + title: DOC_FUNC_ADVANCE_DIRECTIVE;; + mlmname: DOC_FUNC_ADVANCE_DIRECTIVE;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Don Warnick;; + specialist: ;; + date: 2012-02-09;; + validation: testing;; + +library: + purpose: + ;; + explanation: This MLM manages the Advance Directive portion of the Patient Profiles. It checks boxes if an Advance Directive comment is filed. + It will make an order if a request for infomration is charted....this makes a worklist task + + + Change history + + 02.09.2012 DW CSR# 26945 - Created + 11.15.2012 DW HD# 147643 - Corrected issue with mulitple order creation + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + + + + +// DOCUMENT OPENING SECTION + + +IF thisdocumentCommunication.EventType = "DocumentOpening" then + + + // Initialize the "Advance Directive Order" button + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Advance Directive Order Patient Profile"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "-" then selectedItem.IsSelected := false; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + +// Check to see if there is an Advance Directive comment = Y on file + + (AdvanceDirectiveOnFile) := read + { + " select text from CV3CommentDeclaration with (nolock) where TypeCode = {{{SINGLE-QUOTE}}}ADVDIRONFILE{{{SINGLE-QUOTE}}} and clientguid = " || ClientGuid || " and TEXT = {{{SINGLE-QUOTE}}}y{{{SINGLE-QUOTE}}}" + }; + + +// Check to see if the "on file at on file at St. Clair Hospital" button was previously checked. If so set Onfilechecked_before = yes. + + + Onfilechecked_before:= "no"; + Onfilechecked_after := "no"; + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK Advance Directive"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "on file at St. Clair Hospital") + then Onfilechecked_before := "yes"; else Onfilechecked_before := "no"; endif; + + +// If there is an Advance Directive comment = Y on file the select the appropriate radio buttons and set Onfilechecked_after = "yes" + + + if exist AdvanceDirectiveOnFile then + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK Advance Directive Pt has med"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "Has a Medical Advance Directive" then selectedItem.IsSelected := true; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK Advance Directive"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "on file at St. Clair Hospital" then selectedItem.IsSelected := true; Onfilechecked_after := "yes"; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + +// Determine the Document name and whether the user is a nurse + + + DocumentName:= thisDocumentCommunication.documentname; + + if DocumentName in ("Adult Patient Profile - Behavioral Health Outpatient","Adult Patient Profile - Infusion") + then suppressforthisdocument := "yes"; else suppressforthisdocument := "no"; endif; + + theParameter := first of (thisparameters where thisparameters.Name = "sch_notmandatory1"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then nurse := "yes"; else nurse := "no"; endif; + + +// Display message box reminder if approriate Document Name, User is RN, and the "request for info button" was changed from no to yes + + + if Onfilechecked_before = "no" and Onfilechecked_after = "yes" and nurse = "yes" and suppressforthisdocument = "no" then + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n There is a scanned Advance Directive document on file. \n\n Retrieve the most current document, print it and place it on the chart" , "Reminder","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + + endif; + +endif; + + +// CHART OBSERVATION SECTION + + +IF thisdocumentCommunication.EventType = "ChartObservation" then + +// "No Advance Directive" Buttons Section + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK Advance Directive none"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + then + + // "Requests Information on how to complete advance directive" button Section (Update the "Advance Directive Order" button) + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "requests information on how to complete advance directive") + then RequestForInformationSelected := "yes"; else RequestForInformationSelected := "no"; endif; + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Advance Directive Order Patient Profile"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "-" and RequestForInformationSelected = "yes" then selectedItem.IsSelected := true; else selectedItem.IsSelected := false; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; // "Requests information..." button is selected + +endif; // CHART OBSERVATION SECTION + + + + +// DOCUMENT CLOSING SECTION + + +IF thisdocumentCommunication.EventType = "DocumentClosing" then + + +// If the "Advance Directive Order" button is set to "Yes", then make a new order + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Advance Directive Order Patient Profile"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "-") + then placeorder := "yes"; else placeorder := "no"; + endif; + + If placeorder = "yes" + then + try + + NextHour:= EXTRACT HOUR currenttime + 1 || ":00"; + + SessionType := "Standard"; + SessionReason := ""; + RequestingSource := ""; + user_IDType := "Edstan Number (physician)"; + order_Creation_Reason := "From Test MLM"; + orderItemName := "Patient requests information on completing Advance Directive"; + Catalog_Item_Modifier := NextHour; + Catalog_Item_Version := ""; + + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((thisdocumentCommunication.ClientVisitGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + user_IDCode := read last {"SELECT IDCode FROM CV3User " || " where GUID = " || thisdocumentCommunication.UserGUID}; + RequestingCareProvider_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindById with ( user_IDType, (user_IDCode as STRING) ); + location_guid := read last {"SELECT CurrentLocationGUID FROM CV3ClientVisit where ClientGUID = " || thisdocumentCommunication.ClientGUID}; + location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((location_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + general_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with orderItemName; + + + GeneralOrder_Obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder + with client_visit_obj, + general_catalog_item, + Catalog_Item_Modifier, + Catalog_Item_Version, + order_creation_reason, + RequestingCareProvider_obj, + RequestingSource, + SessionType, + SessionReason, + location_obj, + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; + + void := call GeneralOrder_Obj.Save; + void := call GeneralOrder_Obj.Dispose; + + endtry; + + // Exception Handling + catch Exception ex + debugFlag := true; + messageText := messageText || "New General Order:\n" || ex.Message || "\n\n"; + endcatch; + + // Clean UP + if (location_obj IS NOT NULL) then void := call location_obj.Dispose; location_obj := NULL; endif; + if (requesting_care_provider_obj IS NOT NULL) then void := call requesting_care_provider_obj.Dispose; requesting_care_provider_obj := NULL; endif; + if (general_catalog_item IS NOT NULL) then void := call general_catalog_item.Dispose; general_catalog_item := NULL; endif; + if (client_visit_obj IS NOT NULL) then void := call client_visit_obj.Dispose; client_visit_obj := NULL; endif; + + + endif; // End of Place Order = Yes section + + endif; // End of Close Document + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_ADVANCE_DIRECTIVE_FOLLOWUP_CHARTING_REMINDER.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_ADVANCE_DIRECTIVE_FOLLOWUP_CHARTING_REMINDER.mlm new file mode 100644 index 0000000..c1cbdf2 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_ADVANCE_DIRECTIVE_FOLLOWUP_CHARTING_REMINDER.mlm @@ -0,0 +1,157 @@ +maintenance: + + title: DOC_FUNC_ADVANCE_DIRECTIVE_FOLLOWUP_CHARTING_REMINDER;; + mlmname: DOC_FUNC_ADVANCE_DIRECTIVE_FOLLOWUP_CHARTING_REMINDER;; + arden: version 2.5;; + version: 5.50;; + institution: Allscripts;; + author: Debbie Eiler;; + specialist: Don Warnick;; + date: 2011-07-18;; + validation: testing;; + +library: + purpose: Remind the nurse to chart that they have followed up with the familiy on the need to bring in the patient{{{SINGLE-QUOTE}}}s Advance Directive + ;; + explanation: Upon open of the Adult Assessment/Intervention Flowsheet remind the nurse that the patient family is to bring in the Advance Directive and charted follow up must occur + + Change history + + 05.10.2016 DJW CSR#34412 Advance Directive Follow Up Created + 10.26.2017 JML CSR#26413 Modified to support document scanning in SCM + + ;; + keywords: braden, alert, flowsheet + ;; +knowledge: + type: data-driven;; + data: + + (this_documentCommunication) := argument; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + msg := ""; + + //Set constants indicating document type and event + FLOWSHEET := "Flowsheet"; + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTCLOSING := "DocumentClosing"; + + // Get the client and visit GUIDs + client_guid := this_documentCommunication.ClientGUID; + client_visit_guid := this_documentCommunication.ClientVisitGUID; + chart_guid := this_documentCommunication.ChartGUID; + user_guid := this_documentCommunication.UserGUID; + + //Retrieve DocumentType (StructuredNote or Flowsheet) and EventType + this_DocumentType := this_documentCommunication.DocumentType; + this_EventType := this_documentCommunication.EventType; + + OccCode := read last {" select OccupationCode from CV3USER with (nolock) where guid = " || sql(user_guid) }; + + + if ( OccCode IN ("RN","GN","LPN","IT") ) then + + (AdvanceDirectiveDate,AdvanceDirectiveStatus,currentdate) := read last + { + " select distinct " + || " case when cd.DocumentName is not null and com.text IS null then convert(date, fsl.TouchedWhen,112) " + || " when cd.DocumentName is not null and com.text = {{{SINGLE-QUOTE}}}Y{{{SINGLE-QUOTE}}} and com.typecode = {{{SINGLE-QUOTE}}}ADVDIRONFILE{{{SINGLE-QUOTE}}} then convert(date, com.TouchedWhen,112) " + || " end , " + || " case when cd.DocumentName is not null and com.text IS null and ocmi.name IN ({{{SINGLE-QUOTE}}}SCHCK Advance Directive{{{SINGLE-QUOTE}}}) then {{{SINGLE-QUOTE}}}Instructed to bring in copy of Advance Directive{{{SINGLE-QUOTE}}} " + || " when cd.DocumentName is not null and com.text IS null and ocmi.name IN ({{{SINGLE-QUOTE}}}SCHCK Advance Directive Pt has Med{{{SINGLE-QUOTE}}}) and fsl.value = {{{SINGLE-QUOTE}}}Unable to obtain due to patient condition{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}Unable to obtain Advance Directive due to patient condition{{{SINGLE-QUOTE}}} " + || " when cd.DocumentName is not null and com.text = {{{SINGLE-QUOTE}}}Y{{{SINGLE-QUOTE}}} and com.typecode = {{{SINGLE-QUOTE}}}ADVDIRONFILE{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}A copy has been scanned. Please update the Patient Profile{{{SINGLE-QUOTE}}} " + || " end , " + || " convert(date,getdate(),112) " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = " || SQL(client_guid) || " and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock) ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID and ocmi.name in ({{{SINGLE-QUOTE}}}SCHCK Advance Directive{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}SCHCK Advance Directive Pt has Med{{{SINGLE-QUOTE}}}) " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " join cv3obscatalogitem oci with (nolock) on oci.guid = o.obsitemguid " + || " join SCMObsFSListValues fsl with (nolock) ON (fsl.ParentGUID = od.ObservationDocumentGUID AND fsl.ClientGUID = " || SQL(client_guid) || " " + || " and (fsl.value = {{{SINGLE-QUOTE}}}instructed to bring a copy to the hospital{{{SINGLE-QUOTE}}} or fsl.value = {{{SINGLE-QUOTE}}}Unable to obtain due to patient condition{{{SINGLE-QUOTE}}})) " + || " left join CV3CommentDeclaration com with (nolock) on com.clientguid = " || SQL(client_guid) || " and com.TEXT = {{{SINGLE-QUOTE}}}y{{{SINGLE-QUOTE}}} and com.touchedwhen > fsl.touchedwhen and com.typecode = {{{SINGLE-QUOTE}}}ADVDIRONFILE{{{SINGLE-QUOTE}}} " + || " where cd.clientguid = " || SQL(client_guid) || " and cd.ChartGUID = " || SQL(chart_guid) || " and cd.ClientVisitGUID = " || SQL(client_visit_guid) || " and cd.DocumentName like {{{SINGLE-QUOTE}}}%Patient Profile%{{{SINGLE-QUOTE}}} " + || " and cd.CreatedWhen = " + || " (select top 1 cdx.CreatedWhen from CV3ClientDocument cdx with (nolock) where " + || " cdx.clientguid = " || SQL(client_guid) || " and cdx.ChartGUID = " || SQL(chart_guid) || " and cdx.ClientVisitGUID = " || SQL(client_visit_guid) || " " + || " and cdx.DocumentName like {{{SINGLE-QUOTE}}}%Patient Profile%{{{SINGLE-QUOTE}}}) " + }; + + + FollowupChartingDate,FollowupChartingStatus,currentdate2 := read last + { + " set concat_null_yields_null off " + || " select " + || " convert(date, cd.AuthoredDtm,112) {{{SINGLE-QUOTE}}}Timestamp{{{SINGLE-QUOTE}}}, " + || " cast (o.ValueText as varchar(2000)) + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + cast (fsl.value as varchar (2000)) {{{SINGLE-QUOTE}}}Value{{{SINGLE-QUOTE}}}, " + || " convert(date,getdate(),112) " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = " || SQL(client_guid) || " " + || " join CV3ObservationDocument od with (nolock) ON cdd.CLientDocumentGUID = od.OwnerGUID " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) ON od.ObsMasterItemGUID = ocmi.GUID " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " join cv3obscatalogitem oci with (nolock) ON oci.guid = o.obsitemguid " + || " left join cv3obscatalogset ocs with (nolock) ON ocs.guid = od.ObsSetGUID " + || " left join SCMObsFSListValues fsl with (nolock) ON fsl.ParentGUID = od.ObservationDocumentGUID AND fsl.ClientGUID = " || SQL(client_guid) || " " + || " where cd.clientguid = " || SQL(client_guid) || " and cd.ChartGUID = " || SQL(chart_guid) || " and cd.ClientVisitGUID = " || SQL(client_visit_guid) || " " + || " and od.active = 1 and cdd.active = 1 and cd.IsCanceled = 0 " + || " and ocmi.description in ({{{SINGLE-QUOTE}}}SCHCK_AS Advance Directive FU{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCHCK Advance Directive{{{SINGLE-QUOTE}}})" + || " and cd.DocumentName = {{{SINGLE-QUOTE}}}2. Adult Assessment/Intervention{{{SINGLE-QUOTE}}} " + || " order by ocmi.description , cd.authoreddtm " + }; + + + // Determine if an alert should fire. + + + if exists AdvanceDirectiveStatus and AdvanceDirectiveStatus = "Instructed to bring in copy of Advance Directive" and currentdate > AdvanceDirectiveDate + then potential_alert := "yes"; + else potential_alert := "no"; + endif; + + if exists FollowupChartingStatus and FollowupChartingStatus = " Patient/Family reminded to bring in copy of Advance Directive" + then suppress_alert1 := "yes"; + else suppress_alert1 := "no"; + endif; + + if exists FollowupChartingStatus and FollowupChartingStatus = "Unable to contact family" and currentdate2 = FollowupChartingDate + then suppress_alert2 := "yes"; + else suppress_alert2 := "no"; + endif; + + If (Extract Hour NOW) in(0,1,2,3,4,5,6,7) + then suppress_alert3 := "yes"; + else suppress_alert3 := "no"; + endif; + + if potential_alert = "yes" and + ( + suppress_alert1 = "no" + and + (suppress_alert2 = "no" and suppress_alert3 = "no") + ) + then + msg := " Reminder: Advance Directive Follow-up has not been documented"; + dialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with msg, "Advance Directive Follow up Charting Required", "Ok" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + + + endif; // occupation + + + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: + return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_ANTICOAG_PLATELET_ALERT.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_ANTICOAG_PLATELET_ALERT.mlm new file mode 100644 index 0000000..33aa09a --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_ANTICOAG_PLATELET_ALERT.mlm @@ -0,0 +1,194 @@ +maintenance: + + title: BMI Checking;; + mlmname: DOC_FUNC_ANTICOAG_PLATELET_ALERT;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Shawn Head;; + specialist: ;; + date: 2013-02-15;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 02-15-2013 - CSR #: 31409 new alert for patients with anticoag order(s) AND have a platelet count less than 50 (50,000) + 8-30-2013 - HelpDesk issue - Updated to use better SQL logic to extract data from database. MLM was taking 60-90 seconds to open flowsheet for a specific patient. + 11-14-2013 - HelpDesk issue #: 162093 - Updated to more accuratly identify synonyms . + 1-28-2014 - CSR #: 31957 - Update observation item for fall harm for the new observation created. + ;; + keywords: platelet, count, anticoag, anticoagulant + ;; +knowledge: + type: data-driven;; + data: + + //Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Receive arguments from the structured note + (thisDocumentCommunication) := argument; + + // Get the user, charte, client and visit GUIDs + userGuid := thisDocumentCommunication.UserGUID; + clientGuid := thisDocumentCommunication.ClientGUID; + clientvisitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + +// Chart Observation Section + +//only trigger on document open +IF thisdocumentCommunication.EventType ="DocumentOpening" then + + latestplatetctdttm := read last {"select MAX(entered) " + || " from CV3BasicObservation bo with (nolock) " + || " where bo.ClientGUID = " || SQL(clientGuid) + || " and bo.ClientVisitGUID = " || SQL(clientvisitGuid) //{{{SINGLE-QUOTE}}}9000003475300270{{{SINGLE-QUOTE}}} + || " and (bo.itemname in ({{{SINGLE-QUOTE}}}Platelet Count{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Platelet Count.{{{SINGLE-QUOTE}}})) " }; + + if latestplatetctdttm is not null then + //get the latest platelet count result for patients that have + //an active order for one of the defined anticoag medications listed. + //Medication names or synonyms like {{{SINGLE-QUOTE}}}%lovenox%{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}%Heparin%{{{SINGLE-QUOTE}}} + //%Coumadin%, {{{SINGLE-QUOTE}}}%Pradaxa%{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}%Xarelto%{{{SINGLE-QUOTE}}} + //If they dont have an anticoag order OR if they dont have any platelet count + //results this should return NULL preventing the next section from executing + //saving processing time and logic checking that is not required. + plateletct := read last {"select top 1 bo.Value " + || " from CV3ClientVisit cv with (nolock) " + || " inner join CV3BasicObservation bo with (nolock) on (cv.clientguid = bo.clientguid " + || " and cv.GUID = bo.ClientVisitGUID " + || " and bo.clientguid = " || SQL(clientGuid) //{{{SINGLE-QUOTE}}}9000064583200200{{{SINGLE-QUOTE}}} + || " and bo.ClientVisitGUID = " || SQL(clientvisitGuid) //{{{SINGLE-QUOTE}}}9000003475300270{{{SINGLE-QUOTE}}} + || " and (bo.itemname in ({{{SINGLE-QUOTE}}}Platelet Count{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Platelet Count.{{{SINGLE-QUOTE}}})) " + || " and bo.Entered = " || SQL(latestplatetctdttm) || ") " // {{{SINGLE-QUOTE}}}2013-02-20 14:11:43.433{{{SINGLE-QUOTE}}}) + || " inner join CV3Order o with (nolock) on bo.ClientGuid = o.ClientGuid and bo.ClientVisitGUID = o.ClientVisitGUID " + || " inner join CV3CatalogItemName cin with (nolock) on o.OrderCatalogMasterItemGUID = cin.OrderMasterItemGUID " + || " where " + || " (o.TypeCode = {{{SINGLE-QUOTE}}}Medication{{{SINGLE-QUOTE}}} " + || " and o.Name is not null " + || " and o.Active = 1 " + || " and (o.OrderStatusCode like {{{SINGLE-QUOTE}}}AU%{{{SINGLE-QUOTE}}} or o.OrderStatusCode = {{{SINGLE-QUOTE}}}HOLD{{{SINGLE-QUOTE}}}) " + || " and (cin.Name like {{{SINGLE-QUOTE}}}%Enoxaparin%{{{SINGLE-QUOTE}}} " + || " or cin.Name like {{{SINGLE-QUOTE}}}%Heparin%{{{SINGLE-QUOTE}}} " + || " or cin.Name like {{{SINGLE-QUOTE}}}%Warfarin%{{{SINGLE-QUOTE}}} " + || " or cin.Name like {{{SINGLE-QUOTE}}}%Dabigatran%{{{SINGLE-QUOTE}}} " + || " or cin.Name like {{{SINGLE-QUOTE}}}%Rivaroxaban%{{{SINGLE-QUOTE}}} " + || " or cin.Name like {{{SINGLE-QUOTE}}}%lovenox%{{{SINGLE-QUOTE}}} " + || " or cin.Name like {{{SINGLE-QUOTE}}}%Coumadin%{{{SINGLE-QUOTE}}} " + || " or cin.Name like {{{SINGLE-QUOTE}}}%Pradaxa%{{{SINGLE-QUOTE}}} " + || " or cin.Name like {{{SINGLE-QUOTE}}}%Xarelto%{{{SINGLE-QUOTE}}} " + || " or o.Name like {{{SINGLE-QUOTE}}}%Enoxaparin%{{{SINGLE-QUOTE}}} " + || " or o.Name like {{{SINGLE-QUOTE}}}%Heparin%{{{SINGLE-QUOTE}}} " + || " or o.Name like {{{SINGLE-QUOTE}}}%Warfarin%{{{SINGLE-QUOTE}}} " + || " or o.Name like{{{SINGLE-QUOTE}}}%Dabigatran%{{{SINGLE-QUOTE}}} " + || " or o.Name like {{{SINGLE-QUOTE}}}%Rivaroxaban%{{{SINGLE-QUOTE}}} " + || " or o.Name like {{{SINGLE-QUOTE}}}%lovenox%{{{SINGLE-QUOTE}}} " + || " or o.Name like {{{SINGLE-QUOTE}}}%Coumadin%{{{SINGLE-QUOTE}}} " + || " or o.Name like {{{SINGLE-QUOTE}}}%Pradaxa%{{{SINGLE-QUOTE}}} " + || " or o.Name like {{{SINGLE-QUOTE}}}%Xarelto%{{{SINGLE-QUOTE}}})) " }; + + endif; + + + //this if statement will prevent unnecessary code from being executed if + //there is no platelet count on this patients chart OR if they dont have + //an anticoag order on their chart + If plateletct is not null and (plateletct as number) <= 50 then + //get the most curernt observation date/time + //for the observation name {{{SINGLE-QUOTE}}}SCHCK_AS harm risk indicators{{{SINGLE-QUOTE}}} for the harm risk assessment + obsdttm := read last { " SELECT Distinct " + || " isnull(MAX(cd.authoreddtm),{{{SINGLE-QUOTE}}}1900-01-01{{{SINGLE-QUOTE}}}) " + || " FROM CV3ClientDocument CD WITH (NOLOCK) " + || " JOIN CV3ObservationDocument OD WITH (NOLOCK) " + || " ON OD.OwnerGUID = CD.GUID " + || " and OD.Arctype = CD.Arctype " + || " JOIN CV3Observation Obs WITH (NOLOCK) " + || " ON OD.ObservationGUID = Obs.GUID " + || " AND OD.Arctype = Obs.Arctype " + || " left JOIN CV3ObservationXInfo OXI WITH (NOLOCK) " + || " ON obs.GUID = OXI.observationXInfoGUID " + || " and obs.Arctype = OXI.Arctype " + || " LEFT JOIN CV3ObservationEntryItem OEI with (nolock) " + || " ON OEI.GUID = OD.ParameterGUID " + || " JOIN CV3ObsCatalogMasterItem OCMI with (nolock) " + || " on OCMI.GUID = OD.ObsMasterItemGUID " + || " join cv3obscatalogitem oci with (nolock) " + || " on oci.guid = obs.obsitemguid " + || " WHERE CD.ClientGUID = " || sql(clientguid) + || " and cd.ClientVisitGUID = " || sql(clientvisitguid) + || " and cd.ChartGUID = " || sql(chartguid) + || " and oci.name in ({{{SINGLE-QUOTE}}}SCHCK_AS harm risk indicators{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCHCK_AS Harm Risk Assm{{{SINGLE-QUOTE}}})" + || " AND OD.Active = 1 " + || " AND CD.Active = 1 " }; + + + + //get the latest observation value from both the current and archive tables that matches the + //date/time set in the above if statement for variable obsdttm + findanticoagobsval := read last { " SELECT oflv.value " + || " FROM CV3ClientDocument CD WITH (NOLOCK) " + || " JOIN CV3ObservationDocument OD WITH (NOLOCK) " + || " ON OD.OwnerGUID = CD.GUID " + || " and OD.Arctype = CD.Arctype " + || " JOIN CV3Observation Obs WITH (NOLOCK) " + || " ON OD.ObservationGUID = Obs.GUID " + || " AND OD.Arctype = Obs.Arctype " + || " join SCMObsFSListValues oflv with (nolock) " + || " on od.observationdocumentguid = oflv.ParentGUID " + || " and cd.clientguid = oflv.clientguid " + || " left JOIN CV3ObservationXInfo OXI WITH (NOLOCK) " + || " ON obs.GUID = OXI.observationXInfoGUID " + || " and obs.Arctype = OXI.Arctype " + || " LEFT JOIN CV3ObservationEntryItem OEI with (nolock) " + || " ON OEI.GUID = OD.ParameterGUID " + || " JOIN CV3ObsCatalogMasterItem OCMI with (nolock) " + || " on OCMI.GUID = OD.ObsMasterItemGUID " + || " join cv3obscatalogitem oci with (nolock) " + || " on oci.guid = obs.obsitemguid " + || " and oci.name in ({{{SINGLE-QUOTE}}}SCHCK_AS harm risk indicators{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCHCK_AS Harm Risk Assm{{{SINGLE-QUOTE}}})" + || " AND oflv.Value like {{{SINGLE-QUOTE}}}%50,000%{{{SINGLE-QUOTE}}} " + || " WHERE CD.ClientGUID = " || sql(clientguid) + || " and cd.ClientVisitGUID = " || sql(clientvisitguid) + || " and cd.ChartGUID = " || sql(chartguid) + || " and cd.AuthoredDtm = " || SQL(obsdttm) + || " AND OD.Active = 1 " + || " AND CD.Active = 1 " }; + + + //This section checks to if there was a documented observation on the + //A/I flowsheet with a vlue like {{{SINGLE-QUOTE}}}%50,000%{{{SINGLE-QUOTE}}}. If one is not documented + //AND if the plateletct is less than 50 (indicating less than 50,000) + //then the warning message will fire; otherwise it will not display the + //warning message to the user. + + if findanticoagobsval is null and (plateletct as number) <= 50 then + msg:= "This patient has an increased risk of harm should a fall occur due to a Platelet Count less than 50,000 " + || "AND an active Anticoag order." + || "\n\nPlease reassess the harm risk indicators and consider appropriate interventions aimed at reducing harm."; + + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with msg,"Alert","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + endif; + +endif; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_BEHAVIORAL_HEALTH_OUTPATIENT_ALERTS.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_BEHAVIORAL_HEALTH_OUTPATIENT_ALERTS.mlm new file mode 100644 index 0000000..4380e31 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_BEHAVIORAL_HEALTH_OUTPATIENT_ALERTS.mlm @@ -0,0 +1,155 @@ +maintenance: + + title: DOC_FUNC_BEHAVIORAL_HEALTH_OUTPATIENT_ALERTS;; + mlmname: DOC_FUNC_BEHAVIORAL_HEALTH_OUTPATIENT_ALERTS;; + arden: version 2.50;; + version: 18.4;; + institution: St.Clair Hospital;; + author: Juliet M. Law;; + specialist: Peggy Leschak;; + date: 2019-08-29;; + validation: testing;; + +library: + purpose: Display alert if user answers {{{SINGLE-QUOTE}}}YES{{{SINGLE-QUOTE}}} to a set of nutritional questions on the Adult Patient Profile - Behavorial Health Outpatient document. + ;; + explanation: This MLM will trigger off the user answering {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to the following questions: + * Is this a change in appetite? + * Weight loss or weight gain of 10 pounds or more in the past 3 months? + * Do you have any dental problems affecting your nutrition? + + This MLM will trigger off the user answering anything EXCEPT {{{SINGLE-QUOTE}}}None{{{SINGLE-QUOTE}}} to the following question: + * History of Eating Disorder or current behaviors indicative of a possible eating disorder? + + The alert will only display once. + + Change history + + 08.29.2019 JML CSR# 38601 Created. + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // RS ADD Message box + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + nutParamName := ( "SCH_PRO_Nutr change of app" + , "SCH_PRO_Weight loss" + , "SCH_PRO_Weight gain" + , "SCH_PRO_Nutr Dental SG" + , "PRO nutrition eating disorderOutpt"); + + abuseParamName := ( "PRO Abuse Screen referangency_BH profile" + , "PRO Abuse Screen referangency_BH profile2" + , "PRO Abuse Screen referangency_BH profile3" + , "PRO Abuse Screen referangency_BH profile4" + , "PRO Abuse Screen referangency_BH profile5" + , "PRO Abuse Screen referangency_BH profile6" + , "PRO Abuse Screen referangency_BH profile7" ); + displayNutMessage := false; + displayAbuseMessage := false; + + nutritionMsg := "NUTRITION ALERT!\n\nNotify Attending Physician for the appropriate referral. Add problem to Referral or Deferral section of the patient{{{SINGLE-QUOTE}}}s treatment plan."; + abuseMsg := "ABUSE ALERT!\n\nNotify Attending Physician for the appropriate referral. Add problem to Referral or Deferral section of the patient’s treatment plan"; + + if ( thisDocumentCommunication.EventType = "DocumentClosing" ) then + for var IN 1 seqto count nutParamName do + + nutParam := first of ( thisParameters WHERE thisParameters.Name = nutParamName[var] ); + + if ( exists nutParam ) then + + nutObs := first of ( thisObservations WHERE thisObservations.ParameterGUID = nutParam.ParameterGUID ); + + if ( exists nutObs ) then + + selectedYes := exists ( nutObs.ValueObj.ListItemsList.Value + WHERE nutObs.ValueObj.ListItemsList.Value = "yes" + AND nutObs.ValueObj.ListItemsList.IsSelected = true ); + + selectedNonNone := count ( nutObs.ValueObj.ListItemsList.Value + WHERE nutObs.ValueObj.ListItemsList.Value IN ( "anorexia","bulimia","induced vomiting","overuse of laxatives","excessive exercise") + AND nutObs.ValueObj.ListItemsList.IsSelected = true ); + + if ( selectedYes ) then + displayNutMessage := true; + endif; + + if ( selectedNonNone > 0 ) then + displayNutMessage := true; + endif; + + endif; + endif; + enddo; + + for var IN 1 seqto count abuseParamName do + + abuseParam := first of ( thisParameters WHERE thisParameters.Name = abuseParamName[var] ); + + if ( exists abuseParam ) then + + abuseObs := first of ( thisObservations WHERE thisObservations.ParameterGUID = abuseParam.ParameterGUID ); + + if ( exists abuseObs ) then + + selectedYes := exists ( abuseObs.ValueObj.ListItemsList.Value + WHERE abuseObs.ValueObj.ListItemsList.Value = "yes" + AND abuseObs.ValueObj.ListItemsList.IsSelected = true ); + + if ( selectedYes ) then + displayAbuseMessage := true; + endif; + + endif; + endif; + enddo; + + if ( displayNutMessage ) then + dialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with nutritionMsg, "Nutrition Behavior Alert", "Ok" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}, "Exclamation" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + endif; + + if ( displayAbuseMessage ) then + dialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with abuseMsg, "Abuse Screening Alert", "Ok" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}, "Exclamation" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + endif; + endif; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_BLOOD_REFUSAL_HEALTH_ISSUE.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_BLOOD_REFUSAL_HEALTH_ISSUE.mlm new file mode 100644 index 0000000..e5d8813 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_BLOOD_REFUSAL_HEALTH_ISSUE.mlm @@ -0,0 +1,232 @@ +maintenance: + + title: DOC_FUNC_BLOOD_REFUSAL_HEALTH_ISSUE;; + mlmname: DOC_FUNC_BLOOD_REFUSAL_HEALTH_ISSUE;; + arden: version 5.5;; + version: 15.10;; + institution: St.Clair Hospital;; + author: Juliet M. Law;; + specialist: ;; + date: 2016-06-16;; + validation: testing;; + +library: + purpose: Create a health issue when blood refusal observation is charted on any Adult Patient Profile structured note. + ;; + explanation: This MLM will fire on the following structured note documents: + * Adult Patient Profile + * OB Patient Profile + * Adult Patient Profile - Behavioral Health + * Adult Patient Profile - Behavioral Health Outpatient + * Adult Patient Profile - Infusion + * Adult Patient Profile - Observation + + When "Refuses Blood Products" observation value is selected under Transfusion History, a Problem-Chronic health issue, "Refusal of blood product", will be created, if it doesn{{{SINGLE-QUOTE}}}t exist. + When "Refuses Blood Products due to Religious Beliefs" is selected under Transfusion History, a Problem-Chronic health issue, "Transfusion of blood product refused for religious reason", + will be created, if it doesn{{{SINGLE-QUOTE}}}t exist. + + Change history + + 06.16.2016 JML CSR 33898: Created + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + ListValueType := OBJECT [ListGuid, ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + transfusionParameterName := "PRO transfuse restrictions"; + refusesBloodValue := "Refuses Blood Products"; + createBV := false; + refusesBloodReligionValue := "Refuses Blood Products due to Religious Beliefs"; + createRBV := false; + blood_hi_name := ""; + + //Determine if patient has existing Blood Refusal health issue + bloodRefuseHI := READ LAST { "SELECT hi.ShortName" + || " FROM CV3HealthIssueDeclaration hi WITH (NOLOCK) JOIN CV3CodedHealthIssue chi WITH (NOLOCK)" + || " ON hi.CodedHealthIssueGUID = chi.GUID" + || " WHERE hi.ClientGUID = " || SQL(clientGuid) + || " AND hi.ClientVisitGUID = " || SQL(visitGuid) + || " AND hi.Active = 1" + || " AND hi.Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " + || " AND hi.ICD10Code is Not null " + || " AND hi.TypeCode = {{{SINGLE-QUOTE}}}Problem-Visit{{{SINGLE-QUOTE}}}" + || " AND ( hi.Text = {{{SINGLE-QUOTE}}}Refusal of blood product{{{SINGLE-QUOTE}}}" + || " OR hi.ShortName = {{{SINGLE-QUOTE}}}Refusal of blood product{{{SINGLE-QUOTE}}})" }; + + rBloodRefuseHI := READ LAST { "SELECT hi.ShortName" + || " FROM CV3HealthIssueDeclaration hi WITH (NOLOCK) JOIN CV3CodedHealthIssue chi WITH (NOLOCK)" + || " ON hi.CodedHealthIssueGUID = chi.GUID" + || " WHERE hi.ClientGUID = " || SQL(clientGuid) + || " AND hi.ClientVisitGUID = " || SQL(visitGuid) + || " AND hi.Active = 1" + || " AND hi.Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " + || " AND hi.ICD10Code is Not null " + || " AND hi.TypeCode = {{{SINGLE-QUOTE}}}Problem-Visit{{{SINGLE-QUOTE}}}" + || " AND ( hi.Text = {{{SINGLE-QUOTE}}}Transfusion of blood product refused for religious reason{{{SINGLE-QUOTE}}}" + || " OR hi.ShortName = {{{SINGLE-QUOTE}}}Transfusion of blood product refused for religious reason{{{SINGLE-QUOTE}}})" }; + + if (thisDocumentCommunication.EventType = "ChartObservation") Then + //Determine value that they selected + bloodRestrictParam := first of ( thisParameters WHERE thisParameters.Name = transfusionParameterName ); + bloodRestrictObs := first of ( thisObservations WHERE thisObservations.ParameterGUID = bloodRestrictParam.ParameterGUID ); + + bloodRestrictValues := ( bloodRestrictObs.ValueObj.ListItemsList.Value WHERE bloodRestrictObs.ValueObj.ListItemsList.IsSelected = true ); + + //If {{{SINGLE-QUOTE}}}Refuses Blood Products{{{SINGLE-QUOTE}}} value selected AND {{{SINGLE-QUOTE}}}Refusal of blood product{{{SINGLE-QUOTE}}} HI doesn{{{SINGLE-QUOTE}}}t exist, create HI + if ( refusesBloodValue IN bloodRestrictValues AND not exists bloodRefuseHI ) then + createBV := true; + else + createBV := false; + endif; + + //If {{{SINGLE-QUOTE}}}Refuses Blood Products due to Religious Beliefs{{{SINGLE-QUOTE}}} value selected AND {{{SINGLE-QUOTE}}}Transfusion of blood product refused for religious reason{{{SINGLE-QUOTE}}} hi doesn{{{SINGLE-QUOTE}}}t exist, create HI + if ( refusesBloodReligionValue IN bloodRestrictValues AND not exists rBloodRefuseHI ) then + createRBV := true; + else + createRBV := false; + endif; + + //If either value above selected to create HI, alert user + if ( createBV OR createRBV ) then + + msg_hi := "This selection will create a health issue for this visit of "; + if ( createBV ) then + msg_hi := msg_hi || "{{{SINGLE-QUOTE}}}Refusal of blood product{{{SINGLE-QUOTE}}}"; + elseif ( createRBV ) then + msg_hi := msg_hi || "{{{SINGLE-QUOTE}}}Transfusion of blood product refused for religious reason{{{SINGLE-QUOTE}}}"; + endif; + msg_hi := msg_hi || "\n\nClick {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to confirm your selection. "; + msg_hi := msg_hi || "\n\nClick {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} if you wish to change your selection."; + + dialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show WITH msg_hi, "Confirm Blood Avoidance/Restrictions", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}, "Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + if ( ( dialogRes as String ) = "Yes" ) then + + //User selected Yes, create appropriate HI + try + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}Retrieve client:{{-R}}\n" || + ex.Message || "\n\n"; + if ex.InnerException is not null net_object then + error_message := error_message || "Inner Exception: " || ex.InnerException.Message || "\n\n"; + endif; + if ( client_visit_obj is NOT NULL ) then + void:= call client_visit_obj.Dispose; client_visit_obj:= null; + endif; + endcatch; + + try + NewHealthIssueHIType := "Problem-Visit"; + + if ( createRBV ) then + NewHealthIssueHICode := "Z53.1"; //"V13.3"; + elseif ( createBV ) then + NewHealthIssueHICode := "Z78.9"; + endif; + + NewHealthIssueHIScheme := "ICD10"; //"ICD9"; + + dd := EXTRACT Day now; + mn := EXTRACT Month now; + yr := EXTRACT Year now; + + Terms := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.FindIMOTerms with (NewHealthIssueHIScheme,NewHealthIssueHICode); + for i IN 1 SEQTO (Terms.Count as Number ) do + HI_obj := Terms[i]; + HI_Name := HI_obj.TermName as string; + If HI_Name = "Refusal of blood product" then + HI_NO := i; + elseif HI_Name = "Transfusion of blood product refused for religious reason" then + HI_NO := i; + endif; + enddo; + If HI_NO is Null Then + HI_NO :=1 ; + Endif; + New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with (client_visit_obj, NewHealthIssueHIType, Terms[HI_NO]); + + PartialDate_obj := new net_object {{{SINGLE-QUOTE}}}PartialDate{{{SINGLE-QUOTE}}} with (yr as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, mn as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, dd as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}} ); + New_HealthIssue_obj.OnsetDate := PartialDate_obj; + New_HealthIssue_obj.Text := "Created from Patient Profile information. " ; + + if ( createBV ) then + New_HealthIssue_obj.Name := "Refusal of blood product"; + elseif ( createRBV ) then + New_HealthIssue_obj.Name := "Transfusion of blood product refused for religious reason"; + endif; + + if ( New_HealthIssue_obj is NOT NULL ) then + void := call New_HealthIssue_obj.Save; + void := call New_HealthIssue_obj.Dispose; + endif; + + if ( client_visit_obj is NOT NULL ) then + void:= call client_visit_obj.Dispose; + client_visit_obj:= null; + endif; + + endtry; + + catch exception ex + error_occurred := true; + if ( New_HealthIssue_obj is NOT NULL ) then + void:= call New_HealthIssue_obj.Dispose; + New_HealthIssue_obj:= null; + endif; + endcatch; + else + void := ""; + endif; + endif; + endif; + ;; + evoke: + ;; + logic: + +conclude true; + + ;; + action: + + + return thisDocumentCommunication; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_BMI_CHECK.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_BMI_CHECK.mlm new file mode 100644 index 0000000..2f1ebe8 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_BMI_CHECK.mlm @@ -0,0 +1,85 @@ +maintenance: + + title: BMI Checking;; + mlmname: DOC_FUNC_BMI_Check;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Teresa Spicuzza;; + specialist: ;; + date: 2011-06-28;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 06.28.2011 TS Created + 01.30.2012 DW Optimized for FP1 + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + //Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Receive arguments from the structured note + (thisDocumentCommunication) := argument; + // Get the user, charte, client and visit GUIDs + userGuid := thisDocumentCommunication.UserGUID; + clientGuid := thisDocumentCommunication.ClientGUID; + clientvisitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + /* Get the current user{{{SINGLE-QUOTE}}}s occupation*/ + UserCode := read last + {"Select occupationcode " + ||" From cv3user " + ||" Where Guid = " || SQL(userguid) }; + + +// Chart Observation Section + +IF thisdocumentCommunication.EventType ="DocumentOpening" and usercode is in ("RN", "LPN", "CNA", "PCA", "GN", "IT") then + + BMIvaluetext, obsname := read last {"Select o.ValueText, oci.name from CV3ClientDocumentcur cd " + || " join CV3ClientDocDetailcur cdd on (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = " || SQL(ClientGuid) || ") " + || " join CV3ObservationDocumentcur od on cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3ObsCatalogMasterItem on od.ObsMasterItemGUID = CV3ObsCatalogMasterItem.GUID " + || " join CV3Observationcur o on o.GUID = od.ObservationGUID " + || " LEFT OUTER JOIN CV3User u ON o.UserGUID = u.GUID " + || " join cv3obscatalogitem oci on oci.guid = o.obsitemguid and oci.name = {{{SINGLE-QUOTE}}}SCH_vs_BMI{{{SINGLE-QUOTE}}} " + || " where cd.clientguid = " || SQL(ClientGuid) || " and cd.chartguid = " || SQL(ChartGuid) + || " and o.ValueText is not null " + || " order by cd.authoreddtm asc " }; + + If BMIvaluetext is null then + msg:= "This patient does not have a documented BMI." + || "\n\nPlease document the patient{{{SINGLE-QUOTE}}}s Height/Length and Admission/Current Weight in the same time column to calculate the BMI."; + + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with msg,"Alert","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + +endif; + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_BRADEN_SCALE_CHANGE_ALERT.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_BRADEN_SCALE_CHANGE_ALERT.mlm new file mode 100644 index 0000000..62f3c0c --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_BRADEN_SCALE_CHANGE_ALERT.mlm @@ -0,0 +1,135 @@ +maintenance: + + title: DOC_FUNC_BRADEN_SCALE_CHANGE_ALERT;; + mlmname: DOC_FUNC_BRADEN_SCALE_CHANGE_ALERT;; + arden: version 2.5;; + version: 5.50;; + institution: Allscripts;; + author: Juliet M. Law ;; + specialist: ;; + date: 2011-07-18;; + validation: testing;; + +library: + purpose: Alert on decrease in Braden Scale Score. + ;; + explanation: On the Adult Assessment/Intervention Flowsheet, if the Braden Risk criteria calculates a Braden score + less than or equal to 18 and the last charted Braden score charted was greater than the current Braden score, alert + the user. + ;; + keywords: braden, alert, flowsheet + ;; +knowledge: + type: data-driven;; + data: + + (this_documentCommunication) := argument; + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + //Called MLMs to set up the CDS and return obs values + set_cds_vars := MLM {{{SINGLE-QUOTE}}}CALLED_DOC_FS_DEFINITION_MLM{{{SINGLE-QUOTE}}}; + read_obs_value := MLM {{{SINGLE-QUOTE}}}CALLED_DOC_FS_OBS_VALUE_MLM{{{SINGLE-QUOTE}}}; + + + /**************Make Changes To Spelling And Flags In This Section**************/ + //Set up variables; initialize + braden_param := "AS SC braden score CAL"; + + msg := ""; + + mlm_name := "DOC_FUNC_CREATE_DIETITIAN_CONSULT_FROM_BRADEN_OBS"; + + //Set constants indicating document type and event + FLOWSHEET := "Flowsheet"; + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTCLOSING := "DocumentClosing"; + + /******************************************************************************/ + + //Initialize DocumentCommunication objects + (this_documentCommunication, client_guid, client_visit_guid, chart_guid, + user_guid, document_type, document_name, event_type, + configuration_guid, this_currentObs, CancelEventFlag, this_fs_doc, + authored_by_guid, isIOFlowsheetFlag, client_document_guid, this_parameters, + this_columnList, this_currentColumn, this_chartedObservationsList, + this_parameters_displayName, current_parameter, current_parameter_name, current_parameter_guid, + current_parameter_datatype, selectedItems, selectedItems_Value, current_value, + diagnostic_message, displayMessageFlag) := call set_cds_vars WITH (this_documentCommunication); + + //Retrieve DocumentType (StructuredNote or Flowsheet) and EventType + this_DocumentType := this_documentCommunication.DocumentType; + this_EventType := this_documentCommunication.EventType; + + //Process logic on Flowsheets when the document is closing + if (this_DocumentType = FLOWSHEET AND this_EventType = DOCUMENTCLOSING) then + //Retrieve Braden Score parameter + theParameter := first of (this_parameters WHERE this_parameters.Name = braden_param); + + if (exists theParameter) then + //Called MLM to retrieve value for Braden Score parameter + (this_documentCommunication, selectedValue, currentValue) := CALL read_obs_value WITH (this_documentCommunication, theParameter.Name, "Read"); + + if (exists currentValue) then + //Set current Braden Score variable + currentBradenScore := currentValue as number; + + //Retrieve DateTime from current charted column + chartedDateTime := first of (this_columnList.DateTime + where this_columnList.ClientDocumentGUID = this_currentObs.ClientDocumentGUID); + + //Retrieve previously charted Braden Score from database; + //Current charted column DateTime used to exclude current braden score value in the case + //that a modification is being made + oldBradenScore := (); + (oldBradenScore) := read {"SELECT o.ValueText, cd.touchedWhen " + || " FROM CV3ClientDocumentcur cd JOIN CV3ClientDocDetailcur cdd " + || " ON cdd.ClientDocumentGUID = cd.GUID " + || " JOIN CV3ObservationDocumentcur od " + || " ON cdd.CLientDocumentGUID = od.OwnerGUID " + || " JOIN CV3ObsCatalogMasterItem ocmi" + || " ON od.ObsMasterItemGUID = ocmi.GUID" + || " JOIN CV3Observationcur o " + || " ON o.GUID = od.ObservationGUID" + || " LEFT OUTER JOIN CV3User u " + || " ON o.UserGUID = u.GUID" + || " JOIN cv3obscatalogitem oci " + || " ON oci.guid = o.obsitemguid " + || " WHERE cd.clientguid = " || SQL(client_guid) + || " AND cd.chartguid = " || SQL(chart_guid) + || " AND cd.ClientVisitGUID = " || SQL(client_visit_guid) + || " AND oci.name = {{{SINGLE-QUOTE}}}" || braden_param || "{{{SINGLE-QUOTE}}}" + || " AND o.ValueText is not null" + || " AND cdd.Active = 1" + || " AND od.active = 1" + || " AND cd.authoreddtm < {{{SINGLE-QUOTE}}}" || chartedDateTime || "{{{SINGLE-QUOTE}}}" + || " ORDER BY cd.authoreddtm asc " + , primaryTime = touchedWhen}; + lastBradenScore := last of (oldBradenScore) as number; + + //If current Braden Score less than or equal to 18 AND the current Braden Score is less than + //the last charted Braden Score, then alert the user. + if (currentBradenScore <= 18) then + if (currentBradenScore < lastBradenScore) then + msg := "Today{{{SINGLE-QUOTE}}}s Braden Score has decreased since the last assessment. Additional Skin Care " + || "Interventions might be indicated."; + dialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with msg, "Braden Scale Change", "Ok" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + endif; + endif; + endif; + endif; + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: + return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_CARE_TRANSITIONS_INPATIENT_ASSESSMENT.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CARE_TRANSITIONS_INPATIENT_ASSESSMENT.mlm new file mode 100644 index 0000000..295477f --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CARE_TRANSITIONS_INPATIENT_ASSESSMENT.mlm @@ -0,0 +1,345 @@ +maintenance: + + title: DOC_FUNC_CARE_TRANSITIONS_INPATIENT_ASSESSMENT;; + mlmname: DOC_FUNC_CARE_TRANSITIONS_INPATIENT_ASSESSMENT;; + arden: version 6.1;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Juliet Law;; + specialist: Dean Miklavic;; + date: 2014-12-04;; + validation: testing;; + +library: + purpose: + ;; + explanation: + + Change history + + 12.04.2014 JML CSR 32423: Create date. + 01.27.2015 JML Moved to Production. + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // Receive arguments from the structured note + (this_documentCommunication) := argument; + + // .Net assemblies required for ObjectsPlus + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + //Include MLM + str_parse := MLM {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; + + //Include Called MLM to setup CDS objects + set_cds_vars := MLM {{{SINGLE-QUOTE}}}Called_RPM_DOM_Get_Definition_MLM{{{SINGLE-QUOTE}}}; + + //Document Types + STRUCTUREDNOTE := "StructuredNote"; + + //Event Types + DOCUMENTCLOSING := "DocumentClosing"; + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTOPENING := "DocumentOpening"; + + //Setting debugFlag to True will allow popup dialogs containing debug information to appear + debugFlag := false; + + //Initialize CDS objects via MLM call + (this_documentCommunication, client_guid, client_visit_guid, client_chart_guid, user_guid, + document_type, document_name, event_type, configuration_guid, this_currentObj, CancelEventFlag, + this_structuredNoteDoc, authored_date_time, authored_by_guid, client_document_guid, document_date_time, + isNewFlag, isIncompleteFlag, isResultsPendingFlag, isPriorityFlag, this_parameters, + this_chartedObservationsList, this_parameters_display_name, current_parameter, current_parameter_name, + current_parameter_guid, current_parameter_DataType, selectedItems, selectedItems_value, current_value, + diagnosticMessage, displayMessageFlag, CoSigner1, CoSigner2, DocumentTopic) := CALL set_cds_vars WITH + (this_documentCommunication); + + //Set up debugging information to be captured + messageText := ""; + if (debugFlag = true) then + messageText := "Debug Information:\n\n"; + messageText := messageText || " DOC_FUNC_PREOPERATIVE_CHECKLIST mlm called.\n\n"; + endif; + + //Local Variables + theDocumentName := "Care Transitions Inpatient Assessment"; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + NumericValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + if ( event_type = DOCUMENTOPENING AND document_name = theDocumentName ) then + + //Get the patient{{{SINGLE-QUOTE}}}s last inpatient / obs discharge datetime + last_IPOB_discharge_date := read last {"SELECT Top 1 cv.DischargeDtm" + || " FROM CV3ClientVisit cv WITH (NOLOCK)" + || " WHERE cv.ClientGUID = " || Sql(client_guid) + || " AND cv.VisitStatus = {{{SINGLE-QUOTE}}}DSC{{{SINGLE-QUOTE}}}" + || " AND cv.TypeCode IN ({{{SINGLE-QUOTE}}}Inpatient{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Observation{{{SINGLE-QUOTE}}})" + || " ORDER BY cv.DischargeDtm DESC"}; + + //Retrieve IPOBS Admissions observation + ipParameterName := "SCH_Quality_IPOBS_Admissions_Last30days"; + ipParameter := first of ( this_parameters WHERE this_parameters.Name = ipParameterName ); + + if ( exists ipParameter ) then + //Retrieve number of inpatient/observation discharges in the last 30 days + num_IPOBS_visits := read last {"SELECT Count(cv.Guid)" + || " FROM CV3Client c WITH (NOLOCK) JOIN CV3ClientVisit cv WITH (NOLOCK)" + || " ON c.GUID = cv.ClientGUID" + || " WHERE c.GUID = " || Sql(client_guid) + || " AND cv.TypeCode IN ({{{SINGLE-QUOTE}}}Inpatient{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Observation{{{SINGLE-QUOTE}}})" + || " AND cv.DischargeDtm >= DATEADD(day, -30, getdate())" + || " AND cv.DischargeDtm < GetDate()" + || " AND cv.VisitStatus = {{{SINGLE-QUOTE}}}DSC{{{SINGLE-QUOTE}}}"}; + + + if ( exists num_IPOBS_visits ) then + //Setup object type to write to observation + this_currentIPOBSVisitObs := NEW ObservationType; + this_currentIPOBSVisitObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID; + this_currentIPOBSVisitObs.ParameterGUID := ipParameter.ParameterGUID; + this_currentIPOBSVisitObs.DataType := "NumericValue"; + this_currentIPOBSVisitObs.ValueObj := NEW NumericValueType; + this_currentIPOBSVisitObs.ValueObj.Value := num_IPOBS_visits as number; + + this_structuredNoteDoc.ChartedObservationsList := (this_structuredNoteDoc.ChartedObservationsList, this_currentIPOBSVisitObs); + + endif; + endif; //End ipParameter Exists + + //Retrieve ED Admissions observation + edParameterName := "SCH_Quality_ED_Admissions_Last30days"; + edParameter := first of ( this_parameters WHERE this_parameters.Name = edParameterName ); + + if ( exists edParameter ) then + //Retrieve number of ED discharges in last 30 days + num_ED_visits := read last {"SELECT Count(cv.Guid)" + || " FROM CV3Client c WITH (NOLOCK) JOIN CV3ClientVisit cv WITH (NOLOCK)" + || " ON c.GUID = cv.ClientGUID" + || " WHERE c.GUID = " || Sql(client_guid) + || " AND cv.TypeCode = {{{SINGLE-QUOTE}}}Emergency{{{SINGLE-QUOTE}}}" + || " AND cv.DischargeDtm >= DATEADD(day, -30, getdate())" + || " AND cv.DischargeDtm < GetDate()" + || " AND cv.VisitStatus = {{{SINGLE-QUOTE}}}DSC{{{SINGLE-QUOTE}}}"}; + + if ( exists num_ED_visits ) then + //Setup object type to write to observation + this_currentEDVisitObs := NEW ObservationType; + this_currentEDVisitObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID; + this_currentEDVisitObs.ParameterGUID := edParameter.ParameterGUID; + this_currentEDVisitObs.DataType := "NumericValue"; + this_currentEDVisitObs.ValueObj := NEW NumericValueType; + this_currentEDVisitObs.ValueObj.Value := num_ED_visits as number; + + this_structuredNoteDoc.ChartedObservationsList := ( this_structuredNoteDoc.ChartedObservationsList, this_currentEDVisitObs ); + endif; + + endif; //END edParameter Exists + + //Retrieve Last Discharge Date observation + dscParameterName := "SCH_Quality_Last_Discharge_Date"; + dscParameter := first of ( this_parameters WHERE this_parameters.Name = dscParameterName ); + + if ( exists dscParameter ) then + //Retrieve last inpatient, observation, or emergency discharge date + last_discharge_date := read last {"SELECT cv.DischargeDtm" + || " FROM CV3Client c WITH (NOLOCK) JOIN CV3ClientVisit cv WITH (NOLOCK)" + || " ON c.GUID = cv.ClientGUID" + || " WHERE c.GUID = " || Sql(client_guid) + || " AND cv.DischargeDtm IS NOT NULL" + || " AND cv.TypeCode IN ({{{SINGLE-QUOTE}}}Inpatient{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Observation{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Emergency{{{SINGLE-QUOTE}}})" + || " ORDER BY cv.DischargeDtm asc"}; + + if ( exists last_discharge_date ) then + //Setup object type to write to observation + this_currentDSCObs := NEW ObservationType; + this_currentDSCObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID; + this_currentDSCObs.ParameterGUID := dscParameter.ParameterGUID; + this_currentDSCObs.DataType := "DateValue"; + this_currentDSCObs.ValueObj := NEW DateValueType; + this_currentDSCObs.ValueObj.Value := last_discharge_date; + + this_structuredNoteDoc.ChartedObservationsList := ( this_structuredNoteDoc.ChartedObservationsList, this_currentDSCObs ); + endif; + endif; //END dscParameter exists + + //Retrieve Primary Insurance observation + insParameterName := "SCH_Quality_Primary_Insurance"; + insParameter := first of ( this_parameters WHERE this_parameters.Name = insParameterName ); + + if ( exists insParameter ) then + //Retrieve primary insurance + primary_ins := read last {"SELECT TOP 1 ic.Name" + || " FROM CV3FRPContract fc WITH (NOLOCK) JOIN CV3FRP f WITH (NOLOCK)" + || " ON fc.FRPGUID = f.GUID" + || " JOIN SXAAMInsuranceCarrier ic WITH (NOLOCK)" + || " ON f.InsuranceCarrierID = ic.InsuranceCarrierID" + || " WHERE fc.ClientGUID = " || Sql(client_guid) + || " AND fc.ClientVisitGUID = " || Sql(client_visit_guid) + || " AND fc.Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}}" + || " ORDER BY fc.SequenceNum"}; + + if ( exists primary_ins ) then + //Setup object to write to observation + this_currentInsObs := NEW ObservationType; + this_currentInsObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID; + this_currentInsObs.ParameterGUID := insParameter.ParameterGUID; + this_currentInsObs.DataType := "FreeTextValue"; + this_currentInsObs.ValueObj := NEW FreeTextValueType; + this_currentInsObs.ValueObj.Value := primary_ins; + + this_structuredNoteDoc.ChartedObservationsList := ( this_structuredNoteDoc.ChartedObservationsList, this_currentInsObs ); + endif; + endif; //END insParameter Exists + + //Retrieve the Home Care Last Admission observation + hclaParameterName := "SCH_Quality_Home_Care_Last_Admission"; + hclaParameter := first of ( this_parameters WHERE this_parameters.Name = hclaParameterName ); + + if ( exists hclaParameter ) then + //Retrieve Home Care Order Information + ( orderGuid, + orderSummary ) := read {"SELECT o.GUID, IsNull(o.SummaryLine,{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}})" + || " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3Order o WITH (NOLOCK)" + || " ON cv.GUID = o.ClientVisitGUID" + || " AND cv.ClientGUID = o.ClientGUID" + || " AND cv.ChartGUID = o.ChartGUID" + || " WHERE cv.ClientGUID = " || Sql(client_guid) + || " AND ( o.NAME = {{{SINGLE-QUOTE}}}Home Health Services{{{SINGLE-QUOTE}}} OR o.NAME = {{{SINGLE-QUOTE}}}DME - Home Care{{{SINGLE-QUOTE}}} OR o.NAME = {{{SINGLE-QUOTE}}}Home Health Services Consult{{{SINGLE-QUOTE}}})" + || " AND cv.TypeCode IN ({{{SINGLE-QUOTE}}}Inpatient{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Observation{{{SINGLE-QUOTE}}})" + || " AND cv.DischargeDtm = " || Sql(last_IPOB_discharge_date) + || " AND ((o.OrderStatusLevelNum > 15" + || " AND o.OrderStatusLevelNum NOT IN ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}}))" + || " OR o.OrderStatusCode = {{{SINGLE-QUOTE}}}HOLD{{{SINGLE-QUOTE}}})"}; + + if ( exists orderGuid ) then + //Preselect the {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} on the observation + preselectValue := "Yes"; + + if ( count orderGuid = 1 ) then + if ( last of ( orderSummary ) IS NULL ) then + parameterValue := ""; + else + parameterValue := last of ( orderSummary ); + endif; + + parameterValue := Trim(parameterValue); + else + + if ( first of (orderSummary) IS NULL ) then + parameterValue := ""; + else + parameterValue := first of ( Trim(orderSummary) ) || "\n\n"; + endif; + + if ( last of (orderSummary) IS NULL ) then + parameterValue := parameterValue || ""; + else + parameterValue := parameterValue || last of ( Trim(orderSummary) ); + endif; + endif; + else + preselectValue := "No"; + endif; + + //Setup the object to write to the observation + this_currentHCObs := NEW ObservationType; + this_currentHCObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID; + this_currentHCObs.ParameterGUID := hclaParameter.ParameterGUID; + this_currentHCObs.DataType := "ListValue"; + this_currentHCObs.ValueObj := NEW ListValueType; + this_currentHCObs.ValueObj.ListGUID := hclaParameter.ConfigurationObj.ListGUID; + + listItems := (); + for item IN hclaParameter.ConfigurationObj.ListItemsList do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if ( selectedItem.Value = "Yes" AND preselectValue = "Yes" ) then + selectedItem.IsSelected := true; + endif; + if ( selectedItem.Value = "No" AND preselectValue = "Yes" ) then + selectedItem.IsSelected := false; + endif; + if ( selectedItem.Value = "No" AND preselectValue = "No" ) then + selectedItem.IsSelected := true; + endif; + if ( selectedItem.Value = "No" AND preselectValue = "Yes" ) then + selectedItem.IsSelected := false; + endif; + + listItems := ( listItems, selectedItem ); + enddo; + + this_currentHCObs.ValueObj.ListItemsList := listItems; + this_structuredNoteDoc.ChartedObservationsList := ( this_structuredNoteDoc.ChartedObservationsList, this_currentHCObs ); + + if ( exists orderGUID ) then + //Retrieve the Home Care Agency observation + agencyParameterName := "SCH_Quality_HomeCareAgency"; + agencyParameter := first of ( this_parameters WHERE this_parameters.Name = agencyParameterName ); + + if ( exists agencyParameter ) then + //Setup object to write to observation + this_currentAGObs := NEW ObservationType; + this_currentAGObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID; + this_currentAGObs.ParameterGUID := agencyParameter.ParameterGUID; + this_currentAGObs.DataType := "FreeTextValue"; + this_currentAGObs.ValueObj := NEW FreeTextValueType; + this_currentAGObs.ValueObj.Value := parameterValue; + + this_structuredNoteDoc.ChartedObservationsList := ( this_structuredNoteDoc.ChartedObservationsList, this_currentAGObs); + endif; + endif; + + endif; //END hclaParameter Exists + + //Retrieve Admitting Diagnosis observation + admDiagParameterName := "SCH_Quality_Admitting_Diagnosis"; + admDiagParameter := first of ( this_parameters WHERE this_parameters.Name = admDiagParameterName ); + + if ( exists admDiagParameter ) then + //Retrieve admitting diagnosis + adm_diagnosis := read last {"SELECT hid.Text" + || " FROM CV3HealthIssueDeclaration hid WITH (NOLOCK)" + || " WHERE hid.ClientGUID = " || Sql(client_guid) + || " AND hid.ClientVisitGUID = " || Sql(client_visit_guid) + || " AND hid.TypeCode = {{{SINGLE-QUOTE}}}Admitting Dx{{{SINGLE-QUOTE}}}" + || " AND hid.Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}}" + || " AND hid.Active = 1"}; + + if ( exists adm_diagnosis ) then + //Setup object to write to observation + this_currentAdmObs := NEW ObservationType; + this_currentAdmObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID; + this_currentAdmObs.ParameterGUID := admDiagParameter.ParameterGUID; + this_currentAdmObs.DataType := "FreeTextValue"; + this_currentAdmObs.ValueObj := NEW FreeTextValueType; + this_currentAdmObs.ValueObj.Value := adm_diagnosis; + + this_structuredNoteDoc.ChartedObservationsList := ( this_structuredNoteDoc.ChartedObservationsList, this_currentAdmObs ); + endif; + endif; //END admDiagParameter Exists + endif; + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_CARE_TRANSITIONS_INPATIENT_ASSESSMENT_CLOSE.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CARE_TRANSITIONS_INPATIENT_ASSESSMENT_CLOSE.mlm new file mode 100644 index 0000000..770f516 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CARE_TRANSITIONS_INPATIENT_ASSESSMENT_CLOSE.mlm @@ -0,0 +1,257 @@ +maintenance: + + title: DOC_FUNC_CARE_TRANSITIONS_INPATIENT_ASSESSMENT_CLOSE;; + mlmname: DOC_FUNC_CARE_TRANSITIONS_INPATIENT_ASSESSMENT_CLOSE;; + arden: version 6.1;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Shivprasad Jadhav;; + specialist: Shivprasad Jadhav, GOS Allscripts;; + date: 2014-12-04;; + validation: testing;; + +library: + purpose: When user selects YES on the "Outpatient Pharmacy Services requested" observation and clicks SAVE, + automatically create a [Pharmacy Discharge Prescription Order] order item for the patient. + If there is text in the suggested dictionary text box on the structured note (Example: Lasix, Coreg). Copy this text into the Special Instructions box on the order item. + MLM will also retrieve and populate Pharmacy Insurance information from the Patient Info / Comments tab. + Set the Consult Indications data item to: "Fill Patient Prescription" from the drop down selection. + ;; + explanation: + + Change history + + 30.06.2015 GOS CSR 33339: Create date. + 01.05.2018 JML CSR# 26413: REG/SCHED upgrade. Modified MLM to look in CV3ClientUserData table for value + that was previously read from comment created by AMPFM. + + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // Receive arguments from the structured note + (thisDocumentCommunication) := argument; + + // .Net assemblies required for ObjectsPlus + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + //Local Variables + theDocumentName := "Care Transitions Inpatient Assessment"; + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + NumericValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + DocGuid := thisStructuredNoteDoc.ClientDocumentGUID ; + + //Include Called MLM to setup CDS objects + //set_cds_vars := MLM {{{SINGLE-QUOTE}}}Called_RPM_DOM_Get_Definition_MLM{{{SINGLE-QUOTE}}}; + + //Document Types + STRUCTUREDNOTE := "StructuredNote"; + + //Event Types + DOCUMENTCLOSING := "DocumentClosing"; + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTOPENING := "DocumentOpening"; + + //Setting debugFlag to True will allow popup dialogs containing debug information to appear + debugFlag := false; + + //Initialize CDS objects via MLM call + /*(thisDocumentCommunication, client_guid, client_visit_guid, client_chart_guid, user_guid, + document_type, document_name, event_type, configuration_guid, this_currentObj, CancelEventFlag, + this_structuredNoteDoc, authored_date_time, authored_by_guid, client_document_guid, document_date_time, + isNewFlag, isIncompleteFlag, isResultsPendingFlag, isPriorityFlag, this_parameters, + this_chartedObservationsList, this_parameters_display_name, current_parameter, current_parameter_name, + current_parameter_guid, current_parameter_DataType, selectedItems, selectedItems_value, current_value, + diagnosticMessage, displayMessageFlag, CoSigner1, CoSigner2, DocumentTopic) := CALL set_cds_vars WITH + (thisDocumentCommunication); */ + + + + If DocGuid Is not Null Then + LastObsVal := read First {"SELECT oflv.value " + || " FROM CV3ClientDocument cd WITH (NOLOCK) INNER JOIN cv3ClientVisit cv WITH (NOLOCK) ON cv.GUID = cd.ClientVisitGUID And cv.clientguid = cd.ClientGUID " + || " AND cv.chartguid = cd.ChartGUID AND cd.iscanceled = 0 And cd.Active = 1 AND cd.DocumentName = {{{SINGLE-QUOTE}}}Care Transitions Inpatient Assessment{{{SINGLE-QUOTE}}} " + || " INNER JOIN SXACDObservationParameter OP WITH (NOLOCK) ON OP.ClientGUID = cd.ClientGUID AND OP.ChartGUID = cd.ChartGUID " + || " AND OP.PatCareDocGUID = cd.PatCareDocGUID AND OP.RecordedDtm = cd.AuthoredDtm " + || " INNER JOIN CV3ObsCatalogMasterItem omi WITH (NOLOCK) ON omi.GUID = op.ObsMasterItemGUID And omi.name in ({{{SINGLE-QUOTE}}}SCH_Quality_Outpatient_Rx_Consult{{{SINGLE-QUOTE}}}) " + || " LEFT JOIN SCMObsFSListValues oflv WITH (NOLOCK) ON oflv.ParentGUID = op.ObservationDocumentGUID AND oflv.Active = 1 AND cd.ClientGUID = oflv.ClientGUID " + || " AND oflv.ClientGUID = cd.ClientGUID " + || " Where cv.guid = " || visitGuid + || " And cd.guid = " || thisStructuredNoteDoc.ClientDocumentGUID + || " And oflv.value in ({{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}})" }; + + Else + LastObsVal := LastObsVal ; + EndIf; + + + if ( thisDocumentCommunication.EventType = DOCUMENTCLOSING ) then + + + + // For Care Transition ----------------------------------------------------------------------------------------------------- + this_parametername := Last of (thisParameters where thisParameters.Name = "SCH_Quality_Outpatient_Rx_Consult"); + theObservation := Last of (thisobservations where thisobservations.ParameterGUID = this_parametername.ParameterGUID); + + If true in (theObservation.ValueObj.ListItemsList.IsSelected where + theObservation.ValueObj.ListItemsList.Value = "Yes" + ) then + SelValue := "Yes"; + Else + SelValue := "No"; + endif; + + SuggestedVal := theObservation.ValueObj.SuggestedTextValue ; If SuggestedVal is null Then SuggestedVal :=""; Endif; + + If SelValue = "Yes" And ( LastObsVal Is Null or LastObsVal ="No" ) Then + + + //CSR 26413 CHANGE: Modified SQL to use CV3ClientUsData + //Get the patient{{{SINGLE-QUOTE}}}s last inpatient / obs discharge datetime + Comm_Doc := OBJECT [Comm_name, Comm_val ] ; + Comm_vals := read as Comm_Doc {"SELECT cud.UserDataCode, cud.Value " + || " FROM CV3ClientVisit cv With (Nolock) Join CV3ClientUserData cud With (Nolock) " + || " On cv.ClientGUID = cud.ClientGUID " + || " WHERE cv.GUID = " || Sql(visitGuid) + || " AND cud.ClientGUID = " || Sql(clientGuid) + || " AND cv.ChartGUID = " || Sql(chartGuid) + || " And cud.UserDataCode in ({{{SINGLE-QUOTE}}}SER-RxInsurer{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SER-RxBIN{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SER-RxGROUP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SER-RxInsName{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SER-RxMemberID{{{SINGLE-QUOTE}}}) " + || " And cud.Active = 1" + || " And cud.Value IS NOT NULL And cud.Value <> {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}" }; + + Comm_RxInsurer := first of (Comm_vals.Comm_val where Comm_vals.Comm_name = "RxInsurer" ); If Comm_RxInsurer is null Then Comm_RxInsurer :=""; Endif; + Comm_RxBIN := first of (Comm_vals.Comm_val where Comm_vals.Comm_name = "RxBIN" ); If Comm_RxBIN is null Then Comm_RxBIN :=""; Endif; + Comm_RxGROUP := first of (Comm_vals.Comm_val where Comm_vals.Comm_name = "RxGROUP" ); If Comm_RxGROUP is null Then Comm_RxGROUP :=""; Endif; + Comm_RxInsName := first of (Comm_vals.Comm_val where Comm_vals.Comm_name = "RxInsName" ); If Comm_RxInsName is null Then Comm_RxInsName :=""; Endif; + Comm_RxMemberID:= first of (Comm_vals.Comm_val where Comm_vals.Comm_name = "RxMemberID" );If Comm_RxMemberID is null Then Comm_RxMemberID :=""; Endif; + + + + // Create Order + //==================================================================================================== + user_IDType := "Edstan Number (physician)"; + IF(visitGuid IS NOT NULL) THEN + try + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + WSSessionType := "Standard";//"Inpatient Orders";//Standard";//" + WSSessionReason := ""; + WSRequestedBySource := "";//"1 Standard"; + user_IDCode := read last {"SELECT IDCode FROM CV3User " || " where GUID = " || thisdocumentCommunication.UserGUID}; + WSRequestedBy_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindById with ( user_IDType, (user_IDCode as STRING) ); + location_guid := read last {"SELECT CurrentLocationGUID FROM CV3ClientVisit where ClientGUID = " || thisdocumentCommunication.ClientGUID}; + WSlocation_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((location_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + + endtry; + catch Exception ex + error_occurred := true; + error_message := "{{+R}}Common Data:{{-R}}\n" || + ex.Message || "\n\n"; + + if ( client_visit_obj is NOT NULL ) then + void:= call client_visit_obj.Dispose; + client_visit_obj:= null; + endif; + + if ( WSRequestedBy_obj is NOT NULL ) then + void:= call WSRequestedBy_obj.Dispose; + WSRequestedBy_obj:= null; + endif; + + if ( WSlocation_obj is NOT NULL ) then + void:= call WSlocation_obj.Dispose; + WSlocation_obj:= null; + endif; + + Endcatch; + ENDIF; + + + if (client_visit_obj is not null) then + try + + Catalog_Item_Name := "Pharmacy Consult - Discharge Prescription Service"; + order_Creation_Reason := "Order Created From MLM"; + + // get OrderCatalogMasterItem ObjectsPlus object + diagnostic_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with Catalog_Item_Name; + DiagnosticOrder_obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder + with + client_visit_obj, // ClientVisit ObjectsPlus object + diagnostic_catalog_item, // OrderCatalogMasterItem ObjectsPlus object + order_Creation_Reason, // CreateReason + wsRequestedBy_obj, // RequestedBy ObjectsPlus object + wsRequestedBySource, // string RequestedBySource (must be in dictionary) + wsSessionType, // string SessionType + wsSessionReason, // string SessionReason + wslocation_obj, // Location ReleaseLocGrpID + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; // AvailabilityOverride + + + Field0 := call DiagnosticOrder_obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with "PRX_OutptConsultIndicator",( "Possible Discharge Prescription Patient" AS {{{SINGLE-QUOTE}}}System.String{{{SINGLE-QUOTE}}}); Field1 := call DiagnosticOrder_obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with "PRX_Outpt_RxBIN",(Comm_RxBIN AS {{{SINGLE-QUOTE}}}System.String{{{SINGLE-QUOTE}}}); + Field2 := call DiagnosticOrder_obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with "PRX_Outpt_RxInsurer",( Comm_RxInsurer AS {{{SINGLE-QUOTE}}}System.String{{{SINGLE-QUOTE}}}); + Field3 := call DiagnosticOrder_obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with "PRX_Outpt_RxGROUP",( Comm_RxGROUP AS {{{SINGLE-QUOTE}}}System.String{{{SINGLE-QUOTE}}}); + Field4 := call DiagnosticOrder_obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with "PRX_Outpt_RxInsName",( Comm_RxInsName AS {{{SINGLE-QUOTE}}}System.String{{{SINGLE-QUOTE}}}); + Field5 := call DiagnosticOrder_obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with "PRX_Outpt_RxMemberID",( Comm_RxMemberID AS {{{SINGLE-QUOTE}}}System.String{{{SINGLE-QUOTE}}}); + Field6 := call DiagnosticOrder_obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with "PRX_Outpt_SpecialInstruction",( SuggestedVal AS {{{SINGLE-QUOTE}}}System.String{{{SINGLE-QUOTE}}}); + + void := call DiagnosticOrder_obj.save; ///To Save The Order To SCM + + + endtry; + catch Exception ex + + error_occurred := true; + error_message := error_message || "{{+R}}New general order:{{-R}}\n" || + ex.Message || "\n\n"; + + if ( Catalog_Item_Name is NOT NULL ) then + void:= call Catalog_Item_Name.Dispose; + Catalog_Item_Name:= null; + endif; + + if ( DiagnosticOrder_obj is NOT NULL ) then + void:= call DiagnosticOrder_obj.Dispose; + DiagnosticOrder_obj:= null; + endif; + + endcatch; + ENDIF; + + + //==================================================================================================== + // End Order + + + Endif; + Endif; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_CARE_TRANSITIONS_POST_DISCHARGE_FOLLOWUP.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CARE_TRANSITIONS_POST_DISCHARGE_FOLLOWUP.mlm new file mode 100644 index 0000000..a25fce9 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CARE_TRANSITIONS_POST_DISCHARGE_FOLLOWUP.mlm @@ -0,0 +1,500 @@ +maintenance: + + title: DOC_FUNC_CARE_TRANSITIONS_POST_DISCHARGE_FOLLOWUP;; + mlmname: DOC_FUNC_CARE_TRANSITIONS_POST_DISCHARGE_FOLLOWUP;; + arden: version 6.1;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Juliet Law;; + specialist: Dean Miklavic;; + date: 2014-12-08;; + validation: testing;; + +library: + purpose: + ;; + explanation: + + Change history + + 12.08.2014 JML CSR 32423: Create date. + 01.27.2015 JML Moved to Production. + 03.02.2015 JML WO# 1648240: Moved update to production based on issue with multiple post discharge documents existing on patient account. + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // Receive arguments from the structured note + (this_documentCommunication) := argument; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + //Include MLM + str_parse := MLM {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; + + //Include Called MLM to setup CDS objects + set_cds_vars := MLM {{{SINGLE-QUOTE}}}Called_RPM_DOM_Get_Definition_MLM{{{SINGLE-QUOTE}}}; + + //Document Types + STRUCTUREDNOTE := "StructuredNote"; + + //Event Types + DOCUMENTCLOSING := "DocumentClosing"; + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTOPENING := "DocumentOpening"; + + //Setting debugFlag to True will allow popup dialogs containing debug information to appear + debugFlag := false; + + //Initialize CDS objects via MLM call + (this_documentCommunication, client_guid, client_visit_guid, client_chart_guid, user_guid, + document_type, document_name, event_type, configuration_guid, this_currentObj, CancelEventFlag, + this_structuredNoteDoc, authored_date_time, authored_by_guid, client_document_guid, document_date_time, + isNewFlag, isIncompleteFlag, isResultsPendingFlag, isPriorityFlag, this_parameters, + this_chartedObservationsList, this_parameters_display_name, current_parameter, current_parameter_name, + current_parameter_guid, current_parameter_DataType, selectedItems, selectedItems_value, current_value, + diagnosticMessage, displayMessageFlag, CoSigner1, CoSigner2, DocumentTopic) := CALL set_cds_vars WITH + (this_documentCommunication); + + using "AddFollowupPhysicianSN"; + using namespace "AddNewProviderSN"; + test := new net_object {{{SINGLE-QUOTE}}}AddNewProviderSN.AddFollowupPhysicianForm{{{SINGLE-QUOTE}}}; + + //Set up debugging information to be captured + messageText := ""; + if (debugFlag = true) then + messageText := "Debug Information:\n\n"; + messageText := messageText || " DOC_FUNC_CARE_TRANSITIONS_POST_DISCHARGE_FOLLOWUP mlm called.\n\n"; + endif; + + //Local Variables + theDocumentName := "Care Transitions Post Discharge Follow Up"; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + NumericValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + if ( event_type = DOCUMENTOPENING AND document_name = theDocumentName ) then + + //Get the patient{{{SINGLE-QUOTE}}}s last inpatient / obs discharge datetime + last_IPOB_discharge_date := read last {"SELECT Top 1 cv.DischargeDtm" + || " FROM CV3ClientVisit cv WITH (NOLOCK)" + || " WHERE cv.ClientGUID = " || Sql(client_guid) + || " AND cv.VisitStatus = {{{SINGLE-QUOTE}}}DSC{{{SINGLE-QUOTE}}}" + || " AND cv.TypeCode IN ({{{SINGLE-QUOTE}}}Inpatient{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Observation{{{SINGLE-QUOTE}}})" + || " ORDER BY cv.DischargeDtm DESC"}; + + last_IPOB_care_inpat_doc := read last {"SELECT TOP 1 cd.GUID" + || " FROM CV3ClientDocument cd WITH (NOLOCK) JOIN CV3ClientVisit cv WITH (NOLOCK)" + || " ON cd.CLIENTGUID = cv.CLIENTGUID" + || " AND cd.CLIENTVISITGUID = cv.GUID" + || " WHERE cd.CLIENTGUID = " || Sql(client_guid) + || " AND cd.DocumentName = {{{SINGLE-QUOTE}}}Care Transitions Inpatient Assessment{{{SINGLE-QUOTE}}}" + || " AND cv.DISCHARGEDTM = " || Sql(last_IPOB_discharge_date) + || " ORDER BY cd.AuthoredDtm DESC"}; + + last_IPOB_care_outpat_doc := read last {"SELECT TOP 1 cd.GUID" + || " FROM CV3ClientDocument cd WITH (NOLOCK) JOIN CV3ClientVisit cv WITH (NOLOCK)" + || " ON cd.CLIENTGUID = cv.CLIENTGUID" + || " AND cd.CLIENTVISITGUID = cv.GUID" + || " WHERE cd.CLIENTGUID = " || Sql(client_guid) + || " AND cd.DocumentName = {{{SINGLE-QUOTE}}}Care Transitions Post Discharge Follow Up{{{SINGLE-QUOTE}}}" + || " AND cv.DISCHARGEDTM = " || Sql(last_IPOB_discharge_date) + || " ORDER BY cd.AuthoredDtm DESC"}; + + //Check to see if an outpatient care doc exists + if ( exists last_IPOB_care_outpat_doc ) then + + //Retrieve Prior Call Made observation + priorCallParameterName := "SCH_Quality_Prior_Call_Made"; + priorCallParameter := first of ( this_parameters WHERE this_parameters.Name = priorCallParameterName ); + + //Retrieve information from last Post discharge Assessment document, if exists + if ( exists priorCallParameter ) then + + (last_call_date, + authored_by) := read last {"SELECT o.ValueText, cp.DisplayName" + || " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3ClientDocumentCur cd WITH (NOLOCK)" + || " ON cv.GUID = cd.ClientVisitGUID" + || " AND cv.ClientGUID = cd.ClientGUID" + || " AND cv.ChartGUID = cd.ChartGUID" + || " JOIN CV3ClientDocDetailCur cdd WITH (NOLOCK)" + || " ON cd.GUID = cdd.ClientDocumentGUID" + || " AND cd.ClientGUID = cdd.ClientGUID" + || " JOIN CV3ObservationDocumentCur od WITH (NOLOCK)" + || " ON cdd.ClientDocumentGUID = od.OwnerGUID" + || " JOIN CV3ObsCatalogMasterItem ocmi WITH (NOLOCK)" + || " ON od.ObsMasterItemGUID = ocmi.GUID" + || " JOIN CV3ObservationCur o WITH (NOLOCK)" + || " ON od.ObservationGUID = o.GUID" + || " JOIN CV3ObsCatalogItem oci WITH (NOLOCK)" + || " ON o.ObsItemGUID = oci.GUID" + || " JOIN CV3CareProvider cp WITH (NOLOCK)" + || " ON cd.AuthoredProviderGUID = cp.GUID" + || " WHERE cv.ClientGUID = " || Sql(client_guid) + || " AND cv.DischargeDtm = " || Sql(last_IPOB_discharge_date) + || " AND cd.GUID = " || Sql(last_IPOB_care_outpat_doc) + || " AND cdd.Active = 1" + || " AND od.Active = 1" + || " AND oci.Name = {{{SINGLE-QUOTE}}}SCH_Quality_DC_FU_Date{{{SINGLE-QUOTE}}}"}; + + patient_reached := read last {"SELECT fsl.Value" + || " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3ClientDocument cd WITH (NOLOCK)" + || " ON cv.GUID = cd.ClientVisitGUID" + || " AND cv.ClientGUID = cd.ClientGUID" + || " AND cv.ChartGUID = cd.ChartGUID" + || " JOIN CV3ClientDocDetail cdd WITH (NOLOCK)" + || " ON cd.GUID = cdd.ClientDocumentGUID" + || " AND cd.ClientGUID = cdd.ClientGUID" + || " JOIN CV3ObservationDocument od WITH (NOLOCK)" + || " ON cdd.ClientDocumentGUID = od.OwnerGUID" + || " LEFT JOIN SCMObsFsListValues fsl WITH (NOLOCK)" + || " ON od.ObservationDocumentGUID = fsl.ParentGUID" + || " AND cdd.ClientGUID = fsl.ClientGUID" + || " JOIN CV3ObsCatalogMasterItem ocmi WITH (NOLOCK)" + || " ON od.ObsMasterItemGUID = ocmi.GUID" + || " JOIN CV3Observation o WITH (NOLOCK)" + || " ON od.ObservationGUID = o.GUID" + || " JOIN CV3ObsCatalogItem oci WITH (NOLOCK)" + || " ON o.ObsItemGUID = oci.GUID" + || " WHERE cv.ClientGUID = " || Sql(client_guid) + || " AND cv.DischargeDtm = " || Sql(last_IPOB_discharge_date) + || " AND cd.GUID = " || Sql(last_IPOB_care_outpat_doc) + || " AND cdd.Active = 1" + || " AND od.Active = 1" + || " AND oci.Name = {{{SINGLE-QUOTE}}}SCH_QUALITY_PATIENT_REACHED{{{SINGLE-QUOTE}}}"}; + + //Format text string + priorCallString := last_call_date || ", " || authored_by || ", Patient Reached: " || patient_reached; + + //Setup object to write to observation + this_currentPriorCallObs := NEW ObservationType; + this_currentPriorCallObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID; + this_currentPriorCallObs.ParameterGUID := priorCallParameter.ParameterGUID; + this_currentPriorCallObs.DataType := "FreeTextValue"; + this_currentPriorCallObs.ValueObj := NEW FreeTextValueType; + this_currentPriorCallObs.ValueObj.Value := priorCallString; + + this_structuredNoteDoc.ChartedObservationsList := ( this_structuredNoteDoc.ChartedObservationsList, this_currentPriorCallObs ); + + endif; //End priorCallParameter Exists + endif; //End IF oupatient document exists + + //Retrieve Today{{{SINGLE-QUOTE}}}s Call Date observation + callDateParameterName := "SCH_Quality_DC_FU_Date"; + callDateParameter := first of ( this_parameters WHERE this_parameters.Name = callDateParameterName ); + + if ( exists callDateParameter ) then + //Set today{{{SINGLE-QUOTE}}}s date as value in observation + this_currentCallDateObs := NEW ObservationType; + this_currentCallDateObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID; + this_currentCallDateObs.ParameterGUID := callDateParameter.ParameterGUID; + this_currentCallDateObs.DataType := "DateValue"; + this_currentCallDateObs.ValueObj := NEW DateValueType; + this_currentCallDateObs.ValueObj.Value := document_date_time; + + this_structuredNoteDoc.ChartedObservationsList := ( this_structuredNoteDoc.ChartedObservationsList, this_currentCallDateObs ); + + endif; //End callDateParameter Exists + + //Retrieve DME Received observation + dmeParameterName := "SCH_Quality_DME_Recvd"; + dmeParameter := first of ( this_parameters WHERE this_parameters.Name = dmeParameterName ); + + if ( exists dmeParameter ) then + //Retrieve most recent Medical Equipment Order + (orderGuid, + orderSummary) := read {"SELECT o.GUID, o.SummaryLine" + || " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3Order o WITH (NOLOCK)" + || " ON cv.GUID = o.ClientVisitGUID" + || " AND cv.ClientGUID = o.ClientGUID" + || " AND cv.ChartGUID = o.ChartGUID" + || " WHERE cv.ClientGUID = " || Sql(client_guid) + || " AND o.NAME = {{{SINGLE-QUOTE}}}Medical Equipment{{{SINGLE-QUOTE}}}" + || " AND cv.TypeCode IN ({{{SINGLE-QUOTE}}}Inpatient{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Observation{{{SINGLE-QUOTE}}})" + || " AND cv.DischargeDtm = " || Sql(last_IPOB_discharge_date) + || " AND ((o.OrderStatusLevelNum > 15" + || " AND o.OrderStatusLevelNum NOT IN ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}}))" + || " OR o.OrderStatusCode = {{{SINGLE-QUOTE}}}HOLD{{{SINGLE-QUOTE}}})" + || " ORDER BY o.RequestedDtm DESC"}; + + + if ( exists orderGuid ) then + preselectValue := "Yes"; + + if ( count orderGuid = 1 ) then + if ( last of ( orderSummary ) IS NULL ) then + parameterValue := ""; + else + parameterValue := last of ( orderSummary ); + endif; + + parameterValue := Trim(parameterValue); + else + if ( first of ( orderSummary ) IS NULL ) then + parameterValue := ""; + else + parameterValue := first of ( Trim(orderSummary) ) || "\n\n"; + endif; + + if ( last of (orderSummary) IS NULL ) then + parameterValue := parameterValue || ""; + else + parameterValue := parameterValue || last of ( Trim(orderSummary) ); + endif; + endif; + else + preSelectValue := "No"; + endif; + + //Setup the object to write to the observation + this_currentMedEquipObs := NEW ObservationType; + this_currentMedEquipObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID; + this_currentMedEquipObs.ParameterGUID := dmeParameter.ParameterGUID; + this_currentMedEquipObs.DataType := "ListValue"; + this_currentMedEquipObs.ValueObj := NEW ListValueType; + this_currentMedEquipObs.ValueObj.ListGUID := dmeParameter.ConfigurationObj.ListGUID; + + listItems := (); + for item IN dmeParameter.ConfigurationObj.ListItemsList do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if ( selectedItem.Value = "Yes" AND preselectValue = "Yes" ) then + selectedItem.IsSelected := true; + endif; + if ( selectedItem.Value = "No" AND preselectValue = "Yes" ) then + selectedItem.IsSelected := false; + endif; + if ( selectedItem.Value = "No" AND preselectValue = "No" ) then + selectedItem.IsSelected := true; + endif; + if ( selectedItem.Value = "Yes" AND preselectValue = "No" ) then + selectedItem.IsSelected := false; + endif; + if ( selectedItem.Value = "Partial" AND preselectValue = "Yes" ) then + selectedItem.Value := false; + endif; + if ( selectedItem.Value = "Partial" AND preselectValue = "No" ) then + selectedItem.Value := false; + endif; + + listItems := ( listItems, selectedItem ); + + enddo; + + if ( preselectValue = "Yes" ) then + //dmeConfiguration := dmeParameter.ConfigurationObj; + //if ( dmeConfiguration.AllowsSuggestedText = true ) then + // this_currentMedEquipObs.ValueObj.SuggestedTextValue := orderSummary; + //endif; + + //Retrieve DME Orders textbox parameter + dmeOrdersParameterName := "SCH_Quality_DME_Orders"; + dmeOrdersParameter := first of ( this_parameters WHERE this_parameters.Name = dmeOrdersParameterName ); + + if ( exists dmeOrdersParameter ) then + this_currentDMEObj := NEW ObservationType; + this_currentDMEObj.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID; + this_currentDMEObj.ParameterGUID := dmeOrdersParameter.ParameterGUID; + this_currentDMEObj.DataType := "FreeTextValue"; + this_currentDMEObj.ValueObj := NEW FreeTextValueType; + this_currentDMEObj.ValueObj.Value := parameterValue; + + this_structuredNoteDoc.ChartedObservationsList := ( this_structuredNoteDoc.ChartedObservationsList, this_currentDMEObj ); + endif; + endif; + + this_currentMedEquipObs.ValueObj.ListItemsList := listItems; + this_structuredNoteDoc.ChartedObservationsList := ( this_structuredNoteDoc.ChartedObservationsList, this_currentMedEquipObs ); + endif; //End dmeParameter Exists + + //Retrieve Quality Programs Suggested observation + progsParameterName := "SCH_Quality_Programs_SuggestedDC"; + progsParameter := first of ( this_parameters WHERE this_parameters.Name = progsParameterName ); + + if ( exists progsParameter ) then + //Retrieve suggested programs from last Care Transitions Inpatient Assessment document + (programNames) := read {"SELECT fsl.value" + || " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3ClientDocument cd WITH (NOLOCK)" + || " ON cv.GUID = cd.ClientVisitGUID" + || " AND cv.ClientGUID = cd.ClientGUID" + || " AND cv.ChartGUID = cd.ChartGUID" + || " JOIN CV3ClientDocDetail cdd WITH (NOLOCK)" + || " ON cd.GUID = cdd.ClientDocumentGUID" + || " AND cd.ClientGUID = cdd.ClientGUID" + || " JOIN CV3ObservationDocument od WITH (NOLOCK)" + || " ON cdd.ClientDocumentGUID = od.OwnerGUID" + || " LEFT JOIN SCMObsFsListValues fsl WITH (NOLOCK)" + || " ON od.ObservationDocumentGUID = fsl.ParentGUID" + || " AND cdd.ClientGUID = fsl.ClientGUID" + || " JOIN CV3ObsCatalogMasterItem ocmi WITH (NOLOCK)" + || " ON od.ObsMasterItemGUID = ocmi.GUID" + || " JOIN CV3Observation o WITH (NOLOCK)" + || " ON od.ObservationGUID = o.GUID" + || " JOIN CV3ObsCatalogItem oci WITH (NOLOCK)" + || " ON o.ObsItemGUID = oci.GUID" + || " WHERE cv.ClientGUID = " || Sql(client_guid) + || " AND cv.DischargeDtm = " || Sql(last_IPOB_discharge_date) + || " AND cd.GUID = " || Sql(last_IPOB_care_inpat_doc) + || " AND cdd.Active = 1" + || " AND od.Active = 1" + || " AND oci.Name = {{{SINGLE-QUOTE}}}SCH_Quality_Programs_Suggested{{{SINGLE-QUOTE}}}"}; + + if ( exists programNames ) then + //Setup object to write to observation + this_currentProgObs := NEW ObservationType; + this_currentProgObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID; + this_currentProgObs.ParameterGUID := progsParameter.ParameterGUID; + this_currentProgObs.DataType := "ListValue"; + this_currentProgObs.ValueObj := NEW ListValueType; + this_currentProgObs.ValueObj.ListGUID := progsParameter.ConfigurationObj.ListGUID; + + listItems := (); + for item IN progsParameter.ConfigurationObj.ListItemsList do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if ( selectedItem.Value IN programNames ) then + selectedItem.IsSelected := true; + endif; + if ( selectedItem.Value NOT IN programNames ) then + selectedItem.IsSelected := false; + endif; + + listItems := ( listItems, selectedItem ); + enddo; + + this_currentProgObs.ValueObj.ListItemsList := listItems; + this_structuredNoteDoc.ChartedObservationsList := ( this_structuredNoteDoc.ChartedObservationsList, this_currentProgObs ); + endif; + endif; //End progsParameter Exists + + endif; + ;; + evoke: + ;; + logic: + + if ( event_type = CHARTOBSERVATION ) THEN + + + //1 -- OBJ+ to populate followup physician + if ( current_parameter.Name = "SCH_Quality_MD_Select1" ) then + if ( current_value = "Physician selector" ) then + test2 := CALL test.ShowDialog; + followup1_return_value := test.Text; + elseif ( current_value = "Clear Followup" ) then + followup1_return_value := ""; + endif; + endif; + //2 -- OBJ+ to populate followup physician + if ( current_parameter.Name = "SCH_Quality_MD_Select2" ) then + if ( current_value = "Physician selector" ) then + test2 := CALL test.ShowDialog; + followup2_return_value := test.Text; + elseif ( current_value = "Clear Followup" ) then + followup2_return_value := ""; + endif; + endif; + //3 -- OBJ+ to populate followup physician + if ( current_parameter.Name = "SCH_Quality_MD_Select3" ) then + if ( current_value = "Physician selector" ) then + test2 := CALL test.ShowDialog; + followup3_return_value := test.Text; + elseif ( current_value = "Clear Followup" ) then + followup3_return_value := ""; + endif; + endif; + //4 -- OBJ+ to populate followup physician + if ( current_parameter.Name = "SCH_Quality_MD_Select4" ) then + if ( current_value = "Physician selector" ) then + test2 := CALL test.ShowDialog; + followup4_return_value := test.Text; + elseif ( current_value = "Clear Followup" ) then + followup4_return_value := ""; + endif; + endif; + + //1 -- Populate first appointment + followupApptParameterName_1 := "SCH_Quality_FU_Appt1"; + followupApptParameter_1 := first of ( this_parameters WHERE this_parameters.Name = followupApptParameterName_1 ); + + if ( exists followupApptParameter_1 ) then + this_currentApptObs := NEW ObservationType; + this_currentApptObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID; + this_currentApptObs.ParameterGUID := followupApptParameter_1.ParameterGUID; + this_currentApptObs.DataType := "FreeTextValue"; + this_currentApptObs.ValueObj := NEW FreeTextValueType; + this_currentApptObs.ValueObj.Value := followup1_return_value; + + this_structuredNoteDoc.ChartedObservationsList := ( this_structuredNoteDoc.ChartedObservationsList, this_currentApptObs ); + endif; + + //2 -- Populate second appointment + followupApptParameterName_2 := "SCH_Quality_FU_Appt2"; + followupApptParameter_2 := first of ( this_parameters WHERE this_parameters.Name = followupApptParameterName_2 ); + + if ( exists followupApptParameter_2 ) then + this_currentApptObs := NEW ObservationType; + this_currentApptObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID; + this_currentApptObs.ParameterGUID := followupApptParameter_2.ParameterGUID; + this_currentApptObs.DataType := "FreeTextValue"; + this_currentApptObs.ValueObj := NEW FreeTextValueType; + this_currentApptObs.ValueObj.Value := followup2_return_value; + + this_structuredNoteDoc.ChartedObservationsList := ( this_structuredNoteDoc.ChartedObservationsList, this_currentApptObs ); + endif; + + //3 -- Populate third appointment + followupApptParameterName_3 := "SCH_Quality_FU_Appt3"; + followupApptParameter_3 := first of ( this_parameters WHERE this_parameters.Name = followupApptParameterName_3 ); + + if ( exists followupApptParameter_3 ) then + this_currentApptObs := NEW ObservationType; + this_currentApptObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID; + this_currentApptObs.ParameterGUID := followupApptParameter_3.ParameterGUID; + this_currentApptObs.DataType := "FreeTextValue"; + this_currentApptObs.ValueObj := NEW FreeTextValueType; + this_currentApptObs.ValueObj.Value := followup3_return_value; + + this_structuredNoteDoc.ChartedObservationsList := ( this_structuredNoteDoc.ChartedObservationsList, this_currentApptObs ); + endif; + + //4 -- Populate fourth appointment + followupApptParameterName_4 := "SCH_Quality_FU_Appt4"; + followupApptParameter_4 := first of ( this_parameters WHERE this_parameters.Name = followupApptParameterName_4 ); + + if ( exists followupApptParameter_4 ) then + this_currentApptObs := NEW ObservationType; + this_currentApptObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID; + this_currentApptObs.ParameterGUID := followupApptParameter_4.ParameterGUID; + this_currentApptObs.DataType := "FreeTextValue"; + this_currentApptObs.ValueObj := NEW FreeTextValueType; + this_currentApptObs.ValueObj.Value := followup4_return_value; + + this_structuredNoteDoc.ChartedObservationsList := ( this_structuredNoteDoc.ChartedObservationsList, this_currentApptObs ); + endif; + + ENDIF; + + conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_CCDA_CREATE_AND_TRANSPORT.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CCDA_CREATE_AND_TRANSPORT.mlm new file mode 100644 index 0000000..1995726 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CCDA_CREATE_AND_TRANSPORT.mlm @@ -0,0 +1,111 @@ +maintenance: + + title: DOC_FUNC_CCDA_CREATE_AND_TRANSPORT;; + mlmname: DOC_FUNC_CCDA_CREATE_AND_TRANSPORT;; + arden: version 2.5;; + version: 5.50;; + institution: Allscripts;; + author: Renish Bhimani;; + specialist: ;; + date: 2014-05-21;; + validation: testing;; + + ScheduledFlags: LongRunning;; + + +library: + purpose: print CCD-A document report from MLM + + ;; + explanation: The MLM is called from a Document and if a Print Button is selected, it calls MLM "SCH_FUNC_CCDA_Print" + which generates a CCDA document + + Change history + + 06.25.2014 DW CSR# 31688 - MU2 + 07.08.2014 DW CSR# 31688 - MU2 Suppress print for behavioral health patients + 08.18.2015 DW CSR# 26006 - Transport CCDA to CCHIE via XDS protocol (add a dummy TransportType parmaeter to the MLM call) + 12.11.2018 DW CSR# 37522 - Optimize scheduled MLMs. Added Long Running parameter + 09.20.2019 DW CSR# 35638 - MU3 - Transmit to physician direct address (redisign....pass direct address to create and transport MLM instead of discharge location) + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + + trig_event_enter := event {ClientDocumentEnter User ClientDocument: where documentname in ("Discharge Instructions (Post Hospital Care Orders)")}; + trig_event_modify:= event {ClientDocumentModify User ClientDocument: where documentname in ("Discharge Instructions (Post Hospital Care Orders)")}; + + (VisitGUID, ChartGUID, ClientGUID) := read last {ClientDocument: ClientVisitGUID, ChartGUID, ClientGUID REFERENCING EvokingObject}; + + PrintButtonSelected := read first + { + " select top 1 fsl.value " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = " || sql(ClientGUID) || " and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " left join SCMObsFSListValues fsl(nolock) ON (fsl.ParentGUID = od.ObservationDocumentGUID AND fsl.ClientGUID = " || sql(ClientGUID) || " ) " + || " where cd.clientguid = " || sql(ClientGUID) || " and cd.ChartGUID = " || SQL(ChartGuid) || " and cd.ClientVisitGUID= " || SQL(VisitGuid) || " " + || " and cd.iscanceled = 0 " + || " and cd.documentname like {{{SINGLE-QUOTE}}}%Post Hospital Care Orders%{{{SINGLE-QUOTE}}} " + || " and ocmi.name in ({{{SINGLE-QUOTE}}}CXD Transition Care Print{{{SINGLE-QUOTE}}}) " + || " and fsl.value is not null " + || " order by cd.touchedwhen desc " + }; + + + PsychPatient := read + { + " Select currentlocation from cv3clientvisit with (nolock) " + || " Where ClientGUID = " || sql(ClientGUID) || " AND ChartGUID = " || SQL(ChartGuid) + || " AND GUID = " || SQL(VisitGuid) || " and currentlocation like {{{SINGLE-QUOTE}}}Psy%{{{SINGLE-QUOTE}}} " + }; + + + if PrintButtonSelected is not null + and not exist PsychPatient + + then + SCMEnvironment := "NA"; + DirectAddress := "NA"; + Transport := FALSE; + TransportType := "NA"; + CCDAReport := "CCDA Summary of Care"; + + CCD_MLM := MLM {{{SINGLE-QUOTE}}}SCH_FUNC_CCDA_CREATE_AND_TRANSPORT{{{SINGLE-QUOTE}}}; + void := call CCD_MLM with clientGuid,chartguid,visitguid,CCDAReport,Transport,SCMEnvironment,DirectAddress,TransportType; + endif; + + // Diagnostic Alert - Can be enabled if needed + send_alert := "DoNotSend"; + alert_dest := destination { Alert: warning, "Informational", high, chart, "Informational", 15042, send_alert, "No Override Allowed" }; + + ;; + priority: 50 + ;; + evoke: + + 15 seconds after time of trig_event_enter; + 15 seconds after time of trig_event_modify; + ;; + logic: + conclude true; + ;; + action: + + // Diagnostic Alert - Can be enabled if needed + write " Messages " || " CALL the CREATE MLM - " || NOW || " " || PrintButtonSelected + || " " || SCMEnvironment || " " || DischargeLocation + || " " || Transport || " " || CCDAReport + at alert_dest; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_CCDA_DATA.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CCDA_DATA.mlm new file mode 100644 index 0000000..8db4234 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CCDA_DATA.mlm @@ -0,0 +1,481 @@ +maintenance: + + title: DOC_FUNC_CCDA_DATA;; + mlmname: DOC_FUNC_CCDA_DATA;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Don Warnick;; + specialist: ;; + date: 2014-04-30;; + validation: testing;; + +library: + purpose: + ;; + explanation: This MLM manages will popultate the required fields for the CCDA + + + Change history + + 04.30.2014 DW CSR# 31688 - MU2 + 07.08.2014 DW CSR# 31688 - MU2 (1)Print Discharge Instructions (2)Fill text fields upon close rather than open + 07.29.2014 DW HD# 167119 - Only the first 2 OT (and PT) observations of the latest set were being pulled + 08.20.2014 DW HD# 168587 - Needed to increase the size of the "DATA" field of the OT and PT temp SQL tables. A user exceeded 200 characters. Changed it to 1000. + 05.10.2015 STH CRS#: 32070 - Auto print Patient DC instructions and generate DC summary ONLY once discharge order reconiciliation is completed. Also alert + users if order reconciliation is incomplete on entrying into the document. + 08.19.2015 DW CSR# 33555 - 15.1 - updated formatting of "Followup" section + 10.26.2015 STH Support case 1917862 - issue with clinic visits requing order rec completion + ;; + + keywords: + ;; +knowledge: + type: data-driven;; + data: + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + PatCurLocation := read last {"select currentlocation from cv3clientvisit with (nolock)" + || " where clientguid = " || sql(clientguid) + || " and chartguid = " || sql(chartGuid) + || " and guid = " || sql(visitGuid) }; + + (VisitType) := read {"select top 1 typecode from cv3clientvisit with (nolock) " + || " where clientguid = " || sql(clientGuid) + || " and chartguid = " || sql(chartGuid) + || " and guid = " || sql(visitGuid)}; + + //BEGIN - [STH] CSR#: 32070 + if ((PatCurLocation matches pattern "infus%") or (trim(VisitType[1]) is not in ("Inpatient","Observation"))) then + dc_orderrec_GUID := 0; + else + dc_orderrec_GUID := read last {"select guid from CV3OrderReconcile with (nolock) " + || " where clientguid = " || sql(ClientGuid) + || " and chartguid = " || sql(ChartGuid) + || " and ClientVisitGUID = " || sql(VisitGuid) + || " and reconciletypecode = {{{SINGLE-QUOTE}}}discharge{{{SINGLE-QUOTE}}} " + || " and ReconcileStatusType = 2 "}; + endif; + //END - [STH] CSR#: 32070 + + + +// DOCUMENT OPENING SECTION + + +IF thisdocumentCommunication.EventType = "DocumentOpening" + + then + + //BEGIN [STH] - CSR#: 32070 + if dc_orderrec_guid is null or dc_orderrec_guid = "" then + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "Discharge Order Reconciliation is INCOMPLETE. You cannot print the patient’s Discharge Instructions until the Discharge Order Reconciliation is completed. Do you want to launch Order Reconciliation now?" + ,"Discharge Order Reconciliation Incomplete","YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}},"Button1" as {{{SINGLE-QUOTE}}}MessageBoxDefaultButton{{{SINGLE-QUOTE}}}; + + resulttext := dialogResult as string; + + if resulttext = "Yes" then + (thisDocumentCommunication) := argument; + OpenMedRec := MLM {{{SINGLE-QUOTE}}}DOC_Call_Med_Rec{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL OpenMedRec WITH thisDocumentCommunication; + + endif; + endif; + //END - [STH] - CSR#: 32070 + +// Desellect the "Print Document" button + + theParameter := first of (thisparameters where thisparameters.Name = "CXD Transition Care Print"); + theObservation:= first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + + this_parametername := first of (thisParameters where thisParameters.Name = "CXD Transition Care Print"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := false; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + // Set the HIS only "dummy" button to true to activate the SAVE button + + theParameter := first of (thisparameters where thisparameters.Name = "CXD Testing MLM Only"); + theObservation:= first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + + this_parametername := first of (thisParameters where thisParameters.Name = "CXD Testing MLM Only"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := true; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + +endif; // EventType = "DocumentOpening" + + + +// DOCUMENT CLOSING SECTION + + + +IF thisdocumentCommunication.EventType = "DocumentClosing" + + +then + + +// GATHER DATA + + +// Occupational Therapy Data (only the latest charted from SN or FS is to be displayed) + +(OTGoalstData) := read +{ + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), touchedwhen datetime, data varchar(1000), latestdate datetime) " +|| " SET CONCAT_NULL_YIELDS_NULL off " +|| " INSERT INTO #tmp_aaa (touchedwhen,data) " +|| " select cd.entered , o.ValueText + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + fsl.value " +|| " from CV3ClientDocument cd with (nolock) " +|| " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = " || ClientGuid || " and cdd.active = 1) " +|| " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " +|| " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " +|| " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " +|| " left join SCMObsFSListValues fsl(nolock) ON (fsl.ParentGUID = od.ObservationDocumentGUID AND fsl.ClientGUID = " || ClientGuid || " ) " +|| " where cd.clientguid = " || ClientGuid || " and cd.ChartGUID = " || ChartGuid || " and cd.ClientVisitGUID= " || VisitGuid || " " +|| " and cd.iscanceled = 0 " +|| " and cd.documentname in ({{{SINGLE-QUOTE}}}occupational Therapy Initial Evaluation{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}4. Adult Goal/Outcome Evaluation{{{SINGLE-QUOTE}}}) " +|| " and ocmi.name in ({{{SINGLE-QUOTE}}}SCHCK_OT disc prog rec{{{SINGLE-QUOTE}}}) " +|| " order by cd.touchedwhen desc " +|| " declare @lastdate datetime " +|| " set @lastdate = (select touchedwhen from #tmp_aaa where id = 1) " +|| " update t1 set t1.latestdate = @lastdate from #tmp_aaa t1 where t1.touchedwhen = @lastdate " +|| " delete from #tmp_aaa where latestdate is null " +|| " select data from #tmp_aaa " +|| " drop table #tmp_aaa " +}; + + + if exists OTGoalstData + then + OTGoalstDataText := "\n OT Discharge Recommendation : " || OTGoalstData; + else + OTGoalstDataText := ""; + endif; + + +// Physical Therapy Data (only the latest charted from SN or FS is to be displayed) + + +(PTGoalstData) := read +{ + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), touchedwhen datetime, data varchar(1000), latestdate datetime) " +|| " SET CONCAT_NULL_YIELDS_NULL off " +|| " INSERT INTO #tmp_aaa (touchedwhen,data) " +|| " select cd.entered , o.ValueText + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + fsl.value " +|| " from CV3ClientDocument cd with (nolock) " +|| " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = " || ClientGuid || " and cdd.active = 1) " +|| " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " +|| " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " +|| " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " +|| " left join SCMObsFSListValues fsl(nolock) ON (fsl.ParentGUID = od.ObservationDocumentGUID AND fsl.ClientGUID = " || ClientGuid || " ) " +|| " where cd.clientguid = " || ClientGuid || " and cd.ChartGUID = " || ChartGuid || " and cd.ClientVisitGUID= " || VisitGuid || " " +|| " and cd.iscanceled = 0 " +|| " and cd.documentname in ({{{SINGLE-QUOTE}}}Physicial Therapy Initial Evaluation{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}4. Adult Goal/Outcome Evaluation{{{SINGLE-QUOTE}}}) " +|| " and ocmi.name in ({{{SINGLE-QUOTE}}}SCHCK_PT disc prog rec{{{SINGLE-QUOTE}}}) " +|| " order by cd.touchedwhen desc " +|| " declare @lastdate datetime " +|| " set @lastdate = (select touchedwhen from #tmp_aaa where id = 1) " +|| " update t1 set t1.latestdate = @lastdate from #tmp_aaa t1 where t1.touchedwhen = @lastdate " +|| " delete from #tmp_aaa where latestdate is null " +|| " select data from #tmp_aaa " +|| " drop table #tmp_aaa " +}; + if exists PTGoalstData + then + PTGoalstDataText := "\n PT Discharge Recommendation : " || PTGoalstData; + else + PTGoalstDataText := ""; + endif; + + + (DischargeOrder) := read last + { + " SET CONCAT_NULL_YIELDS_NULL off select {{{SINGLE-QUOTE}}}\n {{{SINGLE-QUOTE}}} + o.name + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + REPLACE(REPLACE(REPLACE(o.SummaryLine, CHAR(10), {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}}), CHAR(13), {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}}), CHAR(9), {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}}) " +|| " from cv3ordercatalogmasteritem as ocmi with (nolock) " +|| " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid " +|| " and o.ClientGUID = " || ClientGuid || " and o.ChartGUID = " || ChartGuid || " and o.ClientVisitGUID= " || VisitGuid || " " +|| " and (o.name = {{{SINGLE-QUOTE}}}Discharge{{{SINGLE-QUOTE}}})" +|| " and o.OrderStatusLevelNum > 15 and o.OrderStatusLevelNum not in (69, 70) " + }; + + +// Concatenate the 3 values together with nice formatting + + +If exists DischargeOrder + then RehabGoalstDataText:= " " || DischargeOrder; + If exists PTGoalstData + then RehabGoalstDataText := RehabGoalstDataText || " \n ________________ " || PTGoalstDataText; + endif; + If exists OTGoalstData + then RehabGoalstDataText := RehabGoalstDataText || " \n ________________ " || OTGoalstDataText; + endif; + +elseif exists PTGoalstData + then RehabGoalstDataText:= " " || PTGoalstDataText; + If exists OTGoalstData + then RehabGoalstDataText := RehabGoalstDataText || " \n ________________ " || OTGoalstDataText; + endif; + +elseif exists OTGoalstData + then RehabGoalstDataText:= " " || OTGoalstDataText; +else + RehabGoalstDataText:= " "; + +endif; + + + +// Followup Visit and Test Orders + + (FollowupVisitsandTestsList) := read + { + " SET CONCAT_NULL_YIELDS_NULL off select {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + o.name + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + REPLACE(REPLACE(REPLACE(o.SummaryLine, CHAR(10), {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}), CHAR(13), {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}), CHAR(9), {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}) " +|| " from cv3ordercatalogmasteritem as ocmi with (nolock) " +|| " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid " +|| " and o.ClientGUID = " || ClientGuid || " and o.ChartGUID = " || ChartGuid || " and o.ClientVisitGUID= " || VisitGuid || " " +|| " and o.InitialSessionTypeCode = {{{SINGLE-QUOTE}}}Discharge{{{SINGLE-QUOTE}}} " +|| " and (o.name like {{{SINGLE-QUOTE}}}Lab Test%{{{SINGLE-QUOTE}}} or o.name like {{{SINGLE-QUOTE}}}Lab Test - INR%{{{SINGLE-QUOTE}}} or o.name like {{{SINGLE-QUOTE}}}Medical Imaging & Other Tests%{{{SINGLE-QUOTE}}} or o.name = {{{SINGLE-QUOTE}}}Discharge Follow-Up Visits{{{SINGLE-QUOTE}}} ) " +|| " and o.OrderStatusLevelNum > 15 and o.OrderStatusLevelNum not in (69, 70) " + }; + + if exists FollowupVisitsandTestsList + + then + + for i in 1 seqto count FollowupVisitsandTestsList do + if i = 1 + then FollowupVisitsandTestsListText := " \n " || FollowupVisitsandTestsList [i]; + else FollowupVisitsandTestsListText := FollowupVisitsandTestsListText || "\n _____________\n" || FollowupVisitsandTestsList [i]; + endif; + enddo; + + // Check the Patient Education Box + + this_parametername := first of (thisParameters where thisParameters.Name = "CXD Plan of Care Instruction Type"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := true; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + else + + FollowupVisitsandTestsListText := " "; + + endif; + + + + +// Other Orders + + + (OtherOrdersList) := read + { + " SET CONCAT_NULL_YIELDS_NULL off select {{{SINGLE-QUOTE}}}\n{{{SINGLE-QUOTE}}} + o.name + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + REPLACE(REPLACE(REPLACE(o.SummaryLine, CHAR(10), {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}}), CHAR(13), {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}}), CHAR(9), {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}}) " +|| " from cv3ordercatalogmasteritem as ocmi with (nolock) " +|| " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid " +|| " and o.ClientGUID = " || ClientGuid || " and o.ChartGUID = " || ChartGuid || " and o.ClientVisitGUID= " || VisitGuid || " " +|| " and o.InitialSessionTypeCode = {{{SINGLE-QUOTE}}}Discharge{{{SINGLE-QUOTE}}} and o.name <> {{{SINGLE-QUOTE}}}Discharge{{{SINGLE-QUOTE}}} and o.name <> {{{SINGLE-QUOTE}}}Discharge Follow-Up Visits{{{SINGLE-QUOTE}}} " +|| " and o.name not like {{{SINGLE-QUOTE}}}Lab Test%{{{SINGLE-QUOTE}}} and o.name not like {{{SINGLE-QUOTE}}}Lab Test - INR%{{{SINGLE-QUOTE}}} and o.name not like {{{SINGLE-QUOTE}}}Medical Imaging & Other Tests%{{{SINGLE-QUOTE}}} " +|| " and o.typecode <> {{{SINGLE-QUOTE}}}Medication{{{SINGLE-QUOTE}}} " +|| " and o.OrderStatusLevelNum > 15 and o.OrderStatusLevelNum not in (69, 70) " + }; + + if exists OtherOrdersList + + then +// + + // Determine if the Orders have overflowed the first textbox (>2000) + + for i in 1 seqto count OtherOrdersList do + if i = 1 + then OtherOrders:= OtherOrdersList [i]; + else OtherOrders:= OtherOrders || "\n ___________________________" || OtherOrdersList [i]; + endif; + enddo; + + if length OtherOrders <= 1900 + then + OtherOrders1Text := (substring 1900 characters starting at 1 from OtherOrders); + OtherOrders2Text := " "; + else + OtherOrders1Text := (substring 1900 characters starting at 1 from OtherOrders); + OtherOrders2Text := (substring 2000 characters starting at 1901 from OtherOrders); + endif; + + + else + + OtherOrders1Text := " "; + OtherOrders2Text := " "; + endif; + + + + +// POPULATE THE FIELDS WITH THE DATA + + + + // Populate the Rehab Goals field (OT PT Discharge) + + this_parametername := first of (thisParameters where thisParameters.Name = "CXD Plan of Care Goals"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := RehabGoalstDataText; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + // Populate the Followup Visits and Tests field + + this_parametername := first of (thisParameters where thisParameters.Name = "CXD Plan of Care Instructs"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := FollowupVisitsandTestsListText; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + // Populate the Other Orders field + + this_parametername := first of (thisParameters where thisParameters.Name = "CXD Hosp DC Instructions 1"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := OtherOrders1Text; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + // Populate the Other Orders #2 field + + this_parametername := first of (thisParameters where thisParameters.Name = "CXD Hosp DC Instructions 2"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := OtherOrders2Text; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + + // Print the Discharge Instructions if the button is selected + + + theParameter := first of (thisparameters where thisparameters.Name = "CXD Transition Care Print"); + theObservation:= first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Print and Send With Patient") + then PrintDocument := "yes"; + else PrintDocument := "no"; + endif; + + If PrintDocument = "yes" + + then + Report_Print_MLM := mlm {{{SINGLE-QUOTE}}}SCH_FUNC_PRINT{{{SINGLE-QUOTE}}}; + reportname := "Discharge Instructions"; logicalprinter := "Default Report Printer"; physicalprinter:= ""; + print1 := call Report_Print_MLM with(reportname, logicalprinter, physicalprinter); + print2 := call Report_Print_MLM with(reportname, logicalprinter, physicalprinter); + //BEGIN - [STH] CSR#: 32070 + DCSummmary_Print_MLM := mlm {{{SINGLE-QUOTE}}}SCH_FUNC_DCSUMMARY_PRINT{{{SINGLE-QUOTE}}}; + void := CALL DCSummmary_Print_MLM with (clientguid,chartguid,visitguid,"Day of Discharge%",null); + //END - [STH] CSR#: 32070 + endif; // Create a document + + +endif; // Docuement Closing + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_CCDA_PRINT.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CCDA_PRINT.mlm new file mode 100644 index 0000000..69b6dec --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CCDA_PRINT.mlm @@ -0,0 +1,111 @@ +maintenance: + + title: DOC_FUNC_CCDA_PRINT;; + mlmname: DOC_FUNC_CCDA_PRINT;; + arden: version 2.5;; + version: 5.50;; + institution: Allscripts;; + author: Renish Bhimani;; + specialist: ;; + date: 2014-05-21;; + validation: testing;; + +library: + purpose: print CCD-A document report from MLM + + ;; + explanation: The MLM is called from a Document and if a Print Button is selected, it calls MLM "SCH_FUNC_CCDA_Print" + which generates a CCDA document + + Change history + + 06.25.2014 DW CSR# 31688 - MU2 + 07.08.2014 DW CSR# 31688 - MU2 Suppress print for behavioral health patients + 12.11.2018 DW HD#3548079 - Blank prints are sometimes generated. We think it is due to system latency. I changed the delay from 90 to 120 seconds to permit DOC_FUNC_CCDA_CREATE_AND_TRANSPORT to create the CCDA Summary of Care + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + + trig_event_enter := event {ClientDocumentEnter User ClientDocument: where documentname in ("Discharge Instructions (Post Hospital Care Orders)")}; + trig_event_modify := event {ClientDocumentModify User ClientDocument: where documentname in ("Discharge Instructions (Post Hospital Care Orders)")}; + + (VisitGUID, ChartGUID, ClientGUID) := read last {ClientDocument: ClientVisitGUID, ChartGUID, ClientGUID REFERENCING EvokingObject}; + + ClientDocumentName := "CCDA Summary of Care"; + ClientDocumentGUID := read first + { + " Select GUID from CV3ClientDocument with (nolock) WHERE DocumentName = " || SQL(ClientDocumentName) + || " AND ClientGUID = " || sql(ClientGUID) || " AND ChartGUID = " || SQL(ChartGuid) + || " AND ClientVisitGUID = " || SQL(VisitGuid) + || " ORDER BY TouchedWhen DESC" + }; + + PrintButtonSelected := read first + { + " select top 1 fsl.value " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = " || sql(ClientGUID) || " and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " left join SCMObsFSListValues fsl(nolock) ON (fsl.ParentGUID = od.ObservationDocumentGUID AND fsl.ClientGUID = " || sql(ClientGUID) || " ) " + || " where cd.clientguid = " || sql(ClientGUID) || " and cd.ChartGUID = " || SQL(ChartGuid) || " and cd.ClientVisitGUID= " || SQL(VisitGuid) || " " + || " and cd.iscanceled = 0 " + || " and cd.documentname like {{{SINGLE-QUOTE}}}%Post Hospital Care Orders%{{{SINGLE-QUOTE}}} " + || " and ocmi.name in ({{{SINGLE-QUOTE}}}CXD Transition Care Print{{{SINGLE-QUOTE}}}) " + || " and fsl.value is not null " + || " order by cd.touchedwhen desc " + }; + + + PsychPatient := read + { + " Select currentlocation from cv3clientvisit with (nolock) " + || " Where ClientGUID = " || sql(ClientGUID) || " AND ChartGUID = " || SQL(ChartGuid) + || " AND GUID = " || SQL(VisitGuid) || " and currentlocation like {{{SINGLE-QUOTE}}}Psy%{{{SINGLE-QUOTE}}} " + }; + + + if (ClientDocumentGUID <> "" OR ClientDocumentGUID is not null) + and PrintButtonSelected is not null + and not exist PsychPatient + then + + CCD_MLM := MLM {{{SINGLE-QUOTE}}}SCH_FUNC_CCDA_Print{{{SINGLE-QUOTE}}}; + void := call CCD_MLM with ClientGuid,ChartGuid,VisitGuid,ClientDocumentName; + + endif; + + // Diagnostic Alert - Can be enabled if needed + // send_alert := "DoNotSend"; + // alert_dest := destination { Alert: warning, "Informational" , high, chart, "Informational" , 15042, send_alert, "No Override Allowed" }; + + + ;; + priority: 50 + ;; + evoke: + + 120 seconds after time of trig_event_enter; + 120 seconds after time of trig_event_modify; + // trig_event_enter; + // trig_event_modify; + ;; + logic: + conclude true; + ;; + action: + + // Diagnostic Alert - Can be enabled if needed + // write " Messages " || " CALL the PRINT MLM - " || NOW || " " || PrintButtonSelected at alert_dest; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_CCHD_SCREEN.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CCHD_SCREEN.mlm new file mode 100644 index 0000000..9a0ee2c --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CCHD_SCREEN.mlm @@ -0,0 +1,292 @@ +maintenance: + + title: BMI Checking;; + mlmname: DOC_FUNC_CCHD_Screen;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Pam Roberts / Dr. Griffin & Dean Miklavic ;; + specialist: Shawn Head ;; + date: 2012-06-13;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 06.13.2012 - create by STH + 03.18-2013 - CSR #: 31350 - Modified to be "greater than OR equal to >=" instead of just "greaterthan >" + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + + //Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + obsitemcall := (); + obsitemupdate1 := (); + obsitemupdate2 := (); + obsitemcallgrp1 := (); + obsitemcallgrp2 := (); + addobs := false; + addobslistitems := ""; + addobsvalue := ""; + clearhrsold := false; + + + + /*********************************BEGIN EDIT SECTION*****************************************************/ + + + //declare list items that will need read/calculated/updated/edited/ect. + obsitemcallgrp1 := ("SCH_FBC_CHDS_Initial Date Time", + "SCH_FBC_Init_Pulse Ox_Rt Hand", + "SCH_FBC_Second_Pulse Ox_Rt Hand", + "SCH_FBC_Third_Pulse Ox_Rt Hand"); + + obsitemcallgrp2 := ("", + "SCH_FBC_Init_Pulse Ox_Foot", + "SCH_FBC_Second_Pulse Ox_Foot", + "SCH_FBC_Third_Pulse Ox_Foot"); + + obsitemupdate1 := ("SCH_FBC_Hourly Age", + "SCH_FBC_Init_Pulse Ox Diff", + "SCH_FBC_Second_Pulse Ox Diff", + "SCH_FBC_Third_Pulse Ox Diff"); + + obsitemupdate2 := ("", + "SCH_FBC_CHDS_Init_Pass Fail", + "SCH_FBC_CHDS_Second_Pass Fail", + "SCH_FBC_CHDS_Third_Pass Fail"); + + + /*********************************END EDIT SECTION*****************************************************/ + + + + // Receive arguments from the structured note + (thisDocumentCommunication) := argument; + + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Identify the calling observation item + callingobsvals := thisDocumentCommunication.CurrentObservationObj; + callingobsname := first of (thisParameters where thisParameters.ParameterGUID = callingobsvals.ParameterGUID); + callingobs := first of (thisobservations where thisobservations.ParameterGUID = callingobsname.ParameterGUID); + callingobsval := callingobs.ValueObj.Value; + + + // cyle through the both the obsitemcallgrp1 and obsitemcallgrp2 looking for the position and matching item name + //in the list that matches the callingobsname. If it finds the config then it sets cfgposition equal to the location + //in the list so it can be used through the rest of the MLM logic for knowing what item(s) need compared, updated, ect... + //callingobsval will be equal to the value of obsitemcallgrp1 and callingobsval2 will be the value of the item obsitemcallgrp2 + for x in (1 seqto (count(obsitemcallgrp1))) do + if callingobsname.name = obsitemcallgrp1[x] then + callingobsname2 := first of (thisParameters where thisParameters.Name = obsitemcallgrp2[x]); + callingobs2 := first of (thisobservations where thisobservations.ParameterGUID = callingobsname2.ParameterGUID); + callingobsval2 := callingobs2.ValueObj.Value; + obsitemcall := obsitemcallgrp1; + cfgposition := x; + elseif callingobsname.name = obsitemcallgrp2[x] then + callingobsname2 := first of (thisParameters where thisParameters.Name = obsitemcallgrp1[x]); + callingobs2 := first of (thisobservations where thisobservations.ParameterGUID = callingobsname2.ParameterGUID); + callingobsval2 := callingobs2.ValueObj.Value; + obsitemcall := obsitemcallgrp2; + cfgposition := x; + endif; + enddo; + + + // Get the user, chart, client and visit GUIDs + userGuid := thisDocumentCommunication.UserGUID; + clientGuid := thisDocumentCommunication.ClientGUID; + clientvisitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + callingobsguid := callingobsvals.ParameterGUID; + + //get the admit date/time from the database to be used to calculate the hours old + admitdttm := read last {"select AdmitDtm from CV3ClientVisit " + || "where GUID = " || SQL(clientvisitGuid) //{{{SINGLE-QUOTE}}}9000002915600270{{{SINGLE-QUOTE}}} " + || " and ClientGUID = " || SQL(clientGuid) }; //{{{SINGLE-QUOTE}}}9000001871400200{{{SINGLE-QUOTE}}}"}; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + NumericValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + + //check to make sure the event is a charted observation and that the calling observation exists in + //the list obsitemcall at position "cfgposition" determined in for loop above + if thisDocumentCommunication.EventType = "ChartObservation" + and callingobsname.Name = obsitemcall[cfgposition] then + + //get the observation information for the item(s) listed in obsitemupdate1[cfgposition] and obsitemupdate2[cfgposition] + //these will be the items "updated" in the BEGIN UPDATE TO FORM SECTION + updateobsparam1 := first of (thisParameters where thisParameters.Name = obsitemupdate1[cfgposition]); + updateobsparam2 := first of (thisParameters where thisParameters.Name = obsitemupdate2[cfgposition]); + updateobs1 := first of (thisobservations where thisobservations.ParameterGUID = updateobsparam1.ParameterGUID); + updateobs2 := first of (thisobservations where thisobservations.ParameterGUID = updateobsparam2.ParameterGUID); + updateobsval1 := updateobs1.ValueObj.Value; + updateobsval2 := updateobs2.ValueObj.ListItemsList.IsSelected; + + + //if the chartedobservation is in position 1 follow this logic. for this MLM this will be the admit date/time charted observation + if cfgposition = 1 then + //---------------------------BEGIN ADMIT DATE/TIME COMPARED TO INITIAL DATE/TIME ENTERED ON DOCUMENT--------------------------------// + if callingobsval > admitdttm then + //as long as the entered date/time is greater than the admit date/time then calculate the hours old and grad the whole number + //without rounding. If the patient is 23 hours and 5 minutes old it will return 23. If the patient is 23 hours and 59 minutes it will + //return 23 still per Dr. Griffin{{{SINGLE-QUOTE}}}s request + calchours := (((callingobsval - admitdttm) / 60 seconds) / 60) formatted with "%.2f"; + finddec := FIND "." IN STRING (calchours as string); + calchours := SUBSTRING finddec-1 characters from calchours; + addobsvalue := calchours; + addobs := true; + elseif callingobsval = "" or callingobsval is null then + clearhrsold := true; + elseif admitdttm > callingobsval then + //if the admit date/time is greater than the entered date/time present this message to user so they know how to correct the issue. + errormsg := "The Initial Screening Date/Time entered is prior to the patients Admit Date/Time. " + || "Please enter an approriate date/time in the Initial Screening Date/Time field. " + || "If the screening date/time entered is correct you will need to update the admission date/time in SCM. " + || "If you are unable to update the admission date/time in SCM please call registration to have the admission date/time updated."; + clearhrsold := true; + endif; + //if chearhrsold is set to true then delete the hrsold observation that was previously added to the document. + if clearhrsold = true then + MLM_update_value_observation := NEW ObservationType; + MLM_update_value_observation.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + MLM_update_value_observation.ParameterGUID := updateobsparam1.ParameterGUID; + MLM_update_value_observation.DataType := "NumericValue"; + MLM_update_value_observation.ValueObj := null; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList,MLM_update_value_observation); + + endif; + //---------------------------END ADMIT DATE/TIME COMPARED TO INITIAL DATE/TIME ENTERED ON DOCUMENT--------------------------------// + + + + + //if the chartedobservation is in position 2, 3, or 4 follow this logic (for this MLM these are the pulse ox reading initial, second, third + elseif cfgposition >= 2 and cfgposition <= 4 then + + //--------------------------BEGIN CHECKING THE HAND AND FOOT PULSE OX DATA ENTERED ON DOCUMENT------------------------------------// + if callingobsval = "" or callingobsval is null + or callingobsval2 = "" or callingobsval2 is null then + //if hand or foot pulse ox is null/blank then we will blank out the pulse ox % difference + addobsvalue := ""; + addobs := true; + else + //if there are values in both hand and foot pulse ox value then determine which is greater and subtracted the highest from the lowest + if callingobsval >= callingobsval2 then + addobsvalue := callingobsval - callingobsval2; + else + addobsvalue := callingobsval2 - callingobsval; + endif; + //logic provided by Dr. Griffen read as.... + //If one Pulse Ox value is greater than 95 and the difference is less than 3, precheck the Pass Button. Otherwise select Fail. + //If the difference is greater than 3, precheck the Fail Button. + if (callingobsval >= 95 or callingobsval2 >= 95) and addobsvalue <= 3 then + passfail := "Pass"; + else + passfail := "Fail"; + endif; + addobs := true; + endif; + //--------------------------END CHECKING THE HAND AND FOOT PULSE OX DATA ENTERED ON DOCUMENT------------------------------------// + endif; + + + //-------------------------------BEGIN UPDATE TO FORM SECTION--------------------------------------// + //update the observations identified in obsitemupdate1 and obsitemupdate2 based on above logic as log as the logic set the addobs to true + //and thdobsvalue has been determined through the logic above + if addobs = true and addobsvalue <> "" then + MLM_update_value_observation := NEW ObservationType; + MLM_update_value_observation.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + MLM_update_value_observation.ParameterGUID := updateobsparam1.ParameterGUID; + MLM_update_value_observation.DataType := "NumericValue"; + MLM_update_value_observation.ValueObj := NEW NumericValueType; + MLM_update_value_observation.ValueObj.Value := addobsvalue; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList,MLM_update_value_observation); + + selectParameter := first of (thisParameters where thisParameters.Name = obsitemupdate2[cfgposition]); + if (exists selectParameter) then + + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := selectParameter.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := NEW ListValueType; + this_currentObj.ValueObj.ListGUID := selectParameter.ConfigurationObj.ListGUID; + listItems := (); + for item IN selectParameter.ConfigurationObj.ListItemsList Do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = passfail then + selectedItem.IsSelected := true; + else + selectedItem.IsSelected := false; + endif; + listItems := (listItems, selectedItem); + enddo; + this_currentObj.ValueObj.ListItemsList := listItems; + + + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + + + //if the logic above has determined that we needed to update the observations in obsitemupdate1 and obsitemupdate2 + //and the logic has found that the value needs to be null/blank/deleted then this logic will remove any values from the document that + //needs removed. + elseif addobs = true and addobsvalue = "" then + MLM_update_value_observation := NEW ObservationType; + MLM_update_value_observation.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + MLM_update_value_observation.ParameterGUID := updateobsparam1.ParameterGUID; + MLM_update_value_observation.DataType := "NumericValue"; + MLM_update_value_observation.ValueObj := null; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList,MLM_update_value_observation); + + selectParameter := first of (thisParameters where thisParameters.Name = obsitemupdate2[cfgposition]); + if (exists selectParameter) then + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := selectParameter.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := null; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + elseif errormsg <> "" then + //if the errormsg has been set to something other than blank/null and neither udpate sections were called then display the error message to user + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with errormsg,"Entered Date/Time before Admit Date/Time","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + //-------------------------------END UPDATE TO FORM SECTION--------------------------------------// + ENDIF; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_CLIN_DOC_SPECIALIST_CLARIFICATION.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CLIN_DOC_SPECIALIST_CLARIFICATION.mlm new file mode 100644 index 0000000..abeffd3 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CLIN_DOC_SPECIALIST_CLARIFICATION.mlm @@ -0,0 +1,662 @@ +maintenance: + + title: DOC_FUNC_CLIN_DOC_SPECIALIST_CLARIFICATION;; + mlmname: DOC_FUNC_CLIN_DOC_SPECIALIST_CLARIFICATION;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Rich Schaeffer;; + specialist: Don Warnick;; + date: 2015-02-02;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 02.02.2015 DW CSR# 32616 Develop Application to allow for communication between clinical documentation specialist + 03.23.2015 DW CSR# 32359 Physician CPT codes - Include the ICD code in the plan + 09.30.2015 DW HD# 1887748 Line was added to address null vaule in HIS only section when a doctor opened a blank communication and selected "accept" + 10.01.2015 DW CSR# 23359 ICD10 + 11.09.2015 DW CSR# 33624 Add Clairfication to Day of Discharge Note + 06.29.2017 DW CSR# 33968 CDS Improvements + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + + +// DOCUMENT OPEN SECTION + + + if thisdocumentCommunication.EventType = "DocumentOpening" + then + + (OccCode, userName) := read last {" select OccupationCode, IDCode from CV3USER with (nolock) where guid = " || sql(userGuid) }; +// if ( OccCode = "IT" AND userName = "jlaw" ) then +// break; +// endif; + + // Gather a list of Responses from all EPNs for this visit. This will provide a list of CDS SN{{{SINGLE-QUOTE}}}s that are addresses and need to be excluded + + + (obsNamesListEPN, obsNameValueEPN, obsGuidEPN) := read + {" + SET CONCAT_NULL_YIELDS_NULL off + Select ocmi.name , o.ValueText, cd.guid, cd.* + from CV3ClientDocumentCUR cd with (nolock) + join CV3ClientDocDetailCUR cdd with (nolock) on cdd.ClientDocumentGUID = cd.GUID and cdd.ClientGUID = cd.clientguid and cdd.active = 1 and cdd.ArcType = cd.ArcType + join CV3ObservationDocumentCUR od with (nolock) on cdd.CLientDocumentGUID = od.OwnerGUID and od.ArcType = cdd.ArcType + join CV3ObservationCUR o with (nolock) on o.GUID = od.ObservationGUID and o.ArcType = od.ArcType + join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID + where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " + and cd.iscanceled = 0 and o.ValueText is not null and (cd.DocumentName like {{{SINGLE-QUOTE}}}Physician Progress%{{{SINGLE-QUOTE}}} or cd.DocumentName like {{{SINGLE-QUOTE}}}Day of Discharge Summary eNote%{{{SINGLE-QUOTE}}}) and ocmi.name like {{{SINGLE-QUOTE}}}SCH_CDA_Doc Response MLM%{{{SINGLE-QUOTE}}} + order by ocmi.name desc + "}; + + + // Exlusion GUID List + + ExlusionGuids := ""; + + indexList2 := 1 seqto count (obsNamesListEPN); + for j in indexList2 do + obsNameEPN := last (first j from obsNamesListEPN); + obsValueEPN := last (first j from obsNameValueEPN); + + CDSGuid:= SUBSTRING 16 CHARACTERS STARTING AT 3 FROM obsValueEPN; + + if ExlusionGuids = "" + then ExlusionGuids := ExlusionGuids || "{{{SINGLE-QUOTE}}}" || CDSGuid || "{{{SINGLE-QUOTE}}}"; + else ExlusionGuids := ExlusionGuids || ",{{{SINGLE-QUOTE}}}" || CDSGuid || "{{{SINGLE-QUOTE}}}"; + endif; + enddo; + + // If there are no exclusions, this will be the default value for the following query + + null_found_bad_data := find "null" in string ExlusionGuids; // 03.30.2015 DW HD# 1887748 - Line was added to address null vaule in HIS only section when a doctor opened a blank communication and selected "accept" + + If ExlusionGuids = "" or null_found_bad_data <> 0 then ExlusionGuids := "({{{SINGLE-QUOTE}}}999{{{SINGLE-QUOTE}}})"; endif; + + + (obsNamesList, obsNameValue, obsGuid, obsCDSname) := read + {" + SET CONCAT_NULL_YIELDS_NULL off + Select ocmi.name ,o.ValueText ,cd.guid, cp.DisplayName + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + convert(char(10), cdd.touchedwhen,20) + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + convert(char(5),cdd.touchedwhen,8) + from CV3ClientDocumentCUR cd with (nolock) + join CV3ClientDocDetailCUR cdd with (nolock) on cdd.ClientDocumentGUID = cd.GUID and cdd.ClientGUID = cd.clientguid and cdd.ArcType = cd.ArcType + join CV3ObservationDocumentCUR od with (nolock) on cdd.CLientDocumentGUID = od.OwnerGUID and od.ArcType = cdd.ArcType + join CV3ObservationCUR o with (nolock) on o.GUID = od.ObservationGUID and o.ArcType = od.ArcType + join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID + join CV3CareProvider cp with (nolock) on cp.guid = o.RecordedProviderGUID + where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " + and cd.iscanceled = 0 and cdd.active = 1 and od.active = 1 and o.ValueText is not null and cd.DocumentName = {{{SINGLE-QUOTE}}}Clinical Documentation Specialist Communication{{{SINGLE-QUOTE}}} + and cd.guid not in (" || ExlusionGuids || ") + order by cd.guid + "}; + + + // Display CDS Structured Note data that doesn{{{SINGLE-QUOTE}}}t have a doctor response. + + writeguid := " "; + writetext := " "; + priorguid := " "; + cdscomment := " "; + doctorname := " "; + guidcounter := 0; + obsnameappend:= ""; + + indexList := 1 seqto count (obsNamesList); + + OptionFound := " "; + + for i in indexList do + + obsName := last (first i from obsNamesList); + obsValue := last (first i from obsNameValue); + CDSName := last (first i from obsCDSname); + CDSGUID := last (first i from obsGuid); + + if priorguid <> CDSGUID + then + priorguid := CDSGUID; + guidcounter:= guidcounter + 1; + endif; + + obsnameappend := " " || guidcounter as string; + + + if obsName = "SCH_CDA_Physician" then doctorname:= "To " || obsValue; + elseif obsName = "SCH_CDA_Question 1A" then clarification := "\n\n" || obsValue; // writetext := obsValue; writeobservationname := "SCH_CDA_Question " || guidcounter; + elseif obsName = "SCH_CDA_Clarification Request" then writetext := obsValue; writeobservationname := "SCH_CDA_Clarification Request ePN" || obsnameappend; + elseif obsName = "SCH_CDA_Swap Code" then writetext := obsValue; writeobservationname := "SCH_CDA_MC ICD Swap Code ePN" || obsnameappend || "A"; + + elseif obsName = "SCH_CDA_ICD Name A" then writetext := obsValue; writeobservationname := "SCH_CDA_MC ICD Name ePN " || guidcounter || "A"; OptionFound := "SCH_CDA_Expand " || guidcounter || "A"; + elseif obsName = "SCH_CDA_ICD Code A" then writetext := obsValue; writeobservationname := "SCH_CDA_MC ICD Code ePN " || guidcounter || "A"; + elseif obsName = "SCH_CDA_ICD Name B" then writetext := obsValue; writeobservationname := "SCH_CDA_MC ICD Name ePN " || guidcounter || "B"; OptionFound := "SCH_CDA_Expand " || guidcounter || "B"; + elseif obsName = "SCH_CDA_ICD Code B" then writetext := obsValue; writeobservationname := "SCH_CDA_MC ICD Code ePN " || guidcounter || "B"; + elseif obsName = "SCH_CDA_ICD Name C" then writetext := obsValue; writeobservationname := "SCH_CDA_MC ICD Name ePN " || guidcounter || "C"; OptionFound := "SCH_CDA_Expand " || guidcounter || "C"; + elseif obsName = "SCH_CDA_ICD Code C" then writetext := obsValue; writeobservationname := "SCH_CDA_MC ICD Code ePN " || guidcounter || "C"; + endif; + + + // Check the box that displays the option that is found + + If OptionFound <> " " + then + this_parametername := first of (thisParameters where thisParameters.Name = OptionFound); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := true; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + + + // Write to the Structured Note Text Box + + If writetext <> " " + then + writefield := first of (thisParameters where thisParameters.Name = writeobservationname); + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := writefield.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := writetext; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + endif; + + + // Write to the Clarification field + + if clarification <> " " + + then + + clarificationtext:= doctorname || " from " || CDSName || " " || clarification; + writefield := first of (thisParameters where thisParameters.Name = "SCH_CDA_Question " || guidcounter); + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := writefield.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := clarificationtext; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + // Write the GUID of the CDS SN to a hidden field + + writefield := first of (thisParameters where thisParameters.Name = "SCH_CDA_Document ID" || obsnameappend); + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := writefield.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := CDSGUID; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + + // Check the box that displays the section + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_CDA_Expand" || obsnameappend); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := true; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + endif; + + + // If there is a Health Issue found, then set the Issue Type button to Chronic + + + if OptionFound <> " " + + then + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_CDA_Select" || obsnameappend); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "Chronic" then selectedItem.IsSelected := true; + else selectedItem.IsSelected := false; + endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + OptionFound := " "; // reset for next CDA set + + + endif; + + enddo; + + + + endif; // Document Open + + + + +// CHART OBSERVATION SECTION + + + + if thisdocumentCommunication.EventType = "ChartObservation" + + then + + // Determine the name of the response selected (1 - 5) and append this value to the other observations + + selectedobservationname:= first of (thisparameters.Name where thisparameters.ParameterGUID = thisDocumentCommunication.CurrentObservationObj.parameterguid); + + + // Determine the CDS Message number that is being processed. There are 4 configured to appear in the note. + + If (SUBSTRING 1 CHARACTERS STARTING AT ((LENGTH selectedobservationname)-1) FROM selectedobservationname) = " " + then + // Comment response format (disagree, need to discuss, reviewed) + appendobs := " " || (SUBSTRING 1 CHARACTERS STARTING AT (LENGTH selectedobservationname) FROM selectedobservationname); + else + // Agree to problem format (add problem only, add problem and plan) + appendobs := " " || (SUBSTRING 1 CHARACTERS STARTING AT ((LENGTH selectedobservationname)-1) FROM selectedobservationname); + appendobschoice := SUBSTRING 1 CHARACTERS STARTING AT (LENGTH selectedobservationname) FROM selectedobservationname; // Choice Suffix ( A, B, C) + endif; + + + datestamp := EXTRACT MONTH NOW || "/" || EXTRACT DAY NOW|| "/" || EXTRACT YEAR NOW|| " " || EXTRACT HOUR NOW || ":" || EXTRACT MINUTE NOW; + + username := read last {" SET CONCAT_NULL_YIELDS_NULL off Select displayname + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + OccupationCode from CV3User where guid = " || UserGuid || " " }; + + // Retreive the CSD SN GUID that was written to the Document ID field upon open + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_CDA_Document ID" || appendobs ); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + CSDSNGuid := theObservation.ValueObj.Value; + + // Gather the Health Issue Name + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_CDA_MC ICD Name ePN" || appendobs || appendobschoice ); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + issuename := theObservation.ValueObj.Value; + + // Gather the Health Issue Code + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_CDA_MC ICD Code ePN" || appendobs || appendobschoice ); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + issuecode := theObservation.ValueObj.Value; + + if issuename is null and issuecode is null then isaquestion := "yes"; else isaquestion := "no"; endif; + + // Gather the Health Issue Type + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_CDA_Select" || appendobs ); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Chronic") + then issuetype := "Problem-Chronic"; + else issuetype := "Problem-Visit"; + endif; + + // Determine the Doctor Reponse that was selected + + updateplan := "no"; + + theParameter := first of (thisparameters where thisparameters.Name = selectedobservationname ); + + + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Add or Replace Problem and Plan") + then + if isaquestion = "no" + then agreed := "yes"; updateplan := "yes"; writetext := "1-" || CSDSNGuid || " " || username || " " || datestamp; + else agreed := "no"; updateplan := "no"; writetext := "4-" || CSDSNGuid || " " || username || " " || datestamp; // if selected inappropriately for a question, treat as acknowledged + endif; + endif; + + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Add or Replace Problem Only") + then + if isaquestion = "no" + then agreed := "yes"; updateplan := "no"; writetext := "1-" || CSDSNGuid || " " || username || " " || datestamp; + else agreed := "no"; updateplan := "no"; writetext := "4-" || CSDSNGuid || " " || username || " " || datestamp; // if selected inappropriately for a question, treat as acknowledged + endif; + endif; + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Disagree") + then agreed := "no"; updateplan := "no"; writetext := "2-" || CSDSNGuid || " " || username || " " || datestamp; + endif; + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Need to Discuss") + then agreed := "no"; updateplan := "no"; writetext := "3-" || CSDSNGuid || " " || username || " " || datestamp; + endif; + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Reviewed") + then agreed := "no"; updateplan := "no"; writetext := "4-" || CSDSNGuid || " " || username || " " || datestamp; + endif; + + + + // Write the GUID of the CDS SN to a hidden field + + writefield := first of (thisParameters where thisParameters.Name = "SCH_CDA_Doc Response MLM" || appendobs ); + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := writefield.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := writetext; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + + // If "Agreed", was selected, create a Health Issue, add to Problems, add to Plans (if appropiate) + + if agreed = "yes" + + then + + issuescheme:= "ICD10"; + issuetext := " " ; + + // Gather the Clarification Request Data + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_CDA_Clarification Request ePN" || appendobs); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + evidence := theObservation.ValueObj.Value; + + + + (ExistingHI) := read + { + " select distinct hi.shortname " + || "from cv3healthissuedeclaration hi with (nolock) " + || "join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID " + || "where hi.clientguid = " || ClientGuid || " and hi.active = 1 and hi.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " + || "and hi.typecode = {{{SINGLE-QUOTE}}}problem-chronic{{{SINGLE-QUOTE}}} " + || "and " + || " hi.ICD10Code = {{{SINGLE-QUOTE}}}" || issuecode || "{{{SINGLE-QUOTE}}} " + }; + + + if not exist ExistingHI + then + Func_Create_HI_MLM := mlm {{{SINGLE-QUOTE}}}SCH_Func_Create_Health_Issue{{{SINGLE-QUOTE}}}; + void := call Func_Create_HI_MLM with (visitGuid,issuename,issuecode,issuetext,issuetype,issuescheme); + endif; + + + // Replacement Problem Proceesing + + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_CDA_MC ICD Swap Code ePN" || appendobs || "A"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + ReplacementFound := theObservation.ValueObj.Value; + + targentproblem:= ""; + + ProblemList := 1 seqto 14; + + for x in ProblemList do + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem " || x); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + + // Parse out the ICD10 code from the text in the Probliem field to be used for compare to the "replacement problem" entered by the CDS personnel + + IDCodeBeg := (find "[" in string thisfield) +1; + IDCodeEnd := find "]" in string thisfield; + thisIDCode:= SUBSTRING (IDCodeEnd - IDCodeBeg) CHARACTERS STARTING AT IDCodeBeg FROM thisfield; + + if thisIDCode = ReplacementFound + + then + + targentproblem:= "SCH_MDPN_Problem " || x; + + if updateplan = "yes" + then + if x < 10 + then + targentplan:= "SCH_MDPN_Assessment / Plans 0" || x; + else + targentplan:= "SCH_MDPN_Assessment / Plans " || x; + endif; + endif; + + writefield := first of (thisParameters where thisParameters.Name = "SCH_CDA_MC ICD Swap Name ePN" || appendobs || appendobschoice); + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := writefield.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := "Problem " || ReplacementFound || " has been replaced in the note."; + + if updateplan = "no" then newObservation.ValueObj.Value := newObservation.ValueObj.Value || " Plan is unchanged."; endif; + + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + endif; + + enddo; + + + // No replacement problem was found. Write to the first open field in the AP Plan section + + + If targentproblem = "" + + then + + + openfields := "0"; + opencounter := 0; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 1"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_1 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 2"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_2 := "open"; opencounter := opencounter + 1; endif; + + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 3"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_3 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 4"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_4 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 5"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_5 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 6"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_6 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 7"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_7 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 8"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_8 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 9"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_9 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 10"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_10 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 11"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_11 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 12"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_12 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 13"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_13 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 14"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_14 := "open"; opencounter := opencounter + 1; endif; + + + // Select the first open field for the Problem. Select the first open field for the Plan, if indicated by the doctor. + + + if field_1 = "open" then targentproblem:= "SCH_MDPN_Problem 1"; if updateplan = "yes" then targentplan:= "SCH_MDPN_Assessment / Plans 01"; endif; + elseif field_2 = "open" then targentproblem:= "SCH_MDPN_Problem 2"; if updateplan = "yes" then targentplan:= "SCH_MDPN_Assessment / Plans 02"; endif; + elseif field_3 = "open" then targentproblem:= "SCH_MDPN_Problem 3"; if updateplan = "yes" then targentplan:= "SCH_MDPN_Assessment / Plans 03"; endif; + elseif field_4 = "open" then targentproblem:= "SCH_MDPN_Problem 4"; if updateplan = "yes" then targentplan:= "SCH_MDPN_Assessment / Plans 04"; endif; + elseif field_5 = "open" then targentproblem:= "SCH_MDPN_Problem 5"; if updateplan = "yes" then targentplan:= "SCH_MDPN_Assessment / Plans 05"; endif; + elseif field_6 = "open" then targentproblem:= "SCH_MDPN_Problem 6"; if updateplan = "yes" then targentplan:= "SCH_MDPN_Assessment / Plans 06"; endif; + elseif field_7 = "open" then targentproblem:= "SCH_MDPN_Problem 7"; if updateplan = "yes" then targentplan:= "SCH_MDPN_Assessment / Plans 07"; endif; + elseif field_8 = "open" then targentproblem:= "SCH_MDPN_Problem 8"; if updateplan = "yes" then targentplan:= "SCH_MDPN_Assessment / Plans 08"; endif; + elseif field_9 = "open" then targentproblem:= "SCH_MDPN_Problem 9"; if updateplan = "yes" then targentplan:= "SCH_MDPN_Assessment / Plans 09"; endif; + elseif field_10 = "open" then targentproblem:= "SCH_MDPN_Problem 10"; if updateplan = "yes" then targentplan:= "SCH_MDPN_Assessment / Plans 10"; endif; + elseif field_11 = "open" then targentproblem:= "SCH_MDPN_Problem 11"; if updateplan = "yes" then targentplan:= "SCH_MDPN_Assessment / Plans 11"; endif; + elseif field_12 = "open" then targentproblem:= "SCH_MDPN_Problem 12"; if updateplan = "yes" then targentplan:= "SCH_MDPN_Assessment / Plans 12"; endif; + elseif field_13 = "open" then targentproblem:= "SCH_MDPN_Problem 13"; if updateplan = "yes" then targentplan:= "SCH_MDPN_Assessment / Plans 13"; endif; + elseif field_14 = "open" then targentproblem:= "SCH_MDPN_Problem 14"; if updateplan = "yes" then targentplan:= "SCH_MDPN_Assessment / Plans 14"; endif; + endif; + + + endif; + + + // Write the problem name to the open problem slot + + + targentproblem := first of (thisParameters where thisParameters.Name = targentproblem); + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := targentproblem.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := issuename || " [" || issuecode || "]"; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + + // Write the plan to the open plan slot + + targentplan := first of (thisParameters where thisParameters.Name = targentplan); + + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := targentplan.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := evidence; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + + + endif; // Agreed = "yes" + + + endif; // Observation Change + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_COUMADIN_EDUCATION_OBS.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_COUMADIN_EDUCATION_OBS.mlm new file mode 100644 index 0000000..31919f9 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_COUMADIN_EDUCATION_OBS.mlm @@ -0,0 +1,130 @@ +maintenance: + + title: DOC_FUNC_COUMADIN_EDUCATION_OBS;; + mlmname: DOC_FUNC_COUMADIN_EDUCATION_OBS;; + arden: version 5.5;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Juliet Law;; + specialist: Debbie Eiler;; + date: 2011-09-08;; + validation: testing;; + +library: + purpose: + ;; + explanation: + + Change history + + 09.08.2011 JML Create date. + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // .Net assemblies required for ObjectsPlus + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + // Receive arguments from the structured note + (thisDocumentCommunication) := argument; + + // Configured parameter names that will be selected + USER_CONFIGURED_PARAMETER_NAMES := ("SCH_PHCO Warfarin Education", + "SCH_PHCO Warfarin Physician Contact", + "SCH_PHCO Warfarin Labwork"); + + //Document Types + STRUCTUREDNOTE := "StructuredNote"; + + //Event Types + DOCUMENTCLOSING := "DocumentClosing"; + CHARTOBSERVATION := "ChartObservation"; + + //Setting debugFlag to True will allow popup dialogs containing debug information to appear + debugFlag := false; + + // DocumentCommunication Object Model variables + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Get the client, visit, chart, and user GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + //Set up debugging information to be captured + messageText := ""; + if (debugFlag = true) then + messageText := "Debug Information:\n\n"; + messageText := messageText || " DOC_FUNC_PT_CONSULT_FROM_ADM_OBS mlm called.\n\n"; + endif; + + // Parameter that will trigger selecting all coumadin edu obs + theParameterName := "SCH_PHCO Warfarin Education Y/N"; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + if (thisDocumentCommunication.EventType = CHARTOBSERVATION) then + theParameter := first of (thisParameters where thisParameters.Name = theParameterName); + theObservation := first of (thisObservations where thisObservations.ParameterGUID = theParameter.ParameterGUID); + + if (thisDocumentCommunication.CurrentObservationObj.ParameterGUID = theParameter.ParameterGUID) then + + canSelectAll := exists (theObservation.ValueObj.ListItemsList.Value + where theObservation.ValueObj.ListItemsList.Value = "Yes..." + and theObservation.ValueObj.ListItemsList.IsSelected = true); + + if (canSelectAll) then + For parameterName IN USER_CONFIGURED_PARAMETER_NAMES Do + selectParameter := first of (thisParameters where thisParameters.Name = parameterName); + + if (exists selectParameter) then + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := selectParameter.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := NEW ListValueType; + this_currentObj.ValueObj.ListGUID := selectParameter.ConfigurationObj.ListGUID; + listItems := (); + for item IN selectParameter.ConfigurationObj.ListItemsList Do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + selectedItem.IsSelected := true; + + listItems := (listItems, selectedItem); + enddo; + + this_currentObj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + enddo; + endif; + endif; + endif; + + if (debugFlag = true) then + messageText := messageText || "\n DOC_FUNC_PT_CONSULT_FROM_ADM_OBS mlm completed.\n\n"; + thisDocumentCommunication.DisplayMessage := true; + thisDocumentCommunication.Message := messageText; + endif; + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_CREATE_DIETITIAN_CONSULT_FROM_ADULT_ASSESS_OBS.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CREATE_DIETITIAN_CONSULT_FROM_ADULT_ASSESS_OBS.mlm new file mode 100644 index 0000000..46f4154 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CREATE_DIETITIAN_CONSULT_FROM_ADULT_ASSESS_OBS.mlm @@ -0,0 +1,329 @@ +maintenance: + + title: DOC_FUNC_CREATE_DIETITIAN_CONSULT_FROM_ADULT_ASSESS_OBS;; + mlmname: DOC_FUNC_CREATE_DIETITIAN_CONSULT_FROM_ADULT_ASSESS_OBS;; + arden: version 2.5;; + version: 6.10;; + institution: Allscripts;; + author: Juliet M. Law ;; + specialist: ;; + date: 2011-07-18;; + validation: testing;; + +library: + purpose: Generate a Dietitian Consult Order from a Braden Score result. + ;; + explanation: On the Adult Assessment/Intervention Flowsheet, if the Braden Risk criteria calculate a Braden score + less than or equal to 14, then a Dietitian Consult order will automatically be generated, if one does not + already exist for the patient. + + Change History + -------------- + 2011-07-18 JML Created + 2014-05-02 JML WO# 161614: MLM re-write; Dietician consults erroneously created for Braden Scores. + 2015-02-16 JML CSR 32519: MLM re-write; created; creating dietician consult if Braden Nutrition + score is 2 or less (renamed MLM). + 2015-03-03 JML Moved to Production. + 2016-06-16 STH CSR#: 33438 - Added logic to only generate the Dietitian Consult if there are 2 consecutive Nutrition (quality of food intake) + {Go-Live 6/21/2016} + ;; + keywords: braden, dietitian consult, flowsheet + ;; +knowledge: + type: data-driven;; + data: + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + //Include ObjectsPlus Assemblies + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + //Include Called MLM to setup CDS objects + set_cds_vars := MLM {{{SINGLE-QUOTE}}}CALLED_DOC_FS_DEFINITION_MLM{{{SINGLE-QUOTE}}}; + + (thisDocumentCommunication) := argument; + + /**************Make Changes To Spelling And Flags In This Section**************/ + //Set up variables; initialize + //braden_param := "AS SC braden score CAL"; + + braden_param := "AS SC braden nutrition"; + pressure_param := "AS press ulcer location"; + wound_param := "AS body location"; + dietitian_consult_name := "Dietitian Consult"; + order_reason := ""; + continue_creating_order := false; + + rcd_val := ""; + msg := ""; + braden_val_list := (); + + //Required Objects+ Variables + SessionType := "Standard"; + SessionReason := ""; + RequestingSource := ""; + Order_Creation_Reason := "Low Braden score entered"; + mlm_name := "DOC_FUNC_CREATE_DIETITIAN_CONSULT_FROM_BRADEN_OBS"; + + //Constants for document type and event + DOCUMENTCLOSING := "DocumentClosing"; + CHARTOBSERVATION := "ChartObservation"; + FLOWSHEET := "Flowsheet"; + + /******************************************************************************/ + + //Initialize CDS objects via MLM call + (thisDocumentCommunication, client_guid, client_visit_guid, chart_guid, + user_guid, document_type, document_name, event_type, + configuration_guid, this_currentObs, CancelEventFlag, this_fs_doc, + authored_by_guid, isIOFlowsheetFlag, client_document_guid, this_parameters, + this_columnList, this_currentColumn, this_chartedObservationsList, + this_parameters_displayName, current_parameter, current_parameter_name, current_parameter_guid, + current_parameter_datatype, selectedItems, selectedItems_Value, current_value, + diagnostic_message, displayMessageFlag) := CALL set_cds_vars WITH (thisDocumentCommunication); + + if ( event_type = DOCUMENTCLOSING ) then + + theCurrentColumn := first of ( this_columnList WHERE this_columnList.ClientDocumentGUID = this_currentObs.ClientDocumentGUID ); + + bradenParam := first of ( this_parameters WHERE this_parameters.Name = braden_param); + if ( exists bradenParam ) then + bradenObs := first of ( theCurrentColumn.ChartedObservationsList WHERE theCurrentColumn.ChartedObservationsList.ParameterGUID = bradenParam.ParameterGUID ); + + if ( exists bradenObs ) then + + last_braden := last of ( bradenObs.ValueObj.ListItemsList.Value WHERE bradenObs.ValueObj.ListItemsList.IsSelected = true ); + last_braden := SUBSTRING 1 CHARACTERS FROM last_braden; + + if ( ( last_braden as number ) <= 2 ) then + current_column_dttm := theCurrentColumn.DateTime; + previous_braden_score := read first { " select guid as {{{SINGLE-QUOTE}}}clientvisitguid{{{SINGLE-QUOTE}}}, clientguid, chartguid into #tmp_patients from cv3clientvisit with (nolock) + where ClientGuid = " || sql(client_guid) + || " and ChartGUID = " || sql(chart_guid) + || " and guid = " || sql(client_visit_guid) + + || " Select guid into #tmp_obnames from CV3ObsCatalogMasterItem with (nolock) + where expirationDtm is null + and name = {{{SINGLE-QUOTE}}}AS SC BRADEN NUTRITION{{{SINGLE-QUOTE}}} + + select top 1 substring(oflv.value,2,1) as obsvalue + from #tmp_patients cv with (nolock) + inner join SXACDObservationParameter ObsParam with (nolock) + on cv.ClientGUID = ObsParam.ClientGUID + and cv.chartguid = ObsParam.ChartGUID + and cv.clientvisitguid = ObsParam.clientvisitguid + AND ObsParam.IsCanceled = 0 + and ObsParam.ObsMasterItemGUID in (select guid from #tmp_obnames) + inner join SCMObsFSListValues oflv with (nolock) + on obsparam.clientguid = oflv.clientguid + and obsparam.ObservationDocumentGUID = oflv.ParentGUID + where RecordedDtm < " || sql (current_column_dttm) + || " order by RecordedDtm desc + + drop table #tmp_obnames, #tmp_patients " }; + + if((previous_braden_score as number) <= 2) then + order_reason := "Braden Nutrition Score 2 or Less"; + continue_creating_order := true; + endif; + endif; + endif; + endif; + + if ( NOT continue_creating_order ) then + pressParam := first of ( this_parameters WHERE this_parameters.Name = pressure_param); + if ( exists pressParam ) then + pressureObs := first of ( theCurrentColumn.ChartedObservationsList WHERE theCurrentColumn.ChartedObservationsList.ParameterGUID = pressParam.ParameterGUID ); + if ( exists pressureObs ) then + pressure_location := count ( pressureObs.ValueObj.ListItemsList.IsSelected WHERE pressureObs.ValueObj.ListItemsList.IsSelected = true ); + if ( pressure_location >= 1 ) then + order_reason := "Pressure Ulcer"; + continue_creating_order := true; + endif; + endif; + endif; + endif; + + if ( NOT continue_creating_order ) then + woundParam := first of ( this_parameters WHERE this_parameters.Name = wound_param); + if ( exists woundParam ) then + woundObs := first of ( theCurrentColumn.ChartedObservationsList WHERE theCurrentColumn.ChartedObservationsList.ParameterGUID = woundParam.ParameterGUID ); + if ( exists woundObs ) then + wound_location := count ( woundObs.ValueObj.ListItemsList.IsSelected WHERE woundObs.ValueObj.ListItemsList.IsSelected = true ); + if ( wound_location >= 1 ) then + order_reason := "Wound Care"; + continue_creating_order := true; + endif; + endif; + endif; + endif; + + if ( continue_creating_order ) then + + //Braden score less than or equal to 14 + //Check for existence of Dietitian Consult Order + (orderName) := read {"SELECT o.Name, o.TouchedWhen" + || " FROM CV3Order as o with (nolock) JOIN" + || " (CV3OrderCatalogMasterItem AS ocmi with (nolock)" + || " JOIN CV3OrderReviewCategory AS orc with (nolock)" + || " ON ocmi.OrderReviewCategoryGUID = orc.GUID)" + || " ON o.OrderCatalogMasterItemGUID = ocmi.GUID" + || " WHERE o.ClientGUID = " || Sql(client_guid) + || " AND o.ClientVisitGUID = " || Sql(client_visit_guid) + || " AND o.ChartGUID = " || Sql(chart_guid) + || " AND (" + || " (o.Name = {{{SINGLE-QUOTE}}}" || dietitian_consult_name || "{{{SINGLE-QUOTE}}})" + || " OR (" + || " orc.Code LIKE {{{SINGLE-QUOTE}}}%Risk Assessment Referrals%{{{SINGLE-QUOTE}}}" + || " AND o.Name IN ({{{SINGLE-QUOTE}}}Cachexic Appearance{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}Chewing or Swallowing Difficulty{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}Currently Unable to Feed Self{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}Decubitis Pressure Ulcer Present{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}Mouth Pain- Prevents Eating{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}Nausea, Vomiting Excess over 3 days{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}Poor Appetite, Intake times 2 weeks{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}Recent Oral, Esophageal, or GI Cancer{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}SOB-Prevents Eating- CHF or COPD Only{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}Tube Feedings-Risk{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}Weight Loss Unintentional>10 lbs in 3 mo{{{SINGLE-QUOTE}}})" + || " )" + || " OR (o.Name LIKE {{{SINGLE-QUOTE}}}Dietitian Follow Up%{{{SINGLE-QUOTE}}})" + || " )" + || " AND" + || " ((o.OrderStatusLevelNum > 15" + || " AND o.OrderStatusLevelNum NOT IN ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}}))" + || " OR o.OrderStatusCode = {{{SINGLE-QUOTE}}}HOLD{{{SINGLE-QUOTE}}})"}; + orderCount := count(orderName) as number; + + if orderCount = 0 then + //No Dietitian Consult Orders exist + //Get the currently logged on user + + //Get the locationGuid + locationGuid := read last {"SELECT CurrentLocationGUID, touchedWhen" + || " FROM CV3ClientVisit with (nolock)" + || " WHERE GUID = " || Sql(client_visit_guid) + || " AND ClientGUID = " || Sql(client_guid) + , primaryTime = touchedWhen}; + try + //Retrieve .Net version of client visit object + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey + with ((client_visit_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + //Use current user as default care provider + care_provider_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey + with ((user_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + //Get Location Obj + location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey + with ((locationGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + //Get the OrderCatalogMasterItem Obj + order_catalog_obj := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName + with (dietitian_consult_name); + + endtry; + catch Exception ex + error_occurred := true; + error_message := "{{+R}}CommonData: {{-R}}\n" || + ex.Message || "\n\n"; + + //Clean up + if order_catalog_obj is NOT Null then + void := call order_catalog_obj.Dispose; + order_catalog_obj := null; + endif; + + if location_obj IS NOT Null then + void := call location_obj.Dispose; + location_obj := null; + endif; + + if care_provider_obj IS NOT Null then + void := call care_provider_obj.Dispose; + care_provider_obj := null; + endif; + + if client_visit_obj IS NOT Null then + void := call client_visit_obj.Dispose; + client_visit_obj := null; + endif; + endcatch; + + try + //Generate the Dietitian Consult Order + Order_Obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder + with client_visit_obj, + order_catalog_obj, + Order_Creation_Reason, + care_provider_obj, + RequestingSource, + SessionType, + SessionReason, + location_obj, + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; + endtry; + catch Exception ex + error_occurred := true; + error_message := "{{+R}}New Other Order: {{-R}}\n" || + ex.Message || "\n\n"; + + if Order_Obj IS NOT Null then + void := call Order_Obj.Dispose; + Order_Obj := null; + endif; + + endcatch; + + //Set UDDI field value on order (Indication for Consult) + ret_val := call Order_Obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} + with "NUTR_Consult Reasons",order_reason; + + //Order_Obj.SpecialInstructions := "Current Braden Nutrition Score is " || last_braden || "."; + + //Save order + void := call Order_Obj.Save; + + //CleanUp + if order_catalog_obj IS NOT Null then + void := call order_catalog_obj.Dispose; + order_catalog_obj := null; + endif; + + if location_obj IS NOT Null then + void := call location_obj.Dispose; + location_obj := null; + endif; + + if care_provider_obj IS NOT Null then + void := call care_provider_obj.Dispose; + care_provider_obj := null; + endif; + + if client_visit_obj IS NOT Null then + void := call client_visit_obj.Dispose; + client_visit_obj := null; + endif; + + if error_occurred then + thisDocumentCommunication.DisplayMessage := true; + thisDocumentCommunication.Message := error_message; + endif; + endif; + endif; + endif; + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: + return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_CREATE_DRESSING_CHANGE_FROM_LINE_INSERTION_OBS.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CREATE_DRESSING_CHANGE_FROM_LINE_INSERTION_OBS.mlm new file mode 100644 index 0000000..4bdf1aa --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CREATE_DRESSING_CHANGE_FROM_LINE_INSERTION_OBS.mlm @@ -0,0 +1,515 @@ +maintenance: + + title: DOC_FUNC_CREATE_DRESSING_CHANGE_FROM_LINE_INSERTION_OBS;; + mlmname: DOC_FUNC_CREATE_DRESSING_CHANGE_FROM_LINE_INSERTION_OBS;; + arden: version 2.5;; + version: 5.50;; + institution: Allscripts;; + author: Juliet M. Law ;; + specialist: ;; + date: 2011-08-29;; + validation: testing;; + +library: + purpose: Generate a Dressing Change order following a line insertion observation entry. + ;; + explanation: When charting the location of a central line, picc line, or vascular access port line, + if the location value equals "Inserted" or "Inserted Pre Hospital", then + a dressing change order must be created to ensure the infusion team is scheduled for the dressing change. + The following flowsheets are affected by this: + * Adult Assessment/Intervention + * Pediatric Assessment/Intervention + * OB Assessment/Intervention + * Vital Signs - ED + + The following observations and values are affected by this, + generating the following orders: + * Inserted: + - CVP Line Dressing Change + - INV Central Line Location + - INV Central Line Location Peds + - PICC Line Dressing Change + - INV PICC Location + - INV PICC Location Peds + - schck_INV PICC Location 2 + - schck_INV PICC Location Peds 2 + - Port Dressing Change + - INV Vasc Access Port Location + - Midline Dressing Change + - INV midline cath location + - INV midline cath location peds + * Inserted Pre Hospital: + - CVP Line Dressing Change + - INV Central Line Location + - INV Central Line Location Peds + - PICC Line Dressing Change + - INV PICC Location + - INV PICC Location Peds + - schck_INV PICC Location 2 + - schck_INV PICC Location Peds 2 + - Port Dressing Change + - INV Vasc Access Port Location + - Midline Dressing Change + - INV midline cath location + - INV midline cath location peds + ;; + keywords: flowsheet + ;; +knowledge: + type: data-driven;; + data: + + (this_documentCommunication) := argument; + + // .Net assemblies need to be loaded for ObjectsPlus + standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + // Called MLM declaration section + // Utility function to parse strings + str_parse := MLM {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; + set_cds_vars := MLM {{{SINGLE-QUOTE}}}CALLED_DOC_FS_DEFINITION_MLM{{{SINGLE-QUOTE}}}; + read_obs_value := MLM {{{SINGLE-QUOTE}}}CALLED_DOC_FS_OBS_VALUE_MLM{{{SINGLE-QUOTE}}}; + + //***************** USER CONFIGURED CONSTANTS ********************* + // Configured parameter names and corresponding index number that identifies which order + // in the USER_CONFIGURED_ORDER_ITEMS_LIST to create + // Add your configured parameter name to the top of this list + (USER_CONFIGURED_PARAMETER_LIST) := ( + "INV central line location|1", + "INV central line location peds|1", + "schck_INV picc location 2|2", + "schck_INV picc location peds 2|2", + "INV PICC location|2", + "INV PICC location peds|2", + "INV vasc access port location|3", + "INV midline cath location|4", + "INV midline cath location peds|4" + ); + (PICC_DUPLICATE_ORDER_LIST) := ("INV PICC location", + "INV PICC location peds", + "schck_INV picc location 2", + "schck_INV picc location peds 2"); + // Charted values that will trigger order to be placed + // NOTE: these values do not directly correspond to the parameter name + // Add your configured corresponding charted values to the top of this list + (USER_CONFIGURED_CHARTED_VALUES_LIST) := ( + "Inserted:", + "Inserted Pre Hospital:", + "Insert:" + ); + // Associated Order Catalog Item name to create based on parameter + // Parameter list includes an index number that associates the parameter to the order item + // for example, "INV central line location|1" associates with "CVP Line Dressing Change" since + // the 1 represents the first index in the USER_CONFIGURED_ORDER_ITEMS_LIST + (USER_CONFIGURED_ORDER_ITEMS_LIST) := ( + "CVP Line Dressing Change", + "PICC Line Dressing Change", + "Port Dressing Change", + "Midline Dressing Change" + ); + + //********************** End of USER CONFIGURED CONSTANTS section ********************************* + + // Default values when creating orders + SessionType := "Standard"; + SessionReason := ""; + RequestingSource := ""; + user_IDType := "Primary"; + order_creation_reason := "From MLM"; + + orderPlacedMessage := ""; + + orderItemName := NULL; + canPlaceOrder := false; + chartedDateTime := NULL; + triggerValueExists := false; + pedsExists := false; + //******************** Variable and Constant Declaration section ************************************* + + //Document Type + FLOWSHEET := "FlowSheet"; + + //Event Types + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTCLOSING := "DocumentClosing"; + + // Setting the cancelProcessing to true will cause the charted observation not to be saved + cancelProcessing := false; + + // Setting the debugFlag to true will cause popup dialogs containing debug information to display + debugFlag := false; + + //Set Flowsheet DocumentCommunication object model variables via Called MLM + (this_documentCommunication, client_guid, client_visit_guid, chart_guid, + user_guid, document_type, document_name, event_type, + configuration_guid, this_currentObs, CancelEventFlag, this_fs_doc, + authored_by_guid, isIOFlowsheetFlag, client_document_guid, this_parameters, + this_columnList, this_currentColumn, this_chartedObservationsList, + this_parameters_displayName, current_parameter, current_parameter_name, current_parameter_guid, + current_parameter_datatype, selectedItems, selectedItems_Value, current_value, + diagnostic_message, displayMessageFlag) := CALL set_cds_vars WITH (this_documentCommunication); + + this_DocumentType := this_documentCommunication.DocumentType; + this_EventType := this_documentCommunication.EventType; + + // Set up debugging information to be captured + messageText := ""; + if (debugFlag = true) then + messageText := "Debug Information: \n\n"; + messageText := messageText || " DOC_FUNC_CREATE_DRESSING_CHANGE_FROM_LINE_INSERTION_OBS mlm is called\n\n"; + endif; + + //********************** Begin Processing Logic *********************************** + + // Perform logic if DocumentType is FlowSheet and EventType is DocumentClosing + if ((this_DocumentType = FLOWSHEET) AND (this_EventType = DOCUMENTCLOSING)) then + // Iterate through parameters in user configured list + FOR parameterName IN USER_CONFIGURED_PARAMETER_LIST DO + + // Parse out parameter name from associated order index location + parameterElementList := call str_parse with parameterName, "|"; + observationName := parameterElementList[1]; + orderIdx := parameterElementList[2] as number; + + theParameter := first of (this_parameters WHERE this_parameters.Name = observationName); + + if (exists theParameter) then + (this_documentCommunication, selectedValue, currentValue) := call read_obs_value with (this_documentCommunication, theParameter.Name, "Read"); + + if (exists selectedValue) then + + // Determine if we should place the order by what was charted matching one of the values + // in our configured list + triggerValueExists := ((USER_CONFIGURED_CHARTED_VALUES_LIST[1] IN selectedValue) + OR (USER_CONFIGURED_CHARTED_VALUES_LIST[2] IN selectedValue) + OR (USER_CONFIGURED_CHARTED_VALUES_LIST[3] IN selectedValue)); + // If we can place the order, then retrieve the associated order item name based on the + // order index + + if (triggerValueExists) then + + orderItemName := USER_CONFIGURED_ORDER_ITEMS_LIST[orderIdx]; + + //Check for order existence with same request date & time of charted obs time on flowsheet + //Get DateTime on column just charted + chartedDateTime := first of (this_columnList.DateTime + where this_columnList.ClientDocumentGUID = this_currentObs.ClientDocumentGUID); + + greaterChartDateTime := chartedDateTime + 1 hour; + lessChartDateTime := chartedDateTime - 1 hour; + requestYear := year of chartedDateTime as string; + if ((month of chartedDateTime >= 1) and (month of chartedDatetime <= 9)) then + requestMonth := ("0" || month of chartedDateTime) as string; + else + requestMonth := month of chartedDateTime as string; + endif; + if ((day of chartedDateTime >= 1) and (day of chartedDateTime <= 9)) then + requestDay := ("0" || day of chartedDateTime) as string; + else + requestDay := day of chartedDateTime as string; + endif; + requestDateCheck := (requestMonth || "-" || requestDay || "-" || requestYear) as string; + orderRequestDate := (requestYear || "-" || requestMonth || "-" || requestDay) as string; + + //Locate Order + orderSpecInstr := (); + existingOrderName := (); + (existingOrderName, orderSpecInstr) := read {"SELECT o.Name, oai.SpecialInstructions, o.TouchedWhen" + || " FROM CV3Order as o with (nolock) JOIN" + || " (CV3OrderCatalogMasterItem AS ocmi with (nolock)" + || " JOIN CV3OrderReviewCategory AS orc with (nolock)" + || " ON ocmi.OrderReviewCategoryGUID = orc.GUID)" + || " ON o.OrderCatalogMasterItemGUID = ocmi.GUID" + || " JOIN CV3OrderAddnlInfo as oai with (nolock)" + || " ON o.GUID = oai.GUID" + || " WHERE o.ClientGUID = " || client_guid + || " AND o.ClientVisitGUID = " || client_visit_guid + || " AND o.ChartGUID = " || chart_guid + || " AND (" + || " (o.Name = {{{SINGLE-QUOTE}}}" || orderItemName || "{{{SINGLE-QUOTE}}})" + || " )" + || " AND" + || " ((o.OrderStatusLevelNum > 15" + || " AND o.OrderStatusLevelNum NOT IN ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}100{{{SINGLE-QUOTE}}}))" + || " OR o.OrderStatusCode = {{{SINGLE-QUOTE}}}HOLD{{{SINGLE-QUOTE}}})" + || " AND ((o.CreatedWhen >= {{{SINGLE-QUOTE}}}" || lessChartDateTime || "{{{SINGLE-QUOTE}}}" + || " and o.CreatedWhen < {{{SINGLE-QUOTE}}}" || greaterChartDateTime || "{{{SINGLE-QUOTE}}})" + || " OR o.RequestedDate = {{{SINGLE-QUOTE}}}" || orderRequestDate || "{{{SINGLE-QUOTE}}}" +/* JML: Help desk ticket fix */ || " OR oai.SpecialInstructions LIKE {{{SINGLE-QUOTE}}}%" || chartedDateTime || "%{{{SINGLE-QUOTE}}})" + , primaryTime = touchedWhen}; + + if ((count existingOrderName) = 0) then + canPlaceOrder := true; + elseif ((count existingOrderName) = 1) then + if (("PICC Line Dressing Change" in existingOrderName) and (theParameter.Name in PICC_DUPLICATE_ORDER_LIST)) then + if (orderSpecInstr[1] matches pattern "PICC%" AND + ((theParameter.Name = PICC_DUPLICATE_ORDER_LIST[3]) OR + (theParameter.Name = PICC_DUPLICATE_ORDER_LIST[4]))) then + canPlaceOrder := true; + elseif (orderSpecInstr[1] matches pattern "Additional PICC%" AND + ((theParameter.Name = PICC_DUPLICATE_ORDER_LIST[1]) OR + (theParameter.Name = PICC_DUPLICATE_ORDER_LIST[2]))) then + canPlaceOrder := true; + else + canPlaceOrder := false; + endif; + else + canPlaceOrder := false; + endif; + else //count = 2 + canPlaceOrder := false; + endif; + + if (canPlaceOrder) then + parameterDisplayName := theParameter.DisplayName; + + if (theParameter.Name matches pattern "%peds%") then + pedsExists := true; + endif; + + specialInstructions := ""; + + if (parameterDisplayName = "PICC") then + + if pedsExists then + piccDeviceParamName := "INV picc device Peds"; + insertLengthParamName := "AS iv device insert cath length NU peds"; + externalLengthParamName := "SCHCK_AS iv device external length NU peds"; + dressSecureParamName := "INV iv device dress secure peds"; + elseif not pedsExists then + piccDeviceParamName := "INV picc device"; + insertLengthParamName := "AS iv device insert cath length NU"; + externalLengthParamName := "SCHCK_AS iv device external length NU"; + dressSecureParamName := "INV iv device dress secure"; + endif; + + piccLocation := selectedValue; + (this_documentCommunication, piccDevice, currentValue) := call read_obs_value with + (this_documentCommunication, piccDeviceParamName, "Read"); + (this_documentCommunication, selectedValue, insertLength) := call read_obs_value with + (this_documentCommunication, insertLengthParamName, "Read"); + insertLength := "Insert Length " || insertLength; + (this_documentCommunication, selectedValue, externalLength) := call read_obs_value with + (this_documentCommunication, externalLengthParamName, "Read"); + externalLength := "External Length " || externalLength; + (this_documentCommunication, dressing, currentValue) := call read_obs_value with + (this_documentCommunication, dressSecureParamName, "Read"); + if ("pressure dressing applied" IN dressing) then + pressureDress := true; + else + pressureDress := false; + endif; + + specialInstructions := "PICC: " || chartedDateTime || "; " || piccLocation || "; " || piccDevice + || "; " || insertLength || "; " || externalLength; + + elseif (parameterDisplayName = "Additional PICC") then + + if pedsExists then + insertLengthParamName := "AS iv device insert cath length NU Peds PICC 2"; + externalLengthParamName := "SCHCK_AS iv device external length NU Peds PICC 2"; + dressSecureParamName := "INV iv device dress secure Peds PICC 2"; + elseif NOT pedsExists then + insertLengthParamName := "AS iv device insert cath length NU PICC 2"; + externalLengthParamName := "SCHCK_AS iv device external length NU PICC 2"; + dressSecureParamName := "INV iv device dress secure PICC 2"; + endif; + + addlPiccLocation := selectedValue; + (this_documentCommunication, addlPiccDevice, currentValue) := call read_obs_value with + (this_documentCommunication, "schck_inv picc device 2", "Read"); + (this_documentCommunication, selectedValue, addlInsertLength) := call read_obs_value with + (this_documentCommunication, insertLengthParamName, "Read"); + addlInsertLength := "Insert Length " || addlInsertLength; + (this_documentCommunication, selectedValue, addlExternalLength) := call read_obs_value with + (this_documentCommunication, externalLengthParamName, "Read"); + addlExternalLength := "External Length " || addlExternalLength; + (this_documentCommunication, addlDressing, currentValue) := call read_obs_value with + (this_documentCommunication, dressSecureParamName, "Read"); + if ("pressure dressing applied" IN addlDressing) then + pressureDress := true; + else + pressureDress := false; + endif; + + specialInstructions := "Additional PICC: " || chartedDateTime || "; " || addlPiccLocation || "; " || addlPiccDevice + || "; " || addlInsertLength || "; " || addlExternalLength; + + elseif (parameterDisplayName = "Midline Catheter") then + + if pedsExists then + insertLengthParamName := "AS iv device insert cath length NU Peds midline"; + externalLengthParamName := "SCHCK_AS iv device external length NU Peds midline"; + dressSecureParamName := "INV iv device dress secure Peds midline"; + elseif NOT pedsExists then + insertLengthParamName := "AS iv device insert cath length NU midline"; + externalLengthParamName := "SCHCK_AS iv device external length NU midline"; + dressSecureParamName := "INV iv device dress secure midline"; + endif; + + midlineLocation := selectedValue; + (this_documentCommunication, midlineDevice, currentValue) := call read_obs_value with + (this_documentCommunication, "INV midline cath device", "Read"); + (this_documentCommunication, selectedValue, insertLength) := call read_obs_value with + (this_documentCommunication, insertLengthParamName, "Read"); + insertLength := "Insert Length " || insertLength; + (this_documentCommunication, selectedValue, externalLength) := call read_obs_value with + (this_documentCommunication, externalLengthParamName, "Read"); + externalLength := "External Length " || externalLength; + (this_documentCommunication, dressing, currentValue) := call read_obs_value with + (this_documentCommunication, dressSecureParamName, "Read"); + if ("pressure dressing applied" IN dressing) then + pressureDress := true; + else + pressureDress := false; + endif; + + specialInstructions := chartedDateTime || "; " || midlineLocation || "; " || midlineDevice + || "; " || insertLength || "; " || externalLength; + + elseif (parameterDisplayName = "Central Line") then + + centralLineLocation := selectedValue; + (this_documentCommunication, centralLineDevice, currentValue) := call read_obs_value with + (this_documentCommunication, "INV central line device", "Read"); + pressureDress := false; + + specialInstructions := chartedDateTime || ", " || centralLineLocation || ", " || centralLineDevice; + + elseif (parameterDisplayName = "Vascular Access Port") then + + vascAccessLocation := selectedValue; + + (this_documentCommunication, vascPortType, currentValue) := call read_obs_value with + (this_documentCommunication, "INV vasc access port type", "Read"); + (this_documentCommunication, vascNeedle, currentValue) := call read_obs_value with + (this_documentCommunication, "INV vasc access port needle", "Read"); + + (this_documentCommunication, dressing, currentValue) := call read_obs_value with + (this_documentCommunication, "INV iv device dress secure vasc acc", "Read"); + + if (NOT (exists dressing)) then + (this_documentCommunication, dressing, currentValue) := call read_obs_value with + (this_documentCommunication, "INV iv device dress secure Peds vasc acc", "Read"); + endif; + + if ((exists dressing) AND ("pressure dressing applied" IN dressing)) then + pressureDress := true; + else + pressureDress := false; + endif; + + specialInstructions := chartedDateTime || "; " || vascAccessLocation || "; " || vascPortType + || "; " || vascNeedle; + + endif; + + // Create a GENERAL order from a catalog item + try + + // ClientVisit object + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey + with ((client_visit_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + // GENERAL catalog item object + general_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName + with orderItemName; + + // CareProvider Object + requesting_care_provider_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey + with ((user_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + // Location Object + location_guid := read last {"SELECT CurrentLocationGuid FROM CV3ClientVisit " + || " WHERE ClientGuid = " || client_guid}; + location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey + with ((location_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + // Create GENERAL order + GeneralOrder_Obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder + with client_visit_obj, + general_catalog_item, + order_creation_reason, + requesting_care_provider_obj, + RequestingSource, + SessionType, + SessionReason, + location_obj, + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; + + if pressureDress then + ret_val := call GeneralOrder_Obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} + with "NUR_INF_Pressure DrsgCB", True; + endif; + + GeneralOrder_Obj.RequestedDate := orderRequestDate; + GeneralOrder_Obj.SpecialInstructions := specialInstructions; + + void := call GeneralOrder_Obj.Save; + void := call GeneralOrder_Obj.Dispose; + + orderPlacedMessage := orderPlacedMessage || "\n" || orderItemName; + endtry; + + // Exception Handling + catch Exception ex + debugFlag := true; + messageText := messageText || "New General Order:\n" || + ex.Message || "\n\n"; + endcatch; + + // Clean UP + if (location_obj IS NOT NULL) then + void := call location_obj.Dispose; + location_obj := NULL; + endif; + + if (requesting_care_provider_obj IS NOT NULL) then + void := call requesting_care_provider_obj.Dispose; + requesting_care_provider_obj := NULL; + endif; + + if (general_catalog_item IS NOT NULL) then + void := call general_catalog_item.Dispose; + general_catalog_item := NULL; + endif; + + if (client_visit_obj IS NOT NULL) then + void := call client_visit_obj.Dispose; + client_visit_obj := NULL; + endif; + endif; //canPlaceOrder = True + endif; //triggerValueExists + endif; //theObservation exists + endif; //theParameter Exists + enddo; + endif; + + // If an exception occurred, display debug information + if (debugFlag = true) then + + this_documentCommunication.DisplayMessage := (orderPlacedMessage <> ""); + this_documentCommunication.Message := "The following order(s) were placed:\n" || orderPlacedMessage; + + messageText := messageText || "\n DOC_FUNC_CREATE_DRESSING_CHANGE_FROM_LINE_INSERTION_OBS mlm completed\n\n"; + this_documentCommunication.DisplayMessage := true; + this_documentCommunication.Message := messageText; + endif; + + if (cancelProcessing = true) then + this_documentCommunication.CancelEvent := true; + endif; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: + return this_DocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_CREATE_HEALTH_ISSUE.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CREATE_HEALTH_ISSUE.mlm new file mode 100644 index 0000000..e5a90c9 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_CREATE_HEALTH_ISSUE.mlm @@ -0,0 +1,267 @@ +maintenance: + + title: DOC_FUNC_CREATE_HEALTH_ISSUE;; + mlmname: DOC_FUNC_CREATE_HEALTH_ISSUE;; + arden: version 5.5;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Don Warnick;; + specialist: ;; + date: 2011-08-22;; + validation: testing;; + +library: + purpose: This MLM will create a Health Issue when an observation is charted (started for smoking health issue) + ;; + explanation: This value is needed for meaningful use. + + Change history + + 08.22.2011 DW Created + 04.19.2013 JML CSR 26725: Expand to create "Alcohol Abuse" hi when user selects yes to "problems related to alcohol..." + observation. + 06.03.2013 JML CSR 31688: Include "heavy smoker..." and "light smoker..." observation values in list that + will create "Smoker" health issue when selected. + 09.30.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 HI Dynamic Creation with all details Like ICD10 Code, Snowmed Code etc And Duplicate HI Check Change. + 10.12.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 Coding Scheme [ICD10] And Duplicate Check of HI . + 03.09.2018 DW CSR# 35320 SSC - Added section for pregnancy and lactation health issues + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + (thisDocumentCommunication) := argument; + + (thisStructuredNoteDoc):= thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType:= OBJECT [ListItemGUID, Value, IsSelected]; + + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + createHI := false; + hi_search_name := ""; + searchtype := ""; + + (this_currentObs) := thisDocumentCommunication.CurrentObservationObj; + + + // Selected Observation Logic + + smoker_parametername := first of (thisParameters where thisParameters.Name = "SCHCK tobacco use pt"); + alcohol_parametername:= first of (thisParameters where thisParameters.Name = "PRO alcohol problems rel yn alco"); + preg_or_parametername:= first of (thisParameters where thisParameters.Name = "SCH OR_PRO fem repro pg yn"); + lact_or_parametername:= first of (thisParameters where thisParameters.Name = "SCH_PRO fem repro breastfeed yn"); + + if (this_currentObs.ParameterGUID = smoker_parametername.ParameterGUID) then selected_parametername:= smoker_parametername; hi_search_name:= "smoking"; searchtype := "1"; hi_search_code:= "{{{SINGLE-QUOTE}}}305.1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}V15.82{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}F17.200{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Z87.891{{{SINGLE-QUOTE}}}"; + elseif (this_currentObs.ParameterGUID = alcohol_parametername.ParameterGUID)then selected_parametername:= alcohol_parametername; hi_search_name:= "alcohol"; searchtype := "1"; hi_search_code:= "{{{SINGLE-QUOTE}}}305.0{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}291.81{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}F10.10{{{SINGLE-QUOTE}}}"; + elseif (this_currentObs.ParameterGUID = preg_or_parametername.ParameterGUID)then selected_parametername:= preg_or_parametername; hi_search_name:= "pregnancy"; searchtype := "2"; hi_search_code:= "{{{SINGLE-QUOTE}}}Z33.1{{{SINGLE-QUOTE}}}"; + elseif (this_currentObs.ParameterGUID = lact_or_parametername.ParameterGUID)then selected_parametername:= lact_or_parametername; hi_search_name:= "lactation"; searchtype := "2"; hi_search_code:= "{{{SINGLE-QUOTE}}}Z39.1{{{SINGLE-QUOTE}}}"; + endif; + + selected_observation := first of (thisObservations where thisObservations.ParameterGUID = selected_parametername.ParameterGUID); + + + // Search for existing health issue + + if searchtype is not null + + then + + + if searchtype = "1" // Search by problem name and ICD10 code (include problem-visit on any account) + + then + + (Existing_HI_Found) := read + { " select distinct hi.ShortName + from CV3HealthIssueDeclaration hi with (nolock) join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID + where hi.ClientGUID = " || ClientGuid || " and hi.Active = 1 and hi.Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} and hi.TypeCode not in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}chronic dx{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}dx comments{{{SINGLE-QUOTE}}}) and hi.ICD10Code is not null + and (hi.Text like {{{SINGLE-QUOTE}}}%" || hi_search_name || "%{{{SINGLE-QUOTE}}} or hi.ShortName like {{{SINGLE-QUOTE}}}%" || hi_search_name || "%{{{SINGLE-QUOTE}}} or (case when chi.TypeCode = {{{SINGLE-QUOTE}}}imo{{{SINGLE-QUOTE}}} then SUBSTRING(chi.Code,5,20) when chi.TypeCode = {{{SINGLE-QUOTE}}}icd9{{{SINGLE-QUOTE}}} then chi.Code when chi.TypeCode = {{{SINGLE-QUOTE}}}icd10{{{SINGLE-QUOTE}}} + then chi.Code end) in ( " || hi_search_code || " )) " + }; + + elseif searchtype = "2" // Search by ICD10 code only (problem-visit on this visit only) + + then + + (Existing_HI_Found) := read + { " select distinct hi.ShortName + from CV3HealthIssueDeclaration hi with (nolock) join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID + where hi.ClientGUID = " || ClientGuid || " and hi.ClientVisitGUID = " || visitGuid || " and hi.Active = 1 and hi.Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} and hi.TypeCode not in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}chronic dx{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}dx comments{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}}) and hi.ICD10Code is not null + and case when chi.TypeCode = {{{SINGLE-QUOTE}}}imo{{{SINGLE-QUOTE}}} then SUBSTRING(chi.Code,5,20) when chi.TypeCode = {{{SINGLE-QUOTE}}}icd9{{{SINGLE-QUOTE}}} then chi.Code when chi.TypeCode = {{{SINGLE-QUOTE}}}icd10{{{SINGLE-QUOTE}}} then chi.Code end in ( " || hi_search_code || " ) " + }; + + endif; + + + endif; + + + // Proceed if and existing health issue has not been found + + + if not exists Existing_HI_Found + then + + + // Smoking Section + + + if hi_search_name = "smoking" + then + + If true in (selected_observation.ValueObj.ListItemsList.IsSelected where + selected_observation.ValueObj.ListItemsList.Value = "light smoker (4 or less cigarettes per day)…" or selected_observation.ValueObj.ListItemsList.Value = "current every day smoker..." or + selected_observation.ValueObj.ListItemsList.Value = "current some day smoker..." or selected_observation.ValueObj.ListItemsList.Value = "light smoker..." ) + then smoker := "Smoker"; + + elseif true in (selected_observation.ValueObj.ListItemsList.IsSelected where selected_observation.ValueObj.ListItemsList.Value = "former smoker (no use for at least 30 days)…" ) + then smoker := "Former Smoker"; + + else + smoker := "Non Smoker"; + endif; + + + If smoker not in ("Smoker","Former Smoker") + then + createHI := false; // Never a Smoker + else + dlg_result := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n This selection will create a chronic health issue of {{{SINGLE-QUOTE}}}" || smoker || "{{{SINGLE-QUOTE}}}" || "\n\n Click {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to confirm your selection. \n\n Click {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} if you wish to change your selection.\n " + ,"Confirm Tobacco Use Documentation ", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + If (dlg_result as string) = "No" + then + createHI := false; + else + createHI := true; + + If smoker = "Smoker" + then issuename := "Smoker"; issuecode := "F17.200"; issuetype := "Problem-Chronic"; + else issuename := "Former Smoker"; issuecode := "Z87.891"; issuetype := "Problem-Chronic"; + endif; + endif; + endif; + + + // Alcohol Section + + + elseif hi_search_name = "alcohol" + then + if true in (selected_observation.ValueObj.ListItemsList.IsSelected where selected_observation.ValueObj.ListItemsList.Value = "yes...") + then + dialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n This selection will create a chronic health issue of {{{SINGLE-QUOTE}}}Alcohol Abuse{{{SINGLE-QUOTE}}} \n\n Click {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to confirm your selection. \n\n Click {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} if you wish to change your selection.\n " + ,"Confirm Alcohol Use Documentation ", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + if ((dialogRes as string) = "Yes") + then + createHI := true; + issueName := "Alcohol Abuse"; issuecode := "F10.10"; issuetype := "Problem-Chronic"; + else + createHI := false; + endif; + + else + createHI := false; + endif; + + + // Pregnancy Section + + + elseif hi_search_name = "pregnancy" + then + if true in (selected_observation.ValueObj.ListItemsList.IsSelected where selected_observation.ValueObj.ListItemsList.Value = "yes") + then + dialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n This selection will create a visit health issue of {{{SINGLE-QUOTE}}}Pregnancy{{{SINGLE-QUOTE}}} \n\n Click {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to confirm your selection. \n\n Click {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} if you wish to change your selection.\n " + ,"Confirm Pregnancy Documentation ", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + if ((dialogRes as string) = "Yes") + then + createHI := true; + issueName := "Pregnancy"; issuecode := "Z33.1"; issuetype := "Problem-Visit"; + else + createHI := false; + endif; + + else + createHI := false; + endif; + + + // Lactation Section + + + elseif hi_search_name = "lactation" + then + if true in (selected_observation.ValueObj.ListItemsList.IsSelected where selected_observation.ValueObj.ListItemsList.Value = "yes") + then + dialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n This selection will create a visit health issue of {{{SINGLE-QUOTE}}}Lactating Mother{{{SINGLE-QUOTE}}} \n\n Click {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to confirm your selection. \n\n Click {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} if you wish to change your selection.\n " + ,"Confirm Lactation Documentation ", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + if ((dialogRes as string) = "Yes") + then + createHI := true; + issueName := "Lactating Mother"; issuecode := "Z39.1"; issuetype := "Problem-Visit"; + else + createHI := false; + endif; + + else + createHI := false; + endif; + + + + endif; // End of Health Issue Processing Sections + + + + // Create Health Issue Section + + + if (createHI) + then + issuecodingscheme := "ICD10"; + issuetext := "Created from Patient Profile information. " ; + Func_Create_HI_MLM := mlm {{{SINGLE-QUOTE}}}SCH_Func_Create_Health_Issue{{{SINGLE-QUOTE}}}; + void := call Func_Create_HI_MLM with (visitGuid,issueName,issuecode,issuetext,issuetype,issuecodingscheme); + endif; + + + + endif; // Existing HI not found + + ;; + evoke: + ;; + logic: + + conclude true; + + ;; + action: + + return thisDocumentCommunication; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_DCSUMMARY_SAVE_AND_PRINT.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_DCSUMMARY_SAVE_AND_PRINT.mlm new file mode 100644 index 0000000..cf3c758 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_DCSUMMARY_SAVE_AND_PRINT.mlm @@ -0,0 +1,64 @@ +maintenance: + + title: DOC_FUNC_DCSUMMARY_SAVE_AND_PRINT;; + mlmname: DOC_FUNC_DCSUMMARY_SAVE_AND_PRINT;; + arden: version 2.5;; + version: 0.00;; + institution: St. Clair Hospital;; + author: Shawn Head;; + specialist: Shawn Head;; + date: 2015-06-01;; + validation: testing;; + +library: + purpose: Create DC Summary report after saving the discharge summary. + ;; + explanation: + Change history + + 06.3.2015 STH CSR# 32070 go-live 6/9/2015 - 15 seconds after a Day of Discharge Summary eNote is created/modified this MLM will check to see if + Discharge Order reconiliation is completed. If its complete the MLM will call the DC Summary print. + ;; + keywords: + Discharge Summary, Day of Discharge Note, DC Summary + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + + standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + + trig_event_enter := event {ClientDocumentEnter User ClientDocument: where documentname matches pattern ("Day of Discharge Summary eNote%")}; + trig_event_modify:= event {ClientDocumentModify User ClientDocument: where documentname matches pattern ("Day of Discharge Summary eNote%")}; + + (VisitGUID, ChartGUID, ClientGUID, docguid) := read last {ClientDocument: ClientVisitGUID, ChartGUID, ClientGUID, guid REFERENCING EvokingObject}; + + dc_orderrec_GUID := read last {"select guid from CV3OrderReconcile with (nolock) " + || " where clientguid = " || sql(ClientGUID) + || " and chartguid = " || sql(ChartGUID) + || " and ClientVisitGUID = " || sql(VisitGUID) + || " and reconciletypecode = {{{SINGLE-QUOTE}}}discharge{{{SINGLE-QUOTE}}} " + || " and ReconcileStatusType = 2 "}; + + if dc_orderrec_guid is not null and dc_orderrec_guid <> "" then + DCSummmary_Print_MLM := mlm {{{SINGLE-QUOTE}}}SCH_FUNC_DCSUMMARY_PRINT{{{SINGLE-QUOTE}}}; + void := CALL DCSummmary_Print_MLM with (clientguid,chartguid,visitguid,null,docguid); + endif; + ;; + priority: 50 + ;; + evoke: + 15 seconds after time of trig_event_enter; + 15 seconds after time of trig_event_modify; + ;; + logic: + conclude true; + ;; + action: + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_DEFAULT_OBS_VALUES.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_DEFAULT_OBS_VALUES.mlm new file mode 100644 index 0000000..97204fd --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_DEFAULT_OBS_VALUES.mlm @@ -0,0 +1,125 @@ +maintenance: + + title: DOC_FUNC_DEFAULT_OBS_VALUES;; + mlmname: DOC_FUNC_DEFAULT_OBS_VALUES;; + arden: version 2.5;; + version: 1.00;; + institution: St. Clair Hospital;; + author: Shawn Head x7468 - Allscripts/St. Clair Hospital;; + specialist: Courtney Carr - Allscripts/St. Clair Hospital;; + date: 2017-06-20;; + validation: testing;; + +library: + purpose: + ;; + explanation: + 06-20-2017 STH CSR#: 35320 - This MLM is called to parse through the configuration on structured notes to default the observation values to user configurable values. + + ;; + keywords: + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + std_write_obs_MLM := mlm {{{SINGLE-QUOTE}}}STD_FUNC_DOC_WRITE_TO_DOCUMENT{{{SINGLE-QUOTE}}}; + string_parse := mlm {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + CR := 13 formatted with "%c"; + LF := 10 formatted with "%c"; + CRLF:= CR||LF; + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + DocGuid := thisStructuredNoteDoc.ClientDocumentGUID ; + allrulesprocessed := false; + Generic_SN_Parameter := first of (thisParameters where thisParameters.Name = "GenericSetObsDefaults"); + Generic_SN_Obs := first of (thisObservations where thisObservations.ParameterGUID = Generic_SN_Parameter.ParameterGUID); + Generic_SN_Rules := Generic_SN_Obs.ValueObj.Value; + fidcrlf := find CRLF in string Generic_SN_Rules; + ctlen := length of Generic_SN_Rules; + + ReplaceCRLF := ""; + for x in (fidcrlf seqto(ctlen)) do + + ReplaceCRLF := read {" select replace("|| sql(Generic_SN_Rules) || ",char(13)+char(10),{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}) "}; + fidcrlf := find CRLF in string ReplaceCRLF; + if fidcrlf = 0 then + fidcrlf := ctlen + 1; + endif; + + + enddo; + + if not (ReplaceCRLF[1] matches pattern "%|") then + ReplaceCRLF[1] := ReplaceCRLF[1] || "|"; + endif; + Rules_List := (); + Rules_Obs_Values := (); + SplitRulesFromValues := (); + SplitValuesFromSuggestedText := (); + + Rules_List := call string_parse with (ReplaceCRLF[1],"|"); + + for x in 1 seqto(count(Rules_List)) do + test2 := Rules_List[x]; + tstfind := find CRLF in string Rules_List[x]; + (SplitRulesFromValues) := call string_parse with (Rules_List[x],"~"); + Rules_Obs_Parameter := SplitRulesFromValues[1]; + testsplit := (SplitRulesFromValues[2] matches pattern "%{%"); + if(SplitRulesFromValues[2] matches pattern "%{%") then + SplitValuesFromSuggestedText := call string_parse with (SplitRulesFromValues[2],"{"); + (Rules_Obs_Values) := call string_parse with (SplitValuesFromSuggestedText[1],"^"); + Rules_Obs_SuggestedText := SplitValuesFromSuggestedText[2]; + else + (Rules_Obs_Values) := call string_parse with (SplitRulesFromValues[2],"^"); + Rules_Obs_SuggestedText := "";//SplitValuesFromSuggestedText[2]; + endif; + + IF(count(Rules_Obs_Values)>1) then + (thisDocumentCommunication) := CALL std_write_obs_MLM with (thisDocumentCommunication,Rules_Obs_Parameter,Rules_Obs_Values,Rules_Obs_SuggestedText,"Replace"); + else + (thisDocumentCommunication) := CALL std_write_obs_MLM with (thisDocumentCommunication,Rules_Obs_Parameter,Rules_Obs_Values[1],Rules_Obs_SuggestedText,"Replace"); + endif; + + enddo; + + if((Generic_SN_Rules <> "") and (allrulesprocessed)) then + (thisDocumentCommunication) := CALL std_write_obs_MLM with (thisDocumentCommunication,Generic_SN_Parameter.Name,"","","Replace"); + endif; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_DIABETESRISK.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_DIABETESRISK.mlm new file mode 100644 index 0000000..1bf71c3 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_DIABETESRISK.mlm @@ -0,0 +1,670 @@ +maintenance: + + title: Influenza Logic;; + mlmname: DOC_FUNC_DiabetesRisk;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Teresa Spicuzza;; + specialist: ;; + date: 2010-09-01;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 11.23.2010 TS Created - (copy of Doc_FuncPneumovax functionality) MLM checks health issues for diabetes + and checks to see if patient has a HGA1C in the past 3 months if not order placed via mlm. + + 10.11.2012 JML CSR 30961 - added code to automatically check an HIS defined "unhide" button that displays + additional questions regarding diabetes risk + 06.05.2013 JML CSR 30961 - removed coded section that "un-selects" the "SCHCK_Diabetes retrieve info SCM" + observation after user selects it; not allowing the obs to remain selected + was causing an issue with making that obs mandatory for RNs + 09.10.2015 DW CSR# 23359 - ICD10 + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + + // Receive arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + todays_date := now; + + + + + + +// Chart Observation Section + + +IF thisdocumentCommunication.EventType = "ChartObservation" then + + +// Determine if the Retrieve Info From SCM button has been selected +// (if so, set SCM flag to yes and reset the button or set the SCM flag to no) + + + theParameterx := first of (thisparameters where thisparameters.Name = "SCHCK_Diabetes retrieve info SCM"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameterx.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameterx.ParameterGUID then + + + //CSR 30961 retrieve Info from scm button checked, automatically check the {{{SINGLE-QUOTE}}}unhide{{{SINGLE-QUOTE}}} button + unhide_parametername := first of (thisParameters WHERE thisParameters.Name = "SCHCK_Diabetes Unhide"); + new_currentObj := NEW ObservationType; + new_currentObj.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + new_currentObj.ParameterGUID := unhide_parametername.ParameterGUID; + new_currentObj.DataType := "ListValue"; + new_currentObj.ValueObj := NEW ListValueType; + new_currentObj.ValueObj.ListGUID := unhide_parametername.ConfigurationObj.ListGUID; + new_listItems := (); + for item IN unhide_parametername.ConfigurationObj.ListItemsList do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + selectedItem.IsSelected := true; + + new_listItems := (new_listItems, selectedItem); + enddo; + new_currentObj.ValueObj.ListItemsList := new_listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, new_currentObj); + //End CSR code change + + SCMButton := "yes"; + else SCMButton := "no"; +endif; + + // Determine if the "HgA1C Order - Yes" button has been selected + + // (if so, set the SCMButton flag to neither and the "Place Order - Yes" button to yes) + + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Diabetes HgA1C order"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID then SCMButton := "neither"; endif; + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then PlaceOrderYesButton := "yes"; endif; + + + If SCMButton = "neither" and PlaceOrderYesButton = "yes" then + + + +// The following code is done only if the Place Order YES button was selected + + + + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n You cannot place an order on this patient. " ,"Alert","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Diabetes HgA1C order"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "yes" then selectedItem.IsSelected := false; endif; + if selectedItem.Value = "no" then selectedItem.IsSelected := true; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; + + + +// The following code is done only if a the Retrieve from SCM button was selected + +// (get data from SCM and populate fields) + + +If SCMButton = "yes" then + +// Diabetes health issues +/* + +"select distinct hid.shortname chi.code chi.typecode hid.typecode " +||"from cv3healthissuedeclaration hid with (nolock) " +||"join cv3codedhealthissue chi on chi.Guid = hid.codedhealthissueguid " +where clientvisitguid = {{{SINGLE-QUOTE}}}9000002831200270{{{SINGLE-QUOTE}}} and chi.typecode = {{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}}" +|| "where clientguid = " || ClientGuid || " and hid.active = 1 and hid.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " +|| "and chi.typecode = {{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}} ( " +*/ + +/* Replaced with ICD10 project + +(diabeteshealthissue) := read +{ +"select distinct hid.shortname, chi.code, chi.typecode, hid.typecode " +||"from cv3healthissuedeclaration hid with (nolock) " +||"join cv3codedhealthissue chi on chi.Guid = hid.codedhealthissueguid " +|| "where hid.clientguid = " || ClientGuid || " and hid.active = 1 and hid.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " +|| "and chi.typecode in ({{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Pt-Stated Hx{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Pt Stated HX{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}AMB Med History{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Problem-Visit{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Vaccine History{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Skin Tests{{{SINGLE-QUOTE}}}) " +|| "and (hid.text like {{{SINGLE-QUOTE}}}%Diabetes%{{{SINGLE-QUOTE}}} or hid.shortname like {{{SINGLE-QUOTE}}}%Diabetes%{{{SINGLE-QUOTE}}} )"|| " and chi.code not in ({{{SINGLE-QUOTE}}}250.50{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}253.2{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}253.5{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}352.3{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}354{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}362.29{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}588.1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.00{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.01{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.03{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.04{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}648.80{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}648.81{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}648.82{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}648.83{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}648.84{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}648.90{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}775.00{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}775.10{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}V12.2{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}V18.0{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}V19.8{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}V49.89{{{SINGLE-QUOTE}}}," +|| " {{{SINGLE-QUOTE}}}V77.1{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}V84.89{{{SINGLE-QUOTE}}})" +|| " and (hid.description not like {{{SINGLE-QUOTE}}}Diabetes, Gestational%{{{SINGLE-QUOTE}}} or hid.shortname not like {{{SINGLE-QUOTE}}}Diabetes, Gestational%{{{SINGLE-QUOTE}}}) " +}; +*/ + +ProblemList := "({{{SINGLE-QUOTE}}}250.50{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}253.2{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}253.5{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}352.3{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}354{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}362.29{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}588.1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.00{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.01{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.03{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.04{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.80{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.81{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.82{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.83{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.84{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.90{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}775.00{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}775.10{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}V12.2{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}V18.0{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}V19.8{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}V49.89{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}V77.1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}V84.89{{{SINGLE-QUOTE}}})"; + +(diabeteshealthissue) := read +{ +"select distinct hid.shortname, chi.code, chi.typecode, hid.typecode " +||"from cv3healthissuedeclaration hid with (nolock) " +||"join cv3codedhealthissue chi on chi.Guid = hid.codedhealthissueguid " +|| "where hid.clientguid = " || ClientGuid || " and hid.active = 1 and hid.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " +|| "and chi.typecode in ({{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}ICD10{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Pt-Stated Hx{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Pt Stated HX{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}AMB Med History{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Problem-Visit{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Vaccine History{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Skin Tests{{{SINGLE-QUOTE}}}) " +|| "and (hid.text like {{{SINGLE-QUOTE}}}%Diabetes%{{{SINGLE-QUOTE}}} or hid.shortname like {{{SINGLE-QUOTE}}}%Diabetes%{{{SINGLE-QUOTE}}} )" +|| "and " +|| "( " +|| "(hid.ICD9Code is null and chi.code not in " || ProblemList || " ) " +|| "or " +|| "(hid.ICD9Code is not null and hid.ICD9Code not in " || ProblemList || " ) " +|| ") " +|| " and (hid.description not like {{{SINGLE-QUOTE}}}Diabetes, Gestational%{{{SINGLE-QUOTE}}} or hid.shortname not like {{{SINGLE-QUOTE}}}Diabetes, Gestational%{{{SINGLE-QUOTE}}}) " +}; + + +diabeteshealthissue_found := count(diabeteshealthissue) As Number; + +// A1C Test performed + +(testperformed) := read last{ +"select significantdtm " +|| "from cv3order with (nolock) " +|| "where clientguid = " || ClientGuid || " and name = {{{SINGLE-QUOTE}}}Hemoglobin A1C{{{SINGLE-QUOTE}}} and active = 1 and orderstatuscode = {{{SINGLE-QUOTE}}}RESF{{{SINGLE-QUOTE}}} " +|| "order by significantdtm" +}; +testperformed_found := count(testperformed) As Number ; +testnote := ""; +//if (testperformed as time)is within the past 3 months then within3months := "Has been "; else within3months := "Has not been "; endif; +if (testperformed as time)is within the past 3 months then within3months := "Has been "; + testnote := "Patient has been tested in the past 3 months: " || testperformed; + else within3months := "Has not been "; + testnote:= "Patient has not been tested in the past 3 months. "; +endif; +// Populate Fields and Boxes + + + +// Select Health Issue radio button (or Health Issue unknown) + + healthissue := " "; + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Diabetes HI- unknown"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if diabeteshealthissue_found = 0 then selectedItem.IsSelected := true; healthissue := "Is unknown if "; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + If healthissue <> "Is unknown if " then + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Diabetes HI- y/n"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "yes" and diabeteshealthissue_found > 0 then selectedItem.IsSelected := true; healthissue := "Has a "; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + +// Select A1c done in past 3 months radio button (or test done unknown) + + labtests := " "; + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Diabetes HgA1C- unknown"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if within3months = "Has not been " then selectedItem.IsSelected := true; labtests := "Is unknown if "; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + If within3months = "Has been " then + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Diabetes HgA1C- y/n"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "yes" then selectedItem.IsSelected := true; labtests := "Is "; endif; + listItems := (listItems, selectedItem); + + + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + +// new for check lab as no + + If within3months = "Has not been " then + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Diabetes HgA1C- y/n"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "no" then selectedItem.IsSelected := true; labtests := "Is not "; endif; + listItems := (listItems, selectedItem); + + + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; +// Prepare the data for the Diabetes Health Issue and A1C performed boxes + + + holdHI:=""; + if diabeteshealthissue_found > 0 then + for k in (1 seqto (diabeteshealthissue_found)) do + if diabeteshealthissue[k] is not null then + holdHI := holdHI || diabeteshealthissue[k] ; + if k <> diabeteshealthissue_found then // not the last in the list + holdHI := holdHI || ", "; + endif; + endif; + enddo; + endif; + if holdHI = "" then formattedTextHI := " Nothing found. Does the patient have diabetes? "; + else formattedtextHi := holdHI; + endif; + + + holdHI:=""; + if testperformed_found > 0 then + for k in (1 seqto (testperformed_found )) do + if testperformed[k] is not null then + holdHI := holdHI || testperformed[k] ; + if k <> testperformed_found then // not the last in the list + holdHI := holdHI || ", "; + endif; + endif; + enddo; + endif; + if holdHI = "" then formattedTextTest := " Nothing found. Has the patient had a HgA1C performed? "; + else formattedTextTest := testnote; + endif; + + + +// Populate the Health Issue text box + + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Diabetes HI-FT"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := formattedTextHI; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + +// Populate the A1c performed text box + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Diabetes Hga1c- FT"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := formattedTextTest; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + +// The following code is performed only if a button other than the Retrieve from SCM button was selected +// +// Since it appears that the checking of buttons does not occur until the end, +// this section it to be done only when not SCM button +// + + + elseIf SCMButton = "no" then + + +// Determine which of the Health Issue buttons is selected + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Diabetes HI- y/n"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no") + then healthissue := "Does not have "; endif; + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then healthissue := "Has a "; endif; + + if false in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + and + false in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no") + then + healthissue := "Is unknown if "; endif; + + + +// Determine which of the A1C Perfomred buttons is selected + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Diabetes HgA1C- y/n"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no") + then labtests := "Is not "; endif; + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then labtests := "Is "; endif; + + if false in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + and + false in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no") + then + labtests := "Is unknown if "; endif; + + endif; // If not the SCM button + + + if SCMButton = "yes" or SCMButton = "no" then + + + +// The following code is done regardless of whether the Retrieve from SCM button or other button was selected + +// (this excludes the place order yes button) + + + +// Determine if test was performed within the past 3 months +//testnote:= ""; +if (testperformed as time)is within the past 3 months then within3months := "Has been "; + testnote := "Patient has been tested in the past 3 months: " || testperformed; + else within3months := "Has not been "; + testnote:= "Patient has not been tested in the past 3 months. "; +endif; +// Assess the risk +/* +// This secton as well as the FormattedText1 := below are for diagnostic purposes only + +Factor1 := scmbutton || ": value of scmbutton. "; +Factor2 := diabeteshealthissue || ": diabetes health issue. "; +Factor3 := diabeteshealthissue_found || ": dhi found. "; +Factor4 := labtests || ": labtests. "; +Factor5 := healthissue || ": healthissue. "; +Factor6 := within3months || ": Within3months. "; +Factor7 := testperformed_found || ": tp found. "; +Factor8 := formattedtextHi || ": value of formattedtextHI. " ; +Factor9 := formattedtexttest|| ": value of formattedtexttest. " ; +formattedTextReason := " Risk was not determined. "; +orderlab := "no"; + +formattedText1 := Factor1 ||"\n " || Factor4 || "\n " || Factor5 || "\n " || Factor6 ; +// Populate (HIS only) Diagnostic box + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Pneumo FT info"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := formattedText1; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); +*/ + //Scenarios that will cause an order to be placed +If healthissue = "Has a " and (within3months = "Has not been " and labtests = "Is not ") then orderlab := "yes"; +formattedTextReason := "Order is to be placed since patient is a diabetic and has not been tested in the past 3 months." ; endif; + +If healthissue = "Has a " and (within3months = "Has been " or labtests = "Is ") then orderlab := "no"; +formattedTextReason := "Order is not to be placed since patient is a diabetic but has been tested in the past 3 months." ; endif; + +If healthissue <> "Has a " then orderlab := "no"; +formattedTextReason := "Order is not to be placed since patient is not diabetic." ; endif; + +If healthissue = "Is unknown if " then orderlab := "no"; +formattedTextReason := " Risk was not determined. " ; endif; + +// Populate the Risk Details box /* + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Diabetes Risk Assess Details"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := formattedTextReason; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + +// Select Order A1C radio button + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Diabetes HgA1C order"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "yes" and orderlab = "yes" then selectedItem.IsSelected := true; endif; + if selectedItem.Value = "no" and orderlab = "no" then selectedItem.IsSelected := true; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; // end of section for assessing risk + +// Display error message when Health Issue or A1C performed is unknown + + If healthissue = "Is unknown if " and labtests = "Is unknown if " then + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with + "\n\n There are no Health Issues in SCM indicating that the patient has diabetes or has had an HgA1C in the past 3 months." + || "\n\n Please address these questions with the patient and select the appropriate button for each of these. \n\n " + ,"Un-addressed information to be resolved ","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + + If healthissue <> "Is unknown if " and labtests = "Is unknown if " then + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with + "\n\n There are no indications in SCM that the patient has had an HgA1C in the past 3 months" + || "\n\n Please address this question with the patient and select the appropriate button. \n\n" + ,"Un-addressed information to be resolved ","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + + If healthissue = "Is unknown if " and labtests <> "Is unknown if " then + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with + "\n\n There are no Health Issues in SCM indicating that the patient has diabetes" + || "\n\n Please address this question with the patient and select the appropriate button. \n\n" + ,"Un-addressed information to be resolved ","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + +endif; // Observation Event + + +// Document Closing Event + + +IF thisdocumentCommunication.EventType = "DocumentClosing" then + + +// Determine if an order is to be placed + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Diabetes HgA1C order"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no") + then placeorder := "no"; endif; + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then placeorder := "yes"; endif; + +// Order present + + (orderpresent) := read + { + " select o.name " +|| " from cv3ordercatalogmasteritem as ocmi with (nolock) " +|| " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid " +|| " and o.ClientGUID = " || ClientGuid || " and o.ChartGUID = " || ChartGuid || " and o.ClientVisitGUID= " || VisitGuid || " " +|| " and (o.name = {{{SINGLE-QUOTE}}}Hemoglobin A1C{{{SINGLE-QUOTE}}}) " +|| " and o.OrderStatusLevelNum > 15 and o.OrderStatusLevelNum not in ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}}) " + }; +orderpresent_found := count(orderpresent) As Number; + If placeorder = "yes" and orderpresent_found = 0 then + + SessionType := "Standard"; + SessionReason := ""; + RequestingSource := ""; + user_IDType := "Edstan Number (physician)"; + order_Creation_Reason := "From Test MLM"; + + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((thisdocumentCommunication.ClientVisitGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + user_IDCode := read last {"SELECT IDCode FROM CV3User " || " where GUID = " || thisdocumentCommunication.UserGUID}; + RequestingCareProvider_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindById with ( user_IDType, (user_IDCode as STRING) ); + location_guid := read last {"SELECT CurrentLocationGUID FROM CV3ClientVisit where ClientGUID = " || thisdocumentCommunication.ClientGUID}; + location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((location_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + + // Create a new MEDICATION order from a Pre-Filled item *** + try + Catalog_Item_Name := "Hemoglobin A1C"; + Catalog_Item_Modifier := "Per Risk Assessment"; + Catalog_Item_Version := ""; + Laboratory_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with Catalog_Item_Name; + Parent_DiagnosticOrder_obj := call {{{SINGLE-QUOTE}}}DiagnosticOrder{{{SINGLE-QUOTE}}}.CreateDiagnosticOrder + // PreFilled_MedicationOrder_obj := call {{{SINGLE-QUOTE}}}MedicationOrder{{{SINGLE-QUOTE}}}.CreateMedicationOrder + with + client_visit_obj, // ClientVisit ObjectsPlus object + // Medication_catalog_item, // OrderCatalogMasterItem ObjectsPlus object + Laboratory_catalog_item, // OrderCatalogMasterItem ObjectsPlus object + Catalog_Item_Modifier, // string ItemNameModifier + Catalog_Item_Version, // string ItemNameModifierVersion + order_Creation_Reason, // string CreateReason + RequestingCareProvider_obj , // RequestedBy ObjectsPlus object + RequestingSource, // string RequestedBySource (must be in dictionary) + SessionType, // string SessionType + SessionReason, // string SessionReason + location_obj, // Location ReleaseLocGrpID + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; // AvailabilityOverride eAvailabilityOverride + + + if ( Laboratory_catalog_item is NOT NULL ) then + void := call Parent_DiagnosticOrder_obj.Save; + void := call Parent_DiagnosticOrder_obj.Dispose; + void:= call Laboratory_catalog_item.Dispose; + Laboratory_catalog_item:= null; + + + endif; + +// Parent_DiagnositicOrder_dest.ObjectsPlus := Parent_DiagnositicOrder_obj; + + endtry; + + catch Exception ex error_occurred := true; error_message := "{{+R}}New Parent Diagnostic order:{{-R}}\n" || ex.Message || "\n\n"; + + if ( Laboratory_catalog_item is NOT NULL ) then void:= call Laboratory_catalog_item.Dispose; Laboratory_catalog_item:= null; endif; + if ( Parent_DiagnosticOrder_obj is NOT NULL ) then void:= call Parent_DiagnosticOrder_obj.Dispose; Parent_DiagnosticOrder_obj:= null; endif; + + Parent_DiagnosticOrder_dest := null; + + endcatch; + + endif; // End of Place Order = Yes section + + endif; // End of Close Document + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_DIABETES_ASSESSMT_OUTPATIENT.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_DIABETES_ASSESSMT_OUTPATIENT.mlm new file mode 100644 index 0000000..0e6dcbf --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_DIABETES_ASSESSMT_OUTPATIENT.mlm @@ -0,0 +1,133 @@ +maintenance: + + title: Doc_Func_Diabetes_Assessmt_Outpatient ;; + filename: Doc_Func_Diabetes_Assessmt_Outpatient;; + arden: version 2;; + version: 1.00;; + institution: Allscripts Corp;; + author: Shivprasad Jadhav ;; + specialist: Maya/Shubha ;; + date: 2012-05-11;; + validation: testing;; + +library: + purpose: This MLM will populate the Value in {{{SINGLE-QUOTE}}}Vial and Syring method{{{SINGLE-QUOTE}}} when user select Yes in Instructed patient action for Insulin in Diabetic Assessment Outpatient SN. + ;; + explanation: This MLM will populate the Value in {{{SINGLE-QUOTE}}}Vial and Syring method{{{SINGLE-QUOTE}}} when user select Yes in Instructed patient action for Insulin. + + Change history + + 01.27.2017 SJ Created CSR # 35130- Created under 16.3 transformation of Aware Note to St. Note. + + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + (this_documentCommunication) := argument; + /*******************Make Changes To Spelling And Flags In This Section*******************/ + + /* Set to true if a decision.log is needed.*/ + 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"; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + +// Reset the launch button + + theParameterx := first of (thisparameters where thisparameters.Name = "SCH_diab Edu Insulin syringe method new"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameterx.ParameterGUID); //"SCH_Diab edu Vial & Syring Method FT" + + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Yes") + then Insulin1 := "yes"; + else Insulin1 := "no"; + endif; + + theParameter1 := first of (thisparameters where thisparameters.Name = "SCH_diab Edu Ijecting insulin pen"); + theObservation1 := first of (thisobservations where thisobservations.ParameterGUID = theParameter1.ParameterGUID); + + if true in (theObservation1.ValueObj.ListItemsList.IsSelected where theObservation1.ValueObj.ListItemsList.Value = "Yes") + then Insulin2 := "yes"; + else Insulin2 := "no"; + endif; + + /* To Format the String value in Free Text Box */ + CR := 13 formatted with "%c"; + LF := 10 formatted with "%c"; + CRLF:= CR||LF; + + Var1 := "Vial and Syringe Method: " + ||CRLF|| " Cloudy insulin (NPH or premixed only) should be gently mixed by rolling via between hands. Remove lid from top of insulin vial and wipe rubber top with alcohol. " + ||CRLF|| " Remove plastic needle cap. Pull back plunger of the syringe to the number of units. Inject air from syringe into vial and leave needle in vial. " + ||CRLF|| " Turn vial upside down holding syringe and needle in place. Pull plunger back to draw correct number of units of insulin into syringe. " + ||CRLF|| " Check for bubbles and push air out of syringe back into vial. Adjust plunger to ensure correct number of units of insulin are in syringe proper injection technique." + ||CRLF|| " Site rotation. Storage and expiration of insulin. Appropriate disposal of sharps."; + Var2 := "Insulin Pen Method: " + ||CRLF|| "Clean tip of pen. Attach the pen needle. Perform safety shot. Dial the correct dose. Proper injection technique. Site rotation. " + ||CRLF|| "Storage and expiration appropriate disposal of sharps."; + MLM_DIPA := MLM {{{SINGLE-QUOTE}}}UTIL_OBJECT_Customize_DIPA_MLM{{{SINGLE-QUOTE}}}; + prm_Vial := First of (thisParameters where thisParameters.Name = "SCH_Diab edu Vial & Syring Method FT"); + + /* Setting the Value to actual Observation */ + If Insulin1 = "yes" Then + + Obs_Edu_Vial := CALL MLM_DIPA WITH this_DocumentCommunication,prm_Vial, Var1 as string ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList,Obs_Edu_Vial ); + Else + Obs_Edu_Vial := CALL MLM_DIPA WITH this_DocumentCommunication,prm_Vial, "" as string ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList,Obs_Edu_Vial ); + + Endif; + prm_Vial1 := First of (thisParameters where thisParameters.Name = "SCH_Diab edu Insulin Pen Method FT"); + + If Insulin2 = "yes" Then + + Obs_Edu_Vial1 := CALL MLM_DIPA WITH this_DocumentCommunication,prm_Vial1, Var2 as string ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList,Obs_Edu_Vial1 ); + Else + Obs_Edu_Vial1 := CALL MLM_DIPA WITH this_DocumentCommunication,prm_Vial1, "" as string ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList,Obs_Edu_Vial1 ); + + Endif; + + + + + ;; + evoke: // No evoke statement + ;; + logic: + + + + conclude true; // always concludes TRUE + ;; + action: + return this_documentCommunication; + + ;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_DIABETES_SERVICE_TIME_CALCULATION.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_DIABETES_SERVICE_TIME_CALCULATION.mlm new file mode 100644 index 0000000..e38f491 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_DIABETES_SERVICE_TIME_CALCULATION.mlm @@ -0,0 +1,140 @@ +maintenance: + + title: DOC_FUNC_DIABETES_SERVICE_TIME_CALCULATION;; + mlmname: DOC_FUNC_DIABETES_SERVICE_TIME_CALCULATION;; + arden: version 5.5;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Maya Poojari and Janet Nordin;; + specialist: Don Warnick;; + date: 2011-06-06;; + validation: testing;; + +library: + purpose: This MLM will subtract 2 time fields to determine duration. + + ;; + explanation: + + Change history + + 08.30.2016 DW CSR# 34994 Diabetes Assessment - Created + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + NumericValueType := OBJECT [Value]; + + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + // Gather the Arrival and Departure Date/Time entered by the user + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_FB_Arrival time"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = this_parametername.ParameterGUID); + arrivaltime := theObservation.ValueObj.Value; + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_FB_Departure Time"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = this_parametername.ParameterGUID); + departuretime := theObservation.ValueObj.Value; + + // Subtract the times, parse out the seconds value and convert that value to a number (difference returned as "X months, X seconds" + + duration_with_verbiage:= departuretime - arrivaltime; + only_time_length := ((FIND "se" IN STRING (duration_with_verbiage as string))- (FIND "," IN STRING (duration_with_verbiage as string))-1); + duration_seconds := SUBSTRING only_time_length CHARACTERS STARTING AT ((FIND "," IN STRING (duration_with_verbiage as string)) + 1) from (duration_with_verbiage as string); + duration_seconds_number := duration_seconds as number; + + // If both time fields are populated and are not equal, determine which service was rendered and determine the number of service units delivered + + if arrivaltime is not null and departuretime is not null and duration_seconds_number > 0 + + then + If duration_seconds_number < 14401 + + then + theParameter := first of (thisparameters where thisparameters.Name = "SCH_GCDD_ Type of Encounter"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Diabetes Self-Management Education (DSME)") + then + service_increment:= 30; + endif; + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Medical Nutrition Therapy (MNT)") + then + service_increment:= 15; + endif; + + duration_minutes := duration_seconds_number /60; + service_units := truncate(duration_minutes /service_increment); + + else + duration_minutes := 0; + service_units := 0; + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "The visit time is greater than 4 hours. Please verify the accuracy of the date fields." ,"Error","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + + // Update the duration field + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_FB_Total Visit Time_NU"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "NumericValue"; + this_currentObj.ValueObj := New NumericValueType; + this_currentObj.ValueObj.Value := duration_minutes; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + // Update the units of service field + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_FB_Total Unit Time_GN"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "NumericValue"; + this_currentObj.ValueObj := New NumericValueType; + this_currentObj.ValueObj.Value := service_units; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_DISCHARGE_DIAG.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_DISCHARGE_DIAG.mlm new file mode 100644 index 0000000..c103619 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_DISCHARGE_DIAG.mlm @@ -0,0 +1,99 @@ +maintenance: + + title: ;; + mlmname: DOC_FUNC_DISCHARGE_DIAG;; + arden: version 2.5;; + version: 0.00;; + institution: ;; + author: ;; + specialist: ;; + date: 2012-11-05;; + validation: testing;; + +library: + purpose: Pull the discharge diagnosis from progress notes using SQL/SP "SCH_PHCO_DCInst_SUB_Discharge_Diag" + This MLM will limit the results to the "ProgressNote" entries excluding the items added to the health issue type Discharge Diag + and will then update the discharge instructions (post hospital care orders) document to show the discharge diag from progress notes + ;; + explanation: + 4/16/2013 - CSR #: 31547 - Update MLM and stored procedure to pull from the discharge order observation also. + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + //Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructeredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + + + IF thisdocumentCommunication.EventType = "DocumentOpening" then + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + clientvisitGuid := thisDocumentCommunication.ClientVisitGUID; + + group1 := (); + group2 := (); + healthissues := (); + locationentered := (); + returnhealthissues := (); + + If called_by_editor then + clientvisitguid := "0"; + endif; + + + ( group1, group2, healthissues, locationentered ) := read { "EXEC SCH_PHCO_DCInst_SUB_Discharge_Diag {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}},"|| sql(clientvisitGuid)};//|| SQL(current_status) }; + for x in (1 seqto (count(healthissues))) do + if locationentered[x] = "ProgressNote" or locationentered[x] = "DischargeOrder" then + if (length(returnhealthissues) > 0) then + returnhealthissues := returnhealthissues || ", " || healthissues[x]; + else + returnhealthissues := healthissues[x]; + endif; + endif; + enddo; + + // Create our observation and give it back to the structured note + DischargeDiag := first of (thisParameters where thisParameters.Name = "SCHCK_DI_Diagnosis from PN"); + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := DischargeDiag.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := returnhealthissues as string; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + endif; + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_DISCHARGE_SUMMARY.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_DISCHARGE_SUMMARY.mlm new file mode 100644 index 0000000..ae5f9a2 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_DISCHARGE_SUMMARY.mlm @@ -0,0 +1,112 @@ +maintenance: + + title: DOC_FUNC_DISCHARGE_SUMMARY ;; + mlmname: DOC_FUNC_DISCHARGE_SUMMARY;; + arden: version 2.5;; + version: 0.00;; + institution: St. Clair Hospital;; + author: Shawn Head x7468;; + specialist: Shawn Head x7468;; + date: 2015-05-01;; + validation: testing;; + +library: + purpose: Create a Discharge Summary report request for completed electronic Discharge summaries. + ;; + explanation: This MLM will check to see if the Discharge Order Reconciliation is completed BEFORE allowing the patient discharge instructions, CCDA, and Discharge Summary are printed/created. + If Discharged Order Reconciliation is incomplete when the user clicks the "Print and send with patient" observation on the Discharge Instructions structured note they will get a + prompt letting them know you cannot print the discharge instructions until order reconciliation is completed. + History + 5-1-2015 - STH CSR#: 32070 (DEV) - Created MLM - Loaded to PROD 6-2-2015 + 10.26.2015 STH Support case 1917862 - issue with clinic visits requing order rec completion + ;; + keywords: + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + + //void := CALL Print_DC_Summary with (clientguid,chartguid,visitguid,"Day of Discharge%"); + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + (VisitType) := read {"select top 1 typecode from cv3clientvisit with (nolock) " + || " where clientguid = " || sql(clientGuid) + || " and chartguid = " || sql(chartGuid) + || " and guid = " || sql(visitGuid)}; + + + theParameter := first of (thisparameters where thisparameters.Name = "CXD Transition Care Print"); + theObservation:= first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + dc_orderrec_GUID := read last {"select guid from CV3OrderReconcile with (nolock) " + || " where clientguid = " || sql(ClientGuid) + || " and chartguid = " || sql(ChartGuid) + || " and ClientVisitGUID = " || sql(VisitGuid) + || " and reconciletypecode = {{{SINGLE-QUOTE}}}discharge{{{SINGLE-QUOTE}}} " + || " and ReconcileStatusType = 2 "}; + + if (((dc_orderrec_guid is null) or (dc_orderrec_guid = "")) and (trim(VisitType[1]) is in ("Inpatient","Observation"))) then + + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "You cannot print the patient discharge instructions until Discharge Order Reconciliation is complete." + ,"Discharge Order Reconciliation Incomplete","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}},"Button1" as {{{SINGLE-QUOTE}}}MessageBoxDefaultButton{{{SINGLE-QUOTE}}}; + resulttext := dialogResult as string; + + /*--If they decide they want to allow the user to launch order reconciliation from this error message we can use the logic below to match what appears when the document is opened. This includes the prompt to launch order rec. + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "Discharge Order Reconciliation is INCOMPLETE. You cannot print the patient’s Discharge Instructions until the Discharge Order Reconciliation is completed. Do you want to launch Order Reconciliation now?" + ,"Discharge Order Reconciliation Incomplete","YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}},"Button1" as {{{SINGLE-QUOTE}}}MessageBoxDefaultButton{{{SINGLE-QUOTE}}}; + + resulttext := dialogResult as string; + + if resulttext = "Yes" then + (thisDocumentCommunication) := argument; + OpenMedRec := MLM {{{SINGLE-QUOTE}}}DOC_Call_Med_Rec{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL OpenMedRec WITH thisDocumentCommunication; + endif; + */ + + for x in 1 seqto(count(theObservation.ValueObj.ListItemsList.IsSelected)) do + if theObservation.ValueObj.ListItemsList[x].Value = "Print and Send With Patient" then + theObservation.ValueObj.ListItemsList[x].IsSelected := false; + endif; + enddo; + endif; + + + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_ED_BEDSIDE_SWALLOWING_ALERT.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_ED_BEDSIDE_SWALLOWING_ALERT.mlm new file mode 100644 index 0000000..f8e7c7a --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_ED_BEDSIDE_SWALLOWING_ALERT.mlm @@ -0,0 +1,107 @@ +maintenance: + + title: DOC_FUNC_ED_BEDSIDE_SWALLOWING_ALERT;; + mlmname: DOC_FUNC_ED_BEDSIDE_SWALLOWING_ALERT;; + arden: version 2.5;; + version: 5.50;; + institution: Allscripts;; + author: Juliet M. Law ;; + specialist: ;; + date: 2013-06-20;; + validation: testing;; + +library: + purpose: Alert on failure to indicate bedside swallowing risk on NIH Stroke Scale + ;; + explanation: On the ED Adult Assessment/Intervention Flowsheet, if the flowsheet contains a full exam score for + NIH Stroke Scale and the user fails to answer the Bedside Swallowing screen, then display + alert and do not allow save of flowsheet. + ;; + keywords: NIH Stroke, alert, flowsheet + ;; +knowledge: + type: data-driven;; + data: + + (this_documentCommunication) := argument; + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + //Called MLMs to set up the CDS and return obs values + set_cds_vars := MLM {{{SINGLE-QUOTE}}}CALLED_DOC_FS_DEFINITION_MLM{{{SINGLE-QUOTE}}}; + read_obs_value := MLM {{{SINGLE-QUOTE}}}CALLED_DOC_FS_OBS_VALUE_MLM{{{SINGLE-QUOTE}}}; + + + /**************Make Changes To Spelling And Flags In This Section**************/ + //Set up variables; initialize + nihStroke_Score_param := "AS SC nih ss total CAL"; + bedsideSwallow_Risk_param := "sch_ed_SCHCK_NIH Remain Awake"; + + msg := ""; + + mlm_name := "DOC_FUNC_ED_BEDSIDE_SWALLOWING_ALERT"; + + //Set constants indicating document type and event + FLOWSHEET := "Flowsheet"; + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTCLOSING := "DocumentClosing"; + + /******************************************************************************/ + + //Initialize DocumentCommunication objects + (this_documentCommunication, client_guid, client_visit_guid, chart_guid, + user_guid, document_type, document_name, event_type, + configuration_guid, this_currentObs, CancelEventFlag, this_fs_doc, + authored_by_guid, isIOFlowsheetFlag, client_document_guid, this_parameters, + this_columnList, this_currentColumn, this_chartedObservationsList, + this_parameters_displayName, current_parameter, current_parameter_name, current_parameter_guid, + current_parameter_datatype, selectedItems, selectedItems_Value, current_value, + diagnostic_message, displayMessageFlag) := call set_cds_vars WITH (this_documentCommunication); + + //Retrieve DocumentType (StructuredNote or Flowsheet) and EventType + this_DocumentType := this_documentCommunication.DocumentType; + this_EventType := this_documentCommunication.EventType; + + /* Get the current user{{{SINGLE-QUOTE}}}s occupation*/ + UserCode := read last + {"Select occupationcode " + ||" From cv3user " + ||" Where Guid = " || SQL(user_guid) }; + + //Process logic on Flowsheets when document is closing + if (this_DocumentType = FLOWSHEET AND this_EventType = DOCUMENTCLOSING AND UserCode IN ("RN","LPN","CNA","IT")) then + //Retrieve the NIH Stroke Scale Full Exam Score + theParameter := first of (this_parameters WHERE this_parameters.Name = nihStroke_Score_param); + + if (exists theParameter) then + (this_documentCommunication, selectedValue, currentValue) := CALL read_obs_value WITH (this_documentCommunication, theParameter.Name, "Read"); + + if (currentValue > 0) then + //Retrieve bedside swallowing risk parameter + bsParameter := first of (this_parameters WHERE this_parameters.Name = bedsideSwallow_Risk_param); + + if (exists bsParameter) then + (this_documentCommunication, selectedValue, currentValue) := CALL read_obs_value WITH (this_documentCommunication, bsParameter.Name, "Read"); + + if (not exists selectedValue) then + msg := "Please complete the Bedside Swallowing Screen."; + dialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with msg, "Bedside Swallowing Screen", "Ok" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + endif; + endif; + endif; + endif; + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: + return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_EPN_ALERTS.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_EPN_ALERTS.mlm new file mode 100644 index 0000000..d4fa20f --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_EPN_ALERTS.mlm @@ -0,0 +1,352 @@ +maintenance: + + title: DOC_FUNC_EPN_ALERTS;; + mlmname: DOC_FUNC_EPN_ALERTS;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Don Warnick;; + specialist: Don Warnick ;; + date: 2010-02-02;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 10.20.2014 DW CSR# 32746 - (Alert for missing VTE order) & 32675 (Altert for incomplete or missing Admission ORM) + 10.23.2015 DW CSR# 32874 - Alert the Pulumonary Specialists when an ICU patient has an active Ventilator order, but does not have and active Chest Medical Imaging order. + 12.16.2015 DW CSR# 33655 - Previnar + 02.09.2016 DW CSR# 33949 - Add Code Status and CPR order review + 10.05.2017 JML CSR# 26413 - Modified for Code Status changes based on DOH + 11.03.2017 JML CSR# 26413 - Eliminating Outpatients and Discharged patients from receiving code status alert + 09.28.2018 DW CSR# 36715 - Created - PDMP in order session + + + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + using "CustomCodeStatusAlert"; + using namespace "CustomCodeStatusAlert"; + + (OccCode, RoleType) := read last {" select OccupationCode, OrderRoleType from CV3USER with (nolock) where guid = " || sql(userGuid) }; + + //Get Visit Status + ( visitStatus, + visitType) := read last { "SELECT cv.VisitStatus, cv.TypeCode FROM CV3ClientVisit cv WHERE cv.GUID = " || SQL(visitGuid) }; + + // Code Status Order Section + (CodeStatusOrder, + CodeStatusType) := read {"SELECT ocmi.Name, CASE WHEN ocmi.Name IN ({{{SINGLE-QUOTE}}}Code Status: Comfort Measures Only{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}Code Status: Limited Interventions{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Code Status: Full Treatment{{{SINGLE-QUOTE}}}) THEN {{{SINGLE-QUOTE}}}CODE STATUS{{{SINGLE-QUOTE}}}" + || " WHEN ocmi.Name = {{{SINGLE-QUOTE}}}Code Status: Ethically unable to determine{{{SINGLE-QUOTE}}} THEN {{{SINGLE-QUOTE}}}CODE STATUS ND{{{SINGLE-QUOTE}}}" + || " WHEN ocmi.Name IN ({{{SINGLE-QUOTE}}}CPR/Attempt Resuscitation{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}DNR/Do Not Attempt Resuscitation{{{SINGLE-QUOTE}}}) THEN {{{SINGLE-QUOTE}}}CPR{{{SINGLE-QUOTE}}}" + || " ELSE {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}" + || " END" + || " FROM CV3OrderCatalogMasterItem ocmi with (nolock) JOIN CV3Order o with (nolock)" + || " ON o.OrderCatalogMasterItemGUID = ocmi.GUID" + || " AND o.ClientGUID = " || SQL(ClientGuid) + || " AND o.ClientVisitGUID = " || SQL(VisitGuid) + || " AND o.ChartGUID = " || SQL(ChartGuid) + || " WHERE ( ocmi.Name IN ({{{SINGLE-QUOTE}}}CPR/Attempt Resuscitation{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}DNR/Do Not Attempt Resuscitation{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Code Status: Comfort Measures Only{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}Code Status: Limited Interventions{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Code Status: Full Treatment{{{SINGLE-QUOTE}}})" + || " OR ocmi.Name = {{{SINGLE-QUOTE}}}Code Status: Ethically unable to determine{{{SINGLE-QUOTE}}} )" + || " AND o.OrderStatusLevelNum >= 15 " + || " AND o.OrderStatusLevelNum not in (69, 70) "}; + + + + // DOCUMENT OPEN + if thisdocumentCommunication.EventType = "DocumentOpening" then + + // Admission ORM Section + (AdmORMStatus) := read last + { + " select " + || " (SELECT enumrefvalue FROM SCH_EnumRef_LookUp_FN({{{SINGLE-QUOTE}}}CV3ORDERRECONCILE{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}reconcilestatustype{{{SINGLE-QUOTE}}},reconcilestatustype)) as {{{SINGLE-QUOTE}}}reconcile_status{{{SINGLE-QUOTE}}} " + || " from CV3ORDERRECONCILE with (nolock) " + || " where chartguid = " || ChartGuid || " and clientguid = " || ClientGuid || " and clientvisitguid = " || VisitGuid || " and ReconcileTypeCode = {{{SINGLE-QUOTE}}}admission{{{SINGLE-QUOTE}}}" + }; + +/* + (CPROrder) := read last + { + " select ocmi.Name " + || " from cv3ordercatalogmasteritem as ocmi with (nolock) " + || " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid " + || " and o.chartguid = " || ChartGuid || " and o.clientguid = " || ClientGuid || " and o.clientvisitguid = " || VisitGuid || " " + || " and o.OrderStatusLevelNum >= 15 and o.OrderStatusLevelNum not in (69, 70) " + || " where (ocmi.name like {{{SINGLE-QUOTE}}}CPR%{{{SINGLE-QUOTE}}} or ocmi.name like {{{SINGLE-QUOTE}}}DNR%{{{SINGLE-QUOTE}}} ) " + }; +*/ + // Ventilator Order Section + + (VentilatorOrder) := read last + { + " select ocmi.Name " + || " from cv3ordercatalogmasteritem as ocmi with (nolock) " + || " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid " + || " and o.chartguid = " || ChartGuid || " and o.clientguid = " || ClientGuid || " and o.clientvisitguid = " || VisitGuid || " " + || " and o.OrderStatusLevelNum >= 15 and o.OrderStatusLevelNum not in (69, 70) " + || " where ocmi.name = {{{SINGLE-QUOTE}}}ventilator{{{SINGLE-QUOTE}}} " + }; + + (ChestOrder) := read last + { + " select ocmi.Name " + || " from cv3ordercatalogmasteritem as ocmi with (nolock) " + || " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid " + || " and o.chartguid = " || ChartGuid || " and o.clientguid = " || ClientGuid || " and o.clientvisitguid = " || VisitGuid || " " + || " and o.OrderStatusLevelNum >= 15 and o.OrderStatusLevelNum not in (69, 70) " + || " and o.RepeatOrder <> 1 " + || " where ocmi.name = {{{SINGLE-QUOTE}}}Chest Portable{{{SINGLE-QUOTE}}}" + }; + + + CurrentLocation := read last {"Select CurrentLocation FROM CV3ClientVisit with (nolock) where currentlocation like {{{SINGLE-QUOTE}}}icu%{{{SINGLE-QUOTE}}} and ClientGUID = " || thisdocumentCommunication.ClientGUID}; + Specialty := read last {"Select Discipline from CV3CareProvider with (nolock) where TypeCode = {{{SINGLE-QUOTE}}}physician{{{SINGLE-QUOTE}}} and discipline like {{{SINGLE-QUOTE}}}%pulmonary%{{{SINGLE-QUOTE}}} and guid = " || thisDocumentCommunication.UserGUID}; + + + // PDMP Search Section + + + PatientAge := read last + {" + select case when + right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (datepart (MM,getdate()) as varchar),2) + right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (datepart (DD,getdate()) as varchar),2) < + right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (birthmonthnum as varchar),2) + right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (birthdaynum as varchar),2) + then datediff (yy, cast (birthyearnum as varchar) ,getdate()) -1 + else datediff (yy, cast (birthyearnum as varchar) ,getdate()) + end + from cv3client with (nolock) where guid = " || clientGuid || " + "}; + + + If patientage > 0 + + + then + + Opiods_BenzosFound := " "; + + SignificantEvent := read last + {" + select c.text + from CV3ClientEventDeclaration c with (nolock) + where c.TypeCode = {{{SINGLE-QUOTE}}}PDMP{{{SINGLE-QUOTE}}} and c.status = {{{SINGLE-QUOTE}}}active{{{SINGLE-QUOTE}}} and c.text like {{{SINGLE-QUOTE}}}%:%{{{SINGLE-QUOTE}}} + and c.ClientGUID = " || ClientGuid || " and c.clientvisitguid = " || VisitGuid || " and c.chartguid = " || ChartGuid || " + order by c.CreatedWhen + "}; + + if not exist SignificantEvent + + then + + (Opiods_Benzos) := read + { " + select distinct gn.DrugCatalogKey + from SXAAMBDrugName bn with (nolock) + join SXAAMBGenericNameDrugNameXRef dnx with (nolock) on dnx.DrugNameID = bn.DrugNameID + join SXARxGenericName gn with (nolock) on gn.GenericNameID = dnx.GenericNameID + join SXAAMBDrugCategoryXRef xr with (nolock) on gn.GenericNameID = xr.GenericNameID + join SXAAMBDrugCategory dc with (nolock) on xr.DrugCategoryID = dc.DrugCategoryID + where dc.CategoryName in ({{{SINGLE-QUOTE}}}Benzodiazepines{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}narcotic analgesics{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}narcotic analgesic combinations{{{SINGLE-QUOTE}}}) + "}; + + + (PatientMedDrugID, PatientMedName, PatientMedOrderInfo ) := read + { " + SET CONCAT_NULL_YIELDS_NULL off + select dm.DrugKey, ocmi.Name, convert(char(11),o.Entered,101) + convert(char(5),o.Entered,108) + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + substring (u.FirstName,1,1) + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + u.lastname + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + u.OccupationCode + from cv3ordercatalogmasteritem ocmi with (nolock) + join cv3order o with (nolock) on o.OrderCatalogMasterItemGUID = ocmi.guid + JOIN CV3DrugMapping dm with (nolock) on dm.CatalogItemGUID = ocmi.GUID + join CV3OrganizationalUnit ou with (nolock) on ou.GUID = ocmi.OrgUnitGUID + left join cv3user u with (nolock) on u.guid = o.userguid + join CV3OrganizationalUnit uou with (nolock) on uou.guid = u.OrgUnitGUID + where + ou.name ={{{SINGLE-QUOTE}}}Pharmacy Department{{{SINGLE-QUOTE}}} and o.OrderStatusLevelNum > 15 and o.OrderStatusLevelNum not in ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}}) and + u.OrderRoleType <> {{{SINGLE-QUOTE}}}anesthesia physician{{{SINGLE-QUOTE}}} and uou.Description <> {{{SINGLE-QUOTE}}}Emergency Department{{{SINGLE-QUOTE}}} and + o.clientguid = " || ClientGuid || " and o.ChartGUID = " || ChartGuid || " and o.ClientVisitGUID = " || visitGuid || " + "}; + + + + // Check for Opiod/Benzo Medications + + Opiods_BenzosFound:= ""; + for x in 1 seqto count (PatientMedDrugID) do + if (PatientMedDrugID[x] is in Opiods_Benzos) + then Opiods_BenzosFound := Opiods_BenzosFound || "\n - PDMP Search Required for - " || PatientMedName [x] || " " || PatientMedOrderInfo [x] ; + endif; + enddo; + + endif; // significant event found ? + + endif; // patient age > 0 ? + + + // VTE Order Section + (VTERelatedOrders) := read + { + " select ocmi.Name " + || " from cv3ordercatalogmasteritem as ocmi with (nolock) " + || " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid " + || " and o.chartguid = " || ChartGuid || " and o.clientguid = " || ClientGuid || " and o.clientvisitguid = " || VisitGuid || " " + || " and o.OrderStatusLevelNum >= 15 and o.OrderStatusLevelNum not in (69, 70) " + || " where ( " + || " ocmi.name = {{{SINGLE-QUOTE}}}VTE Drug Therapy Evaluation{{{SINGLE-QUOTE}}} or " + || " (ocmi.name like {{{SINGLE-QUOTE}}}%Heparin%{{{SINGLE-QUOTE}}} and o.typecode = {{{SINGLE-QUOTE}}}medication{{{SINGLE-QUOTE}}} and ocmi.name not like {{{SINGLE-QUOTE}}}%flush%{{{SINGLE-QUOTE}}} and ocmi.name not like {{{SINGLE-QUOTE}}}%lock%{{{SINGLE-QUOTE}}}) " + || " or ocmi.name like {{{SINGLE-QUOTE}}}%Enoxaparin%{{{SINGLE-QUOTE}}} or ocmi.name like {{{SINGLE-QUOTE}}}%Fondaparinux%{{{SINGLE-QUOTE}}} or ocmi.name like {{{SINGLE-QUOTE}}}%Argatroban%{{{SINGLE-QUOTE}}} or ocmi.name like {{{SINGLE-QUOTE}}}%Dabigatran%{{{SINGLE-QUOTE}}} " + || " or ocmi.name like {{{SINGLE-QUOTE}}}%Apixaban%{{{SINGLE-QUOTE}}} or ocmi.name like {{{SINGLE-QUOTE}}}%Rivaroxaban%{{{SINGLE-QUOTE}}} or ocmi.name like {{{SINGLE-QUOTE}}}%Warfarin%{{{SINGLE-QUOTE}}} " + || " or (ocmi.name like {{{SINGLE-QUOTE}}}Aspirin%{{{SINGLE-QUOTE}}} and ocmi.name not like {{{SINGLE-QUOTE}}}%dipyridamole%{{{SINGLE-QUOTE}}}) " + || " ) " + || " and ocmi.name not like {{{SINGLE-QUOTE}}}zz%{{{SINGLE-QUOTE}}} " + || " and ocmi.name <> {{{SINGLE-QUOTE}}}No Warfarin{{{SINGLE-QUOTE}}} " + }; + + VTEEvaluationOrder := "No"; + VTEPreventativeOrder := "No"; + + indexList := 1 seqto count (VTERelatedOrders); + + for i in indexList do + + obsName := last (first i from VTERelatedOrders); + + if obsName = "VTE Drug Therapy Evaluation" then VTEEvaluationOrder := "Yes"; endif; // VTE order was found + + if obsName <> "VTE Drug Therapy Evaluation" then + + // If it is an Asprin order, a Knee or Hip OS order needs to be on file to qualify + if obsName matches pattern "%Aspirin%" then + + (KneeOrHipOrders) := read + { + " select top 1 o.OrderSetName " + || " from cv3order as o with (nolock) " + || " where o.chartguid = " || ChartGuid || " and o.clientguid = " || ClientGuid || " and o.clientvisitguid = " || VisitGuid || " " + || " and o.OrderStatusLevelNum >= 15 and o.OrderStatusLevelNum not in (69, 70) " + || " and (o.OrderSetName like {{{SINGLE-QUOTE}}}%knee%{{{SINGLE-QUOTE}}} or o.OrderSetName like {{{SINGLE-QUOTE}}}%hip%{{{SINGLE-QUOTE}}}) " + }; + + If exists KneeOrHipOrders then + VTEPreventativeOrder := "Yes"; + endif; + + else + VTEPreventativeOrder := "Yes"; // A Non-Aspirin Medication order + endif; + + endif; + + enddo; + + // Message Assesment Section + //formattedTextAll:= " ** Important Reminders (VIEW ONLY) ** "; + //formattedTextAll:= " "; + + If AdmORMStatus = "incomplete" then AdmORMStatusMessage := " - Admission ORM Incomplete"; + + elseif not exists AdmORMStatus then AdmORMStatusMessage := " - Admission ORM NOT Initiated"; + + else AdmORMStatusMessage := ""; + + endif; + + + // If not exists CodeStatusOrder then CodeStatusMessage := "\n\n - Code Status - CPR Review Required"; else CodeStatusMessage := ""; endif; + // If not exists CPROrder then CPRMessage := " CPR Review Required"; else CPRMessage := ""; endif; + + If VTEEvaluationOrder = "No" and VTEPreventativeOrder = "No" then VTEStatusMessage := "\n - VTE Review Required"; + else VTEStatusMessage := ""; endif; + + If exists Specialty and exist VentilatorOrder and not exists ChestOrder and exists CurrentLocation then + VentilatorMessage := "\n - The order for a Chest Portable-Daily has expired."; + else + VentilatorMessage := ""; + endif; + + // No Messages found message + If AdmORMStatusMessage = "" and VTEStatusMessage = "" and VentilatorMessage = "" then + NoErrorMessage := "\n - There are no messages for the patient."; + // then NoErrorMessage := "\n\n "; + else + NoErrorMessage := ""; + endif; + + //formattedTextAll:= AdmORMStatusMessage || CodeStatusMessage || VTEStatusMessage || VentilatorMessage || NoErrorMessage; + formattedTextAll:= AdmORMStatusMessage || VTEStatusMessage || VentilatorMessage || NoErrorMessage || Opiods_BenzosFound; + endif; // Document Open + + // Write to the Structured Note Text Box + If formattedTextAll is not null then + + vitalSignsHL := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Reminder"); + + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := vitalSignsHL.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := formattedTextAll; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + endif; + + ;; + evoke: + ;; + logic: + + if ( NOT ( RoleType matches pattern "%student%" ) ) AND ( NOT ( OccCode matches pattern "%student%" ) ) then + if ( visitStatus = "ADM" AND ( visitType = "Inpatient" OR visitType = "Observation" ) ) then + + if thisDocumentCommunication.EventType = "DocumentOpening" OR thisDocumentCommunication.EventType = "DocumentClosing" then + if ( NOT ( exists CodeStatusOrder ) ) then + CodeStatusAlert_OBJ := new net_object {{{SINGLE-QUOTE}}}CustomCodeStatusAlert.CustomCodeStatusAlertForm{{{SINGLE-QUOTE}}} WITH thisDocumentCommunication.EventType; + rtnValue := CALL CodeStatusAlert_OBJ.ShowDialog; + elseif ( "CODE STATUS ND" IN CodeStatusType ) then + CodeStatusAlert_OBJ := new net_object {{{SINGLE-QUOTE}}}CustomCodeStatusAlert.CustomCodeStatusAlertForm{{{SINGLE-QUOTE}}} WITH "CODE STATUS ND", "Code Status: Ethically unable to determine", thisDocumentCommunication.EventType; + rtnValue := CALL CodeStatusAlert_OBJ.ShowDialog; + endif; + endif; + endif; + endif; + + conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_ETHICS_NOTE.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_ETHICS_NOTE.mlm new file mode 100644 index 0000000..aaa2a7e --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_ETHICS_NOTE.mlm @@ -0,0 +1,198 @@ +maintenance: + + title: DOC_FUNC_ETHICS_NOTE;; + mlmname: DOC_FUNC_ETHICS_NOTE;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Peggy Karish;; + specialist: Don Warnick ;; + date: 2018-03-19;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 03.19.2018 DW CSR# 36364 - Ethics Note - Created + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType:= OBJECT [ListItemGUID, Value, IsSelected]; + + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + launchtheapp:= "no"; + + + // Document Open + + if thisdocumentCommunication.EventType = "DocumentOpening" + + then + + // Vital Signs Section + + DocVitalsHL2 := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_VS_24hrs{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocVitalsHL2 WITH thisDocumentCommunication; + + + // Code Status Section + + formattedText:= ""; + + + CodeStatusOrder := read + {" + SET CONCAT_NULL_YIELDS_NULL off + SELECT ocmi.Name + {{{SINGLE-QUOTE}}} - {{{SINGLE-QUOTE}}} + substring (o.summaryline, 3,500) + FROM CV3OrderCatalogMasterItem ocmi with (nolock) + JOIN CV3Order o with (nolock) ON o.OrderCatalogMasterItemGUID = ocmi.GUID AND o.ClientGUID = " || ClientGuid || " AND o.ClientVisitGUID = " || VisitGuid || " AND o.ChartGUID = " || ChartGuid || " + WHERE ( + ocmi.Name in ({{{SINGLE-QUOTE}}}CPR/Attempt Resuscitation{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}DNR/Do Not Attempt Resuscitation{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Code Status: Comfort Measures Only{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Code Status: Limited Interventions{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Code Status: Full Treatment{{{SINGLE-QUOTE}}}) + or + ocmi.Name = {{{SINGLE-QUOTE}}}Code Status: Ethically unable to determine{{{SINGLE-QUOTE}}} + ) + AND o.OrderStatusLevelNum >= 15 AND o.OrderStatusLevelNum not in (69, 70) + "}; + + + if exists CodeStatusOrder + then + for i in 1 seqto count CodeStatusOrder do + if i = 1 + then formattedText:= formattedText || CodeStatusOrder[i]; + else formattedText:= formattedText || "\n\n" || CodeStatusOrder[i]; + endif; + enddo; + endif; + + + // Write to the Structured Note Text Box + + If formattedText is not null then + + vitalSignsHL := first of (thisParameters where thisParameters.Name = "SCH_MDPN_EthicsCode Status Current"); + + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := vitalSignsHL.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := formattedText; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + endif; + + + // Chart Observation + + ElseIf thisdocumentCommunication.EventType = "ChartObservation" // and selectedobservationname = "SCH_MDPN_Ethics ConsultReq Launch" + + + then + + launchtheapp:= "yes"; + + using "AddCareProvidertoSN"; + test:= new net_object {{{SINGLE-QUOTE}}}AddProviderToNote.AddProviderToNoteForm{{{SINGLE-QUOTE}}}; + + // Reset the launch button + + theParameterx := first of (thisparameters where thisparameters.Name = "SCH_MDPN_Ethics ConsultReq Launch"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameterx.ParameterGUID); + + if thisdocumentCommunication.CurrentObservationObj.parameterguid = theParameterx.ParameterGUID then + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Ethics ConsultReq Launch"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := false; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; + + + endif; + + + + ;; + evoke: + ;; + logic: + + + if launchtheapp = "yes" + + then + + oeUnsigned:=CALL test.ShowDialog; + + return_string:= test.text; + + endif; + + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Ethics ConsultRequestor"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := return_string; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + conclude true; + + + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_FACE_TO_FACE_NOTE.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_FACE_TO_FACE_NOTE.mlm new file mode 100644 index 0000000..97c11f2 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_FACE_TO_FACE_NOTE.mlm @@ -0,0 +1,135 @@ +maintenance: + + title: DOC_FUNC_FACE_TO_FACE_NOTE;; + mlmname: DOC_FUNC_FACE_TO_FACE_NOTE;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Shubha Rai ;; + specialist: Don Warnick;; + date: 2016-09-29;; + validation: testing;; + +library: + purpose: Retrieve data from the RT Ambulation SN fields into a textbox on the Face to Face SN + ;; + explanation: + Change history + + 09.29.2016 DW CSR# 34813 - Created + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + +// DOCUMENT OPEN SECTION + + + if thisdocumentCommunication.EventType = "DocumentOpening" + then + + (FTFValue,FTFHeader,FTFHeaderGuid) := read + {" + SET CONCAT_NULL_YIELDS_NULL off + Select + case when ocs.DisplayName is null then o.ValueText + fsl.value else ocmi.LeftJustifiedLabel + {{{SINGLE-QUOTE}}} - {{{SINGLE-QUOTE}}} + o.ValueText + fsl.value end, + case when ocs.DisplayName is null then ocmi.LeftJustifiedLabel else ocs.DisplayName end, + case when ocs.DisplayName is null then 0 else ocs.guid end + from CV3ClientDocumentCUR cd with (nolock) + join CV3ClientDocDetailCUR cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) + join CV3ObservationDocumentCUR od with (nolock) ON cdd.CLientDocumentGUID = od.OwnerGUID + join CV3ObservationCUR o with (nolock) ON o.GUID = od.ObservationGUID + join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID + left join SCMObsFSListValues fsl with (nolock) ON fsl.ParentGUID = od.ObservationDocumentGUID AND fsl.ClientGUID = " || ClientGuid || " + left join CV3ObsCatalogSet ocs with (nolock) on ocs.GUID = od.ObsSetGUID + where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " + and cd.iscanceled = 0 + and cd.DocumentName like {{{SINGLE-QUOTE}}}RT Ambulation Assessment{{{SINGLE-QUOTE}}} + and ocmi.name like {{{SINGLE-QUOTE}}}sch_rt%{{{SINGLE-QUOTE}}} + order by od.DisplaySequence " + }; + + + FTFInformation := " "; + FTFCurrentHeaderGuid := "999"; + + indexList := 1 seqto count (FTFValue); + for i in indexList do + + if FTFHeaderGuid[i] <> FTFCurrentHeaderGuid + then + if FTFCurrentHeaderGuid = "999" + then + FTFInformation := "\b " || FTFHeader[i] || "\b0" ; + else + FTFInformation := FTFInformation || "\n\n" || "\b " || FTFHeader[i] || "\b0" ; + endif; + endif; + + FTFInformation := FTFInformation || "\n" || FTFValue[i]; + FTFCurrentHeaderGuid := FTFHeaderGuid[i]; + + enddo; + + + // Write to the Structured Note Text Box + + If FTFInformation <> " " + then + writefield := first of (thisParameters where thisParameters.Name = "SCH_FTF_ RT ambulation FT"); + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := writefield.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := FTFInformation; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + endif; + + + endif; // Document Open + + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_FALL_HARM_RISK.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_FALL_HARM_RISK.mlm new file mode 100644 index 0000000..8f09463 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_FALL_HARM_RISK.mlm @@ -0,0 +1,344 @@ +maintenance: + + title: DOC_FUNC_FALL_HARM_RISK;; + mlmname: DOC_FUNC_FALL_HARM_RISK;; + arden: version 2.5;; + version: 5.50;; + institution: Allscripts;; + author: Juliet M. Law ;; + specialist: ;; + date: 2013-12-13;; + validation: testing;; + +library: + purpose: Automatically check observations under the Fall Harm Risk section on the + Adult Assessment / Intervention Flowsheet.. + ;; + explanation: On the Adult Assessment/Intervention Flowsheet, automatically check several observations + based on patient having a "History of Fall in Past 6 months" significant event. + + Change History + 12.13.2013 JML Created + 03.17.2014 JML Modified MLM to optimize SQL queries to handle SCM flowsheet freezing issue; + saving observation values for UDDIs with textbox type in values. + 11.19.2015 JML WO #1947083: Modified MLM to not include completed anticoagulant orders + when determining auto-checking of "therapeutic anticoag..." observation. + 11.07.2018 JML CSR 37204: Removed code for observations that were inactivated on the flowsheet under + the Fall / Harm Risk Assessment category. + + ;; + keywords: fall, risk, flowsheet + ;; +knowledge: + type: data-driven;; + data: + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + //Include ObjectsPlus Assemblies + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + (thisDocumentCommunication) := argument; + + /**************Make Changes To Spelling And Flags In This Section**************/ + //Set up variables; initialize + fire_on_param := "SCHCK_INV Universal INV"; + + //Document Type + FLOWSHEET := "FlowSheet"; + + //Event Types + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTCLOSING := "DocumentClosing"; + /******************************************************************************/ + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid, ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + //Set Flowsheet DocumentCommunication object model variables via Called MLM + (this_fs_doc) := thisDocumentCommunication.DocumentConfigurationObj; + (this_parameters) := this_fs_doc.ParametersList; + (this_currentObs) := thisDocumentCommunication.CurrentObservationObj; + (this_cols) := this_fs_doc.ColumnsList; + (this_curr_col) := this_fs_doc.CurrentColumn; + (this_chartedObs) := this_curr_col.ChartedObservationsList; + + document_type := thisDocumentCommunication.DocumentType; + event_type := thisDocumentCommunication.EventType; + + client_guid := thisDocumentCommunication.ClientGUID; + visit_guid := thisDocumentCommunication.ClientVisitGUID; + chart_guid := thisDocumentCommunication.ChartGUID; + + anticoag_exists := false; + + check_fall_history := read last {"SELECT 1" + || " FROM CV3ClientEventDeclaration ced WITH (NOLOCK)" + || " WHERE ced.ClientGUID = " || Sql(client_guid) + || " AND ced.Active = 1" + || " AND ced.Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}}" + || " AND ced.TypeCode IN ({{{SINGLE-QUOTE}}}Fall{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Fall History{{{SINGLE-QUOTE}}})" + || " AND DATEDIFF(MONTH, ced.CreatedWhen, GetDate()) <= 6"}; + + + patientAge := read last {"SELECT CASE" + || " WHEN ((c.BirthMonthNum > MONTH(getdate())) " + || " OR (c.BirthMonthNum = MONTH(getdate()) and c.BirthDayNum > DAY(getdate()))) then" + || " Convert(char(3),(YEAR(getdate()) - c.BirthYearNum) - 1)" + || " ELSE" + || " Convert(char(3),(YEAR(GETDATE()) - c.BirthYearNum))" + || " END" + || " FROM CV3Client c WITH (NOLOCK) " + || " WHERE c.GUID = " || Sql(client_guid)}; + + patientBMI := read last {"Select TOP 1 o.ValueText" + || " from CV3ClientDocumentCUR cd WITH (NOLOCK) join CV3ClientDocDetailCUR cdd WITH (NOLOCK) " + || " on cdd.ClientDocumentGUID = cd.GUID" + || " join CV3ObservationDocumentCUR od WITH (NOLOCK) " + || " on cdd.CLientDocumentGUID = od.OwnerGUID " + || " join CV3ObsCatalogMasterItem ocmi WITH (NOLOCK) " + || " on od.ObsMasterItemGUID = ocmi.GUID " + || " join CV3ObservationCUR o WITH (NOLOCK) " + || " on o.GUID = od.ObservationGUID " + || " join cv3obscatalogitem oci WITH (NOLOCK) " + || " on oci.guid = o.obsitemguid " + || "where cd.clientguid = " || Sql(client_guid) + || " and cd.ClientVisitGUID = " || Sql(visit_guid) + || " and cd.chartguid = " || Sql(chart_guid) + || " and o.ValueText is not null " + || " and od.active = 1" + || " and oci.name = {{{SINGLE-QUOTE}}}SCH_vs_BMI{{{SINGLE-QUOTE}}}" + || "order by cd.authoreddtm desc "}; + + check_platelet_count := read last {"SELECT TOP 1 bo.Value" + || " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3Order o WITH (NOLOCK)" + || " ON cv.ClientGUID = o.ClientGUID" + || " AND cv.GUID = o.ClientVisitGUID" + || " AND cv.ChartGUID = o.ChartGUID" + || " JOIN CV3BasicObservation bo WITH (NOLOCK)" + || " ON o.GUID = bo.OrderGUID" + || " AND o.ClientGUID = bo.ClientGUID" + || " AND o.ClientVisitGUID = bo.ClientVisitGUID" + || " WHERE bo.ClientGUID = " || Sql(client_guid) + || " AND bo.ClientVisitGUID = " || Sql(visit_guid) + || " AND bo.ChartGUID = " || Sql(chart_guid) + || " AND bo.ItemName IN ({{{SINGLE-QUOTE}}}Platelet Count{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Platelet Count.{{{SINGLE-QUOTE}}})" + || " AND ((o.OrderStatusLevelNum > 15" + || " AND o.OrderStatusLevelNum NOT IN ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}}))" + || " OR o.OrderStatusCode = {{{SINGLE-QUOTE}}}HOLD{{{SINGLE-QUOTE}}})" + || " ORDER BY bo.CreatedWhen DESC"}; + + (check_anticoag_order, + anticoag_order_dose) := read last {"SELECT TOP 1 o.Name, ot.OrderDosageLow" + || " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3Order o WITH (NOLOCK)" + || " ON cv.GUID = o.ClientVisitGUID" + || " AND cv.ClientGUID = o.ClientGUID" + || " JOIN CV3OrderTask ot WITH (NOLOCK)" + || " ON o.GUID = ot.OrderGUID" + || " AND o.ClientGUID = ot.ClientGUID" + || " AND o.ChartGUID = ot.ChartGUID" + || " JOIN CV3OrderTaskOccurrence oto WITH (NOLOCK)" + || " ON ot.GUID = oto.OrderTaskGUID" + || " AND ot.ClientGUID = oto.ClientGUID" + || " WHERE o.ClientGUID = " || Sql(client_guid) + || " AND o.ClientVisitGUID = " || Sql(visit_guid) + || " AND o.ChartGUID = " || Sql(chart_guid) + || " AND o.TypeCode = {{{SINGLE-QUOTE}}}Medication{{{SINGLE-QUOTE}}}" + || " AND o.Active = 1" + || " AND" + || " ( o.Name LIKE {{{SINGLE-QUOTE}}}%Enoxaparin%{{{SINGLE-QUOTE}}}" + || " OR o.Name LIKE {{{SINGLE-QUOTE}}}%Heparin%25,000%{{{SINGLE-QUOTE}}}" + || " OR o.Name LIKE {{{SINGLE-QUOTE}}}%Heparin%Infusion%{{{SINGLE-QUOTE}}}" + || " OR o.Name LIKE {{{SINGLE-QUOTE}}}%Heparin%Prisma%{{{SINGLE-QUOTE}}}" + || " OR o.Name LIKE {{{SINGLE-QUOTE}}}%Warfarin%{{{SINGLE-QUOTE}}}" + || " OR o.Name LIKE{{{SINGLE-QUOTE}}}%Dabigatran%{{{SINGLE-QUOTE}}} " + || " OR o.Name LIKE {{{SINGLE-QUOTE}}}%Rivaroxaban%{{{SINGLE-QUOTE}}}" + || " OR o.Name LIKE {{{SINGLE-QUOTE}}}%Fondaparinux%{{{SINGLE-QUOTE}}}" + || " OR o.Name LIKE {{{SINGLE-QUOTE}}}%Argatroban%{{{SINGLE-QUOTE}}}" + || " OR o.Name LIKE {{{SINGLE-QUOTE}}}%Apixaban%{{{SINGLE-QUOTE}}} )" + || " AND ((o.OrderStatusLevelNum > 15" + || " AND o.OrderStatusLevelNum NOT IN ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}100{{{SINGLE-QUOTE}}}))" + || " OR o.OrderStatusCode = {{{SINGLE-QUOTE}}}HOLD{{{SINGLE-QUOTE}}})" + || " ORDER BY o.CreatedWhen DESC"}; + + if (document_type = FLOWSHEET AND event_type = CHARTOBSERVATION) then + + //*************** UNIVERSAL INTERVENTIONS ************************** + //Autocheck all values under "Universal Interventions" Observation + univIndParameter := first of (this_parameters WHERE this_parameters.Name = fire_on_param); + + if (exists univIndParameter) then + + //Define parameter ConfigurationObj to extract Suggested Text value + univIndListConfiguration := univIndParameter.ConfigurationObj; + + univIndObs := first of ( this_chartedObs WHERE this_chartedObs.ParameterGUID = univIndParameter.ParameterGUID); + + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID := this_fs_doc.ClientDocumentGUID; + this_currentObj.ParameterGUID := univIndParameter.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := NEW ListValueType; + this_currentObj.ValueObj.ListGUID := univIndParameter.ConfigurationObj.ListGUID; + + //Determine if ListValue parameter allows for text type in in addition to list values + if ( univIndListConfiguration.AllowsSuggestedText = true ) then + //Determine if user typed something in + if ( exists univIndObs.ValueObj.SuggestedTextValue ) then + //Save it to the ListValueType object (defined above) + this_currentObj.ValueObj.SuggestedTextValue := univIndObs.ValueObj.SuggestedTextValue; + endif; + endif; + + listItems := (); + + for item IN univIndParameter.ConfigurationObj.ListItemsList Do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + selectedItem.IsSelected := true; + + listItems := (listItems, selectedItem); + + enddo; + + this_currentObj.ValueObj.ListItemsList := listItems; + this_fs_doc.CurrentColumn.ChartedObservationsList := (this_fs_doc.CurrentColumn.ChartedObservationsList, this_currentObj); + + endif; + + + //*********** HIGH FALL RISK ASSESSMENT ************************** + //Query for "Fall History" significant Event + fallRiskParam := first of (this_parameters WHERE this_parameters.Name = "SCHCK_AS High Fall Risk Assm"); + + if (exists fallRiskParam) then + + (fallRiskObs) := first of (this_chartedObs WHERE this_chartedObs.ParameterGUID = fallRiskParam.ParameterGUID); + (fallRiskValues) := (fallRiskObs.ValueObj.ListItemsList.Value WHERE fallRiskObs.ValueObj.ListItemsList.IsSelected = true); + + this_currentObj2 := NEW ObservationType; + this_currentObj2.ClientDocumentGUID := this_fs_doc.ClientDocumentGUID; + this_currentObj2.ParameterGUID := fallRiskParam.ParameterGUID; + this_currentObj2.DataType := "ListValue"; + this_currentObj2.ValueObj := NEW ListValueType; + this_currentObj2.ValueObj.ListGUID := fallRiskParam.ConfigurationObj.ListGUID; + listItems := (); + + for item IN fallRiskParam.ConfigurationObj.ListItemsList do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if ((selectedItem.Value = "*History of Fall in Past 6 Months") AND (exists check_fall_history)) then + selectedItem.IsSelected := true; + elseif (( selectedItem.Value = "No Indicators Present") AND ( count fallRiskValues > 0 )) then + if ( ( count fallRiskValues = 1 ) AND ( "No Indicators Present" IN fallRiskValues ) ) then + selectedItem.IsSelected := true; + elseif ( ( count fallRiskValues > 1 ) AND ( "No Indicators Present" IN fallRiskValues ) ) then + selectedItem.IsSelected := false; + else + selectedItem.IsSelected := false; + endif; + elseif (selectedItem.Value IN fallRiskValues) then + selectedItem.IsSelected := true; + else + selectedItem.IsSelected := false; + endif; + + listItems := (listItems, selectedItem); + enddo; + + this_currentObj2.ValueObj.ListItemsList := listItems; + this_fs_doc.CurrentColumn.ChartedObservationsList := (this_fs_doc.CurrentColumn.ChartedObservationsList, this_currentObj2); + endif; + + //*********************** HARM RISK ASSESSMENT ********************************* + //Determine if obs need auto checked under the Harm Risk Assessment + + //Retrieve the HARM Risk Assessment observation + harmRiskAssm := "SCHCK_AS Harm Risk Assm"; + harmRiskAssmParam := first of (this_parameters WHERE this_parameters.Name = harmRiskAssm); + + if (exists harmRiskAssmParam) then + + (harmRiskAssmObs) := first of (this_chartedObs WHERE this_chartedObs.ParameterGUID = harmRiskAssmParam.ParameterGUID); + harmRiskAssmValues := (harmRiskAssmObs.ValueObj.ListItemsList.Value + WHERE harmRiskAssmObs.ValueObj.ListItemsList.IsSelected = true); + + this_currentObj4 := NEW ObservationType; + this_currentObj4.ClientDocumentGUID := this_fs_doc.ClientDocumentGUID; + this_currentObj4.ParameterGUID := harmRiskAssmParam.ParameterGUID; + this_currentObj4.DataType := "ListValue"; + this_currentObj4.ValueObj := NEW ListValueType; + this_currentObj4.ValueObj.ListGUID := harmRiskAssmParam.ConfigurationObj.ListGUID; + listItems := (); + + for item IN harmRiskAssmParam.ConfigurationObj.ListItemsList do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if ( ( ( patientAge as number ) >= 85 ) AND ( selectedItem.Value = "*Age 85 or Greater" ) ) then + selectedItem.IsSelected := true; + endif; + + if ( ( ( patientBMI as number ) < 20 ) AND ( selectedItem.Value = "*BMI Less than 20, Frail" ) ) then + selectedItem.IsSelected := true; + endif; + + if ( selectedItem.Value matches pattern "*Therapeutic Anticoag%" ) then + if ( exists check_anticoag_order ) then + if ( ( check_anticoag_order matches pattern "Enoxaparin%" ) AND ( ( anticoag_order_dose as number ) > 40 ) ) then + anticoag_exists := true; + selectedItem.IsSelected := true; + elseif ( ( check_anticoag_order matches pattern "Rivaroxaban%" ) AND ( ( anticoag_order_dose as number ) > 10 ) ) then + anticoag_exists := true; + selectedItem.IsSelected := true; + elseif ( ( NOT check_anticoag_order matches pattern "Enoxaparin%" ) AND ( NOT check_anticoag_order matches pattern "Rivaroxaban%" ) ) then + anticoag_exists := true; + selectedItem.IsSelected := true; + endif; + elseif ( ( exists check_platelet_count ) AND ( ( check_platelet_count as number ) <= 50 ) ) then + selectedItem.IsSelected := true; + endif; + endif; + + if ( ( selectedItem.Value = "No Indicators Present" ) AND ( count harmRiskAssmValues > 0 ) ) then + if ( ( count harmRiskAssmValues = 1 ) AND ( "No Indicators Present" IN harmRiskAssmValues ) ) then + selectedItem.IsSelected := true; + elseif ( ( count harmRiskAssmValues > 1 ) AND ( "No Indicators Present" IN harmRiskAssmValues ) ) then + selectedItem.IsSelected := false; + endif; + elseif ( selectedItem.Value IN harmRiskAssmValues ) then + selectedItem.IsSelected := true; + endif; + + listItems := (listItems, selectedItem); + enddo; + + this_currentObj4.ValueObj.ListItemsList := listItems; + this_fs_doc.CurrentColumn.ChartedObservationsList := (this_fs_doc.CurrentColumn.ChartedObservationsList, this_currentObj4); + endif; + + endif; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: + return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_FBC_BILIMETER_SCREEN.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_FBC_BILIMETER_SCREEN.mlm new file mode 100644 index 0000000..760b7dc --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_FBC_BILIMETER_SCREEN.mlm @@ -0,0 +1,219 @@ +maintenance: + + title: DOC_FUNC_FBC_BILIMETER_SCREEN;; + mlmname: DOC_FUNC_FBC_BILIMETER_SCREEN;; + arden: version 5.0;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Juliet M. Law, Allscripts, Inc. x7461 ;; + specialist: Dean Miklavic, Allscripts, Inc. x7466 ;; + date: 2012-11-02;; + validation: testing;; + +library: + purpose: This MLM attaches to the Transcutaneous Bilimeter Screening document (SCH_FBC_Bilimeter Screen). + Retrieve gestational age from Newborn Patient Profile; calculate age in hours based on Bilimeter Screening date. + ;; + explanation: This MLM will check if the Newborn Patient Profile document exists. If the document does not exist, the user + will receive an alert on document open that the gestational age could not be retrieved. The document will not allow + saving as a completed document. + If the document does exist, the gestational age will be retrieved and populated into the observation. + After the user enters the Bilimeter Screening date time, the age in hours will be calculated and populate + the observation. + + Change history + + 11.02.2012 - JML Created + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + + // Receive arguments from the structured note + (this_documentCommunication) := argument; + + //.Net Libraries + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + // Called MLM declaration section + set_cds_vars := MLM {{{SINGLE-QUOTE}}}Called_RPM_DOM_Get_Definition_MLM{{{SINGLE-QUOTE}}}; + read_obs_value := MLM {{{SINGLE-QUOTE}}}CALLED_DOC_FS_OBS_VALUE_MLM{{{SINGLE-QUOTE}}}; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + /*********************************BEGIN EDIT SECTION*****************************************************/ + + //Define Document Type Constants + FLOWSHEET := "Flowsheet"; + STRUCTUREDNOTE := "StructuredNote"; + + //Define Event Type Constants + DOCUMENTOPENING := "DocumentOpening"; + DOCUMENTCLOSING := "DocumentClosing"; + CHARTOBSERVATION := "ChartObservation"; + + // Setting the cancelProcessing to true will cause the charted observation not to be saved + cancelProcessing := false; + + // Setting the debugFlag to true will cause popup dialogs containing debug information to display + debugFlag := false; + + //Variable Declaration + displayAlert := false; + /*********************************END EDIT SECTION*****************************************************/ + + //Set CDS DocumentCommunication object model variables via Called MLM + (this_documentCommunication, client_guid, client_visit_guid, client_chart_guid, + user_guid, document_type, document_name, event_type, + configuration_guid, this_currentObj, CancelEventFlag, this_structuredNoteDoc, + authored_date_time, authored_by_guid, client_document_guid, document_date_time, + isNewFlag, isIncompleteFlag, isResultsPendingFlag, isPriorityFlag, + this_parameters, this_chartedObservationsList, this_parameters_display_name, current_parameter, + current_parameter_name, current_parameter_guid, current_parameter_DataType, selectedItems, + selectedItems_value, current_value, diagnosticMessage, displayMessageFlag, + CoSigner1, CoSigner2, DocumentTopic) := CALL set_cds_vars WITH (this_documentCommunication); + + + // Set up debugging information to be captured + messageText := ""; + if (debugFlag = true) then + messageText := "Debug Information: \n\n"; + messageText := messageText || " DOC_FUNC_FBC_BILIMETER_SCREEN mlm is called\n\n"; + endif; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + NumericValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + //Assign document name and parameter to variable + newbornDocument := "Newborn Patient Profile"; + newbornGestAgeParam := "PRO gestational age infant NU"; + + pediatricDocument := "Pediatric Patient Profile"; + pediatricGestAgeParam := "PRO gestational age peds NU"; + + + //Check for existence of Newborn Patient Profile + (newbornDocName, newbornGestAge) := read {"SELECT cd.DocumentName, o.ValueText" + || " FROM CV3ClientVisit cv JOIN CV3ClientDocumentCUR cd " + || " on cv.GUID = cd.ClientVisitGUID" + || " JOIN CV3ClientDocDetailCUR cdd " + || " on cd.GUID = cdd.ClientDocumentGUID" + || " JOIN CV3ObservationDocumentCUR od" + || " on cdd.ClientDocumentGUID = od.OwnerGUID" + || " JOIN CV3ObsCatalogMasterItem ocmi" + || " on od.ObsMasterItemGUID = ocmi.GUID" + || " JOIN CV3ObservationCUR o" + || " on od.ObservationGUID = o.GUID" + || " JOIN CV3ObsCatalogItem oci" + || " on o.ObsItemGUID = oci.GUID" + || " WHERE ((cd.DocumentName = {{{SINGLE-QUOTE}}}" || newbornDocument || "{{{SINGLE-QUOTE}}}" + || " AND oci.Name = {{{SINGLE-QUOTE}}}" || newbornGestAgeParam || "{{{SINGLE-QUOTE}}})" + || " OR " + || " (cd.DocumentName = {{{SINGLE-QUOTE}}}" || pediatricDocument || "{{{SINGLE-QUOTE}}}" + || " AND oci.Name = {{{SINGLE-QUOTE}}}" || pediatricGestAgeParam || "{{{SINGLE-QUOTE}}}))" + || " AND cd.IsCanceled = 0" + || " AND cdd.Active = 1" + || " AND od.Active = 1" + || " AND cv.ClientGUID = " || Sql(client_guid) + || " AND cv.GUID = " || Sql(client_visit_guid) + || " AND cv.ChartGUID = " || Sql(client_chart_guid) + || " ORDER BY cd.AuthoredDtm DESC"}; + + //On Document Open, retrieve the gestational age from the Newborn Patient Profile; if not available display + //alert to user + if (document_type = STRUCTUREDNOTE AND (event_type = DOCUMENTOPENING OR event_type = DOCUMENTCLOSING)) then + + if (not (exists newbornDocName)) then + //Newborn Patient Profile AND Pediatric Patient Profile don{{{SINGLE-QUOTE}}}t exist for this baby; alert user + displayAlert := true; + else + //Document does exist, but gestation age does not; alert user + if (last of (newbornGestAge) IS NULL) then + displayAlert := true; + else + + //Document and gestational age exist; populate observation SCH_FBC_Bilimeter_gestational age + bilimeterGestAgeParam := "SCH_FBC_Bilimeter_gestational age"; + + //set variable to value + bilimeterGestAgeValue := last of (newbornGestAge); + + bilimeterGestAge := first of (this_parameters WHERE this_parameters.Name = bilimeterGestAgeParam); + + if (exists bilimeterGestAge) then + this_currentObs := NEW ObservationType; + this_currentObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID; + this_currentObs.ParameterGUID := bilimeterGestAge.ParameterGUID; + this_currentObs.DataType := "NumericValue"; + this_currentObs.ValueObj := NEW NumericValueType; + this_currentObs.ValueObj.Value := bilimeterGestAgeValue as number; + + this_structuredNoteDoc.ChartedObservationsList := (this_structuredNoteDoc.ChartedObservationsList, this_currentObs); + endif; + endif; + endif; + + if (displayAlert) then + alertMsg := "Gestational Age has not been documented on the Newborn Patient Profile or the Pediatric Patient Profile." + || " Please enter this information " + || "before completing the Transcutaneous Bilimeter Screening.\n\n" + || "Please NOTE that you will be unable to SAVE this document until a gestational age has been entered " + || "on the Newborn Patient Profile or the Pediatric Patient Profile. Please cancel this document."; + this_documentCommunication.DisplayMessage := true; + this_documentCommunication.Message := alertMsg; + + this_documentCommunication.CancelEvent := true; + endif; + elseif (document_type = STRUCTUREDNOTE AND event_type = CHARTOBSERVATION) then + //If charted observation is the bilimeter screen date time, retrieve value and calculate age in hours + if (current_parameter_name = "SCH_FBC_Bilimeter_Screen Date Time") then + //Retrieve admit date to calculate hours old + admitdttm := read last {"SELECT AdmitDtm " + || " FROM CV3ClientVisit cv WITH (NOLOCK)" + || " WHERE cv.GUID = " || SQL(client_visit_Guid) + || " AND cv.ClientGUID = " || SQL(client_Guid) + || " AND cv.ChartGUID = " || Sql(client_chart_guid) }; + + calcHours := (((current_value - admitdttm) / 60 seconds) / 60) formatted with "%.2f"; + + findDec := FIND "." IN STRING (calcHours as string); + calcHours := SUBSTRING findDec-1 CHARACTERS FROM calcHours; + + //Populate observation + HoursAgeParameterName := "SCH_FBC_Bilimeter_Hourly Age"; + HoursAgeParameter := first of (this_parameters WHERE this_parameters.Name = HoursAgeParameterName); + + if (exists HoursAgeParameter) then + + this_currentAgeObs := NEW ObservationType; + this_currentAgeObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID; + this_currentAgeObs.ParameterGUID := HoursAgeParameter.ParameterGUID; + this_currentAgeObs.DataType := "NumericValue"; + this_currentAgeObs.ValueObj := NEW NumericValueType; + this_currentAgeObs.ValueObj.Value := calcHours; + + this_structuredNoteDoc.ChartedObservationsList := (this_structuredNoteDoc.ChartedObservationsList, this_currentAgeObs); + endif; + endif; + endif; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_FOCUS_NOTE_ALLERGY_ONSET_DATE_CHECK.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_FOCUS_NOTE_ALLERGY_ONSET_DATE_CHECK.mlm new file mode 100644 index 0000000..da30621 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_FOCUS_NOTE_ALLERGY_ONSET_DATE_CHECK.mlm @@ -0,0 +1,154 @@ +maintenance: + + title: DOC_FUNC_FOCUS_NOTE_ALLERGY_ONSET_DATE_CHECK;; + mlmname: DOC_FUNC_FOCUS_NOTE_ALLERGY_ONSET_DATE_CHECK;; + arden: version 2.5;; + version: 5.50;; + institution: St.Clair Hospital;; + author: Juliet M. Law;; + specialist: Debbie Eiler;; + date: 2012-08-15;; + validation: testing;; + + + library: + purpose: Hard stop when attempting to save the Focus Note Structured Note with no allergy onset date. + ;; + explanation: Stops the nurse from saving the structured note when the drug allergy reaction pull set contains + allergies with no onset date recorded. + + + change history + + 08.15.2012 JML CSR# 30881 - Created + 11.19.2012 JML Copied to Production + 11.29.2012 JML Changed time range for checking new allergies entered; went from 2 hours down to 30 mins. + + ;; + keywords: ClientDocument; allergy; onset date; + ;; +knowledge: + type: data-driven;; + data: + + + + (this_documentCommunication) := argument; + + //.Net Libraries + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + // Called MLM declaration section + // Utility function to parse strings + str_parse := MLM {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; + set_cds_vars := MLM {{{SINGLE-QUOTE}}}Called_RPM_DOM_Get_Definition_MLM{{{SINGLE-QUOTE}}}; + read_obs_value := MLM {{{SINGLE-QUOTE}}}CALLED_DOC_FS_OBS_VALUE_MLM{{{SINGLE-QUOTE}}}; + + /*******************Make Changes To Spelling And Flags In This Section*******************/ + //Document Type + FLOWSHEET := "FlowSheet"; + STRUCTUREDNOTE := "StructuredNote"; + + //Event Types + DOCUMENTOPENING := "DocumentOpening"; + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTCLOSING := "DocumentClosing"; + + // Setting the cancelProcessing to true will cause the charted observation not to be saved + cancelProcessing := false; + + // Setting the debugFlag to true will cause popup dialogs containing debug information to display + debugFlag := false; + + allergyAlertMessage := ""; + closeDocument := true; + allergyObsName := "Allergies_Medication_Focus Note"; + /******************************************************************************/ + + //Set Flowsheet DocumentCommunication object model variables via Called MLM + (this_documentCommunication, client_guid, client_visit_guid, client_chart_guid, + user_guid, document_type, document_name, event_type, + configuration_guid, this_currentObj, CancelEventFlag, this_structuredNoteDoc, + authored_date_time, authored_by_guid, client_document_guid, document_date_time, + isNewFlag, isIncompleteFlag, isResultsPendingFlag, isPriorityFlag, + this_parameters, this_chartedObservationsList, this_parameters_display_name, current_parameter, + current_parameter_name, current_parameter_guid, current_parameter_DataType, selectedItems, + selectedItems_value, current_value, diagnosticMessage, displayMessageFlag, + CoSigner1, CoSigner2, DocumentTopic) := CALL set_cds_vars WITH (this_documentCommunication); + + // Set up debugging information to be captured + messageText := ""; + if (debugFlag = true) then + messageText := "Debug Information: \n\n"; + messageText := messageText || " DOC_FUNC_FOCUS_NOTE_ALLERGY_ONSET_DATE_CHECK mlm is called\n\n"; + endif; + + if (document_type = STRUCTUREDNOTE AND event_type = DOCUMENTCLOSING) then + + //Retrieve allergies in Allergy Pull Set on Structured Note + (allergyEntered, + severityEntered, + onsetMonthEntered, + onsetDayEntered, + onsetYearEntered) := read {"SELECT IsNull(a.Code, {{{SINGLE-QUOTE}}}Miscellaneous{{{SINGLE-QUOTE}}})," + || " IsNull(SvrtyLevelDisplay, SvrtyLevelCode) AS SvrtyLevel," + || " CASE WHEN ad.OnsetMonthNum = 0 THEN Null ELSE ad.OnsetMonthNum END as OnsetMonth," + || " CASE WHEN ad.OnsetDayNum = 0 THEN Null ELSE ad.OnsetDayNum END as OnsetDay," + || " CASE WHEN ad.OnsetYearNum = 0 THEN Null ELSE ad.OnsetYearNum END as OnsetYear" + || " FROM CV3AllergyDeclaration ad LEFT JOIN CV3Allergen a ON ad.AllergenGUID = a.GUID" + || " AND a.Active = 1" + || " LEFT OUTER JOIN CV3EnumReference enumRef1 ON (enumRef1.TableName = {{{SINGLE-QUOTE}}}CV3AllergyDeclaration{{{SINGLE-QUOTE}}}" + || " AND enumRef1.ColumnName = {{{SINGLE-QUOTE}}}CategoryType{{{SINGLE-QUOTE}}}" + || " AND enumRef1.EnumValue = CategoryType)" + || " LEFT OUTER JOIN CV3EnumReference enumRef2 ON (enumRef2.TableName = {{{SINGLE-QUOTE}}}CV3AllergyDeclaration{{{SINGLE-QUOTE}}}" + || " AND enumRef2.ColumnName = {{{SINGLE-QUOTE}}}CategoryType{{{SINGLE-QUOTE}}}" + || " AND enumRef2.EnumValue = 0)" + || " LEFT OUTER JOIN CV3EnumReference enumRef3 ON (enumRef3.TableName = {{{SINGLE-QUOTE}}}CV3AllergyDeclaration{{{SINGLE-QUOTE}}}" + || " AND enumRef3.ColumnName = {{{SINGLE-QUOTE}}}Type{{{SINGLE-QUOTE}}}" + || " AND enumRef3.EnumValue = ad.Type" + || " AND enumRef3.EnumValue = 2)" + || " WHERE ad.ClientGUID = " || Sql(client_guid) + || " AND ad.ClientVisitGUID = " || Sql(client_visit_guid) + || " AND ad.ChartGUID = " || Sql(client_chart_guid) + || " AND a.TypeCode = {{{SINGLE-QUOTE}}}Drug{{{SINGLE-QUOTE}}}" + || " AND ad.Active = 1" + || " AND ad.Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}}" + || " AND " + || " (ad.TouchedWhen <= GETDATE()" + || " AND ad.TouchedWhen >= DATEADD(mi,-30, getdate()))"}; + + if (exists allergyEntered) then + AllMissingAllergyOnsetDates := (); + for i IN 1 seqto (count allergyEntered) do + if ((onsetMonthEntered[i] IS NULL)) then + if ((onsetYearEntered[i] IS NULL)) then + AllMissingAllergyOnsetDates := allergyEntered[i] || " " || severityEntered[i], AllMissingAllergyOnsetDates; + endif; + endif; + enddo; + + if (count AllMissingAllergyOnsetDates > 0) then + allergyAlertMessage := "There are Allergies that do not have an Onset Date. Please return to the Allergy and enter" + || " an Onset Date."; + + this_documentCommunication.Message := allergyAlertMessage; + this_documentCommunication.DisplayMessage := True; + + this_documentCommunication.CancelEvent := True; + endif; + endif; + + endif; + ;; + + evoke: + ;; + logic: + conclude true; + ;; + + action: + return this_documentCommunication; + ;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_FOREIGN_TRAVEL_ALERT.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_FOREIGN_TRAVEL_ALERT.mlm new file mode 100644 index 0000000..17dfdbf --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_FOREIGN_TRAVEL_ALERT.mlm @@ -0,0 +1,144 @@ +maintenance: + + title: DOC_FUNC_FOREIGN_TRAVEL_ALERT;; + mlmname: DOC_FUNC_FOREIGN_TRAVEL_ALERT;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Dean Miklavik;; + specialist: Don Warnick ;; + date: 2014-10-15;; + validation: testing;; + +library: + purpose: + ;; + explanation: This MLM will return an alert to have the nurese notify Infection Control when the patient has a fever and has recently traveled + outside of the country or has had contact with someone who has recently traveled + + + Change history + + 10.15.2014 DW CSR# 32793 - Created + 12.01.2014 DW CSR# 32793 - Introduced text messaging to Infection Control + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + + +// CHART OBSERVATION SECTION + + + +IF thisdocumentCommunication.EventType = "ChartObservation" + + then + + + // Determine if a fever was indicated + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Fever_Risk_Assessment"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes...") + then Fever := "yes"; + endif; + + + // Determine if a foreign travel was indicated + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Travel_Risk_Assessment1"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes...") + then ForeignTravel := "yes"; + endif; + + + // Determine if the foreign travel was to a country of interest + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Travel_Risk_Assessment3"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "none of these countries") + then CountryOfInterest := "no"; + endif; + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value <> "none of these countries") + then CountryOfInterest := "yes"; + endif; + + + // Decide whehter to fire the alert + + +If Fever = "yes" and ForeignTravel = "yes" and CountryOfInterest = "yes" + + then + + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with " Notify the Infection Prevention Nurse STAT at Ext 2230 or 2211. ", "Important Alert","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + + // Gather the patien{{{SINGLE-QUOTE}}}t nursing unit + + CurrentLocation := read last {"Select CurrentLocation From cv3Clientvisit with (nolock) Where Guid = " || SQL(visitGuid)||" and VisitStatus = {{{SINGLE-QUOTE}}}ADM{{{SINGLE-QUOTE}}}" }; + EndOfUnit := find "-" in string CurrentLocation; + + If EndofUnit <> 0 + then Unit:= SUBSTRING EndOfUnit -1 CHARACTERS STARTING AT 1 from CurrentLocation; + else Unit:= CurrentLocation; + endif; + + // Send a Text Message Section + + PhoneNumber := read last {" select p.AreaCode + p.PhoneNumber from CV3User u with (nolock) join Cv3Phone p with (nolock) on p.PersonGUID = u.GUID " || + " where u.displayname = {{{SINGLE-QUOTE}}}SCM, Text Messaging{{{SINGLE-QUOTE}}} and p.PhoneNote = {{{SINGLE-QUOTE}}}Infection Control Department Manager{{{SINGLE-QUOTE}}} "}; + + Page_MLM := mlm {{{SINGLE-QUOTE}}}SCH_FUNC_PAGE{{{SINGLE-QUOTE}}}; + MessageSubject:= "Important Message"; + MessageBody := " Please call unit " || Unit || " for a fever travel risk patient. St.Clair main# 412-942-4000"; + void := call Page_MLM with(PhoneNumber, MessageSubject, MessageBody); + + + endif; // Fire the Alert + + +endif; // EventType = "ChartObservation" + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_GENERIC_MANDATORY_BY_OCCUPATION.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_GENERIC_MANDATORY_BY_OCCUPATION.mlm new file mode 100644 index 0000000..05e1205 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_GENERIC_MANDATORY_BY_OCCUPATION.mlm @@ -0,0 +1,139 @@ +maintenance: + + title: DOC_FUNC_GENERIC_MANDATORY_BY_OCCUPATION;; + mlmname: DOC_FUNC_GENERIC_MANDATORY_BY_OCCUPATION;; + arden: version 5.5;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Juliet Law;; + specialist: ;; + date: 2011-07-07;; + validation: testing;; + +library: + purpose: This MLM allows interdisciplinary users to enter data on structured notes that contain + mandatory observations. + ;; + explanation: + + Change history + + 07.07.2011 JML Create date. + 06.26.2018 DW CSR# 36510 Harm to Self or Others - exclude "Nurse (RN) Med Rec" order role type from mandatory requirement + + + ;; + keywords: mandatory, RN + ;; +knowledge: + type: data-driven;; + data: + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Receive arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Get the client, visit, chart, and user GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + //Declare and initialize variables + mandatoryFieldCount := 50; //maximum number of generic obs defined on SN that toggles mandatory requirement + thisDocParamName := "sch_notmandatory"; //base name of generic obs defined on SN + isRn := ""; //Boolean - is current logged on user an RN + + //Retrieve current user{{{SINGLE-QUOTE}}}s Id and occupation code + (userId, userOcc, orderroletype) := read last { + " SELECT IDCode, OccupationCode, OrderRoleType, touchedWhen " + || " FROM CV3User with (nolock)" + || " WHERE GUID = " || Sql(userGuid) + || " AND Active = 1 " + , primarytime = touchedWhen + }; + + //Determine if current logged on user is RN, set boolean + if (userOcc = "RN" OR userOcc = "GN" OR userOcc = "SN") and orderroletype <> "Nurse (RN) Med Rec" then + isRn := "yes"; + else + isRn := "no"; + endif; + + //Only execute on DocumentOpen event + if thisDocumentCommunication.EventType = "DocumentOpening" then + + //Loop through maximum number of generic obs + for i in 1 seqto (mandatoryFieldCount) do + + //Concatenate base parameter/obs name with counter value + tempFldName := thisDocParamName || i; + + //Search SN for existence of parameter/obs name + this_parameterName := first of (thisParameters where thisParameters.name = tempFldName); + + if exists(this_parameterName) then + + //Instantiate a new Observation object + this_currentObj := NEW ObservationType; + //Populate properties of Observation object with data + this_currentObj.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parameterName.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID := this_parameterName.ConfigurationObj.ListGUID; + listItems := (); + + //Loop through List + For item IN this_parameterName.ConfigurationObj.ListItemsList Do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + //Select radio button value based on isRn value + //This logic will toggle the mandatory fields on the SN + if selectedItem.Value = "yes" AND isRn = "yes" then + selectedItem.IsSelected := true; + endif; + if selectedItem.Value = "no" AND isRn = "no" then + selectedItem.IsSelected := true; + endif; + + listItems := (listItems, selectedItem); + + enddo; + + this_currentObj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; + enddo; + endif; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_GENERIC_MULTI_SELECT.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_GENERIC_MULTI_SELECT.mlm new file mode 100644 index 0000000..966a92b --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_GENERIC_MULTI_SELECT.mlm @@ -0,0 +1,113 @@ +maintenance: + + title: DOC_FUNC_GENERIC_MULTI_SELECT;; + mlmname: DOC_FUNC_GENERIC_MULTI_SELECT;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Janet Nordin;; + specialist: Don Warnick;; + date: 2016-04-08;; + validation: testing;; + +library: + purpose: + ;; + explanation: This generic MLM will select the checkboxes in an observation when the "All" checkbox is selected. + + This MLM should be used instead of "DOC_ACS_Reciprocal_Multi_Select" when the observation list utilizes a suggested dictionary. + + That MLM will place a "null" in the freetextbox. This one will not. + + Change history + + 04.08.2016 DW CSR# 33486 - Created for the Post Hospital Care Orders SN but may be used for any SN + + ;; + keywords: generic, multi-select + ;; +knowledge: + type: data-driven;; + data: + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + // Find the Observation Name that was selected + this_currentObj := thisdocumentCommunication.CurrentObservationObj; + current_parameter := FIRST OF (thisParameters WHERE thisparameters.ParameterGUID = this_CurrentObj.ParameterGUID); + selected_observation_name := current_parameter.name ; + + + IF thisdocumentCommunication.EventType = "ChartObservation" then + + // Determine if the "All" checkbox is set to "true" (since the "All" checkox is reset to false later in the MLM, this means that someone has selected it to trigger the MLM) + + theParameter := first of (thisparameters where thisparameters.Name = selected_observation_name); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "All") + then AllWasSelected := "true"; + else AllWasSelected := "false"; + endif; + + // If the All checkbox is set to true, then select all checkboxes and de-select the "All" checkbox to initialize it for future selection + + If AllWasSelected = "true" + then + this_parametername := first of (thisParameters where thisParameters.Name = selected_observation_name); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "All" then selectedItem.IsSelected := false; else selectedItem.IsSelected := true; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + + + endif; // End of Observation Event section + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_HEP_C_SCREENING.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_HEP_C_SCREENING.mlm new file mode 100644 index 0000000..57301f3 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_HEP_C_SCREENING.mlm @@ -0,0 +1,626 @@ +maintenance: + + title: DOC_FUNC_HEP_C_SCREENING;; + mlmname: DOC_FUNC_HEP_C_SCREENING;; + arden: version 5.5;; + version: 15.10;; + institution: St.Clair Hospital;; + author: Shawn Head x7468;; + specialist: Janet Nordin;; + date: 2017-02-13;; + validation: testing;; + +library: + purpose: When patient is being evaluated for Hep C. on the Adult Patient Profile and also the Adult Patient Profile - Behavioraly Health + ;; + explanation: This MLM will fire on the following structured note documents: + * Adult Patient Profile + * Adult Patient Profile - Behavioral Health + * Adult Patient Profile - Observation + + *********Details to be outline here.******** + + Change history + + 02.13.2017 STH CSR 35129: Created + 04.11.2017 STH CSR 35129: Issue with configuration of flowsheet observation and also auto ordering the lab due to nurses not having the proper security. {Go-Live 4/13/2017} + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + FireOnAdultPatProfiles := (); + FireOnAssessmentPlanFS := (); + + /*------------------MAKE CHANGES IN THIS SECTION ONLY----------------------------*/ + + HepCPatient := "SCH_Hep C_Patient born between 1945-1965"; + HepCPriorScreening := "SCH_Hep C_Have you had prior screening"; + HepCScreen_PatApproval := ("SCH_Hep C _Testing","SCH_Hep C _Testing NEW","SCH_Hep C Screening New"); // Added By Shami for FS logic + //created new SQL variable as we had to keep re-creating observations after go-live that we had to account for. MLM{{{SINGLE-QUOTE}}}s like lists one way and SQL likes them another. + HepCScreen_PatApproval_SQL := "({{{SINGLE-QUOTE}}}SCH_Hep C _Testing{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_Hep C _Testing NEW{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_Hep C Screening New{{{SINGLE-QUOTE}}})"; // Added By Shami for FS logic + HepCScreen_AutoOrder := "SCH_Hep C Screening Order"; + HepCordername := "Hepatitis C Antibody IgG"; + HepCFSCharting := "({{{SINGLE-QUOTE}}}SCH_Hep C Screening New{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_Hep C_Screening{{{SINGLE-QUOTE}}})"; + (FireOnAdultPatProfiles) := ("Adult Patient Profile","Adult Patient Profile - Observation","Adult Patient Profile - Behavioral Health"); + (FireOnAssessmentPlanFS) := ("2. Adult Assessment/Intervention"); + + //Depending on lab inventory to complete the Hep C testing the order that needs placed may change. + //the standard order will be the StClair order; however if anyone every "unexpires" the Mayo order the MLM + //will automatically start ordering the Mayo order instead of the StClair order. According ot Maria they + //will only unexpire the Mayo order when the St. Clair order is out of stock. + Catalog_Item_Name_StClair := "Hepatitis C Antibody IgG"; + Catalog_Item_Name_Mayo := "Hepatitis C Antibody (Mayo)"; + + /*-----------------END EDIT SECTION---------------------------------------------*/ + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + // Order and Error Destinations + + DiagnosticOrder_dest := destination { ObjectsPlus } with + [ alert_type := "Warning", + short_message := "Object created by MLM", + priority := "low", + scope := "chart", + rule_group := "Order Object", + rule_number := 2010 ]; + + error_destination := destination { Alert } with [ + alert_type := "Warning", + short_message := "ObjectsPlus Error from MLM", + priority := "low", + scope := "chart", + Rule_group := "ObjectsPlus Error from MLM", + Rule_number := 1003, + Rule_subgroup := "", + Send_alert_with_order := "", + Alert_dialog_settings := "", + Display_alert := true ]; + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (this_currentObs) := thisDocumentCommunication.CurrentObservationObj; + (this_cols) := thisStructuredNoteDoc.ColumnsList; + (this_curr_col) := thisStructuredNoteDoc.CurrentColumn; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + ListValueType := OBJECT [ListGuid, ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + currentlocationGUID := read last { "select currentlocationguid from cv3clientvisit where clientguid = " || sql(clientGuid) || " and guid = " || sql(visitGuid) || " "}; + + DocEventType := thisDocumentCommunication.EventType; + ChartPatAge := false; + ChartPriorScreen := false; + ChartAutoOrder := false; + + + (birth_year) := read last { " select cast (birthyearnum as varchar) from cv3client with (nolock) where guid = " || sql(ClientGuid) }; + + if(((birth_year as number) >= 1945) and ((birth_year as number) <= 1965)) then + RightAgeyes := true; + RightAgeNo := false; + else + RightAgeYes := false; + RightAgeNo := true; + endif; + + + if((RightAgeyes) or (DocEventType = "ChartObservation")) then + //Ran this SQL logic against a PROD patient that had over 1400 visits and dated back to 2002. The SQL returned on 0 seconds. With that being said + //there is always the potential this SQL logic can cause a delay if it is slow to return data. Always check this SQL logic as it is required every time + //this MLM is called and looks across all charts for a specific order. + HepCScreeningOrders := read { " select clientguid, ChartGUID, guid as {{{SINGLE-QUOTE}}}clientvisitguid{{{SINGLE-QUOTE}}} into #tmp_cv from cv3clientvisit cv with (nolocK) + where ClientGUID = " || sql(clientGuid) || " + + select ocmi.guid,ocmi.name, ocmi.OrderReviewCategoryGUID, rci.ItemName, rci.GUID as {{{SINGLE-QUOTE}}}rci_guid{{{SINGLE-QUOTE}}}, rci.ResultCategoriesGUID + into #tmp_ocmi + from cv3ordercatalogmasteritem ocmi with (nolock) + inner join CV3ResultCatalogItem rci with (nolock) on ocmi.guid = rci.OrderMasterItemGUID + where ocmi.Name like {{{SINGLE-QUOTE}}}%Hepatitis C%{{{SINGLE-QUOTE}}} or ocmi.Name like {{{SINGLE-QUOTE}}}%hep c%{{{SINGLE-QUOTE}}} + + + select cv.*, o.guid as {{{SINGLE-QUOTE}}}orderGUID{{{SINGLE-QUOTE}}}, o.OrderStatusCode, o.OrderStatusLevelNum, o.SignificantDtm from #tmp_cv cv with (nolock) + inner join CV3Order o with (nolock) on cv.clientguid = o.clientguid and cv.chartguid = o.chartguid + left join CV3BasicObservation bo with (nolock) + on cv.ClientGUID = bo.ClientGUID + and cv.ChartGUID = bo.ChartGUID + and cv.clientvisitguid = bo.ClientVisitGUID + and bo.OrderGUID = o.GUID + + inner join #tmp_ocmi ocmi with (nolock) on ((bo.ResultItemGUID = ocmi.rci_guid and bo.ItemName = ocmi.ItemName) or (o.OrderCatalogMasterItemGUID = ocmi.guid)) + where ( + (o.ClientGUID = " || sql(clientGuid) || " + and o.ChartGUID = " || sql(chartGuid) || " + and o.ClientVisitGUID = " || sql(visitGuid) || " + and OrderStatusLevelNum not in ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}})) + or + (o.ClientGUID = " || sql(clientGuid) || " + and o.ClientVisitGUID <> " || sql(visitGuid) || " + and o.OrderStatusLevelNum >= {{{SINGLE-QUOTE}}}60{{{SINGLE-QUOTE}}} + and OrderStatusLevelNum not in ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}})) + or + (o.ClientGUID = " || sql(clientGuid) || " + and OrderStatusLevelNum = {{{SINGLE-QUOTE}}}83{{{SINGLE-QUOTE}}}) + ) + drop table #tmp_cv, #tmp_ocmi "}; //clientGuid, visitGuid, chartGuid + + + + endif; + +/*--########################################### BEGINING OF ASSESSMENT AND PLAN FLOWSHEET LOGIC####################################################--*/ +/* -- START: COMMENTED AS IT WAS SLOWING DOWN THE FS + if(trim(thisDocumentCommunication.DocumentName as string) in FireOnAssessmentPlanFS) then + if (count(HepCScreeningOrders)>0 AND HepCScreeningOrders is not NULL) then + + FSAlert := false; + else + FSAlert := true; + endif; + + if((DocEventType = "DocumentOpening") and (FSAlert)) then + + HepC_FS_Charting := read last {" select guid as {{{SINGLE-QUOTE}}}clientvisitguid{{{SINGLE-QUOTE}}}, clientguid, chartguid into #tmp_patients from cv3clientvisit with (nolock) + where ClientGuid = " || sql(clientGuid) + || " and ChartGUID = " || sql(ChartGuid) + || " and guid = " || sql(VisitGuid) + + || " Select guid into #tmp_obnames from CV3ObsCatalogMasterItem with (nolock) + where name in " || HepCFSCharting || " + + select top 1 isnull(oflv.value,{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}) as {{{SINGLE-QUOTE}}}obsvalue{{{SINGLE-QUOTE}}} + from #tmp_patients cv with (nolock) + inner join SXACDObservationParameter ObsParam with (nolock) + on cv.ClientGUID = ObsParam.ClientGUID + and cv.chartguid = ObsParam.ChartGUID + and cv.clientvisitguid = ObsParam.clientvisitguid + AND ObsParam.IsCanceled = 0 + and ObsParam.ObsMasterItemGUID in (select guid from #tmp_obnames) + inner join SCMObsFSListValues oflv with (nolock) + on obsparam.clientguid = oflv.clientguid + and obsparam.ObservationDocumentGUID = oflv.ParentGUID + and oflv.active = 1 + order by RecordedDtm desc + + drop table #tmp_obnames, #tmp_patients " }; + + + AlertShow := read last {" SELECT Distinct + OD.CreatedWhen AS ObsDate + FROM CV3Clientvisit CV + INNER JOIN CV3ClientDocument CD WITH (NOLOCK) + ON CV.GUID = CD.ClientVisitGUID And CD.ClientGUID = CV.ClientGUID + And CD.DocumentName = {{{SINGLE-QUOTE}}}2. Adult Assessment/Intervention{{{SINGLE-QUOTE}}} + AND CD.Active = 1 + AND CD.IsCanceled = 0 + INNER JOIN CV3ObservationDocument OD WITH (NOLOCK) + ON CD.GUID = OD.OwnerGUID + AND OD.Active = 1 + + INNER JOIN CV3ObsCatalogMasterItem OCMI WITH (NOLOCK) + ON OCMI.GUID = OD.ObsMasterItemGUID + AND OCMI.Name IN ({{{SINGLE-QUOTE}}}SCH_Hep C _Testing NEW{{{SINGLE-QUOTE}}}, + {{{SINGLE-QUOTE}}}SCH_Hep C Screening New{{{SINGLE-QUOTE}}}, + {{{SINGLE-QUOTE}}}SCH_Hep C _Hep Education{{{SINGLE-QUOTE}}}, + {{{SINGLE-QUOTE}}}SCH_Hep C _Hep Verbalize understanding{{{SINGLE-QUOTE}}}) + + LEFT JOIN CV3Observation O With (NoLock) + ON OD.ObservationGUID = O.GUID + + LEFT JOIN SCMObsFSListValues SFV WITH (NOLOCK) + ON SFV.ParentGUID = OD.ObservationDocumentGUID + AND SFV.ClientGUID = CD.ClientGUID + AND SFV.Active = 1 + WHERE (OD.CreatedWhen BETWEEN DATEADD(HOUR,7,CONVERT(VARCHAR(10), GETDATE(),110)) AND + DATEADD(HOUR,19,CONVERT(VARCHAR(10), GETDATE(),110)) ) AND + CV.ClientGuid = " || sql(clientGuid) + || " and CV.ChartGUID = " || sql(ChartGuid) + || " and CV.guid = " || sql(VisitGuid) + + + || " ORDER BY OD.CreatedWhen DESC" }; + + CHARTED_DATA_OBJ := OBJECT [DocumentNameOBJ,OBSNAME,OBSVALUE]; + (CHARTED_DATA_LIST) := READ AS CHARTED_DATA_OBJ { " SELECT CD.DocumentName,OCMI.Name,ISNULL(sp.ValueText,dbo.SXAGetFSListValsFn(OD.ObservationDocumentGUID,CD.ClientGUID)) AS Value, " || + " ROW_NUMBER() OVER(PARTITION BY OCMI.NAME ORDER BY SP.RecordedDtm DESC) AS R " || + " INTO #TEST " || + " FROM CV3ClientDocument CD WITH (NOLOCK) " || + " INNER JOIN CV3ObservationDocument OD WITH (NOLOCK) ON OD.OwnerGUID = CD.GUID AND OD.ArcType = CD.ArcType AND OD.Active = 1 AND CD.IsCanceled = 0 " || + " INNER JOIN CV3ObsCatalogMasterItem OCMI WITH (NOLOCK) ON OCMI.GUID = OD.ObsMasterItemGUID " || + " AND OCMI.Name IN ({{{SINGLE-QUOTE}}}SCH_Hep C _Hep Education{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_Hep C _Hep Verbalize understanding{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_Hep C_Have you had prior screening{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_Hep C_Patient born between 1945-1965{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_Hep C _Testing NEW{{{SINGLE-QUOTE}}}) " || + " INNER JOIN SXACDObservationParameter SP WITH (NOLOCK) ON SP.ClientGUID = CD.ClientGUID " || + " AND SP.ChartGUID = CD.ChartGUID AND SP.PatCareDocGUID = CD.PatCareDocGUID " || + " AND SP.ObservationDocumentGUID = OD.ObservationDocumentGUID " || + " WHERE CD.ClientVisitGUID = " || SQL(VisitGuid) || " AND CD.ClientGUID = " || SQL(clientGuid) || " AND CD.ChartGUID = " || SQL(ChartGuid) || " AND CD.Active = 1 " || + " AND ISNULL(sp.ValueText,dbo.SXAGetFSListValsFn(OD.ObservationDocumentGUID,CD.ClientGUID)) IS NOT NULL " || + " SELECT DocumentName,NAME,Value FROM #TEST WHERE R = 1 " }; + FOR V IN 1 SEQTO COUNT OF CHARTED_DATA_LIST DO + DocumentName := CHARTED_DATA_LIST[V].DocumentNameOBJ; + IF CHARTED_DATA_LIST[V].OBSNAME = "SCH_Hep C _Hep Education" THEN + Edu := CHARTED_DATA_LIST[V].OBSVALUE; + ELSEIF CHARTED_DATA_LIST[V].OBSNAME = "SCH_Hep C _Hep Verbalize understanding" THEN + verb := CHARTED_DATA_LIST[V].OBSVALUE; + ELSEIF CHARTED_DATA_LIST[V].OBSNAME = "SCH_Hep C_Have you had prior screening" THEN + prior := CHARTED_DATA_LIST[V].OBSVALUE; + ELSEIF CHARTED_DATA_LIST[V].OBSNAME = "SCH_Hep C_Patient born between 1945-1965" THEN + Born := CHARTED_DATA_LIST[V].OBSVALUE; + ELSEIF CHARTED_DATA_LIST[V].OBSNAME = "SCH_Hep C _Testing NEW" THEN + Test := CHARTED_DATA_LIST[V].OBSVALUE; + ENDIF; + ENDDO; + + ComponentCatalogGuidList := ""; + IF Edu is NULL THEN + IF ComponentCatalogGuidList = "" then + ComponentCatalogGuidList := ". Education Given" ; + ELSE + ComponentCatalogGuidList := ComponentCatalogGuidList ||"\n" || ". Education Given" ; + ENDIF; + ENDIF; + IF Verb is NULL THEN + IF ComponentCatalogGuidList = "" then + ComponentCatalogGuidList := ". Patient/SO verbalized understanding" ; + ELSE + ComponentCatalogGuidList := ComponentCatalogGuidList ||"\n" || ". Patient/SO verbalized understanding" ; + ENDIF; + ENDIF; + IF Test is NULL THEN + IF ComponentCatalogGuidList = "" then + ComponentCatalogGuidList := ". Patient agrees to testing?" ; + ELSE + ComponentCatalogGuidList := ComponentCatalogGuidList ||"\n" || ". Patient agrees to testing?" ; + + ENDIF; + ENDIF; + IF(AlertShow is NULL) THEN + IF( Born ="Yes") THEN + IF( Prior = "No/Unknown" OR Prior= "No") THEN + IF((NOT EXISTS Edu OR NOT EXISTS Verb ) AND (trim(Test as string) = "Undecided") or (trim(Test as string) = "Unable to Consent")) THEN + voiddialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with + (DocumentName as string) || " does not have the following Hepatitis C Questions answered \n" ||""|| (ComponentCatalogGuidList as string) || "\n and has the patient{{{SINGLE-QUOTE}}}s consent listed as " || (Test as string) || "\n Please update the "||(DocumentName as string) || " or chart on this flowsheet.", + "Hepatitis C Screening Questions", "OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Warning" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + ELSEIF( NOT Exists Test OR NOT EXISTS Edu OR NOT EXISTS Verb) then + voiddialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with + (DocumentName as string) || " does not have the following Hepatitis C Questions answered \n" ||""|| (ComponentCatalogGuidList as string) || "\n Please update the "||(DocumentName as string) || " or chart on this flowsheet. ", + "Hepatitis C Screening Questions", "OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Warning" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + ELSEIF ( (trim(Test as string) = "Undecided") or (trim(Test as string) = "Unable to Consent") ) THEN + voiddialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with + (DocumentName as string) || " currently Does Not have the patients consent for Testing Completed.", + "Hepatitis C Patient Consent Required", "OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Warning" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + ENDIF; + ENDIF; + ENDIF; + ENDIF; + ENDIF; +ENDIF; +-- END: COMMENTED AS IT WAS SLOWING DOWN THE FS */ +/*--########################################### END OF ASSESSMENT AND PLAN FLOWSHEET LOGIC####################################################--*/ + +/*--########################################### BEGINING OF ADULT PATIENT PROFILE LOGIC####################################################--*/ + + + +/*--########################################### BEGINING OF ADULT PATIENT PROFILE LOGIC####################################################--*/ + if(trim(thisDocumentCommunication.DocumentName as string) in FireOnAdultPatProfiles OR trim(thisDocumentCommunication.DocumentName as string) in FireOnAssessmentPlanFS) then + + if(DocEventType = "DocumentOpening") then + if(RightAgeYes) then + ChartPriorScreen := true; + if (count(HepCScreeningOrders)>0) then + PriorScreenYes := true; + PriorScreenNo := false; + else + PriorScreenYes := false; + PriorScreenNo := true; + endif; + endif; + + ChartPatAge := true; + + endif; + + // Identify the calling observation item + callingobsvals := thisDocumentCommunication.CurrentObservationObj; + callingobsname := first of (thisParameters where thisParameters.ParameterGUID = callingobsvals.ParameterGUID); + callingobs := first of (thisobservations where thisobservations.ParameterGUID = callingobsname.ParameterGUID); + + if(callingobs.DataType = "ListValue") then + callingobsval := (callingobs.ValueObj.ListItemsList.Value where callingobs.ValueObj.ListItemsList.IsSelected = true); + else + callingobsval := callingobs.ValueObj.Value; + endif; + + ListSetValueType := OBJECT [ListValuesList]; + ListValueType := OBJECT [ListGUID, ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + Obs_ListSet := callingobsvals.ValueObj.ListItemsList; + //Obs_ListItem := Obs_ListSet.ListItemsList ; + Obs_Value := Obs_ListSet.value ; + FOR item IN Obs_ListSet DO + if item.IsSelected = true then + msg1:= item.value; + endif; + ENDDo; +//z:= Obs_ListSet.Records__; + + + + if (DocEventType = "ChartObservation") Then + + + /*------BEGIN-SECTION---PATIENT HAS HAD PRIOR SCREENING-------------------------------------*/ + IF(callingobsname.Name = HepCPatient) then + if("Yes..." in callingobsval) then + RightAgeyes := true; + RightAgeNo := false; + else + RightAgeYes := false; + RightAgeNo := true; + PriorScreenYes := false; + PriorScreenNo := false; + endif; + + if((RightAgeYes) and (count(HepCScreeningOrders>0)) and ("Yes..." in callingobsval)) then + PriorScreenYes := true; + PriorScreenNo := false; + elseif("Yes..." in callingobsval) then + PriorScreenYes := false; + PriorScreenNo := true; + else + PriorScreenYes := false; + PriorScreenNo := false; + endif; + + ChartPatAge := true; + ChartPriorScreen := true; + endif; + + /*------BEGIN-SECTION---PATIENT HAS HAD PRIOR SCREENING-------------------------------------*/ + + + + /*------BEGIN-SECTION--PATIENT APPROVAL FOR HEP C SCREEN SECTION-----------------------------*/ + if(callingobsname.Name in HepCScreen_PatApproval) then + + if ("Yes" in callingobsval) OR ("Place order for Hepatitis C Antibody" in msg1 ) then + selectorderyes := true; + selectorderno := false; + else + selectorderyes := false; + selectorderno := true; + endif; + ChartAutoOrder := true; + + endif; + /*------END-SECTION----PATIENT APPROVAL FOR HEP C SCREEN SEC/TION-----------------------------*/ + + endif; + //ChartPatAge, ChartPriorScreen, ChartAutoOrder + + if(ChartPatAge) then + HepCPatient_Param := first of (thisParameters where thisParameters.Name = HepCPatient); + if (exists HepCPatient_Param) then + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := HepCPatient_Param.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := NEW ListValueType; + this_currentObj.ValueObj.ListGUID := HepCPatient_Param.ConfigurationObj.ListGUID; + listItems := (); + for item IN HepCPatient_Param.ConfigurationObj.ListItemsList Do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if(item.Value = "Yes...") then + selectedItem.IsSelected := RightAgeYes; + else + selectedItem.IsSelected := RightAgeNo; + endif; + listItems := (listItems, selectedItem); + enddo; + this_currentObj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + endif; + + if(ChartPriorScreen) then + HepCPriorScreening_Param := first of (thisParameters where thisParameters.Name = HepCPriorScreening); + if (exists HepCPriorScreening_Param) then + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := HepCPriorScreening_Param.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := NEW ListValueType; + this_currentObj.ValueObj.ListGUID := HepCPriorScreening_Param.ConfigurationObj.ListGUID; + listItems := (); + for item IN HepCPriorScreening_Param.ConfigurationObj.ListItemsList Do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if(item.Value = "Yes") then + selectedItem.IsSelected := PriorScreenYes; + else + selectedItem.IsSelected := PriorScreenNo; + endif; + listItems := (listItems, selectedItem); + enddo; + this_currentObj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + endif; + + if(ChartAutoOrder) then + if((selectorderyes) and (count(HepCScreeningOrders)<=0)) then + + MayoOrderActive := read first { " select case when ExpiryDate is null then {{{SINGLE-QUOTE}}}true{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}false{{{SINGLE-QUOTE}}} end as {{{SINGLE-QUOTE}}}MayoExpired{{{SINGLE-QUOTE}}} + from CV3OrderCatalogMasterItem + where name = " || sql(Catalog_Item_Name_Mayo) || " "}; + + if(MayoOrderActive = "true") then + Laboratory_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with Catalog_Item_Name_Mayo; + else + Laboratory_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with Catalog_Item_Name_StClair; + endif; + + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with + "Clicking Yes will automatically place an order for " || (Laboratory_catalog_item.Name as string) || " which will be scheduled for AM rounds. \n\nAre you sure you want to place the order now?", + "Auto Order Hepatitis C Antibody IgG?", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + If ((dialogResult as string) in ("Yes")) then + + + SessionType := "Standard"; + SessionReason := ""; + RequestingSource := "Standing Order"; + user_IDType := "Edstan Number (physician)"; + order_Creation_Reason := "From Hep C Screening MLM"; + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((thisdocumentCommunication.ClientVisitGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + user_IDCode := read last {"SELECT IDCode FROM CV3User " || " where GUID = " || thisdocumentCommunication.UserGUID}; + //RequestingCareProvider_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindById with ( user_IDType, (user_IDCode as STRING) ); + + CP_GUID := read last {" select ProviderGUID from CV3CareProviderVisitRole + where ClientGUID = " || sql(clientGuid) || " + and ChartGUID = " || sql(chartGuid) || " + and ClientVisitGUID = " || sql(visitGuid) || " + and Active = 1 + and status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} + and RoleCode = {{{SINGLE-QUOTE}}}Attending{{{SINGLE-QUOTE}}} "}; + RequestingCareProvider_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ( ( CP_GUID as number ) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}} ); //Int64 + location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((currentlocationGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + try + + Parent_DiagnosticOrder_obj := call {{{SINGLE-QUOTE}}}DiagnosticOrder{{{SINGLE-QUOTE}}}.CreateDiagnosticOrder + // PreFilled_MedicationOrder_obj := call {{{SINGLE-QUOTE}}}MedicationOrder{{{SINGLE-QUOTE}}}.CreateMedicationOrder + with + client_visit_obj, // ClientVisit ObjectsPlus object + Laboratory_catalog_item, // OrderCatalogMasterItem ObjectsPlus object + order_Creation_Reason, // string CreateReason + RequestingCareProvider_obj , // RequestedBy ObjectsPlus object + RequestingSource, // string RequestedBySource (must be in dictionary) + SessionType, // string SessionType + SessionReason, // string SessionReason + location_obj, // Location ReleaseLocGrpID + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; // AvailabilityOverride eAvailabilityOverride + ReqTime_obj := new net_object {{{SINGLE-QUOTE}}}RequestedTime{{{SINGLE-QUOTE}}}; + ReqTime_obj.CodedTime := "AM Rounds"; + Parent_DiagnosticOrder_obj.RequestedTime := ReqTime_obj; + Parent_DiagnosticOrder_obj.RequestedDate := "T+1"; + if ( Parent_DiagnosticOrder_obj is NOT NULL ) then + try + void := call Parent_DiagnosticOrder_obj.Save; + selectorderyes := true; + selectorderno := false; + void := call Parent_DiagnosticOrder_obj.Dispose; + void:= call Laboratory_catalog_item.Dispose; + Laboratory_catalog_item:= null; + endtry; + catch Exception ex + error_occurred := true; + error_message := "{{+R}}New Parent Diagnostic order:{{-R}}\n" || ex.Message || "\n\n"; + Endcatch; + + + endif; + endtry; + catch Exception ex + error_occurred := true; + error_message := "{{+R}}New Parent Diagnostic order:{{-R}}\n" || ex.Message || "\n\n"; + + if ( Laboratory_catalog_item is NOT NULL ) then void:= call Laboratory_catalog_item.Dispose; Laboratory_catalog_item:= null; endif; + if ( Parent_DiagnosticOrder_obj is NOT NULL ) then void:= call Parent_DiagnosticOrder_obj.Dispose; Parent_DiagnosticOrder_obj:= null; endif; + selectorderyes := false; + selectorderno := true; + Parent_DiagnosticOrder_dest := null; + + endcatch; + + + // Dispose + + if ( ClientVisit_obj is NOT NULL ) then void:= call ClientVisit_obj.Dispose; ClientVisit_obj:= null; endif; + if ( RequestedBy_obj is NOT NULL ) then void:= call RequestedBy_obj.Dispose; RequestedBy_obj:= null; endif; + if ( Location_obj is NOT NULL ) then void:= call Location_obj.Dispose; Location_obj:= null; endif; + else + selectorderyes := false; + selectorderno := true; + endif; + endif; + HepC_AutoOrderParam := first of (thisParameters where thisParameters.Name = HepCScreen_AutoOrder); + if (exists HepC_AutoOrderParam) then + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := HepC_AutoOrderParam.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := NEW ListValueType; + this_currentObj.ValueObj.ListGUID := HepC_AutoOrderParam.ConfigurationObj.ListGUID; + listItems := (); + for item IN HepC_AutoOrderParam.ConfigurationObj.ListItemsList Do + abc123 := item.Value; + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if(item.Value = "Yes") then + selectedItem.IsSelected := selectorderyes; + else + selectedItem.IsSelected := selectorderno; + endif; + listItems := (listItems, selectedItem); + enddo; + this_currentObj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + endif; + endif; +/*--########################################### END OF ADULT PATIENT PROFILE LOGIC####################################################--*/ + + ;; + evoke: + ;; + logic: + +conclude true; + + ;; + action: + if Error_occurred + then + write "An error has occured in the MLM {{+B}}DOC_FUNC_HEP_C_SCREENING{{-B}} " || + "Please notify your System Administrators that an error message has " || + "occurred for this patient. They will review the following error " || + "message: \n" at error_destination; + + write "1. " || error_message at error_destination; + + endif; + + + return thisDocumentCommunication; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_INFLUENZA.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_INFLUENZA.mlm new file mode 100644 index 0000000..35ee256 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_INFLUENZA.mlm @@ -0,0 +1,1410 @@ +maintenance: + + title: Influenza Logic;; + mlmname: DOC_FUNC_INFLUENZA;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Teresa Spicuzza;; + specialist: ;; + date: 2010-09-01;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + +******* Remember to change SCH_INFLUENZA_ORDER_CHECK_HEALTH_ISSUES + + 09.01.2010 TS Created from copy of DOC_FUNC_PNEUMOVAX + 10.26.2010 TS Added logic remove date from structured note if it is from a prior flu season; + Added logic to make new questions for "Is Patient Pregnant" and "Is Patient a Caregiver" + be included in decision to give vaccine. + 08.25.2011 DW Major rewrite CSR#26486 - qualifying rules had changed & the form was streamlined ("SCM Retieve Ifo" & "Reassess" buttons removed) + 11.10.2011 DW Help Desk issue - archive date fomratted as CCYY, original date formatted as YY caused problem with document charting date routine + 08.14.2012 TS Update protocol dates for new flu season + 11.28.2012 DW CSR# 31009 Influenza and Pneumovax prevent overide + 01.28.2013 DW CSR# 31247 Altered to order vaccine for everyone over 6 months who are not contraindicated + 11.12.2013 DW 6.1 Upgrade - A new "code" column was added to cv3healthissuedeclaration making this field ambiguous in the Chronic Condidtion SQL + 09.16.2014 TMS CSR# 32748 - Àdded new Catalog Name for Influenza and CSR #32700 Update protocol dates for new flu season. + 05.05.2015 GOS CSR 33143 : Change in Doses 6m to 8yr 11Mo Age and 9 yrs and Above + 08.31.2015 DW CSR# 23359 - ICD10 + 09.14.2016 DW CSR# 34972 - Update the dates for the new flu season + 09.27.2017 DW CSR# 35845 - Update the dates for the new flu season + 09.05.2018 SZ CSR# 37150 - Update the dates for the new flu season + 08.27.2019 SZ CSR# 37633 - Update the dates for the new flu season and addition of 0.5 mL high dose for 65 years and older + +******* REMEMBER to CHANGE THE END DATE MONTH BACK TO 03 + + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + // Also adjust SCH_INFLUENZA_ORDER_CHECK_HEALTH_ISSUES + + + + flu_season_start :=2019-07-31T00:00:00; + protocol_start :=2019-07-26T00:00:00; //yyyy-mm-dd allow order on this date + protocol_end :=2020-03-31T00:00:00; //yyyy-mm-dd allow order for 3-30 for 3-31 + todays_date := now; + + agerange3_lowerlimit := 3; + agerange4_lowerlimit := 9; + agerange5_lowerlimit := 19; + agerange6_lowerlimit := 50; + agerange7_lowerlimit := 65; //added as part of CSR 37633 - SZ + +// For HIS diagnostic box only + + agerange1note := "under 6m"; + agerange2note := "6m to 3"; + agerange3note := "3 to 9"; + agerange4note := "9 to 18"; + agerange5note := "19 to 50"; + agerange6note := "50 to 65"; + agerange7note := "65 and older"; //added as part of CSR 37633 - SZ + + pregnant := "unknown"; + + + formattedTextReason := "N-0. Influenza risk was not determined. "; + ordervaccine := "no"; + + + +// CHART OBSERVATION SECTION + + +IF thisdocumentCommunication.EventType = "ChartObservation" then + + + +// Attain user{{{SINGLE-QUOTE}}}s ID (for use in override message) + + userId := read last {" SELECT IDCode FROM CV3User with (nolock) WHERE GUID = " || Sql(userGuid) || " AND Active = 1 "}; + + + +// CONTRAINDICATION BUTTON CHANGE SECTION + + +// Using the prior value of the None box, determine if this is the first time a contraindication section box was clicked + + theParameter := first of (thisParameters where thisParameters.Name = "SCHCK_Influ Details"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + SavedNoneContraValue := theObservation.ValueObj.Value; + If SavedNoneContraValue is null + then FirstTime := "true"; else FirstTime := "false"; + endif; + + +// Proceed if a Contraindication section box was clicked + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_influ vac contra 2"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + then + trigger := "A Contraindications Box was selected or deselected"; + + +// If this is first contraindication section box clicked, assess what had been selected (NONE VS a Contraindication) + + if FirstTime = "true" then + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "none") + then contraboxchecked := "false"; MLMAction := "Retrieve and Reassess"; + + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value <> "none") + then contraboxchecked := "true"; MLMAction := "No Assessment Required"; + endif; + endif; + + +// Compare the prior value of the None box to the current value, to determine what was selected (NONE VS a Contraindication) + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "none") + then NewNoneContraValue := "true"; else NewNoneContraValue := "false"; + endif; + + If FirstTime = "false" + then + if NewNoneContraValue = SavedNoneContraValue + then WhatWasClicked := "Other Button Was Clicked"; + else WhatWasClicked := "None Button Was Clicked"; SavedNoneContraValue := NewNoneContraValue; + endif; + else // FirstTime = "true" + SavedNoneContraValue := NewNoneContraValue; + endif; + + +// Determine if all boxes in the section are deselected (nonthing is selected) + + if true not in (theObservation.ValueObj.ListItemsList.IsSelected) + then contraboxchecked := "unknown"; MLMAction := "No Assessment Required"; + endif; + + +// If this is not the first click and something is selected, reset the mutually exclusive contraindication boxes (None VS a Contraindiation) + + If (contraboxchecked = "unknown" or FirstTime = "true") + then ResetOtherBoxes := "false"; else ResetOtherBoxes := "true"; + endif; + + If ResetOtherBoxes = "true" + then + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := theParameter.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= theParameter.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN theParameter.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if WhatWasClicked = "Other Button Was Clicked" // One of the Containdications was selected + then + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = selectedItem.Value) + then selectedItem.IsSelected := true; + else selectedItem.IsSelected := false; + endif; + if selectedItem.Value = "none" + then selectedItem.IsSelected := false; + endif; + NewNoneContraValue := "false"; + endif; + + if WhatWasClicked = "None Button Was Clicked" // The None box was selected + then + if selectedItem.Value = "none" + then selectedItem.IsSelected := true; + else selectedItem.IsSelected := false; + endif; + endif; + + listItems := (listItems, selectedItem); + ENDDO; + + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + +// After the boxes have been reset, assess what is now selected + + If WhatWasClicked = "None Button Was Clicked" and + true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "none") + then contraboxchecked := "false"; MLMAction := "Retrieve and Reassess"; + + elseif WhatWasClicked = "Other Button Was Clicked" and + true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value <> "none") + then contraboxchecked := "true"; MLMAction := "No Assessment Required"; + endif; + + endif; // End of Reset mutually exclusive Contra section + + + +// If None is selcted , Unhide the Chronic Illness and Immunocompromised fields and buttons + + If contraboxchecked = "false" then + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Influ Unhide"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := true; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; + + +// Populate the "None" Contraindiated Selected Value Box + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Influ Details"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := NewNoneContraValue; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + +endif; // End of Contraindication section + + + + +// OTHER BUTTON CHANGE SECTION + + +// Place Order button change to NO (affix ovverride message to assesement) + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Influenza vac order"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + and + true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no") + + then MLMAction := "Reassess Only"; + trigger:= "Order Button NO was selected"; + endif; + + +// Place Order button change to YES (send message to user and reset to original assessment) + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Influenza vac order"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + and + true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + + then MLMAction := "Reassess Only"; + trigger:= "Order Button YES was selected"; + endif; + + +// Imnnoucompromized button change + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Influenza Immuno Comp y/n"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + then trigger := "Immunocompromised Button was changed"; + If SavedNoneContraValue = "true" + then MLMAction := "Reassess Only"; // No Contraindications were identified + else MLMAction := "No Assessment Required"; // Patient has contraindications + endif; + endif; + + +// Chronic Condition button change + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Influenza has Chronic Illness y/n"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + then trigger := "Chronic Illness Button was changed"; + If SavedNoneContraValue = "true" + then MLMAction := "Reassess Only"; // No Contraindications were identified + else MLMAction := "No Assessment Required"; // Patient has contraindications + endif; + endif; + + + +// Date has Changed + + theParameter := first of (thisParameters where thisParameters.Name = "SCHCK_vaccine received date"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + then trigger := "Date was changed"; + If SavedNoneContraValue = "true" + then MLMAction := "Reassess Only"; // No Contraindications were identified + else MLMAction := "No Assessment Required"; // Patient has contraindications + endif; + endif; + + + +// Pregnancy button change + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Influenza is Preg y/n"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + then trigger := "Prenancy Button was changed"; + If SavedNoneContraValue = "true" + then MLMAction := "Reassess Only"; // No Contraindications were identified + else MLMAction := "No Assessment Required"; // Patient has contraindications + endif; + endif; + + +// Doses This Season button change + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Influenza number inject THIS YR"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + then trigger := "Doses This Season Button was changed"; + If SavedNoneContraValue = "true" + then MLMAction := "Reassess Only"; // No Contraindications were identified + else MLMAction := "No Assessment Required"; // Patient has contraindications + endif; + endif; + + + +// Doses Last Season button change + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Influenza number inject PRIOR SEASONS"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + then trigger := "Doses Prior Seasons Button was changed"; + If SavedNoneContraValue = "true" + then MLMAction := "Reassess Only"; // No Contraindications were identified + else MLMAction := "No Assessment Required"; // Patient has contraindications + endif; + endif; + + + +// RETRIEVE AND REASSESS (or REASSESS ONLY) SECTION + + +if MLMAction = "Retrieve and Reassess" or MLMAction = "Reassess Only" then + + + + +// RETRIEVE AND REASSESS SECTION + + + If MLMAction = "Retrieve and Reassess" then + + + +// Date vaccine was charted in the patient profile + + +(vaccinecharteddate) := read last +{ +" select " +||" case when LEN(o.valuetext) = 8 then " +||" case when (substring(o.valuetext, 7, 1)) in ({{{SINGLE-QUOTE}}}7{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}8{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}9{{{SINGLE-QUOTE}}}) then {{{SINGLE-QUOTE}}}19{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}20{{{SINGLE-QUOTE}}} end " +|| " + (substring(o.valuetext, 7, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +|| "(substring(o.valuetext, 1, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 4, 2)) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| "else " +|| "(substring(o.valuetext, 7, 4)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 1, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 4, 2)) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| " end " +|| " from CV3ClientDocument cd with (nolock) " +|| " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = " || ClientGuid || " and cdd.active = 1) " +|| " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " +|| " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " +|| " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID and ocmi.name = {{{SINGLE-QUOTE}}}SCHCK_vaccine received date{{{SINGLE-QUOTE}}} " +|| " where cd.clientguid = " || ClientGuid || " and cd.iscanceled = 0 and cd.documentname like {{{SINGLE-QUOTE}}}%patient profile%{{{SINGLE-QUOTE}}} " +|| " order by (substring(o.valuetext, 7, 2)), (substring(o.valuetext, 1, 2)) , (substring(o.valuetext, 4, 2)) " +}; + +vaccinechartedwhen := (vaccinecharteddate as time); + + +// Date vaccine was charted as given in the EMAR + +(vaccinegivenwhen) := read last +{ +" select oto.performedfromdtm " +|| " from cv3ordercatalogmasteritem as ocmi with (nolock) " +|| " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid " +|| " and o.ClientGUID = " || ClientGuid || " " +|| " and o.name in ({{{SINGLE-QUOTE}}}Influenza Virus Trivalent Vaccine Inj{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Influenza Virus Vaccine Pediatric Inj{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}Influenza Virus Trivalent Vaccine Pediatric Inj{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Influenza Virus Vaccine Inj{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Influenza Virus Vaccine High Dose Inj{{{SINGLE-QUOTE}}} ) " +|| " join cv3ordertask as ot with (nolock) on ot.clientguid = o.clientguid and ot.orderguid = o.guid " +|| " join cv3ordertaskoccurrence as oto with (nolock) on oto.clientguid = ot.clientguid and oto.orderguid = ot.orderguid " +|| " and oto.ordertaskguid = ot.guid and oto.taskstatuscode ={{{SINGLE-QUOTE}}}Performed{{{SINGLE-QUOTE}}} " +}; + + +// Date vaccine was last charted as an active health issue + + +(vaccinehealthissuedate) := read last +{ +" select " +|| " case when onsetyearnum = 0 " +|| " then createdwhen " +|| " else " +|| " case when (onsetmonthnum >0 and onsetmonthnum <10) then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} + cast (onsetmonthnum as varchar) " +|| " when onsetmonthnum = 0 then {{{SINGLE-QUOTE}}}01{{{SINGLE-QUOTE}}} else cast (onsetmonthnum as varchar) end + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +|| " case when (onsetdaynum >0 and onsetdaynum <10) then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} + cast (onsetdaynum as varchar) " +|| " when onsetdaynum = 0 then {{{SINGLE-QUOTE}}}01{{{SINGLE-QUOTE}}} else cast (onsetdaynum as varchar) end " +|| " + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + cast (onsetyearnum as varchar) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| " end {{{SINGLE-QUOTE}}}date returned to mlm{{{SINGLE-QUOTE}}} " +|| " from cv3healthissuedeclaration with (nolock) " +|| " where clientguid = " || ClientGuid || " and active = 1 and status = {{{SINGLE-QUOTE}}}active{{{SINGLE-QUOTE}}}" +|| " and (text like {{{SINGLE-QUOTE}}}%Influenza Vaccine%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%Influenza Vaccine%{{{SINGLE-QUOTE}}} or description like {{{SINGLE-QUOTE}}}%Influenza Vaccine%{{{SINGLE-QUOTE}}} " +|| " or ShortName like {{{SINGLE-QUOTE}}}%influenza%pediatric%{{{SINGLE-QUOTE}}} or ShortName like {{{SINGLE-QUOTE}}}%influenza%quadrivalent%{{{SINGLE-QUOTE}}} or ShortName like {{{SINGLE-QUOTE}}}%influenza%high%{{{SINGLE-QUOTE}}} or ShortName like {{{SINGLE-QUOTE}}}%influenza%trivalent%{{{SINGLE-QUOTE}}})" +|| " order by createdwhen " +}; +vaccinehealthissue_found := count(vaccinehealthissue) As Number; + + + +// Chronic Illness health issues + +/* 08.31.2015 DW ICD10 + +(chronicillness) := read +{ +" select distinct hi.shortname " +|| "from cv3healthissuedeclaration hi with (nolock) " +|| "join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID " +|| "where hi.clientguid = " || ClientGuid || " and hi.active = 1 and hi.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " +|| "and hi.typecode not in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}chronic dx{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}dx comments{{{SINGLE-QUOTE}}}) " +|| " and ( " +|| "hi.text like {{{SINGLE-QUOTE}}}%Diabetes%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Diabetes%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Renal%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Renal%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Cardiomyopathy%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Cardiomyopathy%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%CardioVascular Disease%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%CardioVascular Disease%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Coronary Artery Disease%{{{SINGLE-QUOTE}}}or hi.shortname like {{{SINGLE-QUOTE}}}%Coronary Artery Disease%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%CHF%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%CHF%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Congestive Heart Failure%{{{SINGLE-QUOTE}}}or hi.shortname like {{{SINGLE-QUOTE}}}Congestive Heart Failure{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Abuse, Alcohol%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Abuse, Alcohol%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Tobacco%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Tobacco%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Liver Disease%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Liver Disease%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Asthma%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Asthma%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Splenectomy%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Splenectomy%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Heart Disease%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Heart Disease%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%bronchitis,chronic%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%chronic bronchitis%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%copd%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%copd%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Anemia, Sickle Cell%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Anemia, Sickle Cell%{{{SINGLE-QUOTE}}} or " +|| "(case when chi.typecode = {{{SINGLE-QUOTE}}}imo{{{SINGLE-QUOTE}}} then substring(chi.code, 5, 20) when chi.TypeCode = {{{SINGLE-QUOTE}}}icd9{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}305.1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}V15.82{{{SINGLE-QUOTE}}}) " +|| " ) " +|| " and (hi.text not like {{{SINGLE-QUOTE}}}Adrenal%{{{SINGLE-QUOTE}}} or hi.shortname not like {{{SINGLE-QUOTE}}}%adrenal%{{{SINGLE-QUOTE}}}) " +|| " and (hi.description not like {{{SINGLE-QUOTE}}}Cyst, Renal%{{{SINGLE-QUOTE}}} or hi.shortname not like {{{SINGLE-QUOTE}}}Cyst, Renal%{{{SINGLE-QUOTE}}}) " +|| " and (hi.description not like {{{SINGLE-QUOTE}}}Renal Calculi%{{{SINGLE-QUOTE}}} or hi.shortname not like {{{SINGLE-QUOTE}}}Kidney Stones%{{{SINGLE-QUOTE}}}) " +|| " and (hi.description not like {{{SINGLE-QUOTE}}}Renal Stone%{{{SINGLE-QUOTE}}} or hi.shortname not like {{{SINGLE-QUOTE}}}Renal Stone%{{{SINGLE-QUOTE}}}) " +|| " and (hi.description not like {{{SINGLE-QUOTE}}}Diabetes, Gestational%{{{SINGLE-QUOTE}}} or hi.shortname not like {{{SINGLE-QUOTE}}}Diabetes, Gestational%{{{SINGLE-QUOTE}}}) " +}; +*/ + +(chronicillness) := read +{ +" select distinct hi.shortname " +|| "from cv3healthissuedeclaration hi with (nolock) " +|| "join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID " +|| "where hi.clientguid = " || ClientGuid || " and hi.active = 1 and hi.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " +|| "and hi.typecode not in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}chronic dx{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}dx comments{{{SINGLE-QUOTE}}}) " +|| " and ( " +|| "hi.text like {{{SINGLE-QUOTE}}}%Diabetes%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Diabetes%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Renal%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Renal%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Cardiomyopathy%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Cardiomyopathy%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%CardioVascular Disease%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%CardioVascular Disease%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Coronary Artery Disease%{{{SINGLE-QUOTE}}}or hi.shortname like {{{SINGLE-QUOTE}}}%Coronary Artery Disease%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%CHF%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%CHF%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Congestive Heart Failure%{{{SINGLE-QUOTE}}}or hi.shortname like {{{SINGLE-QUOTE}}}Congestive Heart Failure{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Abuse, Alcohol%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Abuse, Alcohol%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Tobacco%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Tobacco%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Liver Disease%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Liver Disease%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Asthma%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Asthma%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Splenectomy%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Splenectomy%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Heart Disease%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Heart Disease%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%bronchitis,chronic%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%chronic bronchitis%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%copd%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%copd%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Anemia, Sickle Cell%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Anemia, Sickle Cell%{{{SINGLE-QUOTE}}} or " +|| " ( " +|| " (hi.ICD9Code is null and chi.code in ({{{SINGLE-QUOTE}}}305.1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}V15.82{{{SINGLE-QUOTE}}}) ) " +|| " or " +|| " (hi.ICD9Code is not null and hi.ICD9Code in ({{{SINGLE-QUOTE}}}305.1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}V15.82{{{SINGLE-QUOTE}}}) ) " +|| " ) " +|| " ) " +|| " and (hi.text not like {{{SINGLE-QUOTE}}}Adrenal%{{{SINGLE-QUOTE}}} or hi.shortname not like {{{SINGLE-QUOTE}}}%adrenal%{{{SINGLE-QUOTE}}}) " +|| " and (hi.description not like {{{SINGLE-QUOTE}}}Cyst, Renal%{{{SINGLE-QUOTE}}} or hi.shortname not like {{{SINGLE-QUOTE}}}Cyst, Renal%{{{SINGLE-QUOTE}}}) " +|| " and (hi.description not like {{{SINGLE-QUOTE}}}Renal Calculi%{{{SINGLE-QUOTE}}} or hi.shortname not like {{{SINGLE-QUOTE}}}Kidney Stones%{{{SINGLE-QUOTE}}}) " +|| " and (hi.description not like {{{SINGLE-QUOTE}}}Renal Stone%{{{SINGLE-QUOTE}}} or hi.shortname not like {{{SINGLE-QUOTE}}}Renal Stone%{{{SINGLE-QUOTE}}}) " +|| " and (hi.description not like {{{SINGLE-QUOTE}}}Diabetes, Gestational%{{{SINGLE-QUOTE}}} or hi.shortname not like {{{SINGLE-QUOTE}}}Diabetes, Gestational%{{{SINGLE-QUOTE}}}) " +}; + + + +chronicillness_found := count(chronicillness) As Number; + +if chronicillness_found > 0 + then chronic := "something found"; + else chronic := "unknown"; +endif; + +// Immunocompromised health issues + + +(immunocompromised) := read +{ +"select distinct shortname " +|| "from cv3healthissuedeclaration with (nolock) " +|| "where clientguid = " || ClientGuid || " and active = 1 and status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " +|| "and typecode not in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}chronic dx{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}dx comments{{{SINGLE-QUOTE}}}) and ( " +|| " text like {{{SINGLE-QUOTE}}}%Splenectomy%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%Splenectomy%{{{SINGLE-QUOTE}}} or " +|| " text like {{{SINGLE-QUOTE}}}%Transplant%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%Transplant%{{{SINGLE-QUOTE}}} or " +|| " text like {{{SINGLE-QUOTE}}}%Anemia, Sickle Cell%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%Anemia, Sickle Cell%{{{SINGLE-QUOTE}}} or " +|| " text like {{{SINGLE-QUOTE}}}%Chemotherapy%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%Chemotherapy%{{{SINGLE-QUOTE}}} or " +|| " text like {{{SINGLE-QUOTE}}}%Cardiomyopathy%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%Cardiomyopathy%{{{SINGLE-QUOTE}}} or " +|| " text like {{{SINGLE-QUOTE}}}%HIV%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%HIV%{{{SINGLE-QUOTE}}} or " +|| " text like {{{SINGLE-QUOTE}}}%Radiation%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%Radiation%{{{SINGLE-QUOTE}}} or " +|| " text like {{{SINGLE-QUOTE}}}%Radiation Therapy%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%Radiation Therapy%{{{SINGLE-QUOTE}}} or " +|| " text like {{{SINGLE-QUOTE}}}%Cancer%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%Cancer%{{{SINGLE-QUOTE}}} ) " +}; +immunocompromised_found := count(immunocompromised) As Number; + +if immunocompromised_found > 0 + then immuno := "something found"; + else immuno := "unknown"; +endif; + + + +// Populate Fields and Boxes + + + +// Chronic Illness + + +// First determine if a button has previously been selected by the nurse and do not override it + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Influenza has Chronic Illness y/n"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then chronic := "true"; + endif; + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no") + then chronic := "false"; + endif; + +// Select the Chronic Illness YES radio button if one is found (only if no button has been peviously selected) + + If chronic = "something found" then + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Influenza has Chronic Illness y/n"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "yes" and chronicillness_found > 0 + then selectedItem.IsSelected := true; chronic := "true"; + endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + + +// Populate the Chronic Illnesses Information box + + holdchron:=""; + if chronicillness_found > 0 then + for k in (1 seqto (chronicillness_found )) do + if chronicillness[k] is not null then + holdchron := holdchron || chronicillness[k] ; + if k <> chronicillness_found then // not the last in the list + holdchron := holdchron || ", "; + endif; + endif; + enddo; + endif; + if holdchron = "" then formattedTextChron := " Nothing found. Does the patient have an illness that can be considered a chronic illness as defined by protocol? "; + else formattedtextChron := holdchron; + endif; + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Influenza Chronic Ill FT"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := formattedTextChron; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + + +// Immunocompromised + + +// First determine if a button has previously been selected by the nurse and do not override it + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Influenza immuno Comp y/n"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then immuno := "true"; + endif; + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no") + then immuno := "false"; + endif; + +// Select the Immunocompromised YES radio button if one is found (only if no button has been peviously selected) + + If immuno = "something found" then + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Influenza immuno Comp y/n"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "yes" and immunocompromised_found > 0 then selectedItem.IsSelected := true; immuno := "true"; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + +// Populate the Immunocompromised Information box + + holdchron:=""; + if immunocompromised_found > 0 then + for k in (1 seqto (immunocompromised_found )) do + if immunocompromised[k] is not null then + holdchron := holdchron || immunocompromised[k] ; + if k <> immunocompromised_found then // not the last in the list + holdchron := holdchron || ", "; + endif; + endif; + enddo; + endif; + if holdchron = "" then formattedTextImmune := " Nothing found. Does the patient have any reason to be immunocompromised as defined by protocol? "; + else formattedTextImmune := holdchron; + endif; + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Influenza Immuno FT"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := formattedTextImmune; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + + +// Date + + +// First determine which of the 3 dates is latest (Pneumococcal given, charted, or health issue) + + match1 := false; + match2 := false; + match3 := false; + nodates:= false; + + If vaccinegivenwhen is null and vaccinehealthissuedate is null and vaccinechartedwhen is null + then nodates := true; endif; + + If vaccinegivenwhen is null then vaccinegivenwhen := 1800-01-01T00:00:00; endif; + If vaccinehealthissuedate is null then vaccinehealthissuedate := 1800-01-01T00:00:00; endif; + If vaccinechartedwhen is null then vaccinechartedwhen := 1800-01-01T00:00:00; endif; + + match1 := vaccinegivenwhen IS AFTER vaccinehealthissuedate; + + If match1 = true + then match2 := vaccinegivenwhen IS AFTER vaccinechartedwhen; + else match3 := vaccinehealthissuedate IS AFTER vaccinechartedwhen; + endif; + + If match2 = true then givenwins := true; endif; + If match3 = true then healthissuewins := true; endif; + If (match2 = false) and (match3 = false) then chartedwins := true; endif; + + + if nodates = false then + If givenwins = true then latestdate := vaccinegivenwhen; endif; + If healthissuewins = true then latestdate := vaccinehealthissuedate; endif; + If chartedwins = true then latestdate := vaccinechartedwhen; endif; + endif; + +// If the latest date is not within this flu season, blank it out (only show dates in this flu season) + + if (latestdate as time) < (flu_season_start as time) then latestdate := null; endif; + +// Populate Date field + + +// First determine if the field has been manually updated by the nurse (not empty) + + theParameter := first of (thisParameters where thisParameters.Name = "SCHCK_vaccine received date"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + datefieldcontents := theObservation.ValueObj.Value; + + if datefieldcontents is null + then datefield := latestdate; + else datefield := datefieldcontents; + endif; + +// Populate the field if history is found in SCM and the field hasn{{{SINGLE-QUOTE}}}t been overriden by the nurse (not empty) + + If latestdate is not null and datefieldcontents is null + then + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_vaccine received date"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "DateValue"; + this_currentObj.ValueObj := New DateValueType; + this_currentObj.ValueObj.Value := latestdate; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + + + +// REASSESS ONLY SECTION + + + elseIf MLMAction = "Reassess Only" then + + + +// Determine which of the chronic illness buttons is selected + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Influenza has Chronic Illness y/n"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true not in (theObservation.ValueObj.ListItemsList.IsSelected) + then chronic := "unknown"; + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then chronic := "true"; + else chronic := "false"; + endif; + + +// Determine which of the immunocompromised buttons is selected + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Influenza immuno Comp y/n"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true not in (theObservation.ValueObj.ListItemsList.IsSelected) + then immuno := "unknown"; + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then immuno := "true"; + else immuno := "false"; + endif; + + +// Determine if any of the Contraindications boxes are checked + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_influ vac contra 2"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true not in (theObservation.ValueObj.ListItemsList.IsSelected) + then contraboxchecked := "unknown"; + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "none") + then contraboxchecked := "false"; + else contraboxchecked := "true"; + endif; + + +// Determine the value of the date given field + + theParameter := first of (thisParameters where thisParameters.Name = "SCHCK_vaccine received date"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + datefield := theObservation.ValueObj.Value; + + if datefield is null or (datefield as time) < (flu_season_start as time) then datefield := "unknown"; endif; + + +// Determine which Pregnancy button is selected + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Influenza is Preg y/n"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true not in (theObservation.ValueObj.ListItemsList.IsSelected) + then pregnant := "unknown"; + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then pregnant := "true"; + else pregnant := "false"; + endif; + + +// Determine which of the Doses This Season buttons is selected + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Influenza number inject THIS YR"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true not in (theObservation.ValueObj.ListItemsList.IsSelected) + then dosesthisseason := "unknown"; + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "0") + then dosesthisseason := "0"; + if datefield <> "unknown" then + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "There is conflicting information." || "\n\n There is a vaccine received date for this season and you have selected zero doses this season." || "\n\n Please resolve this inconsistency." ,"Action Required","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "1") + then dosesthisseason := "1"; + if datefield = "unknown" then + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "A date from this flu season is required with this selection." || "\n\n If the date is not known please enter August 1 of this flu season." ,"Action Required","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "2") + then dosesthisseason := "2"; + if datefield = "unknown" then + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "A date from this flu season is required with this selection." || "\n\n If the date is not known please enter August 1 of this flu season." ,"Action Required","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "unknown") + then dosesthisseason := "unknown"; + endif; + + +// Determine which Double Doses in Prior Season buttons is selected + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Influenza number inject PRIOR SEASONS"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true not in (theObservation.ValueObj.ListItemsList.IsSelected) + then doubledosepriorseason := "unknown"; + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then doubledosepriorseason := "true"; + else doubledosepriorseason := "false"; + endif; + + + endif; // End of "Reassess Only" Section + + + + + +// ASSESS THE RISK SECTION ("Retrieve and Reassess" or "Reassess Only") + + + if MLMAction = "Retrieve and Reassess" or MLMAction = "Reassess Only" then + + + +// Age + +(dob,dob65,patientage) := read last + { +" select " +||" cast (birthyearnum as varchar) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +||" case when birthmonthnum <10 then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}end + cast (birthmonthnum as varchar) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +||" case when birthdaynum <10 then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}end + cast (birthdaynum as varchar) + {{{SINGLE-QUOTE}}}T00:00:00{{{SINGLE-QUOTE}}}, " +||" cast (birthyearnum + 65 as varchar) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +||" case when birthmonthnum <10 then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}end + cast (birthmonthnum as varchar) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +||" case when birthdaynum <10 then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}end + cast (birthdaynum as varchar) + {{{SINGLE-QUOTE}}}T00:00:00{{{SINGLE-QUOTE}}}, " +||" case when " +||" right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (datepart (MM,getdate()) as varchar),2) + right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (datepart (DD,getdate()) as varchar),2) < " +||" right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (birthmonthnum as varchar),2) + right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (birthdaynum as varchar),2) " +||" then datediff (yy, cast (birthyearnum as varchar) ,getdate()) -1 " +||" else datediff (yy, cast (birthyearnum as varchar) ,getdate()) " +||" end " +||" from cv3client with (nolock) where guid = " || ClientGuid || " " +}; + + + +// Determine the age range of the patient + + if ((NOW - (dob as time)) / (1 month)) < 6 then agerange := "1"; agerangenote := agerange1note; endif; + if ((NOW - (dob as time)) / (1 month)) >= 6 and (patientage as number) < agerange3_lowerlimit then agerange := "2"; agerangenote := agerange2note; endif; + if (patientage as number) >= agerange3_lowerlimit and (patientage as number) < agerange4_lowerlimit then agerange := "3"; agerangenote := agerange3note; endif; + if (patientage as number) >= agerange4_lowerlimit and (patientage as number) < agerange5_lowerlimit then agerange := "4"; agerangenote := agerange4note; endif;// Row for 9 and Older Age & agerange4note := "9 to 18"; + if (patientage as number) >= agerange5_lowerlimit and (patientage as number) < agerange6_lowerlimit then agerange := "5"; agerangenote := agerange5note; endif; + if (patientage as number) >= agerange6_lowerlimit and (patientage as number) < agerange7_lowerlimit then agerange := "6"; agerangenote := agerange6note; endif; + if (patientage as number) >= agerange7_lowerlimit then agerange := "7"; agerangenote := agerange7note; highdose := "true"; endif; //added as part of CSR 37633 - SZ + +// break; +// Determine how long ago the vaccine was given and the patients age at the time + + if (datefield as time)is within the past 365 days then within365 := "true"; else within365 := "false"; endif; + if (datefield as time)is within the past 5 years then within5years:= "true"; else within5years:= "false"; endif; + if (datefield as time) > (dob65 as time) then vacover65 := "true"; else vacover65 := "false"; endif; + if (datefield as time)is within the past 30 days then within30 := "true"; else within30 := "false"; endif; + + // set to unknown to satisfy conditions below + + if datefield is null then datefield := "unknown"; endif; + + +// Risk Senarios + + +// Scenarios that will cause an order to be placed + +/* +If agerange in ("4", "6") and datefield = "unknown" then ordervaccine := "yes"; +formattedTextReason := "Y-1. Order is to be placed since patient is not 19-50 and has not received a vaccine within this flu season." ; endif; + +If agerange in ("2", "3") and datefield = "unknown" and dosesthisseason = "0" then ordervaccine := "yes"; +formattedTextReason := "Y-2. Order is to be placed since patient is 6 months to 8 years and has not received a vaccine within this flu season." ; endif; + +If agerange in ("2", "3") and dosesthisseason = "1" and doubledosepriorseason = "false" then ordervaccine := "yes"; +formattedTextReason := "Y-3. Order is to be placed since patient is 6 months to 8 years and has received less than 2 vaccine doses." ; endif; + +If agerange in ("2", "3") and dosesthisseason = "unknown" then ordervaccine := "yes"; +formattedTextReason := "Y-4. Order is to be placed since patient is 6 months to 8 years and it is unknown if they have received a vaccine within this flu season." ; endif; + +If agerange = "5" and datefield = "unknown" and (chronic = "true" or immuno = "true") then ordervaccine := "yes"; +formattedTextReason := "Y-5. Order is to be placed since patient is 19-50, has a chronic illness or is immunocompromised and has not received a vaccine within this flu season." ; endif; + +If pregnant = "true" and datefield = "unknown" then ordervaccine := "yes"; +formattedTextReason := "Y-6. Order is to be placed since patient is pregnant and has not received a vaccine within this flu season." ; endif; +*/ + +If agerange <> "1" and datefield = "unknown" then ordervaccine := "yes"; +formattedTextReason := "Y-7. Order is to be placed since patient is over 6 months and has not received a vaccine within this flu season." ; endif; + +//Break; +/**** CSR 33143 : Code added by Shivprasad */ +//======================================================================= +If agerange In( "2","3") //and datefield = "unknown" +And dosesthisseason = "1" then +//Break; +If doubledosepriorseason= "True" Then + ordervaccine := "No"; + formattedTextReason := "N-8. Order Cannot to be placed since patient is over 6 months to 9 Year and has received a 0 or 1 vaccine within this flu season." ; + + Else + ordervaccine := "yes"; + formattedTextReason := "Y-8. Order is to be placed since patient is over 6 months to 9 Year and has received a 0 or 1 vaccine within this flu season." ; +//Break; +Endif; +ElseIf agerange In( "2","3") And dosesthisseason = "2" Then +ordervaccine := "No"; + +endif; + + +//=============================================================================== +/* End Code :Shivprasad */ + +// Scenarios that will NOT cause an order to be placed +/* +If datefield <> "unknown" and agerange not in ("2", "3") then ordervaccine := "no"; +formattedTextReason := "N-1. Order is not to be placed since patient has had a vaccine for the current flu season. " ; endif; +*/ +If agerange = "1" then ordervaccine := "no"; +formattedTextReason := "N-2. Patient is under 6 months do not recieve the vaccine. " ; endif; + +//Break; +/* +If agerange in ("2", "3") and dosesthisseason in ("1", "2") and doubledosepriorseason = "true" then ordervaccine := "no"; +formattedTextReason := "N-3. Order is not to be placed since patient is 6 months to 8 years and has received a vaccine dose this season and 2 doses in a prior season." ; endif; + +If agerange = "5" and immuno = "false" and chronic = "false" and pregnant in ("false","unknown") then ordervaccine := "no"; +formattedTextReason := "N-4. Order is not to be placed since patient is 19-50 and does not meet criteria." ; endif; +*/ + + // Special Handling for Place Order Button Changes + + +/* 11/28/2012 DW stopped override entirely CSR# 6496 MLM + + If trigger = "Order Button NO was selected" then ordervaccine := "no"; + formattedTextReason := formattedTextReason || " ** OVERRIDDEN TO NO BY " || userId || " ** "; endif; +*/ +If trigger = "Order Button NO was selected" and ordervaccine = "yes" then +dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n This patient meets the criteria for a vaccination order. \n\n Select ""Refuses Influenza Vaccine"" if an order is not to be entered. ", "Error","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; +formattedTextReason := formattedTextReason || " ** OVERRIDDEN TO NO BY " || userId || " ** "; endif; + +If trigger = "Order Button YES was selected" and ordervaccine = "no" then +dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n You cannot place an order on this patient. ", "Error","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; +formattedTextReason := formattedTextReason || " ** FAILED OVERRIDE TO YES BY " || userId || " ** "; endif; + + + + endif; // end of section for assessing risk + + + + endif; // End of Bypass Everything (If MLMAction <> "No Assessment Required") + + + + +// FOR ANY OBSERVATION CHANGE + + +// Select the appropriate Order Pneumococcal radio button determined by the assessment + + + If contraboxchecked = "true" then ordervaccine := "no"; + formattedTextReason := "N-7. Order will not be placed since the vaccine is contraindicated."; endif; + + If within30 = "true" then ordervaccine := "no"; + formattedTextReason := "N-8. Order will not be placed since the vaccine has been given in the last 30 days."; endif; + + If todays_date < protocol_start or todays_date > protocol_end then ordervaccine := "no"; + formattedTextReason := "N-9. Physician order is required for Influenza vaccine to be administered before October 1st or after March 31st. " ; endif; + + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Influenza vac order"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "yes" and ordervaccine = "yes" then selectedItem.IsSelected := true; endif; + if selectedItem.Value = "no" and ordervaccine = "no" then selectedItem.IsSelected := true; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + +//Break; + +// Appropriately set the hidden Chronic Illness Mandatory button + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Influenza CI- unknown"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if chronic = "unknown" and contraboxchecked = "false" + then selectedItem.IsSelected := true; + else selectedItem.IsSelected := false; + endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + +// Appropriately set the hidden Immunocompromised Mandatory button + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Influenza IC- unknown"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if immuno = "unknown" and contraboxchecked = "false" + then selectedItem.IsSelected := true; + else selectedItem.IsSelected := false; + endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + +// Appropriately set the hidden Pregnancy Mandatory button + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Influenza Preg - unknown"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if pregnant = "unknown" and contraboxchecked = "false" + then selectedItem.IsSelected := true; + else selectedItem.IsSelected := false; + endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + +// Appropriately set the Dosage button + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Influenza inj dosage"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + // if selectedItem.Value = "0.25 ml" and agerange = "2" then selectedItem.IsSelected := true; endif; //SZ - removed for changes in CSR + if selectedItem.Value = "0.25 mL (6 mo - 35 mo)" and agerange = "2" then selectedItem.IsSelected := true; endif; + // if selectedItem.Value = "0.5 ml" and agerange in ("3","4","5","6","7") then selectedItem.IsSelected := true; endif; // Set Dose ML for 9-18 Age Range + if selectedItem.Value = "0.5 mL (3-64 years)" and agerange in ("3","4","5","6","7") then selectedItem.IsSelected := true; endif; // Set Dose ML for 9-18 Age Range + if selectedItem.Value = "0.5 mL HD (65 years+)" and agerange in ("7") then selectedItem.IsSelected := true; endif; // Set Dose ML for 9-18 Age Range + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + +endif; // End of Observation Event section + + + + + +// DOCUMENT CLOSING SECTION + + +IF thisdocumentCommunication.EventType = "DocumentClosing" then +(cdob,cdob65,cpatientage) := read last + { +" select " +||" cast (birthyearnum as varchar) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +||" case when birthmonthnum <10 then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}end + cast (birthmonthnum as varchar) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +||" case when birthdaynum <10 then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}end + cast (birthdaynum as varchar) + {{{SINGLE-QUOTE}}}T00:00:00{{{SINGLE-QUOTE}}}, " +||" cast (birthyearnum + 65 as varchar) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +||" case when birthmonthnum <10 then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}end + cast (birthmonthnum as varchar) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +||" case when birthdaynum <10 then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}end + cast (birthdaynum as varchar) + {{{SINGLE-QUOTE}}}T00:00:00{{{SINGLE-QUOTE}}}, " +||" case when " +||" right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (datepart (MM,getdate()) as varchar),2) + right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (datepart (DD,getdate()) as varchar),2) < " +||" right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (birthmonthnum as varchar),2) + right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (birthdaynum as varchar),2) " +||" then datediff (yy, cast (birthyearnum as varchar) ,getdate()) -1 " +||" else datediff (yy, cast (birthyearnum as varchar) ,getdate()) " +||" end " +||" from cv3client with (nolock) where guid = " || ClientGuid || " " +}; + +if (cpatientage as number) >= 65 then highdose := "true"; endif; +//break; +// Determine if Place Order button is set to "Yes" + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Influenza vac order"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no") + then placeorder := "no"; endif; + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then placeorder := "yes"; endif; + + +// Determine which Dosage Button is selected" + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Influenza inj dosage"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + // if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "0.25 ml") + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "0.25 mL (6 mo - 35 mo)") + then ordername := "Influenza Virus Vaccine Pediatric Inj"; dosage := "0.25ml, IM Once (6mos - 35 mos)"; endif; + + + // if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "0.5 ml") + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "0.5 mL (3-64 years)") + then ordername := "Influenza Virus Vaccine Inj"; dosage := "0.5ml IM Once (3 - 64 years)"; + + /* + then + if highdose = "true" + then ordername := "Influenza Virus Vaccine High Dose Inj"; dosage := "0.5ml, IM Once (65 years and older)"; + else ordername := "Influenza Virus Vaccine Inj"; dosage := "0.5ml IM Once"; + endif; + */ + + endif; + + + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "0.5 mL HD (65 years+)") + then if highdose = "true" + then ordername := "Influenza Virus Vaccine High Dose Inj"; dosage := "0.5ml, IM Once (65 years and older)"; endif; + + endif; + + +// Check for existing Influenza Order on the account + + (orderpresent) := read + { + " select o.name " +|| " from cv3ordercatalogmasteritem as ocmi with (nolock) " +|| " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid " +|| " and o.ClientGUID = " || ClientGuid || " and o.ChartGUID = " || ChartGuid || " and o.ClientVisitGUID= " || VisitGuid || " " +|| " and o.name in ({{{SINGLE-QUOTE}}}Influenza Virus Trivalent Vaccine Inj{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Influenza Virus Trivalent Vaccine Pediatric Inj{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}Influenza Virus Vaccine Inj{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Influenza Virus Vaccine Pediatric Inj{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Influenza Virus Vaccine High Dose Inj{{{SINGLE-QUOTE}}}) " +|| " and o.OrderStatusLevelNum > 15 " + }; +orderpresent_found := count(orderpresent) As Number; + + + +// If no existing order is found and Place Order button is "Yes" then create a new order + +//break; + If placeorder = "yes" and orderpresent_found = 0 then + +//break; + SessionType := "Standard"; + SessionReason := ""; + RequestingSource := "Standing Order"; + user_IDType := "Edstan Number (physician)"; + order_Creation_Reason := "From Test MLM"; + + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((thisdocumentCommunication.ClientVisitGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + user_IDCode := read last {"SELECT IDCode FROM CV3User " || " where GUID = " || thisdocumentCommunication.UserGUID}; + RequestingCareProvider_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindById with ( user_IDType, (user_IDCode as STRING) ); + location_guid := read last {"SELECT CurrentLocationGUID FROM CV3ClientVisit where ClientGUID = " || thisdocumentCommunication.ClientGUID}; + location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((location_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + + // Create a new MEDICATION order from a Pre-Filled item + try + // Catalog_Item_Name := "Influenza Virus Trivalent Vaccine Inj"; + // Catalog_Item_Modifier := "0.5ml IM Once"; + Catalog_Item_Name := ordername; + Catalog_Item_Modifier := dosage; + Catalog_Item_Version := ""; + Medication_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with Catalog_Item_Name; + PreFilled_MedicationOrder_obj := call {{{SINGLE-QUOTE}}}MedicationOrder{{{SINGLE-QUOTE}}}.CreateMedicationOrder + with + client_visit_obj, // ClientVisit ObjectsPlus object + Medication_catalog_item, // OrderCatalogMasterItem ObjectsPlus object + Catalog_Item_Modifier, // string ItemNameModifier + Catalog_Item_Version, // string ItemNameModifierVersion + order_Creation_Reason, // string CreateReason + RequestingCareProvider_obj , // RequestedBy ObjectsPlus object + RequestingSource, // string RequestedBySource (must be in dictionary) + SessionType, // string SessionType + SessionReason, // string SessionReason + location_obj, // Location ReleaseLocGrpID + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; // AvailabilityOverride eAvailabilityOverride + + + if ( Medication_catalog_item is NOT NULL ) then + void := call PreFilled_MedicationOrder_obj.Save; + void := call PreFilled_MedicationOrder_obj.Dispose; + void:= call Medication_catalog_item.Dispose; + Medication_catalog_item:= null; + endif; + + + endtry; + + catch Exception ex error_occurred := true; error_message := "{{+R}}New prefilled medication order:{{-R}}\n" || ex.Message || "\n\n"; + + if ( Medication_catalog_item is NOT NULL ) then void:= call Medication_catalog_item.Dispose; Medication_catalog_item:= null; endif; + if ( PreFilled_MedicationOrder_obj is NOT NULL ) then void:= call PreFilled_MedicationOrder_obj.Dispose; PreFilled_MedicationOrder_obj:= null; endif; + + Prefilled_MedicationOrder_dest := null; + + endcatch; + + if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; + if ( RequestingCareProvider_obj is NOT NULL ) then void:= call RequestingCareProvider_obj.Dispose; RequestingCareProvider_obj:= null; endif; + if ( location_obj is NOT NULL ) then void:= call location_obj.Dispose; location_obj:= null; endif; + + + endif; // End of Place Order = Yes section + + endif; // End of Close Document + + + + +// Populate the HIS only Assessment Information box + + +// This secton as well as the FormattedText1 := below are for diagnostic purposes only + +dateonly:= SUBSTRING 10 CHARACTERS FROM (datefield as string); +fludateonly:= SUBSTRING 10 CHARACTERS FROM (flu_season_start as string); +protstartdateonly:= SUBSTRING 10 CHARACTERS FROM (protocol_start as string); +protenddateonly:= SUBSTRING 10 CHARACTERS FROM (protocol_end as string); +nowdateonly:= SUBSTRING 10 CHARACTERS FROM (now as string); + +Factor2 := "Chronic Condition - " || chronic; +Factor3 := "Immunocompromised - " || immuno || ""; +Factor4 := "WasOver65 - " || vacover65; +Factor5 := "Contraindicated - "|| contraboxchecked; +Factor6 := "Within 365days - " || within365; +Factor7 := "Within 5yrs - " || within5years; +Factor8 := "Last Given This Season - " || dateonly; +Factor9 := "Last Trigger Event - " || nowdateonly || " " || trigger || " by " || userid || " (MLM reaction - " || MLMAction || ")"; +Factor14:= "Age - " || patientage; +Factor17:= "Pregnant - " || pregnant; +Factor18:= "range " || agerange || " (" || agerangenote || ")"; +Factor19:= "Within 30days - " || within30; +Factor20:= "Doses This Season - " || dosesthisseason; +Factor21:= "Double Dose Prior Season - " || doubledosepriorseason; +Factor23:= "Flu Season Start - " || fludateonly; +Factor24:= "Flu Protocol - " || protstartdateonly || " to " || protenddateonly ; +Factor25:= "Place Order - " || placeorder; + + +formattedText1 := "\n\n" || Factor9 || " " || Factor25|| + "\n\n" || Factor14|| " " || Factor18|| " " || Factor17|| + "\n" || Factor5 || " " || Factor2 || " " || Factor3 || + "\n" || Factor8 || " " || Factor6 || " " || Factor19|| " " || Factor7 || " " || Factor4 || " " || Factor20 || " " || Factor21|| + "\n" || Factor23|| " " || Factor24; + +formattedTextReason := formattedTextReason || formattedText1; + +this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Influenza Risk Assess Details"); +this_currentObj := NEW ObservationType; +this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; +this_currentObj.ParameterGUID := this_parametername.ParameterGUID; +this_currentObj.DataType := "FreeTextValue"; +this_currentObj.ValueObj := New FreeTextValueType; +this_currentObj.ValueObj.Value := formattedTextReason; +thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + +// break; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_INSULIN_PUMP_FS_CALC.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_INSULIN_PUMP_FS_CALC.mlm new file mode 100644 index 0000000..e8bd3e9 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_INSULIN_PUMP_FS_CALC.mlm @@ -0,0 +1,164 @@ +maintenance: + + title: ;; + mlmname: DOC_FUNC_INSULIN_PUMP_FS_CALC;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Shawn Head;; + specialist: Dean Miklavic;; + date: 2014-08-26;; + validation: testing;; + +library: + purpose: + This MLM will calculate the above target BGM, the correction bolus and the correction dose on the Insulin Pump flowsheet. + + ;; + explanation: + create for CSR #: 32128 + ;; + keywords: + target BGM, correction bolus, correction dose, insulin pump calculation + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + error_occurred := false; + error_message := ""; + + log_execution_info := false; + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + NumericValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid, ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + //Set Flowsheet DocumentCommunication object model variables via Called MLM + (this_fs_doc) := thisDocumentCommunication.DocumentConfigurationObj; + (this_parameters) := this_fs_doc.ParametersList; + (this_currentObs) := thisDocumentCommunication.CurrentObservationObj; + (this_cols) := this_fs_doc.ColumnsList; + (this_curr_col) := this_fs_doc.CurrentColumn; + (this_chartedObs) := this_curr_col.ChartedObservationsList; + + document_type := thisDocumentCommunication.DocumentType; + event_type := thisDocumentCommunication.EventType; + + client_guid := thisDocumentCommunication.ClientGUID; + visit_guid := thisDocumentCommunication.ClientVisitGUID; + chart_guid := thisDocumentCommunication.ChartGUID; + + + IF thisDocumentCommunication.EventType = "ChartObservation" then + + + theParameter := first of (this_parameters where this_parameters.Name = "SCHCK_AS Current BGM"); + theObservation := first of (this_chartedObs where this_chartedObs.ParameterGUID = theParameter.ParameterGUID); + CurrentBMG := theObservation.ValueObj.Value; + + + theParameter := first of (this_parameters where this_parameters.Name = "SCHCK_AS Target BGM"); + theObservation := first of (this_chartedObs where this_chartedObs.ParameterGUID = theParameter.ParameterGUID); + targetBMG := theObservation.ValueObj.Value; + + theParameter := first of (this_parameters where this_parameters.Name = "SCHCK_AS Above Target BMG"); + theObservation := first of (this_chartedObs where this_chartedObs.ParameterGUID = theParameter.ParameterGUID); + AbovetargetBMG := theObservation.ValueObj.Value; + + theParameter := first of (this_parameters where this_parameters.Name = "SCHCK_AS Insulin Correction Factor"); + theObservation := first of (this_chartedObs where this_chartedObs.ParameterGUID = theParameter.ParameterGUID); + CorrectFactor := theObservation.ValueObj.Value; + + theParameter := first of (this_parameters where this_parameters.Name = "SCHCK_AS Insulin Correction Bolus"); + theObservation := first of (this_chartedObs where this_chartedObs.ParameterGUID = theParameter.ParameterGUID); + CorrectionBolus := theObservation.ValueObj.Value; + + theParameter := first of (this_parameters where this_parameters.Name = "SCHCK_AS Insulin Correction Dose"); + theObservation := first of (this_chartedObs where this_chartedObs.ParameterGUID = theParameter.ParameterGUID); + CorrectDose := theObservation.ValueObj.Value; + + + if (((CurrentBMG as number) > 0) and ((targetBMG as number) > 0)) then + + calcTargetBMG := (CurrentBMG as number) - (targetBMG as number); + + if (AbovetargetBMG is null) or ((AbovetargetBMG as number) <> (calcTargetBMG as number)) then + + AboveBMGparam := first of (this_parameters WHERE this_parameters.Name = "SCHCK_AS Above Target BGM"); + + this_currentObj1 := NEW ObservationType; + this_currentObj1.ClientDocumentGUID := this_fs_doc.ClientDocumentGUID; + this_currentObj1.ParameterGUID := AboveBMGparam.ParameterGUID; + this_currentObj1.DataType := "NumericValue"; + this_currentObj1.ValueObj := NEW NumericValueType; + this_currentObj1.ValueObj.Value := (calcTargetBMG as number); + this_fs_doc.CurrentColumn.ChartedObservationsList := (this_fs_doc.CurrentColumn.ChartedObservationsList, this_currentObj1); + endif; + + endif; + + if ((CorrectFactor as number) > 0) then + if ((calcTargetBMG as number) > 0) then + //SCHCK_AS Above Target BGM / SCHCK_AS Insulin Correction Factor + CorrectiveBolus := ((calcTargetBMG as number) / (CorrectFactor as number)); + CorrectiveBolus := CorrectiveBolus formatted with "%.2f"; + + CorrectiveDose := round (CorrectiveBolus as number); + else + CorrectiveBolus := 0; + CorrectiveDose := 0; + endif; + + CorrectBolusparam := first of (this_parameters WHERE this_parameters.Name = "SCHCK_AS Insulin Correction Bolus"); + CorrectDoseparam := first of (this_parameters WHERE this_parameters.Name = "SCHCK_AS Insulin Correction Dose"); + + this_currentObj2 := NEW ObservationType; + this_currentObj2.ClientDocumentGUID := this_fs_doc.ClientDocumentGUID; + this_currentObj2.ParameterGUID := CorrectBolusparam.ParameterGUID; + this_currentObj2.DataType := "NumericValue"; + this_currentObj2.ValueObj := NEW NumericValueType; + this_currentObj2.ValueObj.Value := (CorrectiveBolus as number); + this_fs_doc.CurrentColumn.ChartedObservationsList := (this_fs_doc.CurrentColumn.ChartedObservationsList, this_currentObj2); + + this_currentObj3 := NEW ObservationType; + this_currentObj3.ClientDocumentGUID := this_fs_doc.ClientDocumentGUID; + this_currentObj3.ParameterGUID := CorrectDoseparam.ParameterGUID; + this_currentObj3.DataType := "NumericValue"; + this_currentObj3.ValueObj := NEW NumericValueType; + this_currentObj3.ValueObj.Value := (CorrectiveDose as number); + this_fs_doc.CurrentColumn.ChartedObservationsList := (this_fs_doc.CurrentColumn.ChartedObservationsList, this_currentObj3); + endif; + + + + + endif; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: + + conclude true; + ;; + action: return thisDocumentCommunication; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_IRU_PREADMISSION_SCREEN.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_IRU_PREADMISSION_SCREEN.mlm new file mode 100644 index 0000000..680a951 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_IRU_PREADMISSION_SCREEN.mlm @@ -0,0 +1,305 @@ +maintenance: + + title: DOC_FUNC_IRU_PREADMISSION_SCREEN;; + mlmname: DOC_FUNC_IRU_PREADMISSION_SCREEN;; + arden: version 15.1;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Juliet Law;; + specialist: Shubha Rai / Debbie Eiler;; + date: 2016-02-29;; + validation: testing;; + +library: + purpose: + ;; + explanation: + + Change history + + 02.29.2016 JML CSR 33994: Create date. + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // Receive arguments from the structured note + (this_documentCommunication) := argument; + + // .Net assemblies required for ObjectsPlus + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + + //Include MLM + str_parse := MLM {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; + + //Include Called MLM to setup CDS objects + set_cds_vars := MLM {{{SINGLE-QUOTE}}}Called_RPM_DOM_Get_Definition_MLM{{{SINGLE-QUOTE}}}; + + Get_result_impression_lookup := MLM {{{SINGLE-QUOTE}}}ACS_result_impression_Lookup{{{SINGLE-QUOTE}}}; + + //Document Types + STRUCTUREDNOTE := "StructuredNote"; + + //Event Types + DOCUMENTCLOSING := "DocumentClosing"; + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTOPENING := "DocumentOpening"; + + //Setting debugFlag to True will allow popup dialogs containing debug information to appear + debugFlag := false; + + //Tab definitions and formating + TAB := 9 FORMATTED WITH "%C" ; + TAB2 := TAB || TAB ; + TAB3 := TAB || TAB || TAB; + CR := 13 formatted with "%c"; + LF := 10 formatted with "%c"; + CRLF:= CR||LF; + CRLF2 := CR||LF||LF; + SP:= 32 formatted with "%c"; + SP2:= SP||SP; + SP3:= SP||SP||SP; + + //Initialize CDS objects via MLM call + (this_documentCommunication, client_guid, client_visit_guid, client_chart_guid, user_guid, + document_type, document_name, event_type, configuration_guid, this_currentObj, CancelEventFlag, + this_structuredNoteDoc, authored_date_time, authored_by_guid, client_document_guid, document_date_time, + isNewFlag, isIncompleteFlag, isResultsPendingFlag, isPriorityFlag, this_parameters, + this_chartedObservationsList, this_parameters_display_name, current_parameter, current_parameter_name, + current_parameter_guid, current_parameter_DataType, selectedItems, selectedItems_value, current_value, + diagnosticMessage, displayMessageFlag, CoSigner1, CoSigner2, DocumentTopic) := CALL set_cds_vars WITH + (this_documentCommunication); + + //Set up debugging information to be captured + messageText := ""; + if (debugFlag = true) then + messageText := "Debug Information:\n\n"; + messageText := messageText || " DOC_FUNC_IRU_PREADMISSION_SCREEN mlm called.\n\n"; + endif; + + //Local Variables + theDocumentName := "Inpatient Rehabilitation Unit Pre-Admission Screen"; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + NumericValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + if ( event_type = DOCUMENTOPENING AND document_name = theDocumentName ) then + + vital_sign_msg := "Vital Signs in last Past 24 Hours - Last Charted"; + //Retrieve last 24 hours of vital signs + + ( vital_sign, + vital_value, + vital_date ) := READ {"SELECT oci.Name, o.ValueText, cd.AuthoredDtm" + || " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3ClientDocumentCUR cd WITH (NOLOCK)" + || " ON cv.ClientGUID = cd.ClientGUID" + || " AND cv.GUID = cd.ClientVisitGUID" + || " AND cv.ChartGUID = cd.ChartGUID" + || " JOIN CV3ClientDocDetailCUR cdd WITH (NOLOCK) " + || " ON cd.GUID = cdd.ClientDocumentGUID" + || " AND cd.ClientGUID = cdd.ClientGUID" + || " JOIN CV3ObservationDocumentCUR od WITH (NOLOCK)" + || " ON cdd.ClientDocumentGUID = od.OwnerGUID " + || " JOIN CV3ObsCatalogMasterItem ocmi WITH (NOLOCK)" + || " ON od.ObsMasterItemGUID = ocmi.GUID" + || " JOIN CV3ObservationCUR o WITH (NOLOCK)" + || " ON o.GUID = od.ObservationGUID" + || " JOIN CV3ObsCatalogItem oci WITH (NOLOCK)" + || " ON oci.guid = o.ObsItemGUID" + || " WHERE cd.ClientGUID = " || Sql(client_guid) + || " AND cd.ChartGUID = " || Sql(client_chart_guid) + || " AND cd.ClientVisitGUID = " || Sql(client_visit_guid) + || " AND cd.DocumentName = {{{SINGLE-QUOTE}}}1.Vital Signs - Basic{{{SINGLE-QUOTE}}}" + || " AND o.ValueText is not null" + || " AND oci.Name IN ({{{SINGLE-QUOTE}}}Farenheit{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Heart Rate{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Resp Rate{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}Noninvasive Systolic BP{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Noninvasive Diastolic BP{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}SCH_vs_pulse ox saturation{{{SINGLE-QUOTE}}})" + || " AND DateDiff(HOUR, cd.AuthoredDtm, GETDATE()) <= 24" + || " AND od.Active = 1" + || " AND cdd.Active = 1" + || " ORDER BY cd.AuthoredDtm"}; + + + if ( exists vital_sign ) then + pulse_ox := "Pulse Ox: "; pulse_ox_value := ""; pulse_ox_datediff := 0; + temp := "T: "; temp_value := ""; temp_datediff := 0; + hr := "HR: "; hr_value := ""; hr_datediff := 0; + resp_rate := "R: "; resp_rate_value := ""; resp_rate_datediff := 0; + bp := "BP: "; bp_sys_value := ""; bp_sys_datediff := 0; + bp_dia_value := ""; bp_dia_datediff := 0; + + for i IN 1 seqto ( count vital_sign ) do + + if ( vital_sign[i] = "SCH_vs_pulse ox saturation" AND pulse_ox_datediff = 0 ) then + pulse_ox_value := vital_value[i]; + pulse_ox_datediff := ( now - vital_date[i] ); + elseif ( vital_sign[i] = "SCH_vs_pulse ox saturation" AND ( ( now - vital_date[i] ) <= pulse_ox_datediff ) ) then + pulse_ox_value := vital_value[i]; + else + pulse_ox_datediff := ( now - vital_date[i] ); + endif; + + if ( vital_sign[i] = "Farenheit" AND temp_datediff = 0 ) then + temp_value := vital_value[i]; + temp_datediff := ( now - vital_date[i] ); + elseif ( vital_sign[i] = "Farenheit" AND ( ( now - vital_date[i] ) <= temp_datediff ) ) then + temp_value := vital_value[i]; + else + temp_datediff := ( now - vital_date[i] ); + endif; + + if ( vital_sign[i] = "Heart Rate" AND hr_datediff = 0 ) then + hr_value := vital_value[i]; + hr_datediff := ( now - vital_date[i] ); + elseif ( vital_sign[i] = "Heart Rate" AND ( ( now - vital_date[i] ) <= hr_datediff ) ) then + hr_value := vital_value[i]; + else + hr_datediff := ( now - vital_date[i] ); + endif; + + if ( vital_sign[i] = "Resp Rate" AND resp_rate_datediff = 0 ) then + resp_rate_value := vital_value[i]; + resp_rate_datediff := ( now - vital_date[i] ); + elseif ( vital_sign[i] = "Resp Rate" AND ( ( now - vital_date[i] ) <= resp_rate_datediff ) ) then + resp_rate_value := vital_value[i]; + else + resp_rate_datediff := ( now - vital_date[i] ); + endif; + + if ( vital_sign[i] = "Noninvasive Systolic BP" AND bp_sys_datediff = 0 ) then + bp_sys_value := vital_value[i]; + bp_sys_datediff := ( now - vital_date[i] ); + elseif ( vital_sign[i] = "Noninvasive Systolic BP" AND ( ( now - vital_date[i] ) <= bp_sys_datediff ) ) then + bp_sys_value := vital_value[i]; + else + bp_sys_datediff := ( now - vital_date[i] ); + endif; + + if ( vital_sign[i] = "Noninvasive Diastolic BP" AND bp_dia_datediff = 0 ) then + bp_dia_value := vital_value[i]; + bp_dia_datediff := ( now - vital_date[i] ); + elseif ( vital_sign[i] = "Noninvasive Diastolic BP" AND ( ( now - vital_date[i] ) <= bp_dia_datediff ) ) then + bp_dia_value := vital_value[i]; + else + bp_dia_datediff := ( now - vital_date[i] ); + endif; + + enddo; + + vital_sign_msg := vital_sign_msg || CRLF2 || TAB || vital_date[i] || SP2 || temp || temp_value + || SP2 || hr || hr_value + || SP2 || resp_rate || resp_rate_value + || SP2 || bp || bp_sys_value || "/" || bp_dia_value + || SP2 || pulse_ox || pulse_ox_value; + + else + + vital_sign_msg := vital_sign_msg || CRLF2 || TAB || "No vital signs charted in the last 24 hours."; + endif; + + VitalParameterName := "SCH_FB_IRU Vital Signs"; + VitalParameter := first of ( this_parameters WHERE this_parameters.Name = VitalParameterName ); + + this_currentVitalsObs := NEW ObservationType; + this_currentVitalsObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID; + this_currentVitalsObs.ParameterGUID := VitalParameter.ParameterGUID; + this_currentVitalsObs.DataType := "FreeTextValue"; + this_currentVitalsObs.ValueObj := NEW FreeTextValueType; + this_currentVitalsObs.ValueObj.Value := vital_sign_msg; + + this_structuredNoteDoc.ChartedObservationsList := ( this_structuredNoteDoc.ChartedObservationsList, this_currentVitalsObs ); + + + //Retrieve applicable diagnostic MI / Cardiac results + medical_imaging_msg := "Medical Imaging Results in last 7 days"; + + ( order_name, + order_dttm ) := READ {"SELECT DISTINCT {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}} + o.Name + {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}, osh.CreatedWhen" + || " FROM CV3ClientVisit v WITH (NOLOCK) JOIN CV3Order o WITH (NOLOCK) " + || " ON v.GUID = o.ClientVisitGUID" + || " AND v.ClientGUID = o.ClientGUID" + || " AND v.ChartGUID = o.ChartGUID" + || " JOIN CV3OrderStatusHistory osh WITH (NOLOCK)" + || " ON o.GUID = osh.OrderGUID" + || " AND o.ClientGUID = osh.ClientGUID" + || " JOIN CV3OrderCatalogMasterItem om WITH (NOLOCK) " + || " ON o.OrderCatalogMasterItemGUID = om.GUID" + || " JOIN CV3OrganizationalUnit org WITH (NOLOCK) " + || " ON om.OrgUnitGUID = org.GUID" + || " WHERE v.ClientGUID = " || Sql(client_guid) + || " AND v.GUID = " || Sql(client_visit_guid) + || " AND v.ChartGUID = " || Sql(client_chart_guid) + || " AND o.CreatedWhen >= dateadd(day, -7, getdate())" + || " and o.CreatedWhen < DATEADD(day, 0, getdate())" + || " AND o.TypeCode = {{{SINGLE-QUOTE}}}Diagnostic{{{SINGLE-QUOTE}}}" + || " AND osh.FunctionCodeNum = {{{SINGLE-QUOTE}}}10{{{SINGLE-QUOTE}}}" + || " AND ( org.code LIKE {{{SINGLE-QUOTE}}}%medical imaging%{{{SINGLE-QUOTE}}}" + || " OR org.Code like {{{SINGLE-QUOTE}}}%cardiology%{{{SINGLE-QUOTE}}}" + || " OR org.Code like {{{SINGLE-QUOTE}}}%cardiac%{{{SINGLE-QUOTE}}}" + || " OR org.Code like {{{SINGLE-QUOTE}}}%eeg%{{{SINGLE-QUOTE}}})"}; + + if ( exists order_name ) then + + Retreive_Attribute := "text_val"; + Retreive_Object := "Results"; + Filterable_Attribute := "itemname"; + Filterable_Operator := "IN" ; + + if ( count order_name = 1 ) then + Filterable_Value := first of ( order_name ); + else + Filterable_Value := order_name; + endif; + + Additional_condition := ""; + + // Call Impression Lookup MLM to get patient data + (All_Attributes_Lst, All_Med_Rel_Dttm_Lst, All_Values_Lst) := CALL Get_result_impression_lookup WITH + (client_guid, client_visit_guid, client_chart_guid, Is_Historical, Retreive_Object, Retreive_Attribute, + Filterable_Attribute, Filterable_Operator, Filterable_Value, Additional_condition); + + if ( exists All_Values_Lst ) then + for i IN 1 seqto ( count All_Attributes_Lst ) do + medical_imaging_msg := medical_imaging_msg || CRLF2 || TAB || All_Attributes_Lst[i] || SP + || All_Med_Rel_Dttm_Lst[i] || ": " || All_Values_Lst[i]; + enddo; + else + medical_imaging_msg := medical_imaging_msg || CRLF2 || TAB || "No IMAGE diagnostic impressios Recorded."; + endif; + else + medical_imaging_msg := medical_imaging_msg || CRLF2 || TAB || "No IMAGE diagnostic impressions Recorded."; + endif; + + MIParameterName := "SCH_FB_IRU_Diagnosis"; + MIParameter := first of ( this_parameters WHERE this_parameters.Name = MIParameterName ); + + this_currentMIObs := NEW ObservationType; + this_currentMIObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID; + this_currentMIObs.ParameterGUID := MIParameter.ParameterGUID; + this_currentMIObs.DataType := "FreeTextValue"; + this_currentMIObs.ValueObj := NEW FreeTextValueType; + this_currentMIObs.ValueObj.Value := medical_imaging_msg; + + this_structuredNoteDoc.ChartedObservationsList := ( this_structuredNoteDoc.ChartedObservationsList, this_currentMIObs ); + + + endif; + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_IV_HALDOL_STATUSBOARD.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_IV_HALDOL_STATUSBOARD.mlm new file mode 100644 index 0000000..543ada5 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_IV_HALDOL_STATUSBOARD.mlm @@ -0,0 +1,179 @@ +maintenance: + + title: DOC_FUNC_IV_HALDOL_STATUSBOARD;; + mlmname: DOC_FUNC_IV_HALDOL_STATUSBOARD;; + arden: version 2.5;; + version: 5.50;; + institution: Allscripts;; + author: Shawn T. Head ;; + specialist: Dean M;; + date: 2016-04-28;; + validation: testing;; + +library: + purpose: Update statusboard IV Haldol dosage to remove red flag once ryhthem strip is documented on flowsheet. + ;; + explanation: + + 4.29.2016 STH CSR#: 33207 - When the user charts the observation "Rhythm" on the Adult Assessment A/I Flowsheet and there is currently a value in the IV Haldol column on the status board with an * at the end + This MLM will update the column to remove the * and replace it with CRLF so the red flag clears off status board. + NOTE: There are 2 other MLM{{{SINGLE-QUOTE}}}s that are used in conjuction with this MLM to create the haldol column on charting of IV haldol. + SCH_CHARTED_HALDOL_24HRS & DOC_ADULT_ASSESSMENT_CLOSE {Go-Live 6/1/2016} + 12.8.2016 STH CSR#: 335130 - Update for issues identified when testing for 16.3 Needed to change the search to look for the current value by searching for the enterprise defined column by name not by the column number. + ;; + keywords: IV Haldol, alert, flowsheet + ;; +knowledge: + type: data-driven;; + data: + + (this_documentCommunication) := argument; + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + //Called MLMs to set up the CDS and return obs values + set_cds_vars := MLM {{{SINGLE-QUOTE}}}CALLED_DOC_FS_DEFINITION_MLM{{{SINGLE-QUOTE}}}; + read_obs_value := MLM {{{SINGLE-QUOTE}}}CALLED_DOC_FS_OBS_VALUE_MLM{{{SINGLE-QUOTE}}}; + //create_ED_column := MLM {{{SINGLE-QUOTE}}}SCH_FUNC_CREATE_ENTERPRISE_DEFINED_COLUMN{{{SINGLE-QUOTE}}}; + + /**************Make Changes To Spelling And Flags In This Section**************/ + //Set up variables; initialize + braden_param := "Rhythm"; + + msg := ""; + + mlm_name := "DOC_FUNC_IV_HALDOL_STATUSBOARD"; + + //Set constants indicating document type and event + FLOWSHEET := "Flowsheet"; + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTCLOSING := "DocumentClosing"; + + /******************************************************************************/ + updatecol := false; + + + CR := 13 formatted with "%c"; + LF := 10 formatted with "%c"; + TS := 9 formatted with "%c"; + CRLF:= CR||LF; + //Initialize DocumentCommunication objects + (this_documentCommunication, clientGUID, CVGUID, chartGUID, + user_guid, document_type, document_name, event_type, + configuration_guid, this_currentObs, CancelEventFlag, this_fs_doc, + authored_by_guid, isIOFlowsheetFlag, client_document_guid, this_parameters, + this_columnList, this_currentColumn, this_chartedObservationsList, + this_parameters_displayName, current_parameter, current_parameter_name, current_parameter_guid, + current_parameter_datatype, selectedItems, selectedItems_Value, current_value, + diagnostic_message, displayMessageFlag) := call set_cds_vars WITH (this_documentCommunication); + + //Retrieve DocumentType (StructuredNote or Flowsheet) and EventType + this_DocumentType := this_documentCommunication.DocumentType; + this_EventType := this_documentCommunication.EventType; + + try + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey + with ((CVGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + + + EntDefinedColumn_obj := call {{{SINGLE-QUOTE}}}EnterpriseDefinedColumn{{{SINGLE-QUOTE}}}.FindByName + with ( client_visit_obj, "Haldol Total"); + + endtry; + catch Exception ex + error_occurred := true; + error_message := "{{+R}}Common Data:{{-R}}\n" || + ex.Message || "\n\n"; + + if ( client_visit_obj is NOT NULL ) then + void:= call client_visit_obj.Dispose; + client_visit_obj:= null; + endif; + + if ( EntDefinedColumn_obj is NOT NULL) then + void := call EntDefinedColumn_obj.Dispose; + EntDefinedColumn_obj := null; + endif; + endcatch; + + + current_value := EntDefinedColumn_obj.Value; + /*read last { " select EnterpriseVisitCol37 from CV3EnterpriseVisitData + where clientguid = " || sql(ClientGUID) + || " and visitguid = " || sql(CVGUID) }; + */ + + + + IV_Haldol_Alert_on_statusboard := current_value matches pattern "%*%"; + //Process logic on Flowsheets when the document is closing + if (IV_Haldol_Alert_on_statusboard and this_DocumentType = FLOWSHEET AND this_EventType = DOCUMENTCLOSING) then + //Retrieve Braden Score parameter + theParameter := first of (this_parameters WHERE this_parameters.Name = braden_param); + + if (exists theParameter) then + //Retrieve DateTime from current charted column + updatecol := true; + finda := FIND "*" IN STRING current_value; + newvalue := SUBSTRING (finda-1) CHARACTERS FROM current_value; + newvalue := newvalue || TS; + endif; + endif; + + + + ;; + priority: 50 + ;; + evoke: + ;; + logic: + + if (updatecol=true) then + + + try +/* + EntDefinedColumn_obj := call {{{SINGLE-QUOTE}}}EnterpriseDefinedColumn{{{SINGLE-QUOTE}}}.FindByName + with ( client_visit_obj, "Haldol Total"); +*/ + EntDefinedColumn_obj.Value := newvalue; + void := call EntDefinedColumn_obj.Save; + void := call EntDefinedColumn_obj.Dispose; + EntDefinedColumn_obj := null; + + endtry; + + catch Exception ex + error_occurred := true; + error_message := error_message || "{{+R}}Enterprise Patient List Column{{-R}}\n" + || ex.message || "\n\n"; + + if ex.InnerException is not null net_object then + error_message := error_message || "Inner Exception: " || ex.InnerException.Message || "\n\n"; + endif; + if (EntDefinedColumn_obj is not null) then + void := call EntDefinedColumn_obj.Dispose; + EntDefinedColumn_obj := null; + endif; + + EDColumn_Dest := null; + endcatch; + + if ( client_visit_obj is not null ) then + void := call client_visit_obj.Dispose; + client_visit_obj := null; + endif; + + endif; + conclude true; + ;; + action: + + + return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAST_24HRS.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAST_24HRS.mlm new file mode 100644 index 0000000..3c71f44 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAST_24HRS.mlm @@ -0,0 +1,487 @@ +maintenance: + + title: Vital Signs - Highs and Lows;; + mlmname: DOC_FUNC_Last_24hrs;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Shivprasad Jadhav;; + specialist: ;; + date: 2014-12-16;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 20.12.2014 DW Created to show last 24 hours Vital Sign observations from Physician Progress Note. + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + +// OBSERVATION CHANGE + + + if thisDocumentCommunication.EventType = "ChartObservation" + then + + (obsNamesList, lastValuesList, highValuesList, lowValuesList) := read + { + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), name varchar(200), value varchar(500), timstmp datetime, sortseq int, timstmp2 varchar(30) ) " + || " INSERT INTO #tmp_aaa (name,value,timstmp, sortseq) " + || " select ocmi.Name, o.ValueText, od.RecordedDtm, " + || " CASE WHEN Name = {{{SINGLE-QUOTE}}}farenheit{{{SINGLE-QUOTE}}} THEN 01 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Heart Rate{{{SINGLE-QUOTE}}} THEN 02 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Resp Rate{{{SINGLE-QUOTE}}} THEN 03 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Noninvasive Systolic BP{{{SINGLE-QUOTE}}} THEN 04 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Noninvasive Diastolic BP{{{SINGLE-QUOTE}}} THEN 05 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Noninvasive Mean BP{{{SINGLE-QUOTE}}} THEN 06 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Noninvasive BP Source 1{{{SINGLE-QUOTE}}} THEN 07 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_vs_pulse ox saturation{{{SINGLE-QUOTE}}} THEN 08 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_vs_pulse ox source{{{SINGLE-QUOTE}}} THEN 09 " + || " ELSE 99 " + || " END AS SortSeq " + || " " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " AND ocmi.Name in ({{{SINGLE-QUOTE}}}farenheit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Heart Rate{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Resp Rate{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Noninvasive Diastolic BP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Noninvasive Systolic BP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Noninvasive Mean BP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Noninvasive BP Source 1{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}SCH_vs_pulse ox saturation{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCH_vs_pulse ox source{{{SINGLE-QUOTE}}} ) " + || " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " " + || " and cd.iscanceled = 0 " + || " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}1.Vital Signs - Basic{{{SINGLE-QUOTE}}}) " + || " order by sortseq , cd.touchedwhen " + || " " + // || " update t1 set timstmp2 = t2.timstmp from #tmp_aaa t1 " + // || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq = t2.sortseq " + // || " delete from #tmp_aaa where timstmp2 is not null " + || " Delete from #tmp_aaa where Value is Null " + || " select name, value, timstmp, sortseq from #tmp_aaa order by timstmp desc, sortseq " + || " drop table #tmp_aaa " + }; +// update #tmp_aaa Set #tmp_aaa.timstmp = Dateadd(hour, -4, Getdate()) + header1 :="\n\n\b Vital Signs - Basic in Past 24 Hours -All Charted \b0\n\n"; + formattedText1 := " "; + thisdatefield := " "; + yesterday := now-24 hours; + + + indexList := 1 seqto count (obsNamesList); + + for i in indexList do + + obsName := (obsNamesList[i]); + + // Reformat the Time Stamp + + thisdatefield_unformatted := (highValuesList[i]); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the first group and charted in the past 24 hours + + if obsName in ("farenheit" , "Heart Rate" , "Resp Rate" , "Noninvasive Diastolic BP" , "Noninvasive Systolic BP" , + "Noninvasive Mean BP", "Noninvasive BP Source 1", "SCH_vs_pulse ox saturation", "SCH_vs_pulse ox source") + and + thisdatefield_unformatted > yesterday + + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := (highValuesList[i]); + formattedText1 := thisdatefield_formatted; + endif; + + + if thisdatefield <> (highValuesList[i]) // new timestamp + then + formattedText1 := formattedText1 || "\n" || thisdatefield_formatted; + thisdatefield := (highValuesList[i]); + else + formattedText1 := formattedText1 || " " ; + endif; + + + if obsName = "Heart Rate" then formattedText1 := formattedText1 || "\b HR:\b0 "; + elseif obsName = "Farenheit" then formattedText1 := formattedText1 || "\b T:\b0 "; + elseif obsName = "Resp Rate" then formattedText1 := formattedText1 || "\b R:\b0 "; + elseif obsName = "Noninvasive Systolic BP" then formattedText1 := formattedText1 || "\b BP:\b0 "; + elseif obsName = "Noninvasive Diastolic BP" then formattedText1 := formattedText1 || "/"; + elseif obsName = "Noninvasive Mean BP" then formattedText1 := formattedText1 || "\b Mean BP:\b0 "; + elseif obsName = "Noninvasive BP Source 1" then formattedText1 := formattedText1 || "/"; + elseif obsName = "SCH_vs_pulse ox saturation" then formattedText1 := formattedText1 || "\b Pulse Ox:\b0 "; + //elseif obsName = "SCH_vs_pulse ox source" then formattedText1 := formattedText1 || "/" ; //b O2 L/min:\b0 "; + endif; + + + formattedText1 := formattedText1 || " "; + formattedText1 := formattedText1 || (lastValuesList[i]); + + endif; // Obsname amongst the Vital Signs observations + + +// for Urine +// SCH_io_Foley Catheter, io_output_condom_catheter, SCH_io_Straight Catheter + + enddo; + + + // Gather the existing contents of the textbox + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_FT VS, I & O"); + obs := FIRST OF (thisObservations WHERE thisObservations.parameterGUID = theParameter.parameterGUID); + priorcontents := obs.ValueObj.Value; + + formattedTextAll:= priorcontents || header1 || formattedText1; + + + + endif; + + +// DOCUMENT OPEN +/* + + if thisdocumentCommunication.EventType = "DocumentOpening" + then + + // Query the database for the vitals info + + + (obsNamesList, lastValuesList, highValuesList, lowValuesList) := read + { + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), name varchar(200), value varchar(500), timstmp datetime, sortseq int, timstmp2 varchar(30) ) " + || " INSERT INTO #tmp_aaa (name,value,timstmp, sortseq) " + || " select ocmi.Name, o.ValueText, od.RecordedDtm, " + || " CASE WHEN Name = {{{SINGLE-QUOTE}}}Farenheit{{{SINGLE-QUOTE}}} THEN 01 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Heart Rate{{{SINGLE-QUOTE}}} THEN 02 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Resp Rate{{{SINGLE-QUOTE}}} THEN 03 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Noninvasive Systolic BP{{{SINGLE-QUOTE}}} THEN 04 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Noninvasive Diastolic BP{{{SINGLE-QUOTE}}} THEN 05 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Arterial Systolic BP - Radial{{{SINGLE-QUOTE}}} THEN 06 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Arterial Diastolic BP - Radial{{{SINGLE-QUOTE}}} THEN 07 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Arterial Systolic BP - Second Line{{{SINGLE-QUOTE}}} THEN 08 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Arterial Diastolic - Second Line{{{SINGLE-QUOTE}}} THEN 09 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_vs_pulse ox saturation{{{SINGLE-QUOTE}}} THEN 10 " + || " WHEN Name = {{{SINGLE-QUOTE}}}L/min{{{SINGLE-QUOTE}}} THEN 11 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Height in cm{{{SINGLE-QUOTE}}} THEN 20 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Height in ft{{{SINGLE-QUOTE}}} THEN 21 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Height remainder in inches{{{SINGLE-QUOTE}}} THEN 22 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby a wt gm ob NU{{{SINGLE-QUOTE}}} THEN 23 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby b wt gm ob NU{{{SINGLE-QUOTE}}} THEN 24 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby a wt lb ob NU{{{SINGLE-QUOTE}}} THEN 25 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby a wt oz ob NU{{{SINGLE-QUOTE}}} THEN 26 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby b wt lb ob NU{{{SINGLE-QUOTE}}} THEN 27 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby b wt oz ob NU{{{SINGLE-QUOTE}}} THEN 28 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - grams{{{SINGLE-QUOTE}}} THEN 29 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - lbs{{{SINGLE-QUOTE}}} THEN 40 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - oz{{{SINGLE-QUOTE}}} THEN 41 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Weight - lbs{{{SINGLE-QUOTE}}} THEN 42 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Weight - kg{{{SINGLE-QUOTE}}} THEN 43 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_vs_Occipital-Frontal Head{{{SINGLE-QUOTE}}} THEN 44 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Stool{{{SINGLE-QUOTE}}}THEN 45 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Urine{{{SINGLE-QUOTE}}}THEN 46 " + || " ELSE 99 " + || " END AS SortSeq " + || " " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " AND ocmi.Name in ( " + || " {{{SINGLE-QUOTE}}}farenheit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Heart Rate{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Resp Rate{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_vs_pulse ox saturation{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}L/min{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}Noninvasive Diastolic BP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Noninvasive Systolic BP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Arterial Systolic BP - Radial{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Arterial Diastolic BP - Radial{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Arterial Systolic BP - Second Line{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Arterial Diastolic - Second Line{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}AS deliv baby a wt gm ob NU{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}AS deliv baby b wt gm ob NU{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}AS deliv baby a wt lb ob NU{{{SINGLE-QUOTE}}} , " + || " {{{SINGLE-QUOTE}}}AS deliv baby b wt lb ob NU{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}AS deliv baby a wt oz ob NU{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}AS deliv baby b wt oz ob NU{{{SINGLE-QUOTE}}} , " + || " {{{SINGLE-QUOTE}}}SCH_Newborn Weight - grams{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_Newborn Weight - lbs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_Newborn Weight - oz{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}Weight - lbs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Weight - kg{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}Height in ft{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Height remainder in inches{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Height in cm{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCH_vs_Occipital-Frontal Head{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}Current Weight{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Stool{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Urine{{{SINGLE-QUOTE}}} " + || " ) " + || " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " " + || " and cd.iscanceled = 0 " + || " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}Newborn Patient Profile{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}B1. Newborn Vital Signs{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}B2. Newborn Assessment/Intervention{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}1.Vital Signs - Basic{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}1.Vital Signs - Critical Care{{{SINGLE-QUOTE}}}) " + || " order by sortseq , cd.touchedwhen " + || " " + || " update t1 set timstmp2 = t2.timstmp from #tmp_aaa t1 " + || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq = t2.sortseq " + || " update t2 set timstmp2 = {{{SINGLE-QUOTE}}}first weight{{{SINGLE-QUOTE}}}, name = {{{SINGLE-QUOTE}}}First Adult Weight - kg{{{SINGLE-QUOTE}}} from #tmp_aaa t1 " + || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq <> t2.sortseq and t2.name = {{{SINGLE-QUOTE}}}Weight - kg{{{SINGLE-QUOTE}}} " + || " delete from #tmp_aaa where timstmp2 is not null and timstmp2 <> {{{SINGLE-QUOTE}}}first weight{{{SINGLE-QUOTE}}} " + || " " + || " select name, value, timstmp, sortseq from #tmp_aaa order by timstmp desc, sortseq " + || " drop table #tmp_aaa " + }; + + + + // Process the First Group Data Elements (past 24 hours) + + + header1 :="\b Vital Signs in Past 24 Hours - Last Charted \b0\n\n"; + formattedText1:= " "; + thisdatefield := " "; + yesterday:= now-24 hours; + + indexList := 1 seqto count (obsNamesList); + + for i in indexList do + + obsName := last (first i from obsNamesList); + + // Reformat the Time Stamp + + thisdatefield_unformatted := last (first i from highValuesList); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the first group and charted in the past 24 hours + + if obsName in ("farenheit","Heart Rate","Resp Rate","SCH_vs_pulse ox saturation","L/min", + "Noninvasive Diastolic BP","Noninvasive Systolic BP","Arterial Systolic BP - Radial","Arterial Diastolic BP - Radial", + "Arterial Systolic BP - Second Line","Arterial Diastolic - Second Line" ) + and + thisdatefield_unformatted > yesterday + + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := last (first i from highValuesList); + formattedText1 := thisdatefield_formatted; + endif; + + + if thisdatefield <> last (first i from highValuesList) // new timestamp + then + formattedText1 := formattedText1 || "\n" || thisdatefield_formatted; + thisdatefield := last (first i from highValuesList); + else + formattedText1 := formattedText1 || " " ; + endif; + + + if obsName = "Heart Rate" then formattedText1 := formattedText1 || "\b HR:\b0 "; + elseif obsName = "Farenheit" then formattedText1 := formattedText1 || "\b T:\b0 "; + elseif obsName = "Noninvasive Systolic BP" then formattedText1 := formattedText1 || "\b BP:\b0 "; + elseif obsName = "Noninvasive Diastolic BP" then formattedText1 := formattedText1 || "/"; + elseif obsName = "Arterial Systolic BP - Radial" then formattedText1 := formattedText1 || "\b ART BP:\b0 "; + elseif obsName = "Arterial Diastolic BP - Radial" then formattedText1 := formattedText1 || "/"; + elseif obsName = "Arterial Systolic BP - Second Line" then formattedText1 := formattedText1 || "\b ART BP Second:\b0 "; + elseif obsName = "Arterial Diastolic - Second Line" then formattedText1 := formattedText1 || "/"; + elseif obsName = "Resp Rate" then formattedText1 := formattedText1 || "\b R:\b0 "; + elseif obsName = "SCH_vs_pulse ox saturation" then formattedText1 := formattedText1 || "\b Pulse Ox:\b0 "; + elseif obsName = "L/min" then formattedText1 := formattedText1 || "\b O2 L/min:\b0 "; + endif; + + formattedText1 := formattedText1 || " "; + formattedText1 := formattedText1 || last (first i from lastValuesList); + + endif; // Obsname amongst the Vital Signs observations + + enddo; + + + formattedText1 := header1 || formattedText1; + + + + + // Process the Second Group Data Elements (Start of Chart) + + + + header2 :="\n\n \b Additional Information - Last Charted \b0 \n\n"; + formattedText2:= " "; + thisdatefield := " "; + + + indexList := 1 seqto count (obsNamesList); + for i in indexList do + + obsName := last (first i from obsNamesList); + + + // Reformat the Time Stamp + + + thisdatefield_unformatted := last (first i from highValuesList); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the second group + + + if obsName in ( + "AS deliv baby a wt gm ob NU" , "AS deliv baby b wt gm ob NU" , "AS deliv baby a wt lb ob NU" , "AS deliv baby b wt lb ob NU" , "AS deliv baby a wt oz ob NU" , "AS deliv baby b wt oz ob NU" , + "SCH_Newborn Weight - grams","SCH_Newborn Weight - lbs","SCH_Newborn Weight - oz", "Weight - lbs","Weight - kg","First Adult Weight - kg","Height in ft" , "Height remainder in inches" , "Height in cm", + "SCH_vs_Occipital-Frontal Head", "Current Weight","SCH_io_newborn_diaper count - Stool" , "SCH_io_newborn_diaper count - Urine" + ) + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := last (first i from highValuesList); + formattedText2 := thisdatefield_formatted; + endif; + + + if thisdatefield <> last (first i from highValuesList) // new timestamp + then + formattedText2 := formattedText2 || "\n" || thisdatefield_formatted; + thisdatefield := last (first i from highValuesList); + else + formattedText2 := formattedText2 || " " ; + endif; + + + if obsName = "SCH_io_newborn_diaper count - Stool" then formattedText2 := formattedText2 || "\b Stool Diaper:\b0 "; + elseif obsName = "SCH_io_newborn_diaper count - Urine" then formattedText2 := formattedText2 || "\b Urine Diaper:\b0 "; + elseif obsName = "SCH_vs_Occipital-Frontal Head" then formattedText2 := formattedText2 || "\b H.C./cm:\b0 "; + elseif obsName = "Height in cm" then formattedText2 := formattedText2 || "\b Ht/cm:\b0 "; + elseif obsName = "Height in ft" then formattedText2 := formattedText2 || "\b Ht/ft:\b0 "; + elseif obsName = "Height remainder in inches" then formattedText2 := formattedText2 || "-"; + elseif obsName = "SCH_Newborn Weight - grams" then formattedText2 := formattedText2 || "\b Wt/gm:\b0 "; curwt:= last (first i from lastValuesList); + elseif obsName = "SCH_Newborn Weight - lbs" then formattedText2 := formattedText2 || "\b Wt/lb:\b0 "; + elseif obsName = "SCH_Newborn Weight - oz" then formattedText2 := formattedText2 || "-"; + elseif obsName = "AS deliv baby a wt gm ob NU" then formattedText2 := formattedText2 || "\b Deliv Wt/gm:\b0 "; delwt:= last (first i from lastValuesList); + elseif obsName = "AS deliv baby b wt gm ob NU" then formattedText2 := formattedText2 || "\b Deliv Wt/gm:\b0 "; delwt:= last (first i from lastValuesList); + elseif obsName = "AS deliv baby a wt lb ob NU" then formattedText2 := formattedText2 || "\b Deliv Wt/lb:\b0 "; + elseif obsName = "AS deliv baby a wt oz ob NU" then formattedText2 := formattedText2 || "-"; + elseif obsName = "AS deliv baby b wt lb ob NU" then formattedText2 := formattedText2 || "\b Deliv Wt/lb:\b0 "; + elseif obsName = "AS deliv baby b wt oz ob NU" then formattedText2 := formattedText2 || "-"; + elseif obsName = "Weight - lbs" then formattedText2 := formattedText2 || "\b Wt/lb:\b0 "; + elseif obsName = "Weight - kg" then formattedText2 := formattedText2 || "\b Wt/kg:\b0 "; lastwt := last (first i from lastValuesList); + elseif obsName = "First Adult Weight - kg" then formattedText2 := formattedText2 || "\b First Wt/kg:\b0 "; firstwt:= last (first i from lastValuesList); + endif; + + formattedText2 := formattedText2 || " "; + formattedText2 := formattedText2 || last (first i from lastValuesList); + + endif; // Obsname amongst the Additional Information observations + + enddo; + + + + // Calculate the weight change + + + + If exist delwt // Baby since birth weight + + then + wtlabel := "Wt change since birth: \b0 "; + wtscale := " gm "; + wtchange := ((curwt as number) - (delwt as number)) formatted with " %.2f %"; + wtchangepcnt := (((curwt as number) - (delwt as number))/(delwt as number) * 100) formatted with " %.2f %%"; + + else // Adult since first weighing + + wtlabel := "Wt change since first weighing: \b0 "; + wtscale := " kg "; + wtchange := ((lastwt as number) - (firstwt as number)) formatted with " %.2f %"; + wtchangepcnt := (((lastwt as number) - (firstwt as number)) /(firstwt as number) * 100) formatted with " %.2f %%"; + + endif; + + + If wtchange is not null + then + wtchange := " \n\n\b " || wtlabel || wtchange || wtscale || wtchangepcnt ; + else + wtchange := " "; + endif; + + formattedText2 := header2 || formattedText2 || wtchange; + + + formattedTextAll:= formattedText1 || formattedText2; + + + + endif; // Document Open + +*/ + + + // Write to the Structured Note Text Box + + + + If formattedTextAll is not null + + then + + vitalSignsHL := first of (thisParameters where thisParameters.Name = "SCH_MDPN_FT VS, I & O"); + + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := vitalSignsHL.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := formattedTextAll; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + endif; + + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAST_24HRS_OSTOMY.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAST_24HRS_OSTOMY.mlm new file mode 100644 index 0000000..e6a6501 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAST_24HRS_OSTOMY.mlm @@ -0,0 +1,311 @@ +maintenance: + + title: DOC_FUNC_Last_24hrs_Ostomy;; + mlmname: DOC_FUNC_Last_24hrs_Ostomy;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Shawn Head;; + specialist: ;; + date: 2014-12-24;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 06.15.2016 STH CSR# 34735 Created to show last 24 hours Ostomy totals from Physician Progress Note. {Go-Live 6/21/2016} + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + + +// OBSERVATION CHANGE + + + + + if thisDocumentCommunication.EventType = "ChartObservation" + then + + ( lastValuesList, highValuesList ) := read + { + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), value varchar(500), timstmp datetime ) " + || " INSERT INTO #tmp_aaa (value,timstmp) " + || " select Sum(Convert(Integer, obsx.OutValue)) as Value , od.RecordedDtm " + || " " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " Inner Join CV3ObservationXInfo AS obsx " + || " ON (obsx.ObservationXInfoGUID = o.GUID AND obsx.ArcType = o.ArcType And obsx.BagVolumeUnit is Not Null ) " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " AND ocmi.Name in ({{{SINGLE-QUOTE}}}io_output_colostomy{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}io_output_gastrostomy{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}io_output_ileostomy{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}io_output_jejunostomy{{{SINGLE-QUOTE}}} ) " + || " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " " + || " and cd.iscanceled = 0 " + || " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}2. Intake and Output{{{SINGLE-QUOTE}}}) " + || " Group By od.RecordedDtm " + || " Order By od.RecordedDtm Desc " + || " " + // || " update t1 set timstmp2 = t2.timstmp from #tmp_aaa t1 " + // || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq = t2.sortseq " + // || " delete from #tmp_aaa where timstmp2 is not null " + || " " + || " select value, timstmp from #tmp_aaa " + || " drop table #tmp_aaa " + }; + + +// update #tmp_aaa Set #tmp_aaa.timstmp = Dateadd(hour, -4, Getdate()) + header1 :="\n\n\b Ostomy Output - Observations in Past 24 Hours -All Charted \b0\n\n"; + formattedText1 := " "; + thisdatefield := " "; + yesterday := now-24 hours; + + + indexList := 1 seqto count (highValuesList); + + for i in indexList do + + + + // Reformat the Time Stamp + + thisdatefield_unformatted := (highValuesList[i]); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the first group and charted in the past 24 hours + + if thisdatefield_unformatted > yesterday + + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := (highValuesList[i]); + formattedText1 := thisdatefield_formatted; + endif; + + if thisdatefield <> (highValuesList[i]) // new timestamp + then + formattedText1 := formattedText1 || "\n" || thisdatefield_formatted; + thisdatefield := (highValuesList[i]); + else + formattedText1 := formattedText1 || " " ; + endif; + + + /*if obsName = "SCH_io_Straight Catheter" then formattedText1 := formattedText1 || "\b Straight Cath:\b0 "; + elseif obsName = "SCH_io_Foley Catheter" then formattedText1 := formattedText1 || "\b Foley Cath:\b0 "; + elseif obsName = "io_output_condom_catheter" then formattedText1 := formattedText1 || "\b Condom Cath:\b0 "; + elseif obsName = "io_output_voided" then formattedText1 := formattedText1 || "\b Voided:\b0 "; + elseif obsName = "io_output_nephrostomy" then formattedText1 := formattedText1 || "\b Nephro:\b0 "; + /*elseif obsName = "Noninvasive Mean BP" then formattedText1 := formattedText1 || "\b Mean BP:\b0 "; + elseif obsName = "Noninvasive BP Source 1" then formattedText1 := formattedText1 || "/"; + elseif obsName = "SCH_vs_pulse ox saturation" then formattedText1 := formattedText1 || "\b Pulse Ox:\b0 "; + elseif obsName = "SCH_vs_pulse ox source" then formattedText1 := formattedText1 || "/" ; //b O2 L/min:\b0 "; + endif; */ + + + formattedText1 := formattedText1 || " "; + formattedText1 := formattedText1 || (lastValuesList[i]) || " ml"; + + endif; // Obsname amongst the Vital Signs observations + + enddo; + + + // Gather the existing contents of the textbox + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_FT VS, I & O"); + obs := FIRST OF (thisObservations WHERE thisObservations.parameterGUID = theParameter.parameterGUID); + priorcontents := obs.ValueObj.Value; + + formattedTextAll:= priorcontents || header1 || formattedText1; + + + + endif; + + + /* if thisDocumentCommunication.EventType = "ChartObservation" + then + + (obsNamesList, lastValuesList, highValuesList, lowValuesList) := read + { + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), name varchar(200), value varchar(500), timstmp datetime, sortseq int, timstmp2 varchar(30) ) " + || " INSERT INTO #tmp_aaa (name,value,timstmp, sortseq) " + || " select ocmi.Name, Convert(Integer, obsx.OutValue) as Value, od.RecordedDtm, " + || " CASE WHEN Name = {{{SINGLE-QUOTE}}}SCH_io_Straight Catheter{{{SINGLE-QUOTE}}} THEN 01 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_io_Foley Catheter{{{SINGLE-QUOTE}}} THEN 02 " + || " WHEN Name = {{{SINGLE-QUOTE}}}io_output_condom_catheter{{{SINGLE-QUOTE}}} THEN 03 " + || " WHEN Name = {{{SINGLE-QUOTE}}}io_output_voided{{{SINGLE-QUOTE}}} THEN 04 " + || " WHEN Name = {{{SINGLE-QUOTE}}}io_output_nephrostomy{{{SINGLE-QUOTE}}} THEN 05 " + || " ELSE 99 " + || " END AS SortSeq " + || " " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " Inner Join CV3ObservationXInfo AS obsx " + || " ON (obsx.ObservationXInfoGUID = o.GUID AND obsx.ArcType = o.ArcType And obsx.BagVolumeUnit is Not Null ) " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " AND ocmi.Name in ({{{SINGLE-QUOTE}}}SCH_io_Foley Catheter{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}io_output_condom_catheter{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCH_io_Straight Catheter{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}io_output_voided{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}io_output_nephrostomy{{{SINGLE-QUOTE}}} ) " + || " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " " + || " and cd.iscanceled = 0 " + || " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}2. Intake and Output{{{SINGLE-QUOTE}}}) " + || " order by sortseq , cd.touchedwhen " + || " " + // || " update t1 set timstmp2 = t2.timstmp from #tmp_aaa t1 " + // || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq = t2.sortseq " + // || " delete from #tmp_aaa where timstmp2 is not null " + || " " + || " select name, value, timstmp, sortseq from #tmp_aaa order by timstmp desc, sortseq " + || " drop table #tmp_aaa " + }; +// update #tmp_aaa Set #tmp_aaa.timstmp = Dateadd(hour, -4, Getdate()) + header1 :="\n\n\b Urine Output - Observations in Past 24 Hours -All Charted \b0\n\n"; + formattedText1 := " "; + thisdatefield := " "; + yesterday := now-24 hours; + + + indexList := 1 seqto count (obsNamesList); + + for i in indexList do + + obsName := (obsNamesList[i]); + + // Reformat the Time Stamp + + thisdatefield_unformatted := (highValuesList[i]); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the first group and charted in the past 24 hours + + if obsName in ("SCH_io_Foley Catheter","io_output_condom_catheter", "SCH_io_Straight Catheter", "io_output_voided" , "io_output_nephrostomy") + and + thisdatefield_unformatted > yesterday + + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := (highValuesList[i]); + formattedText1 := thisdatefield_formatted; + endif; + + + if thisdatefield <> (highValuesList[i]) // new timestamp + then + formattedText1 := formattedText1 || "\n" || thisdatefield_formatted; + thisdatefield := (highValuesList[i]); + else + formattedText1 := formattedText1 || " " ; + endif; + + + if obsName = "SCH_io_Straight Catheter" then formattedText1 := formattedText1 || "\b Straight Cath:\b0 "; + elseif obsName = "SCH_io_Foley Catheter" then formattedText1 := formattedText1 || "\b Foley Cath:\b0 "; + elseif obsName = "io_output_condom_catheter" then formattedText1 := formattedText1 || "\b Condom Cath:\b0 "; + elseif obsName = "io_output_voided" then formattedText1 := formattedText1 || "\b Voided:\b0 "; + elseif obsName = "io_output_nephrostomy" then formattedText1 := formattedText1 || "\b Nephro:\b0 "; + + endif; + + + formattedText1 := formattedText1 || " "; + formattedText1 := formattedText1 || (lastValuesList[i]); + + endif; // Obsname amongst the Vital Signs observations + + enddo; + + + // Gather the existing contents of the textbox + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_FT VS, I & O"); + obs := FIRST OF (thisObservations WHERE thisObservations.parameterGUID = theParameter.parameterGUID); + priorcontents := obs.ValueObj.Value; + + formattedTextAll:= priorcontents || header1 || formattedText1; + + + + endif; */ + + // Write to the Structured Note Text Box + + + + If formattedTextAll is not null + + then + + vitalSignsHL := first of (thisParameters where thisParameters.Name = "SCH_MDPN_FT VS, I & O"); + + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := vitalSignsHL.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := formattedTextAll; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + endif; + + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAST_24HRS_URINE.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAST_24HRS_URINE.mlm new file mode 100644 index 0000000..1fc1666 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAST_24HRS_URINE.mlm @@ -0,0 +1,312 @@ +maintenance: + + title: Vital Signs - Highs and Lows;; + mlmname: DOC_FUNC_Last_24hrs_Urine;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Shivprasad Jadhav;; + specialist: Shivprasad Jadhav ;; + date: 2015-01-21;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 20.12.2014 DW CSR# 32476 Created to show last 24 hours Urine observations from Physician Progress Note. + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + + +// OBSERVATION CHANGE + + + + + if thisDocumentCommunication.EventType = "ChartObservation" + then + + ( lastValuesList, highValuesList ) := read + { + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), value varchar(500), timstmp datetime ) " + || " INSERT INTO #tmp_aaa (value,timstmp) " + || " select Sum(Convert(Integer, obsx.OutValue)) as Value , od.RecordedDtm " + || " " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " Inner Join CV3ObservationXInfo AS obsx " + || " ON (obsx.ObservationXInfoGUID = o.GUID AND obsx.ArcType = o.ArcType And obsx.BagVolumeUnit is Not Null ) " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " AND ocmi.Name in ({{{SINGLE-QUOTE}}}SCH_io_Foley Catheter{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}io_output_condom_catheter{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCH_io_Straight Catheter{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}io_output_voided{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}io_output_nephrostomy{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}SCH_io_Suprapubic Catheter{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCH_io_Urostomy{{{SINGLE-QUOTE}}} ) " + || " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " " + || " and cd.iscanceled = 0 " + || " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}2. Intake and Output{{{SINGLE-QUOTE}}}) " + || " Group By od.RecordedDtm " + || " Order By od.RecordedDtm Desc " + || " " + // || " update t1 set timstmp2 = t2.timstmp from #tmp_aaa t1 " + // || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq = t2.sortseq " + // || " delete from #tmp_aaa where timstmp2 is not null " + || " " + || " select value, timstmp from #tmp_aaa " + || " drop table #tmp_aaa " + }; + + +// update #tmp_aaa Set #tmp_aaa.timstmp = Dateadd(hour, -4, Getdate()) + header1 :="\n\n\b Urine Output - Observations in Past 24 Hours -All Charted \b0\n\n"; + formattedText1 := " "; + thisdatefield := " "; + yesterday := now-24 hours; + + + indexList := 1 seqto count (highValuesList); + + for i in indexList do + + + + // Reformat the Time Stamp + + thisdatefield_unformatted := (highValuesList[i]); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the first group and charted in the past 24 hours + + if thisdatefield_unformatted > yesterday + + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := (highValuesList[i]); + formattedText1 := thisdatefield_formatted; + endif; + + + if thisdatefield <> (highValuesList[i]) // new timestamp + then + formattedText1 := formattedText1 || "\n" || thisdatefield_formatted; + thisdatefield := (highValuesList[i]); + else + formattedText1 := formattedText1 || " " ; + endif; + + + /*if obsName = "SCH_io_Straight Catheter" then formattedText1 := formattedText1 || "\b Straight Cath:\b0 "; + elseif obsName = "SCH_io_Foley Catheter" then formattedText1 := formattedText1 || "\b Foley Cath:\b0 "; + elseif obsName = "io_output_condom_catheter" then formattedText1 := formattedText1 || "\b Condom Cath:\b0 "; + elseif obsName = "io_output_voided" then formattedText1 := formattedText1 || "\b Voided:\b0 "; + elseif obsName = "io_output_nephrostomy" then formattedText1 := formattedText1 || "\b Nephro:\b0 "; + /*elseif obsName = "Noninvasive Mean BP" then formattedText1 := formattedText1 || "\b Mean BP:\b0 "; + elseif obsName = "Noninvasive BP Source 1" then formattedText1 := formattedText1 || "/"; + elseif obsName = "SCH_vs_pulse ox saturation" then formattedText1 := formattedText1 || "\b Pulse Ox:\b0 "; + elseif obsName = "SCH_vs_pulse ox source" then formattedText1 := formattedText1 || "/" ; //b O2 L/min:\b0 "; + endif; */ + + + formattedText1 := formattedText1 || " "; + formattedText1 := formattedText1 || (lastValuesList[i]) || " ml"; + + endif; // Obsname amongst the Vital Signs observations + + enddo; + + + // Gather the existing contents of the textbox + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_FT VS, I & O"); + obs := FIRST OF (thisObservations WHERE thisObservations.parameterGUID = theParameter.parameterGUID); + priorcontents := obs.ValueObj.Value; + + formattedTextAll:= priorcontents || header1 || formattedText1; + + + + endif; + + + /* if thisDocumentCommunication.EventType = "ChartObservation" + then + + (obsNamesList, lastValuesList, highValuesList, lowValuesList) := read + { + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), name varchar(200), value varchar(500), timstmp datetime, sortseq int, timstmp2 varchar(30) ) " + || " INSERT INTO #tmp_aaa (name,value,timstmp, sortseq) " + || " select ocmi.Name, Convert(Integer, obsx.OutValue) as Value, od.RecordedDtm, " + || " CASE WHEN Name = {{{SINGLE-QUOTE}}}SCH_io_Straight Catheter{{{SINGLE-QUOTE}}} THEN 01 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_io_Foley Catheter{{{SINGLE-QUOTE}}} THEN 02 " + || " WHEN Name = {{{SINGLE-QUOTE}}}io_output_condom_catheter{{{SINGLE-QUOTE}}} THEN 03 " + || " WHEN Name = {{{SINGLE-QUOTE}}}io_output_voided{{{SINGLE-QUOTE}}} THEN 04 " + || " WHEN Name = {{{SINGLE-QUOTE}}}io_output_nephrostomy{{{SINGLE-QUOTE}}} THEN 05 " + || " ELSE 99 " + || " END AS SortSeq " + || " " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " Inner Join CV3ObservationXInfo AS obsx " + || " ON (obsx.ObservationXInfoGUID = o.GUID AND obsx.ArcType = o.ArcType And obsx.BagVolumeUnit is Not Null ) " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " AND ocmi.Name in ({{{SINGLE-QUOTE}}}SCH_io_Foley Catheter{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}io_output_condom_catheter{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCH_io_Straight Catheter{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}io_output_voided{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}io_output_nephrostomy{{{SINGLE-QUOTE}}} ) " + || " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " " + || " and cd.iscanceled = 0 " + || " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}2. Intake and Output{{{SINGLE-QUOTE}}}) " + || " order by sortseq , cd.touchedwhen " + || " " + // || " update t1 set timstmp2 = t2.timstmp from #tmp_aaa t1 " + // || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq = t2.sortseq " + // || " delete from #tmp_aaa where timstmp2 is not null " + || " " + || " select name, value, timstmp, sortseq from #tmp_aaa order by timstmp desc, sortseq " + || " drop table #tmp_aaa " + }; +// update #tmp_aaa Set #tmp_aaa.timstmp = Dateadd(hour, -4, Getdate()) + header1 :="\n\n\b Urine Output - Observations in Past 24 Hours -All Charted \b0\n\n"; + formattedText1 := " "; + thisdatefield := " "; + yesterday := now-24 hours; + + + indexList := 1 seqto count (obsNamesList); + + for i in indexList do + + obsName := (obsNamesList[i]); + + // Reformat the Time Stamp + + thisdatefield_unformatted := (highValuesList[i]); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the first group and charted in the past 24 hours + + if obsName in ("SCH_io_Foley Catheter","io_output_condom_catheter", "SCH_io_Straight Catheter", "io_output_voided" , "io_output_nephrostomy") + and + thisdatefield_unformatted > yesterday + + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := (highValuesList[i]); + formattedText1 := thisdatefield_formatted; + endif; + + + if thisdatefield <> (highValuesList[i]) // new timestamp + then + formattedText1 := formattedText1 || "\n" || thisdatefield_formatted; + thisdatefield := (highValuesList[i]); + else + formattedText1 := formattedText1 || " " ; + endif; + + + if obsName = "SCH_io_Straight Catheter" then formattedText1 := formattedText1 || "\b Straight Cath:\b0 "; + elseif obsName = "SCH_io_Foley Catheter" then formattedText1 := formattedText1 || "\b Foley Cath:\b0 "; + elseif obsName = "io_output_condom_catheter" then formattedText1 := formattedText1 || "\b Condom Cath:\b0 "; + elseif obsName = "io_output_voided" then formattedText1 := formattedText1 || "\b Voided:\b0 "; + elseif obsName = "io_output_nephrostomy" then formattedText1 := formattedText1 || "\b Nephro:\b0 "; + + endif; + + + formattedText1 := formattedText1 || " "; + formattedText1 := formattedText1 || (lastValuesList[i]); + + endif; // Obsname amongst the Vital Signs observations + + enddo; + + + // Gather the existing contents of the textbox + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_FT VS, I & O"); + obs := FIRST OF (thisObservations WHERE thisObservations.parameterGUID = theParameter.parameterGUID); + priorcontents := obs.ValueObj.Value; + + formattedTextAll:= priorcontents || header1 || formattedText1; + + + + endif; */ + + // Write to the Structured Note Text Box + + + + If formattedTextAll is not null + + then + + vitalSignsHL := first of (thisParameters where thisParameters.Name = "SCH_MDPN_FT VS, I & O"); + + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := vitalSignsHL.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := formattedTextAll; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + endif; + + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAUNCH_ADD_CAREPROVIDERS.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAUNCH_ADD_CAREPROVIDERS.mlm new file mode 100644 index 0000000..082e665 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAUNCH_ADD_CAREPROVIDERS.mlm @@ -0,0 +1,160 @@ +maintenance: + + title: Doc_Func_Launch_Add_CareProviders;; + filename: Doc_Func_Launch_Add_CareProviders;; + arden: version 2;; + version: 1.00;; + institution: Eclipsys Corp;; + author: Eclipsys Corp;; + specialist: Shawn Head;; + date: 2015-11-16;; + validation: testing;; + +library: + purpose: This mlm launches the AddCareProviders Objects+ custom application from a document + ;; + explanation: The Add Care Providers was designed for use by the Physician Progress Note, but could be useful in other areas of SCM + + Change history + + 10.14.2015 STH CSR#: 33715 - Add care providers {Go-Live 12/10/2015} + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + (this_documentCommunication) := argument; + /*******************Make Changes To Spelling And Flags In This Section*******************/ + + /* Set to true if a decision.log is needed.*/ + log_execution_info := FALSE; + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + str_parse := mlm {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; //used to parse string data into a list + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + using "AddCareProviders"; + using namespace "AddProviders"; + + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + +// Reset the launch button + + theParameterx := first of (thisparameters where thisparameters.Name = "SCH_Launch CP Window"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameterx.ParameterGUID); + + rtbCommentsParam := first of (thisparameters where thisparameters.Name = "SCH_MDPN_CareProviders"); + rtbCommentsObs := first of (thisobservations where thisobservations.ParameterGUID = rtbCommentsParam.ParameterGUID); +//first of (thisparameters where thisparameters.Name = "SCH_MDPN_Other Results"); + //rtbCommentsObs := first of (thisobservations where thisobservations.ParameterGUID = rtbCommentsParam.ParameterGUID); + + if this_documentCommunication.CurrentObservationObj.parameterguid = theParameterx.ParameterGUID then + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_Launch CP Window"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := false; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; + + docname := this_documentCommunication.DocumentName as string; + LaunchCP := new net_object {{{SINGLE-QUOTE}}}AddCareProviders.Form1{{{SINGLE-QUOTE}}}; + + ;; + evoke: // No evoke statement + ;; + logic: + + tstCPLaunch := CALL LaunchCP.ShowDialog; + lstresults := (); + lstitems := (); + lstFromObj := (); + //lstFromObj := LaunchCP.lstProviders4Note; + txtfromobj := LaunchCP.providers4note as string; + lstresults := call str_parse with (txtfromobj,"|"); + ctlistitems := count(lstresults); + a := lstresults[0]; + b := lstresults[1]; + c := lstresults[2]; + d := lstresults[3]; + finalresults := ""; + resultcategory := ""; + currentcategory := ""; + ccproviders := ""; + nonccproviders := ""; + sendtonote := ""; + for x in (1 seqto count(lstresults)) do + if((trim(lstresults[x]) is not null) and (trim(lstresults[x]) <> "")) then + lstitems := call str_parse with (lstresults[x],"^"); + if((trim(lstitems[2]) is not null) and (trim(lstitems[2]) <> "")) then + if((lstitems[1] = "electronic") and (lstitems[4] = "true")) then + sendtonote := " (ELECTRONICALLY SENT TO PHYSICIAN PRACTICE)"; + elseif((lstitems[1] = "fax") and (lstitems[4] = "true")) then + sendtonote := " (FAXED DOCUMENT TO " || lstitems[3] || ")"; + else + sendtonote := ""; + endif; + + if(lstitems[4] = "true") then + ccproviders := ccproviders || "\b \li720" || "CC: " || lstitems[2] || "\b0 \i " || sendtonote || "\i0 \n"; + else + nonccproviders := nonccproviders || "\b \li720" || lstitems[2] || "\b0 \i " || sendtonote || " \i0 \n"; + endif; + endif; + endif; + enddo; + messagefornote := ""; + //messagefornote := "\b \ul \li0" || "ADDITIONAL CARE PROVIDERS" || "\b0 \ul0 \n"; + if(ccproviders <> "") then + messagefornote := messagefornote || "\n \b \ul \li360 THE FOLLOWING CARE PROVIDERS RECEIVED A COPY OF THIS NOTE \b0 \ul0 \n\n" || ccproviders; + endif; + if(nonccproviders <> "") then + messagefornote := messagefornote || "\n \b \ul \li360 THE FOLLOWING CARE PROVIDERS DID NOT RECEIVE A COPY OF THIS NOTE \b0 \ul0 \n\n" || nonccproviders; + endif; + + rtbCommentObj := NEW ObservationType; + rtbCommentObj.ClientdocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + rtbCommentObj.ParameterGUID := rtbCommentsParam.ParameterGUID; + rtbCommentObj.DataType := "FreeTextValue"; + rtbCommentObj.ValueObj := NEW FreeTextValueType; + rtbCommentObj.ValueObj.Value := messagefornote; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, rtbCommentObj); + + conclude true; // always concludes TRUE + ;; + action: + return this_documentCommunication; + + ;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAUNCH_EXITCARE.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAUNCH_EXITCARE.mlm new file mode 100644 index 0000000..8ea4013 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAUNCH_EXITCARE.mlm @@ -0,0 +1,123 @@ +maintenance: + + title: Doc_Func_Launch_ExitCare;; + mlmname: Doc_Func_Launch_ExitCare;; + arden: version 2.5;; + version: 5.05;; + institution: St.Clair Hospital;; + author: Peggy Karish;; + specialist: Don Warnick ;; + date: 2013-03-12;; + validation: testing;; + +library: + purpose: Standardize the document mlm responsible for initiation. + ;; + explanation: none + Change history + + 03.12.2013 DJW CSR# 31118 Created from a sample MLM shared by Dr. Mansour + 07.15.2019 STH CSR# 37676 18.4 Upgrade requires changing "getconnectionstring" to "getsecureconnectionstring". + ;; + keywords: RTF, Document Called MLM , list + ;; +knowledge: + type: data-driven;; + data: + (this_documentCommunication) := argument; + /*******************Make Changes To Spelling And Flags In This Section******************/ + + /* Set to true if a decision.log is needed.*/ + log_execution_info := false; + /* Create variable for tab*/ + TAB := 9 formatted with "%c" ; + /***************************************************************************************/ + + //*** Variable Declaration ***// + (this_structuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (this_parameters) := this_structuredNoteDoc.ParametersList; + (this_chartedObservationsList) := this_structuredNoteDoc.ChartedObservationsList; + (this_authoredDateTime) := this_structuredNoteDoc.AuthoredDateTime ; + (this_authoredByGuid) := this_structuredNoteDoc.AuthoredByGuid ; + (this_Doc_IsNew) := this_structuredNoteDoc.IsNew ; + (this_Doc_IsIncomplete) := this_structuredNoteDoc.IsIncomplete ; + (this_Doc_IsResultsPending) := this_structuredNoteDoc.IsResultsPending ; + (this_Doc_IsPriority) := this_structuredNoteDoc.IsPriority ; + + (this_event) := this_documentCommunication.EventType ; + (this_currentObj) := this_documentCommunication.CurrentObservationObj ; + (client_guid) := this_documentCommunication.ClientGUID; + (client_chart_guid) := this_documentCommunication.ChartGUID; + (client_visit_guid) := this_documentCommunication.ClientVisitGUID; + (client_document_guid) := this_documentCommunication.DocumentConfigurationObj.ClientDocumentGUID ; + (this_document_name) := this_documentCommunication.DocumentName ; + (this_parameters_display_name) := this_parameters.DisplayName ; + + + IF this_event = "ChartObservation" THEN // could be "DocumentOpening", "ChartObservation", OR "DocumentClosing" + current_parameter := FIRST OF (this_Parameters + WHERE this_parameters.ParameterGUID = this_CurrentObj.ParameterGUID); + current_parameter_name := current_parameter.name ; + current_parameter_guid := current_parameter.ParameterGuid ; + current_parameter_DataType := current_parameter.DataType ; + + IF current_parameter_DataType IS IN("FreeTextValue","NumericValue","DateValue") THEN + current_value := this_currentObj.ValueObj.value; + ELSEIF current_parameter_DataType = "ListValue" THEN + selectedItems := (this_currentObj.ValueObj.ListItemsList + WHERE this_currentObj.ValueObj.ListItemsList.IsSelected = + true); + currentObj_selectedItems := selectedItems.value ; + countOf_selectedItems := count of currentObj_selectedItems ; + current_value := FIRST OF currentObj_selectedItems ; + ENDIF; + ENDIF; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + Debug:=FALSE; + + try + using "SCMLib"; + using namespace "SCMLib.HVCLogon"; + using "SXA.ED.DischargeInstructions"; + using namespace "SXA.ED.DischargeInstructions"; + + using "SXA.Framework" ; + using Namespace "Eclipsys.SunriseXA.Framework.WinClient" ; + shellinterface := new NET_OBJECT {{{SINGLE-QUOTE}}}XAShellInterface{{{SINGLE-QUOTE}}} ; + shellinterface := new NET_OBJECT {{{SINGLE-QUOTE}}}XAShellInterface{{{SINGLE-QUOTE}}} ; + connstring := call {{{SINGLE-QUOTE}}}HVCLogonObj{{{SINGLE-QUOTE}}}.GetSecureConnectionString; + dis_instr := new NET_OBJECT {{{SINGLE-QUOTE}}}DischargeInstructions{{{SINGLE-QUOTE}}} ; + Exit_Care_Diaglog := call dis_instr.LaunchDischargeInstructions + with (shellinterface, true) ; + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}Cannot start ExitCare Application: {{-R}}\n" + || ex.Message || "\n\n"; + msg := error_message || msg; + + if ( dis_instr is NOT NULL ) then + void:= call dis_instr.Dispose; + dis_instr:= null; + endif; + endcatch; + + If Debug = TRUE THEN + this_documentCommunication.DisplayMessage := FALSE; + this_documentCommunication.Message := sMessage ; + ENDIF; + ;; + evoke: + ;; + logic: + conclude true; + ;; + action: + return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAUNCH_PHYSICIAN_CHARGE_BUILDER.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAUNCH_PHYSICIAN_CHARGE_BUILDER.mlm new file mode 100644 index 0000000..b754cfb --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAUNCH_PHYSICIAN_CHARGE_BUILDER.mlm @@ -0,0 +1,529 @@ +maintenance: + + title: Doc_Func_Launch_Physician_Charge_Builder;; + filename: Doc_Func_Launch_Physician_Charge_Builder;; + arden: version 2;; + version: 1.00;; + institution: Eclipsys Corp;; + author: Eclipsys Corp;; + specialist: Don Warnick;; + date: 2015-03-04;; + validation: testing;; + +library: + purpose: This mlm launches the Physician Charge Builder Objects+ custom application from a document + ;; + explanation: The Physician Charge Builder was designed for use by the Physician Progress Note, but could be useful in other areas of SCM + + Change history + + 03.04.2015 DW CSR# 32359 - Physician CPT codes - Created + 06.22.2015 DW CSR# 32359 - Address the PA / CRNP who enters on behalf of a physician + 11.11.2015 DW CSR# 32359 - Change ICD9 to ICD10 (was a meaningless comment until we began electronically filing charges via the interface) + 11.13.2015 DW CSR# 33842 - Physician Charging for Specialists + 01.14.2015 DW CSR# 32359 - Limit the Problem modifer count to 12. + 07.14.2016 DW CSR# 34389 - Adjusted for Nursing Assess.& Disch Summ which is created once per visit. DOS = Today when launched from this document + 11.30.2016 DW CSR# 35130 - Upgrade SCM to version 16.3 + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + + (this_documentCommunication) := argument; + + log_execution_info := FALSE; + str_parse := mlm {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + problemlist := " "; + launchtheapp:= "yes"; + + (thisStructuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + launchtheapp:= "no"; + + // Only lauch the app on button click or document close (of a new document...not upon modification) + + + If (this_documentCommunication.EventType = "DocumentClosing" and thisStructuredNoteDoc.ClientDocumentGUID is null) or this_documentCommunication.EventType = "ChartObservation" + + + then + + + If this_documentCommunication.EventType = "DocumentClosing" + + then + + (OccCode, userName) := read last {" select OccupationCode, IDCode from CV3USER with (nolock) where guid = " || sql(this_documentCommunication.UserGUID) }; +// if ( OccCode = "IT" AND userName = "jlaw") then +// break; +// endif; + + problemlist := "DocumentClose"; + + // Determine if the HIS Only - Charges Addressed button is selected + + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_Charge Addressed"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Rounding Charges") + then charges_addressed_button_selected := "true"; + else charges_addressed_button_selected := "false"; + endif; + + else + + problemlist := "EPNUserLaunch"; + + endif; + + + + // Proceed if the Rounding Charges Button was selected or the EPN is closing and charging had not been addressed + + + If (problemlist = "EPNUserLaunch") or (problemlist = "DocumentClose" and charges_addressed_button_selected = "false") + + + then + + // If the document is created one time per visit, use today as the date of service instead of Authored Date + + if this_documentCommunication.DocumentName = "Newborn Assessment and Discharge Summary" + then + EPNAuthoredDate:= Substring 10 Characters Starting at 1 from (NOW as string); + else + EPNAuthoredDate:= Substring 10 Characters Starting at 1 from (thisStructuredNoteDoc.AuthoredDateTime as string); + endif; + + problemlist := problemlist || EPNAuthoredDate; + + launchtheapp:= "yes"; + + // Gather the problems into a variable to be passed to the Charge Builder App + + for i in 1 seqto 12 do + + fieldname := "SCH_MDPN_Problem " || i ; + + theParameter := first of (thisParameters where thisParameters.Name = fieldname ); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is not null + then + if problemlist = " " + then problemlist := problemlist || thisfield; + else problemlist := problemlist || "#" || thisfield; + endif; + endif; + + enddo; + + + problemlistlen := length (problemlist); + + + // If problemlist = "EPNUserLaunch" or problemlist = "DocumentClose" + if problemlistlen = 23 + then problemlist := problemlist || "#" || "No Problems were documented"; + + endif; + + + // Launch the Charge Builder App + + using "PhysicianChargeBuilder"; + test:= new net_object {{{SINGLE-QUOTE}}}PhysicianChargeBuilder.PhysicianChargeBuilderForm{{{SINGLE-QUOTE}}} with (problemlist); + + + client_visit_guid := this_documentCommunication.clientvisitguid; + client_guid := this_documentCommunication.clientguid; + chart_guid := this_documentCommunication.chartguid; + user_guid := this_documentCommunication.UserGUID; + + document_guid := thisStructuredNoteDoc.ClientDocumentGUID; + + + user_name := read last {"SET CONCAT_NULL_YIELDS_NULL off SELECT firstname + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + middlename + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + lastname " + || " FROM CV3User with (nolock) " + || " WHERE GUID = " || Sql(user_guid)} + ; + + locationGuid := read last {"SELECT CurrentLocationGUID, touchedWhen" + || " FROM CV3ClientVisit with (nolock)" + || " WHERE GUID = " || Sql(client_visit_guid) + || " AND ClientGUID = " || Sql(client_guid) + , primaryTime = touchedWhen}; + + + + // Find the co-signer or authoured by selected by PA{{{SINGLE-QUOTE}}}s/CRNP{{{SINGLE-QUOTE}}}s + + + if document_guid is not null // is a modified document + + then + + cosigner,cosignerid := read last {" SET CONCAT_NULL_YIELDS_NULL off select u.LastName + {{{SINGLE-QUOTE}}}^{{{SINGLE-QUOTE}}} + u.FirstName + {{{SINGLE-QUOTE}}}^{{{SINGLE-QUOTE}}} + u.MiddleName, cpid.IDCode " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocProviderXrefCUR cdpxr with (nolock) on cdpxr.ClientDocGUID = cd.GUID " + || " join CV3CareProvider cp with (nolock) on cp.guid = cdpxr.providerguid " + || " join CV3CareProviderID cpid with (nolock) on cp.GUID = cpid.ProviderGUID " + || " join cv3user u with (nolock) on u.guid = cp.GUID " + || " where cd.guid = " || Sql(document_guid) || " and cdpxr.ProviderGUID <> cd.UserGUID " + || " and cpid.ProviderIDTypeCode = {{{SINGLE-QUOTE}}}Edstan Number (physician){{{SINGLE-QUOTE}}}"}; + + + elseif thisStructuredNoteDoc.Cosigner1GUID is not null // it is a new document with a co-signer + + + then + + cosigner_guid := thisStructuredNoteDoc.Cosigner1GUID; + + cosigner,cosignerid := read last {" SET CONCAT_NULL_YIELDS_NULL off select u.LastName + {{{SINGLE-QUOTE}}}^{{{SINGLE-QUOTE}}} + FirstName + {{{SINGLE-QUOTE}}}^{{{SINGLE-QUOTE}}} + u.MiddleName, cpid.IDCode " + || " from CV3CareProvider cp with (nolock) " + || " join CV3CareProviderID cpid with (nolock) on cp.GUID = cpid.ProviderGUID " + || " join cv3user u with (nolock) on u.guid = cp.GUID " + || " where cp.guid = " || Sql(cosigner_guid) || " and cpid.ProviderIDTypeCode = {{{SINGLE-QUOTE}}}Edstan Number (physician){{{SINGLE-QUOTE}}}"}; + + + elseif this_documentCommunication.UserGUID <> thisStructuredNoteDoc.AuthoredByGUID // it is a new document with authoured by selected + + + then + + cosigner_guid := thisStructuredNoteDoc.AuthoredByGUID; + + cosigner,cosignerid := read last {" SET CONCAT_NULL_YIELDS_NULL off select u.LastName + {{{SINGLE-QUOTE}}}^{{{SINGLE-QUOTE}}} + FirstName + {{{SINGLE-QUOTE}}}^{{{SINGLE-QUOTE}}} + u.MiddleName, cpid.IDCode " + || " from CV3CareProvider cp with (nolock) " + || " join CV3CareProviderID cpid with (nolock) on cp.GUID = cpid.ProviderGUID " + || " join cv3user u with (nolock) on u.guid = cp.GUID " + || " where cp.guid = " || Sql(cosigner_guid) || " and cpid.ProviderIDTypeCode = {{{SINGLE-QUOTE}}}Edstan Number (physician){{{SINGLE-QUOTE}}}"}; + endif; + + + if cosigner is null then cosigner := " "; cosignerid := " "; endif; // set the fields from null to blank + + if cosigner <> " " then cosigner := cosignerid || "^" || cosigner; endif; // if something is found concatonat the name with the id + + else + + launchtheapp:= "no"; + + + endif; // Launch Button was selected or the EPN is closing with charges unaddressed + + + endif; // this_documentCommunication.EventType = "DocumentClose" or "ChartObservation" + + + + + // Reset the launch button + + + theParameterx := first of (thisparameters where thisparameters.Name = "SCH_MDPN_Launch Charge Entry"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameterx.ParameterGUID); + + if this_documentCommunication.CurrentObservationObj.parameterguid = theParameterx.ParameterGUID then + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Launch Charge Entry"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := false; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; + + + + + ;; + + evoke: // No evoke statement + ;; + + logic: + + + + if launchtheapp = "yes" + + then + + oeUnsigned:=CALL test.ShowDialog; + + return_string:= test.text; + + + // Parse the individual charges + + calc_map_list :=(return_string); + itemlist := call str_parse with calc_map_list,"|"; + calc_element_list := call str_parse with calc_map_list, "|"; + + for i in 1 seqto count itemlist do + + chargemessage := calc_element_list[i]; + + chargecomponents := call str_parse with chargemessage, "~"; + + order_item_name := chargecomponents[1]; // Order + order_item_code := chargecomponents[2]; // Code + charge_date := chargecomponents[3]; // Date + diagnosis_list := chargecomponents[4]; // Diagnosis List + alternate_charge := chargecomponents[5]; // Alternate Charge + referring_physician:= chargecomponents[6]; // Referring Physician + + + diagnosis_list_caret:= diagnosis_list; + + + // Called by editor + + if called_by_editor + then placeorder := "no"; else placeorder := "yes"; + endif; + + + If placeorder = "yes" then + + + // Closed the app (no entry) + + If order_item_name matches pattern "%Rounding Charge Builder%" + + then + + xxx:= "User Exited the Form using the Close Control (X button)....do nothing"; + + + + // Bypassed Charge + + + elseif order_item_name = "Bypass charge entry" + + then + + + // Make an AVL entry + + + + + zzz:= ((extract year NOW) as string) || ((extract month NOW) as string) || ((extract day NOW) as string) || ((extract hour NOW) as string) || ((extract minute NOW) as string); + zzz:= zzz || client_visit_guid; + + bypassdetail := user_guid || "|" || diagnosis_list; + dos:= NOW; + + bypassdocument := this_documentCommunication.DocumentName || "-" || this_documentCommunication.DocumentTopic; + + + try + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((client_visit_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + advanced_visit_list_data_obj := call {{{SINGLE-QUOTE}}}AdvancedVisitListData{{{SINGLE-QUOTE}}}.CreateAdvancedVisitListData with (client_visit_obj, "Physician Encounter Charging Bypassed", zzz) ; + void := call advanced_visit_list_data_obj.{{{SINGLE-QUOTE}}}SetValue{{{SINGLE-QUOTE}}} with "BypassedChargesEncounterInformation" , bypassdetail ; + void := call advanced_visit_list_data_obj.{{{SINGLE-QUOTE}}}SetValue{{{SINGLE-QUOTE}}} with "BypassedChargesDoctorName" , user_name ; + void := call advanced_visit_list_data_obj.{{{SINGLE-QUOTE}}}SetValue{{{SINGLE-QUOTE}}} with "BypassedChargesDocumentName" , bypassdocument ; + void := call advanced_visit_list_data_obj.{{{SINGLE-QUOTE}}}SetValue>{{{SINGLE-QUOTE}}} with ("BypassedChargesServiceDate", dos as {{{SINGLE-QUOTE}}}System.DateTime{{{SINGLE-QUOTE}}}); + void := call advanced_visit_list_data_obj.Save; + endtry; + + catch Exception ex + error_occurred := true; error_message := "{{+R}}Error Message:{{-R}}\n" || ex.Message || "\n\n"; + if ( advanced_visit_list_data_obj is NOT NULL ) then void:= call advanced_visit_list_data_obj.Dispose; advanced_visit_list_data_obj:= null; endif; + if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; + endcatch; + + + + + // Addressed a Bypassed Charge + + + elseif order_item_name matches pattern "%Charge entry was bypassed on%" + + + then + + + + // Delete the Bypass AVL Entry + + chargingaddressed := "yes"; + discontinue_Comment_GUID := diagnosis_list; + + + + try + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((client_visit_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + advanced_visit_list_data_obj := call {{{SINGLE-QUOTE}}}AdvancedVisitListData{{{SINGLE-QUOTE}}}.CreateAdvancedVisitListData with (client_visit_obj, "Physician Encounter Charging Bypassed", discontinue_Comment_GUID) ; + + void := call advanced_visit_list_data_obj.Deactivate; + void := call advanced_visit_list_data_obj.Purge; + void := call advanced_visit_list_data_obj.Save; + + endtry; + + catch Exception ex + error_occurred := true; error_message := "{{+R}}Error Message:{{-R}}\n" || ex.Message || "\n\n"; + if ( advanced_visit_list_data_obj is NOT NULL ) then void:= call advanced_visit_list_data_obj.Dispose; advanced_visit_list_data_obj:= null; endif; + if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; + endcatch; + + + else + + + + // Create a Charge + + + chargingaddressed := "yes"; + + try + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((client_visit_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + care_provider_obj:= call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((user_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((locationGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + order_catalog_obj:= call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with (order_item_name); + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}CommonData: {{-R}}\n" || ex.Message || "\n\n"; + + if order_catalog_obj is NOT Null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; + if location_obj IS NOT Null then void := call location_obj.Dispose; location_obj := null; endif; + if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif; + if client_visit_obj IS NOT Null then void := call client_visit_obj.Dispose; client_visit_obj := null; endif; + endcatch; + + try + Order_Creation_Reason := "Physician Charge"; + RequestingSource := ""; + SessionType := "Standard"; + SessionReason := ""; + + Order_Obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder + with client_visit_obj, + order_catalog_obj, + Order_Creation_Reason, + care_provider_obj, + RequestingSource, + SessionType, + SessionReason, + location_obj, + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}New Other Order: {{-R}}\n" || ex.Message || "\n\n"; + if Order_Obj IS NOT Null then void := call Order_Obj.Dispose; Order_Obj := null; endif; + endcatch; + + diagnosis_val := call Order_Obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with "CHG_MDBill_Dx","ICD10 " || diagnosis_list_caret; + + // 35130 Upgrade SCM to version 16.3 + // dateofsvc_val := call Order_Obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue>{{{SINGLE-QUOTE}}} with "CHG_SVC_DATE",charge_date as time; + dateofsvc_val := call Order_Obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue>{{{SINGLE-QUOTE}}} with "CHG_SVC_DATE",(charge_date as time)as{{{SINGLE-QUOTE}}}System.DateTime{{{SINGLE-QUOTE}}}; + + conditchg_val := call Order_Obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with "CHG_MDBill_Comment",alternate_charge; + cosigner_val := call Order_Obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with "CHG_Cosigner",cosigner; + referring_val := call Order_Obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with "CHG_MDBill_Referring Physician",referring_physician; + + void := call Order_Obj.Save; + + if order_catalog_obj IS NOT Null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; + if location_obj IS NOT Null then void := call location_obj.Dispose; location_obj := null; endif; + if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif; + if client_visit_obj IS NOT Null then void := call client_visit_obj.Dispose; client_visit_obj := null; endif; + + + endif; // Comment VS Order creation + + + endif; // End of Place Order = Yes section + + + enddo; + + + + if chargingaddressed = "yes" + + then + + // Select the Charges Addressed Button + + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Charge Addressed"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := true; + listItems := (listItems, selectedItem); + + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; + + + endif; // launchtheapp = "yes" + + + conclude true; // always concludes TRUE + + + ;; + action: + + + return this_documentCommunication; + + ;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAUNCH_PROGRESS_NOTES_PROBLEM_LIST_BUILDER.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAUNCH_PROGRESS_NOTES_PROBLEM_LIST_BUILDER.mlm new file mode 100644 index 0000000..180dbb2 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAUNCH_PROGRESS_NOTES_PROBLEM_LIST_BUILDER.mlm @@ -0,0 +1,244 @@ +maintenance: + + title: Doc_Func_Launch_Progress_Notes_Problem_List_Builder;; + filename: Doc_Func_Launch_Progress_Notes_Problem_List_Builder;; + arden: version 2;; + version: 1.00;; + institution: Eclipsys Corp;; + author: Eclipsys Corp;; + specialist: Don Warnick;; + date: 2012-05-11;; + validation: testing;; + +library: + purpose: This mlm launches the Problem List Selector Objects+ custom application from a document. + ;; + explanation: The Problem List Selector was designed for use by the Physician Progress Note. + + Change history + + 08.08.2013 DW CSR#31743 Created + 01.26.2015 JML CSR# 32617 - Modify Problem List Selector window to combine HI Search with one used for Admit/Discharge Dx + 02.24.2015 JML Moved to Production. + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + (this_documentCommunication, selectedbutton) := argument; + + 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"; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + str_parse := mlm {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; +// WriteToNote_MLM := MLM{{{SINGLE-QUOTE}}}Called_RPM_DOM_MLM{{{SINGLE-QUOTE}}}; + WriteToNote_MLM := MLM{{{SINGLE-QUOTE}}}STD_DOC_FUNC_CHART_OBSERVATION_HELPER_JAB{{{SINGLE-QUOTE}}}; + + target_parameter_name := "" ;newValue:= "" ;sugg_txt_value:="";REPLACE_APPEND := "Replace"; +// THIS_MLM_NAME:= "Doc_Func_Launch_Progress_Notes_Problem_List_Builder"; //. unsure of the reason for this line, so I commented it out + + openfields := "0"; + opencounter := 0; + + // This section determines which of the fields are vacant + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 1"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_1 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 2"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_2 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 3"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_3 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 4"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_4 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 5"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_5 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 6"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_6 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 7"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_7 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 8"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_8 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 9"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_9 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 10"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_10 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 11"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_11 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 12"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_12 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 13"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_13 := "open"; opencounter := opencounter + 1; endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Problem 14"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + thisfield := theObservation.ValueObj.Value; + if thisfield is null then field_14 := "open"; opencounter := opencounter + 1; endif; + + openfields := opencounter as string; + + + + //using "ProgressNoteProblemListBuilder"; + using "Problem List Selector 1.2"; + using namespace "ProblemListBuilder"; + test := new net_object {{{SINGLE-QUOTE}}}ProblemListBuilder.ProblemListBuilderForm{{{SINGLE-QUOTE}}} with (openfields); + //using namespace "xxx"; + //test:= new net_object {{{SINGLE-QUOTE}}}ProblemListBuilder.ProblemListBuilderForm{{{SINGLE-QUOTE}}} with (openfields); + + ;; + evoke: // No evoke statement + ;; + logic: + + oeUnsigned:=CALL test.ShowDialog; // launch as a modal window to enable text to pass back to the MLM + return_string:= test.text; // returns information gathered from the app to the MLM + + sugg_txt_value:=""; + + + // This secton parses the data passed from the app (format = "problem|problem|problem" etc..) + + + calc_map_list :=(return_string); + itemlist := call str_parse with calc_map_list,"|"; + + calc_element_list := call str_parse with calc_map_list, "|"; + problem1 := calc_element_list[1]; + problem2 := calc_element_list[2]; + problem3 := calc_element_list[3]; + problem4 := calc_element_list[4]; + problem5 := calc_element_list[5]; + problem6 := calc_element_list[6]; + problem7 := calc_element_list[7]; + problem8 := calc_element_list[8]; + problem9 := calc_element_list[9]; + problem10:= calc_element_list[10]; + problem11:= calc_element_list[11]; + problem12:= calc_element_list[12]; + problem13:= calc_element_list[13]; + problem14:= calc_element_list[14]; + + + // Populate the variable, "prob" with a problem (if it is pass 1, use problem1) + + + for i in 1 seqto count itemlist do + + if i = 1 then prob := problem1; + elseif i = 2 then prob := problem2; + elseif i = 3 then prob := problem3; + elseif i = 4 then prob := problem4; + elseif i = 5 then prob := problem5; + elseif i = 6 then prob := problem6; + elseif i = 7 then prob := problem7; + elseif i = 8 then prob := problem8; + elseif i = 9 then prob := problem9; + elseif i = 10 then prob := problem10; + elseif i = 11 then prob := problem11; + elseif i = 12 then prob := problem12; + elseif i = 13 then prob := problem13; + elseif i = 14 then prob := problem14; + endif; + + + // Place the problem in the first available text field...and mark it as "occupied" + + + if field_1 = "open" then target_parameter_name1:= "SCH_MDPN_Problem 1"; field_1 := "occupied"; + elseif field_2 = "open" then target_parameter_name1:= "SCH_MDPN_Problem 2"; field_2 := "occupied"; + elseif field_3 = "open" then target_parameter_name1:= "SCH_MDPN_Problem 3"; field_3 := "occupied"; + elseif field_4 = "open" then target_parameter_name1:= "SCH_MDPN_Problem 4"; field_4 := "occupied"; + elseif field_5 = "open" then target_parameter_name1:= "SCH_MDPN_Problem 5"; field_5 := "occupied"; + elseif field_6 = "open" then target_parameter_name1:= "SCH_MDPN_Problem 6"; field_6 := "occupied"; + elseif field_7 = "open" then target_parameter_name1:= "SCH_MDPN_Problem 7"; field_7 := "occupied"; + elseif field_8 = "open" then target_parameter_name1:= "SCH_MDPN_Problem 8"; field_8 := "occupied"; + elseif field_9 = "open" then target_parameter_name1:= "SCH_MDPN_Problem 9"; field_9 := "occupied"; + elseif field_10 = "open" then target_parameter_name1:= "SCH_MDPN_Problem 10"; field_10 := "occupied"; + elseif field_11 = "open" then target_parameter_name1:= "SCH_MDPN_Problem 11"; field_11 := "occupied"; + elseif field_12 = "open" then target_parameter_name1:= "SCH_MDPN_Problem 12"; field_12 := "occupied"; + elseif field_13 = "open" then target_parameter_name1:= "SCH_MDPN_Problem 13"; field_13 := "occupied"; + elseif field_14 = "open" then target_parameter_name1:= "SCH_MDPN_Problem 14"; field_14 := "occupied"; + endif; + + + // Write to the text field + + + if exist prob and (length of (TRIM prob)) > 1 and prob <> "<>" then + target_parameter_name := target_parameter_name1; + newValue := prob; + REPLACE_APPEND := "Replace"; + +// this_documentCommunication := CALL WriteToNote_MLM WITH (this_documentCommunication, target_parameter_name,newValue,sugg_txt_value,REPLACE_APPEND); + this_documentCommunication := CALL WriteToNote_MLM WITH (this_documentCommunication, target_parameter_name,newValue,REPLACE_APPEND); + + endif; + + enddo; + + + + conclude true; // always concludes TRUE + ;; + action: + return this_documentCommunication; + + ;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAUNCH_RESULTS_QUICK_VIEWER.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAUNCH_RESULTS_QUICK_VIEWER.mlm new file mode 100644 index 0000000..0812965 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAUNCH_RESULTS_QUICK_VIEWER.mlm @@ -0,0 +1,167 @@ +maintenance: + + title: Doc_Func_Launch_Results_Quick_Viewer;; + filename: Doc_Func_Launch_Results_Quick_Viewer;; + arden: version 2;; + version: 1.00;; + institution: Eclipsys Corp;; + author: Eclipsys Corp;; + specialist: Don Warnick;; + date: 2012-05-11;; + validation: testing;; + +library: + purpose: This mlm launches the Results Quick Viewer Objects+ custom application from a document + ;; + explanation: The Results Quick Viewer was designed for use by the Physician Progress Note, but could be useful in other areas of SCM + + Change history + + 05.11.2011 DW Created + 10.17.2015 SH CSR#: 33714 - Updating results quickviewer objects plus to allow adding results to the progress notes. + 3.2.2016 STH CSR#: 34201 - Update formatting of results as the RTF formatting didnt have a space so when a numeric value followed RTF formatting you would loose both the formatting and the numeric value. {Go-Live 3/16/2016} + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + (this_documentCommunication) := argument; + /*******************Make Changes To Spelling And Flags In This Section*******************/ + + /* Set to true if a decision.log is needed.*/ + log_execution_info := FALSE; + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + str_parse := mlm {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; //used to parse string data into a list + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + using "ResultsQuickViewer"; + using namespace "ResutlsQuickViewer"; + + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + +// Reset the launch button + + theParameterx := first of (thisparameters where thisparameters.Name = "SCH_Launch FT Window"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameterx.ParameterGUID); + + rtbCommentsParam := first of (thisparameters where thisparameters.Name = "SCH_MDPN_Other Results"); + rtbCommentsObs := first of (thisobservations where thisobservations.ParameterGUID = rtbCommentsParam.ParameterGUID); +//first of (thisparameters where thisparameters.Name = "SCH_MDPN_Other Results"); + //rtbCommentsObs := first of (thisobservations where thisobservations.ParameterGUID = rtbCommentsParam.ParameterGUID); + + if this_documentCommunication.CurrentObservationObj.parameterguid = theParameterx.ParameterGUID then + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_Launch FT Window"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := false; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; + + docname := this_documentCommunication.DocumentName as string; + test:= new net_object {{{SINGLE-QUOTE}}}ResultsQuickViewer.ResultsQuickViewerForm{{{SINGLE-QUOTE}}} with (docname); + ;; + evoke: // No evoke statement + ;; + logic: + lstFromObj := LaunchCP.lstProviders4Note; + oeUnsigned:=CALL test.ShowDialog; + + lstFromObj := (); + lstFromObj := test.lstResults4note; + txtfromobj := test.Results4Note as string; + lstresults := call str_parse with (txtfromobj,"|"); + ctlistitems := count(lstresults); + a := lstresults[0]; + b := lstresults[1]; + c := lstresults[2]; + d := lstresults[3]; + finalresults := ""; + resultcategory := ""; + currentcategory := ""; + for x in (1 seqto (ctlistitems)) do + lstitems := call str_parse with (lstresults[x],"^"); + currentcategory := lstitems[2]; + if currentcategory <> resultcategory then + if (lstitems is not null and lstitems <> "") then + finalresults := finalresults || "\n____________________________________________________________"; + endif; + finalresults := finalresults || "\b \ul \li0 " || lstitems[2] || "\b0 \ul0 \n"; + resultcategory := currentcategory; + endif; + if lstitems[1] is not null and lstitems[1] <> "" then + finalresults := finalresults || "\b \li360 " || lstitems[1] || " - " || lstitems[3] || " [" || lstitems[4] || "]" || "\b0 " || "\n" || "\li720 " || (trim left(lstitems[5])) || "\n \li0 "; + if x < ctlistitems then + finalresults := finalresults || "\li360 ------------------------------------------------------------" || "\n \li0 "; + + + else + finalresults := finalresults || "\n"; + endif; + endif; + enddo; + + + rtbCommentObj := NEW ObservationType; + rtbCommentObj.ClientdocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + rtbCommentObj.ParameterGUID := rtbCommentsParam.ParameterGUID; + rtbCommentObj.DataType := "FreeTextValue"; + rtbCommentObj.ValueObj := NEW FreeTextValueType; + rtbCommentObj.ValueObj.Value := finalresults; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, rtbCommentObj); + + + +/* + vitalSignsHL := first of (thisParameters where thisParameters.Name = "SCH_MDPN_FT VS, I & O"); + + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := vitalSignsHL.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := formattedTextAll; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); +*/ + + + conclude true; // always concludes TRUE + ;; + action: + return this_documentCommunication; + + ;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAY_CAREGIVER_NAME.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAY_CAREGIVER_NAME.mlm new file mode 100644 index 0000000..5a60872 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_LAY_CAREGIVER_NAME.mlm @@ -0,0 +1,104 @@ +maintenance: + + title: DOC_FUNC_LAY_CAREGIVER_NAME ;; + mlmname: DOC_FUNC_LAY_CAREGIVER_NAME;; + arden: version 2.5;; + version: 1.00;; + institution: St.Clair Hospital ;; + author: Sandy Zhang, PharmD ;; + specialist: Janet Nordin ;; + date: 2017-06-13;; + validation: testing;; + +library: + purpose: This MLM takes the patient{{{SINGLE-QUOTE}}}s Lay Caregiver name and populates it into Discharge Checklist + ;; + explanation: + + Change History + + 06.13.2017 SZ CSR# 35709 - Start of project + + ;; + keywords: + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + // Standard includes + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + // SQL returns Lay Caregiver{{{SINGLE-QUOTE}}}s name. This name is inserted into discharge checklist unless it matches "NO, CAREGIVER, NO_CAREGIVER or name returns null" + (laygiver_name) := read last { + "select Name" + ||" from CV3ClientContact" + ||" where TypeCode = {{{SINGLE-QUOTE}}}Lay Caregiver{{{SINGLE-QUOTE}}}" + ||" and ClientGUID = " || sql(clientGuid) + ||" and Active = 1" + }; + + + if thisdocumentCommunication.EventType = "DocumentOpening" then + + // Lay Caregiver name in Discharge Checklist returns N/A if it matches: "NO, CAREGIVER, NO_CAREGIVER or name returns null" from SQL + if (laygiver_name = "NO, CAREGIVER") or (laygiver_name = "NO_CAREGIVER") or (laygiver_name is null) then + + vitalSignsHL := first of (thisParameters where thisParameters.Name = "SCH_PDC_ Designated Lay Caregiver Name"); + + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := vitalSignsHL.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := "N/A"; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + // If it doens{{{SINGLE-QUOTE}}}t match up to any of the above no-names then the Discharge Checklist returns the name of the Lay Caregiver + else + vitalSignsHL := first of (thisParameters where thisParameters.Name = "SCH_PDC_ Designated Lay Caregiver Name"); + + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := vitalSignsHL.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := laygiver_name; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + endif; + endif; + + + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_MAX_TEMPERATURE.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_MAX_TEMPERATURE.mlm new file mode 100644 index 0000000..02fc81a --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_MAX_TEMPERATURE.mlm @@ -0,0 +1,222 @@ +maintenance: + + title: DOC_FUNC_Max_Temperature ;; + mlmname: DOC_FUNC_Max_Temperature ;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Shivprasad Jadhav;; + specialist: ;; + date: 2015-04-27;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 27.04.2015 DW CSR:33155- Created to show last 24 hours Max Temperature observations from Physician Progress Note. + 14.08.2015 GOS Added document name [{{{SINGLE-QUOTE}}}B1. Newborn Vital Signs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}1. Vital Signs - Critical Care{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}1.Vital Signs - Critical Care{{{SINGLE-QUOTE}}} ] + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + local_session := cds_session.local; + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + (this_currentObj) := thisdocumentCommunication.CurrentObservationObj; + comm_obj := thisDocumentCommunication.primaryobj; + + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + Infectious_Dis := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Grouping Disease"); + selectedItems := (this_currentObj.ValueObj.ListItemsList WHERE this_currentObj.ValueObj.ListItemsList.IsSelected = true); + currentObj_selectedItems := selectedItems.value ; //,Infectious Disease + + + +// OBSERVATION CHANGE + + + if thisDocumentCommunication.EventType = "ChartObservation" + then + + (obsNamesList, lastValuesList, highValuesList, lowValuesList) := read + { + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), name varchar(200), value decimal(5,2), timstmp datetime, sortseq int, timstmp2 varchar(30) ) " + || " INSERT INTO #tmp_aaa (name,value,timstmp, sortseq) " + || " select ocmi.Name, o.ValueText, od.RecordedDtm, " + || " CASE WHEN Name = {{{SINGLE-QUOTE}}}farenheit{{{SINGLE-QUOTE}}} THEN 01 " + || " ELSE 99 " + || " END AS SortSeq " + || " " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " AND ocmi.Name in ({{{SINGLE-QUOTE}}}farenheit{{{SINGLE-QUOTE}}}) " + || " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " " + || " and cd.iscanceled = 0 " + || " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}1.Vital Signs - Basic{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}B1. Newborn Vital Signs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}1. Vital Signs - Critical Care{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}1.Vital Signs - Critical Care{{{SINGLE-QUOTE}}}) " + || " order by sortseq , cd.touchedwhen " + || " " + // || " update t1 set timstmp2 = t2.timstmp from #tmp_aaa t1 " + // || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq = t2.sortseq " + || " delete from #tmp_aaa where Value is null Delete from #tmp_aaa Where Convert(datetime,timstmp) < dateadd(hour, -24,getdate()) " + || " " + || " select Top 1 name, value, timstmp, sortseq from #tmp_aaa Where Value= (Select Max(Value ) From #tmp_aaa ) order by timstmp desc, sortseq " + || " drop table #tmp_aaa " + }; +// update #tmp_aaa Set #tmp_aaa.timstmp = Dateadd(hour, -4, Getdate()) + header1 :="\n\n\b Vital Signs - Max Temperature in Past 24 Hours\b0\n\n"; + formattedText1 := " "; + thisdatefield := " "; + yesterday := now-24 hours; + + + indexList := 1 seqto count (obsNamesList); + + for i in indexList do + + obsName := (obsNamesList[i]); + + // Reformat the Time Stamp + + thisdatefield_unformatted := (highValuesList[i]); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the first group and charted in the past 24 hours + + if obsName in ("farenheit" ) + and + thisdatefield_unformatted > yesterday + + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := (highValuesList[i]); + formattedText1 := thisdatefield_formatted; + endif; + + + if thisdatefield <> (highValuesList[i]) // new timestamp + then + formattedText1 := formattedText1 || "\n" || thisdatefield_formatted; + thisdatefield := (highValuesList[i]); + else + formattedText1 := formattedText1 || " " ; + endif; + + + + if obsName = "Farenheit" then formattedText1 := formattedText1 || "\b T:\b0 "; + + //elseif obsName = "SCH_vs_pulse ox source" then formattedText1 := formattedText1 || "/" ; //b O2 L/min:\b0 "; + endif; + + + formattedText1 := formattedText1 || " "; + formattedText1 := formattedText1 || (lastValuesList[i]); + + endif; // Obsname amongst the Vital Signs observations + + enddo; + + + // Gather the existing contents of the textbox + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_FT VS, I & O"); + obs := FIRST OF (thisObservations WHERE thisObservations.parameterGUID = theParameter.parameterGUID); + priorcontents := obs.ValueObj.Value; + + formattedTextAll:= priorcontents || header1 || formattedText1; + + + endif; +// for Passing the Value in Base MLm via Session Variable ===== +If formattedText1 is Not Null Then +abc:= Call (formattedText1 as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "T:" as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}, "" as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}; +Else +abc:= formattedText1 ; +Endif; +local_session.ACS_FormatedText := Null ; +local_session.ACS_FormatedText := " " || abc ; + +//End ========================================================= + + If formattedTextAll is not null + + then + + vitalSignsHL := first of (thisParameters where thisParameters.Name = "SCH_MDPN_FT VS, I & O"); + + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := vitalSignsHL.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := formattedTextAll; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + + /*for current_item in currentObj_selectedItems do + If current_item ="Infectious Disease" Then + + vitalSignsHL1 := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Groupings"); + + newObservation1 := NEW ObservationType; + newObservation1.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation1.ParameterGUID := vitalSignsHL1.ParameterGUID; + newObservation1.DataType := "FreeTextValue"; + newObservation1.ValueObj := NEW FreeTextValueType; + newObservation1.ValueObj.Value := formattedTextAll; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation1); + + Endif; + enddo;*/ + + endif; + + + + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_MD_PROGRESSNOTE_COREMEASURES.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_MD_PROGRESSNOTE_COREMEASURES.mlm new file mode 100644 index 0000000..5727078 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_MD_PROGRESSNOTE_COREMEASURES.mlm @@ -0,0 +1,349 @@ +maintenance: + + title: DOC_Func_MD_ProgressNote_CoreMeasures ;; + mlmname: DOC_Func_MD_ProgressNote_CoreMeasures ;; + arden: version 2.5;; + version: 5.50;; + institution: St. Clair;; + author: ACS;; + specialist: Allscripts Custom Services;; + date: 2011-09-05;; + validation: testing;; + +library: + purpose: Called upon opening of the Physician Progress note to assess compliance with the Core Measures + ;; + explanation: This MLM looks at the patient{{{SINGLE-QUOTE}}}s health issues and medictions to determine Core Measure Compliance + + Change history + + 05.08.2012 DW CSR# 26409 - Built from Core Measure code extracted from DOC_ST_Clair_MAIN_PN_MLM + 10.24.2013 DW CSR# 31693 - Probiotic Protocol CSR required a change to the Create Order Functional MLM. I now pass session type = "standard" + 11.13.2013 DW CSR# 31693 - Pass Order Source Value to Order Creation Functional MLM + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + (this_documentCommunication) := argument; + + //Initialize Variables and Constants Declaration + (this_structuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (this_parameters) := this_structuredNoteDoc.ParametersList; + (this_chartedObservationsList) := this_structuredNoteDoc.ChartedObservationsList; + (this_currentObj) := this_documentCommunication.CurrentObservationObj; + (client_guid) := this_documentCommunication.ClientGUID; + (client_chart_guid) := this_documentCommunication.ChartGUID; + (client_visit_guid) := this_documentCommunication.ClientVisitGUID; + (client_document_guid) := this_structuredNoteDoc.ClientDocumentGUID ; + (doc_name) := this_documentCommunication.DocumentName ; + (this_parameter_name) := this_parameters.DisplayName ; + (theEvent) :=this_documentCommunication.EventType ; + (this_parameter_nameis) :=this_parameters.Name ; + current_parameter := FIRST OF (this_Parameters WHERE this_parameters.ParameterGUID = this_CurrentObj.ParameterGUID); + current_parameter_name := current_parameter.name ; + current_parameter_guid := current_parameter.ParameterGuid ; + current_parameter_DataType := current_parameter.DataType ; + selectedItems := (this_currentObj.ValueObj.ListItemsList WHERE this_currentObj.ValueObj.ListItemsList.IsSelected = true); + currentObj_selectedItems := selectedItems.value ; + countOf_selectedItems := COUNT OF currentObj_selectedItems ; + DocumentTopic := this_structuredNoteDoc.DocumentTopic; + + //List Variables + All_Attributes_Lst:=(); //List object attributes retrieved (“name”, “itemname”, etc.) + All_Values_Lst:=(); //List of values for the attribute(s) + All_UoM_Lst:=(); //List of UOMs (units of measure) for the attributes + All_Med_Rel_Dttm_Lst:=(); //List of medically relevant times /(“performeddtm”,“significantdtm”, etc.) + All_Start_Time_Lst:=(); //List of start times (if relevant) + All_Stop_Time_Lst:=(); //List of stop tiames (if relevant) + All_User_Guid_Lst:=(); //List of userguids who entered data. + All_Significant_Data_Lst:=(); //List of other “significant data” as a text field. + All_Sig_Count_Lst := (); //List of significant counts. + current_item_list := (); // items currently to be processed + + //SET THE DEFAULT VALUES of Variables to be passed to ACS_Generic_Lookup MLM + + Is_Historical := "Historical" ; //“historical” or “current” (indicates whether to use SQL or current object navigation) + Retreive_Object := ""; //Object to retrieve (“HealthIssue”, “order”, “allergy”, “observation”, etc.) + Retreive_Attribute := ""; //Attribute to retrieve (“name”, “itemname”, etc.) + Filterable_Attribute := ""; //Filterable attribute (“name”,“itemname”,“typecode”, etc.) + Filterable_Operator := ""; //Filterable operator (“=”, “in”, “matches pattern”, etc.) + Filterable_Value :=""; //Filterable value(s) (“chronic”, “antibiotic”, “(‘480.00’,’480.30’)”, etc.) + Additional_condition := ""; //Additional condition(s) (“orderstatuslevelnum between 55 and 60”, “performedtm > dateadd(-24, hh, getdate()”, etc.) + topic_var:= ""; //this_documentCommunication.DocumentTopic; + msg := ""; //message + Selected_groups := (); // for groupings section, uses the local_config object; + + //Tab definitions and formating + TAB := 9 FORMATTED WITH "%C" ; + TAB2 := TAB || TAB ; + TAB3 := TAB || TAB || TAB; + Token:= ""; //Token for deciding which list item is selected + Result_String := ""; //String which is return from this MLM + CR := 13 formatted with "%c"; + LF := 10 formatted with "%c"; + CRLF:= CR||LF; + SP:= 32 formatted with "%c"; + SP2:= SP||SP; + SP3:= SP||SP||SP; + + // "hidden" terminator characters for parsing/deleting text: + (blt_char, par_char) := read first{"select char(8), char(20)"}; + + //********************Lookup Site Specific Configured items***************************// + //Called MLM{{{SINGLE-QUOTE}}}s + Get_mlm_Generic_Lookup_data := MLM {{{SINGLE-QUOTE}}}ACS_Generic_Lookup{{{SINGLE-QUOTE}}}; + Called_DOM_mlm := MLM {{{SINGLE-QUOTE}}}STD_DOC_FUNC_CHART_OBSERVATION_HELPER_JAB{{{SINGLE-QUOTE}}}; + parse_mlm:= MLM {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; + set_contingency_question := mlm {{{SINGLE-QUOTE}}}ACS_obs_select_func_on_lookup{{{SINGLE-QUOTE}}}; + create_CHF_order := mlm {{{SINGLE-QUOTE}}}SCH_FUNC_CREATE_ORDER{{{SINGLE-QUOTE}}}; + + // TOKEN \ RTF FIELD\ THER OR MED SEARCH \ MED SEARH OPERATOR \ MED SEARCH VALUE \ QUALIFYING HIs \ THER SEARCH TYPEs + map_list :=( + "|CM_AMI|\SCH_MDPN_CM AMI FT\TherandMed\like\{{{SINGLE-QUOTE}}}305.1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}V15.82{{{SINGLE-QUOTE}}}\{{{SINGLE-QUOTE}}}cardiovascular agents | angiotensin converting enzyme inhibitors{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}cardiovascular agents | angiotensin II inhibitors{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}cardiovascular agents | beta-adrenergic blocking agents{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}metabolic agents | antihyperlipidemic agents{{{SINGLE-QUOTE}}}" + ,"|cm_vte|\SCH_MDPN_CM VTE FT\MedOnly\like\{{{SINGLE-QUOTE}}}453{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.0{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.2{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.3{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.40{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.41{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.42{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.50{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.51{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.52{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.6{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.71{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.72{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.73{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.74{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.75{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.76{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.77{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.79{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.8{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.81{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.82{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.83{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.84{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.85{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.86{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.87{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.89{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}453.9{{{SINGLE-QUOTE}}}\" + ,"|cm_chf|\SCH_MDPN_CM HF FT\TherOnly\\{{{SINGLE-QUOTE}}}428{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}428.0{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}428.00{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}428.1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}428.20{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}428.21{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}428.22{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}428.23{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}428.30{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}428.31{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}428.32{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}428.33{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}428.40{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}428.41{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}428.42{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}428.43{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}428.9{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}428@758.5{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}V15.82{{{SINGLE-QUOTE}}}\{{{SINGLE-QUOTE}}}cardiovascular agents | angiotensin converting enzyme inhibitors{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}cardiovascular agents | angiotensin II inhibitors{{{SINGLE-QUOTE}}}" + ,"|cm_stroke|\SCH_MDPN_CM Stroke FT\MedOnly\like\{{{SINGLE-QUOTE}}}434.91{{{SINGLE-QUOTE}}}\" + ); + + if (theEvent = "DocumentOpening") then + + (OccCode, userName) := read last {" select OccupationCode, IDCode from CV3USER with (nolock) where guid = " || sql(this_documentCommunication.UserGUID) }; +// if ( OccCode = "IT" AND userName = "jlaw" ) then +// break; +// endif; + + for i in 1 seqto count map_list do + element_list := call parse_mlm with map_list[i], "\"; + Token := element_list[1]; + target_parameter_name := element_list[2]; + medsearchtype := element_list[3]; + add_med_name_operator := element_list[4]; + Filterable_Value := element_list[5]; + med_ther_cat_filter := element_list[6]; + + Is_Historical := "Historical"; + Retreive_Object := "HealthIssue"; + Retreive_Attribute := "hi.shortname"; + Filterable_Attribute := "ch.code"; + Filterable_Operator := "IN" ; + Additional_condition := ""; + Result_String := ""; + + + // Need to update this field afterward as some have values surrounded with double quotes + + if Token = "|CM_AMI|" then + add_med_name_filter := "%aspirin%"; + endif; + + if Token = "|cm_vte|" then + add_med_name_filter := "Heparin", "Coumadin", "Warfarin", "Lovenox","Enoxaparin", "Pradaxa", "Dabigatran", "Argatroban"; + endif; + + if Token = "|cm_stroke|" then + add_med_name_filter := "Aspirin", "Aggrenox", "Plavix", "Pradaxa", "Jantoven", "Argatroban", "Acuprin", "Ascriptin", "Coumadin", "Lovenox", "Warfarin", "Heparin"; + endif; + + + // clear target area + this_documentCommunication := CALL Called_DOM_Mlm WITH (this_documentCommunication, target_parameter_name, ("","Replace")); + + // Get Related Health Issues + ther_cat_not_found := (); + add_meds_not_found := (); + all_not_found := (); + + // Call ACS_Generic_Lookup MLM to retrieve patient data + (All_Attributes_Lst, All_Values_Lst, All_UoM_Lst, All_Med_Rel_Dttm_Lst, All_Start_Time_Lst, All_Stop_Time_Lst, + All_User_Guid_Lst, All_Significant_Data_Lst, this_documentCommunication, All_Sig_Count_Lst) := CALL Get_mlm_Generic_Lookup_data WITH + (this_documentCommunication, client_guid, client_visit_guid,client_chart_guid, Is_Historical,Retreive_Object,Retreive_Attribute, + Filterable_Attribute, Filterable_Operator,Filterable_Value, Additional_condition); + + // Core Measure Qualifying Health Issues Section + Result_string := Result_String || "\n Core Measure: " || token || "\n\n Related Health Issue: " || All_Attributes_Lst || "\n\n" ; // Core Measure Name & Health Issue + + If Exists All_Values_Lst Then + CoreMeasurePatient := "True"; + Else CoreMeasurePatient := "False"; + endif; + + // If Patient qualifies for this Core Measure, look for related medications + + If CoreMeasurePatient = "True" then + All_Attributes_Lst := (); + + // Check for Core Measure Related Medications by therapeutic class + + if medsearchtype = "TherOnly" or medsearchtype = "TherandMed" then + + Retreive_Object := "Orders"; //"Therap_Cat_Orders"; + Filterable_Attribute := "ocmi.TherapeuticCategory"; + Filterable_Operator := "IN" ; + Filterable_Value := med_ther_cat_filter; + Additional_condition := ""; + + // Call ACS_Generic_Lookup MLM to retrieve patient data + (All_Attributes_Lst, All_Values_Lst, All_UoM_Lst, All_Med_Rel_Dttm_Lst, All_Start_Time_Lst, All_Stop_Time_Lst, + All_User_Guid_Lst, All_Significant_Data_Lst, this_documentCommunication, All_Sig_Count_Lst) := CALL Get_mlm_Generic_Lookup_data WITH + (this_documentCommunication, client_guid, client_visit_guid,client_chart_guid, Is_Historical,Retreive_Object,Retreive_Attribute, + Filterable_Attribute, Filterable_Operator,Filterable_Value, Additional_condition); + + // Make the SQL list readable by Arden and compare with returned data + arden_mtcf_parsed := call parse_mlm with med_ther_cat_filter, "{{{SINGLE-QUOTE}}}"; + arden_med_ther_cat_filter := arden_mtcf_parsed where (length it > 1); + ther_cat_not_found := arden_med_ther_cat_filter where (it is not in All_UoM_Lst); + + //NOTE: Under CHF, {{{SINGLE-QUOTE}}}no{{{SINGLE-QUOTE}}} still checking IF patient has a med + // because ther_cat_not_found is being set to one of two theraputic categories + // when a med from only 1 is required + // If no related medications are found, update the not found field + + if exists ther_cat_not_found then + if ((Token = "|CM_CHF|" AND (count ther_cat_not_found > 1)) OR (Token <> "|CM_CHF|")) then + all_not_found := all_not_found, ther_cat_not_found; + endif; + endif; + + endif; + + // Check for Core Measure Related Medications by indiviual medication name + if medsearchtype = "MedOnly" or medsearchtype = "TherandMed" then + Retreive_Object := "Orders"; + Filterable_Attribute := "o.name"; + Filterable_Operator := add_med_name_operator ; + Filterable_Value := add_med_name_filter; + Additional_condition := " o.typecode = {{{SINGLE-QUOTE}}}Medication{{{SINGLE-QUOTE}}} "; + + // Call ACS_Generic_Lookup MLM to retrieve patient data + (more_Attributes_Lst, more_Values_Lst, more_UoM_Lst, more_Med_Rel_Dttm_Lst, more_Start_Time_Lst, more_Stop_Time_Lst, + more_User_Guid_Lst, more_Significant_Data_Lst, this_documentCommunication) := CALL Get_mlm_Generic_Lookup_data WITH + (this_documentCommunication, client_guid, client_visit_guid, client_chart_guid, Is_Historical, Retreive_Object, + Retreive_Attribute, Filterable_Attribute, Filterable_Operator, Filterable_Value, Additional_condition); + + // If no related medications are found, update the not found field + if (not exists more_Attributes_Lst) then + add_meds_not_found := "(ANY)"; + all_not_found := all_not_found,add_meds_not_found; + endif; + + endif; //exists add_med_name_filter + + + // Compose the message related to the med being found or not + If ((medsearchtype = "TherOnly" or medsearchtype = "TherandMed") and exists All_Attributes_Lst) OR + ((medsearchtype = "MedOnly" or medsearchtype = "TherandMed") and exists more_Attributes_Lst) Then + Result_string := Result_String || All_Attributes_Lst || "\n " || more_Attributes_Lst || " \n\n Medications found - no deficiency"; + Else + Result_string := Result_String || " \n\n No Medications related to the Core Measure were found - deficiency"; + endif; + + // If no medications were found, Call {{{SINGLE-QUOTE}}}ACS_obs_select_func_on_lookup{{{SINGLE-QUOTE}}} to select the appropriate box + + if exists all_not_found then + this_documentCommunication := CALL set_contingency_question with (this_documentCommunication, token, all_not_found); + endif; + EndIf; + + // Calls the STD_DOC_FUNC_CHART_OBSERVATION_HELPER_JAB which writes data to the note + if Result_String <> "" then + this_documentCommunication:= CALL Called_DOM_Mlm WITH (this_documentCommunication,target_parameter_name,(Result_String,"Append")); //Appending the result with existing value. + endif; + enddo; + + elseif (theEvent = "ChartObservation") then + if (current_parameter_name = "SCH_MDPN_CM_HF_Orders ACE") then + SelectedList := OBJECT[ ListGUID, SelectedValues, SuggestiveText ]; + + PN_sel_list := NEW SelectedList; + newValue := (); + + if (countOf_selectedItems > 1) then + for i in 1 seqto countOf_selectedItems do + if (currentObj_selectedItems[i] <> "no") then + //Need to uncheck {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} + newValue := newValue, currentObj_selectedItems[i]; + endif; + enddo; + + //PN_sel_list.ListGUID := currentObj_ParameterObj.ListGUID; + PN_sel_list.ListGUID := current_parameter.ConfigurationObj.ListGUID; + list_name := current_parameter_name; + PN_sel_list.SelectedValues := newValue; + PN_sel_list.SuggestiveText := null; + + if (exists newValue) then + this_documentCommunication := CALL Called_DOM_mlm WITH (this_documentCommunication, list_name, PN_sel_list); + endif; + endif; + endif; + + elseif (theEvent = "DocumentClosing") then + + (OccCode, userName) := read last {" select OccupationCode, IDCode from CV3USER with (nolock) where guid = " || sql(this_documentCommunication.UserGUID) }; +// if ( OccCode = "IT" AND userName = "jlaw" ) then +// break; +// endif; + + cm_chf_ace_list := first of (this_parameters WHERE this_parameters.Name = "SCH_MDPN_CM_HF_Orders ACE"); + + if (exists cm_chf_ace_list) then + + cm_chf_ace_list_obs := first of (this_chartedObservationsList + WHERE this_chartedObservationsList.ParameterGUID = cm_chf_ace_list.ParameterGUID); + + if (exists cm_chf_ace_list_obs) then + selectedValues := (cm_chf_ace_list_obs.ValueObj.ListItemsList.Value + WHERE cm_chf_ace_list_obs.ValueObj.ListItemsList.IsSelected = true); + + if ((count selectedValues) >= 1) then + for i IN 1 seqto (count selectedValues) do + parameter_med := (SUBSTRING (FIND "po" IN STRING LOWERCASE selectedValues[i])-1 CHARACTERS FROM selectedValues[i]); + if (selectedValues[i] matches pattern "%daily%") then + parameter_freq := "Daily (09)"; + elseif (selectedValues[i] matches pattern "%BID%") then + parameter_freq := "BID (09-21)"; + else + parameter_freq := "Daily (09)"; + endif; + + genericMedName := read {"SELECT ocmi.Name, ocmi.touchedWhen " + || " FROM CV3OrderCatalogMasterItem ocmi with (nolock) " + || " JOIN CV3CatalogItemName cin with (nolock) " + || " ON ocmi.GUID = cin.OrderMasterItemGUID " + || " WHERE cin.Name = {{{SINGLE-QUOTE}}}" || parameter_med || "{{{SINGLE-QUOTE}}}" + , primaryTime = touchedWhen}; + + SessionType := "Standard"; + + if (exists genericMedName) then + var := call create_CHF_order WITH (client_visit_guid, this_documentCommunication.UserGUID, + client_guid, SessionType,"", genericMedName[1], "-", "Medication", parameter_freq); + + endif; + enddo; + endif; + endif; + endif; + //Clear target area + this_documentCommunication := CALL Called_DOM_Mlm WITH (this_documentCommunication, "SCH_MDPN_CM_HF_Orders ACE", ("","Replace")); + endif; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_MRSA_SCREEN.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_MRSA_SCREEN.mlm new file mode 100644 index 0000000..77f965b --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_MRSA_SCREEN.mlm @@ -0,0 +1,226 @@ +maintenance: + + title: MRSA Screening Logic;; + mlmname: DOC_FUNC_MRSA_Screen;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Teresa Spicuzza;; + specialist: ;; + date: 2010-12-21;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 12.21.2010 TS Created + 05.04.2011 TS Added logic to check if patient has ever had screen done. If yes, do not order another if + updates made to patient profile. + 09.27.2016 TS Eliminate current location of "St. Clair Hospital Anc" from proceeding through logic. Some + outpatient departments are using the Adult Patient Profile and screens are getting ordered + if patient has a history of MRSA. HD Ticket # 2372719 + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + //Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Receive arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + clientvisitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + todays_date := now; + + // Get the current location + CurrentLocation := read last + {"Select CurrentLocation " + ||" From cv3Clientvisit " + ||" Where Guid = " || SQL(clientvisitguid) + ||" and VisitStatus = {{{SINGLE-QUOTE}}}ADM{{{SINGLE-QUOTE}}}" }; + + + +// Chart Observation Section + +IF thisdocumentCommunication.EventType is in ("ChartObservation", "DocumentClosing") and CurrentLocation <> "St. Clair Hospital Anc" then + +//Obtain data items from standard mlm +MRSA_Rules_MLM := mlm {{{SINGLE-QUOTE}}}SCH_Func_MRSA_Order{{{SINGLE-QUOTE}}}; +(ScreeningUnit, OrderedToday, OrderedWithin3, Positivescreen, SignificantDTM, StatusCode, ResultValue, MRSAHistory, NursingHomeResidency, AntiInfectivewithin7) + := call MRSA_Rules_MLM with (ClientVisitGuid, ChartGuid, ClientGuid, CurrentLocation); + +//Obtain Value of Is Patient from Nursing Home from structured note + NursingHome := ""; + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_MRSA nursing home"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then NursingHome := "yes"; + else NursingHome := "no"; + endif; + +//Set Order Screening Flag if patient meets criteria +formattedTextMRSA := " "; + + If (MRSAHistory = "Yes" or NursingHome = "Yes" or ScreeningUnit ="Yes") and StatusCode is null //OrderedWithin3 = "No" + then OrderScreen := "Yes"; + formattedTextMRSA := "Patient meets one or more Criteria for MRSA Screening and has not had a Nasal Screen ordered. Order is being placed for Nasal Screen for MRSA."; + endif; + If (MRSAHistory = "Yes" or NursingHome = "Yes" or ScreeningUnit ="Yes") and StatusCode is not null //OrderedWithin3 = "No" + then OrderScreen := "No"; + formattedTextMRSA := "Patient meets one or more Criteria for MRSA Screening, but has a Nasal Screen already ordered or resulted."; + endif; + + +//Set which child order to enter based upon if patient has received antibiotics within 7 days + If AntiInfectivewithin7 = "Yes" + then Catalog_Item_ModifierVar := "MRSA Screen Antibiotics"; + else Catalog_Item_ModifierVar := "Ordered Per Protocol"; + endif; + + +//Mark the parameter to order screen based upon Screening Parameters on the structured note + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_MRSA order"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "yes" and orderscreen = "yes" then selectedItem.IsSelected := true; endif; + if selectedItem.Value = "no" and orderscreen = "no" then selectedItem.IsSelected := true; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + +// Populate the Info box + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_MRSA Order Info"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := formattedTextMRSA; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + +endif; //If event is ChartObservation or DocumentClosing + + +// Document Closing Event + +IF thisdocumentCommunication.EventType = "DocumentClosing" and CurrentLocation <> "St. Clair Hospital Anc" then + +// Determine if an order is to be placed +/* + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_MRSA order"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no") + then orderscreen := "no"; endif; + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then orderscreen := "yes"; endif; +*/ + +// Place order for Nasal Screen for MRSA + if OrderScreen = "yes" then + SessionType := "Standard"; + SessionReason := ""; + RequestingSource := ""; + user_IDType := "Edstan Number (physician)"; + order_Creation_Reason := "From Protocol"; + + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((thisdocumentCommunication.ClientVisitGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + user_IDCode := "infectioncontrol"; + RequestingCareProvider_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindById with ( user_IDType, (user_IDCode as STRING) ); + location_guid := read last {"SELECT CurrentLocationGUID FROM CV3ClientVisit where ClientGUID = " || thisdocumentCommunication.ClientGUID}; + location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((location_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + +// Create a new Laboratory order from a Pre-Filled item + try + Catalog_Item_Name := "Nasal Screen for MRSA (Infection Control)"; + Catalog_Item_Modifier := Catalog_Item_ModifierVar ; + Catalog_Item_Version := ""; + Laboratory_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with Catalog_Item_Name; + PreFilled_DiagnosticOrder_obj := call {{{SINGLE-QUOTE}}}DiagnosticOrder{{{SINGLE-QUOTE}}}.CreateDiagnosticOrder + + with + client_visit_obj, // ClientVisit ObjectsPlus object + Laboratory_catalog_item, // OrderCatalogMasterItem ObjectsPlus object + Catalog_Item_Modifier, // string ItemNameModifier + Catalog_Item_Version, // string ItemNameModifierVersion + order_Creation_Reason, // string CreateReason + RequestingCareProvider_obj , // RequestedBy ObjectsPlus object + RequestingSource, // string RequestedBySource (must be in dictionary) + SessionType, // string SessionType + SessionReason, // string SessionReason + location_obj, // Location ReleaseLocGrpID + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; // AvailabilityOverride eAvailabilityOverride + + if ( Laboratory_catalog_item is NOT NULL ) then + void := call PreFilled_DiagnosticOrder_obj.Save; + void := call PreFilled_DiagnosticOrder_obj.Dispose; + void := call Laboratory_catalog_item.Dispose; + Laboratory_catalog_item:= null; + endif; + + endtry; + + catch Exception ex error_occurred := true; error_message := "{{+R}}New PreFilled Diagnostic order:{{-R}}\n" || ex.Message || "\n\n"; + + if ( Laboratory_catalog_item is NOT NULL ) then void:= call Laboratory_catalog_item.Dispose; Laboratory_catalog_item:= null; endif; + if ( PreFilled_DiagnosticOrder_obj is NOT NULL ) then void:= call PreFilled_DiagnosticOrder_obj.Dispose; PreFilled_DiagnosticOrder_obj:= null; endif; + + PreFilled_DiagnosticOrder_dest := null; + + endcatch; + + endif; // End of Place order for Nasal Screen for MRSA + + endif; // End of Document Closing Event + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_NEWBORN_ASSESSSMENT.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_NEWBORN_ASSESSSMENT.mlm new file mode 100644 index 0000000..c51c0d7 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_NEWBORN_ASSESSSMENT.mlm @@ -0,0 +1,324 @@ +maintenance: + + title: DOC_FUNC_NEWBORN_ASSESSSMENT;; + mlmname: DOC_FUNC_NEWBORN_ASSESSSMENT;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Peggy Karish;; + specialist: Don Warnick ;; + date: 2014-07-30;; + validation: testing;; + +library: + purpose: + ;; + explanation: This MLM manages will popultate fields on the Newborn Assessment Structured Note + + + Change history + + 07.30.2014 DW CSR# 32407 - Created + 08.03.2015 GOS CSR#32427 - added code for Vital Sign in Newborn Assessment flowsheet + 03.16.2016 DW HD#1681011 - The newborn assessment MLM is not retrieving the Transcutaneous Bilirubin Level into the Newborn Assessment TCB Screen field + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + +// DOCUMENT OPENING SECTION + + +IF thisdocumentCommunication.EventType = "DocumentOpening" + + then + + + + +// GATHER DATA + + + +(NewbornData) := read +{ + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), touchedwhen datetime, data varchar(200), latestdate datetime, field int) " +|| " SET CONCAT_NULL_YIELDS_NULL off " +|| " INSERT INTO #tmp_aaa (field,touchedwhen,data) " +|| " select " +|| " case when ocmi.name in " +|| " ( " +|| " {{{SINGLE-QUOTE}}}as deliv vag type ob{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCHCK deliv csect performed{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}INV deliv vag assist type ob{{{SINGLE-QUOTE}}} " +|| " ) " +|| " then 1 " +|| " when ocmi.name in " +|| " ( " +|| " {{{SINGLE-QUOTE}}}PRO blood type routine panel{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}PRO group b strep ob DT{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO group b strep ob{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}PRO group a status{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO group b status{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}PRO hbsag routine panel{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO rubella routine panel{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO vdrl routine panel{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}Pro pos tmt routine panel{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO vdrl post treat routine panel{{{SINGLE-QUOTE}}} " +|| " ) " +|| " then 2 " +|| " when ocmi.name in " +|| " ( " +|| " {{{SINGLE-QUOTE}}}as deliv baby a time ob DT{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}as deliv baby b time ob DT{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}AS deliv baby a sex ob{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AS deliv baby b sex ob{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}AS deliv baby a wt gm ob NU{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AS deliv baby b wt gm ob NU{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}AS deliv baby a wt lb ob CAL{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AS deliv baby b wt lb ob CAL{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}AS deliv baby a wt oz ob CAL{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AS deliv baby b wt oz ob CAL{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}AS deliv baby a length inch ob CAL{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AS deliv baby b length inch ob CAL{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}AS deliv baby a length cm ob CAL{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AS deliv baby b length cm ob CAL{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}AS deliv baby a head circum ob NU{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AS deliv baby b head circum ob NU{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}AS deliv baby a gestational age ob NU{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AS deliv baby b gestational age ob NU{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}AS SC deliv apgar a1 score ob CAL{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AS SC deliv apgar b1 score ob CAL{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}AS SC deliv apgar a5 score ob CAL{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AS SC deliv apgar b5 score ob CAL{{{SINGLE-QUOTE}}} " +|| " ) " +|| " then 3 " +|| " when ocmi.name in " +|| " ( " +|| " {{{SINGLE-QUOTE}}}SCH_FBC_Init_Pulse Ox_Rt Hand{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_FBC_Init_Pulse Ox_Foot{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_FBC_Second_Pulse Ox_Rt Hand{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}SCH_FBC_Second_Pulse Ox_Foot{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_FBC_CHDS_Init_Pass Fail{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_FBC_CHDS_Second_Pass Fail{{{SINGLE-QUOTE}}} " +|| " ) " +|| " then 4 " +|| " when ocmi.name in " +|| " ( " +|| " {{{SINGLE-QUOTE}}}SCH_FBC_Bilimeter_gestational age{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_FBC_Bilimeter_Hourly Age{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_FBC_Bilimeter_Screen Date Time{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_FBC_Bilimeter_TCB Level{{{SINGLE-QUOTE}}}" +|| " ) " +|| " then 5 " +|| " when ocmi.name in " +|| " ( " +|| " {{{SINGLE-QUOTE}}}PRO screen hear result infant{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCHCK rescreen hear result infant{{{SINGLE-QUOTE}}}" +|| " ) " +|| " then 6 " +|| " when ocmi.name in " +|| " ( " +|| " {{{SINGLE-QUOTE}}}PRO feeding plan infant ob{{{SINGLE-QUOTE}}} " +|| " ) " +|| " then 7 " +|| " end , " +|| " cd.entered , CHAR(10) + CHAR(13) + ocmi.LeftJustifiedLabel + {{{SINGLE-QUOTE}}} : {{{SINGLE-QUOTE}}} + o.ValueText + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + fsl.value " +|| " from CV3ClientDocument cd with (nolock) " +|| " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = " || ClientGuid || " and cdd.active = 1) " +|| " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " +|| " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " +|| " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " +|| " left join SCMObsFSListValues fsl(nolock) ON (fsl.ParentGUID = od.ObservationDocumentGUID AND fsl.ClientGUID = " || ClientGuid || " ) " +|| " where cd.clientguid = " || ClientGuid || " and cd.ChartGUID = " || ChartGuid || " and cd.ClientVisitGUID= " || VisitGuid || " " +|| " and cd.iscanceled = 0 " +|| " and cd.documentname in ({{{SINGLE-QUOTE}}}Newborn Patient Profile{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}B1. Newborn Vital Signs{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Newborn Hearing Screen{{{SINGLE-QUOTE}}}) " +|| " and (o.ValueText + fsl.value) is not null " +|| " and ocmi.name in " +|| " ( " +|| " {{{SINGLE-QUOTE}}}as deliv vag type ob{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCHCK deliv csect performed{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}INV deliv vag assist type ob{{{SINGLE-QUOTE}}} " +|| " , " +|| " {{{SINGLE-QUOTE}}}PRO blood type routine panel{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}PRO group b strep ob DT{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO group b strep ob{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO group a status{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO group b status{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}PRO hbsag routine panel{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO rubella routine panel{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO vdrl routine panel{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}Pro pos tmt routine panel{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO vdrl post treat routine panel{{{SINGLE-QUOTE}}} " +|| " , " +|| " {{{SINGLE-QUOTE}}}as deliv baby a time ob DT{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}as deliv baby b time ob DT{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}AS deliv baby a sex ob{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AS deliv baby b sex ob{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}AS deliv baby a wt gm ob NU{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AS deliv baby b wt gm ob NU{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}AS deliv baby a wt lb ob CAL{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AS deliv baby b wt lb ob CAL{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}AS deliv baby a wt oz ob CAL{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AS deliv baby b wt oz ob CAL{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}AS deliv baby a length inch ob CAL{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AS deliv baby b length inch ob CAL{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}AS deliv baby a length cm ob CAL{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AS deliv baby b length cm ob CAL{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}AS deliv baby a head circum ob NU{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AS deliv baby b head circum ob NU{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}AS deliv baby a gestational age ob NU{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AS deliv baby b gestational age ob NU{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}AS SC deliv apgar a1 score ob CAL{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AS SC deliv apgar b1 score ob CAL{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}AS SC deliv apgar a5 score ob CAL{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}AS SC deliv apgar b5 score ob CAL{{{SINGLE-QUOTE}}} " +|| " , " +|| " {{{SINGLE-QUOTE}}}SCH_FBC_Init_Pulse Ox_Rt Hand{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_FBC_Init_Pulse Ox_Foot{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_FBC_Second_Pulse Ox_Rt Hand{{{SINGLE-QUOTE}}}, " +|| " {{{SINGLE-QUOTE}}}SCH_FBC_Second_Pulse Ox_Foot{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_FBC_CHDS_Init_Pass Fail{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_FBC_CHDS_Second_Pass Fail{{{SINGLE-QUOTE}}} " +|| " , " +|| " {{{SINGLE-QUOTE}}}SCH_FBC_Bilimeter_gestational age{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_FBC_Bilimeter_Hourly Age{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_FBC_Bilimeter_Screen Date Time{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_FBC_Bilimeter_TCB Level{{{SINGLE-QUOTE}}} " +|| " , " +|| " {{{SINGLE-QUOTE}}}PRO screen hear result infant{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCHCK rescreen hear result infant{{{SINGLE-QUOTE}}} " +|| " , " +|| " {{{SINGLE-QUOTE}}}PRO feeding plan infant ob{{{SINGLE-QUOTE}}} " +|| " ) " +|| " order by cd.touchedwhen desc " +|| " select cast (field as varchar) + {{{SINGLE-QUOTE}}}...{{{SINGLE-QUOTE}}} + data from #tmp_aaa order by field " +|| " drop table #tmp_aaa " +}; + + +if exists NewbornData + + then + + NewbornDataText := " " || NewbornData; + + str_parse := mlm {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; + + calc_map_list := call str_parse with NewbornDataText,","; + + + TextFormatted1 := "."; + TextFormatted2 := "."; + TextFormatted3 := "."; + TextFormatted4 := "."; + TextFormatted5 := "."; + TextFormatted6 := "."; + TextFormatted7 := "."; + + for i in 1 seqto count calc_map_list do + + textbox := Substring 1 characters starting at 2 from calc_map_list[i] ; + if textbox = "1" then + TextFormatted1 := TextFormatted1 || (Substring 100 characters starting at 6 from calc_map_list[i]) ; + elseif textbox = "2" then + TextFormatted2 := TextFormatted2 || (Substring 100 characters starting at 6 from calc_map_list[i]) ; + elseif textbox = "3" then + TextFormatted3 := TextFormatted3 || (Substring 100 characters starting at 6 from calc_map_list[i]) ; + elseif textbox = "4" then + TextFormatted4 := TextFormatted4 || (Substring 100 characters starting at 6 from calc_map_list[i]) ; + elseif textbox = "5" then + TextFormatted5 := TextFormatted5 || (Substring 100 characters starting at 6 from calc_map_list[i]) ; + elseif textbox = "6" then + TextFormatted6 := TextFormatted6 || (Substring 100 characters starting at 6 from calc_map_list[i]) ; + elseif textbox = "7" then + TextFormatted7 := TextFormatted7 || (Substring 100 characters starting at 6 from calc_map_list[i]) ; + endif; + enddo; + + + +// POPULATE THE FIELDS WITH THE DATA + + + + // Populate the Delivery Information field + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_NEWBORN_MLM Mom Info"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := TextFormatted1; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + // Populate the Prenatal Lab Information field + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_NEWBORN_MLM Prenatal Lab Info"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := TextFormatted2; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + // Populate the Birth Information field + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_NEWBORN_MLM Baby Info"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := TextFormatted3; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + // Populate the Newborn Screening Information field + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_NEWBORN_MLM Baby Screen Info"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := TextFormatted4; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + // Populate the Newborn TCB Screening Information field + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_NEWBORN_MLM Baby Screen TcB"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := TextFormatted5; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + // Populate the Newborn Hearing Screening Information field + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_NEWBORN_MLM Baby Screen Hearing"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := TextFormatted6; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + // Populate the Newborn Feeding Plan Information field + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_NEWBORN_MLM Baby Feeding"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := TextFormatted7; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + endif; // Exists NewbornData +//Added below section show data in Vital sign I & O (Vikas) CSR : 33427 - Vital Sign for Newborn Assessment + if thisDocumentCommunication.DocumentName = "Newborn Assessment and Discharge Summary" then + DocVitalsHL2 := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_NEWBORN_VS_24hrs{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocVitalsHL2 WITH thisDocumentCommunication; + endif; + +endif; // EventType = "DocumentOpening" + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_NEWBORN_LAST_24HRS.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_NEWBORN_LAST_24HRS.mlm new file mode 100644 index 0000000..73b23d5 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_NEWBORN_LAST_24HRS.mlm @@ -0,0 +1,488 @@ +maintenance: + + title: Vital Signs - Highs and Lows;; + mlmname: DOC_FUNC_Newborn_Last_24hrs;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Vikaskumar Yadav;; + specialist: ;; + date: 2015-06-16;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + +Dev 06/16/2015 DW Created to show last 24 hours Vital Sign observations from B1. Newborn Vital Signs. + In Devlopment + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + +// OBSERVATION CHANGE + + + if thisDocumentCommunication.EventType = "ChartObservation" + then + + (obsNamesList, lastValuesList, highValuesList, lowValuesList) := read + { + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), name varchar(200), value varchar(500), timstmp datetime, sortseq int, timstmp2 varchar(30) ) " + || " INSERT INTO #tmp_aaa (name,value,timstmp, sortseq) " + || " select ocmi.Name, o.ValueText, od.RecordedDtm, " + || " CASE WHEN Name = {{{SINGLE-QUOTE}}}farenheit{{{SINGLE-QUOTE}}} THEN 01 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Heart Rate{{{SINGLE-QUOTE}}} THEN 02 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Resp Rate{{{SINGLE-QUOTE}}} THEN 03 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Noninvasive Systolic BP{{{SINGLE-QUOTE}}} THEN 04 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Noninvasive Diastolic BP{{{SINGLE-QUOTE}}} THEN 05 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Noninvasive Mean BP{{{SINGLE-QUOTE}}} THEN 06 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Noninvasive BP Source 1{{{SINGLE-QUOTE}}} THEN 07 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_vs_pulse ox saturation{{{SINGLE-QUOTE}}} THEN 08 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_vs_pulse ox source{{{SINGLE-QUOTE}}} THEN 09 " + || " ELSE 99 " + || " END AS SortSeq " + || " " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " AND ocmi.Name in ({{{SINGLE-QUOTE}}}farenheit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Heart Rate{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Resp Rate{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Noninvasive Diastolic BP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Noninvasive Systolic BP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Noninvasive Mean BP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Noninvasive BP Source 1{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}SCH_vs_pulse ox saturation{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCH_vs_pulse ox source{{{SINGLE-QUOTE}}} ) " + || " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " " + || " and cd.iscanceled = 0 " + || " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}B1. Newborn Vital Signs{{{SINGLE-QUOTE}}}) " + || " order by sortseq , cd.touchedwhen " + || " " + // || " update t1 set timstmp2 = t2.timstmp from #tmp_aaa t1 " + // || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq = t2.sortseq " + || " delete from #tmp_aaa where Value is null " + || " " + || " select name, value, timstmp, sortseq from #tmp_aaa order by timstmp desc, sortseq " + || " drop table #tmp_aaa " + }; +// update #tmp_aaa Set #tmp_aaa.timstmp = Dateadd(hour, -4, Getdate()) + header1 :="\n\n\b Vital Signs - Basic in Past 24 Hours -All Charted \b0\n\n"; + formattedText1 := " "; + thisdatefield := " "; + yesterday := now-24 hours; + + + indexList := 1 seqto count (obsNamesList); + + for i in indexList do + + obsName := (obsNamesList[i]); + + // Reformat the Time Stamp + + thisdatefield_unformatted := (highValuesList[i]); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the first group and charted in the past 24 hours + + if obsName in ("farenheit" , "Heart Rate" , "Resp Rate" , "Noninvasive Diastolic BP" , "Noninvasive Systolic BP" , + "Noninvasive Mean BP", "Noninvasive BP Source 1", "SCH_vs_pulse ox saturation", "SCH_vs_pulse ox source") + and + thisdatefield_unformatted > yesterday + + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := (highValuesList[i]); + formattedText1 := thisdatefield_formatted; + endif; + + + if thisdatefield <> (highValuesList[i]) // new timestamp + then + formattedText1 := formattedText1 || "\n" || thisdatefield_formatted; + thisdatefield := (highValuesList[i]); + else + formattedText1 := formattedText1 || " " ; + endif; + + + if obsName = "Heart Rate" then formattedText1 := formattedText1 || "\b HR:\b0 "; + elseif obsName = "Farenheit" then formattedText1 := formattedText1 || "\b T:\b0 "; + elseif obsName = "Resp Rate" then formattedText1 := formattedText1 || "\b R:\b0 "; + elseif obsName = "Noninvasive Systolic BP" then formattedText1 := formattedText1 || "\b BP:\b0 "; + elseif obsName = "Noninvasive Diastolic BP" then formattedText1 := formattedText1 || "/"; + elseif obsName = "Noninvasive Mean BP" then formattedText1 := formattedText1 || "\b Mean BP:\b0 "; + elseif obsName = "Noninvasive BP Source 1" then formattedText1 := formattedText1 || "/"; + elseif obsName = "SCH_vs_pulse ox saturation" then formattedText1 := formattedText1 || "\b Pulse Ox:\b0 "; + //elseif obsName = "SCH_vs_pulse ox source" then formattedText1 := formattedText1 || "/" ; //b O2 L/min:\b0 "; + endif; + + + formattedText1 := formattedText1 || " "; + formattedText1 := formattedText1 || (lastValuesList[i]); + + endif; // Obsname amongst the Vital Signs observations + + +// for Urine +// SCH_io_Foley Catheter, io_output_condom_catheter, SCH_io_Straight Catheter + + enddo; + + + // Gather the existing contents of the textbox + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_FT VS, I & O"); + obs := FIRST OF (thisObservations WHERE thisObservations.parameterGUID = theParameter.parameterGUID); + priorcontents := obs.ValueObj.Value; + + formattedTextAll:= priorcontents || header1 || formattedText1; + + + + endif; + + +// DOCUMENT OPEN +/* + + if thisdocumentCommunication.EventType = "DocumentOpening" + then + + // Query the database for the vitals info + + + (obsNamesList, lastValuesList, highValuesList, lowValuesList) := read + { + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), name varchar(200), value varchar(500), timstmp datetime, sortseq int, timstmp2 varchar(30) ) " + || " INSERT INTO #tmp_aaa (name,value,timstmp, sortseq) " + || " select ocmi.Name, o.ValueText, od.RecordedDtm, " + || " CASE WHEN Name = {{{SINGLE-QUOTE}}}Farenheit{{{SINGLE-QUOTE}}} THEN 01 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Heart Rate{{{SINGLE-QUOTE}}} THEN 02 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Resp Rate{{{SINGLE-QUOTE}}} THEN 03 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Noninvasive Systolic BP{{{SINGLE-QUOTE}}} THEN 04 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Noninvasive Diastolic BP{{{SINGLE-QUOTE}}} THEN 05 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Arterial Systolic BP - Radial{{{SINGLE-QUOTE}}} THEN 06 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Arterial Diastolic BP - Radial{{{SINGLE-QUOTE}}} THEN 07 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Arterial Systolic BP - Second Line{{{SINGLE-QUOTE}}} THEN 08 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Arterial Diastolic - Second Line{{{SINGLE-QUOTE}}} THEN 09 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_vs_pulse ox saturation{{{SINGLE-QUOTE}}} THEN 10 " + || " WHEN Name = {{{SINGLE-QUOTE}}}L/min{{{SINGLE-QUOTE}}} THEN 11 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Height in cm{{{SINGLE-QUOTE}}} THEN 20 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Height in ft{{{SINGLE-QUOTE}}} THEN 21 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Height remainder in inches{{{SINGLE-QUOTE}}} THEN 22 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby a wt gm ob NU{{{SINGLE-QUOTE}}} THEN 23 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby b wt gm ob NU{{{SINGLE-QUOTE}}} THEN 24 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby a wt lb ob NU{{{SINGLE-QUOTE}}} THEN 25 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby a wt oz ob NU{{{SINGLE-QUOTE}}} THEN 26 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby b wt lb ob NU{{{SINGLE-QUOTE}}} THEN 27 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby b wt oz ob NU{{{SINGLE-QUOTE}}} THEN 28 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - grams{{{SINGLE-QUOTE}}} THEN 29 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - lbs{{{SINGLE-QUOTE}}} THEN 40 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - oz{{{SINGLE-QUOTE}}} THEN 41 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Weight - lbs{{{SINGLE-QUOTE}}} THEN 42 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Weight - kg{{{SINGLE-QUOTE}}} THEN 43 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_vs_Occipital-Frontal Head{{{SINGLE-QUOTE}}} THEN 44 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Stool{{{SINGLE-QUOTE}}}THEN 45 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Urine{{{SINGLE-QUOTE}}}THEN 46 " + || " ELSE 99 " + || " END AS SortSeq " + || " " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " AND ocmi.Name in ( " + || " {{{SINGLE-QUOTE}}}farenheit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Heart Rate{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Resp Rate{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_vs_pulse ox saturation{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}L/min{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}Noninvasive Diastolic BP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Noninvasive Systolic BP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Arterial Systolic BP - Radial{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Arterial Diastolic BP - Radial{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Arterial Systolic BP - Second Line{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Arterial Diastolic - Second Line{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}AS deliv baby a wt gm ob NU{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}AS deliv baby b wt gm ob NU{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}AS deliv baby a wt lb ob NU{{{SINGLE-QUOTE}}} , " + || " {{{SINGLE-QUOTE}}}AS deliv baby b wt lb ob NU{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}AS deliv baby a wt oz ob NU{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}AS deliv baby b wt oz ob NU{{{SINGLE-QUOTE}}} , " + || " {{{SINGLE-QUOTE}}}SCH_Newborn Weight - grams{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_Newborn Weight - lbs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_Newborn Weight - oz{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}Weight - lbs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Weight - kg{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}Height in ft{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Height remainder in inches{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Height in cm{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCH_vs_Occipital-Frontal Head{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}Current Weight{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Stool{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Urine{{{SINGLE-QUOTE}}} " + || " ) " + || " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " " + || " and cd.iscanceled = 0 " + || " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}Newborn Patient Profile{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}B1. Newborn Vital Signs{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}B2. Newborn Assessment/Intervention{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}1.Vital Signs - Basic{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}1.Vital Signs - Critical Care{{{SINGLE-QUOTE}}}) " + || " order by sortseq , cd.touchedwhen " + || " " + || " update t1 set timstmp2 = t2.timstmp from #tmp_aaa t1 " + || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq = t2.sortseq " + || " update t2 set timstmp2 = {{{SINGLE-QUOTE}}}first weight{{{SINGLE-QUOTE}}}, name = {{{SINGLE-QUOTE}}}First Adult Weight - kg{{{SINGLE-QUOTE}}} from #tmp_aaa t1 " + || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq <> t2.sortseq and t2.name = {{{SINGLE-QUOTE}}}Weight - kg{{{SINGLE-QUOTE}}} " + || " delete from #tmp_aaa where timstmp2 is not null and timstmp2 <> {{{SINGLE-QUOTE}}}first weight{{{SINGLE-QUOTE}}} " + || " " + || " select name, value, timstmp, sortseq from #tmp_aaa order by timstmp desc, sortseq " + || " drop table #tmp_aaa " + }; + + + + // Process the First Group Data Elements (past 24 hours) + + + header1 :="\b Vital Signs in Past 24 Hours - Last Charted \b0\n\n"; + formattedText1:= " "; + thisdatefield := " "; + yesterday:= now-24 hours; + + indexList := 1 seqto count (obsNamesList); + + for i in indexList do + + obsName := last (first i from obsNamesList); + + // Reformat the Time Stamp + + thisdatefield_unformatted := last (first i from highValuesList); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the first group and charted in the past 24 hours + + if obsName in ("farenheit","Heart Rate","Resp Rate","SCH_vs_pulse ox saturation","L/min", + "Noninvasive Diastolic BP","Noninvasive Systolic BP","Arterial Systolic BP - Radial","Arterial Diastolic BP - Radial", + "Arterial Systolic BP - Second Line","Arterial Diastolic - Second Line" ) + and + thisdatefield_unformatted > yesterday + + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := last (first i from highValuesList); + formattedText1 := thisdatefield_formatted; + endif; + + + if thisdatefield <> last (first i from highValuesList) // new timestamp + then + formattedText1 := formattedText1 || "\n" || thisdatefield_formatted; + thisdatefield := last (first i from highValuesList); + else + formattedText1 := formattedText1 || " " ; + endif; + + + if obsName = "Heart Rate" then formattedText1 := formattedText1 || "\b HR:\b0 "; + elseif obsName = "Farenheit" then formattedText1 := formattedText1 || "\b T:\b0 "; + elseif obsName = "Noninvasive Systolic BP" then formattedText1 := formattedText1 || "\b BP:\b0 "; + elseif obsName = "Noninvasive Diastolic BP" then formattedText1 := formattedText1 || "/"; + elseif obsName = "Arterial Systolic BP - Radial" then formattedText1 := formattedText1 || "\b ART BP:\b0 "; + elseif obsName = "Arterial Diastolic BP - Radial" then formattedText1 := formattedText1 || "/"; + elseif obsName = "Arterial Systolic BP - Second Line" then formattedText1 := formattedText1 || "\b ART BP Second:\b0 "; + elseif obsName = "Arterial Diastolic - Second Line" then formattedText1 := formattedText1 || "/"; + elseif obsName = "Resp Rate" then formattedText1 := formattedText1 || "\b R:\b0 "; + elseif obsName = "SCH_vs_pulse ox saturation" then formattedText1 := formattedText1 || "\b Pulse Ox:\b0 "; + elseif obsName = "L/min" then formattedText1 := formattedText1 || "\b O2 L/min:\b0 "; + endif; + + formattedText1 := formattedText1 || " "; + formattedText1 := formattedText1 || last (first i from lastValuesList); + + endif; // Obsname amongst the Vital Signs observations + + enddo; + + + formattedText1 := header1 || formattedText1; + + + + + // Process the Second Group Data Elements (Start of Chart) + + + + header2 :="\n\n \b Additional Information - Last Charted \b0 \n\n"; + formattedText2:= " "; + thisdatefield := " "; + + + indexList := 1 seqto count (obsNamesList); + for i in indexList do + + obsName := last (first i from obsNamesList); + + + // Reformat the Time Stamp + + + thisdatefield_unformatted := last (first i from highValuesList); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the second group + + + if obsName in ( + "AS deliv baby a wt gm ob NU" , "AS deliv baby b wt gm ob NU" , "AS deliv baby a wt lb ob NU" , "AS deliv baby b wt lb ob NU" , "AS deliv baby a wt oz ob NU" , "AS deliv baby b wt oz ob NU" , + "SCH_Newborn Weight - grams","SCH_Newborn Weight - lbs","SCH_Newborn Weight - oz", "Weight - lbs","Weight - kg","First Adult Weight - kg","Height in ft" , "Height remainder in inches" , "Height in cm", + "SCH_vs_Occipital-Frontal Head", "Current Weight","SCH_io_newborn_diaper count - Stool" , "SCH_io_newborn_diaper count - Urine" + ) + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := last (first i from highValuesList); + formattedText2 := thisdatefield_formatted; + endif; + + + if thisdatefield <> last (first i from highValuesList) // new timestamp + then + formattedText2 := formattedText2 || "\n" || thisdatefield_formatted; + thisdatefield := last (first i from highValuesList); + else + formattedText2 := formattedText2 || " " ; + endif; + + + if obsName = "SCH_io_newborn_diaper count - Stool" then formattedText2 := formattedText2 || "\b Stool Diaper:\b0 "; + elseif obsName = "SCH_io_newborn_diaper count - Urine" then formattedText2 := formattedText2 || "\b Urine Diaper:\b0 "; + elseif obsName = "SCH_vs_Occipital-Frontal Head" then formattedText2 := formattedText2 || "\b H.C./cm:\b0 "; + elseif obsName = "Height in cm" then formattedText2 := formattedText2 || "\b Ht/cm:\b0 "; + elseif obsName = "Height in ft" then formattedText2 := formattedText2 || "\b Ht/ft:\b0 "; + elseif obsName = "Height remainder in inches" then formattedText2 := formattedText2 || "-"; + elseif obsName = "SCH_Newborn Weight - grams" then formattedText2 := formattedText2 || "\b Wt/gm:\b0 "; curwt:= last (first i from lastValuesList); + elseif obsName = "SCH_Newborn Weight - lbs" then formattedText2 := formattedText2 || "\b Wt/lb:\b0 "; + elseif obsName = "SCH_Newborn Weight - oz" then formattedText2 := formattedText2 || "-"; + elseif obsName = "AS deliv baby a wt gm ob NU" then formattedText2 := formattedText2 || "\b Deliv Wt/gm:\b0 "; delwt:= last (first i from lastValuesList); + elseif obsName = "AS deliv baby b wt gm ob NU" then formattedText2 := formattedText2 || "\b Deliv Wt/gm:\b0 "; delwt:= last (first i from lastValuesList); + elseif obsName = "AS deliv baby a wt lb ob NU" then formattedText2 := formattedText2 || "\b Deliv Wt/lb:\b0 "; + elseif obsName = "AS deliv baby a wt oz ob NU" then formattedText2 := formattedText2 || "-"; + elseif obsName = "AS deliv baby b wt lb ob NU" then formattedText2 := formattedText2 || "\b Deliv Wt/lb:\b0 "; + elseif obsName = "AS deliv baby b wt oz ob NU" then formattedText2 := formattedText2 || "-"; + elseif obsName = "Weight - lbs" then formattedText2 := formattedText2 || "\b Wt/lb:\b0 "; + elseif obsName = "Weight - kg" then formattedText2 := formattedText2 || "\b Wt/kg:\b0 "; lastwt := last (first i from lastValuesList); + elseif obsName = "First Adult Weight - kg" then formattedText2 := formattedText2 || "\b First Wt/kg:\b0 "; firstwt:= last (first i from lastValuesList); + endif; + + formattedText2 := formattedText2 || " "; + formattedText2 := formattedText2 || last (first i from lastValuesList); + + endif; // Obsname amongst the Additional Information observations + + enddo; + + + + // Calculate the weight change + + + + If exist delwt // Baby since birth weight + + then + wtlabel := "Wt change since birth: \b0 "; + wtscale := " gm "; + wtchange := ((curwt as number) - (delwt as number)) formatted with " %.2f %"; + wtchangepcnt := (((curwt as number) - (delwt as number))/(delwt as number) * 100) formatted with " %.2f %%"; + + else // Adult since first weighing + + wtlabel := "Wt change since first weighing: \b0 "; + wtscale := " kg "; + wtchange := ((lastwt as number) - (firstwt as number)) formatted with " %.2f %"; + wtchangepcnt := (((lastwt as number) - (firstwt as number)) /(firstwt as number) * 100) formatted with " %.2f %%"; + + endif; + + + If wtchange is not null + then + wtchange := " \n\n\b " || wtlabel || wtchange || wtscale || wtchangepcnt ; + else + wtchange := " "; + endif; + + formattedText2 := header2 || formattedText2 || wtchange; + + + formattedTextAll:= formattedText1 || formattedText2; + + + + endif; // Document Open + +*/ + + + // Write to the Structured Note Text Box + + + + If formattedTextAll is not null + + then + + vitalSignsHL := first of (thisParameters where thisParameters.Name = "SCH_MDPN_FT VS, I & O"); + + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := vitalSignsHL.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := formattedTextAll; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + endif; + + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_NEWBORN_LAST_24HRS_OSTOMY.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_NEWBORN_LAST_24HRS_OSTOMY.mlm new file mode 100644 index 0000000..9c531fd --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_NEWBORN_LAST_24HRS_OSTOMY.mlm @@ -0,0 +1,315 @@ +maintenance: + + title: DOC_FUNC_Last_24hrs_Ostomy;; + mlmname: DOC_FUNC_Newborn_Last_24hrs_Ostomy;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Shawn Head;; + specialist: ;; + date: 2016-06-16;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 06.15.2016 STH CSR# 34735 Created to show last 24 hours Ostomy observations from B2. Newborn Intake and Output. {Go-Live 6/21/2016} + + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + + +// OBSERVATION CHANGE + + + + + if thisDocumentCommunication.EventType = "ChartObservation" + then + + ( lastValuesList, highValuesList ) := read + { + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), value varchar(500), timstmp datetime ) " + || " INSERT INTO #tmp_aaa (value,timstmp) " + || " select Sum(Convert(Integer, obsx.OutValue)) + sum(convert(integer,o.ValueText)) as Value , od.RecordedDtm " + || " " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " left Join CV3ObservationXInfo AS obsx " + || " ON (obsx.ObservationXInfoGUID = o.GUID AND obsx.ArcType = o.ArcType And obsx.BagVolumeUnit is Not Null ) " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " AND ocmi.Name in ({{{SINGLE-QUOTE}}}io_output_colostomy{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}io_output_gastrostomy{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}io_output_ileostomy{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}io_output_jejunostomy{{{SINGLE-QUOTE}}} ) " + || " and (obsx.OutValue is not null or o.ValueText is not null) " + || " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " " + || " and cd.iscanceled = 0 " + || " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}B2. Newborn Intake and Output{{{SINGLE-QUOTE}}})" + || " Group By od.RecordedDtm " + || " Order By od.RecordedDtm Desc " + || " " + // || " update t1 set timstmp2 = t2.timstmp from #tmp_aaa t1 " + // || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq = t2.sortseq " + // || " delete from #tmp_aaa where timstmp2 is not null " + || " " + || " select value, timstmp from #tmp_aaa " + || " drop table #tmp_aaa " + }; + + +// update #tmp_aaa Set #tmp_aaa.timstmp = Dateadd(hour, -4, Getdate()) + header1 :="\n\n\b Ostomy Output - Observations in Past 24 Hours -All Charted \b0\n\n"; + formattedText1 := " "; + thisdatefield := " "; + yesterday := now-24 hours; + + + indexList := 1 seqto count (highValuesList); + + for i in indexList do + + + + // Reformat the Time Stamp + + thisdatefield_unformatted := (highValuesList[i]); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the first group and charted in the past 24 hours + + if thisdatefield_unformatted > yesterday + + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := (highValuesList[i]); + formattedText1 := thisdatefield_formatted; + endif; + + + if thisdatefield <> (highValuesList[i]) // new timestamp + then + formattedText1 := formattedText1 || "\n" || thisdatefield_formatted; + thisdatefield := (highValuesList[i]); + else + formattedText1 := formattedText1 || " " ; + endif; + + + /*if obsName = "SCH_io_Straight Catheter" then formattedText1 := formattedText1 || "\b Straight Cath:\b0 "; + elseif obsName = "SCH_io_Foley Catheter" then formattedText1 := formattedText1 || "\b Foley Cath:\b0 "; + elseif obsName = "io_output_condom_catheter" then formattedText1 := formattedText1 || "\b Condom Cath:\b0 "; + elseif obsName = "io_output_voided" then formattedText1 := formattedText1 || "\b Voided:\b0 "; + elseif obsName = "io_output_nephrostomy" then formattedText1 := formattedText1 || "\b Nephro:\b0 "; + /*elseif obsName = "Noninvasive Mean BP" then formattedText1 := formattedText1 || "\b Mean BP:\b0 "; + elseif obsName = "Noninvasive BP Source 1" then formattedText1 := formattedText1 || "/"; + elseif obsName = "SCH_vs_pulse ox saturation" then formattedText1 := formattedText1 || "\b Pulse Ox:\b0 "; + elseif obsName = "SCH_vs_pulse ox source" then formattedText1 := formattedText1 || "/" ; //b O2 L/min:\b0 "; + endif; */ + + + formattedText1 := formattedText1 || " "; + formattedText1 := formattedText1 || (lastValuesList[i]) || " ml"; + + endif; // Obsname amongst the Vital Signs observations + + enddo; + + + // Gather the existing contents of the textbox + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_FT VS, I & O"); + obs := FIRST OF (thisObservations WHERE thisObservations.parameterGUID = theParameter.parameterGUID); + priorcontents := obs.ValueObj.Value; + + formattedTextAll:= priorcontents || header1 || formattedText1; + + + + endif; + + + /* if thisDocumentCommunication.EventType = "ChartObservation" + then + + (obsNamesList, lastValuesList, highValuesList, lowValuesList) := read + { + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), name varchar(200), value varchar(500), timstmp datetime, sortseq int, timstmp2 varchar(30) ) " + || " INSERT INTO #tmp_aaa (name,value,timstmp, sortseq) " + || " select ocmi.Name, Convert(Integer, obsx.OutValue) as Value, od.RecordedDtm, " + || " CASE WHEN Name = {{{SINGLE-QUOTE}}}SCH_io_Straight Catheter{{{SINGLE-QUOTE}}} THEN 01 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_io_Foley Catheter{{{SINGLE-QUOTE}}} THEN 02 " + || " WHEN Name = {{{SINGLE-QUOTE}}}io_output_condom_catheter{{{SINGLE-QUOTE}}} THEN 03 " + || " WHEN Name = {{{SINGLE-QUOTE}}}io_output_voided{{{SINGLE-QUOTE}}} THEN 04 " + || " WHEN Name = {{{SINGLE-QUOTE}}}io_output_nephrostomy{{{SINGLE-QUOTE}}} THEN 05 " + || " ELSE 99 " + || " END AS SortSeq " + || " " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " Inner Join CV3ObservationXInfo AS obsx " + || " ON (obsx.ObservationXInfoGUID = o.GUID AND obsx.ArcType = o.ArcType And obsx.BagVolumeUnit is Not Null ) " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " AND ocmi.Name in ({{{SINGLE-QUOTE}}}SCH_io_Foley Catheter{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}io_output_condom_catheter{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCH_io_Straight Catheter{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}io_output_voided{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}io_output_nephrostomy{{{SINGLE-QUOTE}}} ) " + || " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " " + || " and cd.iscanceled = 0 " + || " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}2. Intake and Output{{{SINGLE-QUOTE}}}) " + || " order by sortseq , cd.touchedwhen " + || " " + // || " update t1 set timstmp2 = t2.timstmp from #tmp_aaa t1 " + // || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq = t2.sortseq " + // || " delete from #tmp_aaa where timstmp2 is not null " + || " " + || " select name, value, timstmp, sortseq from #tmp_aaa order by timstmp desc, sortseq " + || " drop table #tmp_aaa " + }; +// update #tmp_aaa Set #tmp_aaa.timstmp = Dateadd(hour, -4, Getdate()) + header1 :="\n\n\b Urine Output - Observations in Past 24 Hours -All Charted \b0\n\n"; + formattedText1 := " "; + thisdatefield := " "; + yesterday := now-24 hours; + + + indexList := 1 seqto count (obsNamesList); + + for i in indexList do + + obsName := (obsNamesList[i]); + + // Reformat the Time Stamp + + thisdatefield_unformatted := (highValuesList[i]); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the first group and charted in the past 24 hours + + if obsName in ("SCH_io_Foley Catheter","io_output_condom_catheter", "SCH_io_Straight Catheter", "io_output_voided" , "io_output_nephrostomy") + and + thisdatefield_unformatted > yesterday + + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := (highValuesList[i]); + formattedText1 := thisdatefield_formatted; + endif; + + + if thisdatefield <> (highValuesList[i]) // new timestamp + then + formattedText1 := formattedText1 || "\n" || thisdatefield_formatted; + thisdatefield := (highValuesList[i]); + else + formattedText1 := formattedText1 || " " ; + endif; + + + if obsName = "SCH_io_Straight Catheter" then formattedText1 := formattedText1 || "\b Straight Cath:\b0 "; + elseif obsName = "SCH_io_Foley Catheter" then formattedText1 := formattedText1 || "\b Foley Cath:\b0 "; + elseif obsName = "io_output_condom_catheter" then formattedText1 := formattedText1 || "\b Condom Cath:\b0 "; + elseif obsName = "io_output_voided" then formattedText1 := formattedText1 || "\b Voided:\b0 "; + elseif obsName = "io_output_nephrostomy" then formattedText1 := formattedText1 || "\b Nephro:\b0 "; + + endif; + + + formattedText1 := formattedText1 || " "; + formattedText1 := formattedText1 || (lastValuesList[i]); + + endif; // Obsname amongst the Vital Signs observations + + enddo; + + + // Gather the existing contents of the textbox + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_FT VS, I & O"); + obs := FIRST OF (thisObservations WHERE thisObservations.parameterGUID = theParameter.parameterGUID); + priorcontents := obs.ValueObj.Value; + + formattedTextAll:= priorcontents || header1 || formattedText1; + + + + endif; */ + + // Write to the Structured Note Text Box + + + + If formattedTextAll is not null + + then + + vitalSignsHL := first of (thisParameters where thisParameters.Name = "SCH_MDPN_FT VS, I & O"); + + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := vitalSignsHL.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := formattedTextAll; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + endif; + + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_NEWBORN_LAST_24HRS_URINE.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_NEWBORN_LAST_24HRS_URINE.mlm new file mode 100644 index 0000000..3c57a13 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_NEWBORN_LAST_24HRS_URINE.mlm @@ -0,0 +1,268 @@ +maintenance: + + title: DOC_FUNC_Last_24hrs_Urine;; + mlmname: DOC_FUNC_Newborn_Last_24hrs_Urine;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Vikaskumar Yadav;; + specialist: ;; + date: 2016-06-16;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 16.06.2015 - VY CSR# 32476 Created to show last 24 hours Urine observations from B2. Newborn Intake and Output. + 11/26/2018 - DJW HD# 2481782 - Newborn Urine issue (ML was being added to diaper count) + + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + + +// OBSERVATION CHANGE + + + + + if thisDocumentCommunication.EventType = "ChartObservation" + then + + + // I&O Section + + + ( lastValuesList, highValuesList ) := read + { + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), value varchar(500), timstmp datetime ) " + || " INSERT INTO #tmp_aaa (value,timstmp) " + || " select Sum(Convert(Integer, obsx.OutValue)) as Value , od.RecordedDtm " + || " " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " left Join CV3ObservationXInfo AS obsx " + || " ON (obsx.ObservationXInfoGUID = o.GUID AND obsx.ArcType = o.ArcType And obsx.BagVolumeUnit is Not Null ) " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " AND ocmi.Name in ({{{SINGLE-QUOTE}}}SCH_io_Foley Catheter{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}io_output_condom_catheter{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCH_io_Straight Catheter{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}io_output_voided{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}io_output_nephrostomy{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}SCH_io_Suprapubic Catheter{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCH_io_Urostomy{{{SINGLE-QUOTE}}} ) " + || " and (obsx.OutValue is not null or o.ValueText is not null) " + || " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " " + || " and cd.iscanceled = 0 " + || " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}B2. Newborn Intake and Output{{{SINGLE-QUOTE}}})" + || " Group By od.RecordedDtm " + || " Order By od.RecordedDtm Desc " + || " " + || " " + || " select value, timstmp from #tmp_aaa " + || " drop table #tmp_aaa " + }; + + + header1 :="\n\n\b Urine Output - Observations in Past 24 Hours -All Charted \b0\n\n"; + formattedText1 := ""; + thisdatefield := " "; + yesterday := now-24 hours; + + + indexList := 1 seqto count (highValuesList); + + for i in indexList do + + // Reformat the Time Stamp + + thisdatefield_unformatted := (highValuesList[i]); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the first group and charted in the past 24 hours + + if thisdatefield_unformatted > yesterday + + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := (highValuesList[i]); + formattedText1 := thisdatefield_formatted; + endif; + + + if thisdatefield <> (highValuesList[i]) // new timestamp + then + formattedText1 := formattedText1 || "\n" || thisdatefield_formatted || " "; + thisdatefield := (highValuesList[i]); + else + formattedText1 := formattedText1 || " " ; + endif; + + + formattedText1 := formattedText1 || " "; + formattedText1 := formattedText1 || (lastValuesList[i]) || " ml"; + + endif; // Obsname amongst the Vital Signs observations + + enddo; + + + + // Diaper Count Section (DW 11/26/2018 - HD# 2481782 - Newborn Urine) + + + + ( lastValuesList, highValuesList ) := read + { " + select obsparam.ValueText , obsparam.RecordedDtm + from CV3ObsCatalogMasterItem ocmi with (nolock) + inner join SXACDObservationParameter obsparam with (nolock) on obsparam.ClientGUID = " || clientGuid || " and obsparam.ClientVisitGUID = " || visitGuid || " and obsparam.ChartGUID = " || chartGuid || " and obsparam.ObsMasterItemGUID = ocmi.GUID + join CV3Flowsheet fs with (nolock) on fs.GUID = obsparam.FlowsheetGUID + where ocmi.name = {{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Urine{{{SINGLE-QUOTE}}} and fs.name = {{{SINGLE-QUOTE}}}SCH_Intake and Output_Newborn Version{{{SINGLE-QUOTE}}} and obsparam.IsCanceled = 0 and obsparam.ValueText is not null + order by obsparam.RecordedDtm desc " + }; + + + if exists lastValuesList + + + then + + if formattedText1 <> "" then formattedText1 := formattedText1 || "\n\n"; endif; // add extra spaces after the ML section + + thisdatefield := " "; + yesterday := now-24 hours; + + + indexList := 1 seqto count (highValuesList); + + for i in indexList do + + + // Reformat the Time Stamp + + thisdatefield_unformatted := (highValuesList[i]); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the first group and charted in the past 24 hours + + if thisdatefield_unformatted > yesterday + + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := (highValuesList[i]); + formattedText1 := formattedText1 || thisdatefield_formatted; + endif; + + + if thisdatefield <> (highValuesList[i]) // new timestamp + then + formattedText1 := formattedText1 || "\n" || thisdatefield_formatted || " "; + thisdatefield := (highValuesList[i]); + else + formattedText1 := formattedText1 || " " ; + endif; + + + formattedText1 := formattedText1 || " "; + formattedText1 := formattedText1 || (lastValuesList[i]) || " Diaper(s)"; + + endif; // Obsname amongst the Vital Signs observations + + enddo; + + endif; // Diaper Count Found ? + + + + + // Gather the existing contents of the textbox + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_FT VS, I & O"); + obs := FIRST OF (thisObservations WHERE thisObservations.parameterGUID = theParameter.parameterGUID); + priorcontents := obs.ValueObj.Value; + + formattedTextAll:= priorcontents || header1 || formattedText1; + + + + + endif; // Charted Observation ? + + + + // Write to the Structured Note Text Box + + + + If formattedTextAll is not null + + then + + vitalSignsHL := first of (thisParameters where thisParameters.Name = "SCH_MDPN_FT VS, I & O"); + + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := vitalSignsHL.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := formattedTextAll; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + endif; + + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_NEWBORN_MAX_TEMPERATURE.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_NEWBORN_MAX_TEMPERATURE.mlm new file mode 100644 index 0000000..5762336 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_NEWBORN_MAX_TEMPERATURE.mlm @@ -0,0 +1,225 @@ +maintenance: + + title: DOC_FUNC_Max_Temperature ;; + mlmname: DOC_FUNC_Newborn_Max_Temperature ;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Vikaskumar Yadav;; + specialist: Shivprasad Jadhav ;; + date: 2015-06-16;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + +Dev 16.06.2015 DW CSR:33155- Created to show last 24 hours Max Temperature observations from B1. Newborn Vital Signs. + In Development + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + local_session := cds_session.local; + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + (this_currentObj) := thisdocumentCommunication.CurrentObservationObj; + comm_obj := thisDocumentCommunication.primaryobj; + + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + Infectious_Dis := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Grouping Disease"); + selectedItems := (this_currentObj.ValueObj.ListItemsList WHERE this_currentObj.ValueObj.ListItemsList.IsSelected = true); + currentObj_selectedItems := selectedItems.value ; //,Infectious Disease + + + +// OBSERVATION CHANGE + + + if thisDocumentCommunication.EventType = "ChartObservation" + then + + (obsNamesList, lastValuesList, highValuesList, lowValuesList) := read + { + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), name varchar(200), value decimal(5,2), timstmp datetime, sortseq int, timstmp2 varchar(30) ) " + || " INSERT INTO #tmp_aaa (name,value,timstmp, sortseq) " + || " select ocmi.Name, o.ValueText, od.RecordedDtm, " + || " CASE WHEN Name = {{{SINGLE-QUOTE}}}farenheit{{{SINGLE-QUOTE}}} THEN 01 " + || " ELSE 99 " + || " END AS SortSeq " + || " " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " AND ocmi.Name in ({{{SINGLE-QUOTE}}}farenheit{{{SINGLE-QUOTE}}}) " + || " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " " + || " and cd.iscanceled = 0 " + || " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}B1. Newborn Vital Signs{{{SINGLE-QUOTE}}}) " + || " order by sortseq , cd.touchedwhen " + || " " + // || " update t1 set timstmp2 = t2.timstmp from #tmp_aaa t1 " + // || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq = t2.sortseq " + || " delete from #tmp_aaa where Value is null Delete from #tmp_aaa Where Convert(datetime,timstmp) < dateadd(hour, -24,getdate()) " + || " " + || " select Top 1 name, value, timstmp, sortseq from #tmp_aaa Where Value= (Select Max(Value ) From #tmp_aaa ) order by timstmp desc, sortseq " + || " drop table #tmp_aaa " + }; + + + +// update #tmp_aaa Set #tmp_aaa.timstmp = Dateadd(hour, -4, Getdate()) + header1 :="\n\n\b Vital Signs - Max Temperature in Past 24 Hours\b0\n\n"; + formattedText1 := " "; + thisdatefield := " "; + yesterday := now-24 hours; + + + indexList := 1 seqto count (obsNamesList); + + for i in indexList do + + obsName := (obsNamesList[i]); + + // Reformat the Time Stamp + + thisdatefield_unformatted := (highValuesList[i]); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the first group and charted in the past 24 hours + + if obsName in ("farenheit" ) + and + thisdatefield_unformatted > yesterday + + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := (highValuesList[i]); + formattedText1 := thisdatefield_formatted; + endif; + + + if thisdatefield <> (highValuesList[i]) // new timestamp + then + formattedText1 := formattedText1 || "\n" || thisdatefield_formatted; + thisdatefield := (highValuesList[i]); + else + formattedText1 := formattedText1 || " " ; + endif; + + + + if obsName = "Farenheit" then formattedText1 := formattedText1 || "\b T:\b0 "; + + //elseif obsName = "SCH_vs_pulse ox source" then formattedText1 := formattedText1 || "/" ; //b O2 L/min:\b0 "; + endif; + + + formattedText1 := formattedText1 || " "; + formattedText1 := formattedText1 || (lastValuesList[i]); + + endif; // Obsname amongst the Vital Signs observations + + enddo; + + + // Gather the existing contents of the textbox + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_FT VS, I & O"); + obs := FIRST OF (thisObservations WHERE thisObservations.parameterGUID = theParameter.parameterGUID); + priorcontents := obs.ValueObj.Value; + + formattedTextAll:= priorcontents || header1 || formattedText1; + + + endif; +// for Passing the Value in Base MLm via Session Variable ===== +If formattedText1 is Not Null Then +abc:= Call (formattedText1 as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "T:" as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}, "" as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}; +Else +abc:= formattedText1 ; +Endif; + +local_session.ACS_FormatedText := " " || abc ; + +//End ========================================================= + + If formattedTextAll is not null + + then + + vitalSignsHL := first of (thisParameters where thisParameters.Name = "SCH_MDPN_FT VS, I & O"); + + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := vitalSignsHL.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := formattedTextAll; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + + /*for current_item in currentObj_selectedItems do + If current_item ="Infectious Disease" Then + + vitalSignsHL1 := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Groupings"); + + newObservation1 := NEW ObservationType; + newObservation1.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation1.ParameterGUID := vitalSignsHL1.ParameterGUID; + newObservation1.DataType := "FreeTextValue"; + newObservation1.ValueObj := NEW FreeTextValueType; + newObservation1.ValueObj.Value := formattedTextAll; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation1); + + Endif; + enddo;*/ + + endif; + + + + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_NEWBORN_VS_24HRS.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_NEWBORN_VS_24HRS.mlm new file mode 100644 index 0000000..4952892 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_NEWBORN_VS_24HRS.mlm @@ -0,0 +1,523 @@ +maintenance: + + title: Vital Signs - Highs and Lows;; + mlmname: DOC_FUNC_NewBorn_VS_24hrs;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Vikaskumar Yadav;; + specialist: ;; + date: 2015-06-16;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 06-16-2015 - VY Created MLM to pull the data of all the vital signs charted on the patient in last 24 hours from the "B1. Newborn Vital Signs " flowsheet. + 10.26.2015 SJ + 01.03.2017 DW HD# 2469756 - Upgrade SCM to version 16.3 uncovered an issue with missing ounces + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + + +// OBSERVATION CHANGE + + + + if thisDocumentCommunication.EventType = "ChartObservation" + then + + (obsNamesList, lastValuesList, highValuesList, lowValuesList) := read + { + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), name varchar(200), value varchar(500), timstmp datetime, sortseq int, timstmp2 varchar(30) ) " + || " INSERT INTO #tmp_aaa (name,value,timstmp, sortseq) " + || " select ocmi.Name, o.ValueText, od.RecordedDtm, " + || " CASE WHEN Name = {{{SINGLE-QUOTE}}}Supine Systolic BP{{{SINGLE-QUOTE}}} THEN 01 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Supine Diastolic BP{{{SINGLE-QUOTE}}} THEN 02 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Sitting Systolic BP{{{SINGLE-QUOTE}}} THEN 03 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Sitting Diastolic BP{{{SINGLE-QUOTE}}} THEN 04 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Standing Systolic BP{{{SINGLE-QUOTE}}} THEN 05 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Standing Diastolic BP{{{SINGLE-QUOTE}}} THEN 06 " + || " WHEN Name = {{{SINGLE-QUOTE}}}sch_orthostatic heart rate - supine{{{SINGLE-QUOTE}}} THEN 07 " + || " WHEN Name = {{{SINGLE-QUOTE}}}sch_orthostatic heart rate - sitting{{{SINGLE-QUOTE}}} THEN 08 " + || " WHEN Name = {{{SINGLE-QUOTE}}}sch_orthostatic heart rate - standing{{{SINGLE-QUOTE}}} THEN 09 " + || " ELSE 99 " + || " END AS SortSeq " + || " " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " AND ocmi.Name in ({{{SINGLE-QUOTE}}}Supine Systolic BP{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Supine Diastolic BP{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Sitting Systolic BP{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Sitting Diastolic BP{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Standing Systolic BP{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Standing Diastolic BP{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}sch_orthostatic heart rate - supine{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}sch_orthostatic heart rate - sitting{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}sch_orthostatic heart rate - standing{{{SINGLE-QUOTE}}} ) " + || " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " " + || " and cd.iscanceled = 0 " + || " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}B1. Newborn Vital Signs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Newborn Patient Profile{{{SINGLE-QUOTE}}}) " + || " order by sortseq , cd.touchedwhen " + || " " + || " update t1 set timstmp2 = t2.timstmp from #tmp_aaa t1 " + || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq = t2.sortseq " + || " delete from #tmp_aaa where timstmp2 is not null " + || " " + || " select name, value, timstmp, sortseq from #tmp_aaa order by timstmp desc, sortseq " + || " drop table #tmp_aaa " + }; + + header1 :="\n\n\b Orthostatic Vital Signs in Past 24 Hours - Last Charted \b0\n\n"; + formattedText1 := " "; + thisdatefield := " "; + yesterday := now-24 hours; + + + indexList := 1 seqto count (obsNamesList); + + for i in indexList do + + obsName := last (first i from obsNamesList); + + // Reformat the Time Stamp + + thisdatefield_unformatted := last (first i from highValuesList); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the first group and charted in the past 24 hours + + if obsName in ("Supine Systolic BP" , "Supine Diastolic BP" , "Sitting Systolic BP" , "Sitting Diastolic BP" , "Standing Systolic BP" , "Standing Diastolic BP","sch_orthostatic heart rate - supine", + "sch_orthostatic heart rate - sitting","sch_orthostatic heart rate - standing" ) + and + thisdatefield_unformatted > yesterday + + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := last (first i from highValuesList); + formattedText1 := thisdatefield_formatted; + endif; + + + if thisdatefield <> last (first i from highValuesList) // new timestamp + then + formattedText1 := formattedText1 || "\n" || thisdatefield_formatted; + thisdatefield := last (first i from highValuesList); + else + formattedText1 := formattedText1 || " " ; + endif; + + + if obsName = "Supine Systolic BP" then formattedText1 := formattedText1 || "\b Supine BP:\b0 "; + elseif obsName = "Supine Diastolic BP" then formattedText1 := formattedText1 || "/"; + elseif obsName = "Sitting Systolic BP" then formattedText1 := formattedText1 || "\b Sitting BP:\b0 "; + elseif obsName = "Sitting Diastolic BP" then formattedText1 := formattedText1 || "/"; + elseif obsName = "Standing Systolic BP" then formattedText1 := formattedText1 || "\b Standing BP:\b0 "; + elseif obsName = "Standing Diastolic BP" then formattedText1 := formattedText1 || "/"; + elseif obsName = "sch_orthostatic heart rate - supine" then formattedText1 := formattedText1 || "\b Ortho HR Supine:\b0 "; + elseif obsName = "sch_orthostatic heart rate - sitting" then formattedText1 := formattedText1 || "\b Ortho HR Sitting:\b0 "; + elseif obsName = "sch_orthostatic heart rate - standing" then formattedText1 := formattedText1 || "\b Ortho HR Standing:\b0 "; + endif; + + formattedText1 := formattedText1 || " "; + formattedText1 := formattedText1 || last (first i from lastValuesList); + + endif; // Obsname amongst the Vital Signs observations + + enddo; + + + // Gather the existing contents of the textbox + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_FT VS, I & O"); + obs := FIRST OF (thisObservations WHERE thisObservations.parameterGUID = theParameter.parameterGUID); + priorcontents := obs.ValueObj.Value; + + formattedTextAll:= priorcontents || header1 || formattedText1; + + + + endif; + + +// DOCUMENT OPEN + + + if thisdocumentCommunication.EventType = "DocumentOpening" + then + + // Query the database for the vitals info + + + (obsNamesList, lastValuesList, highValuesList, lowValuesList) := read + { + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), name varchar(200), value varchar(500), timstmp datetime, sortseq int, timstmp2 varchar(30) ) " + || " INSERT INTO #tmp_aaa (name,value,timstmp, sortseq) " + || " select ocmi.Name, o.ValueText, od.RecordedDtm, " + || " CASE WHEN Name = {{{SINGLE-QUOTE}}}Farenheit{{{SINGLE-QUOTE}}} THEN 01 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Heart Rate{{{SINGLE-QUOTE}}} THEN 02 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Resp Rate{{{SINGLE-QUOTE}}} THEN 03 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Noninvasive Systolic BP{{{SINGLE-QUOTE}}} THEN 04 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Noninvasive Diastolic BP{{{SINGLE-QUOTE}}} THEN 05 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Arterial Systolic BP - Radial{{{SINGLE-QUOTE}}} THEN 06 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Arterial Diastolic BP - Radial{{{SINGLE-QUOTE}}} THEN 07 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Arterial Systolic BP - Second Line{{{SINGLE-QUOTE}}} THEN 08 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Arterial Diastolic - Second Line{{{SINGLE-QUOTE}}} THEN 09 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_vs_pulse ox saturation{{{SINGLE-QUOTE}}} THEN 10 " + || " WHEN Name = {{{SINGLE-QUOTE}}}L/min{{{SINGLE-QUOTE}}} THEN 11 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Height in cm{{{SINGLE-QUOTE}}} THEN 20 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Height in ft{{{SINGLE-QUOTE}}} THEN 21 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Height remainder in inches{{{SINGLE-QUOTE}}} THEN 22 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby a wt gm ob NU{{{SINGLE-QUOTE}}} THEN 23 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby b wt gm ob NU{{{SINGLE-QUOTE}}} THEN 24 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby a wt lb ob NU{{{SINGLE-QUOTE}}} THEN 25 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby a wt oz ob NU{{{SINGLE-QUOTE}}} THEN 26 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby b wt lb ob NU{{{SINGLE-QUOTE}}} THEN 27 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby b wt oz ob NU{{{SINGLE-QUOTE}}} THEN 28 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - grams{{{SINGLE-QUOTE}}} THEN 29 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - lbs{{{SINGLE-QUOTE}}} THEN 40 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - oz{{{SINGLE-QUOTE}}} THEN 41 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Weight - lbs{{{SINGLE-QUOTE}}} THEN 42 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Weight - kg{{{SINGLE-QUOTE}}} THEN 43 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_vs_Occipital-Frontal Head{{{SINGLE-QUOTE}}} THEN 44 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Stool{{{SINGLE-QUOTE}}}THEN 45 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Urine{{{SINGLE-QUOTE}}}THEN 46 " + || " ELSE 99 " + || " END AS SortSeq " + || " " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " AND ocmi.Name in ( " + || " {{{SINGLE-QUOTE}}}farenheit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Heart Rate{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Resp Rate{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_vs_pulse ox saturation{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}L/min{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}Noninvasive Diastolic BP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Noninvasive Systolic BP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Arterial Systolic BP - Radial{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Arterial Diastolic BP - Radial{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Arterial Systolic BP - Second Line{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Arterial Diastolic - Second Line{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}AS deliv baby a wt gm ob NU{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}AS deliv baby b wt gm ob NU{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}AS deliv baby a wt lb ob NU{{{SINGLE-QUOTE}}} , " + || " {{{SINGLE-QUOTE}}}AS deliv baby b wt lb ob NU{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}AS deliv baby a wt oz ob NU{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}AS deliv baby b wt oz ob NU{{{SINGLE-QUOTE}}} , " + || " {{{SINGLE-QUOTE}}}SCH_Newborn Weight - grams{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_Newborn Weight - lbs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_Newborn Weight - oz{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}Weight - lbs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Weight - kg{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}Height in ft{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Height remainder in inches{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Height in cm{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCH_vs_Occipital-Frontal Head{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}Current Weight{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Stool{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Urine{{{SINGLE-QUOTE}}} " + || " ) " + || " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " " + || " and cd.iscanceled = 0 " + || " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}B1. Newborn Vital Signs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Newborn Patient Profile{{{SINGLE-QUOTE}}}) " + || " order by sortseq , cd.touchedwhen " + || " " + || " update t1 set timstmp2 = t2.timstmp from #tmp_aaa t1 " + || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq = t2.sortseq " + || " update t2 set timstmp2 = {{{SINGLE-QUOTE}}}first weight{{{SINGLE-QUOTE}}}, name = {{{SINGLE-QUOTE}}}First Adult Weight - kg{{{SINGLE-QUOTE}}} from #tmp_aaa t1 " + || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq <> t2.sortseq and t2.name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - grams{{{SINGLE-QUOTE}}} " //{{{SINGLE-QUOTE}}}Weight - kg{{{SINGLE-QUOTE}}} + || " update t2 set timstmp2 = {{{SINGLE-QUOTE}}}first weight lbs{{{SINGLE-QUOTE}}}, name = {{{SINGLE-QUOTE}}}First Adult Weight - lbs{{{SINGLE-QUOTE}}} from #tmp_aaa t1 " + || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq <> t2.sortseq and t2.name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - lbs{{{SINGLE-QUOTE}}} " //{{{SINGLE-QUOTE}}}Weight - lbs{{{SINGLE-QUOTE}}} + || " update t2 set timstmp2 = {{{SINGLE-QUOTE}}}first weight oz{{{SINGLE-QUOTE}}}, name = {{{SINGLE-QUOTE}}}First Adult Weight - oz{{{SINGLE-QUOTE}}} from #tmp_aaa t1 " + || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq <> t2.sortseq and t2.name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - oz{{{SINGLE-QUOTE}}} " //{{{SINGLE-QUOTE}}}Weight - oz{{{SINGLE-QUOTE}}} + || " delete from #tmp_aaa where timstmp2 is not null and timstmp2 not in ({{{SINGLE-QUOTE}}}first weight{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}first weight lbs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}first weight oz{{{SINGLE-QUOTE}}}) " + || " " + || " select name, value, timstmp, sortseq from #tmp_aaa order by timstmp desc, sortseq " + || " drop table #tmp_aaa " + }; + +//break; + + // Process the First Group Data Elements (past 24 hours) + + + header1 :="\b Vital Signs in Past 24 Hours - Last Charted \b0\n\n"; + formattedText1:= " "; + thisdatefield := " "; + yesterday:= now-24 hours; + + indexList := 1 seqto count (obsNamesList); + + for i in indexList do + + obsName := last (first i from obsNamesList); + + // Reformat the Time Stamp + + thisdatefield_unformatted := last (first i from highValuesList); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the first group and charted in the past 24 hours + +//break; + + if obsName in ("farenheit","Heart Rate","Resp Rate","SCH_vs_pulse ox saturation","L/min", + "Noninvasive Diastolic BP","Noninvasive Systolic BP","Arterial Systolic BP - Radial","Arterial Diastolic BP - Radial", + "Arterial Systolic BP - Second Line","Arterial Diastolic - Second Line" ) + and + thisdatefield_unformatted > yesterday + + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := last (first i from highValuesList); + formattedText1 := thisdatefield_formatted; + endif; + + + if thisdatefield <> last (first i from highValuesList) // new timestamp + then + formattedText1 := formattedText1 || "\n" || thisdatefield_formatted; + thisdatefield := last (first i from highValuesList); + else + formattedText1 := formattedText1 || " " ; + endif; + + + if obsName = "Heart Rate" then formattedText1 := formattedText1 || "\b HR:\b0 "; + elseif obsName = "Farenheit" then formattedText1 := formattedText1 || "\b T:\b0 "; + elseif obsName = "Noninvasive Systolic BP" then formattedText1 := formattedText1 || "\b BP:\b0 "; + elseif obsName = "Noninvasive Diastolic BP" then formattedText1 := formattedText1 || "/"; + elseif obsName = "Arterial Systolic BP - Radial" then formattedText1 := formattedText1 || "\b ART BP:\b0 "; + elseif obsName = "Arterial Diastolic BP - Radial" then formattedText1 := formattedText1 || "/"; + elseif obsName = "Arterial Systolic BP - Second Line" then formattedText1 := formattedText1 || "\b ART BP Second:\b0 "; + elseif obsName = "Arterial Diastolic - Second Line" then formattedText1 := formattedText1 || "/"; + elseif obsName = "Resp Rate" then formattedText1 := formattedText1 || "\b R:\b0 "; + elseif obsName = "SCH_vs_pulse ox saturation" then formattedText1 := formattedText1 || "\b Pulse Ox:\b0 "; + elseif obsName = "L/min" then formattedText1 := formattedText1 || "\b O2 L/min:\b0 "; + endif; + + formattedText1 := formattedText1 || " "; + formattedText1 := formattedText1 || last (first i from lastValuesList); + + endif; // Obsname amongst the Vital Signs observations + + enddo; + + + formattedText1 := header1 || formattedText1; + + + + + // Process the Second Group Data Elements (Start of Chart) + + + + header2 :="\n\n \b Additional Information - Last Charted \b0 \n\n"; + formattedText2:= " "; + thisdatefield := " "; + +//break; + indexList := 1 seqto count (obsNamesList); + for i in indexList do + + obsName := last (first i from obsNamesList); + + + // Reformat the Time Stamp + + + thisdatefield_unformatted := last (first i from highValuesList); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the second group +//break; + + if obsName in ( + "AS deliv baby a wt gm ob NU" , "AS deliv baby b wt gm ob NU" , "AS deliv baby a wt lb ob NU" , "AS deliv baby b wt lb ob NU" , "AS deliv baby a wt oz ob NU" , "AS deliv baby b wt oz ob NU" , + "SCH_Newborn Weight - grams","SCH_Newborn Weight - lbs","SCH_Newborn Weight - oz", "Weight - lbs","Weight - kg","First Adult Weight - kg","Height in ft" , "Height remainder in inches" , "Height in cm", + "SCH_vs_Occipital-Frontal Head", "Current Weight","SCH_io_newborn_diaper count - Stool" , "SCH_io_newborn_diaper count - Urine","First Adult Weight - lbs","First Adult Weight - oz" + ) + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := last (first i from highValuesList); + formattedText2 := thisdatefield_formatted; + endif; + + + if thisdatefield <> last (first i from highValuesList) // new timestamp + then + formattedText2 := formattedText2 || "\n" || thisdatefield_formatted; + thisdatefield := last (first i from highValuesList); + else + formattedText2 := formattedText2 || " " ; + endif; + + + if obsName = "SCH_io_newborn_diaper count - Stool" then formattedText2 := formattedText2 || "\b Stool Diaper:\b0 "; + elseif obsName = "SCH_io_newborn_diaper count - Urine" then formattedText2 := formattedText2 || "\b Urine Diaper:\b0 "; + elseif obsName = "SCH_vs_Occipital-Frontal Head" then formattedText2 := formattedText2 || "\b H.C./cm:\b0 "; + elseif obsName = "Height in cm" then formattedText2 := formattedText2 || "\b Ht/cm:\b0 "; + elseif obsName = "Height in ft" then formattedText2 := formattedText2 || "\b Ht/ft:\b0 "; + elseif obsName = "Height remainder in inches" then formattedText2 := formattedText2 || "-"; + elseif obsName = "SCH_Newborn Weight - grams" then formattedText2 := formattedText2 || "\b Wt/gm:\b0 "; + curwt:= last (first i from lastValuesList); + lastwt := last (first i from lastValuesList); + //delwt:= last (last i from lastValuesList); //vikas + elseif obsName = "SCH_Newborn Weight - lbs" then formattedText2 := formattedText2 || "\b Wt/lb:\b0 "; + //curwt:= last (first i from lastValuesList); + //lastwt := last (first i from lastValuesList); + elseif obsName = "SCH_Newborn Weight - oz" then formattedText2 := formattedText2 || "-"; + elseif obsName = "AS deliv baby a wt gm ob NU" then formattedText2 := formattedText2 || "\b Deliv Wt/gm:\b0 "; delwt:= last (first i from lastValuesList); + elseif obsName = "AS deliv baby b wt gm ob NU" then formattedText2 := formattedText2 || "\b Deliv Wt/gm:\b0 "; delwt:= last (first i from lastValuesList); + elseif obsName = "AS deliv baby a wt lb ob NU" then formattedText2 := formattedText2 || "\b Deliv Wt/lb:\b0 "; + elseif obsName = "AS deliv baby a wt oz ob NU" then formattedText2 := formattedText2 || "-"; + elseif obsName = "AS deliv baby b wt lb ob NU" then formattedText2 := formattedText2 || "\b Deliv Wt/lb:\b0 "; + elseif obsName = "AS deliv baby b wt oz ob NU" then formattedText2 := formattedText2 || "-"; + elseif obsName = "Weight - lbs" then formattedText2 := formattedText2 || "\b Wt/lb:\b0 "; + elseif obsName = "Weight - kg" then formattedText2 := formattedText2 || "\b Wt/kg:\b0 "; lastwt := last (first i from lastValuesList); + elseif obsName = "First Adult Weight - kg" then formattedText2 := formattedText2 || "\b First Wt/gm:\b0 "; firstwt:= last (first i from lastValuesList); + elseif obsName = "First Adult Weight - lbs" then formattedText2 := formattedText2 || "\b First Wt/lb:\b0 "; //firstwtlbs:= last (first i from lastValuesList); + elseif obsName = "First Adult Weight - oz" then formattedText2 := formattedText2 || "-"; +//break; + endif; + + formattedText2 := formattedText2 || " "; + formattedText2 := formattedText2 || last (first i from lastValuesList); + + + endif; // Obsname amongst the Additional Information observations + + enddo; + + + + // Calculate the weight change + +//break; + + If exist delwt // Baby since birth weight + + then + /*wtlabel := "Wt change since birth: \b0 "; + wtscale := " gm "; + wtchange := ((curwt as number) - (delwt as number)) formatted with " %.2f %"; + wtchangepcnt := (((curwt as number) - (delwt as number))/(delwt as number) * 100) formatted with " %.2f %%"; */ + wtlabel := "Wt change since birth: \b0 "; + wtscale := " gm "; + wtscalelbs := " lbs "; + //wtchange := (((curwt as number) - (delwt as number))/1000) formatted with " %.2f %"; + wtchange := ((curwt as number) - (delwt as number)) formatted with " %.2f %"; + wtchangepcnt := (((curwt as number) - (delwt as number))/(delwt as number) * 100) formatted with " %.2f %%"; + Calc := (wtchange as number) * ("0.00220462" As number); //("2.20462" as number) ;// * ("1000" as number ) ; + If Calc Is Not Null Then + WtChangeLbs := Read first{" Select Format( " || Calc || " , {{{SINGLE-QUOTE}}}00.00{{{SINGLE-QUOTE}}}) " } ; // Added By Shivprasad for CSR:33428 on 19 June 2015 + Endif; + + else // Adult since first weighing + + Void:= Null; + + /*wtlabel := "Wt change since first weighing: \b0 "; + wtscale := " kg "; + wtchange := ((lastwt as number) - (firstwt as number)) formatted with " %.2f %"; + wtchangepcnt := (((lastwt as number) - (firstwt as number)) /(firstwt as number) * 100) formatted with " %.2f %%";*/ + + /* wtlabel := "Wt change since first weighing: \b0 "; + wtscale := " kg "; + wtscalelbs := " lbs "; // Added By Shivprasad for CSR:33428 on 19 June 2015 + wtchange := (((lastwt as number) - (firstwt as number))/1000) formatted with " %.2f %"; + wtchangepcnt := (((lastwt as number) - (firstwt as number)) /(firstwt as number)) formatted with " %.2f %%"; // /(firstwt as number) * 100) formatted with " %.2f %%"; + WtChangeLbs := (wtchange as number) * ("2.20462" as number) ; */ //Hide By Shivprasad On 11 Sept 2015 + //break; + + endif; +// break; + + If wtchange is not null + then + //wtchange := " \n\n\b " || wtlabel || wtchange || wtscale || wtchangepcnt ; + wtchange := " \n\n\b " || wtlabel || WtChangeLbs || wtscalelbs || wtchange || wtscale || wtchangepcnt ; + else + wtchange := " "; + endif; + + formattedText2 := header2 || formattedText2 || wtchange; + + + formattedTextAll:= formattedText1 || formattedText2; + + + + endif; // Document Open + + + + + // Write to the Structured Note Text Box + + + + If formattedTextAll is not null + + then + + vitalSignsHL := first of (thisParameters where thisParameters.Name = "SCH_MDPN_FT VS, I & O"); + + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := vitalSignsHL.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := formattedTextAll; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + endif; + + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_OUTPATIENT_CLEARPRINTBUTTON.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_OUTPATIENT_CLEARPRINTBUTTON.mlm new file mode 100644 index 0000000..5184aca --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_OUTPATIENT_CLEARPRINTBUTTON.mlm @@ -0,0 +1,121 @@ +maintenance: + + title: DOC_FUNC_OUTPATIENT_CLEARPRINTBUTTON;; + mlmname: DOC_FUNC_OUTPATIENT_CLEARPRINTBUTTON;; + arden: version 2.5;; + version: 0.00;; + institution: St. Clair Hospital;; + author: Shawn Head x7468;; + specialist: ;; + date: 2017-08-23;; + validation: testing;; + +library: + purpose: print Outpatient reports when print button selected on outpatient structured notes. + + ;; + explanation: The MLM is called from outpatient structured notes. Depending on the structured note that called the report determines which report(s) to print. + + Change history + + 08.23.2017 STH - CSR#: 35320 - Created + 04.25.2018 DW - HD# : 3196602 - Corrected an issue with the print button that was discovered during the early days of the activation + ;; + keywords: + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + + + IF (thisdocumentCommunication.EventType = "DocumentOpening") + + then + + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_Discharge Instruction Print"); + theObservation:= first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_Discharge Instruction Print"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := false; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + // Set the HIS only "dummy" button to true to activate the SAVE button + + + theParameter := first of (thisparameters where thisparameters.Name = "CXD Testing MLM Only"); + theObservation:= first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + this_parametername := first of (thisParameters where thisParameters.Name = "CXD Testing MLM Only"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := true; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + endif; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_PATIENT_HEADER_VISIT_COUNT.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_PATIENT_HEADER_VISIT_COUNT.mlm new file mode 100644 index 0000000..7a18dc7 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_PATIENT_HEADER_VISIT_COUNT.mlm @@ -0,0 +1,150 @@ +maintenance: + + title: DOC_FUNC_PATIENT_HEADER_VISIT_COUNT;; + mlmname: DOC_FUNC_PATIENT_HEADER_VISIT_COUNT;; + arden: version 2.5;; + version: 5.50;; + institution: Allscripts;; + author: Janet Nordin;; + specialist: Don Warnick;; + date: 2016-08-22;; + validation: testing;; + +library: + purpose: Permit clinicians to monitor frequent readmissions + ;; + explanation: Upon save of Patient Profile SNs, a Patient Commnent with the recent visit count will be created which will update the patient header with a visit count. The clinicians will notify management if the visit count is high + + Change history + + 08.22.2016 DJW CSR# 34849 Patient Header Visit Count Readmission Monitoring - Created + + ;; + keywords: patient header, readmission, structured note + ;; +knowledge: + type: data-driven;; + data: + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + msg := ""; + + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + + // NewComment_dest := destination { ObjectsPlus } with [alert_type:="Warning",short_message:="Object created by MLM",priority:="low",scope :="chart",rule_group:="Comment Object",rule_number:=2010]; + + error_destination := destination { Alert } with [alert_type:="Warning",short_message:="ObjectsPlus Error from MLM",priority:="low",scope:="chart",Rule_group:="ObjectsPlus Error from MLM", + Rule_number:=1003,Rule_subgroup:="",Send_with_order:="",Alert_dialog_settings:= "",Display_alert:= true ]; + + // Gather the ED visit count for the past 12 months + + + (EDVisitCount) := read last + { + " select count (v.TypeCode) as varchar " + || " from CV3ClientVisit v with (nolock) " + || " where v.clientguid = " || ClientGuid || " and v.CreatedWhen > getdate() -366 and v.TypeCode = {{{SINGLE-QUOTE}}}Emergency{{{SINGLE-QUOTE}}} " + }; + + + // Gather the Inpatient and Observatoin visit count for the past 12 months + + + (InpObsVisitCount) := read last + { + " select count (v.TypeCode) as varchar " + || " from CV3ClientVisit v with (nolock) " + || " where v.clientguid = " || ClientGuid || " and v.CreatedWhen > getdate() -366 and TypeCode in ({{{SINGLE-QUOTE}}}Inpatient{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Observation{{{SINGLE-QUOTE}}}) " + }; + + + + // Create the Visit Count Comments + + try + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + + New_Comment_obj_ED := call {{{SINGLE-QUOTE}}}PatientComment{{{SINGLE-QUOTE}}}.CreatePatientComment with client_visit_obj,"ED Visits"; + New_Comment_obj_ED.Text:= EDVisitCount; + Void := Call New_Comment_obj_ED.Save; + + New_Comment_obj_InpObs:= call {{{SINGLE-QUOTE}}}PatientComment{{{SINGLE-QUOTE}}}.CreatePatientComment with client_visit_obj,"IP/OBS Admits"; + New_Comment_obj_InpObs.Text := InpObsVisitCount; + Void := Call New_Comment_obj_InpObs.Save; + + if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; + if ( New_Comment_obj_ED is NOT NULL ) then void:= call New_Comment_obj_ED.Dispose; New_Comment_obj_ED:= null; endif; + if ( New_Comment_obj_InpObs is NOT NULL ) then void:= call New_Comment_obj_InpObs.Dispose; New_Comment_obj_InpObs:= null; endif; + + endtry; + + catch exception ex + error_occurred := true; + error_message := "{{+R}}New Comment:{{-R}}\n" || ex.Message || "\n\n"; + if ex.InnerException is not null net_object + then + error_message := error_message || + "Inner Exception: " || ex.InnerException.Message || "\n\n"; + endif; + + if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; + if ( New_Comment_obj_ED is NOT NULL ) then void:= call New_Comment_obj_ED.Dispose; New_Comment_obj_ED:= null; endif; + if ( New_Comment_obj_InpObs is NOT NULL ) then void:= call New_Comment_obj_InpObs.Dispose; New_Comment_obj_InpObs:= null; endif; + + endcatch; + + + + ;; + priority: 50 + ;; + evoke: + ;; + logic: + + conclude true; + + ;; + action: + + + if Error_occurred + then + + write "An error has occured in the MLM {{+B}}DOC_FUNC_PATIENT_HEADER_VISIT_COUNT{{-B}} " || + "Please notify your System Administrators that an error message has " || + "occurred for this patient. They will review the following error " || + "message: \n" at error_destination; + write error_message at error_destination; + + endif; + + return thisdocumentCommunication; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_PAWSS.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_PAWSS.mlm new file mode 100644 index 0000000..e4fbf6b --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_PAWSS.mlm @@ -0,0 +1,266 @@ +maintenance: + + title: DOC_FUNC_PAWSS;; + mlmname: DOC_FUNC_PAWSS;; + arden: version 2.5;; + version: 5.50;; + institution: Allscripts;; + author: Peggy Karish;; + specialist: Don Warnick;; + date: 2011-07-18;; + validation: testing;; + +library: + purpose: Support PAWSS assessment in the Patient Profile + ;; + explanation: Support PAWSS assessment in the Patient Profile + + Change history + + 05.23.2016 DJW CSR#34250 PAWSS - Created + + ;; + keywords: pawss + ;; +knowledge: + type: data-driven;; + data: + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + msg := ""; + + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + + TaskRoleType := read { " select cp.TaskRoleType from CV3USER u with (nolock) " + || " join CV3CareProvider cp with (nolock) on cp.GUID = u.guid " + || " where u.guid = " || sql(userGuid) || " and cp.TaskRoleType like {{{SINGLE-QUOTE}}}%infusion%{{{SINGLE-QUOTE}}} " + }; + + +If not exists TaskRoleType + + + then + + + +// DOCUMENT OPENING SECTION + + + IF thisdocumentCommunication.EventType = "DocumentOpening" then + + // Retrieve Alcohol Level Plasma Serum + + (Result) := read last + { + " select ov.value " + || " from CV3BasicObservationView ov with (nolock) " + || " where ov.ResultItemCodingStandard = {{{SINGLE-QUOTE}}}lab{{{SINGLE-QUOTE}}} and ov.ItemName = {{{SINGLE-QUOTE}}}ETOH Level{{{SINGLE-QUOTE}}} " + || " and ov.clientguid = " || SQL (clientGuid) || " and ov.chartguid = " || SQL (chartGuid) || " and ov.clientvisitguid = " || SQL (visitGuid) || " " + || " order by ov.value " + }; + + + If Result is not null or Result <> "NONDETECTED" + + then + + // Populate the Result value in the Blood Alcohol box + + this_parametername := first of (thisParameters where thisParameters.Name = "PRO Blood alcohol level"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := Result; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + // Select the "Alcohol in 30 days question" + + this_parametername := first of (thisParameters where thisParameters.Name = "PRO consumed any alcohol in last 30 days"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "yes..." then selectedItem.IsSelected := true; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; // Positive ETOH Level found + + endif; + + + + + +// DOCUMENT CLOSING SECTION + + + IF thisdocumentCommunication.EventType = "DocumentClosing" + + then + + + // Check for PAWSS Score + + theParameter := first of (thisParameters where thisParameters.Name = "PRO PAWSS Total Score 1"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + PAWWSScore := theObservation.ValueObj.Value; + + + if (PAWWSScore as number) > 3 + + then + + + // Check for existing CIWA Assessment Order on the account + + (orderpresent) := read last + { + " select o.name " + || " from cv3ordercatalogmasteritem as ocmi with (nolock) " + || " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid " + || " and o.ClientGUID = " || ClientGuid || " and o.ChartGUID = " || chartGuid || " and o.ClientVisitGUID= " || VisitGuid || " " + || " and o.name = {{{SINGLE-QUOTE}}}Contact Attending Physician to Implement AWD Protocol orders{{{SINGLE-QUOTE}}} " + || " and o.OrderStatusLevelNum >= 15 and o.OrderStatusLevelNum not in (69, 70) " + }; + + + if orderpresent is null + + then + + // Enter CIAW Assessment Order + + try + + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n PAWSS Risk score is 4 or greater. Contact the attending physician to implement the Alcohol Withdrawal Protocol Order ", "Informational","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + + + + locationGuid := read last {"SELECT CurrentLocationGUID, touchedWhen" + || " FROM CV3ClientVisit with (nolock)" + || " WHERE GUID = " || Sql(visitGuid) + || " AND ClientGUID = " || Sql(clientGuid) + , primaryTime = touchedWhen}; + + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + care_provider_obj:= call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((userGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((locationGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + order_catalog_obj:= call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with ("Contact Attending Physician to Implement AWD Protocol orders"); + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}CommonData: {{-R}}\n" || ex.Message || "\n\n"; + + if order_catalog_obj is NOT Null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; + if location_obj IS NOT Null then void := call location_obj.Dispose; location_obj := null; endif; + if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif; + if client_visit_obj IS NOT Null then void := call client_visit_obj.Dispose; client_visit_obj := null; endif; + endcatch; + + try + Order_Creation_Reason := "Created per protocol"; + RequestingSource := "Protocol Order"; + SessionType := "Standard"; + SessionReason := ""; + + Order_Obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder + with client_visit_obj, + order_catalog_obj, + Order_Creation_Reason, + care_provider_obj, + RequestingSource, + SessionType, + SessionReason, + location_obj, + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; + + order_obj.SpecialInstructions := "Contact the attending physician to implement the alcohol withdrawal protocol orders."; + + void := call Order_Obj.Save; + + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}New Other Order: {{-R}}\n" || ex.Message || "\n\n"; + if Order_Obj IS NOT Null then void := call Order_Obj.Dispose; Order_Obj := null; endif; + endcatch; + + if order_catalog_obj IS NOT Null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; + if location_obj IS NOT Null then void := call location_obj.Dispose; location_obj := null; endif; + if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif; + if client_visit_obj IS NOT Null then void := call client_visit_obj.Dispose; client_visit_obj := null; endif; + + + endif; // Order already on file + + + endif; // PAWWS Score > 4 + + + endif; // Document Closing + + + endif; // Not an infusion nurse + + + + + ;; + priority: 50 + ;; + evoke: + ;; + logic: + + + + + +conclude true; + + + ;; + action: + return thisdocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_PNEUMOVAX.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_PNEUMOVAX.mlm new file mode 100644 index 0000000..83f2c93 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_PNEUMOVAX.mlm @@ -0,0 +1,1187 @@ +maintenance: + + title: Pneumovax Logic;; + mlmname: DOC_FUNC_PNEUMOVAX;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Don Warnick;; + specialist: ;; + date: 2010-02-19;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 02.19.2010 DW Created + 04.26.2010 DW Altered to 1. Not compare the label of the "SCM Retieve Ifo" and "Reassess" buttons 2. Add COPD and Bronchitis + 10.15.2010 TMS Changed made to add criteria to logic to not order vaccine only when vaccine received after 65 and to correct typo of + "was not" to "has not been" for within5years in statement to order vaccine. + 08.01.2011 DW Major rewrite CSR#26269 - qualifying rules had changed & the form was streamlined ("SCM Retieve Ifo" & "Reassess" buttons removed) + 11.10.2011 DW Help Desk issue - archive date fomratted as CCYY, original date formatted as YY caused problem with document charting date routine + 11.28.2012 DW CSR# 31009 MLM - Influenza and Pneumovax prevent overide + 06.18.2013 JML CSR# 26725 - Additional alcoholism-related health issues needed checked for chronic illnesses + 11.12.2013 DW 6.1 Upgrade - A new "code" column was added to cv3healthissuedeclaration making this field ambiguous in the Chronic Condidtion SQL + 08.31.2015 DW CSR# 23359 - ICD10 + 11.09.2015 DW CSR# 33655 Rewrite for Prevnar + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + agerange2_lowerlimit := 18; + agerange3_lowerlimit := 65; + +// For HIS diagnostic box only + + agerange1note := "under 18"; + agerange2note := "18 to 64"; + agerange3note := "65 and over"; + + + formattedTextReason := "N-0. Pneumococcal risk was not determined. "; + ordervaccine := "no"; + orderpneumovax:= "no"; + orderprevnar := "no"; + + + +// CHART OBSERVATION SECTION + + +IF thisdocumentCommunication.EventType = "ChartObservation" then + + + +// Attain user{{{SINGLE-QUOTE}}}s ID (for use in override message) + + userId := read last {" SELECT IDCode FROM CV3User with (nolock) WHERE GUID = " || Sql(userGuid) || " AND Active = 1 "}; + + + +// CONTRAINDICATION BUTTON CHANGE SECTION + + +// Using the prior value of the None box, determine if this is the first time a contraindication section box was clicked + + theParameter := first of (thisParameters where thisParameters.Name = "SCHCK_Pneumo Details"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + SavedNoneContraValue := theObservation.ValueObj.Value; + If SavedNoneContraValue is null + then FirstTime := "true"; else FirstTime := "false"; + endif; + + +// Proceed if a Contraindication section box was clicked + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_pneumo vac contra"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + then + trigger := "A Contraindications Box was selected or deselected"; + + +// If this is first contraindication section box clicked, assess what had been selected (NONE VS a Contraindication) + + if FirstTime = "true" then + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "none") + then contraboxchecked := "false"; MLMAction := "Retrieve and Reassess"; + + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value <> "none") + then contraboxchecked := "true"; MLMAction := "No Assessment Required"; + endif; + endif; + +// Compare the prior value of the None box to the current value, to determine what was selected (NONE VS a Contraindication) + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "none") + then NewNoneContraValue := "true"; else NewNoneContraValue := "false"; + endif; + + If FirstTime = "false" + then + if NewNoneContraValue = SavedNoneContraValue + then WhatWasClicked := "Other Button Was Clicked"; + else WhatWasClicked := "None Button Was Clicked"; SavedNoneContraValue := NewNoneContraValue; + endif; + else // FirstTime = "true" + SavedNoneContraValue := NewNoneContraValue; + endif; + + +// Determine if all boxes in the section are deselected (nonthing is selected) + + if true not in (theObservation.ValueObj.ListItemsList.IsSelected) + then contraboxchecked := "unknown"; MLMAction := "No Assessment Required"; + endif; + + +// If this is not the first click and something is selected, reset the mutually exclusive contraindication boxes (None VS a Contraindiation) + + If (contraboxchecked = "unknown" or FirstTime = "true") + then ResetOtherBoxes := "false"; else ResetOtherBoxes := "true"; + endif; + + If ResetOtherBoxes = "true" + then + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := theParameter.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= theParameter.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN theParameter.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if WhatWasClicked = "Other Button Was Clicked" // One of the Containdications was selected + then + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = selectedItem.Value) + then selectedItem.IsSelected := true; + else selectedItem.IsSelected := false; + endif; + if selectedItem.Value = "none" + then selectedItem.IsSelected := false; + endif; + NewNoneContraValue := "false"; + endif; + + if WhatWasClicked = "None Button Was Clicked" // The None box was selected + then + if selectedItem.Value = "none" + then selectedItem.IsSelected := true; + else selectedItem.IsSelected := false; + endif; + endif; + + listItems := (listItems, selectedItem); + ENDDO; + + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + +// After the boxes have been reset, assess what is now selected + + If WhatWasClicked = "None Button Was Clicked" and + true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "none") + then contraboxchecked := "false"; MLMAction := "Retrieve and Reassess"; + + elseif WhatWasClicked = "Other Button Was Clicked" and + true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value <> "none") + then contraboxchecked := "true"; MLMAction := "No Assessment Required"; + endif; + + endif; // End of Reset mutually exclusive Contra section + + + +// If None is selcted , Unhide the Chronic Illness and Chronic Illness Prevnar fields and buttons + + If contraboxchecked = "false" then + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Pneumo Unhide"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := true; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; + + + +// Populate the "None" Contraindiated Selected Value Box + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Pneumo Details"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := NewNoneContraValue; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + +endif; // End of Contraindication section + + + +// OTHER BUTTON CHANGE SECTION + + +// Recommend Order button change to NO (affix ovverride message to assesement) + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Pneumo vac recommend"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + and + true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "No") + + then MLMAction := "Reassess Only"; + trigger:= "Recommend Button NO was selected"; + endif; + + +// Recommend Order button change to Pneumovax (affix ovverride message to assesement) + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Pneumo vac recommend"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + and + true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Pneumovax 23") + + then MLMAction := "Reassess Only"; + trigger:= "Recommend Pneumovax Button was selected"; + endif; + + +// Recommend Order button change to Prevnar (affix ovverride message to assesement) + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Pneumo vac recommend"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + and + true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Prevnar 13") + + then MLMAction := "Reassess Only"; + trigger:= "Recommend Prevnar Button was selected"; + endif; + + + +// Chronic Condition button change + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Pneumo has Chronic Illness y/n"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + then trigger := "Chronic Illness Button was changed"; + If SavedNoneContraValue = "true" + then MLMAction := "Reassess Only"; // No Contraindications were identified + else MLMAction := "No Assessment Required"; // Patient has contraindications + endif; + endif; + + +// Date has Changed + + theParameter := first of (thisParameters where thisParameters.Name = "SCHCK_Vaccine Received Date 2"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + then trigger := "Date was changed"; + If SavedNoneContraValue = "true" + then MLMAction := "Reassess Only"; // No Contraindications were identified + else MLMAction := "No Assessment Required"; // Patient has contraindications + endif; + endif; + + + +// Allergy to Prevnar Vaccine button change + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Pneumo Allergy DT y/n"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + then trigger := "Prevnar Vaccine Allergy Button was changed"; + If SavedNoneContraValue = "true" + then MLMAction := "Reassess Only"; // No Contraindications were identified + else MLMAction := "No Assessment Required"; // Patient has contraindications + endif; + endif; + + + +// RETRIEVE AND REASSESS (or REASSESS ONLY) SECTION + + +if MLMAction = "Retrieve and Reassess" or MLMAction = "Reassess Only" then + + + + +// RETRIEVE AND REASSESS SECTION + + + If MLMAction = "Retrieve and Reassess" then + + + +// Date vaccine was charted in the patient profile + + +(vaccinecharteddate) := read last +{ +" select " +||" case when LEN(o.valuetext) = 8 then " +||" case when (substring(o.valuetext, 7, 1)) in ({{{SINGLE-QUOTE}}}7{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}8{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}9{{{SINGLE-QUOTE}}}) then {{{SINGLE-QUOTE}}}19{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}20{{{SINGLE-QUOTE}}} end " +|| " + (substring(o.valuetext, 7, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +|| "(substring(o.valuetext, 1, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 4, 2)) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| "else " +|| "(substring(o.valuetext, 7, 4)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 1, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 4, 2)) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| " end " +|| " from CV3ClientDocument cd with (nolock) " +|| " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = " || ClientGuid || " and cdd.active = 1) " +|| " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " +|| " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " +|| " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID and ocmi.name = {{{SINGLE-QUOTE}}}SCHCK_Vaccine Received Date 2{{{SINGLE-QUOTE}}} " +|| " where cd.clientguid = " || ClientGuid || " and cd.iscanceled = 0 and cd.documentname like {{{SINGLE-QUOTE}}}%patient profile%{{{SINGLE-QUOTE}}} " +|| " order by (substring(o.valuetext, 7, 2)), (substring(o.valuetext, 1, 2)) , (substring(o.valuetext, 4, 2)) " +}; + +vaccinechartedwhen := (vaccinecharteddate as time); + + +// Date vaccine was charted as given in the EMAR + +(vaccinegivenwhen) := read last +{ +" select oto.performedfromdtm " +|| " from cv3ordercatalogmasteritem as ocmi with (nolock) " +|| " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid " +|| " and o.ClientGUID = " || ClientGuid || " " +|| " and o.name like {{{SINGLE-QUOTE}}}Pneumococcal%{{{SINGLE-QUOTE}}} and o.name like {{{SINGLE-QUOTE}}}%Vaccine Inj{{{SINGLE-QUOTE}}} " +|| " join cv3ordertask as ot with (nolock) on ot.clientguid = o.clientguid and ot.orderguid = o.guid " +|| " join cv3ordertaskoccurrence as oto with (nolock) on oto.clientguid = ot.clientguid and oto.orderguid = ot.orderguid " +|| " and oto.ordertaskguid = ot.guid and oto.taskstatuscode ={{{SINGLE-QUOTE}}}Performed{{{SINGLE-QUOTE}}} " +}; + + +// Date vaccine was last charted as an active health issue + + +(vaccinehealthissuedate) := read last +{ +" select " +|| " case when onsetyearnum = 0 " +|| " then createdwhen " +|| " else " +|| " case when (onsetmonthnum >0 and onsetmonthnum <10) then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} + cast (onsetmonthnum as varchar) " +|| " when onsetmonthnum = 0 then {{{SINGLE-QUOTE}}}01{{{SINGLE-QUOTE}}} else cast (onsetmonthnum as varchar) end + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +|| " case when (onsetdaynum >0 and onsetdaynum <10) then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} + cast (onsetdaynum as varchar) " +|| " when onsetdaynum = 0 then {{{SINGLE-QUOTE}}}01{{{SINGLE-QUOTE}}} else cast (onsetdaynum as varchar) end " +|| " + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + cast (onsetyearnum as varchar) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| " end {{{SINGLE-QUOTE}}}date returned to mlm{{{SINGLE-QUOTE}}} " +|| " from cv3healthissuedeclaration with (nolock) " +|| " where clientguid = " || ClientGuid || " and active = 1 and status = {{{SINGLE-QUOTE}}}active{{{SINGLE-QUOTE}}}" +|| " and (shortname like {{{SINGLE-QUOTE}}}Pneumococcal Vaccine%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}Pneumococcal polysaccharide%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}Pneumococcal conjugate%{{{SINGLE-QUOTE}}}) and typecode = {{{SINGLE-QUOTE}}}Vaccine History{{{SINGLE-QUOTE}}} " +|| " order by createdwhen " +}; +vaccinehealthissue_found := count(vaccinehealthissue) As Number; + + + +// Chronic Illness health issues + + +(chronicillness) := read +{ +" select distinct hi.shortname " +|| "from cv3healthissuedeclaration hi with (nolock) " +|| "join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID " +|| "where hi.clientguid = " || ClientGuid || " and hi.active = 1 and hi.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " +|| "and hi.typecode not in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}chronic dx{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}dx comments{{{SINGLE-QUOTE}}}) " +|| " and ( " +|| "hi.text like {{{SINGLE-QUOTE}}}%Abuse,%Alcohol%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Abuse,%Alcohol%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Acute Renal Failure%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Acute Renal Failure%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Alcohol Dependence%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Alcohol Dependence%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Alcohol Use%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Alcohol Use%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Alcoholism%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Alcoholism%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Alcohol%Abuse%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Alcohol%Abuse%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Alcohol%Addiction%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Alcohol%Addiction%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Alcohol%Withdrawal%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Alcohol%Withdrawal%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Alcoholic%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Alcoholic%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Asthma%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Asthma%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Cancer%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Cancer%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Cardiomyopathy%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Cardiomyopathy%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%CardioVascular Disease%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%CardioVascular Disease%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Cirrhosis%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Cirrhosis%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%CHF%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%CHF%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%bronchitis,chronic%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%chronic bronchitis%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%chronic obstructive pulmonary%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%chronic obstructive pulmonary%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%copd%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%copd%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Coronary Artery Disease%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Coronary Artery Disease%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Diabetes%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Diabetes%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Emphysema%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Emphysema%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Heart Disease%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Heart Disease%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Heart Failure%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Heart Failure%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Chronic Liver Disease%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Chronic Liver Disease%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Long-term care facility resident%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Long-term care facility resident%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Respiratory Failure%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Respiratory Failure%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Smoker%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Smoker%{{{SINGLE-QUOTE}}} or " +|| "hi.text like {{{SINGLE-QUOTE}}}%Tobacco%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Tobacco%{{{SINGLE-QUOTE}}} or " +|| " ( " +|| " (hi.ICD9Code is null and chi.code in ({{{SINGLE-QUOTE}}}305.1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}V15.82{{{SINGLE-QUOTE}}}) ) " +|| " or " +|| " (hi.ICD9Code is not null and hi.ICD9Code in ({{{SINGLE-QUOTE}}}305.1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}V15.82{{{SINGLE-QUOTE}}}) ) " +|| " ) " +|| " ) " +|| " and (hi.text not like {{{SINGLE-QUOTE}}}Adrenal%{{{SINGLE-QUOTE}}} or hi.shortname not like {{{SINGLE-QUOTE}}}%adrenal%{{{SINGLE-QUOTE}}}) " +|| " and (hi.description not like {{{SINGLE-QUOTE}}}Cyst, Renal%{{{SINGLE-QUOTE}}} or hi.shortname not like {{{SINGLE-QUOTE}}}Cyst, Renal%{{{SINGLE-QUOTE}}}) " +|| " and (hi.description not like {{{SINGLE-QUOTE}}}Diabetes, Gestational%{{{SINGLE-QUOTE}}} or hi.shortname not like {{{SINGLE-QUOTE}}}Diabetes, Gestational%{{{SINGLE-QUOTE}}}) " +|| " and (hi.description not like {{{SINGLE-QUOTE}}}Renal Calculi%{{{SINGLE-QUOTE}}} or hi.shortname not like {{{SINGLE-QUOTE}}}Kidney Stones%{{{SINGLE-QUOTE}}}) " +|| " and (hi.description not like {{{SINGLE-QUOTE}}}Renal Stone%{{{SINGLE-QUOTE}}} or hi.shortname not like {{{SINGLE-QUOTE}}}Renal Stone%{{{SINGLE-QUOTE}}}) " +|| " and (hi.description not like {{{SINGLE-QUOTE}}}Former Smoker%{{{SINGLE-QUOTE}}} or hi.shortname not like {{{SINGLE-QUOTE}}}Former Smoker%{{{SINGLE-QUOTE}}} ) " + +}; + + +//Obtain Value of "Is Patient from Nursing Home" from the note and add it to the list of chronic illnesses + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_MRSA nursing home"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then chronicillness := (chronicillness ,"Arrived from a nursing home"); + endif; + + +chronicillness_found := count(chronicillness) As Number; + + +if chronicillness_found > 0 + then chronic := "something found"; + else chronic := "unknown"; +endif; + + + +// Chronic health issues Prevnar + + +(chronicillnessprevnar) := read +{ +"select distinct shortname " +|| "from cv3healthissuedeclaration with (nolock) " +|| "where clientguid = " || ClientGuid || " and active = 1 and status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " +|| "and typecode not in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}chronic dx{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}dx comments{{{SINGLE-QUOTE}}}) and ( " +|| " text like {{{SINGLE-QUOTE}}}%Acquired immunodeficiency%{{{SINGLE-QUOTE}}}    or shortname like {{{SINGLE-QUOTE}}}%Acquired immunodeficiency%{{{SINGLE-QUOTE}}}   or  " +|| " text like {{{SINGLE-QUOTE}}}%Anemia, Sickle Cell%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%Anemia, Sickle Cell%{{{SINGLE-QUOTE}}} or " +|| " text like {{{SINGLE-QUOTE}}}%Chemotherapy%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%Chemotherapy%{{{SINGLE-QUOTE}}} or " +|| " text like {{{SINGLE-QUOTE}}}%Chronic renal failure%{{{SINGLE-QUOTE}}}      or shortname like {{{SINGLE-QUOTE}}}%Chronic renal failure%{{{SINGLE-QUOTE}}}   or  " +|| " text like {{{SINGLE-QUOTE}}}%Cerebrospinal Fluid Leak%{{{SINGLE-QUOTE}}}     or shortname like {{{SINGLE-QUOTE}}}%Cerebrospinal Fluid Leak%{{{SINGLE-QUOTE}}}   or  " +|| " text like {{{SINGLE-QUOTE}}}%CSF leak%{{{SINGLE-QUOTE}}}      or shortname like {{{SINGLE-QUOTE}}}%CSF leak%{{{SINGLE-QUOTE}}}   or  " +|| " text like {{{SINGLE-QUOTE}}}%Cochlear Implant%{{{SINGLE-QUOTE}}}     or shortname like {{{SINGLE-QUOTE}}}%Cochlear Implant%{{{SINGLE-QUOTE}}}   or  " +|| " text like {{{SINGLE-QUOTE}}}%Congenital immunodeficiency%{{{SINGLE-QUOTE}}}  or shortname like {{{SINGLE-QUOTE}}}%Congenital immunodeficiency%{{{SINGLE-QUOTE}}}   or  " +|| " text like {{{SINGLE-QUOTE}}}%Corticosteroid-induced %{{{SINGLE-QUOTE}}}     or shortname like {{{SINGLE-QUOTE}}}%Corticosteroid-induced%{{{SINGLE-QUOTE}}}   or  " +|| " text like {{{SINGLE-QUOTE}}}%Hb-S disease%{{{SINGLE-QUOTE}}}     or shortname like {{{SINGLE-QUOTE}}}%Hb-S disease%{{{SINGLE-QUOTE}}}     or  " +|| " text like {{{SINGLE-QUOTE}}}%Hemoglobinopathy%{{{SINGLE-QUOTE}}}     or shortname like {{{SINGLE-QUOTE}}}%Hemoglobinopathy%{{{SINGLE-QUOTE}}}     or  " +|| " text like {{{SINGLE-QUOTE}}}%HIV%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%HIV%{{{SINGLE-QUOTE}}} or " +|| " text like {{{SINGLE-QUOTE}}}%Hodgkin%{{{SINGLE-QUOTE}}}       or shortname like {{{SINGLE-QUOTE}}}%Hodgkin%{{{SINGLE-QUOTE}}}   or  " +|| " text like {{{SINGLE-QUOTE}}}%Human immunodeficiency virus%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%Human immunodeficiency virus%{{{SINGLE-QUOTE}}}   or  " +|| " text like {{{SINGLE-QUOTE}}}%Leukemia%{{{SINGLE-QUOTE}}}       or shortname like {{{SINGLE-QUOTE}}}%Leukemia%{{{SINGLE-QUOTE}}}   or  " +|| " text like {{{SINGLE-QUOTE}}}%use of systemic steroids%{{{SINGLE-QUOTE}}}  or shortname like {{{SINGLE-QUOTE}}}%use of systemic steroids%{{{SINGLE-QUOTE}}} or  " +|| " text like {{{SINGLE-QUOTE}}}%Lymphoma%{{{SINGLE-QUOTE}}}       or shortname like {{{SINGLE-QUOTE}}}%Lymphoma%{{{SINGLE-QUOTE}}}   or  " +|| " text like {{{SINGLE-QUOTE}}}%Multiple Myeloma%{{{SINGLE-QUOTE}}}      or shortname like {{{SINGLE-QUOTE}}}%Multiple Myeloma%{{{SINGLE-QUOTE}}}   or  " +|| " text like {{{SINGLE-QUOTE}}}%Nephrotic Syndrome%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%Nephrotic Syndrome%{{{SINGLE-QUOTE}}} or " +|| " text like {{{SINGLE-QUOTE}}}%Radiation Therapy%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%Radiation Therapy%{{{SINGLE-QUOTE}}} or " +|| " text like {{{SINGLE-QUOTE}}}%Radiation%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%Radiation%{{{SINGLE-QUOTE}}} or " +|| " text like {{{SINGLE-QUOTE}}}%Radiation Therapy%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%Radiation Therapy%{{{SINGLE-QUOTE}}} or " +|| " text like {{{SINGLE-QUOTE}}}%Splenectomy%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%Splenectomy%{{{SINGLE-QUOTE}}} or " +|| " text like {{{SINGLE-QUOTE}}}%Thalassemia%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%Thalassemia%{{{SINGLE-QUOTE}}} or " +|| " text like {{{SINGLE-QUOTE}}}%Transplant%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%Transplant%{{{SINGLE-QUOTE}}} ) " +}; +chronicillnessprevnar_found := count(chronicillnessprevnar) As Number; + +if chronicillnessprevnar_found > 0 + then chronicprevnar := "something found"; + else chronicprevnar := "unknown"; +endif; + + + + +// Populate Fields and Boxes + + + +// Chronic Illness + + +// First determine if a button has previously been selected by the nurse and do not override it + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Pneumo has Chronic Illness y/n"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then chronic := "true"; + endif; + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no") + then chronic := "false"; + endif; + +// Select the Chronic Illness YES radio button if one is found (only if no button has been peviously selected) + + If chronic = "something found" or chronicprevnar = "something found" then + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Pneumo has Chronic Illness y/n"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "yes" and (chronicillness_found > 0 or chronicillnessprevnar_found > 0) + then selectedItem.IsSelected := true; chronic := "true"; + endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + + +// Populate the Chronic Illnesses Information box + + holdchron:=""; + if chronicillness_found > 0 then + for k in (1 seqto (chronicillness_found )) do + if chronicillness[k] is not null then + holdchron := holdchron || chronicillness[k] ; + if k <> chronicillness_found then // not the last in the list + holdchron := holdchron || ", "; + endif; + endif; + enddo; + endif; + if holdchron = "" then formattedTextChron := " Nothing found. Does the patient have an illness that can be considered a chronic illness as defined by protocol? "; + else formattedtextChron := holdchron; + endif; + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Pneumo Chronic Ill FT"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := formattedTextChron; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + + +// Chronic Illness Prevnar + + +// Select the Chronic Illness Prevnar YES radio button if one is found (only if no button has been peviously selected) + + If chronicprevnar = "something found" then + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Pneumo Chronic Illness Prevnar y/n"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "yes" and chronicillnessprevnar_found > 0 + then selectedItem.IsSelected := true; chronicprevnar := "true"; + endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + + + +// Populate the Chronic Illnesses for Prevnar Information box + + holdchronprevnar:=""; + if chronicillnessprevnar_found > 0 then + for k in (1 seqto (chronicillnessprevnar_found )) do + if chronicillnessprevnar[k] is not null then + holdchronprevnar := holdchronprevnar || chronicillnessprevnar[k] ; + if k <> chronicillnessprevnar_found then // not the last in the list + holdchronprevnar := holdchronprevnar || ", "; + endif; + endif; + enddo; + endif; + if holdchronprevnar = "" then formattedTextChronPrevnar := " Nothing found. "; + else formattedTextChronPrevnar := holdchronprevnar; + endif; + + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Pneumo Chronic Ill FT Prevnar"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := formattedTextChronPrevnar; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + + +// Date + + +// First determine which of the 3 dates is latest (Pneumococcal given, charted, or health issue) + + match1 := false; + match2 := false; + match3 := false; + nodates:= false; + + If vaccinegivenwhen is null and vaccinehealthissuedate is null and vaccinechartedwhen is null + then nodates := true; endif; + + If vaccinegivenwhen is null then vaccinegivenwhen := 1800-01-01T00:00:00; endif; + If vaccinehealthissuedate is null then vaccinehealthissuedate := 1800-01-01T00:00:00; endif; + If vaccinechartedwhen is null then vaccinechartedwhen := 1800-01-01T00:00:00; endif; + + match1 := vaccinegivenwhen IS AFTER vaccinehealthissuedate; + + If match1 = true + then match2 := vaccinegivenwhen IS AFTER vaccinechartedwhen; + else match3 := vaccinehealthissuedate IS AFTER vaccinechartedwhen; + endif; + + If match2 = true then givenwins := true; endif; + If match3 = true then healthissuewins := true; endif; + If (match2 = false) and (match3 = false) then chartedwins := true; endif; + + + if nodates = false then + If givenwins = true then latestdate := vaccinegivenwhen; endif; + If healthissuewins = true then latestdate := vaccinehealthissuedate; endif; + If chartedwins = true then latestdate := vaccinechartedwhen; endif; + endif; + + + +// Populate Date field + + +// First determine if the field has been manually updated by the nurse (not empty) + + theParameter := first of (thisParameters where thisParameters.Name = "SCHCK_Vaccine Received Date 2"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + datefieldcontents := theObservation.ValueObj.Value; + + if datefieldcontents is null + then datefield := latestdate; + else datefield := datefieldcontents; + endif; + +// Populate the field if history is found in SCM and the field hasn{{{SINGLE-QUOTE}}}t been overriden by the nurse (not empty) + + If latestdate is not null and datefieldcontents is null + then + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Vaccine Received Date 2"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "DateValue"; + this_currentObj.ValueObj := New DateValueType; + this_currentObj.ValueObj.Value := latestdate; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + + + + + +// REASSESS ONLY SECTION + + + elseIf MLMAction = "Reassess Only" then + + + +// Determine which of the chronic illness buttons is selected + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Pneumo has Chronic Illness y/n"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true not in (theObservation.ValueObj.ListItemsList.IsSelected) + then chronic := "unknown"; + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then chronic := "true"; + else chronic := "false"; + endif; + + +// Determine which of the chronic illness for Prevnare buttons is selected + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Pneumo Chronic Illness Prevnar y/n"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true not in (theObservation.ValueObj.ListItemsList.IsSelected) + then chronicprevnar := "unknown"; + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then chronicprevnar := "true"; + else chronicprevnar := "false"; + endif; + + + +// Determine if any of the Contraindications boxes are checked + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_pneumo vac contra"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true not in (theObservation.ValueObj.ListItemsList.IsSelected) + then contraboxchecked := "unknown"; + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "none") + then contraboxchecked := "false"; + else contraboxchecked := "true"; + endif; + + +// Determine the value of the date given field + + theParameter := first of (thisParameters where thisParameters.Name = "SCHCK_Vaccine Received Date 2"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + datefield := theObservation.ValueObj.Value; + if datefield is null then datefield := "unknown"; endif; + + +// If Date was changed and the value is a date, Unhide the vaccine type fields + + + If trigger = "Date was changed" /* and datefield <> "unknown" */ then + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Vaccine Types Unhide"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if datefield <> "unknown" then selectedItem.IsSelected := true; else selectedItem.IsSelected := false; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; + + + + + +// Determine which of the Prevnar allergy buttons is selected + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Pneumo Allergy DT y/n"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true not in (theObservation.ValueObj.ListItemsList.IsSelected) + then prevnarallergy := "unknown"; + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then prevnarallergy := "true"; + else prevnarallergy := "false"; + endif; + + + + + endif; // End of "Reassess Only" Section + + + + + +// ASSESS THE RISK SECTION ("Retrieve and Reassess" or "Reassess Only") + + + if MLMAction = "Retrieve and Reassess" or MLMAction = "Reassess Only" then + + + +// Age + +(dob,dob65,patientage) := read last + { +" select " +||" case when birthmonthnum <10 then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}end + cast (birthmonthnum as varchar) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +||" case when birthdaynum <10 then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}end + cast (birthdaynum as varchar) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +||" cast (birthyearnum as varchar) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}}, " +||" cast (birthyearnum + 65 as varchar) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +||" case when birthmonthnum <10 then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}end + cast (birthmonthnum as varchar) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +||" case when birthdaynum <10 then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}end + cast (birthdaynum as varchar) + {{{SINGLE-QUOTE}}}T00:00:00{{{SINGLE-QUOTE}}}, " +||" case when " +||" right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (datepart (MM,getdate()) as varchar),2) + right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (datepart (DD,getdate()) as varchar),2) < " +||" right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (birthmonthnum as varchar),2) + right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (birthdaynum as varchar),2) " +||" then datediff (yy, cast (birthyearnum as varchar) ,getdate()) -1 " +||" else datediff (yy, cast (birthyearnum as varchar) ,getdate()) " +||" end " +||" from cv3client with (nolock) where guid = " || ClientGuid || " " +}; + + +// Determine the age range of the patient + + if (patientage as number) < agerange2_lowerlimit then agerange := "1"; agerangenote := agerange1note; endif; + if (patientage as number) >= agerange2_lowerlimit and (patientage as number) < agerange3_lowerlimit then agerange := "2"; agerangenote := agerange2note; endif; + if (patientage as number) >= agerange3_lowerlimit then agerange := "3"; agerangenote := agerange3note; endif; + + + // set to unknown to satisfy conditions below + + if datefield is null then datefield := "unknown"; endif; + + + + +//  Risk Scenarios + + +//  Scenarios that will cause an order to be placed + + + +If agerange = "3" and datefield = "unknown" then ordervaccine := "yes"; orderprevnar := "yes"; +formattedTextReason := "Y-1. Order is to be placed since patient is over 65 and has never received a vaccine." ; endif; + +If agerange = "2" and chronic = "true" and datefield = "unknown" then ordervaccine := "yes"; orderpneumovax := "yes"; +formattedTextReason := "Y-3. Order is to be placed since patient is 5 to 64, has a chronic illness.and has not received the vaccine." ; endif; + + +//  Scenarios that will NOT cause an order to be placed + + +If agerange = "2" and chronic = "false" then ordervaccine := "no"; orderpneumovax := "no"; +formattedTextReason := "N-1. There are no Health Issues in SCM indicating that the patient has a chronic illnesses or is immunocompromised."; endif; + +If datefield <> "unknown" then ordervaccine := "no"; orderpneumovax := "no"; +formattedTextReason := "N-2. Order is not to be placed since patient has received the vaccine. " ; endif; + +If agerange = "1" then ordervaccine := "no"; orderpneumovax := "no"; +formattedTextReason := "N-5. Order is not to be placed since patient is under 5." ; endif; + + + + +// Scenarios that will recommend an upgrade to Prevnar + +If ordervaccine = "yes" and chronicprevnar = "true" and (prevnarallergy = "false" or prevnarallergy is null or prevnarallergy is "unknown") then orderprevnar := "yes"; /*ordervaccine := "no";*/ orderpneumovax := "no"; +formattedTextReason := "Y-9. Prevnar is recommmended as a (prevnar) chronic issue has been found." ; endif; + + + +//  Scenarios that will disqualify the use of Prevnar. Pneumovax is recommended. + + +If ordervaccine = "yes" and prevnarallergy = "true" then /* ordervaccine := "yes";*/ orderpneumovax := "yes"; orderprevnar := "no"; +formattedTextReason := "N-9. The patient is allergic to Prevnar. Pneumovax is recommended."; endif; + + + + +// Special Handling for Place Order Button Changes + + + + If trigger = "Recommend Button NO was selected" and (orderpneumovax = "yes" or orderprevnar = "yes") then + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n This patient meets the criteria for a vaccination order. \n\n Select ""Refuses Pneumococcal Vaccine"" if an order is not to be entered. ", "Error","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + formattedTextReason := formattedTextReason || " ** FAILED OVERRIDE TO NO BY " || userId || " ** "; endif; + + If trigger = "Recommend Pneumovax Button was selected" and (ordervaccine = "no" or orderprevnar = "yes") then + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n You cannot recommend an order for this patient. ", "Error","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + formattedTextReason := formattedTextReason || " ** FAILED OVERRIDE TO YES BY " || userId || " ** "; endif; + + If trigger = "Recommend Prevnar Button was selected" and (ordervaccine = "no" or orderpneumovax = "yes") then + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n You cannot recommend an order for this patient. ", "Error","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + formattedTextReason := formattedTextReason || " ** FAILED OVERRIDE TO YES BY " || userId || " ** "; endif; + + + + + + endif; // end of section for assessing risk + + endif; // End of Bypass Everything (If MLMAction <> "No Assessment Required") + + + + +// FOR ANY OBSERVATION CHANGE + + +// Select the appropriate Order Pneumococcal radio button determined by the assessment + + + If contraboxchecked = "true" then ordervaccine := "no"; + formattedTextReason := "N-7. Order will not be placed since the vaccine is contraindicated."; endif; + + + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Pneumo vac recommend"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "Pneumovax 23" and orderpneumovax = "yes" then selectedItem.IsSelected := true; endif; + if selectedItem.Value = "Prevnar 13" and orderprevnar = "yes" then selectedItem.IsSelected := true; endif; + if selectedItem.Value = "No" and ordervaccine = "no" /* and orderprevnar = "no"*/ then selectedItem.IsSelected := true; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + +// Appropriately set the hidden Allergy button + + if orderprevnar = "yes" then + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Pneumo DT Allergy Unhide"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := true; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; + +// Appropriately set the hidden Chronic Illness Mandatory button + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Pneumo CI- unknown"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if chronic = "unknown" and contraboxchecked = "false" + then selectedItem.IsSelected := true; + else selectedItem.IsSelected := false; + endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + +endif; // End of Observation Event section + + + + + +// DOCUMENT CLOSING SECTION + + +IF thisdocumentCommunication.EventType = "DocumentClosing" then + + issuename := ""; + +// Determine which vaccine button (if any) is selected + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Pneumo Vaccine Type"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Pneumococcal Vaccine (type unknown)") + then issuename := "Pneumococcal Vaccine"; + endif; + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Pneumovax 23 (Pneumococcal Polysaccharide Vaccine, PPV 23)") + then issuename := "Pneumococcal polysaccharide PPV23"; + endif; + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Prevnar 13 (Pneumococcal Conjugate Vaccine, PCV 13)") + then issuename := "Pneumococcal conjugate PCV13"; + endif; + + + +// If one of the buttons is selected, then create a new health issue + + + If issuename <> "" + + then + + try + NewHealthIssueHIType := "Vaccine History"; + NewHealthIssueHICode := "V03.82"; + NewHealthIssueHIScheme := "Vaccine History"; + + theParameter := first of (thisParameters where thisParameters.Name = "SCHCK_Vaccine Received Date 2"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + vaccinedate_other_cp := theObservation.ValueObj.Value; + + vaccineyy := EXTRACT Year (vaccinedate_other_cp as time); + vaccinemm := EXTRACT Month (vaccinedate_other_cp as time); + vaccinedd := EXTRACT Day (vaccinedate_other_cp as time); + + Terms := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.FindIMOTerms with (NewHealthIssueHIScheme,NewHealthIssueHICode); + + FOR i IN 1 SEQTO (Terms.Count as Number ) DO + + HI_obj := Terms[i]; + HI_Name := HI_obj.TermName as string; + + If HI_Name = issuename + then HI_NO := i ; + Endif; + + ENDDO; + + If HI_NO is Null + then HI_NO :=1 ; + Endif; + + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((thisdocumentCommunication.ClientVisitGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with (client_visit_obj, NewHealthIssueHIType, Terms[HI_NO]); + + + PartialDate_obj := new net_object {{{SINGLE-QUOTE}}}PartialDate{{{SINGLE-QUOTE}}} with (vaccineyy as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, vaccinemm as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, vaccinedd as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}} ); + + New_HealthIssue_obj.OnsetDate := PartialDate_obj; + New_HealthIssue_obj.Text := "Patient stated that vaccine was given by another provider "; + New_HealthIssue_obj.Name := issuename; + + + if ( New_HealthIssue_obj is NOT NULL ) then + void := call New_HealthIssue_obj.Save; + void := call New_HealthIssue_obj.Dispose; + endif; + + endtry; + + catch exception ex + error_occurred := true; + if ( New_HealthIssue_obj is NOT NULL ) then void:= call New_HealthIssue_obj.Dispose; New_HealthIssue_obj:= null; endif; + if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; + NewHealthIssue_dest := null; + endcatch; + + + endif; + + + + endif; // End of Close Document + + + + +// Populate the HIS only Assessment Information box + + +// This secton as well as the FormattedText1 := below are for diagnostic purposes only + +dateonly:= SUBSTRING 10 CHARACTERS FROM (datefield as string); +nowdateonly:= SUBSTRING 10 CHARACTERS FROM (now as string); + +Factor2 := "Chronic Condition - " || chronic; +Factor5 := "Contraindicated - "|| contraboxchecked; +Factor8 := "Last Given - " || dateonly; +Factor9 := "Last Trigger Event - " || nowdateonly || " " || trigger || " by " || userid || " (MLM reaction - " || MLMAction || ")"; +Factor14:= "Age - " || patientage; +Factor18:= "range " || agerange || " (" || agerangenote || ")"; + + +formattedText1 := "\n\n" || Factor9 || + "\n\n" || Factor14|| " " || Factor18|| + "\n" || Factor5 || " " || Factor2 || + "\n" || Factor8 ; + +formattedTextReason := formattedTextReason || formattedText1; + +this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Pneumo Risk Assess Details"); +this_currentObj := NEW ObservationType; +this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; +this_currentObj.ParameterGUID := this_parametername.ParameterGUID; +this_currentObj.DataType := "FreeTextValue"; +this_currentObj.ValueObj := New FreeTextValueType; +this_currentObj.ValueObj.Value := formattedTextReason; +thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_PNEUMOVAX_EPN.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_PNEUMOVAX_EPN.mlm new file mode 100644 index 0000000..a0c3bf4 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_PNEUMOVAX_EPN.mlm @@ -0,0 +1,324 @@ +maintenance: + + title: Pneumovax Logic for the Progress Note;; + mlmname: DOC_FUNC_PNEUMOVAX_EPN;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Don Warnick;; + specialist: ;; + date: 2015-12-16;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 12.16.2015 DW CSR# 33655 Previnar - Created + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + + + +// DOCUMENT OPENING SECTION + + +IF thisdocumentCommunication.EventType = "DocumentOpening" then + + + (OccCode, userName) := read last {" select OccupationCode, IDCode from CV3USER with (nolock) where guid = " || sql(userGuid) }; +// if ( OccCode = "IT" AND userName = "jlaw" ) then +// break; +// endif; + + // Search for a pneumococcal recommendation on a patient profile + + recommendedvaccine := read last + { " Select fsl.value " + || " from CV3ObsCatalogMasterItem ocmi with (nolock) " + || " join CV3ObservationDocument od with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " join CV3ClientDocDetailCUR cdd with (nolock) on cdd.CLientDocumentGUID = od.OwnerGUID and cdd.ClientGUID = " || ClientGuid || " " + || " join CV3ClientDocumentCUR cd with (nolock) on cd.GUID = cdd.ClientDocumentGUID AND cd.clientguid = cdd.ClientGUID and cd.ChartGUID = " || ChartGuid || " and cd.ClientVisitGUID = " || VisitGuid || " " + || " left join SCMObsFSListValues fsl with (nolock) on fsl.ParentGUID = od.ObservationDocumentGUID AND fsl.ClientGUID = " || ClientGuid || " " + || " where ocmi.name = {{{SINGLE-QUOTE}}}SCHCK_Pneumo vac recommend{{{SINGLE-QUOTE}}} and cd.DocumentName like {{{SINGLE-QUOTE}}}%profile%{{{SINGLE-QUOTE}}} " + || " and cd.iscanceled = 0 and cdd.active = 1 and od.Active = 1 " + }; + + + // Search for a pnumococcal vacccine resolution on an EPN. If one ia found the recommendation will not appear + + recommendationaddressed := read last + { " Select o.ValueText " + || " from CV3ObsCatalogMasterItem ocmi with (nolock) " + || " join CV3ObservationDocument od with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " join CV3ClientDocDetailCUR cdd with (nolock) on cdd.CLientDocumentGUID = od.OwnerGUID and cdd.ClientGUID = " || ClientGuid || " " + || " join CV3ClientDocumentCUR cd with (nolock) on cd.GUID = cdd.ClientDocumentGUID AND cd.clientguid = cdd.ClientGUID and cd.ChartGUID = " || ChartGuid || " and cd.ClientVisitGUID = " || VisitGuid || " " + || " join CV3Observation o with (nolock) on o.GUID = od.ObservationGUID " + || " where ocmi.name = {{{SINGLE-QUOTE}}}SCH_MDPN_Pneumo Ordered FT{{{SINGLE-QUOTE}}} and cd.DocumentName like {{{SINGLE-QUOTE}}}%progress%{{{SINGLE-QUOTE}}} and " + || " cd.iscanceled = 0 and cdd.active = 1 and od.Active = 1 " + }; + + + + // Select the "Pneumococcal Expand" radio button - When selected, vaccine ordering observations are displayed + + + If exists recommendedvaccine and recommendedvaccine <> "no" and not exists recommendationaddressed then + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_Pneumo_Expand"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := true; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + + + // Display the recommended vaccine type (Pneumococcal or Prevnar) for the user + + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Pneumo Recommend FT"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := recommendedvaccine; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + endif; // Docuement Open Section + + + + // CHART OBSERVATION SECTION + + + + + IF thisdocumentCommunication.EventType = "ChartObservation" then + + + // Determine if the Order or Deferr button was selected + + response := ""; + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_Pneumo Vaccine Order"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Order Vaccine") + then response := "Approved administration of "; + endif; + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Defer Vaccine") + then response := "Deferred administration of pneumonia vaccine"; + endif; + + + if response = "Approved administration of " then + + // Determine which Vaccine is recommended + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_Pneumo Recommend FT"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + vaccinerecommendation:= theObservation.ValueObj; + response := response || vaccinerecommendation.Value; + + endif; + + + // If the recommendation is addressed, store the response in a field to be saved to the note (to document the action and clear the recommendation) + + if response <> "" then + + // Populate the resonse field + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Pneumo Ordered FT"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := response; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; // Recommendation is addressed ? + + + endif; // End of Observation Event section + + + + + + // DOCUMENT CLOSING SECTION + + + + + IF thisdocumentCommunication.EventType = "DocumentClosing" then + + + (OccCode, userName) := read last {" select OccupationCode, IDCode from CV3USER with (nolock) where guid = " || sql(userGuid) }; +// if ( OccCode = "IT" AND userName = "jlaw" ) then +// break; +// endif; + + // Determine if Place Order button is set to "Yes" + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_Pneumo Vaccine Order"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Order Vaccine") + then placeorder := "yes"; endif; + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Defer Vaccine") + then placeorder := "no"; endif; + + + // Determine which Vaccine is recommended + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_Pneumo Recommend FT"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + vaccinerecommendation:= theObservation.ValueObj; + + + + // Check for existing Pneumococcal Order on the account + + (orderpresent) := read + { + " select o.name " + || " from cv3ordercatalogmasteritem as ocmi with (nolock) " + || " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid " + || " and o.ClientGUID = " || ClientGuid || " and o.ChartGUID = " || ChartGuid || " and o.ClientVisitGUID= " || VisitGuid || " " + || " and o.name like {{{SINGLE-QUOTE}}}Pneumococcal%{{{SINGLE-QUOTE}}} and o.name like {{{SINGLE-QUOTE}}}%Vaccine Inj{{{SINGLE-QUOTE}}} " + || " and o.OrderStatusLevelNum >= 15 and o.OrderStatusLevelNum not in (69, 70) " + }; + orderpresent_found := count(orderpresent) As Number; + + + // If no existing order is found and Place Order button is "Yes" then create a new order + + + If placeorder = "yes" and orderpresent_found = 0 then + + if vaccinerecommendation.value = "Pneumovax 23" then Catalog_Item_Name := "Pneumococcal Vaccine Inj"; Catalog_Item_Modifier := "0.5mL, IM, Once"; endif; + if vaccinerecommendation.value = "Prevnar 13" then Catalog_Item_Name := "Pneumococcal 13-Valent Vaccine Inj"; Catalog_Item_Modifier := "-"; endif; + + + SessionType := "Standard"; + SessionReason := ""; + RequestingSource := ""; + user_IDType := "Edstan Number (physician)"; + order_Creation_Reason := " "; + + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((thisdocumentCommunication.ClientVisitGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + RequestingCareProvider_obj:= call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((thisdocumentCommunication.UserGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + location_guid:= read last {"SELECT CurrentLocationGUID FROM CV3ClientVisit where ClientGUID = " || thisdocumentCommunication.ClientGUID}; + location_obj:= call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((location_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + + // Create a new MEDICATION order from a Pre-Filled item + try + Catalog_Item_Version := ""; + Medication_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with Catalog_Item_Name; + PreFilled_MedicationOrder_obj := call {{{SINGLE-QUOTE}}}MedicationOrder{{{SINGLE-QUOTE}}}.CreateMedicationOrder + with + client_visit_obj, // ClientVisit ObjectsPlus object + Medication_catalog_item, // OrderCatalogMasterItem ObjectsPlus object + Catalog_Item_Modifier, // string ItemNameModifier + Catalog_Item_Version, // string ItemNameModifierVersion + order_Creation_Reason, // string CreateReason + RequestingCareProvider_obj , // RequestedBy ObjectsPlus object + RequestingSource, // string RequestedBySource (must be in dictionary) + SessionType, // string SessionType + SessionReason, // string SessionReason + location_obj, // Location ReleaseLocGrpID + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; // AvailabilityOverride eAvailabilityOverride + + + if ( Medication_catalog_item is NOT NULL ) then + void := call PreFilled_MedicationOrder_obj.Save; + void := call PreFilled_MedicationOrder_obj.Dispose; + void:= call Medication_catalog_item.Dispose; + Medication_catalog_item:= null; + endif; + + + endtry; + + catch Exception ex error_occurred := true; error_message := "{{+R}}New prefilled medication order:{{-R}}\n" || ex.Message || "\n\n"; + + if ( Medication_catalog_item is NOT NULL ) then void:= call Medication_catalog_item.Dispose; Medication_catalog_item:= null; endif; + if ( PreFilled_MedicationOrder_obj is NOT NULL ) then void:= call PreFilled_MedicationOrder_obj.Dispose; PreFilled_MedicationOrder_obj:= null; endif; + + Prefilled_MedicationOrder_dest := null; + + endcatch; + + if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; + if ( RequestingCareProvider_obj is NOT NULL ) then void:= call RequestingCareProvider_obj.Dispose; RequestingCareProvider_obj:= null; endif; + if ( location_obj is NOT NULL ) then void:= call location_obj.Dispose; location_obj:= null; endif; + + + endif; // End of Place Order = Yes section + + + endif; // End of Close Document + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_POLST.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_POLST.mlm new file mode 100644 index 0000000..fe0369d --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_POLST.mlm @@ -0,0 +1,301 @@ +maintenance: + + title: DOC_FUNC_POLST;; + mlmname: DOC_FUNC_POLST;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Don Warnick;; + specialist: ;; + date: 2012-08-13;; + validation: testing;; + +library: + purpose: + ;; + explanation: This MLM manages the POLST portion of the Patient Profiles. + It will make an order if a request for infomration is charted....this makes a worklist task + + + Change history + + 08.13.2012 DW CSR# 30902 - Copied from Doc_Func_Advance_Directive + 10.23.2017 JML CSR# 26413 - Modified to include POLST scanning + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + + // DOCUMENT OPENING SECTION + IF thisdocumentCommunication.EventType = "DocumentOpening" then + + // Initialize the "POLST Order" button + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_POLST Order Patient Profile"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if selectedItem.Value = "-" then + selectedItem.IsSelected := false; + endif; + + listItems := (listItems, selectedItem); + ENDDO; + + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + // Check to see if there is a POLST on file comment = Y on file + (POLSTOnFile) := read {" select text from CV3CommentDeclaration with (nolock) where TypeCode = {{{SINGLE-QUOTE}}}POLSTONFILE{{{SINGLE-QUOTE}}} and clientguid = " || ClientGuid || " and TEXT = {{{SINGLE-QUOTE}}}Y{{{SINGLE-QUOTE}}}" }; + + // Check to see if the "on file at on file at St. Clair Hospital" button was previously checked. If so set Onfilechecked_before = yes. + Onfilechecked_before:= "no"; + Onfilechecked_after := "no"; + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Yes_POLST"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "on file at St. Clair Hospital") then + Onfilechecked_before := "yes"; + else + Onfilechecked_before := "no"; + endif; + + // If there is an Advance Directive comment = Y on file the select the appropriate radio buttons and set Onfilechecked_after = "yes" + if exist POLSTOnFile then + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_POLST_Question"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if selectedItem.Value = "Has Penna Orders for Life Sustaining Treatment (POLST)" then + selectedItem.IsSelected := true; + endif; + + listItems := (listItems, selectedItem); + ENDDO; + + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Yes_POLST"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if selectedItem.Value = "on file at St Clair Hospital" then + selectedItem.IsSelected := true; + Onfilechecked_after := "yes"; + endif; + + listItems := (listItems, selectedItem); + ENDDO; + + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + // Determine the Document name and whether the user is a nurse + DocumentName:= thisDocumentCommunication.documentname; + + if DocumentName in ("Adult Patient Profile - Behavioral Health Outpatient","Adult Patient Profile - Infusion") then + suppressforthisdocument := "yes"; + else + suppressforthisdocument := "no"; + endif; + + theParameter := first of (thisparameters where thisparameters.Name = "sch_notmandatory1"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") then + nurse := "yes"; + else + nurse := "no"; + endif; + + // Display message box reminder if approriate Document Name, User is RN, and the "request for info button" was changed from no to yes + if Onfilechecked_before = "no" and Onfilechecked_after = "yes" and nurse = "yes" and suppressforthisdocument = "no" then + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n There is a scanned POLST document on file. \n\n Retrieve the most current document, print it and place it on the chart" , "Reminder","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + endif; + endif; + + +// CHART OBSERVATION SECTION + + +IF thisdocumentCommunication.EventType = "ChartObservation" then + +// "No POLST" Buttons Section + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_No_Polst"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + then + + // "Requests Information on how to complete polst" button Section (Update the "POLST Order" button) + a := theObservation.ValueObj.ListItemsList.IsSelected; + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "requests information on how to complete polst") + then RequestForInformationSelected := "yes"; else RequestForInformationSelected := "no"; endif; + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_POLST Order Patient Profile"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "-" and RequestForInformationSelected = "yes" then selectedItem.IsSelected := true; else selectedItem.IsSelected := false; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; // "Requests information..." button is selected + +endif; // CHART OBSERVATION SECTION + + + +// DOCUMENT CLOSING SECTION + + +IF thisdocumentCommunication.EventType = "DocumentClosing" then + +// If the "POLST Order" button is set to "Yes", then make a new order + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_POLST Order Patient Profile"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "-") + then placeorder := "yes"; else placeorder := "no"; + endif; + + If placeorder = "yes" + then + try + + NextHour:= EXTRACT HOUR currenttime + 1 || ":00"; + + SessionType := "Standard"; + SessionReason := ""; + RequestingSource := ""; + user_IDType := "Edstan Number (physician)"; + order_Creation_Reason := "From Test MLM"; + orderItemName := "Patient requests information on completing POLST"; + Catalog_Item_Modifier := NextHour; + Catalog_Item_Version := ""; + + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((thisdocumentCommunication.ClientVisitGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + user_IDCode := read last {"SELECT IDCode FROM CV3User " || " where GUID = " || thisdocumentCommunication.UserGUID}; + RequestingCareProvider_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindById with ( user_IDType, (user_IDCode as STRING) ); + location_guid := read last {"SELECT CurrentLocationGUID FROM CV3ClientVisit where ClientGUID = " || thisdocumentCommunication.ClientGUID}; + location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((location_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + general_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with orderItemName; + + GeneralOrder_Obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder + with client_visit_obj, + general_catalog_item, + Catalog_Item_Modifier, + Catalog_Item_Version, + order_creation_reason, + RequestingCareProvider_obj, + RequestingSource, + SessionType, + SessionReason, + location_obj, + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; + + void := call GeneralOrder_Obj.Save; + void := call GeneralOrder_Obj.Dispose; + + endtry; + + // Exception Handling + catch Exception ex + debugFlag := true; + messageText := messageText || "New General Order:\n" || ex.Message || "\n\n"; + endcatch; + + // Clean UP + if (location_obj IS NOT NULL) then void := call location_obj.Dispose; location_obj := NULL; endif; + if (requesting_care_provider_obj IS NOT NULL) then void := call requesting_care_provider_obj.Dispose; requesting_care_provider_obj := NULL; endif; + if (general_catalog_item IS NOT NULL) then void := call general_catalog_item.Dispose; general_catalog_item := NULL; endif; + if (client_visit_obj IS NOT NULL) then void := call client_visit_obj.Dispose; client_visit_obj := NULL; endif; + + endif; // End of Place Order = Yes section + + endif; // End of Close Document + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_POLST_FOLLOWUP_CHARTING_REMINDER.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_POLST_FOLLOWUP_CHARTING_REMINDER.mlm new file mode 100644 index 0000000..e522bdf --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_POLST_FOLLOWUP_CHARTING_REMINDER.mlm @@ -0,0 +1,164 @@ +maintenance: + + title: DOC_FUNC_POLST_FOLLOWUP_CHARTING_REMINDER;; + mlmname: DOC_FUNC_POLST_FOLLOWUP_CHARTING_REMINDER;; + arden: version 2.5;; + version: 5.50;; + institution: Allscripts;; + author: Juliet Law;; + specialist: Peggy Lechak;; + date: 2017-10-26;; + validation: testing;; + +library: + purpose: Remind the nurse to chart that they have followed up with the familiy on the need to bring in the patient{{{SINGLE-QUOTE}}}s POLST + ;; + explanation: Upon open of the Adult Assessment/Intervention Flowsheet remind the nurse that the patient family is to bring in the POLST and charted follow up must occur + + Change history + + 10.26.2017 JML CSR# 26413 POLST Follow Up Created - copied from DOC_FUNC_ADVANCE_DIRECTIVE_FOLLOWUP_CHARTING_REMINDER + + ;; + keywords: braden, alert, flowsheet + ;; +knowledge: + type: data-driven;; + data: + + (this_documentCommunication) := argument; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + msg := ""; + + //Set constants indicating document type and event + FLOWSHEET := "Flowsheet"; + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTCLOSING := "DocumentClosing"; + + // Get the client and visit GUIDs + client_guid := this_documentCommunication.ClientGUID; + client_visit_guid := this_documentCommunication.ClientVisitGUID; + chart_guid := this_documentCommunication.ChartGUID; + user_guid := this_documentCommunication.UserGUID; + + //Retrieve DocumentType (StructuredNote or Flowsheet) and EventType + this_DocumentType := this_documentCommunication.DocumentType; + this_EventType := this_documentCommunication.EventType; + + OccCode := read last {" select OccupationCode from CV3USER with (nolock) where guid = " || sql(user_guid) }; + + if ( OccCode IN ("RN","GN","LPN","IT") ) then + + (POLSTDate, + POLSTStatus, + currentdate) := read last {"select distinct case when cd.DocumentName is not null and com.text IS null then convert(date, fsl.TouchedWhen,112) " + || " when cd.DocumentName is not null and com.text = {{{SINGLE-QUOTE}}}Y{{{SINGLE-QUOTE}}} and com.typecode = {{{SINGLE-QUOTE}}}POLSTONFILE{{{SINGLE-QUOTE}}} then convert(date, com.TouchedWhen,112) " + || " end , " + || " case when cd.DocumentName is not null and com.text IS null and ocmi.name IN ({{{SINGLE-QUOTE}}}SCHCK_Yes_POLST{{{SINGLE-QUOTE}}}) then {{{SINGLE-QUOTE}}}Instructed to bring in copy of POLST{{{SINGLE-QUOTE}}} " + || " when cd.DocumentName is not null and com.text IS null and ocmi.name IN ({{{SINGLE-QUOTE}}}SCHCK_POLST_Question{{{SINGLE-QUOTE}}}) and fsl.value = {{{SINGLE-QUOTE}}}Unable to obtain due to patient condition{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}Unable to obtain POLST due to patient condition{{{SINGLE-QUOTE}}} " + || " when cd.DocumentName is not null and com.text = {{{SINGLE-QUOTE}}}Y{{{SINGLE-QUOTE}}} and com.typecode = {{{SINGLE-QUOTE}}}POLSTONFILE{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}A copy has been scanned. Please update the Patient Profile{{{SINGLE-QUOTE}}} " + || " end , " + || " convert(date,getdate(),112) " + || " from CV3ClientDocument cd with (nolock) join CV3ClientDocDetail cdd with (nolock) ON cd.GUID = cdd.ClientDocumentGUID" + || " AND cd.ClientGUID = cdd.ClientGUID AND cd.ArcType = cdd.ArcType" + || " join CV3ObservationDocument od with (nolock) ON cdd.CLientDocumentGUID = od.OwnerGUID " + || " AND cdd.ArcType = od.ArcType" + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " join CV3Observation o with (nolock) ON od.ObservationGUID = o.GUID" + || " join cv3obscatalogitem oci with (nolock) ON o.ObsItemGUID = oci.GUID " + || " join SCMObsFSListValues fsl with (nolock) ON od.ObservationDocumentGUID = fsl.ParentGUID" + || " AND cd.ClientGUID = fsl.ClientGUID" + || " left join CV3CommentDeclaration com with (nolock) ON cd.ClientGUID = com.ClientGUID" + || " and com.TEXT = {{{SINGLE-QUOTE}}}Y{{{SINGLE-QUOTE}}} and com.touchedwhen > fsl.touchedwhen and com.typecode = {{{SINGLE-QUOTE}}}POLSTONFILE{{{SINGLE-QUOTE}}} " + || " where cd.clientguid = " || SQL(client_guid) + || " and cd.ChartGUID = " || SQL(chart_guid) + || " and cd.ClientVisitGUID = " || SQL(client_visit_guid) + || " and cd.DocumentName like {{{SINGLE-QUOTE}}}%Patient Profile%{{{SINGLE-QUOTE}}} " + || " AND cdd.Active = 1" + || " AND od.Active = 1" + || " AND ocmi.name in ({{{SINGLE-QUOTE}}}SCHCK_Yes_POLST{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}SCHCK_POLST_Question{{{SINGLE-QUOTE}}})" + || " AND ( fsl.value = {{{SINGLE-QUOTE}}}instructed to bring a copy to the hospital{{{SINGLE-QUOTE}}} " + || " or fsl.value = {{{SINGLE-QUOTE}}}Unable to obtain due to patient condition{{{SINGLE-QUOTE}}})" + || " and cd.CreatedWhen = (select top 1 cdx.CreatedWhen " + || " from CV3ClientDocument cdx with (nolock) " + || " where cdx.clientguid = " || SQL(client_guid) + || " and cdx.ChartGUID = " || SQL(chart_guid) + || " and cdx.ClientVisitGUID = " || SQL(client_visit_guid) + || " and cdx.DocumentName like {{{SINGLE-QUOTE}}}%Patient Profile%{{{SINGLE-QUOTE}}})"}; + + + (FollowupChartingDate, + FollowupChartingStatus, + currentdate2) := read last {"set concat_null_yields_null off " + || " select convert(date, cd.AuthoredDtm,112) {{{SINGLE-QUOTE}}}Timestamp{{{SINGLE-QUOTE}}}, " + || " cast (o.ValueText as varchar(2000)) + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + cast (fsl.value as varchar (2000)) {{{SINGLE-QUOTE}}}Value{{{SINGLE-QUOTE}}}, " + || " convert(date,getdate(),112) " + || " from CV3ClientDocument cd with (nolock) join CV3ClientDocDetail cdd with (nolock) ON cd.GUID = cdd.ClientDocumentGUID" + || " AND cd.ClientGUID = cdd.ClientGUID AND cd.ArcType = cdd.ArcType" + || " join CV3ObservationDocument od with (nolock) ON cdd.CLientDocumentGUID = od.OwnerGUID " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) ON od.ObsMasterItemGUID = ocmi.GUID " + || " join CV3Observation o with (nolock) ON od.ObservationGUID = o.GUID " + || " join cv3obscatalogitem oci with (nolock) ON o.ObsItemGUID = oci.GUID" + || " left join cv3obscatalogset ocs with (nolock) ON od.ObsSetGUID = ocs.GUID" + || " left join SCMObsFSListValues fsl with (nolock) ON od.ObservationDocumentGUID = fsl.ParentGUID" + || " AND cd.ClientGUID = fsl.ClientGUID" + || " where cd.clientguid = " || SQL(client_guid) + || " and cd.ChartGUID = " || SQL(chart_guid) + || " and cd.ClientVisitGUID = " || SQL(client_visit_guid) + || " and od.active = 1 " + || " and cdd.active = 1 " + || " and cd.IsCanceled = 0 " + || " and ocmi.description in ({{{SINGLE-QUOTE}}}SCHCK_AS POLST FU{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCHCK_Yes_POLST{{{SINGLE-QUOTE}}})" + || " and cd.DocumentName = {{{SINGLE-QUOTE}}}2. Adult Assessment/Intervention{{{SINGLE-QUOTE}}} " + || " order by ocmi.description , cd.authoreddtm"}; + + + // Determine if an alert should fire. + if exists POLSTStatus and POLSTStatus = "Instructed to bring in copy of POLST" and currentdate > POLSTDate then + potential_alert := "yes"; + else + potential_alert := "no"; + endif; + + if exists FollowupChartingStatus and FollowupChartingStatus = "Patient/Family reminded to bring in copy of the POLST" then + suppress_alert1 := "yes"; + else + suppress_alert1 := "no"; + endif; + + if exists FollowupChartingStatus and FollowupChartingStatus = "Unable to contact family" and currentdate2 = FollowupChartingDate then + suppress_alert2 := "yes"; + else + suppress_alert2 := "no"; + endif; + + If (Extract Hour NOW) in (0,1,2,3,4,5,6,7) then + suppress_alert3 := "yes"; + else + suppress_alert3 := "no"; + endif; + + if potential_alert = "yes" and (suppress_alert1 = "no" and (suppress_alert2 = "no" and suppress_alert3 = "no")) then + msg := " Reminder: POLST Follow-up has not been documented"; + dialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with msg, "POLST Follow up Charting Required", "Ok" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + + + endif; // occupation + + + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: + return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_PREFERRED_PHARMACY_TEXT_BOX.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_PREFERRED_PHARMACY_TEXT_BOX.mlm new file mode 100644 index 0000000..7ec4b4e --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_PREFERRED_PHARMACY_TEXT_BOX.mlm @@ -0,0 +1,105 @@ +maintenance: + + title: DOC_FUNC_PREFERRED_PHARMACY_TEXT_BOX ;; + mlmname: DOC_FUNC_PREFERRED_PHARMACY_TEXT_BOX ;; + arden: version 2.5;; + version: 1.00;; + institution: ;; + author: Sandy Zhang ;; + specialist: Rob Stewart ;; + date: 2017-06-21;; + validation: testing;; + +library: + purpose: Fills in the preferred pharmacy text box in several adult patient profile structured notes. + ;; + explanation: + + Change history + + 06.21.2017 SZ CSR #35712: Preferred Pharmacy Text Box + 07.26.2017 SZ CSR #35278: Care Transitions note + + ;; + keywords: + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + // Standard includes + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + if called_by_editor then + clientGuid := 9000002225000200; + endif; + + // SQL to grab the full pharmacy address + (pharmacy_name, pharmacy_address_1, pharmacy_address_2, pharmacy_city, pharmacy_state, pharmacy_zip_code) := read last { + + "select p.PharmacyName, p.Address1, p.Address2, p.City, p.CountryDvsnCode, p.PostalCode" + ||" from SXAAMBClientPharmacyXREF cp" + ||" join SXAAMBPharmacy p on cp.PharmacyID = p.PharmacyID" + ||" where ClientGUID = " || sql(clientGuid) + ||" and cp.IsPreferred = 1" + + }; + + // if second line of pharmacy address does not exist then set it to blank so {{{SINGLE-QUOTE}}}null{{{SINGLE-QUOTE}}} is not printed + if not exists pharmacy_address_2 then + pharmacy_address_2 := ""; + endif; + + // if pharmacy name does not exist then set the address to blank, otherwise format the full pharmacy address + if not exists pharmacy_name then + full_pharm_address := ""; + else + full_pharm_address := pharmacy_name || " \n" || pharmacy_address_1 || " " || pharmacy_address_2 || ", " || pharmacy_city || ", " || pharmacy_state || ", " || pharmacy_zip_code; + endif; + + + // when document is opening, look for the preferred pharmacy text box parameter and populate it with the full pharmacy address if it exists + if thisdocumentCommunication.EventType = "DocumentOpening" then + + vitalSignsHL := first of (thisParameters where thisParameters.Name = "SCH_Preferred Pharmacy Text"); + + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := vitalSignsHL.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := full_pharm_address; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + endif; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_PREOPERATIVE_CHECKLIST.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_PREOPERATIVE_CHECKLIST.mlm new file mode 100644 index 0000000..5476a41 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_PREOPERATIVE_CHECKLIST.mlm @@ -0,0 +1,1243 @@ +maintenance: + + title: DOC_FUNC_PREOPERATIVE_CHECKLIST;; + mlmname: DOC_FUNC_PREOPERATIVE_CHECKLIST;; + arden: version 5.5;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Juliet Law;; + specialist: Dean Miklavic;; + date: 2012-02-29;; + validation: testing;; + +library: + purpose: + ;; + explanation: Limit Observation selections under the Fall Risk Medications to prevent erroneous selections. + Effects the Adult Patient Profile - Behavioral Health Outpatient document. + + Change history + + 02.21.2012 JML Create date. + 04.24.2012 JML Removed verbiage for any lab result not found; added logic to save document as Incomplete + if all observations were not valued. + 06.25.2012 JML Changes for PPC. + 08.08.2013 JML Changes for PPC 2 and Mgr. + + ;; + keywords: psych, outpatient, profile, fall risk, medications + ;; +knowledge: + type: data-driven;; + data: + + // Receive arguments from the structured note + (this_documentCommunication) := argument; + + // .Net assemblies required for ObjectsPlus + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + //Include MLM + str_parse := MLM {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; + + //Document Types + STRUCTUREDNOTE := "StructuredNote"; + + //Event Types + DOCUMENTCLOSING := "DocumentClosing"; + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTOPENING := "DocumentOpening"; + + //Setting debugFlag to True will allow popup dialogs containing debug information to appear + debugFlag := false; + + //List of Parameters + + // DocumentCommunication Object Model variables + (thisStructuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Get the client, visit, chart, and user GUIDs + clientGuid := this_documentCommunication.ClientGUID; + visitGuid := this_documentCommunication.ClientVisitGUID; + chartGuid := this_documentCommunication.ChartGUID; + userGuid := this_documentCommunication.UserGUID; + + //Set up debugging information to be captured + messageText := ""; + if (debugFlag = true) then + messageText := "Debug Information:\n\n"; + messageText := messageText || " DOC_FUNC_PREOPERATIVE_CHECKLIST mlm called.\n\n"; + endif; + + // Parameter that will trigger the restriction of the Fall Risk Medications values + theDocumentName := "Preoperative Checklist"; + isIncompleteFlag := false; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + //Retrieve Patient Gender, age, and ER location + (patientAge, gender, erLoc) := read {"SELECT TOP 1 CASE" + || " WHEN ((c.BirthMonthNum > MONTH(getdate())) " + || " OR (c.BirthMonthNum = MONTH(getdate()) and c.BirthDayNum > DAY(getdate()))) then" + || " Convert(char(3),(YEAR(getdate()) - c.BirthYearNum) - 1)" + || " ELSE" + || " Convert(char(3),(YEAR(GETDATE()) - c.BirthYearNum))" + || " END," + || " c.GenderCode," + || " CASE " + || " WHEN (l.Name LIKE {{{SINGLE-QUOTE}}}ER%{{{SINGLE-QUOTE}}}) THEN l.Name" + || " ELSE NULL" + || " END AS {{{SINGLE-QUOTE}}}LOCATION{{{SINGLE-QUOTE}}}," + || " cvl.Status, l.Name" + || " FROM CV3Client c WITH (NOLOCK) JOIN CV3ClientVisit cv WITH (NOLOCK)" + || " ON c.GUID = cv.ClientGUID" + || " JOIN CV3ClientVisitLocation cvl WITH (NOLOCK)" + || " ON cv.GUID = cvl.ClientVisitGUID" + || " AND cv.ClientGUID = cvl.ClientGUID" + || " JOIN CV3Location l WITH (NOLOCK)" + || " ON cvl.LocationGUID = l.GUID" + || " WHERE c.GUID = " || Sql(clientGuid) + || " AND cv.GUID = " || Sql(visitGuid) + || " AND cv.ChartGUID = " || Sql(chartGuid) + || " AND cvl.ClientLocnTypeCode <> {{{SINGLE-QUOTE}}}T{{{SINGLE-QUOTE}}}" + || "ORDER BY LOCATION DESC"}; + + patAge := first of (patientAge) as number; + patGender := first of (gender); + patLoc := first of (erLoc); + + //Only perform this MLM when charting an Observation on the Behavioral Health Outpatient patient profile + if (this_documentCommunication.EventType = DOCUMENTOPENING AND this_documentCommunication.DocumentName = theDocumentName) then + + //Retrieve type and screen + tsParameterName := "SCH_Preop_Type Screen Results"; + tsParameter := first of (thisParameters WHERE thisParameters.Name = tsParameterName); + + if (exists TSParameter) then + + (labName, + resulted, + textValue, + orderStatus) := read {"SELECT bo.ItemName, o.arrivaldtm," + || " IsNull(tol.Text,{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}), o.OrderStatusCode" + || " FROM cv3clientvisit cv WITH (NOLOCK) JOIN cv3order o WITH (NOLOCK) ON cv.clientguid = o.clientguid " + || " AND cv.GUID = o.ClientVisitGUID" + || " AND cv.chartguid = o.chartguid " + || " LEFT JOIN CV3BasicObservation bo WITH (NOLOCK) ON o.GUID = bo.OrderGUID" + || " AND o.ClientGUID = bo.ClientGUID " + || " AND o.ClientVisitGUID = bo.ClientVisitGUID" + || " AND o.ChartGUID = bo.ChartGUID" + || " AND bo.ItemName IN ({{{SINGLE-QUOTE}}}Blood Type (ABO/RH){{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Antibody Screen{{{SINGLE-QUOTE}}})" + || " LEFT JOIN CV3TextualObservationLine tol WITH (NOLOCK) ON bo.GUID = tol.ObservationGUID" + || " AND o.ClientGUID = tol.ClientGUID" + || " WHERE " + || " DateDiff(HH, o.ArrivalDtm, GetDate()) <= 72 " + || " AND cv.ClientGUID = " || SQL(clientGUID) + || " AND cv.GUID = " || SQL(visitGUID) + || " AND cv.ChartGUID = " || SQL(chartGUID) + || " AND o.orderstatuscode NOT LIKE {{{SINGLE-QUOTE}}}can%{{{SINGLE-QUOTE}}}" + || " AND o.name = {{{SINGLE-QUOTE}}}Type and Screen{{{SINGLE-QUOTE}}}" + || " AND cv.visitstatus <> {{{SINGLE-QUOTE}}}can{{{SINGLE-QUOTE}}}" + || " AND o.OrderStatusCode IN ({{{SINGLE-QUOTE}}}PERF{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}RESF{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}RESC{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PCOL{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}COLL{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}SPRV{{{SINGLE-QUOTE}}})" + || " ORDER BY o.ArrivalDtm DESC"}; + + + CR := 13 FORMATTED WITH "%c"; + LF := 10 FORMATTED WITH "%c"; + CRLF := CR||LF; + resultText := ""; + if (exists resulted) then + if (count resulted = 1) then + resultText := "Type and Screen "; + if (first of (orderStatus) = "PCOL" ) then + resultText := resultText || "Ordered On " || first of (resulted); + elseif ( first of (orderStatus) = "COLL" ) then + resultText := resultText || "Collected On " || first of (resulted); + elseif ( first of (orderStatus) = "SPRV" ) then + resultText := resultText || "Specimen Received On " || first of (resulted); + elseif ( first of (orderStatus) = "PERF" ) then + resultText := resultText || "Performed On " || first of (resulted); + endif; + else + for k in 1 seqto (count labName) do + if (orderStatus[k] = "RESF" OR orderStatus[k] = "RESC") then + resultText := labName[k] || " " || resulted[k] || ": " || textValue[k] || "; " || CRLF || resultText; + elseif (k = 1) then + resultText := "Type and Screen "; + if (orderStatus[k] = "PCOL" ) then + resultText := resultText || "Ordered On " || resulted[k]; + elseif ( orderStatus[k] = "COLL" ) then + resultText := resultText || "Collected On " || resulted[k]; + elseif ( orderStatus[k] = "SPRV" ) then + resultText := resultText || "Specimen Received On " || resulted[k]; + elseif ( orderStatus[k] = "PERF" ) then + resultText := resultText || "Performed On " || resulted[k]; + endif; + endif; + enddo; + endif; + + this_currentTSObs := NEW ObservationType; + this_currentTSObs.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentTSObs.ParameterGUID := tsParameter.ParameterGUID; + this_currentTSObs.DataType := "FreeTextValue"; + this_currentTSObs.ValueObj := NEW FreeTextValueType; + this_currentTSObs.ValueObj.Value := resultText; + + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentTSObs); + + endif; + + endif; //End tsParameter Exists + + //Retrieve hCG Pregnancy + hCGParameterName := "SCH_Preop_Pregnancy Results"; + hCGParameter := first of (thisParameters WHERE thisParameters.Name = hCGParameterName); + if (exists hCGParameter) then + + if ((patGender = "Female") AND (patAge >= 10 AND patAge <= 60)) then + //Check if patient was ever an ED patient + //If so, check for existence of BedSide Urine HCG on ED Vital Signs + checkOtherHcg := false; +/* + (patientLoc) := read {"SELECT l.Name" + || " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3ClientVisitLocation cvl WITH (NOLOCK)" + || " ON cv.GUID = cvl.ClientVisitGUID" + || " AND cv.ClientGUID = cvl.ClientGUID" + || " JOIN CV3Location l WITH (NOLOCK)" + || " ON cvl.LocationGUID = l.GUID" + || " WHERE cv.ClientGUID = " || Sql(clientGuid) + || " AND cv.GUID = " || Sql(visitGuid) + || " AND cv.ChartGUID = " || Sql(chartGuid) + || " AND l.Name LIKE {{{SINGLE-QUOTE}}}ER%{{{SINGLE-QUOTE}}}"}; +*/ + if (exists patLoc) then + + //Check for existence of BedSide Urine HCG + (labName, value, resulted) := read {"SELECT oci.Name, fsl.Value, od.RecordedDtm" + || " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3ClientDocumentCUR cd WITH (NOLOCK)" + || " ON cv.GUID = cd.ClientVisitGUID" + || " AND cv.ClientGUID = cd.ClientGUID" + || " AND cv.ChartGUID = cd.ChartGUID" + || " JOIN CV3ClientDocDetailCUR cdd WITH (NOLOCK)" + || " ON cd.GUID = cdd.ClientDocumentGUID" + || " AND cd.ClientGUID = cdd.ClientGUID" + || " JOIN CV3ObservationDocumentCUR od WITH (NOLOCK)" + || " ON cdd.ClientDocumentGUID = od.OwnerGUID" + || " LEFT JOIN SCMObsFSListValues fsl WITH (NOLOCK)" + || " ON od.ObservationDocumentGUID = fsl.ParentGUID" + || " AND cdd.ClientGUID = fsl.ClientGUID" + || " JOIN CV3ObsCatalogMasterItem ocmi WITH (NOLOCK)" + || " ON od.ObsMasterItemGUID = ocmi.GUID" + || " JOIN CV3ObservationCUR o WITH (NOLOCK)" + || " ON od.ObservationGUID = o.GUID" + || " JOIN CV3ObsCatalogItem oci WITH (NOLOCK)" + || " ON o.ObsItemGUID = oci.GUID" + || " WHERE cd.DocumentName = {{{SINGLE-QUOTE}}}1. Vital Sign - ED{{{SINGLE-QUOTE}}}" + || " AND cdd.Active = 1" + || " AND cv.ClientGUID = " || Sql(clientGuid) + || " AND cv.GUID = " || Sql(visitGuid) + || " AND cv.ChartGUID = " || Sql(chartGuid) + || " AND oci.Name = {{{SINGLE-QUOTE}}}sch_edvitalsign_bedsideHCG{{{SINGLE-QUOTE}}}"}; + + if (exists labName) then + resultText := "Bedside Urine HCG " || resulted[1] || ": " || value[1]; + + this_currentBedsideObs := NEW ObservationType; + this_currentBedsideObs.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentBedsideObs.ParameterGUID := hCGParameter.ParameterGUID; + this_currentBedsideObs.DataType := "FreeTextValue"; + this_currentBedsideObs.ValueObj := NEW FreeTextValueType; + this_currentBedsideObs.ValueObj.Value := resultText; + + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentBedsideObs); + else + //Patient IS ED patient and NO Bedside Urine, continue checking other labs + checkOtherHcg := true; + endif; + else + //Patient NOT ED patient, continue with checking other labs + checkOtherHcg := true; + endif; //ED patient location exists + + if (checkOtherHcg) then + //Retrieve hCG Pregnancy lab result + (labName, resulted, value) := read {"SELECT bo.ItemName," + || " Convert(varchar(25), o.arrivaldtm, 20)," + || " IsNull(bo.Value,{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}})" + || " FROM cv3clientvisit cv WITH (NOLOCK) JOIN cv3order o WITH (NOLOCK)" + || " ON cv.clientguid = o.clientguid " + || " AND cv.GUID = o.ClientVisitGUID" + || " AND cv.chartguid = o.chartguid " + || " JOIN CV3BasicObservation bo WITH (NOLOCK)" + || " ON o.GUID = bo.OrderGUID" + || " AND o.ClientGUID = bo.ClientGUID " + || " AND o.ClientVisitGUID = bo.ClientVisitGUID" + || " AND o.ChartGUID = bo.ChartGUID" + || " JOIN cv3ordercatalogmasteritem om WITH (NOLOCK)" + || " ON om.guid = o.ordercatalogmasteritemguid" + || " JOIN cv3organizationalunit org WITH (NOLOCK)" + || " ON org.guid = om.orgunitguid " + || " AND org.name = {{{SINGLE-QUOTE}}}Chemistry{{{SINGLE-QUOTE}}}" + || " JOIN cv3orderstatushistory oshentr WITH (NOLOCK)" + || " ON oshentr.orderguid = o.guid " + || " AND oshentr.OrderStatusCode = {{{SINGLE-QUOTE}}}RESF{{{SINGLE-QUOTE}}}" + || " WHERE cv.ClientGUID = " || Sql(clientGuid) + || " AND cv.GUID = " || Sql(visitGuid) + || " AND cv.ChartGUID = " || Sql(chartGuid) + || " AND o.orderstatuscode NOT LIKE {{{SINGLE-QUOTE}}}can%{{{SINGLE-QUOTE}}}" + || " AND o.name = {{{SINGLE-QUOTE}}}hCG Qualitative Urine (Pos/Neg){{{SINGLE-QUOTE}}}" + || " AND cv.visitstatus <> {{{SINGLE-QUOTE}}}can{{{SINGLE-QUOTE}}}"}; + + if (exists labName) then + resultText := labName[1] || " " || resulted[1] || ": " || value[1]; + + this_currentHCGObs := NEW ObservationType; + this_currentHCGObs.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentHCGObs.ParameterGUID := hCGParameter.ParameterGUID; + this_currentHCGObs.DataType := "FreeTextValue"; + this_currentHCGObs.ValueObj := NEW FreeTextValueType; + this_currentHCGObs.ValueObj.Value := resultText; + + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentHCGObs); + endif; + endif; //checkOtherHcg = true + else + hCGNAParameterName := "SCH_Preop_HCG N/A"; + hCGNAParameter := first of (thisParameters WHERE thisParameters.Name = hCGNAParameterName); + if (exists hCGNAParameter) then + this_currentObs := NEW ObservationType; + this_currentObs.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObs.ParameterGUID := hCGNAParameter.ParameterGUID; + this_currentObs.DataType := "ListValue"; + this_currentObs.ValueObj := NEW ListValueType; + this_currentObs.ValueObj.ListGUID := hCGNAParameter.ConfigurationObj.ListGUID; + listItems := (); + for item IN hCGNAParameter.ConfigurationObj.ListItemsList Do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if (selectedItem.Value = "N/A") then + selectedItem.IsSelected := true; + endif; + if (selectedItem.Value <> "N/A") then + selectedItem.IsSelected := false; + endif; + + listItems := (listItems, selectedItem); + enddo; + + this_currentObs.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentObs); + endif; //End hCGNAParameter Exists + endif; //End if patient is Female and between age 10 and 60 + endif; //End hCGParameter Exists + + //Retrieve History / Physical Document Existence + HPParameterName := "SCH_Preop_History Physical Results"; + HPParameter := first of (thisParameters WHERE thisParameters.Name = HPParameterName); + + if (exists HPParameter) then + (documentDate) := read {"SELECT cdd.CreatedWhen, cdd.TouchedWhen" + || " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3ClientDocumentCUR cd WITH (NOLOCK)" + || " ON cv.GUID = cd.ClientVisitGUID" + || " AND cv.ClientGUID = cd.ClientGUID" + || " AND cv.ChartGUID = cd.ChartGUID" + || " JOIN CV3ClientDocDetailCUR cdd WITH (NOLOCK)" + || " ON cd.GUID = cdd.ClientDocumentGUID" + || " AND cd.ClientGUID = cdd.ClientGUID" + || " WHERE cd.DocumentName like {{{SINGLE-QUOTE}}}%History/Physical%{{{SINGLE-QUOTE}}}" + || " AND cdd.Active = 1" + || " AND cv.ClientGUID = " || Sql(clientGuid) + || " AND cv.GUID = " || Sql(visitGuid) + || " AND cv.ChartGUID = " || Sql(chartGuid)}; + if (exists documentDate) then + resultText := "History / Physical has been dictated"; + + this_currentHPObs := NEW ObservationType; + this_currentHPObs.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentHPObs.ParameterGUID := HPParameter.ParameterGUID; + this_currentHPObs.DataType := "FreeTextValue"; + this_currentHPObs.ValueObj := NEW FreeTextValueType; + this_currentHPObs.ValueObj.Value := resultText; + + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentHPObs); + endif; + endif; //End HPParameter Exists + + //EKG 12 Lead Results + EkgParameterName := "SCH_Preop_EKG Results"; + EkgParameter := first of (thisParameters WHERE thisParameters.Name = EkgParameterName); + if (exists EkgParameter) then + + //Retrieve EKG 12 Lead results + (resulted, orderStatus) := read {"SELECT o.arrivaldtm, o.orderstatuscode" + || " FROM cv3clientvisit cv WITH (NOLOCK) JOIN cv3order o WITH (NOLOCK)" + || " ON cv.clientguid = o.clientguid" + || " AND cv.GUID = o.ClientVisitGUID" + || " AND cv.ChartGUID = o.ChartGUID" + || " JOIN cv3ordercatalogmasteritem om WITH (NOLOCK)" + || " ON om.guid = o.ordercatalogmasteritemguid" + || " JOIN cv3organizationalunit org WITH (NOLOCK)" + || " ON org.guid = om.orgunitguid" + || " AND org.name = {{{SINGLE-QUOTE}}}Cardiology{{{SINGLE-QUOTE}}}" + || " WHERE " + || " DateDiff(MONTH, o.ArrivalDtm, GETDATE()) <= 6" + || " AND " + || " cv.ClientGUID = " || Sql(clientGuid) + || " AND o.orderstatuscode NOT LIKE {{{SINGLE-QUOTE}}}can%{{{SINGLE-QUOTE}}}" + || " AND o.OrderStatusCode NOT LIKE {{{SINGLE-QUOTE}}}disc%{{{SINGLE-QUOTE}}}" + || " AND o.name = {{{SINGLE-QUOTE}}}EKG 12 Lead{{{SINGLE-QUOTE}}}" + || " AND cv.visitstatus <> {{{SINGLE-QUOTE}}}can{{{SINGLE-QUOTE}}}" + || " ORDER BY o.ArrivalDtm desc"}; + + if (exists resulted) then + resultText := ""; + if (count resulted = 1) then + resultText := "EKG "; + if (first of (orderStatus) = "RESC") then + resultText := resultText || "Corrected Results Received on " || first of (resulted); + elseif (first of (orderStatus) = "RESF") then + resultText := resultText || "Results Received on " || first of (resulted); + elseif (first of (orderStatus) = "AUA4") then + resultText := resultText || "Ordered on " || first of (resulted); + elseif (first of (orderStatus) = "PERF") then + resultText := resultText || "Performed on " || first of (resulted); + endif; + else + if (orderStatus[1] = "RESF") then + resultText := "EKG Received on " || resulted[1]; + elseif (orderStatus[1] = "RESC") then + resultText := "EKG Corrected Results Received on " || resulted[1]; + elseif (orderStatus[1] = "AUA4") then + resultText := "EKG Ordered on " || resulted[1]; + if (orderStatus[2] = "RESC" OR orderStatus[2] = "RESF") then + resultText := resultText || "; EKG Received on " || resulted[2]; + elseif (orderStatus[2] = "PERF") then + resultText := resultText || "; EKG Performed on " || resulted[2]; + endif; + endif; + endif; + else + resultText := "No EKG order or results found for last 6 months."; + endif; + + this_currentEkgObs := NEW ObservationType; + this_currentEkgObs.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentEkgObs.ParameterGUID := EkgParameter.ParameterGUID; + this_currentEkgObs.DataType := "FreeTextValue"; + this_currentEkgObs.ValueObj := NEW FreeTextValueType; + this_currentEkgObs.ValueObj.Value := resultText; + + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentEkgObs); + endif; //End EkgParameter Exists + + //Isolation Status + IsolationParameterName := "SCH_Preop_Isolation Results"; + IsolationParameter := first of (thisParameters WHERE thisParameters.Name = IsolationParameterName); + + if (exists IsolationParameter) then + //Retrieve Active Isolation Order + (isolationStatus) := read {"SELECT o.SummaryLine" + || " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3Order o WITH (NOLOCK)" + || " ON cv.GUID = o.ClientVisitGUID" + || " AND cv.ClientGUID = o.ClientGUID" + || " AND cv.ChartGUID = o.ChartGUID" + || " WHERE o.Name LIKE {{{SINGLE-QUOTE}}}%Isolation%{{{SINGLE-QUOTE}}}" + || " AND cv.ClientGUID = " || Sql(clientGuid) + || " AND cv.GUID = " || Sql(visitGuid) + || " AND cv.ChartGUID = " || Sql(chartGuid) + || " AND((o.OrderStatusLevelNum > 15" + || " AND o.OrderStatusLevelNum NOT IN ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}100{{{SINGLE-QUOTE}}}))" + || " OR o.OrderStatusCode = {{{SINGLE-QUOTE}}}HOLD{{{SINGLE-QUOTE}}})"}; + + if (exists isolationStatus) then + resultText := first of (isolationStatus); + + this_currentIsoObs := NEW ObservationType; + this_currentIsoObs.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentIsoObs.ParameterGUID := IsolationParameter.ParameterGUID; + this_currentIsoObs.DataType := "FreeTextValue"; + this_currentIsoObs.ValueObj := NEW FreeTextValueType; + this_currentIsoObs.ValueObj.Value := resultText; + + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentIsoObs); + endif; + endif; //End IsolationParameter Exists + + //Allergies + AllergyParameterName := "SCH_Preop_Allergies Results"; + AllergyParameter := first of (thisParameters WHERE thisParameters.Name = AllergyParameterName); + + if (exists AllergyParameter) then + //Retrieve Allergies + (allergyReference, + category, + allergyType, + allergen, + reaction) := read {"SELECT IsNull(enumRef3.ReferenceString,{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}})," + || " IsNull(enumRef1.ReferenceString, enumRef2.ReferenceString)," + || " IsNull(a.TypeCode,{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}})," + || " IsNull(a.Code, {{{SINGLE-QUOTE}}}Miscellaneous{{{SINGLE-QUOTE}}}), " + || " IsNull(SvrtyLevelDisplay, SvrtyLevelCode) " + || " FROM CV3AllergyDeclaration ad WITH (NOLOCK) LEFT JOIN CV3Allergen a WITH (NOLOCK) " + || " ON ad.AllergenGUID = a.GUID" + || " AND a.Active = 1" + || " LEFT OUTER JOIN CV3EnumReference enumRef1 WITH (NOLOCK) " + || " ON (enumRef1.TableName = " || Sql("CV3AllergyDeclaration") + || " AND enumRef1.ColumnName = " || Sql("CategoryType") + || " AND enumRef1.EnumValue = CategoryType)" + || " LEFT OUTER JOIN CV3EnumReference enumRef2 WITH (NOLOCK) " + || " ON (enumRef2.TableName = " || Sql("CV3AllergyDeclaration") + || " AND enumRef2.ColumnName = " || Sql("CategoryType") + || " AND enumRef2.EnumValue = 0)" + || " LEFT OUTER JOIN CV3EnumReference enumRef3 WITH (NOLOCK) " + || " ON (enumRef3.TableName = " || Sql("CV3AllergyDeclaration") + || " AND enumRef3.ColumnName = " || Sql("Type") + || " AND enumRef3.EnumValue = ad.Type" + || " AND enumRef3.EnumValue = 2)" + || " WHERE ClientGUID = " || Sql(clientGuid) + || " AND ad.Active = 1" + || " AND ad.Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}}" + || " AND ad.Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}}"}; + + resultText := ""; + if (exists allergen) then + if ("NoKnownAllergies" IN allergyReference) then + resultText := "No Known Allergies"; + else + for k in 1 seqto (count category) do + resultText := resultText || category[k]; + if (allergyType[k] <> "" OR allergyType[k] <> Null) then + resultText := resultText || ", Type: " || allergyType[k]; + endif; + resultText := resultText || ", Allergy: " || allergen[k]; + if (reaction[k] <> "" OR reaction[k] <> Null) then + resultText := resultText || ", Reaction: " || reaction[k]; + endif; + + resultText := resultText || "; "; + enddo; + endif; + + this_currentAllergyObs := NEW ObservationType; + this_currentAllergyObs.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentAllergyObs.ParameterGUID := AllergyParameter.ParameterGUID; + this_currentAllergyObs.DataType := "FreeTextValue"; + this_currentAllergyObs.ValueObj := NEW FreeTextValueType; + this_currentAllergyObs.ValueObj.Value := resultText; + + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentAllergyObs); + endif; + endif; //End AllergyParameter Exists + + //Patient Stated Health Issues for Pacemaker or Defibrillator + HealthIssueParameterName := "SCH_Preop_Health Issues_Pacemaker_Defib Results"; + HealthIssueParameter := first of (thisParameters WHERE thisParameters.Name = HealthIssueParameterName); + + if (exists HealthIssueParameter) then + //Retrieve Health Issues for Pacemaker / Defib + (hiDesc) := read {"SELECT hid.ShortName, chi.TouchedWhen" + || " FROM CV3HealthIssueDeclaration hid WITH (NOLOCK) JOIN CV3CodedHealthIssue chi WITH (NOLOCK)" + || " ON chi.guid = hid.codedhealthissueguid" + || " WHERE hid.ClientGUID = " || Sql(clientGuid) + || " AND ( (chi.Description LIKE {{{SINGLE-QUOTE}}}%Pacemaker%{{{SINGLE-QUOTE}}} OR chi.Description LIKE {{{SINGLE-QUOTE}}}%Defibrillator%{{{SINGLE-QUOTE}}} )" + || " OR (chi.ShortName LIKE {{{SINGLE-QUOTE}}}%Pacemaker%{{{SINGLE-QUOTE}}} OR chi.ShortName LIKE {{{SINGLE-QUOTE}}}%Defibrillator%{{{SINGLE-QUOTE}}}) )" + || " AND hid.Active = 1" + || " AND hid.Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}}" + || " AND hid.TypeCode IN ({{{SINGLE-QUOTE}}}AMB Med History{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Proced{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Visit{{{SINGLE-QUOTE}}})" + , primaryTime = touchedWhen}; + + resultText := ""; + if (exists hiDesc) then + for k in 1 seqto (count hiDesc) do + if (k = 1) then + resultText := hiDesc[k]; + else + resultText := resultText || ", " || hiDesc[k]; + endif; + enddo; + endif; + + this_currentHealthIssueObs := NEW ObservationType; + this_currentHealthIssueObs.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentHealthIssueObs.ParameterGUID := HealthIssueParameter.ParameterGUID; + this_currentHealthIssueObs.DataType := "FreeTextValue"; + this_currentHealthIssueObs.ValueObj := NEW FreeTextValueType; + this_currentHealthIssueObs.ValueObj.Value := resultText; + + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentHealthIssueObs); + endif; //End HealthIssue Parameter Exists + + //Chest XRay Results + ChestParameterName := "SCH_Preop_CXR Results"; + ChestParameter := first of (thisParameters WHERE thisParameters.Name = ChestParameterName); + + if (exists ChestParameter) then + //Retrieve Chest XRay Orders + (orderName, + resulted, + orderStatus) := read {"SELECT o.Name, o.ArrivalDtm, o.OrderStatusCode" + || " FROM cv3ClientVisit cv WITH (NOLOCK) JOIN cv3order o WITH (NOLOCK)" + || " ON cv.ClientGUID = o.ClientGUID" + || " AND cv.GUID = o.ClientVisitGUID" + || " AND cv.ChartGUID = o.ChartGUID" + || " JOIN cv3ordercatalogmasteritem om WITH (NOLOCK)" + || " ON om.guid = o.ordercatalogmasteritemguid" + || " JOIN cv3organizationalunit org WITH (NOLOCK)" + || " ON org.guid = om.orgunitguid" + || " AND org.name = {{{SINGLE-QUOTE}}}General Diagnostic{{{SINGLE-QUOTE}}}" + || " WHERE DateDiff(MONTH, o.ArrivalDtm, GETDATE()) <= 6" + || " AND o.ClientGUID = " || Sql(clientGuid) + || " AND o.orderstatuscode NOT LIKE {{{SINGLE-QUOTE}}}can%{{{SINGLE-QUOTE}}}" + || " AND o.OrderStatusCode NOT LIKE {{{SINGLE-QUOTE}}}disc%{{{SINGLE-QUOTE}}}" + || " AND o.name IN ({{{SINGLE-QUOTE}}}Chest Portable{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Chest 2 view - Routine{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Chest 3 Views{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Chest 4 View{{{SINGLE-QUOTE}}})" + || " AND cv.VisitStatus <> {{{SINGLE-QUOTE}}}can{{{SINGLE-QUOTE}}}" + || " ORDER BY o.ArrivalDtm desc"}; + resultText := ""; + if (exists orderName) then + if ((count orderName) = 1) then + if (first of (orderStatus) = "RESF" OR first of (orderStatus) = "RESC") then + resultText := orderName[1] || " resulted on " || resulted[1]; + elseif (first of (orderStatus) = "RESI") then + resultText := orderName[1] || " interim results received on " || resulted[1]; + elseif (first of (orderStatus) = "PERF") then + resultText := orderName[1] || " performed on " || resulted[1]; + elseif (first of (orderStatus) = "AUA4") then + resultText := orderName[1] || " ordered on " || resulted[1]; + endif; + else + if (orderStatus[1] = "RESF" OR orderStatus[1] = "RESC") then + resultText := orderName[1] || " resulted on " || resulted[1]; + elseif (orderStatus[1] = "AUA4") then + resultText := orderName[1] || " ordered on " || resulted[1]; + if (orderStatus[2] = "RESF" OR orderStatus[2] = "RESC") then + resultText := resultText || "; " || orderName[2] || " resulted on " || resulted[2]; + elseif (orderStatus[2] = "PERF") then + resultText := resultText || "; " || orderName[2] || " performed on " || resulted[2]; + elseif (orderStatus[2] = "RESI") then + resultText := resultText || "; " || orderName[2] || " interim results received on " || resulted[2]; + endif; + endif; + endif; + + this_currentChestObs := NEW ObservationType; + this_currentChestObs.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentChestObs.ParameterGUID := ChestParameter.ParameterGUID; + this_currentChestObs.DataType := "FreeTextValue"; + this_currentChestObs.ValueObj := NEW FreeTextValueType; + this_currentChestObs.ValueObj.Value := resultText; + + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentChestObs); + endif; + endif; //End ChestParameter Exists + + //Infection Prevention Education + InfectionParameterName := "SCH_Preop_Infect Prevent Results"; + InfectionParameter := first of (thisParameters WHERE thisParameters.Name = InfectionParameterName); + + if (exists InfectionParameter) then + (value, infectEduCharted) := read {"SELECT fsl.Value, fsl.CreatedWhen" + || " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3ClientDocumentCUR cd WITH (NOLOCK)" + || " ON cv.GUID = cd.ClientVisitGUID" + || " AND cv.ClientGUID = cd.ClientGUID" + || " AND cv.ChartGUID = cd.ChartGUID" + || " JOIN CV3ClientDocDetailCUR cdd WITH (NOLOCK)" + || " ON cd.GUID = cdd.ClientDocumentGUID" + || " AND cd.ClientGUID = cdd.ClientGUID" + || " JOIN CV3ObservationDocumentCUR od WITH (NOLOCK)" + || " ON cdd.ClientDocumentGUID = od.OwnerGUID" + || " LEFT JOIN SCMObsFsListValues fsl WITH (NOLOCK)" + || " ON od.ObservationDocumentGUID = fsl.ParentGUID" + || " AND cdd.ClientGUID = fsl.ClientGUID" + || " JOIN CV3ObsCatalogMasterItem ocmi WITH (NOLOCK)" + || " ON od.ObsMasterItemGUID = ocmi.GUID" + || " JOIN CV3ObservationCUR o WITH (NOLOCK)" + || " ON od.ObservationGUID = o.GUID" + || " JOIN CV3ObsCatalogItem oci WITH (NOLOCK)" + || " ON o.ObsItemGUID = oci.GUID" + || " WHERE cd.DocumentName = {{{SINGLE-QUOTE}}}3. Adult Education Outcome Record{{{SINGLE-QUOTE}}}" + || " AND cdd.Active = 1" + || " AND od.Active = 1" + || " AND cv.ClientGUID = " || Sql(clientGuid) + || " AND cv.GUID = " || Sql(visitGuid) + || " AND cv.ChartGUID = " || Sql(chartGuid) + || " AND (oci.Name = {{{SINGLE-QUOTE}}}ED Infection Prevention{{{SINGLE-QUOTE}}}" + || " AND fsl.Value = {{{SINGLE-QUOTE}}}Surgical Site Infection Patient Guide Given{{{SINGLE-QUOTE}}})" + || " ORDER BY fsl.CreatedWhen ASC"}; + + resultText := ""; + if (exists value) then + resultText := value[1] || " was documented on " || infectEduCharted[1]; + + this_currentInfectionObs := NEW ObservationType; + this_currentInfectionObs.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentInfectionObs.ParameterGUID := InfectionParameter.ParameterGUID; + this_currentInfectionObs.DataType := "FreeTextValue"; + this_currentInfectionObs.ValueObj := NEW FreeTextValueType; + this_currentInfectionObs.ValueObj.Value := resultText; + + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentInfectionObs); + endif; + endif; //End InfectionParameter Exists + + //Height / Weight + HWParameterName := "SCH_Preop_Height Weight Results"; + HWParameter := first of (thisParameters WHERE thisParameters.Name = HWParameterName); + + if (exists HWParameter) then + (pName, pValue, pDate) := read {"SELECT oci.Name, o.ValueText, cd.AuthoredDtm" + || " FROM CV3ClientDocumentCUR cd JOIN CV3ClientDocDetailCUR cdd ON cdd.ClientDocumentGUID = cd.GUID " + || " AND cdd.ClientGUID = cd.ClientGUID" + || " JOIN CV3ObservationDocumentCUR od ON cdd.ClientDocumentGUID = od.OwnerGUID " + || " JOIN CV3ObsCatalogMasterItem ocmi ON od.ObsMasterItemGUID = ocmi.GUID" + || " JOIN CV3ObservationCUR o ON o.GUID = od.ObservationGUID" + || " JOIN CV3ObsCatalogItem oci ON oci.guid = o.ObsItemGUID" + || " WHERE cd.ClientGUID = " || Sql(clientGuid) + || " AND cd.ChartGUID = " || Sql(chartGuid) + || " AND o.ValueText is not null" + || " AND oci.Name IN ({{{SINGLE-QUOTE}}}Weight - lbs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Weight - kg{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}Height in ft{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Height remainder in inches{{{SINGLE-QUOTE}}})" + || " AND od.Active = 1" + || " ORDER BY oci.Name ASC" + , primaryTime = touchedWhen}; + + resultText := ""; + if (exists pName) then + lbWeight := ""; lbWtValue := ""; lbWtDateDifference := 0; + kgWeight := ""; kgWtValue := ""; kgWtDateDifference := 0; + ftHeight := ""; ftHtValue := ""; ftHtDateDifference := 0; + inHeight := ""; inHtValue := ""; inHtDateDifference := 0; + for k in 1 seqto (count pName) do + if (pName[k] = "Weight - lbs" AND lbWtDateDifference = 0) then + lbWeight := pName[k]; + lbWtValue := pValue[k]; + lbWtDateDifference := (now - pDate[k]); + elseif ((pName[k] = "Weight - lbs") AND ((now - pDate[k]) <= lbWtDateDifference)) then + lbWeight := pName[k]; + lbWtValue := pValue[k]; + else + lbWtDateDifference := (now - pDate[k]); + endif; + if (pName[k] = "Weight - kg" AND kgWtDateDifference = 0) then + kgWeight := pName[k]; + kgWtValue := pValue[k] as Number; + kgWtDateDifference := (now - pDate[k]); + elseif ((pName[k] = "Weight - kg") AND ((now - pDate[k]) <= kgWtDateDifference)) then + kgWeight := pName[k]; + kgWtValue := pValue[k] as Number; + else + kgWtDateDifference := (now - pDate[k]); + endif; + if (pName[k] = "Height in ft" AND ftHtDateDifference = 0) then + ftHeight := pName[k]; + ftHtValue := pValue[k]; + ftHtDateDifference := (now - pDate[k]); + elseif ((pName[k] = "Height in ft") AND ((now - pDate[k]) <= ftHtDateDifference)) then + ftHeight := pName[k]; + ftHtValue := pValue [k]; + else + ftHtDateDifference := (now - pDate[k]); + endif; + if (pName[k] = "Height remainder in inches" AND inHtDateDifference = 0) then + inHeight := pName[k]; + inHtValue := pValue[k]; + inHtDateDifference := (now - pDate[k]); + elseif ((pName[k] = "Height remainder in inches") AND ((now - pDate[k]) <= inHtDateDifference)) then + inHeight := pName[k]; + inHtValue := pValue[k]; + else + inHtDateDifference := (now - pDate[k]); + endif; + + enddo; + resultText := lbWeight || " " || lbWtValue || ", " || kgWeight || " " || (kgWtValue FORMATTED WITH "%.2f") + || ", " || ftHeight || " " || ftHtValue || ", " || inHeight || " " || inHtValue; + + this_currentHWObs := NEW ObservationType; + this_currentHWObs.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentHWObs.ParameterGUID := HWParameter.ParameterGUID; + this_currentHWObs.DataType := "FreeTextValue"; + this_currentHWObs.ValueObj := NEW FreeTextValueType; + this_currentHWObs.ValueObj.Value := resultText; + + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentHWObs); + endif; + endif; //End HWParameter Exists + + //Hover Mat Parameter + lbWt300ParameterName := "SCH_Preop_HoverMat"; + lbWt300Parameter := first of (thisParameters WHERE thisParameters.Name = lbWt300ParameterName); + + if ((exists lbWt300Parameter) AND (exists lbWtValue)) then + if ((lbWtValue as number) >= 300) then + hoverMatValue := "Yes"; + elseif ((lbWtValue as number) < 300) then + hoverMatValue := "N/A"; + endif; + + this_currentHoverMatObs := NEW ObservationType; + this_currentHoverMatObs.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentHoverMatObs.ParameterGUID := lbWt300Parameter.ParameterGUID; + this_currentHoverMatObs.DataType := "ListValue"; + this_currentHoverMatObs.ValueObj := NEW ListValueType; + this_currentHoverMatObs.ValueObj.ListGUID := lbWt300Parameter.ConfigurationObj.ListGUID; + + listItems := (); + + for item IN lbWt300Parameter.ConfigurationObj.ListItemsList do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if (selectedItem.Value = hoverMatValue) then + selectedItem.IsSelected := true; + endif; + + if (selectedItem.Value <> hoverMatValue) then + selectedItem.IsSelected := false; + endif; + listItems := (listItems, selectedItem); + enddo; + + this_currentHoverMatObs.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentHoverMatObs); + endif; //End lbWt300Parameter Exists + + //BGM / FBS + GlucoseParameterName := "SCH_Preop_BGM FGS Results"; + GlucoseParameter := first of (thisParameters WHERE thisParameters.Name = GlucoseParameterName); + + if (exists GlucoseParameter) then + (labName, labResulted, labValue) := read {"SELECT bo.ItemName, o.arrivaldtm, " + || " IsNull(bo.Value,{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}})" + || " FROM cv3clientvisit cv with (nolock) JOIN cv3order o with (nolock) " + || " ON cv.clientguid = o.clientguid " + || " AND cv.GUID = o.ClientVisitGUID" + || " AND cv.chartguid = o.chartguid " + || " JOIN CV3BasicObservation bo with (nolock) " + || " ON o.GUID = bo.OrderGUID" + || " AND o.ClientGUID = bo.ClientGUID " + || " AND o.ClientVisitGUID = bo.ClientVisitGUID" + || " AND o.ChartGUID = bo.ChartGUID" + || " JOIN cv3ordercatalogmasteritem om with (nolock) " + || " ON om.guid = o.ordercatalogmasteritemguid" + || " JOIN cv3organizationalunit org with (nolock) " + || " ON org.guid = om.orgunitguid " + || " AND org.name = {{{SINGLE-QUOTE}}}Chemistry{{{SINGLE-QUOTE}}}" + || " JOIN cv3orderstatushistory oshentr with (nolock) " + || " ON oshentr.orderguid = o.guid " + || " AND oshentr.OrderStatusCode = {{{SINGLE-QUOTE}}}RESF{{{SINGLE-QUOTE}}}" + || " WHERE DATEDIFF(HH, o.ArrivalDTM, GetDate()) <= 2" + || " AND cv.ClientGUID = " || Sql(clientGuid) + || " AND cv.GUID = " || Sql(visitGuid) + || " AND cv.ChartGUID = " || Sql(chartGuid) + || " AND o.orderstatuscode NOT LIKE {{{SINGLE-QUOTE}}}can%{{{SINGLE-QUOTE}}}" + || " AND o.name IN ({{{SINGLE-QUOTE}}}Glucose Bedside{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Glucose Bedside.{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Glucose Fasting{{{SINGLE-QUOTE}}})" + || " ORDER BY o.ArrivalDtm asc " + , primaryTime = arrivalDtm}; + + resultText := ""; + dateDifference := 0; + if (exists labName) then + for k in 1 seqto (count labName) do + if (dateDifference = 0) then + mostCurrentLab := labName[k]; + mostCurrentValue := labValue[k]; + mostCurrentDate := labResulted[k]; + dateDifference := (now - labResulted[k]); + elseif ((now - labResulted[k]) <= dateDifference) then + mostCurrentLab := labName[k]; + mostCurrentValue := labValue[k]; + mostCurrentDate := labResulted[k]; + else + dateDifference := (now - labResulted[k]); + endif; + enddo; + resultText := mostCurrentLab || " " || mostCurrentValue || " resulted on " || mostCurrentDate; + + this_currentGlucoseObs := NEW ObservationType; + this_currentGlucoseObs.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentGlucoseObs.ParameterGUID := GlucoseParameter.ParameterGUID; + this_currentGlucoseObs.DataType := "FreeTextValue"; + this_currentGlucoseObs.ValueObj := NEW FreeTextValueType; + this_currentGlucoseObs.ValueObj.Value := resultText; + + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentGlucoseObs); + endif; + endif; // End GlucoseParameter Exists + + //Last ABX Given + LastABXAdminParameterName := "SCH_Preop_Last ABX Admin"; + LastABXAdminParameter := first of (thisParameters WHERE thisParameters.Name = LastABXAdminParameterName); + if (exists LastABXAdminParameter) then + + (abxName, abxAdmin, + abxDose, abxUom, + abxRoute, abxFreq) := read {"SELECT o.Name, oto.PerformedFromDtm, " + || " oto.TaskDose, oto.TaskUom, oto.TaskRouteCode, o.FrequencyCode" + || " FROM CV3ClientVisit cv JOIN CV3Order o" + || " ON cv.GUID = o.ClientVisitGUID" + || " AND cv.ClientGUID = o.ClientGUID" + || " AND cv.ChartGUID = o.ChartGUID" + || " JOIN CV3OrderCatalogMasterItem ocmi" + || " ON o.OrderCatalogMasterItemGUID = ocmi.GUID" + || " JOIN CV3OrderTask ot" + || " ON o.ClientGUID = ot.ClientGUID" + || " AND o.ChartGUID = ot.ChartGUID" + || " AND o.GUID = ot.OrderGUID" + || " JOIN CV3OrderTaskOccurrence oto" + || " ON ot.ClientGUID = oto.ClientGUID" + || " AND ot.OrderGUID = oto.OrderGUID" + || " AND ot.GUID = oto.OrderTaskGUID" + || " WHERE cv.ClientGUID = " || Sql(clientGuid) + || " AND cv.GUID = " || Sql(visitGuid) + || " AND cv.ChartGUID = " || Sql(chartGuid) + || " AND oto.TaskStatusCode = {{{SINGLE-QUOTE}}}Performed{{{SINGLE-QUOTE}}}" +// || " AND ((o.OrderStatusLevelNum > 15" +// || " AND o.OrderStatusLevelNum NOT IN ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}}))" +// || " AND o.OrderStatusCode <> {{{SINGLE-QUOTE}}}HOLD{{{SINGLE-QUOTE}}})" + || " AND ocmi.TherapeuticCategory IN ({{{SINGLE-QUOTE}}}anti-infectives | aminoglycosides{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}anti-infectives | anthelmintics{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}anti-infectives | antifungals{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}anti-infectives | antimalarial agents{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}anti-infectives | antituberculosis agents{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}anti-infectives | antiviral agents{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}anti-infectives | carbapenems{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}anti-infectives | cephalosporins{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}anti-infectives | glycopeptide antibiotics{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}anti-infectives | glycylcyclines{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}anti-infectives | leprostatics{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}anti-infectives | lincomycin derivatives{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}anti-infectives | macrolide derivatives{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}anti-infectives | miscellaneous antibiotics{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}anti-infectives | penicillins{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}anti-infectives | quinolones{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}anti-infectives | tetracyclines{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}anti-infectives | urinary anti-infectives{{{SINGLE-QUOTE}}})" + || " ORDER BY oto.PerformedFromDtm desc"}; + + if (exists abxName) then + + LastAbxYesNoParameterName := "SCH_Preop_Current_ABX_YN"; + LastAbxYesNoParameter := first of (thisParameters WHERE thisParameters.Name = LastAbxYesNoParameterName); + + if (exists LastAbxYesNoParameter) then + + //Check yes + this_currentAbxYesNoObs := NEW ObservationType; + this_currentAbxYesNoObs.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentAbxYesNoObs.ParameterGUID := LastAbxYesNoParameter.ParameterGUID; + this_currentAbxYesNoObs.DataType := "ListValue"; + this_currentAbxYesNoObs.ValueObj := NEW ListValueType; + this_currentAbxYesNoObs.ValueObj.ListGUID := LastAbxYesNoParameter.ConfigurationObj.ListGUID; + + listItems := (); + + for item IN LastAbxYesNoParameter.ConfigurationObj.ListItemsList do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if (selectedItem.Value = "Yes") then + selectedItem.IsSelected := true; + endif; + if (selectedItem.Value <> "Yes") then + selectedItem.IsSelected := false; + endif; + + listItems := (listItems, selectedItem); + enddo; + + this_currentAbxYesNoObs.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentAbxYesNoObs); + endif; + + abxAdminTime := first of (abxAdmin) formatted with "%.4t"; + resultText := first of (abxName) || " " || first of (abxDose) || " " || first of (abxUom) || " " || first of (abxRoute) + || " " || first of (abxFreq) || " was administered on " || abxAdminTime; + + this_currentAbxObs := NEW ObservationType; + this_currentAbxObs.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentAbxObs.ParameterGUID := LastABXAdminParameter.ParameterGUID; + this_currentAbxObs.DataType := "FreeTextValue"; + this_currentAbxObs.ValueObj := NEW FreeTextValueType; + this_currentAbxObs.ValueObj.Value := resultText; + + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentAbxObs); + endif; + + endif; //End LastABXAdminParameter exists + + //Last Beta Blocker Given + LastBetaBlockerParameterName := "SCH_Preop_Last BetaBlocker Admin"; + LastBetaBlockerParameter := first of (thisParameters WHERE thisParameters.Name = LastBetaBlockerParameterName); + + if (exists LastBetaBlockerParameter) then + (betaName, betaAdmin, + betaDose, betaUom, + betaRoute, betaFreq, + betaTaskStatus) := read {"SELECT o.Name, oto.PerformedFromDtm, " + || " oto.TaskDose, oto.TaskUom, oto.TaskRouteCode, o.FrequencyCode," + || " oto.TaskStatusCode" + || " FROM CV3ClientVisit cv JOIN CV3Order o" + || " ON cv.GUID = o.ClientVisitGUID" + || " AND cv.ClientGUID = o.ClientGUID" + || " AND cv.ChartGUID = o.ChartGUID" + || " JOIN CV3OrderCatalogMasterItem ocmi" + || " ON o.OrderCatalogMasterItemGUID = ocmi.GUID" + || " JOIN CV3OrderTask ot" + || " ON o.ClientGUID = ot.ClientGUID" + || " AND o.ChartGUID = ot.ChartGUID" + || " AND o.GUID = ot.OrderGUID" + || " JOIN CV3OrderTaskOccurrence oto" + || " ON ot.ClientGUID = oto.ClientGUID" + || " AND ot.OrderGUID = oto.OrderGUID" + || " AND ot.GUID = oto.OrderTaskGUID" + || " WHERE cv.ClientGUID = " || Sql(clientGuid) + || " AND cv.GUID = " || Sql(visitGuid) + || " AND cv.ChartGUID = " || Sql(chartGuid) + || " AND oto.TaskStatusCode <> {{{SINGLE-QUOTE}}}Canceled{{{SINGLE-QUOTE}}}" + || " AND ((o.OrderStatusLevelNum > 15" + || " AND o.OrderStatusLevelNum NOT IN ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}}))" + || " AND o.OrderStatusCode <> {{{SINGLE-QUOTE}}}HOLD{{{SINGLE-QUOTE}}})" + || " AND ocmi.TherapeuticCategory = {{{SINGLE-QUOTE}}}cardiovascular agents | beta-adrenergic blocking agents{{{SINGLE-QUOTE}}}" + || " ORDER BY oto.PerformedFromDtm desc"}; + + if (exists betaName) then + + //Check Yes + BetaYesNoParameterName := "SCH_Preop_BetaBlocker_YN"; + BetaYesNoParameter := first of (thisParameters WHERE thisParameters.Name = BetaYesNoParameterName); + + if (exists BetaYesNoParameter) then + this_currentBetaYNObs := NEW ObservationType; + this_currentBetaYNObs.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentBetaYNObs.ParameterGUID := BetaYesNoParameter.ParameterGUID; + this_currentBetaYNObs.DataType := "ListValue"; + this_currentBetaYNObs.ValueObj := NEW ListValueType; + this_currentBetaYNObs.ValueObj.ListGUID := BetaYesNoParameter.ConfigurationObj.ListGUID; + + listItems := (); + + for item IN BetaYesNoParameter.ConfigurationObj.ListItemsList do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if (selectedItem.Value = "Yes") then + selectedItem.IsSelected := true; + endif; + if (selectedItem.Value <> "Yes") then + selectedItem.IsSelected := false; + endif; + + listItems := (listItems, selectedItem); + enddo; + + this_currentBetaYNObs.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentBetaYNObs); + endif; + + if ( ( first of (betaTaskStatus) ) = "Performed") then + betaAdminTime := first of (betaAdmin) formatted with "%.4t"; + resultText := first of (betaName) || " " || first of (betaDose) || " " || first of (betaUom) + || " " || first of (betaRoute) || " " || first of (betaFreq) + || " was administered on " || betaAdminTime || "."; + elseif ( ( first of (betaTaskStatus) ) = "Not Performed" + OR ( first of (betaTaskStatus ) ) = "Overdue" + OR ( first of (betaTaskStatus) ) = "Pending") then + resultText := first of (betaName) || " ordered. Medication has not been administered."; + endif; + this_currentBetaObs := NEW ObservationType; + this_currentBetaObs.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentBetaObs.ParameterGUID := LastBetaBlockerParameter.ParameterGUID; + this_currentBetaObs.DataType := "FreeTextValue"; + this_currentBetaObs.ValueObj := NEW FreeTextValueType; + this_currentBetaObs.ValueObj.Value := resultText; + + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentBetaObs); + endif; + + endif; //End LastBetaBlockerParameter exists + + //PTT & PT/INR + INRParameterName := "SCH_Preop_PTT_PTINR Results"; + INRParameter := first of (thisParameters WHERE thisParameters.Name = INRParameterName); + + if (exists INRParameter) then + (labName, labResulted, labValue) := read {"SELECT bo.ItemName, o.arrivaldtm, IsNull(bo.Value,{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}})" + || " FROM cv3clientvisit cv with (nolock) JOIN cv3order o with (nolock) " + || " ON cv.clientguid = o.clientguid " + || " AND cv.GUID = o.ClientVisitGUID" + || " AND cv.chartguid = o.chartguid " + || " JOIN CV3BasicObservation bo with (nolock) " + || " ON o.GUID = bo.OrderGUID" + || " AND o.ClientGUID = bo.ClientGUID " + || " AND o.ClientVisitGUID = bo.ClientVisitGUID" + || " AND o.ChartGUID = bo.ChartGUID" + || " LEFT JOIN CV3TextualObservationLine tol with (nolock) " + || " ON bo.GUID = tol.ObservationGUID" + || " AND bo.ClientGUID = tol.ClientGUID" + || " JOIN cv3ordercatalogmasteritem om with (nolock) " + || " ON om.guid = o.ordercatalogmasteritemguid" + || " JOIN cv3organizationalunit org with (nolock) " + || " ON org.guid = om.orgunitguid " + || " AND org.name = {{{SINGLE-QUOTE}}}Coagulation{{{SINGLE-QUOTE}}}" + || " JOIN cv3orderstatushistory oshentr with (nolock) " + || " ON oshentr.orderguid = o.guid " + || " AND oshentr.OrderStatusCode = {{{SINGLE-QUOTE}}}RESF{{{SINGLE-QUOTE}}}" + || " WHERE cv.ClientGUID = " || Sql(clientGuid) + || " AND cv.GUID = " || Sql(visitGuid) + || " AND cv.ChartGUID = " || Sql(chartGuid) + || " AND o.orderstatuscode NOT LIKE {{{SINGLE-QUOTE}}}can%{{{SINGLE-QUOTE}}}" + || " AND o.name IN ({{{SINGLE-QUOTE}}}Prothrombin/INR{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}APTT{{{SINGLE-QUOTE}}})" + || " AND bo.Value IS NOT NULL" + , primaryTime = arrivalDtm}; + + resultText := ""; + if (exists labName) then + + apttDateDiff := 0; + inrDateDiff := 0; + prothDateDiff := 0; + for k in 1 seqto (count labName) do + if (labName[k] = "APTT") then + if (apttDateDiff = 0) then + apttLab := labName[k]; + apttResult := labResulted[k]; + apttValue := labValue[k]; + apttDateDiff := (now - labResulted[k]); + elseif ((now - labResulted[k]) <= apttDateDiff) then + apttLab := labName[k]; + apttResult := labResulted[k]; + apttValue := labValue[k]; + else + apttDateDiff := (now - labResulted[k]); + endif; + elseif (labName[k] = "INR") then + if (inrDateDiff = 0) then + inrLab := labName[k]; + inrResult := labResulted[k]; + inrValue := labValue[k]; + inrDateDiff := (now - labResulted[k]); + elseif ((now - labResulted[k]) <= inrDateDiff) then + inrLab := labName[k]; + inrResult := labResulted[k]; + inrValue := labValue[k]; + else + inrDateDiff := (now - labResulted[k]); + endif; + elseif (labName[k] = "Prothrombin Time") then + if (prothDateDiff = 0) then + prothLab := labName[k]; + prothResult := labResulted[k]; + prothValue := labValue[k]; + prothDateDiff := (now - labResulted[k]); + elseif ((now - labResulted[k]) <= prothDateDiff) then + prothLab := labName[k]; + prothResult := labResulted[k]; + prothValue := labValue[k]; + else + prothDateDiff := (now - labResulted[k]); + endif; + endif; + enddo; + if (exists apttLab) then + resultText := apttLab || ": " || apttValue || " resulted on " || apttResult; + endif; + if (exists inrLab) then + if (resultText = "") then + resultText := inrLab || ": " || inrValue || " resulted on " || inrResult; + else + resultText := resultText || "; " || inrLab || ": " || inrValue || " resulted on " || inrResult; + endif; + endif; + if (exists prothLab) then + if (resultText = "") then + resultText := prothLab || ": " || prothValue || " resulted on " || prothResult; + else + resultText := resultText || "; " || prothLab || ": " || prothValue || " resulted on " || prothResult; + endif; + endif; + + this_currentInrObs := NEW ObservationType; + this_currentInrObs.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentInrObs.ParameterGUID := INRParameter.ParameterGUID; + this_currentInrObs.DataType := "FreeTextValue"; + this_currentInrObs.ValueObj := NEW FreeTextValueType; + this_currentInrObs.ValueObj.Value := resultText; + + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentInrObs); + endif; + endif; //End INRParameter exists + endif; //End EventType and DocumentName check + + //On Document Close, check if all observations have been entered; otherwise, save the document as Incomplete + if (this_documentCommunication.EventType = DOCUMENTCLOSING) then + //Determine the total number of parameters that require values + totalParams := (count thisParameters) as number; + //Declare variable to tally the number of observations that have values + totalValueCount := 0; + + //Loop through all the parameters + for currentParam IN thisParameters do + //Retrieve the observations object for the current parameter + theObs := first of (thisObservations WHERE thisObservations.ParameterGUID = currentParam.ParameterGUID); + + //Need to determine the DataType of the parameter in order to retrieve the value + //If the retrieved value is valid (i.e. not null or empty), increment the totalValueCount + if (currentParam.DataType = "FreeTextValue") then + if (theObs.ValueObj.Value is not null) then + totalValueCount := totalValueCount + 1; + endif; + elseif (currentParam.DataType = "ListValue") then + value := (theObs.ValueObj.ListItemsList.Value WHERE theObs.ValueObj.ListItemsList.IsSelected = true); + if (count value > 0) then + totalValueCount := totalValueCount + 1; + endif; + else + if (theObs.ValueObj.Value is not null) then + totalValueCount := totalValueCount + 1; + endif; + endif; + enddo; + + //Determine the number of observations that did not have a value + //Need to take into consideration parameters / observations that can contain a "N/A" value + // since they are contained in two different parameters (i.e. Type & Screen has two parameters, + // one for the "N/A" radio button, one for the free text lab results. If either of these parameters contain a value, + // then the observation is valid). As a result, the danglingParams variable can be 6 or less and the document + // can still be saved as Complete. + danglingParams := (totalParams - totalValueCount) as number; + + //If danglingParams is greater than 6, save document as Incomplete + if (danglingParams > 6) then + isIncompleteFlag := true; + endif; + + thisStructuredNoteDoc.IsIncomplete := isIncompleteFlag; + + endif; + + if (debugFlag = true) then + messageText := messageText || "\n DOC_FUNC_PREOPERATIVE_CHECKLIST mlm completed.\n\n"; + this_documentCommunication.DisplayMessage := true; + this_documentCommunication.Message := messageText; + endif; + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_PRESSURE_ULCER_HEALTH_ISSUE.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_PRESSURE_ULCER_HEALTH_ISSUE.mlm new file mode 100644 index 0000000..39c1b2d --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_PRESSURE_ULCER_HEALTH_ISSUE.mlm @@ -0,0 +1,257 @@ +maintenance: + + title: DOC_FUNC_PRESSURE_ULCER_HEALTH_ISSUE;; + mlmname: DOC_FUNC_PRESSURE_ULCER_HEALTH_ISSUE;; + arden: version 5.5;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Juliet M. Law;; + specialist: ;; + date: 2013-03-07;; + validation: testing;; + +library: + purpose: This MLM deals with the Pressure Ulcer observation on the Patient Profile documents + (Adult Patient Profile, Adult Patient Profile - Behavioral Health, OB Patient Profile, + Adult Patient Profile - Observation) + ;; + explanation: This MLM will automatically answer the "History of Pressure Ulcers" observation to {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} if + the patient has an existing Health Issue for Pressure Ulcers on document open. + This MLM will create a health issue "History of Pressure Ulcers" when the user selects {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} + to the observation "History of Pressure Ulcers" in the Patient Profile documents. + This MLM will create a health issue "History of Pressure Ulcers" when the user selects {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} + to the observation "History of Pressure Ulcers" BUT selects {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to the observations + "Pressure Ulcer present at time of admission" in the Patient Profile documents. + + Change history + + 03.07.2013 JML Created + 09.30.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 HI Dynamic Creation with all details Like ICD10 Code, Snowmed Code etc And Duplicate HI Check Change. + 10.12.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 Coding Scheme [ICD10] And Duplicate Check of HI . + 06.15.2016 SSJ CSR#34418 - Added new observation {{{SINGLE-QUOTE}}}SCHCK_PRO pressure ulcer present_obs{{{SINGLE-QUOTE}}}. Made changes according to discriminate Value for this Observation. + + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + ListValueType := OBJECT [ListGuid, ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + pastPUParameterName := "SCHCK_PRO pressure ulcer past obs"; + currPUParameterName := "SCHCK_PRO pressure ulcer present obs"; + currPUParameterName1 := "SCHCK_PRO pressure ulcer present_obs"; //06.15.2016 SSJ CSR#34418 - Added new observation + + //On document open, determine if patient has existing Pressure Ulcer health issue + pressureUlcerHI := read {"SELECT hi.ShortName" + || " FROM CV3HealthIssueDeclaration hi WITH (NOLOCK) JOIN CV3CodedHealthIssue chi WITH (NOLOCK)" + || " ON hi.CodedHealthIssueGUID = chi.GUID" + || " WHERE hi.ClientGUID = " || SQL(clientGuid) + || " AND hi.Active = 1" + || " AND hi.Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} And hi.ICD10Code is Not null " // Added By Shivprasad on 30 Sept 2015 for ICD9-10 Changes + || " AND hi.TypeCode = {{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}}" + || " AND (hi.Text = {{{SINGLE-QUOTE}}}History of Pressure Ulcer{{{SINGLE-QUOTE}}}" + || " OR hi.ShortName = {{{SINGLE-QUOTE}}}History of Pressure Ulcer{{{SINGLE-QUOTE}}})"}; + + if (thisDocumentCommunication.EventType = "DocumentOpening") then + + if (exists pressureUlcerHI) then + //Patient has an existing pressure ulcer health issue, automatically check {{{SINGLE-QUOTE}}}yes{{{SINGLE-QUOTE}}} to + //observation {{{SINGLE-QUOTE}}}History of Pressure Ulcers{{{SINGLE-QUOTE}}} + this_ParameterName := first of (thisParameters WHERE thisParameters.Name = pastPUParameterName); + if (exists this_ParameterName) then + this_currentObj := NEW ObservationType; + + this_currentObj.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_ParameterName.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := NEW ListValueType; + this_currentObj.ValueObj.ListGUID := this_ParameterName.ConfigurationObj.ListGUID; + listItems := (); + for item IN this_ParameterName.ConfigurationObj.ListItemsList do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if (selectedItem.Value = "yes") then + selectedItem.IsSelected := true; + endif; + if (selectedItem.Value = "no") then + selectedItem.IsSelected := false; + endif; + + listItems := (listItems, selectedItem); + enddo; + + + this_currentObj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; + endif; + elseif (thisDocumentCommunication.EventType = "ChartObservation") Then + if (not exists pressureUlcerHI) then + this_past_PU_Parameter := first of (thisParameters WHERE thisParameters.Name = pastPUParameterName); + this_past_PU_Observation := first of (thisObservations WHERE thisObservations.ParameterGUID = this_past_PU_Parameter.ParameterGUID); + + this_curr_PU_Parameter := first of (thisParameters WHERE thisParameters.Name = currPUParameterName); + this_curr_PU_Observation := first of (thisObservations WHERE thisObservations.ParameterGUID = this_curr_PU_Parameter.ParameterGUID); + + this_curr_PU_Parameter1 := first of (thisParameters WHERE thisParameters.Name = currPUParameterName1 ); // 06.15.2016 SSJ CSR#34418 - Added new observation + this_curr_PU_Observation1 := first of (thisObservations WHERE thisObservations.ParameterGUID = this_curr_PU_Parameter1.ParameterGUID); //06.15.2016 SSJ CSR#34418 - Added new observation + + past_pressure_ulcer_value := (this_past_PU_Observation.ValueObj.ListItemsList.Value + WHERE this_past_PU_Observation.ValueObj.ListItemsList.IsSelected = true); + current_pressure_ulcer_value := (this_curr_PU_Observation.ValueObj.ListItemsList.Value + WHERE this_curr_PU_Observation.ValueObj.ListItemsList.IsSelected = true); + + current_pressure_ulcer_value1 := (this_curr_PU_Observation1.ValueObj.ListItemsList.Value //06.15.2016 SSJ CSR#34418 - Added new observation + WHERE this_curr_PU_Observation1.ValueObj.ListItemsList.IsSelected = true); //06.15.2016 SSJ CSR#34418 - Added new observation + + //Determine observation values in {{{SINGLE-QUOTE}}}History of Pressure Ulcer{{{SINGLE-QUOTE}}} and {{{SINGLE-QUOTE}}}Pressure Ulcer at Admission{{{SINGLE-QUOTE}}} + if ("yes" IN past_pressure_ulcer_value) then + createPUHI := true; + elseif ("no" IN past_pressure_ulcer_value AND (("yes..." IN current_pressure_ulcer_value1) or ("yes" in current_pressure_ulcer_value ) ) ) then //06.15.2016 SSJ CSR#34418 - Added new observation + createPUHI := true; + elseif ( (("yes..." IN current_pressure_ulcer_value1) or ("yes" in current_pressure_ulcer_value ) ) AND (count past_pressure_ulcer_value = 0)) then //06.15.2016 SSJ CSR#34418 - Added new observation + createPUHI := true; + else + createPUHI := false; + endif; //End yes IN past_pressure_ulcer_value + + //User selected {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to one of the two observations + //Alert user that health issue will be created + if (createPUHI = true) then + msgPU_HI := "This selection will create a chronic health issue of {{{SINGLE-QUOTE}}}History of pressure ulcer{{{SINGLE-QUOTE}}}." + || "\n\n Click {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to confirm your selection. " + || "\n\n Click {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} if you wish to change your selection."; + + dialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with msgPU_HI, "Confirm Pressure Ulcer History", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}, "Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + //User agreed to creation of HI + if ((dialogRes as String) = "Yes") then + try + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}Retrieve client:{{-R}}\n" || + ex.Message || "\n\n"; + if ex.InnerException is not null net_object then + error_message := error_message || "Inner Exception: " || ex.InnerException.Message || "\n\n"; + endif; + if ( client_visit_obj is NOT NULL ) then + void:= call client_visit_obj.Dispose; client_visit_obj:= null; + endif; + endcatch; + + try + //--------------------------------------------------------- + // New HealthIssue Example + //--------------------------------------------------------- + + NewHealthIssueHIType := "Problem-Chronic"; + NewHealthIssueHICode := "Z87.2"; //"V13.3";// 10.12.2015-CSR#23359- ICD10 Coding Scheme and HI Duplicate check + NewHealthIssueHIScheme := "ICD10"; //"ICD9";// 10.12.2015-CSR#23359- ICD10 Coding Scheme and HI Duplicate check + + dd := EXTRACT Day now; + mn := EXTRACT Month now; + yr := EXTRACT Year now; + + //--Start: CSR 23359-ICD9-ICD10 HI Change Added By shivprasad + Terms := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.FindIMOTerms with (NewHealthIssueHIScheme,NewHealthIssueHICode); + FOR i IN 1 SEQTO (Terms.Count as Number ) DO + HI_obj := Terms[i]; + HI_Name := HI_obj.TermName as string; + If HI_Name = "History of Pressure Ulcer" then + HI_NO := i ; + Endif; + ENDDO; + If HI_NO is Null Then + HI_NO :=1 ; + Endif; + New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with (client_visit_obj, NewHealthIssueHIType, Terms[HI_NO]); + + //--End Added by Shivprasad + + /* New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with + (client_visit_obj, + NewHealthIssueHIType, + NewHealthIssueHIScheme, + NewHealthIssueHICode ); */ + + PartialDate_obj := new net_object {{{SINGLE-QUOTE}}}PartialDate{{{SINGLE-QUOTE}}} with (yr as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, mn as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, dd as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}} ); + New_HealthIssue_obj.OnsetDate := PartialDate_obj; + New_HealthIssue_obj.Text := "Created from Patient Profile information. " ; + New_HealthIssue_obj.Name := "History of Pressure Ulcer"; + + if ( New_HealthIssue_obj is NOT NULL ) then + void := call New_HealthIssue_obj.Save; + void := call New_HealthIssue_obj.Dispose; + endif; + + if ( client_visit_obj is NOT NULL ) then + void:= call client_visit_obj.Dispose; + client_visit_obj:= null; + endif; + + endtry; + + catch exception ex + error_occurred := true; + if ( New_HealthIssue_obj is NOT NULL ) then + void:= call New_HealthIssue_obj.Dispose; + New_HealthIssue_obj:= null; + endif; + endcatch; + elseif ((dialogRes as String) = "No") then + void := ""; + endif; //End dialogRes = Yes/No + endif; //End createPUHI = true + endif; //End NOT exists pressureUlcerHI + endif; //End thisDocumentCommunication.EventType + ;; + evoke: + ;; + logic: + +conclude true; + + ;; + action: + + + return thisDocumentCommunication; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_PRINT_ON_SAVE.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_PRINT_ON_SAVE.mlm new file mode 100644 index 0000000..3f84572 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_PRINT_ON_SAVE.mlm @@ -0,0 +1,150 @@ +maintenance: + + title: ProgressNote_PrintOnSave;; + mlmname: DOC_FUNC_PRINT_ON_SAVE;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Robert Spence;; + specialist: ;; + date: 2010-04-06;; + validation: testing;; + +library: + purpose: References a radio button on the Physician Progress Notes By System + On Document Open, forces the radio button to be false + On Document Close, if the radio button is false asks the user if they want to print to the nursing unit + If Yes, auto checks the radio button to true + If No, leaves the button as false from the document open logic + Document is sent out of the interface per config + If interface finds the print to nursing unit references, it formats and sends to netprint for distribution + ;; + explanation: + Change history + + 04-06-2010 RS Copied from DOC_FUNC_CHF for template + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + + // this makes pilot users only see the print option + user_IDCode := read last {"SELECT IDCode FROM CV3User with (nolock) " || + " where GUID = " || thisDocumentCommunication.UserGUID}; + + // add the pilot user login id to this list + pilotusers := ("jmiller","pkarish","ccorbett"); + // removed ,"lcivitarese" from pilot 07/30/2010 + printallowed:= false; + printallowed := user_IDCode in pilotusers; + + // marker end of pilot users, uncomment next line to work for all users, comment out to run for just pilot users + // printallowed := true; + + + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + ListValueType := OBJECT [ListGuid, ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + IF thisdocumentCommunication.EventType = "DocumentOpening" + then + + // Simply wish to reset the PRINT ON SAVE EVENT To False + // Therefore when the close event happens, we can ask the {{{SINGLE-QUOTE}}}do you want to print at nursing unit question again + + // Reference the radio button + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Print on save"); + + // create the object + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + // hard code the list object to be false + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := false; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + // send the object to the document + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + elseif thisdocumentCommunication.EventType = "DocumentClosing" and printallowed = true + then + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_Print on save"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + if true not in (theObservation.ValueObj.ListItemsList.IsSelected) + then + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "Would You Like To Print Directly To The Nursing Unit Now?" + ,"Direct Printing","YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}},"Button1" as {{{SINGLE-QUOTE}}}MessageBoxDefaultButton{{{SINGLE-QUOTE}}}; + + resulttext := dialogResult as string; + + if resulttext = "Yes" + then + + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := theParameter.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= theParameter.ConfigurationObj.ListGUID; + listItems := (); + + FOR item IN theParameter.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := true; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + endif; + endif; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_PRINT_OUTPATIENT_REPORTS.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_PRINT_OUTPATIENT_REPORTS.mlm new file mode 100644 index 0000000..ef733f7 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_PRINT_OUTPATIENT_REPORTS.mlm @@ -0,0 +1,91 @@ +maintenance: + + title: DOC_FUNC_PRINT_OUTPATIENT_REPORTS;; + mlmname: DOC_FUNC_PRINT_OUTPATIENT_REPORTS;; + arden: version 2.5;; + version: 5.50;; + institution: Allscripts;; + author: Shawn Head x7468;; + specialist: ;; + date: 2017-08-23;; + validation: testing;; + +library: + purpose: print Outpatient reports when print button selected on outpatient structured notes. + + ;; + explanation: The MLM is called from outpatient structured notes. Depending on the structured note that called the report determines which report(s) to print. + + Change history + + 08.23.2017 STH - CSR#: 35320 - Created + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + VisitGUID := thisDocumentCommunication.ClientVisitGUID; + ChartGUID := thisDocumentCommunication.ChartGUID; + ClientGUID := thisDocumentCommunication.ClientGUID; + DocName := thisDocumentCommunication.DocumentName; + PrintRPTObsName := ""; + SCMReportVersion := ""; + if(DocName matches pattern "%Discharge Instructions%") then + PrintRPTObsName := "SCH_Discharge Instruction Print"; + SCMReportVersion := "DischargeInstructionOutpatient"; + else + PrintRPTObsName := "SCH_OutPatient MedRec Print"; + SCMReportVersion := "Pre-Op Med Rec"; + endif; + + theParameter := first of (thisparameters where thisparameters.Name = PrintRPTObsName); + theObservation:= first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + PrintSelected := theObservation.ValueObj.ListItemsList[1].IsSelected; + + if PrintSelected + then + Report_Print_MLM := mlm {{{SINGLE-QUOTE}}}SCH_FUNC_PRINT{{{SINGLE-QUOTE}}}; + logicalprinter := "Default Report Printer"; physicalprinter:= ""; + print1 := call Report_Print_MLM with(SCMReportVersion, logicalprinter, physicalprinter); + + endif; + + ;; + priority: 50 + ;; + evoke: + + ;; + logic: + conclude true; + ;; + action: + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_PSYCH_OUTPATIENT_PROFILE_FALL_RISK_MEDS_OBS.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_PSYCH_OUTPATIENT_PROFILE_FALL_RISK_MEDS_OBS.mlm new file mode 100644 index 0000000..a101e47 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_PSYCH_OUTPATIENT_PROFILE_FALL_RISK_MEDS_OBS.mlm @@ -0,0 +1,227 @@ +maintenance: + + title: DOC_FUNC_PSYCH_OUTPATIENT_PROFILE_FALL_RISK_MEDS_OBS;; + mlmname: DOC_FUNC_PSYCH_OUTPATIENT_PROFILE_FALL_RISK_MEDS_OBS;; + arden: version 5.5;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Juliet Law;; + specialist: Dean Miklavic;; + date: 2012-02-21;; + validation: testing;; + +library: + purpose: + ;; + explanation: Limit Observation selections under the Fall Risk Medications to prevent erroneous selections. + Effects the Adult Patient Profile - Behavioral Health Outpatient document. + + Change history + + 02.21.2012 JML Create date. + ;; + keywords: psych, outpatient, profile, fall risk, medications + ;; +knowledge: + type: data-driven;; + data: + + // Receive arguments from the structured note + (this_documentCommunication) := argument; + + // .Net assemblies required for ObjectsPlus + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + local_session := cds_session.local; + + //List of first three Fall Risk Medications Observation Values + USER_CONFIG_PARAMETERS_RESTRICTED := ("No Medications", + "Cardiac Medications", + "Psychotropic Medications (incl. benzos & antidepressants)"); + //List of last Fall Risk Medications Observation Value + USER_CONFIG_PARAMETERS_RESTRICTED2 := ("Increase in these meds &/or psy/pain PRN meds rec’d last 24", + "EOL"); + + //Document Types + STRUCTUREDNOTE := "StructuredNote"; + + //Event Types + DOCUMENTCLOSING := "DocumentClosing"; + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTOPENING := "DocumentOpening"; + + //Setting debugFlag to True will allow popup dialogs containing debug information to appear + debugFlag := false; + + // DocumentCommunication Object Model variables + (thisStructuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Get the client, visit, chart, and user GUIDs + clientGuid := this_documentCommunication.ClientGUID; + visitGuid := this_documentCommunication.ClientVisitGUID; + chartGuid := this_documentCommunication.ChartGUID; + userGuid := this_documentCommunication.UserGUID; + + //Set up debugging information to be captured + messageText := ""; + if (debugFlag = true) then + messageText := "Debug Information:\n\n"; + messageText := messageText || " DOC_FUNC_PSYCH_OUTPATIENT_PROFILE_FALL_RISK_MEDS_OBS mlm called.\n\n"; + endif; + + // Parameter that will trigger the restriction of the Fall Risk Medications values + theParameterName := "SCHCK_BH_Fall Risk Meds"; + theDocumentName := "Adult Patient Profile - Behavioral Health Outpatient"; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + + //Only perform this MLM when charting an Observation on the Behavioral Health Outpatient patient profile + if (this_documentCommunication.EventType = CHARTOBSERVATION AND this_documentCommunication.DocumentName = theDocumentName) then + + //Retrieve Parameter and Observation Value + theParameter := first of (thisParameters where thisParameters.Name = theParameterName); + theObservation := first of (thisObservations where thisObservations.ParameterGUID = theParameter.ParameterGUID); + + if (this_documentCommunication.CurrentObservationObj.ParameterGUID = theParameter.ParameterGUID) then + //Build a list of selected values + selectionList := (theObservation.ValueObj.ListItemsList.Value + where theObservation.ValueObj.ListItemsList.IsSelected = true); + + //If User only selected one checkbox, determine if it was the last value and set session variable + if ((count selectionList) = 1) then + + if (first of (selectionList) IN USER_CONFIG_PARAMETERS_RESTRICTED2) then + local_session.SessionFallRiskMedLast := true; + else + local_session.SessionFallRiskMedLast := false; + endif; + + //If user has selected two checkboxes, again determine if the last checkbox was selected first via session + //variable and restrict checkbox selection accordingly + elseif ((count selectionList) = 2) then + + //Last checkbox was selected first, do not allow user to select any of the first 3 values + if (local_session.SessionFallRiskMedLast = true) then + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := theParameter.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := NEW ListValueType; + this_currentObj.ValueObj.ListGUID := theParameter.ConfigurationObj.ListGUID; + listItems := (); + + for item IN theParameter.ConfigurationObj.ListItemsList do + + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if (selectedItem.Value IN USER_CONFIG_PARAMETERS_RESTRICTED) then + selectedItem.IsSelected := false; + endif; + if (selectedItem.Value IN USER_CONFIG_PARAMETERS_RESTRICTED2) then + selectedItem.IsSelected := true; + endif; + + listItems := (listItems, selectedItem); + enddo; + + this_currentObj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, this_currentObj); + + //Last checkbox was NOT selected first, do not allow user to select the last checkbox + elseif (local_session.SessionFallRiskMedLast = false) then + the_currentObj := NEW ObservationType; + the_currentObj.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + the_currentObj.ParameterGUID := theParameter.ParameterGUID; + the_currentObj.DataType := "ListValue"; + the_currentObj.ValueObj := NEW ListValueType; + the_currentObj.ValueObj.ListGUID := theParameter.ConfigurationObj.ListGUID; + listItems := (); + + for item IN theParameter.ConfigurationObj.ListItemsList do + + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if (selectedItem.Value IN USER_CONFIG_PARAMETERS_RESTRICTED AND selectedItem.Value IN selectionList) then + selectedItem.IsSelected := true; + endif; + if (selectedItem.Value IN USER_CONFIG_PARAMETERS_RESTRICTED AND NOT selectedItem.Value IN selectionList) then + selectedItem.IsSelected := false; + endif; + + if (selectedItem.Value IN USER_CONFIG_PARAMETERS_RESTRICTED2) then + selectedItem.IsSelected := false; + endif; + + listItems := (listItems, selectedItem); + enddo; + the_currentObj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, the_currentObj); + + endif; + + //User has selected more than 2 checkboxes + //Safe to assume that the last checkbox has not been selected first, do not allow user to select the last checkbox + elseif (count selectionList > 2) then + if (last of (selectionList) IN USER_CONFIG_PARAMETERS_RESTRICTED2) then + + the_currentObj := NEW ObservationType; + the_currentObj.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID; + the_currentObj.ParameterGUID := theParameter.ParameterGUID; + the_currentObj.DataType := "ListValue"; + the_currentObj.ValueObj := NEW ListValueType; + the_currentObj.ValueObj.ListGUID := theParameter.ConfigurationObj.ListGUID; + listItems := (); + + for item IN theParameter.ConfigurationObj.ListItemsList do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if (selectedItem.Value IN USER_CONFIG_PARAMETERS_RESTRICTED AND selectedItem.Value IN selectionList) then + selectedItem.IsSelected := true; + endif; + if (selectedItem.Value IN USER_CONFIG_PARAMETERS_RESTRICTED AND NOT selectedItem.Value IN selectionList) then + selectedItem.IsSelected := false; + endif; + + if (selectedItem.Value IN USER_CONFIG_PARAMETERS_RESTRICTED2) then + selectedItem.IsSelected := false; + endif; + + listItems := (listItems, selectedItem); + enddo; + the_currentObj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, the_currentObj); + + endif; + endif; //End selectionList Count + + endif; //End Observation Parameter GUID = Parameter GUID + endif; //End EventType and DocumentName check + + if (debugFlag = true) then + messageText := messageText || "\n DOC_FUNC_PSYCH_OUTPATIENT_PROFILE_FALL_RISK_MEDS_OBS mlm completed.\n\n"; + this_documentCommunication.DisplayMessage := true; + this_documentCommunication.Message := messageText; + endif; + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_RISK_CATEGORY.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_RISK_CATEGORY.mlm new file mode 100644 index 0000000..ef63c3d --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_RISK_CATEGORY.mlm @@ -0,0 +1,270 @@ +maintenance: + + title: DOC_FUNC_RISK_CATEGORY;; + mlmname: DOC_FUNC_RISK_CATEGORY;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Janet Nordin;; + specialist: Don Warnick;; + date: 2017-10-17;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 10.17.2017 DW CSR# 36030 Elder Risk (renamed Risk Category then renamed Readmission Risk) + 08.27.2018 DW CSR# 36721 Risk Score Enhancement - increase the score via the EPN + + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + + (thisDocumentCommunication) := argument; + + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + ThisDocumentGuid := thisStructuredNoteDoc.ClientDocumentGUID; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + +if thisdocumentCommunication.EventType = "ChartObservation" and thisDocumentCommunication.DocumentName in ("Physician Progress Note" , "Readmission Risk Planning") + + then + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_Readmission Risk based on clinical judgement"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Yes") + then + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n\nClicking {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} will automatically add 14 points to the overall Readmission Risk Score calculation. The patient{{{SINGLE-QUOTE}}}s score will increase to either high or very high risk category (depending on comorbidities).\n\n", "Readmission Risk Adjustment","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + +endif; + + + +if ( thisdocumentCommunication.EventType = "DocumentClosing" and thisDocumentCommunication.DocumentName in ("Adult Patient Profile" , "Adult Patient Profile - Observation" , "Physician Progress Note" , "Readmission Risk Planning") ) + + or + + ( thisdocumentCommunication.EventType = "ChartObservation" and thisDocumentCommunication.DocumentName = "Discharge Instructions (Post Hospital Care Orders)" ) + + + then + + + + // Gather Data + + + + (MaritalStatus,PatientAge) := read last + {" + select MaritalStatusCode, + case when + right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (datepart (MM,getdate()) as varchar),2) + right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (datepart (DD,getdate()) as varchar),2) < + right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (birthmonthnum as varchar),2) + right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (birthdaynum as varchar),2) + then datediff (yy, cast (birthyearnum as varchar) ,getdate()) -1 + else datediff (yy, cast (birthyearnum as varchar) ,getdate()) + end + from cv3client with (nolock) where guid = " || clientGuid || " + "}; + + + HospitalDays := read last + {" + select datediff(day, v.admitdtm, getdate()) + from cv3clientvisit v with (nolock) + where v.clientGUID = " || clientguid || " and v.guid = " || visitguid || " + "}; + + + RelevantProblems := read + {" + select distinct + case + when chi.code like {{{SINGLE-QUOTE}}}I21%{{{SINGLE-QUOTE}}} or chi.code like {{{SINGLE-QUOTE}}}I22%{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}AMI{{{SINGLE-QUOTE}}} + when chi.code like {{{SINGLE-QUOTE}}}I25%{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}CAD{{{SINGLE-QUOTE}}} + when (chi.code >= {{{SINGLE-QUOTE}}}C00{{{SINGLE-QUOTE}}} and chi.code < {{{SINGLE-QUOTE}}}C97{{{SINGLE-QUOTE}}}) or (chi.code >= {{{SINGLE-QUOTE}}}D00{{{SINGLE-QUOTE}}} and chi.code < {{{SINGLE-QUOTE}}}D10{{{SINGLE-QUOTE}}}) or (chi.code >= {{{SINGLE-QUOTE}}}D32{{{SINGLE-QUOTE}}} and chi.code < {{{SINGLE-QUOTE}}}D34{{{SINGLE-QUOTE}}}) or (chi.code >= {{{SINGLE-QUOTE}}}D35.2{{{SINGLE-QUOTE}}} and chi.code < {{{SINGLE-QUOTE}}}D35.5{{{SINGLE-QUOTE}}}) or (chi.code >= {{{SINGLE-QUOTE}}}D42{{{SINGLE-QUOTE}}} and chi.code < {{{SINGLE-QUOTE}}}D44{{{SINGLE-QUOTE}}}) + or (chi.code >= {{{SINGLE-QUOTE}}}D44.3{{{SINGLE-QUOTE}}} and chi.code <= {{{SINGLE-QUOTE}}} D44.5{{{SINGLE-QUOTE}}}) or (chi.code like {{{SINGLE-QUOTE}}}D46.%{{{SINGLE-QUOTE}}}) or (chi.code like {{{SINGLE-QUOTE}}}D47.Z%{{{SINGLE-QUOTE}}}) + or chi.code in ({{{SINGLE-QUOTE}}}D18.02{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}D18.1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}D45{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}D47.1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}D47.3{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}D47.4{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}D47.7{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}D47.9{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}D49.6{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}D49.7{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Z51.0{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Z51.1{{{SINGLE-QUOTE}}}) then {{{SINGLE-QUOTE}}}Cancer{{{SINGLE-QUOTE}}} + when (chi.code >= {{{SINGLE-QUOTE}}}J41{{{SINGLE-QUOTE}}} and chi.code < {{{SINGLE-QUOTE}}}J45{{{SINGLE-QUOTE}}}) then {{{SINGLE-QUOTE}}}COPD{{{SINGLE-QUOTE}}} + when (chi.code >= {{{SINGLE-QUOTE}}}F01{{{SINGLE-QUOTE}}} and chi.code < {{{SINGLE-QUOTE}}}F04{{{SINGLE-QUOTE}}}) or chi.code like {{{SINGLE-QUOTE}}}F05%{{{SINGLE-QUOTE}}} or chi.code in ({{{SINGLE-QUOTE}}}F1027{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}F1098{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}F1927{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}F1997{{{SINGLE-QUOTE}}}) then {{{SINGLE-QUOTE}}}Dementia{{{SINGLE-QUOTE}}} + when (chi.code >= {{{SINGLE-QUOTE}}}E08{{{SINGLE-QUOTE}}} and chi.code < {{{SINGLE-QUOTE}}}E12{{{SINGLE-QUOTE}}}) or (chi.code >= {{{SINGLE-QUOTE}}}O24.0{{{SINGLE-QUOTE}}} and chi.code <= {{{SINGLE-QUOTE}}}O24.1{{{SINGLE-QUOTE}}}) or (chi.code >= {{{SINGLE-QUOTE}}}O24.8{{{SINGLE-QUOTE}}} and chi.code < {{{SINGLE-QUOTE}}}O25{{{SINGLE-QUOTE}}}) or chi.code like {{{SINGLE-QUOTE}}}E13%{{{SINGLE-QUOTE}}} or chi.code like {{{SINGLE-QUOTE}}}O24.3%{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}Diabetes{{{SINGLE-QUOTE}}} + when chi.code like {{{SINGLE-QUOTE}}}I50%{{{SINGLE-QUOTE}}} or chi.code in ({{{SINGLE-QUOTE}}}I110{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}I130{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}I132{{{SINGLE-QUOTE}}}) then {{{SINGLE-QUOTE}}}HeartFailure{{{SINGLE-QUOTE}}} + when chi.code like {{{SINGLE-QUOTE}}}I60%{{{SINGLE-QUOTE}}} or chi.code like {{{SINGLE-QUOTE}}}I63%{{{SINGLE-QUOTE}}} or chi.code in ({{{SINGLE-QUOTE}}}G45.8{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}O99.411{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}O99.413{{{SINGLE-QUOTE}}}) then {{{SINGLE-QUOTE}}}Stroke{{{SINGLE-QUOTE}}} + else {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} end + + from CV3HealthIssueDeclaration hid with (nolock) + join CV3CodedHealthIssue chi with (nolock) on chi.guid = hid.CodedHealthIssueGUID + where hid.typecode in ({{{SINGLE-QUOTE}}}Admitting Dx{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Admit Diag{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Discharge Diag{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}MR-Admit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}MR-Principal{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Visit{{{SINGLE-QUOTE}}}) and hid.CodingScheme = {{{SINGLE-QUOTE}}}ICD10{{{SINGLE-QUOTE}}} and hid.Status = {{{SINGLE-QUOTE}}}active{{{SINGLE-QUOTE}}} + and + ( + chi.code like {{{SINGLE-QUOTE}}}I21%{{{SINGLE-QUOTE}}} or chi.code like {{{SINGLE-QUOTE}}}I22%{{{SINGLE-QUOTE}}} + or chi.code like {{{SINGLE-QUOTE}}}I25%{{{SINGLE-QUOTE}}} + or(chi.code >= {{{SINGLE-QUOTE}}}C00{{{SINGLE-QUOTE}}} and chi.code < {{{SINGLE-QUOTE}}}C97{{{SINGLE-QUOTE}}}) or (chi.code >= {{{SINGLE-QUOTE}}}D00{{{SINGLE-QUOTE}}} and chi.code < {{{SINGLE-QUOTE}}}D10{{{SINGLE-QUOTE}}}) or (chi.code >= {{{SINGLE-QUOTE}}}D32{{{SINGLE-QUOTE}}} and chi.code < {{{SINGLE-QUOTE}}}D34{{{SINGLE-QUOTE}}}) or (chi.code >= {{{SINGLE-QUOTE}}}D35.2{{{SINGLE-QUOTE}}} and chi.code < {{{SINGLE-QUOTE}}}D35.5{{{SINGLE-QUOTE}}}) or (chi.code >= {{{SINGLE-QUOTE}}}D42{{{SINGLE-QUOTE}}} and chi.code < {{{SINGLE-QUOTE}}}D44{{{SINGLE-QUOTE}}}) + or (chi.code >= {{{SINGLE-QUOTE}}}D44.3{{{SINGLE-QUOTE}}} and chi.code <= {{{SINGLE-QUOTE}}} D44.5{{{SINGLE-QUOTE}}}) or (chi.code like {{{SINGLE-QUOTE}}}D46.%{{{SINGLE-QUOTE}}}) or (chi.code like {{{SINGLE-QUOTE}}}D47.Z%{{{SINGLE-QUOTE}}}) + or chi.code in ({{{SINGLE-QUOTE}}}D18.02{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}D18.1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}D45{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}D47.1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}D47.3{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}D47.4{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}D47.7{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}D47.9{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}D49.6{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}D49.7{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Z51.0{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Z51.1{{{SINGLE-QUOTE}}}) + or (chi.code >= {{{SINGLE-QUOTE}}}J41{{{SINGLE-QUOTE}}} and chi.code < {{{SINGLE-QUOTE}}}J45{{{SINGLE-QUOTE}}}) + or (chi.code >= {{{SINGLE-QUOTE}}}F01{{{SINGLE-QUOTE}}} and chi.code < {{{SINGLE-QUOTE}}}F04{{{SINGLE-QUOTE}}}) or chi.code like {{{SINGLE-QUOTE}}}F05%{{{SINGLE-QUOTE}}} or chi.code in ({{{SINGLE-QUOTE}}}F1027{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}F1098{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}F1927{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}F1997{{{SINGLE-QUOTE}}}) + or (chi.code >= {{{SINGLE-QUOTE}}}E08{{{SINGLE-QUOTE}}} and chi.code < {{{SINGLE-QUOTE}}}E12{{{SINGLE-QUOTE}}}) or (chi.code >= {{{SINGLE-QUOTE}}}O24.0{{{SINGLE-QUOTE}}} and chi.code <= {{{SINGLE-QUOTE}}}O24.1{{{SINGLE-QUOTE}}}) or (chi.code >= {{{SINGLE-QUOTE}}}O24.8{{{SINGLE-QUOTE}}} and chi.code < {{{SINGLE-QUOTE}}}O25{{{SINGLE-QUOTE}}}) or chi.code like {{{SINGLE-QUOTE}}}E13%{{{SINGLE-QUOTE}}} or chi.code like {{{SINGLE-QUOTE}}}O24.3%{{{SINGLE-QUOTE}}} + or chi.code like {{{SINGLE-QUOTE}}}I50%{{{SINGLE-QUOTE}}} or chi.code in ({{{SINGLE-QUOTE}}}I110{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}I130{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}I132{{{SINGLE-QUOTE}}}) + or chi.code like {{{SINGLE-QUOTE}}}I60%{{{SINGLE-QUOTE}}} or chi.code like {{{SINGLE-QUOTE}}}I63%{{{SINGLE-QUOTE}}} or chi.code in ({{{SINGLE-QUOTE}}}G45.8{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}O99.411{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}O99.413{{{SINGLE-QUOTE}}}) + ) + and hid.clientguid = " || clientguid || " + "}; + + + PhysicianUpgrade := read last + {" + select fs.Value + from CV3ObsCatalogMasterItem ocmi with (nolock) + inner join SXACDObservationParameter obsparam with (nolock) on obsparam.ClientGUID = " || clientguid || " and obsparam.ChartGUID = " || chartguid || " and obsparam.ClientVisitGUID = " || visitGuid || " and obsparam.ObsMasterItemGUID = ocmi.GUID and obsparam.IsCanceled = 0 + left outer join SCMObsFSListValues fs with (nolock) on fs.ClientGUID = " || clientguid || " and ObsParam.ObservationDocumentGUID = fs.ParentGUID + where ocmi.name = {{{SINGLE-QUOTE}}}SCH_Readmission Risk based on clinical judgement{{{SINGLE-QUOTE}}} and fs.Value= {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} + order by obsparam.RecordedDtm desc + "}; + + + // Determine if the Physician Upgrade question "Yes" radio button has been selected + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_Readmission Risk based on clinical judgement"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Yes") then PhysicianUpgradeButtonSelected := "yes"; endif; + + + // Calculate the Risk Score + + + RiskProblem:= 0; + + indexList := 1 seqto count (RelevantProblems); + for i in indexList do + ProblemType := last (first i from RelevantProblems); + if ProblemType = "AMI" then RiskProblem := RiskProblem + 3; endif; + if ProblemType = "CAD" then RiskProblem := RiskProblem + 3; endif; + if ProblemType = "Cancer" then RiskProblem := RiskProblem + 1; endif; + if ProblemType = "COPD" then RiskProblem := RiskProblem + 5; endif; + if ProblemType = "Dementia" then RiskProblem := RiskProblem + 3; endif; + if ProblemType = "Diabetes" then RiskProblem := RiskProblem + 2; endif; + if ProblemType = "HeartFailure" then RiskProblem := RiskProblem + 3; endif; + if ProblemType = "Stroke" then RiskProblem := RiskProblem + 2; endif; + enddo; + + + RiskAge:= 0; + + if PatientAge > 69 and PatientAge < 80 then RiskAge := 1; + elseif PatientAge > 79 and PatientAge < 90 then RiskAge := 3; + elseif PatientAge > 89 then RiskAge := 1; + endif; + + + RiskHospitalDays:= 0; + + if HospitalDays > 0 and HospitalDays < 6 then RiskHospitalDays := 5; + elseif HospitalDays > 5 then RiskHospitalDays := 11; + endif; + + RiskMarital:= 0; + + if MaritalStatus = "Married" then RiskMarital := -1; endif; + + + RiskPhysicianUpgrade:= 0; + + if PhysicianUpgrade is not null or PhysicianUpgradeButtonSelected = "yes" then RiskPhysicianUpgrade := 14; endif; + + + RiskScore := RiskProblem + RiskAge + RiskMarital + RiskHospitalDays + RiskPhysicianUpgrade; + + RiskScoreText:= " "; + + if RiskScore >= -1 and RiskScore <= 6 then RiskScoreText := "Very Low (1)"; + elseif RiskScore >= 7 and RiskScore <= 9 then RiskScoreText := "Low (2)"; + elseif RiskScore >= 10 and RiskScore <= 12 then RiskScoreText := "Moderate (3)"; + elseif RiskScore >= 13 and RiskScore <= 15 then RiskScoreText := "High (4)"; + elseif RiskScore >= 16 then RiskScoreText := "Very High (5)"; + endif; + + // Write to the Structured Note Text Box + /* + Evidence:= " Problems: " || RelevantProblems || + " Marital: " || MaritalStatus || + " Days: " || HospitalDays || + " Age: " || PatientAge || + " Score: " || RiskScore || + ""; + */ + FreeTextBox := first of (thisParameters where thisParameters.Name = "SCH_READMISSION RISK"); + + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := FreeTextBox.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := RiskScoreText; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + + + CreateColumnMLM := MLM {{{SINGLE-QUOTE}}}SCH_FUNC_CREATE_ENTERPRISE_DEFINED_COLUMN{{{SINGLE-QUOTE}}}; // MLM that creates the Enterprise Defined Column in the "Action" section of the MLM + ColumnObj := OBJECT [column_name,column_value,client_guid,chart_guid,client_visit_guid]; // Create Enterprise Defined Column Obj + + + // Update the Risk Category Column + + RiskCategory_Column := NEW ColumnObj WITH + [ + column_name := "Readmission Risk", + column_value := RiskScoreText, + client_guid := clientguid, + chart_guid := chartguid, + client_visit_guid := visitguid + ]; + return_value := call CreateColumnMLM with ( RiskCategory_Column ); + + + +endif; + + + + ;; + evoke: + ;; + logic: conclude true; + + ;; + action: + + + return thisDocumentCommunication; + + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_STROKE_LAST_KNOWN_WELL_CALC.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_STROKE_LAST_KNOWN_WELL_CALC.mlm new file mode 100644 index 0000000..702f0ee --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_STROKE_LAST_KNOWN_WELL_CALC.mlm @@ -0,0 +1,143 @@ +maintenance: + + title: DOC_FUNC_STROKE_LAST_KNOWN_WELL_CALC;; + mlmname: DOC_FUNC_STROKE_LAST_KNOWN_WELL_CALC;; + arden: version 5.5;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Don Warnick;; + specialist: ;; + date: 2011-06-06;; + validation: testing;; + +library: + purpose: This MLM determine if the last known well time prior to a stroke is within 2 hours of the admit time. + It then updates the radio button associated with this question in the ED Triage Note + ;; + explanation: This value is needed for meaningful use. + + Change history + + 06.06.2011 DW Created + 06.30.2011 DW Revised the admit date routine. Now using first transferrequestdtm rather than last admitdtm + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + +// Find the "last well time" entered by the user + + this_parametername := first of (thisParameters where thisParameters.Name = "sch_edtriage_stroke date and time"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = this_parametername.ParameterGUID); + datefield := theObservation.ValueObj.Value; + +// Find the patient admit date and time + + + admitted := read first +{" select top 1 cvl.transferrequestdtm from cv3clientvisit cv with (nolock) " +||" join cv3clientvisitlocation cvl with (nolock) on cvl.clientguid = cv.clientguid and cvl.clientvisitguid = cv.guid " +||" join cv3location l with (nolock) on l.guid = cvl.locationguid " +||" where cv.clientguid = " || ClientGuid || " and cv.chartguid = " || Chartguid || " and cv.guid = " || VisitGuid || " " +||" " }; + + +/* +Removed on 6/30 to provide the accurate present in ED timestamp. The admitdtm field changes with new locations + + admittedold := read last +{" select cv.admitdtm from cv3clientvisit cv with (nolock) " +||" where cv.clientguid = " || ClientGuid || " and cv.chartguid = " || Chartguid || " and cv.guid = " || VisitGuid || " " +||" " }; +*/ + + +// Find the duration betwen "last well time" and the "admit time"(format of "9 months, 999 seconds" converted to hours) + +duration_with_verbiage := (admitted - datefield)/3600; + +// Find the length of the "time value only" (the characters between the verbiage using - between "months," and "seconds") + +only_time_length := ((FIND "se" IN STRING (duration_with_verbiage as string))- (FIND "," IN STRING (duration_with_verbiage as string))-1); + +// Return the "hours" + +duration_hours := SUBSTRING only_time_length CHARACTERS STARTING AT ((FIND "," IN STRING (duration_with_verbiage as string)) + 1) from (duration_with_verbiage as string); + + + +// Fill the calculation field + +if (duration_hours as number) < 0 then + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "The {{{SINGLE-QUOTE}}}Stroke Last Known Well Date and Time{{{SINGLE-QUOTE}}} that was entered is after the admit time." ,"Error","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + hrs := " "; + + elseif (duration_hours as number) is null then + hrs := " "; + + else + hrs := (duration_hours as number); + +endif; + + if hrs < 2 then within2hours := "yes"; else within2hours := "no"; endif; + + this_parametername := first of (thisParameters where thisParameters.Name = "sch_edtriage_Stroke less than 2 hours"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "yes" and within2hours = "yes" then selectedItem.IsSelected := true; endif; + if selectedItem.Value = "no" and within2hours = "no" then selectedItem.IsSelected := true; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_SUICIDAL_OR_VIOLENT.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_SUICIDAL_OR_VIOLENT.mlm new file mode 100644 index 0000000..0061be8 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_SUICIDAL_OR_VIOLENT.mlm @@ -0,0 +1,1221 @@ +maintenance: + + title: DOC_FUNC_SUICIDAL_OR_VIOLENT;; + mlmname: DOC_FUNC_SUICIDAL_OR_VIOLENT;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: GMS;; + specialist: Don Warnick ;; + date: 2018-05-23;; + validation: testing;; + +library: + purpose: + ;; + explanation: Upon open of the ED Triage Note, this MLM will retrieve suicide & violence risk information from past visits and update an observation textbox. + Upon save of the ED Triage Note, it will update the Suicide Violence status board column with the latest information. + + + Change history + + 05.23.2018 DW CSR# 36510 Harm to Self or Others - Created + 07.03.2018 DW CSR# 36510 added this response which is configured in the Paient Profile "NA under 12 years of age". There is no comma after the "NA" as there is in the ED Triage Note. + 07.06.2018 DW CSR# 36510 added code to support the "discrepancy between past history and patient responses" checkbox + 07.25.2018 DW CSR# 36510 Harm to Self or Others - Changes required for inpatient processes + 10.30.2018 DW CSR# 36510 Harm to Self or Others - Changes required for inpatient processes - requested changes ("notify md" order verbiage change) + 08.06.2019 DW CSR# 38551 Redesign based upon JACHO observations + 09.03.2019 DW CSR# 38604 Columbia Severity Note for Outpatients and Adult Patient Profile Behavioral Health Outpatients + + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + local_session := cds_session.local; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + ClientGUID := thisDocumentCommunication.ClientGUID; + ChartGUID := thisDocumentCommunication.ChartGUID; + VisitGUID := thisDocumentCommunication.ClientVisitGUID; + userGuid := thisDocumentCommunication.UserGUID; + + + document_event_enter := event {ClientDocumentEnter User ClientDocument: where documentname = "ED Triage Note" or documentname matches pattern "%Patient Profile" }; + document_event_modify := event {ClientDocumentModify User ClientDocument: where documentname = "ED Triage Note" or documentname matches pattern "%Patient Profile" }; + + + // If evoked by document enter or document modify, attain the guids + + If EvokingEventType = document_event_modify.type or EvokingEventType = document_event_enter.type + then + (VisitGUID, ChartGUID, ClientGUID) := read last {ClientDocument: ClientVisitGUID, ChartGUID, ClientGUID REFERENCING EvokingObject}; + endif; + + + + // Determine the type of Structured Note + + if thisDocumentCommunication.DocumentName = "Adult Patient Profile - Behavioral Health Outpatient" + then + current_document_type := "behv_outpatient_patient_profile"; + has_orders := "no"; + + elseif thisDocumentCommunication.DocumentName matches pattern "%Profile%" + then + current_document_type := "patient_profile"; + orders_observation_name:= "SCH_PSY_Risk OrdersInp"; // List of order checkboxes + has_orders := "yes"; + + elseif thisDocumentCommunication.DocumentName = "ED Triage Note" + then + current_document_type := "triage_note"; + orders_observation_name:= "SCH_PSY_Risk Orders"; // List of order checkboxes + has_orders := "yes"; + + else + current_document_type := "columbia_outpatient"; + has_orders := "no"; + endif; + + + + + If thisdocumentCommunication.EventType = "DocumentOpening" or thisdocumentCommunication.EventType is null then + + + // Gather past history (...only for "DocumentOpening" & "Document modify/enter"...unneeded for other events) + + + SignificantEvent := read + {" + select + case when (c.OnsetYearNum is null and c.OnsetMonthNum is null) or (c.OnsetYearNum = 0 and c.OnsetMonthNum = 0) then cast (convert(char(10), c.CreatedWhen,20)as varchar) + when c.OnsetYearNum is not null and c.OnsetYearNum <> 0 and c.OnsetMonthNum is not null and c.OnsetMonthNum <> 0 and c.OnsetDayNum is not null and c.OnsetDayNum <> 0 then cast (c.OnsetYearNum as varchar) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + cast (c.OnsetMonthNum as varchar) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + cast (c.OnsetDayNum as varchar) + else + case + when c.OnsetYearNum is not null and c.OnsetMonthNum = 0 then cast (c.OnsetYearNum as varchar) + when c.OnsetYearNum is not null and c.OnsetMonthNum > 0 then cast (c.OnsetYearNum as varchar) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + cast (c.OnsetMonthNum as varchar) + end + end + + case when c.TypeCode = {{{SINGLE-QUOTE}}}Violence-Clinical Support Team{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}} - Flagged for Violence Caution by the Clinical Support Team (see significant event){{{SINGLE-QUOTE}}} + when c.TypeCode = {{{SINGLE-QUOTE}}}Behavioral Health{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}} - Flagged by Mental Health for {{{SINGLE-QUOTE}}} + c.Description + {{{SINGLE-QUOTE}}} (see significant event){{{SINGLE-QUOTE}}} + end + + {{{SINGLE-QUOTE}}}\n{{{SINGLE-QUOTE}}} + from CV3ClientEventDeclaration c with (nolock) + where c.TypeCode in ({{{SINGLE-QUOTE}}}Violence-Clinical Support Team{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Behavioral Health{{{SINGLE-QUOTE}}}) and c.status = {{{SINGLE-QUOTE}}}active{{{SINGLE-QUOTE}}} and c.ClientGUID = " || ClientGuid || " + order by c.CreatedWhen + "}; + + + SuidcideObservation := read + {" + SET CONCAT_NULL_YIELDS_NULL off + select cast (convert(char(10), obsparam.RecordedDtm,20)as varchar) + {{{SINGLE-QUOTE}}} - {{{SINGLE-QUOTE}}} + + case when ocmi.name = {{{SINGLE-QUOTE}}}SCH_PSY_Wish to be Dead{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}Have you wished you were dead or wished you could sleep and not wake up?{{{SINGLE-QUOTE}}} + when ocmi.name = {{{SINGLE-QUOTE}}}SCH_PSY_Suicidal Thoughts{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}Have you actually had any thoughts of killing yourself?{{{SINGLE-QUOTE}}} + when ocmi.name = {{{SINGLE-QUOTE}}}SCH_PSY_Suicide Behavior Question{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}Have you ever done, started, prepared to end your life?{{{SINGLE-QUOTE}}} + else ocmi.LeftJustifiedLabel + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + ocmi.RightJustifiedLabel + end + + {{{SINGLE-QUOTE}}} - {{{SINGLE-QUOTE}}} + {{{SINGLE-QUOTE}}} ({{{SINGLE-QUOTE}}} + fs.Value + obsparam.ValueText +{{{SINGLE-QUOTE}}}){{{SINGLE-QUOTE}}} + + {{{SINGLE-QUOTE}}}\n{{{SINGLE-QUOTE}}} + from CV3ObsCatalogMasterItem ocmi with (nolock) + inner join SXACDObservationParameter obsparam with (nolock) on " || ClientGuid || " = obsparam.ClientGUID and obsparam.ObsMasterItemGUID = ocmi.GUID and obsparam.IsCanceled = 0 + left outer join SCMObsFSListValues fs with (nolock) on fs.ClientGUID = " || ClientGuid || " and ObsParam.ObservationDocumentGUID = fs.ParentGUID + where + ( + ( + ocmi.name like ({{{SINGLE-QUOTE}}}%hurt%{{{SINGLE-QUOTE}}}) or ocmi.name in ({{{SINGLE-QUOTE}}}SCH_PSY_Wish to be Dead{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_PSY_Suicidal Thoughts{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_PSY_Suicide Behavior Question{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}CAS psych suicide homicide ideation{{{SINGLE-QUOTE}}}) + ) + and fs.value not in ({{{SINGLE-QUOTE}}}no{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Not at all{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Unable to answer due to clinical condition{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}NA, under 12 years of age{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}NA under 12 years of age{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Unable to respond or under 12 years of age{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}neither{{{SINGLE-QUOTE}}}) + ) + or ocmi.name = {{{SINGLE-QUOTE}}}SCH_PSY_Columbia Risk Score{{{SINGLE-QUOTE}}} and obsparam.ValueText <> {{{SINGLE-QUOTE}}}No Risk{{{SINGLE-QUOTE}}} + + order by obsparam.RecordedDtm desc + "}; + + endif; + + + + + + // DOCUMENT OPEN SECTION + + + + + IF thisdocumentCommunication.EventType = "DocumentOpening" then + + + HarmText := ""; + + + // Concatenate the individual significant event items into a text variable (removes the commas) + + If exists SignificantEvent + then + SignificantEventText:= ""; + for i in 1 seqto count SignificantEvent do + SignificantEventText := SignificantEventText || SignificantEvent[i]; + enddo; + + HarmText:= SignificantEventText; + endif; + + + // Concatenate the individual suicide list items into a text variable (removes the commas) + + If exists SuidcideObservation + then + SuidcideObservationText:= ""; + for i in 1 seqto count SuidcideObservation do + SuidcideObservationText := SuidcideObservationText || SuidcideObservation[i]; + enddo; + + if HarmText = "" + then + HarmText := SuidcideObservationText; + else + HarmText := HarmText || SuidcideObservationText; + endif; + endif; + + + If HarmText = "" + then + HarmText := "No history of harming self or others has been found in the chart." ; + endif; + + + + // Populate past history free text box + + this_parametername := first of (thisParameters where thisParameters.Name = "sch_edtriage_Hurt History"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := HarmText; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + + // Determine which Orders were selected at Document Open (needed to prevent new orders from being created when the SN is updated for other reasons) + + + if has_orders = "yes" + + then + + PriorOrders:= " "; + + theParameter := first of (thisparameters where thisparameters.Name = orders_observation_name); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "MHRN Consult") then PriorOrders:= PriorOrders || "M"; endif; + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "SCO 1:1") then PriorOrders:= PriorOrders || "S"; endif; + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Notify MD (day/evening) PPM (nights)") then PriorOrders:= PriorOrders || "N"; endif; + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Self Harm Precautions/Observation Monitoring") then PriorOrders:= PriorOrders || "P"; endif; + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Constant Observation (CO)") then PriorOrders:= PriorOrders || "C"; endif; + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Implement Environmental Assessment for High Suicidal Risk") then PriorOrders:= PriorOrders || "E"; endif; + + + // Populate prior order selections free text box + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_PSY_Risk Orders Prior"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := PriorOrders; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; + + + + // Patient Profile only Section - if this is a new profile, populate Columbia question responses with the ED Triage responses from this visit + + + + + If current_document_type= "patient_profile" and thisStructuredNoteDoc.ClientDocumentGUID is null + + + then + + + // Gather the responses + + + SuidcideObservationThisVisit := read + {" + SET CONCAT_NULL_YIELDS_NULL off + select ocmi.name + {{{SINGLE-QUOTE}}}|{{{SINGLE-QUOTE}}} + isnull ((obsparam.valuetext + fs.Value), {{{SINGLE-QUOTE}}}X{{{SINGLE-QUOTE}}}) + from CV3ObsCatalogMasterItem ocmi with (nolock) + inner join SXACDObservationParameter obsparam with (nolock) on " || ClientGuid || " = obsparam.ClientGUID and obsparam.ChartGUID = " || ChartGuid || " and obsparam.ClientVisitGUID = " || VisitGuid || " and obsparam.ObsMasterItemGUID = ocmi.GUID and obsparam.IsCanceled = 0 + left outer join SCMObsFSListValues fs with (nolock) on fs.ClientGUID = " || ClientGuid || " and ObsParam.ObservationDocumentGUID = fs.ParentGUID + join CV3ClientDocument cd with (nolock) on cd.guid = obsparam.OwnerGUID + where + ocmi.name in ({{{SINGLE-QUOTE}}}SCH_PSY_Columbia Risk Score{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_PSY_Wish Dead Wake Up{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_PSY_Done Start Any to End Life{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_PSY_Think of How Might do{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_PSY_Work out Detail of How to and Carry Out{{{SINGLE-QUOTE}}}, + {{{SINGLE-QUOTE}}}SCH_PSY_THought and Intention of Acting{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_PSY_Actual Thought of Killing Self{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_PSY_Think of How Might do{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_PSY_How Long ago{{{SINGLE-QUOTE}}}) + and cd.DocumentName = {{{SINGLE-QUOTE}}}ed triage note{{{SINGLE-QUOTE}}} + and obsparam.ClientGUID = " || ClientGuid || " and obsparam.ChartGUID = " || ChartGuid || " and obsparam.ClientVisitGUID = " || VisitGuid || " + "}; + + // Loop through the responses looking for the risk score + + for i in 1 seqto count SuidcideObservationThisVisit DO + observation := SuidcideObservationThisVisit[i]; + if observation matches pattern "SCH_PSY_Columbia Risk Score%" then RiskScore:= substring ((length of observation) - (FIND "|" STRING observation)) CHARACTERS STARTING AT ((FIND "|" STRING observation) +1) FROM observation; endif; + enddo; + + + // Pre-populate the responses unless it is No Risk + + + if RiskScore <> "No Risk" + + + then + + // Loop through the responses and update the corresponding observation in this note + + for i in 1 seqto count SuidcideObservationThisVisit DO + observation := SuidcideObservationThisVisit[i]; + + ColumbiaQuestion := substring (FIND "|" STRING observation)-1 CHARACTERS STARTING AT 1 FROM observation; + ColumbiaResponse := substring ((length of observation) - (FIND "|" STRING observation)) CHARACTERS STARTING AT ((FIND "|" STRING observation) +1) FROM observation; + + if observation matches pattern "SCH_PSY_Columbia Risk Score%" + then + // Populate risk score value text box + this_parametername := first of (thisParameters where thisParameters.Name = ColumbiaQuestion); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := ColumbiaResponse; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + else + // Populate the other observations + this_parametername := first of (thisParameters where thisParameters.Name = ColumbiaQuestion ); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = ColumbiaResponse then selectedItem.IsSelected := true; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + + enddo; + + + // Populate risk score instructions text box + + + if RiskScore = "Low Risk" then protocol_instructions:= "Immediate notification of MD is required. Consider Special Constant Observation (SCO 1:1); Constant Observation and Safety Precautions/Observation Monitoring. Select the orders from below. If diet is being ordered: Add a Seclusion Tray with No Hot Beverages."; + elseif RiskScore = "Moderate Risk" then protocol_instructions:= "Immediate notification of MD is required. Constant Observation; Safety Precautions/Observation Monitoring orders will be automatically entered. If diet is being ordered:Add a Seclusion Tray with No Hot Beverages."; + elseif RiskScore = "High Risk" then protocol_instructions:= "Immediate notification of MD is required. Special Constant Observation (SCO 1:1); Environmental Assessment; Safety Precautions/Observation Monitoring orders will be automatically entered. If diet is being ordered: Add a Seclusion Tray with No Hot Beverages."; + endif; + + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_PSY_Risk Order Choices"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := protocol_instructions; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + // Select the appropriate Orders for the risk + + + this_parametername := first of (thisParameters where thisParameters.Name = orders_observation_name); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + + if RiskScore = "High Risk" or RiskScore = "Moderate Risk" + then + if selectedItem.Value = "SCO 1:1" then selectedItem.IsSelected := true; endif; + if selectedItem.Value = "Notify MD (day/evening) PPM (nights)" then selectedItem.IsSelected := true; endif; + if selectedItem.Value = "Safety Precautions/Observation Monitoring" then selectedItem.IsSelected := true; endif; + if selectedItem.Value = "Environmental Assessment" then selectedItem.IsSelected := true; endif; + endif; + + + listItems := (listItems, selectedItem); + + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; // Moderate or High Risk Section + + + endif; // Patient Profile Section + + + + + + // CHART OBSERVATION SECTION + + + + + + + elseif thisdocumentCommunication.EventType = "ChartObservation" then + + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_PSY_Discrepancy"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = ".") then nurseoverride := "yes"; endif; + + + // Determine which observation was selected if it is a Patient Profile or ED Triage Note (risk question vs order selection) + + if has_orders = "yes" + + then + theParameter := first of (thisparameters where thisparameters.Name = orders_observation_name); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + endif; + + + if (has_orders = "yes" and thisDocumentCommunication.CurrentObservationObj.parameterguid <> theParameter.ParameterGUID) or has_orders = "no" + + + then + + + // Risk Button or Descrepancy Checbox Selection Section + + + + // Determine which of the risk score buttons is selected + + + riskscore := 0 as number; + + theParameter := first of (thisparameters where thisparameters.Name matches pattern "SCH_PSY_Wish Dead Wake Up%" or thisparameters.Name matches pattern "SCH_PSY_Wish Dead WakeUp%"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") then riskscore := riskscore + 1 as number; endif; + + theParameter := first of (thisparameters where thisparameters.Name matches pattern "SCH_PSY_Actual Thought of Killing%"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes...") then riskscore := riskscore + 1 as number; endif; + + theParameter := first of (thisparameters where thisparameters.Name matches pattern "SCH_PSY_Think of How Might%"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") then riskscore := riskscore + 10 as number; endif; + + theParameter := first of (thisparameters where thisparameters.Name matches pattern "SCH_PSY_Thought and Intention%"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") then riskscore := riskscore + 20 as number; endif; + + theParameter := first of (thisparameters where thisparameters.Name matches pattern "SCH_PSY_Work out Detail of How to and Carry%"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") then riskscore := riskscore + 20 as number; endif; + + + theParameter := first of (thisparameters where thisparameters.Name matches pattern "SCH_PSY_How Long%"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Over a year ago") then riskscore := riskscore + 1 as number; + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Between 3 months and a year") then riskscore := riskscore + 10 as number; + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Within the last 3 months") then riskscore := riskscore + 20 as number; + endif; + + + + // Only found in the Columbia Severity Score for Outpatients Note + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_PSY_Risk Protect Factors"); // This one will elevate from Low to Moderate + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") and riskscore >= 0 and riskscore < 10 then riskscore := riskscore + 10 as number; endif; + + + + // Only found in the Behavioral Health Outpatient Note + + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_PSY_Recent hosp step down"); // This one will elevate from Low to Moderate + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") and riskscore >= 0 and riskscore < 10 then riskscore := riskscore + 10 as number; endif; + + + + + // Calculate the risk score value + + + If riskscore = 0 then riskscorevalue := "No Risk"; triage_instructions := "No Mental Health orders are necessary."; + profile_instructions := "No Mental Health orders are necessary."; + columbop_instructions:= "No Mental Health orders are necessary."; + + elseif riskscore >= 0 and riskscore < 10 then riskscorevalue := "Low Risk"; triage_instructions := "Consider ordering MHRN Consult and/or Special Constant Observation (SCO 1:1); or Constant Observation with Safety Precautions/Observation Monitoring if other risk factors are present. Select from below. If diet is being ordered: Add a Seclusion Tray with No Hot Beverages."; + profile_instructions := "Immediate notification of MD is required. Consider Special Constant Observation (SCO 1:1); Constant Observation and Safety Precautions/Observation Monitoring. Select the orders from below. If diet is being ordered: Add a Seclusion Tray with No Hot Beverages"; + columbop_instructions:= "Low:\n\n-Develop and or reinforce Crisis Safety Plan"; + + elseif riskscore >= 10 and riskscore < 20 then riskscorevalue := "Moderate Risk"; triage_instructions := "MHRN Consult; Constant Observation; Safety Precautions/Observation Monitoring; orders will be automatically entered. If diet is being ordered: Add a Seclusion Tray with No Hot Beverages"; + profile_instructions := "Immediate notification of MD is required. Constant Observation; Safety Precautions/Observation Monitoring orders will be automatically entered. If diet is being ordered:Add a Seclusion Tray with No Hot Beverages."; + columbop_instructions:= "Moderate: \n\n-Develop and or reinforce Crisis Safety Plan \n\n-Patient to complete Self Report form at each visit \n\n-Staff to review patient{{{SINGLE-QUOTE}}}s Self Report form at each visit and discuss with patient if this is a change from last contact"; + + elseif riskscore >= 20 then riskscorevalue := "High Risk"; triage_instructions := "Immediate notification of MD is required. MHRN Consult, Special Constant Observation (SCO 1:1)), Implement the Safety Precautions/ Observation Monitoring Form, the Environmental Assessment for High Suicidal Risk will be automatically entered. If diet is being ordered: Add a Seclusion Tray with No Hot Beverages."; + profile_instructions := "Immediate notification of MD is required. Special Constant Observation (SCO 1:1); Environmental Assessment; Safety Precautions/Observation Monitoring orders will be automatically entered. If diet is being ordered:Add a Seclusion Tray with No Hot Beverages."; + columbop_instructions:= "High:\n\n-SCO 1:1 \n\n-Escort patient to the Emergency Department for a mental health evaluation \n\n-Contact attending psychiatrist \n\n-Encourage patient to notify family/significant other or staff to call if patient requests"; + endif; + + + + // Populate risk score value text box + + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_PSY_Columbia Risk Score"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := riskscorevalue; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + // Populate risk score instructions text box + + + If current_document_type= "patient_profile" then protocol_instructions := profile_instructions; else protocol_instructions := triage_instructions; endif; // ED Triage Note vs Patient Profile ? + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_PSY_Risk Order Choices"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := protocol_instructions; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + + // Populate Interventions text box (Columbia Severity Score Note only) + + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_PSY_Interventions"); // Columbia Severity Note for Outpatients only + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := columbop_instructions; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + + if has_orders = "yes" + + then + + // Select the appropriate Orders for the risk + + this_parametername := first of (thisParameters where thisParameters.Name = orders_observation_name); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + + if riskscorevalue = "High Risk" + then + if selectedItem.Value = "SCO 1:1" then selectedItem.IsSelected := true; endif; + if selectedItem.Value = "MHRN Consult" then selectedItem.IsSelected := true; endif; // ED Triage Note Only + if selectedItem.Value = "Notify MD (day/evening) PPM (nights)" then selectedItem.IsSelected := true; endif; // Patient Profile Only + if selectedItem.Value = "Environmental Assessment" then selectedItem.IsSelected := true; endif; + if selectedItem.Value = "Safety Precautions/Observation Monitoring" then selectedItem.IsSelected := true; endif; + endif; + + if riskscorevalue = "Moderate Risk" + then + if selectedItem.Value = "CO" then selectedItem.IsSelected := true; endif; + if selectedItem.Value = "MHRN Consult" then selectedItem.IsSelected := true; endif; // ED Triage Note Only + if selectedItem.Value = "Notify MD (day/evening) PPM (nights)" then selectedItem.IsSelected := true; endif; // Patient Profile Only + if selectedItem.Value = "Safety Precautions/Observation Monitoring" then selectedItem.IsSelected := true; endif; + endif; + + + if nurseoverride = "yes" + then + + if selectedItem.Value = "SCO 1:1" then selectedItem.IsSelected := true; endif; + + endif; + + + listItems := (listItems, selectedItem); + + + ENDDO; + + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; + + else + + + + + // Order Button Checkbox Selection Section + + + + if has_orders = "yes" + + + + then + + + // Determine the value Risk Score text box + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_PSY_Columbia Risk Score"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + riskscorevalue := theObservation.ValueObj.Value; + + if (riskscorevalue = "Moderate Risk" or riskscorevalue = "High Risk") + + then + + // Select the appropriate Orders for the risk + + + this_parametername := first of (thisParameters where thisParameters.Name = orders_observation_name); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + + if riskscorevalue = "High Risk" + then + if selectedItem.Value = "SCO 1:1" then selectedItem.IsSelected := true; endif; + if selectedItem.Value = "MHRN Consult" then selectedItem.IsSelected := true; endif; // ED Triage Note Only + if selectedItem.Value = "Notify MD (day/evening) PPM (nights)" then selectedItem.IsSelected := true; endif; // Patient Profile Only + if selectedItem.Value = "Environmental Assessment" then selectedItem.IsSelected := true; endif; + if selectedItem.Value = "Safety Precautions/Observation Monitoring" then selectedItem.IsSelected := true; endif; + endif; + + + if riskscorevalue = "Moderate Risk" + then + if selectedItem.Value = "CO" then selectedItem.IsSelected := true; endif; + if selectedItem.Value = "MHRN Consult" then selectedItem.IsSelected := true; endif; // ED Triage Note Only + if selectedItem.Value = "Notify MD (day/evening) PPM (nights)" then selectedItem.IsSelected := true; endif; // Patient Profile Only + if selectedItem.Value = "Safety Precautions/Observation Monitoring" then selectedItem.IsSelected := true; endif; + endif; + + + listItems := (listItems, selectedItem); + + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; + + + + // Manually select orders when the patient is low risk + + + if riskscorevalue = "Low Risk" + + + then + + + SelectedBefore:= local_session.SessionSuicideOrdersSelected; + + theParameter := first of (thisparameters where thisparameters.Name = orders_observation_name); + theObservation:= first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + SelectedNow := (theObservation.ValueObj.ListItemsList.Value where theObservation.ValueObj.ListItemsList.IsSelected = true); + + + + // SCO is selected + + + + if "SCO 1:1" in SelectedNow + + then + + this_parametername := first of (thisParameters where thisParameters.Name = orders_observation_name); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if selectedItem.Value = "SCO 1:1" then selectedItem.IsSelected := true; endif; + if selectedItem.Value = "MHRN Consult" then selectedItem.IsSelected := true; endif; // ED Triage Note Only + if selectedItem.Value = "Notify MD (day/evening) PPM (nights)" then selectedItem.IsSelected := true; endif; // Patient Profile Only + if selectedItem.Value = "Environmental Assessment" then selectedItem.IsSelected := true; endif; + if selectedItem.Value = "Safety Precautions/Observation Monitoring" then selectedItem.IsSelected := true; endif; + if selectedItem.Value = "CO" then selectedItem.IsSelected := false; endif; + + listItems := (listItems, selectedItem); + + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + + + elseif "SCO 1:1" not in SelectedNow and "SCO 1:1" in SelectedBefore + + then + + this_parametername := first of (thisParameters where thisParameters.Name = orders_observation_name); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if selectedItem.Value = "SCO 1:1" then selectedItem.IsSelected := false; endif; + if selectedItem.Value = "MHRN Consult" then selectedItem.IsSelected := false; endif; // ED Triage Note Only + if selectedItem.Value = "Notify MD (day/evening) PPM (nights)" then selectedItem.IsSelected := false; endif; // Patient Profile Only + if selectedItem.Value = "Environmental Assessment" then selectedItem.IsSelected := false; endif; + if selectedItem.Value = "Safety Precautions/Observation Monitoring" then selectedItem.IsSelected := false; endif; + if selectedItem.Value = "CO" then selectedItem.IsSelected := false; endif; + + listItems := (listItems, selectedItem); + + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + + endif; // SCO selected + + + local_session.SessionSuicideOrdersSelected:= SelectedNow; // Set session object = orders that were selected + + + + endif; // Low Risk + + + + endif; // The note has orders + + + + endif; // Risk Button or Order Button was selected + + + + + + + // DOCUMENT CLOSE SECTION + + + + + + elseif thisdocumentCommunication.EventType = "DocumentClosing" then + + + // Determine the value of the risk score field + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_PSY_Columbia Risk Score"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + riskscorevalue := theObservation.ValueObj.Value; + + + // Search for {{{SINGLE-QUOTE}}}Call Physician{{{SINGLE-QUOTE}}} order on file + + (CallPhysicianOnFile) := read + {" + select distinct ocmi.name + from cv3ordercatalogmasteritem ocmi with (nolock) + join cv3order o with (nolock) on o.ordercatalogmasteritemguid = ocmi.guid + where + o.clientguid = " || clientGuid || " and o.chartguid = " || chartGuid || " and o.clientvisitguid = " || visitGuid || " and ocmi.name = {{{SINGLE-QUOTE}}}Call Physician{{{SINGLE-QUOTE}}} + "}; + + // Display the "contact the doctor" message if "High Risk" (suppress on SN modify "Call Physician" order already on file) + + If current_document_type = "triage_note" then notifymessage := "\n The patient score suggests a high risk of suicide.\n\n\n Please contact the doctor immediately.\n"; + else notifymessage := "\n The patient score suggests a high risk of suicide.\n\n\n Please contact the doctor(day/evening) PPM (nights) immediately.\n"; + endif; + + If riskscorevalue = "High Risk" and not exists CallPhysicianOnFile then dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with notifymessage, "Suicide Caution","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; endif; + + + // Determine which order boxes were selected + + ordercount:= 0; + + if has_orders = "yes" + + then + + theParameter := first of (thisparameters where thisparameters.Name = orders_observation_name); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "SCO 1:1") then ordercount := ordercount + 1; SCOorder := true; ordername:= "SCO 1:1"; endif; + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "CO") then ordercount := ordercount + 1; COorder := true; ordername:= "CO"; endif; + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "MHRN Consult") then ordercount := ordercount + 1; MHRNorder := true; ordername:= "Mental Health Nurse Consult"; endif; + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Notify MD (day/evening) PPM (nights)") then ordercount := ordercount + 1; NotifyMDorder := true; ordername:= "Notify MD"; endif; + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Safety Precautions/Observation Monitoring") then ordercount := ordercount + 1; HarmPrecautorder:= true; ordername:= "Implement Safety Precautions/Observation Monitoring"; endif; + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Environmental Assessment") then ordercount := ordercount + 1; EnvirAssessorder:= true; ordername:= "Implement Safety Precautions/Observation Monitoring"; endif; + endif; + + + + // Create orders if something was selected + + + + if ordercount > 0 + + then + + // Search for orders already on file + + (MHorderOnFile) := read + {" + select distinct ocmi.name + from cv3ordercatalogmasteritem ocmi with (nolock) + join cv3order o with (nolock) on o.ordercatalogmasteritemguid = ocmi.guid + where + o.clientguid = " || clientGuid || " and o.chartguid = " || chartGuid || " and o.clientvisitguid = " || visitGuid || " and + ocmi.name in + ({{{SINGLE-QUOTE}}}Constant Observation (CO){{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Special Constant Observation (SCO 1:1){{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Mental Health Nurse Consult{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Implement Environmental Assessment for High Suicidal Risk{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Implement Safety Precautions/ Observation Monitoring{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Call Physician{{{SINGLE-QUOTE}}}) + "}; + + // Attain the Attending MD + + attendingguid := read last + {"Select providerguid from cv3careprovidervisitrole cpr with (nolock) + join cv3user u with (nolock) on u.guid = cpr.providerguid + where cpr.rolecode = {{{SINGLE-QUOTE}}}attending{{{SINGLE-QUOTE}}} and cpr.active = 1 and cpr.ToDtm is null and u.lastname not like {{{SINGLE-QUOTE}}}non staff%{{{SINGLE-QUOTE}}} + and cpr.clientguid = " || clientguid || " and cpr.chartguid = " || chartguid || " and cpr.clientvisitguid = " || visitguid || " "}; + + + SCOOnFile := false; + MHRNOnFile := false; + NotifyMDOnFile := false; + HarmPrecautOnFile:= false; + EnvirAssessOnFile:= false; + COOnFile := false; + + If exists MHorderOnFile + then + + for i in 1 seqto count MHorderOnFile do + if MHorderOnFile[i] = "Special Constant Observation (SCO 1:1)" then SCOOnFile := true; endif; + if MHorderOnFile[i] = "Mental Health Nurse Consult" then MHRNOnFile := true; endif; + if MHorderOnFile[i] = "Call Physician" then NotifyMDOnFile := true; endif; + if MHorderOnFile[i] = "Implement Safety Precautions/ Observation Monitoring" then HarmPrecautOnFile:= true; endif; + if MHorderOnFile[i] = "Implement Environmental Assessment for High Suicidal Risk" then EnvirAssessOnFile:= true; endif; + if MHorderOnFile[i] = "Constant Observation (CO)" then COOnFile := true; endif; + enddo; + endif; + + + // Determine is the order is newly selected by comparing it to the list of orders selected upon document open + + PriorOrderSCO := 0; + PriorOrderMHRN := 0; + PriorOrderHarmPrecaut:= 0; + PriorOrderNotifyMD := 0; + PriorOrderEnvirAssess:= 0; + PriorOrderCO := 0; + + + theParameter := first of (thisParameters where thisParameters.Name = "SCH_PSY_Risk Orders Prior"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + if exists theObservation + then + PriorOrderList:= theObservation.ValueObj.Value; + PriorOrderSCO := FIND "S" IN STRING PriorOrderList; + PriorOrderMHRN := FIND "M" IN STRING PriorOrderList; + PriorOrderHarmPrecaut := FIND "P" IN STRING PriorOrderList; + PriorOrderNotifyMD := FIND "N" IN STRING PriorOrderList; + PriorOrderEnvirAssess := FIND "E" IN STRING PriorOrderList; + PriorOrderCO := FIND "C" IN STRING PriorOrderList; + + + endif; + + + // Create Objects and value variables to be used by either order + + try + locationGuid := read last {"SELECT CurrentLocationGUID, touchedWhen" + || " FROM CV3ClientVisit with (nolock)" + || " WHERE GUID = " || Sql(visitGuid) + || " AND ClientGUID = " || Sql(clientGuid) + , primaryTime = touchedWhen}; + + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((locationGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + Order_Creation_Reason := "Suicide Risk Assessment"; + RequestingSource := "Standing Order"; + SessionType := "Standard"; + SessionReason := ""; + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}CommonData: {{-R}}\n" || ex.Message || "\n\n"; + if location_obj IS NOT Null then void := call location_obj.Dispose; location_obj := null; endif; + if client_visit_obj IS NOT Null then void := call client_visit_obj.Dispose; client_visit_obj := null; endif; + + endcatch; + + if client_visit_obj IS NOT Null + + then + + // Create SSO Order + + if SCOorder = true and SCOOnFile = false and PriorOrderSCO = 0 + then + try + + if not exist attendingguid + then + if current_document_type = "triage_note" + then attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}biggs{{{SINGLE-QUOTE}}} and firstname = {{{SINGLE-QUOTE}}}jason{{{SINGLE-QUOTE}}} and active = 1"}; + else attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}non staff{{{SINGLE-QUOTE}}} and active = 1"}; + endif; + endif; + + care_provider_obj:= call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((attendingGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + order_catalog_obj:= call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with ("Special Constant Observation (SCO 1:1)"); + order_obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder with client_visit_obj, order_catalog_obj,Order_Creation_Reason,care_provider_obj,RequestingSource,SessionType,SessionReason,location_obj,"Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; + void := call order_obj.Save; + if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; + if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; + endtry; + catch Exception ex + error_occurred := true; + error_message := "{{+R}}New Other Order: {{-R}}\n" || ex.Message || "\n\n"; + if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif; + if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; + if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; + endcatch; + endif; + + + // Create CO Order + + if COorder = true and COOnFile = false and PriorOrderCO = 0 + + then + + + try + if not exist attendingguid + then + if current_document_type = "triage_note" + then attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}biggs{{{SINGLE-QUOTE}}} and firstname = {{{SINGLE-QUOTE}}}jason{{{SINGLE-QUOTE}}} and active = 1"}; + else attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}non staff{{{SINGLE-QUOTE}}} and active = 1"}; + endif; + endif; + + care_provider_obj:= call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((attendingGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + order_catalog_obj:= call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with ("Constant Observation (CO)"); + order_obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder with client_visit_obj, order_catalog_obj,Order_Creation_Reason,care_provider_obj,RequestingSource,SessionType,SessionReason,location_obj,"Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; + void := call order_obj.Save; + if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; + if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; + endtry; + catch Exception ex + error_occurred := true; + error_message := "{{+R}}New Other Order: {{-R}}\n" || ex.Message || "\n\n"; + if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif; + if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; + if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; + endcatch; + endif; + + + + // Create MNRN Consult Order + + if MHRNorder = true and MHRNOnFile = false and PriorOrderMHRN = 0 + then + try + + if not exist attendingguid + then + if current_document_type = "triage_note" + then attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}biggs{{{SINGLE-QUOTE}}} and firstname = {{{SINGLE-QUOTE}}}jason{{{SINGLE-QUOTE}}} and active = 1"}; + else attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}non staff{{{SINGLE-QUOTE}}} and active = 1"}; + endif; + endif; + + care_provider_obj:= call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((attendingGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + order_catalog_obj:= call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with ("Mental Health Nurse Consult"); + order_obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder with client_visit_obj, order_catalog_obj,Order_Creation_Reason,care_provider_obj,RequestingSource,SessionType,SessionReason,location_obj,"Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; + void := call order_obj.Save; + if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; + if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; + endtry; + catch Exception ex + error_occurred := true; + error_message := "{{+R}}New Other Order: {{-R}}\n" || ex.Message || "\n\n"; + if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif; + if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; + if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; + endcatch; + endif; + + + + // Create Notify MD Order + + if NotifyMDorder = true and NotifyMDOnFile = false and PriorOrderNotifyMD = 0 + then + try + if not exist attendingguid + then + if current_document_type = "triage_note" + then attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}biggs{{{SINGLE-QUOTE}}} and firstname = {{{SINGLE-QUOTE}}}jason{{{SINGLE-QUOTE}}} and active = 1"}; + else attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}non staff{{{SINGLE-QUOTE}}} and active = 1"}; + endif; + endif; + + care_provider_obj:= call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((attendingGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + order_catalog_obj:= call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with ("Call Physician"); + order_obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder with client_visit_obj, order_catalog_obj,Order_Creation_Reason,care_provider_obj,RequestingSource,SessionType,SessionReason,location_obj,"Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; + order_obj.SpecialInstructions := "Notify MD (day/evening) PPM (nights). Further direction regarding mental health consult"; + retval := call order_obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with "NUR_NotifyType", "Physician" ; + void := call order_obj.Save; + if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; + if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; + endtry; + catch Exception ex + error_occurred := true; + error_message := "{{+R}}New Other Order: {{-R}}\n" || ex.Message || "\n\n"; + if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif; + if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; + if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; + endcatch; + endif; + + + // Create Environmental Assessment Order + + if EnvirAssessorder = true and EnvirAssessOnFile = false and PriorOrderEnvirAssess = 0 + then + try + if not exist attendingguid + then + if current_document_type = "triage_note" + then attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}biggs{{{SINGLE-QUOTE}}} and firstname = {{{SINGLE-QUOTE}}}jason{{{SINGLE-QUOTE}}} and active = 1"}; + else attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}non staff{{{SINGLE-QUOTE}}} and active = 1"}; + endif; + endif; + + care_provider_obj:= call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((attendingGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + order_catalog_obj:= call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with ("Implement Environmental Assessment for High Suicidal Risk"); + order_obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder with client_visit_obj, order_catalog_obj,Order_Creation_Reason,care_provider_obj,RequestingSource,SessionType,SessionReason,location_obj,"Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; + void := call order_obj.Save; + if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; + if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; + endtry; + catch Exception ex + error_occurred := true; + error_message := "{{+R}}New Other Order: {{-R}}\n" || ex.Message || "\n\n"; + if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif; + if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; + if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; + endcatch; + endif; + + + + // Create Self Harm Precautions Order + + if HarmPrecautorder = true and HarmPrecautOnFile = false and PriorOrderHarmPrecaut = 0 + then + try + if not exist attendingguid + then + if current_document_type = "triage_note" + then attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}biggs{{{SINGLE-QUOTE}}} and firstname = {{{SINGLE-QUOTE}}}jason{{{SINGLE-QUOTE}}} and active = 1"}; + else attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}non staff{{{SINGLE-QUOTE}}} and active = 1"}; + endif; + endif; + + care_provider_obj:= call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((attendingGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + order_catalog_obj := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with ("Implement Safety Precautions/ Observation Monitoring"); + order_obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder with client_visit_obj, order_catalog_obj,Order_Creation_Reason,care_provider_obj,RequestingSource,SessionType,SessionReason,location_obj,"Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; + void := call order_obj.Save; + if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; + if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; + endtry; + catch Exception ex + error_occurred := true; + error_message := "{{+R}}New Other Order: {{-R}}\n" || ex.Message || "\n\n"; + if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif; + if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; + if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; + endcatch; + endif; + + + // Dispose of common objects + + if location_obj is not null then void := call location_obj.Dispose; location_obj := null; endif; + if client_visit_obj is not null then void := call client_visit_obj.Dispose; client_visit_obj := null; endif; + + + endif; // Common Objects were succesfully created ? + + + + endif; // Order count > 0 + + + + + + // DOCUMENT ENTER/MODIFY EVOKE SECTION + + + + + else + + // Update the Enterprise Defined Column after the filing of the document. A new risk may have been revealed by the Columnbia resposnes + + + + If called_by_editor then columnvalue := "."; endif; + + + if exists SuidcideObservation or exists SignificantEvent then columnvalue := "Yes"; + else columnvalue := "."; + endif; + + create_ED_column := MLM {{{SINGLE-QUOTE}}}SCH_FUNC_CREATE_ENTERPRISE_DEFINED_COLUMN{{{SINGLE-QUOTE}}}; // MLM that creates the Enterprise Defined Column + EDCObj := OBJECT [column_name,column_value,client_guid,chart_guid,client_visit_guid]; // Create Enterprise Defined Column Obj + + SuicideViolence_Column := NEW EDCObj WITH + [ + column_name := "Suicide Violence Risk", + column_value := columnvalue, + client_guid := ClientGUID, + chart_guid := ChartGUID, + client_visit_guid := visitGuid + ]; + + return_value := call create_ED_column with ( SuicideViolence_Column ); + + + endif; // Document Open / Chart Observation / Document Enter/ Document Modify Evoking Event + + ;; + evoke: + + 15 seconds after time of document_event_enter; + 15 seconds after time of document_event_modify; + + ;; + logic: + conclude true; + + + ;; + action: return thisDocumentCommunication; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_SUICIDE_RISK.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_SUICIDE_RISK.mlm new file mode 100644 index 0000000..a63c9ef --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_SUICIDE_RISK.mlm @@ -0,0 +1,280 @@ +maintenance: + + title: DOC_FUNC_SUICIDE_RISK;; + mlmname: DOC_FUNC_SUICIDE_RISK;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: GMS;; + specialist: Don Warnick ;; + date: 2016-08-02;; + validation: testing;; + +library: + purpose: + ;; + explanation: This MLM will create physician notification and nurse intervention orders if the patient is identified as at risk for suicide during the patient profile or ed triage interview + + + Change history + + 08.02.2016 DW CSR# 34885 - Created + 06.15.2018 DW CSR# 36510 - Harm to Self or Others - look for risk score instead of single simplistic observation + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + + +// CHART OBSERVATION SECTION + + + +IF thisdocumentCommunication.EventType = "ChartObservation" + + then + + // Determine if patient is at risk for suicide in the patient profiles + + theParameter := first of (thisparameters where thisparameters.Name = "sch_adult patient_hurt RD"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") then suiciderisk := "yes"; endif; + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no") then suiciderisk := "no"; endif; + + + // Determine if the patient was identified in the ED and if a Mental Health order was placed + + If suiciderisk = "no" + + then + + + // replaced - 06.15.2018 DW CSR# 36510 - Harm to Self or Others - look for risk score instead of single simplistic observation + /* + edtriageriskfound := read last + { + " select " + ||" fsl.value " + ||" from CV3ClientDocument cd with (nolock) " + ||" join CV3ClientDocDetail cdd with (nolock) on cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = " || clientGuid || " " + ||" join CV3ObservationDocument od with (nolock) on cdd.CLientDocumentGUID = od.OwnerGUID " + ||" join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + ||" join SCMObsFSListValues fsl with (nolock) on fsl.ParentGUID = od.ObservationDocumentGUID and fsl.ClientGUID = " || clientGuid || " " + ||" where cd.clientguid = " || clientGuid || " and cd.ChartGUID = " || chartGuid || " and cd.ClientVisitGUID = " || visitGuid || " " + ||" and od.active = 1 and cdd.active = 1 and cd.DocumentName = {{{SINGLE-QUOTE}}}ED Triage Note{{{SINGLE-QUOTE}}} and ocmi.name = {{{SINGLE-QUOTE}}}sch_edtriage_hurt{{{SINGLE-QUOTE}}} and fsl.value = {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} " + }; + */ + + edtriageriskfound := read last + {" + select obsparam.ValueText + from CV3ObsCatalogMasterItem ocmi with (nolock) + inner join SXACDObservationParameter obsparam with (nolock) on obsparam.ClientGUID = " || ClientGuid || " and obsparam.ChartGUID = " || ChartGuid || " and obsparam.ClientVisitGUID = " || visitGuid || " and obsparam.ObsMasterItemGUID = ocmi.GUID and obsparam.IsCanceled = 0 + where ocmi.name = {{{SINGLE-QUOTE}}}SCH_PSY_Columbia Risk Score{{{SINGLE-QUOTE}}} and obsparam.ValueText not in ({{{SINGLE-QUOTE}}}No Risk{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Low Risk{{{SINGLE-QUOTE}}}) + "}; + + + mhorder := read last + { + " select ocmi.name " + || " from cv3ordercatalogmasteritem ocmi with (nolock) " + || " join cv3order o with (nolock) on o.ordercatalogmasteritemguid = ocmi.guid " + || " where " + || " o.clientguid = " || clientGuid || " and o.chartguid = " || chartGuid || " and o.clientvisitguid = " || visitGuid || " and " + || " o.OrderStatusLevelNum >= 15 and o.OrderStatusLevelNum not in (69, 70) and ocmi.name = {{{SINGLE-QUOTE}}}Mental Health Nurse Consult{{{SINGLE-QUOTE}}} " + }; + + + endif; + + + nurinstruct := read last + { + " select ocmi.name " + || " from cv3ordercatalogmasteritem ocmi with (nolock) " + || " join cv3order o with (nolock) on o.ordercatalogmasteritemguid = ocmi.guid " + || " where " + || " o.clientguid = {{{SINGLE-QUOTE}}}" || clientGuid || "{{{SINGLE-QUOTE}}} and o.chartguid = {{{SINGLE-QUOTE}}}" || chartGuid || "{{{SINGLE-QUOTE}}} and o.clientvisitguid = {{{SINGLE-QUOTE}}}" || visitGuid || "{{{SINGLE-QUOTE}}} and " + || " o.OrderStatusLevelNum >= 15 and o.OrderStatusLevelNum not in (69, 70) and ocmi.name = {{{SINGLE-QUOTE}}}Nurse Intervention:{{{SINGLE-QUOTE}}} and o.SummaryLine like {{{SINGLE-QUOTE}}}%Initiate Self Harm Precautions{{{SINGLE-QUOTE}}} " + }; + + + // Create the orders if ... + // + // 1 the patient was identifed as a suicide risk in the patinet profile + // 2 the patient was not identifed as a suicide risk in the patinet profile , but were identified as a risk in the ED triage note, but no mental health consult was entered + + // replaced - 06.15.2018 DW CSR# 36510 - Harm to Self or Others - no longer look for MH consult as one is auto-ordered if Columbia Score = Medim or High + + // If (suiciderisk = "yes" and not exists nurinstruct) or (suiciderisk = "no" and exists edtriageriskfound and not exists mhorder and not exists nurinstruct) + If (suiciderisk = "yes" and not exists nurinstruct) or (suiciderisk = "no" and exists edtriageriskfound and not exists nurinstruct) + + + then + + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with + "\nEither you or the ED Triage note has selected ‘Yes’ to the Suicide Risk " || + "\n\n 1.Please call the physician for further direction regarding mental health consult " || + "\n\n 2.Initiate Self Harm Precautions \n " || + "\n Click ‘Yes’ to confirm your selection \n" || + "\n Click ‘No’ if you wish to change your selection ", + "Confirm Suicide Risk Selection ", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + + If (dialogResult as string) = "Yes" + + then + + + // Create "common" objects shared by the 2 orders + + + try + locationGuid := read last {"SELECT CurrentLocationGUID, touchedWhen" + || " FROM CV3ClientVisit with (nolock)" + || " WHERE GUID = " || Sql(visitGuid) + || " AND ClientGUID = " || Sql(clientGuid) + , primaryTime = touchedWhen}; + + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + care_provider_obj:= call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((userGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((locationGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + Order_Creation_Reason := "Created per protocol"; + RequestingSource := ""; + SessionType := "Standard"; + SessionReason := ""; + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}CommonData: {{-R}}\n" || ex.Message || "\n\n"; + + if location_obj IS NOT Null then void := call location_obj.Dispose; location_obj := null; endif; + if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif; + if client_visit_obj IS NOT Null then void := call client_visit_obj.Dispose; client_visit_obj := null; endif; + endcatch; + + + + // Create the Nurse Intervention Order + + + try + order_catalog_obj:= call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with ("Nurse Intervention:"); + + Order_Obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder + with client_visit_obj, + order_catalog_obj, + Order_Creation_Reason, + care_provider_obj, + RequestingSource, + SessionType, + SessionReason, + location_obj, + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; + + order_obj.SpecialInstructions := "Initiate Self Harm Precautions"; + + void := call Order_Obj.Save; + + if order_catalog_obj IS NOT Null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}New Other Order: {{-R}}\n" || ex.Message || "\n\n"; + if Order_Obj IS NOT Null then void := call Order_Obj.Dispose; Order_Obj := null; endif; + endcatch; + + + + // Create the Call Physician Order + + + try + order_catalog_obj:= call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with ("Call Physician"); + + Order_Obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder + with client_visit_obj, + order_catalog_obj, + Order_Creation_Reason, + care_provider_obj, + RequestingSource, + SessionType, + SessionReason, + location_obj, + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; + + order_obj.SpecialInstructions := "Further direction regarding mental health consult"; + retval := call order_obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with "NUR_NotifyType", "Physician" ; + + void := call Order_Obj.Save; + + if order_catalog_obj IS NOT Null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}New Other Order: {{-R}}\n" || ex.Message || "\n\n"; + if Order_Obj IS NOT Null then void := call Order_Obj.Dispose; Order_Obj := null; endif; + endcatch; + + + // Dispose of the "common" objects shared by the 2 orders + + + if location_obj IS NOT Null then void := call location_obj.Dispose; location_obj := null; endif; + if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif; + if client_visit_obj IS NOT Null then void := call client_visit_obj.Dispose; client_visit_obj := null; endif; + + + endif; // Confirm OK to enter the order + + + endif; // create the order + + +endif; // EventType = "ChartObservation" + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_TDAP.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_TDAP.mlm new file mode 100644 index 0000000..23ec0bb --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_TDAP.mlm @@ -0,0 +1,753 @@ +maintenance: + + title: TDAP Logic;; + mlmname: DOC_FUNC_TDAP;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Don Warnick;; + specialist: ;; + date: 2012-01-31;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 01.31.2012 DW CSR# 26307 - Created (copied from Doc_Func_Pneumovax) + 06.17.2016 DW CSR# 34778 Change order source to "Standing Order" + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + + formattedTextReason := "N-0. TDAP risk was not determined. "; + ordervaccine := "no"; + + + +// CHART OBSERVATION SECTION + + +IF thisdocumentCommunication.EventType = "ChartObservation" then + + + +// Attain user{{{SINGLE-QUOTE}}}s ID (for use in override message) + + userId := read last {" SELECT IDCode FROM CV3User with (nolock) WHERE GUID = " || Sql(userGuid) || " AND Active = 1 "}; + + + +// CONTRAINDICATION BUTTON CHANGE SECTION + + +// Using the prior value of the None box, determine if this is the first time a contraindication section box was clicked + + theParameter := first of (thisParameters where thisParameters.Name = "SCHCK_TDAP Details"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + SavedNoneContraValue := theObservation.ValueObj.Value; + If SavedNoneContraValue is null + then FirstTime := "true"; else FirstTime := "false"; + endif; + + +// Proceed if a Contraindication section box was clicked + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_TDAP vac contra"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + then + trigger := "A Contraindications Box was selected or deselected"; + + +// If this is first contraindication section box clicked, assess what had been selected (NONE VS a Contraindication) + + if FirstTime = "true" then + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "none") + then contraboxchecked := "false"; MLMAction := "Retrieve and Reassess"; + + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value <> "none") + then contraboxchecked := "true"; MLMAction := "No Assessment Required"; + endif; + endif; + + +// Compare the prior value of the None box to the current value, to determine what was selected (NONE VS a Contraindication) + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "none") + then NewNoneContraValue := "true"; else NewNoneContraValue := "false"; + endif; + + If FirstTime = "false" + then + if NewNoneContraValue = SavedNoneContraValue + then WhatWasClicked := "Other Button Was Clicked"; + else WhatWasClicked := "None Button Was Clicked"; SavedNoneContraValue := NewNoneContraValue; + endif; + else // FirstTime = "true" + SavedNoneContraValue := NewNoneContraValue; + endif; + + +// Determine if all boxes in the section are deselected (nonthing is selected) + + if true not in (theObservation.ValueObj.ListItemsList.IsSelected) + then contraboxchecked := "unknown"; MLMAction := "No Assessment Required"; + endif; + + +// If this is not the first click and something is selected, reset the mutually exclusive contraindication boxes (None VS a Contraindiation) + + If (contraboxchecked = "unknown" or FirstTime = "true") + then ResetOtherBoxes := "false"; else ResetOtherBoxes := "true"; + endif; + + If ResetOtherBoxes = "true" + then + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := theParameter.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= theParameter.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN theParameter.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if WhatWasClicked = "Other Button Was Clicked" // One of the Containdications was selected + then + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = selectedItem.Value) + then selectedItem.IsSelected := true; + else selectedItem.IsSelected := false; + endif; + if selectedItem.Value = "none" + then selectedItem.IsSelected := false; + endif; + NewNoneContraValue := "false"; + endif; + + if WhatWasClicked = "None Button Was Clicked" // The None box was selected + then + if selectedItem.Value = "none" + then selectedItem.IsSelected := true; + else selectedItem.IsSelected := false; + endif; + endif; + + listItems := (listItems, selectedItem); + ENDDO; + + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + +// After the boxes have been reset, assess what is now selected + + If WhatWasClicked = "None Button Was Clicked" and + true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "none") + then contraboxchecked := "false"; MLMAction := "Retrieve and Reassess"; + + elseif WhatWasClicked = "Other Button Was Clicked" and + true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value <> "none") + then contraboxchecked := "true"; MLMAction := "No Assessment Required"; + endif; + + endif; // End of Reset mutually exclusive Contra section + + + +// If None is selcted , Unhide the Chronic Illness and Immunocompromised fields and buttons + + If contraboxchecked = "false" then + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_TDAP Unhide"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := true; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; + + +// Populate the "None" Contraindiated Selected Value Box + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_TDAP Details"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := NewNoneContraValue; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + + + +endif; // End of Contraindication section + + + + +// OTHER BUTTON CHANGE SECTION + + +// Place Order button change to NO (affix ovverride message to assesement) + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_TDAP vac order"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + and + true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no") + + then MLMAction := "Reassess Only"; + trigger:= "Order Button NO was selected"; + endif; + + +// Place Order button change to YES (send message to user and reset to original assessment) + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_TDAP vac order"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + and + true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + + then MLMAction := "Reassess Only"; + trigger:= "Order Button YES was selected"; + endif; + + + +// Date has Changed + + theParameter := first of (thisParameters where thisParameters.Name = "SCHCK_Tdap date vacc rec ob"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + then trigger := "Date was changed"; + If SavedNoneContraValue = "true" + then MLMAction := "Reassess Only"; // No Contraindications were identified + else MLMAction := "No Assessment Required"; // Patient has contraindications + endif; + endif; + + + +// RETRIEVE AND REASSESS (or REASSESS ONLY) SECTION + + +if MLMAction = "Retrieve and Reassess" or MLMAction = "Reassess Only" then + + + + +// RETRIEVE AND REASSESS SECTION + + + If MLMAction = "Retrieve and Reassess" then + + + +// Date vaccine was charted in the patient profile + + +(vaccinecharteddate) := read last +{ +" select " +||" case when LEN(o.valuetext) = 8 then " +||" case when (substring(o.valuetext, 7, 1)) in ({{{SINGLE-QUOTE}}}7{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}8{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}9{{{SINGLE-QUOTE}}}) then {{{SINGLE-QUOTE}}}19{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}20{{{SINGLE-QUOTE}}} end " +|| " + (substring(o.valuetext, 7, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +|| "(substring(o.valuetext, 1, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 4, 2)) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| "else " +|| "(substring(o.valuetext, 7, 4)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 1, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 4, 2)) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| " end " +|| " from CV3ClientDocument cd with (nolock) " +|| " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = " || ClientGuid || " and cdd.active = 1) " +|| " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " +|| " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " +|| " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID and ocmi.name = {{{SINGLE-QUOTE}}}SCHCK_Tdap date vacc rec ob{{{SINGLE-QUOTE}}} " +|| " where cd.clientguid = " || ClientGuid || " and cd.iscanceled = 0 and cd.documentname like {{{SINGLE-QUOTE}}}%patient profile%{{{SINGLE-QUOTE}}} " +|| " and " +|| " (select top 1 fslx.value " +|| " from CV3ClientDocument cdx with (nolock) " +|| " join CV3ClientDocDetail cddx with (nolock) ON (cddx.ClientDocumentGUID = cdx.GUID AND cddx.ClientGUID = " || ClientGuid || " and cddx.active = 1) " +|| " join CV3ObservationDocument odx with (nolock)ON cddx.CLientDocumentGUID = odx.OwnerGUID and odx.active = 1 " +|| " join CV3Observation ox with (nolock) ON ox.GUID = odx.ObservationGUID " +|| " join CV3ObsCatalogMasterItem ocmix with (nolock) on odx.ObsMasterItemGUID = ocmix.GUID and ocmix.name = {{{SINGLE-QUOTE}}}SCHCK_Tdap vaccine type rec ob{{{SINGLE-QUOTE}}} " +|| " left join SCMObsFSListValues fslx(nolock) ON (fslx.ParentGUID = odx.ObservationDocumentGUID AND fslx.ClientGUID = " || ClientGuid || " ) " +|| " where cdx.GUID = cd.guid ) " +|| " is null " +|| " order by (substring(o.valuetext, 7, 4)), (substring(o.valuetext, 1, 2)) , (substring(o.valuetext, 4, 2)) " +}; + +vaccinechartedwhen := (vaccinecharteddate as time); + + + +// Date vaccine was charted in the patient profile - old style (with tetanus radio button selected....not + + +(vaccinecharteddateoldstyle) := read last +{ +" select " +||" case when LEN(o.valuetext) = 8 then " +||" case when (substring(o.valuetext, 7, 1)) in ({{{SINGLE-QUOTE}}}7{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}8{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}9{{{SINGLE-QUOTE}}}) then {{{SINGLE-QUOTE}}}19{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}20{{{SINGLE-QUOTE}}} end " +|| " + (substring(o.valuetext, 7, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +|| "(substring(o.valuetext, 1, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 4, 2)) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| "else " +|| "(substring(o.valuetext, 7, 4)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 1, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 4, 2)) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| " end " +|| " from CV3ClientDocument cd with (nolock) " +|| " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = " || ClientGuid || " and cdd.active = 1) " +|| " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " +|| " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " +|| " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID and ocmi.name = {{{SINGLE-QUOTE}}}SCHCK_Tdap date vacc rec ob{{{SINGLE-QUOTE}}} " +|| " where cd.clientguid = " || ClientGuid || " and cd.iscanceled = 0 and cd.documentname like {{{SINGLE-QUOTE}}}%patient profile%{{{SINGLE-QUOTE}}} " +|| " and " +|| " (select top 1 fslx.value " +|| " from CV3ClientDocument cdx with (nolock) " +|| " join CV3ClientDocDetail cddx with (nolock) ON (cddx.ClientDocumentGUID = cdx.GUID AND cddx.ClientGUID = " || ClientGuid || " and cddx.active = 1) " +|| " join CV3ObservationDocument odx with (nolock)ON cddx.CLientDocumentGUID = odx.OwnerGUID and odx.active = 1 " +|| " join CV3Observation ox with (nolock) ON ox.GUID = odx.ObservationGUID " +|| " join CV3ObsCatalogMasterItem ocmix with (nolock) on odx.ObsMasterItemGUID = ocmix.GUID and ocmix.name = {{{SINGLE-QUOTE}}}SCHCK_Tdap vaccine type rec ob{{{SINGLE-QUOTE}}} " +|| " left join SCMObsFSListValues fslx(nolock) ON (fslx.ParentGUID = odx.ObservationDocumentGUID AND fslx.ClientGUID = " || ClientGuid || " ) " +|| " where cdx.GUID = cd.guid ) " +|| " = {{{SINGLE-QUOTE}}}TDAP{{{SINGLE-QUOTE}}} " +|| " order by (substring(o.valuetext, 7, 4)), (substring(o.valuetext, 1, 2)) , (substring(o.valuetext, 4, 2)) " +}; + +vaccinechartedwhenoldstyle := (vaccinecharteddateoldstyle as time); + + +// Date vaccine was charted as given in the EMAR + +(vaccinegivenwhen) := read last +{ +" select oto.performedfromdtm " +|| " from cv3ordercatalogmasteritem as ocmi with (nolock) " +|| " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid " +|| " and o.ClientGUID = " || ClientGuid || " " +|| " and (o.name = {{{SINGLE-QUOTE}}}Diphtheria, Pertussis, Tetanus Vaccine{{{SINGLE-QUOTE}}}) " +|| " join cv3ordertask as ot with (nolock) on ot.clientguid = o.clientguid and ot.orderguid = o.guid " +|| " join cv3ordertaskoccurrence as oto with (nolock) on oto.clientguid = ot.clientguid and oto.orderguid = ot.orderguid " +|| " and oto.ordertaskguid = ot.guid and oto.taskstatuscode ={{{SINGLE-QUOTE}}}Performed{{{SINGLE-QUOTE}}} " +}; + + +// Date vaccine was last charted as an active health issue + + +(vaccinehealthissuedate) := read last +{ +" select " +|| " case when onsetyearnum = 0 " +|| " then createdwhen " +|| " else " +|| " case when (onsetmonthnum >0 and onsetmonthnum <10) then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} + cast (onsetmonthnum as varchar) " +|| " when onsetmonthnum = 0 then {{{SINGLE-QUOTE}}}01{{{SINGLE-QUOTE}}} else cast (onsetmonthnum as varchar) end + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +|| " case when (onsetdaynum >0 and onsetdaynum <10) then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} + cast (onsetdaynum as varchar) " +|| " when onsetdaynum = 0 then {{{SINGLE-QUOTE}}}01{{{SINGLE-QUOTE}}} else cast (onsetdaynum as varchar) end " +|| " + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + cast (onsetyearnum as varchar) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| " end {{{SINGLE-QUOTE}}}date returned to mlm{{{SINGLE-QUOTE}}} " +|| " from cv3healthissuedeclaration with (nolock) " +|| " where clientguid = " || ClientGuid || " and active = 1 and status = {{{SINGLE-QUOTE}}}active{{{SINGLE-QUOTE}}}" +|| " and (text like {{{SINGLE-QUOTE}}}%TDAP%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%TDAP%{{{SINGLE-QUOTE}}}) " +|| " order by createdwhen " +}; +vaccinehealthissue_found := count(vaccinehealthissue) As Number; + + + + +// Populate Fields and Boxes + + + + + +// Date + + +// First determine which of the 3 dates is latest (vaccine given, charted, or health issue) + + match1 := false; + match2 := false; + match3 := false; + nodates:= false; + + If vaccinegivenwhen is null and vaccinehealthissuedate is null and vaccinechartedwhen is null and vaccinechartedwhenoldstyle is null + then nodates := true; endif; + + If vaccinegivenwhen is null then vaccinegivenwhen := 1800-01-01T00:00:00; endif; + If vaccinehealthissuedate is null then vaccinehealthissuedate := 1800-01-01T00:00:00; endif; + If vaccinechartedwhen is null then vaccinechartedwhen := 1800-01-01T00:00:00; endif; + If vaccinechartedwhenoldstyle is null then vaccinechartedwhenoldstyle := 1800-01-01T00:00:00; endif; + +// Save the "new stye" date (for the HIS box) & then update vaccinechartedwhen with the later of the two dates ("old style" w/tetanus radio button or "new style w/no radio button) + + vaccinechartedwhennewstyle := vaccinechartedwhen; + if vaccinechartedwhenoldstyle IS AFTER vaccinechartedwhen then vaccinechartedwhen := vaccinechartedwhenoldstyle; endif; + +// With the latest "vaccine given" date established, proceed with the process of determining the latest of (vaccine given, charted, or health issue) + + match1 := vaccinegivenwhen IS AFTER vaccinehealthissuedate; + + If match1 = true + then match2 := vaccinegivenwhen IS AFTER vaccinechartedwhen; + else match3 := vaccinehealthissuedate IS AFTER vaccinechartedwhen; + endif; + + If match2 = true then givenwins := true; endif; + If match3 = true then healthissuewins := true; endif; + If (match2 = false) and (match3 = false) then chartedwins := true; endif; + + + if nodates = false then + If givenwins = true then latestdate := vaccinegivenwhen; endif; + If healthissuewins = true then latestdate := vaccinehealthissuedate; endif; + If chartedwins = true then latestdate := vaccinechartedwhen; endif; + endif; + + +// Populate Date field + + +// First determine if the field has been manually updated by the nurse (not empty) + + theParameter := first of (thisParameters where thisParameters.Name = "SCHCK_Tdap date vacc rec ob"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + datefieldcontents := theObservation.ValueObj.Value; + + if datefieldcontents is null + then datefield := latestdate; + else datefield := datefieldcontents; + endif; + +// Populate the field if history is found in SCM and the field hasn{{{SINGLE-QUOTE}}}t been overriden by the nurse (not empty) + + If latestdate is not null and datefieldcontents is null + then + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Tdap date vacc rec ob"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "DateValue"; + this_currentObj.ValueObj := New DateValueType; + this_currentObj.ValueObj.Value := latestdate; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + + + + + +// REASSESS ONLY SECTION + + + elseIf MLMAction = "Reassess Only" then + + +// Determine if any of the Contraindications boxes are checked + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_TDAP vac contra"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true not in (theObservation.ValueObj.ListItemsList.IsSelected) + then contraboxchecked := "unknown"; + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "none") + then contraboxchecked := "false"; + else contraboxchecked := "true"; + endif; + + +// Determine the value of the date given field + + theParameter := first of (thisParameters where thisParameters.Name = "SCHCK_Tdap date vacc rec ob"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + datefield := theObservation.ValueObj.Value; + if datefield is null then datefield := "unknown"; endif; + + + endif; // End of "Reassess Only" Section + + + + + +// ASSESS THE RISK SECTION ("Retrieve and Reassess" or "Reassess Only") + + + if MLMAction = "Retrieve and Reassess" or MLMAction = "Reassess Only" then + + + // set to unknown to satisfy conditions below + + if datefield is null then datefield := "unknown"; endif; + + +// Risk Senarios + + +// Scenarios that will cause an order to be placed + + +If datefield = "unknown" then ordervaccine := "yes"; +formattedTextReason := "Y-1. Order is to be placed since patient has never received a vaccine." ; endif; + + +// Scenarios that will NOT cause an order to be placed + + +If datefield <> "unknown" then ordervaccine := "no"; +formattedTextReason := "N-1. Order is not to be placed since patient has received the vaccine." ; endif; + + + +// Special Handling for Place Order Button Changes + +If trigger = "Order Button NO was selected" then ordervaccine := "no"; +formattedTextReason := formattedTextReason || " ** OVERRIDDEN TO NO BY " || userId || " ** "; endif; + +If trigger = "Order Button YES was selected" and ordervaccine = "no" then +dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n You cannot place an order on this patient. ", "Error","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; +formattedTextReason := formattedTextReason || " ** FAILED OVERRIDE TO YES BY " || userId || " ** "; endif; + + + + + endif; // end of section for assessing risk + + + + endif; // End of Bypass Everything (If MLMAction <> "No Assessment Required") + + + + +// FOR ANY OBSERVATION CHANGE + + +// Select the appropriate Order Vaccine radio button determined by the assessment + + + If contraboxchecked = "true" then ordervaccine := "no"; + formattedTextReason := "N-7. Order will not be placed since the vaccine is contraindicated."; endif; + + + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_TDAP vac order"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "yes" and ordervaccine = "yes" then selectedItem.IsSelected := true; endif; + if selectedItem.Value = "no" and ordervaccine = "no" then selectedItem.IsSelected := true; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + +endif; // End of Observation Event section + + + + + +// DOCUMENT CLOSING SECTION + + +IF thisdocumentCommunication.EventType = "DocumentClosing" then + + +// Determine if Place Order button is set to "Yes" + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_TDAP vac order"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no") + then placeorder := "no"; endif; + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then placeorder := "yes"; endif; + + +// Check for existing Vaccine Order on the account + + (orderpresent) := read + { + " select o.name " +|| " from cv3ordercatalogmasteritem as ocmi with (nolock) " +|| " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid " +|| " and o.ClientGUID = " || ClientGuid || " and o.ChartGUID = " || ChartGuid || " and o.ClientVisitGUID= " || VisitGuid || " " +|| " and (o.name = {{{SINGLE-QUOTE}}}Diphtheria, Pertussis, Tetanus Vaccine{{{SINGLE-QUOTE}}}) " +|| " and o.OrderStatusLevelNum > 15 " + }; +orderpresent_found := count(orderpresent) As Number; + +// If no existing order is found and Place Order button is "Yes" then create a new order + + + + If placeorder = "yes" and orderpresent_found = 0 then + + SessionType := "Standard"; + SessionReason := ""; + RequestingSource := "Standing Order"; + user_IDType := "Edstan Number (physician)"; + order_Creation_Reason := "From Test MLM"; + + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((thisdocumentCommunication.ClientVisitGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + user_IDCode := read last {"SELECT IDCode FROM CV3User " || " where GUID = " || thisdocumentCommunication.UserGUID}; + RequestingCareProvider_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindById with ( user_IDType, (user_IDCode as STRING) ); + location_guid := read last {"SELECT CurrentLocationGUID FROM CV3ClientVisit where ClientGUID = " || thisdocumentCommunication.ClientGUID}; + location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((location_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + + // Create a new MEDICATION order from a Pre-Filled item + try + Catalog_Item_Name := "Diphtheria, Pertussis, Tetanus Vaccine"; + Catalog_Item_Modifier := "0.5mL, IM, Once"; + Catalog_Item_Version := ""; + Medication_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with Catalog_Item_Name; + PreFilled_MedicationOrder_obj := call {{{SINGLE-QUOTE}}}MedicationOrder{{{SINGLE-QUOTE}}}.CreateMedicationOrder + with + client_visit_obj, // ClientVisit ObjectsPlus object + Medication_catalog_item, // OrderCatalogMasterItem ObjectsPlus object + Catalog_Item_Modifier, // string ItemNameModifier + Catalog_Item_Version, // string ItemNameModifierVersion + order_Creation_Reason, // string CreateReason + RequestingCareProvider_obj , // RequestedBy ObjectsPlus object + RequestingSource, // string RequestedBySource (must be in dictionary) + SessionType, // string SessionType + SessionReason, // string SessionReason + location_obj, // Location ReleaseLocGrpID + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; // AvailabilityOverride eAvailabilityOverride + + + if ( Medication_catalog_item is NOT NULL ) then + void := call PreFilled_MedicationOrder_obj.Save; + void := call PreFilled_MedicationOrder_obj.Dispose; + void:= call Medication_catalog_item.Dispose; + Medication_catalog_item:= null; + endif; + + + endtry; + + catch Exception ex error_occurred := true; error_message := "{{+R}}New prefilled medication order:{{-R}}\n" || ex.Message || "\n\n"; + + if ( Medication_catalog_item is NOT NULL ) then void:= call Medication_catalog_item.Dispose; Medication_catalog_item:= null; endif; + if ( PreFilled_MedicationOrder_obj is NOT NULL ) then void:= call PreFilled_MedicationOrder_obj.Dispose; PreFilled_MedicationOrder_obj:= null; endif; + + Prefilled_MedicationOrder_dest := null; + + endcatch; + + if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; + if ( RequestingCareProvider_obj is NOT NULL ) then void:= call RequestingCareProvider_obj.Dispose; RequestingCareProvider_obj:= null; endif; + if ( location_obj is NOT NULL ) then void:= call location_obj.Dispose; location_obj:= null; endif; + + + endif; // End of Place Order = Yes section + + endif; // End of Close Document + + + + +// Populate the HIS only Assessment Information box + + +// This secton as well as the FormattedText1 := below are for diagnostic purposes only + +dateonly:= SUBSTRING 10 CHARACTERS FROM (datefield as string); +nowdateonly:= SUBSTRING 10 CHARACTERS FROM (now as string); + + +Factor5 := "Contraindicated - "|| contraboxchecked; +Factor6 := "\n Last Given Worklist - " || vaccinegivenwhen || "\n Last Given Profile - " || vaccinechartedwhennewstyle || "\n Last Given Profile Old Style - " || vaccinechartedwhenoldstyle || "\n Last Given Health Issue - " || vaccinehealthissuedate; +Factor8 := "Last Given - " || dateonly; +Factor9 := "Last Trigger Event - " || nowdateonly || " " || trigger || " by " || userid || " (MLM reaction - " || MLMAction || ")"; + + +formattedText1 := "\n\n" || Factor5 || "\n\n" || Factor6 || "\n\n" || Factor8 || " " || Factor9 ; + +formattedTextReason := formattedTextReason || formattedText1; + +this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_TDAP Risk Assess Details"); +this_currentObj := NEW ObservationType; +this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; +this_currentObj.ParameterGUID := this_parametername.ParameterGUID; +this_currentObj.DataType := "FreeTextValue"; +this_currentObj.ValueObj := New FreeTextValueType; +this_currentObj.ValueObj.Value := formattedTextReason; +thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_TDAP_TETANUS_ED.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_TDAP_TETANUS_ED.mlm new file mode 100644 index 0000000..fe44571 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_TDAP_TETANUS_ED.mlm @@ -0,0 +1,974 @@ +maintenance: + + title: TDAP and Tetanus Logic for ED patients;; + mlmname: DOC_FUNC_TDAP_TETANUS_ED;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Don Warnick;; + specialist: ;; + date: 2012-04-02;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 04.02.2012 DW CSR# 26307 - Created (copied from DOC_FUNC_TDAP) + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + userGuid := thisDocumentCommunication.UserGUID; + + + formattedTextReason := "N-0. TDAP/Tetanus risk was not determined. "; + ordervaccine := "no"; + + + +// CHART OBSERVATION SECTION + + +IF thisdocumentCommunication.EventType = "ChartObservation" then + + + +// Attain user{{{SINGLE-QUOTE}}}s ID (for use in override message) + + userId := read last {" SELECT IDCode FROM CV3User with (nolock) WHERE GUID = " || Sql(userGuid) || " AND Active = 1 "}; + + + +// CONTRAINDICATION BUTTON CHANGE SECTION + + +// Using the prior value of the None box, determine if this is the first time a contraindication section box was clicked + + theParameter := first of (thisParameters where thisParameters.Name = "SCHCK_TDAP ED Details"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + SavedNoneContraValue := theObservation.ValueObj.Value; + If SavedNoneContraValue is null + then FirstTime := "true"; else FirstTime := "false"; + endif; + + +// Proceed if a Contraindication section box was clicked + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_TDAP ED vac contra"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + then + trigger := "A Contraindications Box was selected or deselected"; + + +// If this is first contraindication section box clicked, assess what had been selected (NONE VS a Contraindication) + + if FirstTime = "true" then + If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "none") + then contraboxchecked := "false"; MLMAction := "Retrieve and Reassess"; + + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value <> "none") + then contraboxchecked := "true"; MLMAction := "No Assessment Required"; + endif; + endif; + + +// Compare the prior value of the None box to the current value, to determine what was selected (NONE VS a Contraindication) + + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "none") + then NewNoneContraValue := "true"; else NewNoneContraValue := "false"; + endif; + + If FirstTime = "false" + then + if NewNoneContraValue = SavedNoneContraValue + then WhatWasClicked := "Other Button Was Clicked"; + else WhatWasClicked := "None Button Was Clicked"; SavedNoneContraValue := NewNoneContraValue; + endif; + else // FirstTime = "true" + SavedNoneContraValue := NewNoneContraValue; + endif; + + +// Determine if all boxes in the section are deselected (nonthing is selected) + + if true not in (theObservation.ValueObj.ListItemsList.IsSelected) + then contraboxchecked := "unknown"; MLMAction := "No Assessment Required"; + endif; + + +// If this is not the first click and something is selected, reset the mutually exclusive contraindication boxes (None VS a Contraindiation) + + If (contraboxchecked = "unknown" or FirstTime = "true") + then ResetOtherBoxes := "false"; else ResetOtherBoxes := "true"; + endif; + + If ResetOtherBoxes = "true" + then + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := theParameter.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= theParameter.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN theParameter.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if WhatWasClicked = "Other Button Was Clicked" // One of the Containdications was selected + then + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = selectedItem.Value) + then selectedItem.IsSelected := true; + else selectedItem.IsSelected := false; + endif; + if selectedItem.Value = "none" + then selectedItem.IsSelected := false; + endif; + NewNoneContraValue := "false"; + endif; + + if WhatWasClicked = "None Button Was Clicked" // The None box was selected + then + if selectedItem.Value = "none" + then selectedItem.IsSelected := true; + else selectedItem.IsSelected := false; + endif; + endif; + + listItems := (listItems, selectedItem); + ENDDO; + + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + +// After the boxes have been reset, assess what is now selected + + If WhatWasClicked = "None Button Was Clicked" and + true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "none") + then contraboxchecked := "false"; MLMAction := "Retrieve and Reassess"; + + elseif WhatWasClicked = "Other Button Was Clicked" and + true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value <> "none") + then contraboxchecked := "true"; MLMAction := "No Assessment Required"; + endif; + + endif; // End of Reset mutually exclusive Contra section + + + +// If None is selcted , Unhide the Chronic Illness and Immunocompromised fields and buttons + + If contraboxchecked = "false" then + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_TDAP ED Unhide"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := true; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; + + +// Populate the "None" Contraindiated Selected Value Box + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_TDAP ED Details"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := NewNoneContraValue; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + + + +endif; // End of Contraindication section + + + + +// OTHER BUTTON CHANGE SECTION + + +// Place Order button change to NO (affix ovverride message to assesement) + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_TDAP vac order"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + and + true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no") + + then MLMAction := "Reassess Only"; + trigger:= "Order Button NO was selected"; + endif; + + +// Place Order button change to YES (send message to user and reset to original assessment) + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_TDAP vac order"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + and + true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + + then MLMAction := "Reassess Only"; + trigger:= "Order Button YES was selected"; + endif; + + + +// Date has Changed + + theParameter := first of (thisParameters where thisParameters.Name = "SCHCK_Tdap date vacc rec ob"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + then trigger := "Date was changed"; + If SavedNoneContraValue = "true" + then MLMAction := "Reassess Only"; // No Contraindications were identified + else MLMAction := "No Assessment Required"; // Patient has contraindications + endif; + endif; + + theParameter := first of (thisParameters where thisParameters.Name = "SCHCK_Tetanus date vacc rec"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID + then trigger := "Date was changed"; + If SavedNoneContraValue = "true" + then MLMAction := "Reassess Only"; // No Contraindications were identified + else MLMAction := "No Assessment Required"; // Patient has contraindications + endif; + endif; + + + +// RETRIEVE AND REASSESS (or REASSESS ONLY) SECTION + + +if MLMAction = "Retrieve and Reassess" or MLMAction = "Reassess Only" then + + + + +// RETRIEVE AND REASSESS SECTION + + + If MLMAction = "Retrieve and Reassess" then + + +// Gather date information related to the first of two vaccines (TDAP) + +// Date vaccine #1 was charted in the patient profile + + +(vaccinecharteddate) := read last +{ +" select " +||" case when LEN(o.valuetext) = 8 then " +||" case when (substring(o.valuetext, 7, 1)) in ({{{SINGLE-QUOTE}}}7{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}8{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}9{{{SINGLE-QUOTE}}}) then {{{SINGLE-QUOTE}}}19{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}20{{{SINGLE-QUOTE}}} end " +|| " + (substring(o.valuetext, 7, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +|| "(substring(o.valuetext, 1, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 4, 2)) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| "else " +|| "(substring(o.valuetext, 7, 4)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 1, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 4, 2)) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| " end " +|| " from CV3ClientDocument cd with (nolock) " +|| " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = " || ClientGuid || " and cdd.active = 1) " +|| " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " +|| " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " +|| " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID and ocmi.name = {{{SINGLE-QUOTE}}}SCHCK_Tdap date vacc rec ob{{{SINGLE-QUOTE}}} " +|| " where cd.clientguid = " || ClientGuid || " and cd.iscanceled = 0 and cd.documentname like {{{SINGLE-QUOTE}}}%patient profile%{{{SINGLE-QUOTE}}} " +|| " and " +|| " (select top 1 fslx.value " +|| " from CV3ClientDocument cdx with (nolock) " +|| " join CV3ClientDocDetail cddx with (nolock) ON (cddx.ClientDocumentGUID = cdx.GUID AND cddx.ClientGUID = " || ClientGuid || " and cddx.active = 1) " +|| " join CV3ObservationDocument odx with (nolock)ON cddx.CLientDocumentGUID = odx.OwnerGUID and odx.active = 1 " +|| " join CV3Observation ox with (nolock) ON ox.GUID = odx.ObservationGUID " +|| " join CV3ObsCatalogMasterItem ocmix with (nolock) on odx.ObsMasterItemGUID = ocmix.GUID and ocmix.name = {{{SINGLE-QUOTE}}}SCHCK_Tdap vaccine type rec ob{{{SINGLE-QUOTE}}} " +|| " left join SCMObsFSListValues fslx(nolock) ON (fslx.ParentGUID = odx.ObservationDocumentGUID AND fslx.ClientGUID = " || ClientGuid || " ) " +|| " where cdx.GUID = cd.guid ) " +|| " is null " +|| " order by (substring(o.valuetext, 7, 4)), (substring(o.valuetext, 1, 2)) , (substring(o.valuetext, 4, 2)) " +}; + +vaccinechartedwhen := (vaccinecharteddate as time); + + + +// Date vaccine #1 was charted in the patient profile - old style (with tetanus radio button selected....not + + +(vaccinecharteddateoldstyle) := read last +{ +" select " +||" case when LEN(o.valuetext) = 8 then " +||" case when (substring(o.valuetext, 7, 1)) in ({{{SINGLE-QUOTE}}}7{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}8{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}9{{{SINGLE-QUOTE}}}) then {{{SINGLE-QUOTE}}}19{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}20{{{SINGLE-QUOTE}}} end " +|| " + (substring(o.valuetext, 7, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +|| "(substring(o.valuetext, 1, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 4, 2)) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| "else " +|| "(substring(o.valuetext, 7, 4)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 1, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 4, 2)) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| " end " +|| " from CV3ClientDocument cd with (nolock) " +|| " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = " || ClientGuid || " and cdd.active = 1) " +|| " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " +|| " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " +|| " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID and ocmi.name = {{{SINGLE-QUOTE}}}SCHCK_Tdap date vacc rec ob{{{SINGLE-QUOTE}}} " +|| " where cd.clientguid = " || ClientGuid || " and cd.iscanceled = 0 and cd.documentname like {{{SINGLE-QUOTE}}}%patient profile%{{{SINGLE-QUOTE}}} " +|| " and " +|| " (select top 1 fslx.value " +|| " from CV3ClientDocument cdx with (nolock) " +|| " join CV3ClientDocDetail cddx with (nolock) ON (cddx.ClientDocumentGUID = cdx.GUID AND cddx.ClientGUID = " || ClientGuid || " and cddx.active = 1) " +|| " join CV3ObservationDocument odx with (nolock)ON cddx.CLientDocumentGUID = odx.OwnerGUID and odx.active = 1 " +|| " join CV3Observation ox with (nolock) ON ox.GUID = odx.ObservationGUID " +|| " join CV3ObsCatalogMasterItem ocmix with (nolock) on odx.ObsMasterItemGUID = ocmix.GUID and ocmix.name = {{{SINGLE-QUOTE}}}SCHCK_Tdap vaccine type rec ob{{{SINGLE-QUOTE}}} " +|| " left join SCMObsFSListValues fslx(nolock) ON (fslx.ParentGUID = odx.ObservationDocumentGUID AND fslx.ClientGUID = " || ClientGuid || " ) " +|| " where cdx.GUID = cd.guid ) " +|| " = {{{SINGLE-QUOTE}}}TDAP{{{SINGLE-QUOTE}}} " +|| " order by (substring(o.valuetext, 7, 4)), (substring(o.valuetext, 1, 2)) , (substring(o.valuetext, 4, 2)) " +}; + +vaccinechartedwhenoldstyle := (vaccinecharteddateoldstyle as time); + + +// Date vaccine #1 was charted as given in the EMAR + +(vaccinegivenwhen) := read last +{ +" select oto.performedfromdtm " +|| " from cv3ordercatalogmasteritem as ocmi with (nolock) " +|| " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid " +|| " and o.ClientGUID = " || ClientGuid || " " +|| " and (o.name = {{{SINGLE-QUOTE}}}Diphtheria, Pertussis, Tetanus Vaccine{{{SINGLE-QUOTE}}}) " +|| " join cv3ordertask as ot with (nolock) on ot.clientguid = o.clientguid and ot.orderguid = o.guid " +|| " join cv3ordertaskoccurrence as oto with (nolock) on oto.clientguid = ot.clientguid and oto.orderguid = ot.orderguid " +|| " and oto.ordertaskguid = ot.guid and oto.taskstatuscode ={{{SINGLE-QUOTE}}}Performed{{{SINGLE-QUOTE}}} " +}; + + +// Date vaccine #1 was last charted as an active health issue + + +(vaccinehealthissuedate) := read last +{ +" select " +|| " case when onsetyearnum = 0 " +|| " then createdwhen " +|| " else " +|| " case when (onsetmonthnum >0 and onsetmonthnum <10) then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} + cast (onsetmonthnum as varchar) " +|| " when onsetmonthnum = 0 then {{{SINGLE-QUOTE}}}01{{{SINGLE-QUOTE}}} else cast (onsetmonthnum as varchar) end + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +|| " case when (onsetdaynum >0 and onsetdaynum <10) then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} + cast (onsetdaynum as varchar) " +|| " when onsetdaynum = 0 then {{{SINGLE-QUOTE}}}01{{{SINGLE-QUOTE}}} else cast (onsetdaynum as varchar) end " +|| " + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + cast (onsetyearnum as varchar) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| " end {{{SINGLE-QUOTE}}}date returned to mlm{{{SINGLE-QUOTE}}} " +|| " from cv3healthissuedeclaration with (nolock) " +|| " where clientguid = " || ClientGuid || " and active = 1 and status = {{{SINGLE-QUOTE}}}active{{{SINGLE-QUOTE}}}" +|| " and (text like {{{SINGLE-QUOTE}}}%TDAP%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%TDAP%{{{SINGLE-QUOTE}}}) " +|| " order by createdwhen " +}; +vaccinehealthissue_found := count(vaccinehealthissue) As Number; + + + + +// Gather date information related to the second of two vaccines (TETANUS) + + +// Date vaccine #2 was charted in the patient profile + + +(vaccinecharteddate_2) := read last +{ +" select " +||" case when LEN(o.valuetext) = 8 then " +||" case when (substring(o.valuetext, 7, 1)) in ({{{SINGLE-QUOTE}}}7{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}8{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}9{{{SINGLE-QUOTE}}}) then {{{SINGLE-QUOTE}}}19{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}20{{{SINGLE-QUOTE}}} end " +|| " + (substring(o.valuetext, 7, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +|| "(substring(o.valuetext, 1, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 4, 2)) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| "else " +|| "(substring(o.valuetext, 7, 4)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 1, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 4, 2)) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| " end " +|| " from CV3ClientDocument cd with (nolock) " +|| " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = " || ClientGuid || " and cdd.active = 1) " +|| " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " +|| " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " +|| " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID and ocmi.name = {{{SINGLE-QUOTE}}}SCHCK_Tetanus date vacc rec{{{SINGLE-QUOTE}}} " +|| " where cd.clientguid = " || ClientGuid || " and cd.iscanceled = 0 and cd.documentname like {{{SINGLE-QUOTE}}}%patient profile%{{{SINGLE-QUOTE}}} " +|| " and " +|| " (select top 1 fslx.value " +|| " from CV3ClientDocument cdx with (nolock) " +|| " join CV3ClientDocDetail cddx with (nolock) ON (cddx.ClientDocumentGUID = cdx.GUID AND cddx.ClientGUID = " || ClientGuid || " and cddx.active = 1) " +|| " join CV3ObservationDocument odx with (nolock)ON cddx.CLientDocumentGUID = odx.OwnerGUID and odx.active = 1 " +|| " join CV3Observation ox with (nolock) ON ox.GUID = odx.ObservationGUID " +|| " join CV3ObsCatalogMasterItem ocmix with (nolock) on odx.ObsMasterItemGUID = ocmix.GUID and ocmix.name = {{{SINGLE-QUOTE}}}SCHCK_Tdap vaccine type rec ob{{{SINGLE-QUOTE}}} " +|| " left join SCMObsFSListValues fslx(nolock) ON (fslx.ParentGUID = odx.ObservationDocumentGUID AND fslx.ClientGUID = " || ClientGuid || " ) " +|| " where cdx.GUID = cd.guid ) " +|| " is null " +|| " order by (substring(o.valuetext, 7, 4)), (substring(o.valuetext, 1, 2)) , (substring(o.valuetext, 4, 2)) " +}; + +vaccinechartedwhen_2 := (vaccinecharteddate_2 as time); + + + +// Date vaccine #2 was charted in the patient profile - old style (with tetanus radio button selected....not + + +(vaccinecharteddateoldstyle_2) := read last +{ +" select " +||" case when LEN(o.valuetext) = 8 then " +||" case when (substring(o.valuetext, 7, 1)) in ({{{SINGLE-QUOTE}}}7{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}8{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}9{{{SINGLE-QUOTE}}}) then {{{SINGLE-QUOTE}}}19{{{SINGLE-QUOTE}}} else {{{SINGLE-QUOTE}}}20{{{SINGLE-QUOTE}}} end " +|| " + (substring(o.valuetext, 7, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +|| "(substring(o.valuetext, 1, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 4, 2)) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| "else " +|| "(substring(o.valuetext, 7, 4)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 1, 2)) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + (substring(o.valuetext, 4, 2)) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| " end " +|| " from CV3ClientDocument cd with (nolock) " +|| " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = " || ClientGuid || " and cdd.active = 1) " +|| " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " +|| " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " +|| " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID and ocmi.name = {{{SINGLE-QUOTE}}}SCHCK_Tdap date vacc rec ob{{{SINGLE-QUOTE}}} " +|| " where cd.clientguid = " || ClientGuid || " and cd.iscanceled = 0 and cd.documentname like {{{SINGLE-QUOTE}}}%patient profile%{{{SINGLE-QUOTE}}} " +|| " and " +|| " (select top 1 fslx.value " +|| " from CV3ClientDocument cdx with (nolock) " +|| " join CV3ClientDocDetail cddx with (nolock) ON (cddx.ClientDocumentGUID = cdx.GUID AND cddx.ClientGUID = " || ClientGuid || " and cddx.active = 1) " +|| " join CV3ObservationDocument odx with (nolock)ON cddx.CLientDocumentGUID = odx.OwnerGUID and odx.active = 1 " +|| " join CV3Observation ox with (nolock) ON ox.GUID = odx.ObservationGUID " +|| " join CV3ObsCatalogMasterItem ocmix with (nolock) on odx.ObsMasterItemGUID = ocmix.GUID and ocmix.name = {{{SINGLE-QUOTE}}}SCHCK_Tdap vaccine type rec ob{{{SINGLE-QUOTE}}} " +|| " left join SCMObsFSListValues fslx(nolock) ON (fslx.ParentGUID = odx.ObservationDocumentGUID AND fslx.ClientGUID = " || ClientGuid || " ) " +|| " where cdx.GUID = cd.guid ) " +|| " = {{{SINGLE-QUOTE}}}Tetanus{{{SINGLE-QUOTE}}} " +|| " order by (substring(o.valuetext, 7, 4)), (substring(o.valuetext, 1, 2)) , (substring(o.valuetext, 4, 2)) " +}; + +vaccinechartedwhenoldstyle_2 := (vaccinecharteddateoldstyle_2 as time); + + +// Date vaccine #2 was charted as given in the EMAR + +(vaccinegivenwhen_2) := read last +{ +" select oto.performedfromdtm " +|| " from cv3ordercatalogmasteritem as ocmi with (nolock) " +|| " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid " +|| " and o.ClientGUID = " || ClientGuid || " " +|| " and (o.name in ({{{SINGLE-QUOTE}}}Tetanus Toxoid Adsorbed Inj{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Diphtheria/Tetanus Toxoid{{{SINGLE-QUOTE}}})) " +|| " join cv3ordertask as ot with (nolock) on ot.clientguid = o.clientguid and ot.orderguid = o.guid " +|| " join cv3ordertaskoccurrence as oto with (nolock) on oto.clientguid = ot.clientguid and oto.orderguid = ot.orderguid " +|| " and oto.ordertaskguid = ot.guid and oto.taskstatuscode ={{{SINGLE-QUOTE}}}Performed{{{SINGLE-QUOTE}}} " +}; + + +// Date vaccine #2 was last charted as an active health issue + + +(vaccinehealthissuedate_2) := read last +{ +" select " +|| " case when onsetyearnum = 0 " +|| " then createdwhen " +|| " else " +|| " case when (onsetmonthnum >0 and onsetmonthnum <10) then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} + cast (onsetmonthnum as varchar) " +|| " when onsetmonthnum = 0 then {{{SINGLE-QUOTE}}}01{{{SINGLE-QUOTE}}} else cast (onsetmonthnum as varchar) end + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + " +|| " case when (onsetdaynum >0 and onsetdaynum <10) then {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} + cast (onsetdaynum as varchar) " +|| " when onsetdaynum = 0 then {{{SINGLE-QUOTE}}}01{{{SINGLE-QUOTE}}} else cast (onsetdaynum as varchar) end " +|| " + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + cast (onsetyearnum as varchar) +{{{SINGLE-QUOTE}}} 00:00:00.000{{{SINGLE-QUOTE}}} " +|| " end {{{SINGLE-QUOTE}}}date returned to mlm{{{SINGLE-QUOTE}}} " +|| " from cv3healthissuedeclaration with (nolock) " +|| " where clientguid = " || ClientGuid || " and active = 1 and status = {{{SINGLE-QUOTE}}}active{{{SINGLE-QUOTE}}}" +|| " and (text like {{{SINGLE-QUOTE}}}%Tetanus%{{{SINGLE-QUOTE}}} or shortname like {{{SINGLE-QUOTE}}}%Tetanus%{{{SINGLE-QUOTE}}}) " +|| " order by createdwhen " +}; +vaccinehealthissue_found_2 := count(vaccinehealthissue_2) As Number; + + + + + + +// Populate Fields and Boxes + + + + + +// Populate the latest date of Vaccine #1 (TDAP) + + +// First determine which of the 3 dates is latest (vaccine given, charted, or health issue) + + match1 := false; + match2 := false; + match3 := false; + nodates:= false; + + If vaccinegivenwhen is null and vaccinehealthissuedate is null and vaccinechartedwhen is null and vaccinechartedwhenoldstyle is null + then nodates := true; endif; + + If vaccinegivenwhen is null then vaccinegivenwhen := 1800-01-01T00:00:00; endif; + If vaccinehealthissuedate is null then vaccinehealthissuedate := 1800-01-01T00:00:00; endif; + If vaccinechartedwhen is null then vaccinechartedwhen := 1800-01-01T00:00:00; endif; + If vaccinechartedwhenoldstyle is null then vaccinechartedwhenoldstyle := 1800-01-01T00:00:00; endif; + +// Save the "new stye" date (for the HIS box) & then update vaccinechartedwhen with the later of the two dates ("old style" w/tetanus radio button or "new style w/no radio button) + + vaccinechartedwhennewstyle := vaccinechartedwhen; + if vaccinechartedwhenoldstyle IS AFTER vaccinechartedwhen then vaccinechartedwhen := vaccinechartedwhenoldstyle; endif; + +// With the latest "vaccine given" date established, proceed with the process of determining the latest of (vaccine given, charted, or health issue) + + match1 := vaccinegivenwhen IS AFTER vaccinehealthissuedate; + + If match1 = true + then match2 := vaccinegivenwhen IS AFTER vaccinechartedwhen; + else match3 := vaccinehealthissuedate IS AFTER vaccinechartedwhen; + endif; + + If match2 = true then givenwins := true; endif; + If match3 = true then healthissuewins := true; endif; + If (match2 = false) and (match3 = false) then chartedwins := true; endif; + + + if nodates = false then + If givenwins = true then latestdate := vaccinegivenwhen; endif; + If healthissuewins = true then latestdate := vaccinehealthissuedate; endif; + If chartedwins = true then latestdate := vaccinechartedwhen; endif; + endif; + + +// Populate Date field + + +// First determine if the field has been manually updated by the nurse (not empty) + + theParameter := first of (thisParameters where thisParameters.Name = "SCHCK_Tdap date vacc rec ob"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + datefieldcontents := theObservation.ValueObj.Value; + + if datefieldcontents is null + then datefield := latestdate; + else datefield := datefieldcontents; + endif; + +// Populate the field if history is found in SCM and the field hasn{{{SINGLE-QUOTE}}}t been overriden by the nurse (not empty) + + If latestdate is not null and datefieldcontents is null + then + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Tdap date vacc rec ob"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "DateValue"; + this_currentObj.ValueObj := New DateValueType; + this_currentObj.ValueObj.Value := latestdate; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + + + + +// Populate the latest date of Vaccine #2 (TETANUS) + + +// First determine which of the 3 dates is latest (vaccine given, charted, or health issue) + + match1_2 := false; + match2_2 := false; + match3_2 := false; + nodates_2:= false; + + If vaccinegivenwhen_2 is null and vaccinehealthissuedate_2 is null and vaccinechartedwhen_2 is null and vaccinechartedwhenoldstyle_2 is null + then nodates_2 := true; endif; + + If vaccinegivenwhen_2 is null then vaccinegivenwhen_2 := 1800-01-01T00:00:00; endif; + If vaccinehealthissuedate_2 is null then vaccinehealthissuedate_2 := 1800-01-01T00:00:00; endif; + If vaccinechartedwhen_2 is null then vaccinechartedwhen_2 := 1800-01-01T00:00:00; endif; + If vaccinechartedwhenoldstyle_2 is null then vaccinechartedwhenoldstyle_2 := 1800-01-01T00:00:00; endif; + +// Save the "new stye" date (for the HIS box) & then update vaccinechartedwhen with the later of the two dates ("old style" w/tetanus radio button or "new style w/no radio button) + + vaccinechartedwhennewstyle_2 := vaccinechartedwhen_2; + if vaccinechartedwhenoldstyle_2 IS AFTER vaccinechartedwhen_2 then vaccinechartedwhen_2 := vaccinechartedwhenoldstyle_2; endif; + +// With the latest "vaccine given" date established, proceed with the process of determining the latest of (vaccine given, charted, or health issue) + + match1_2 := vaccinegivenwhen_2 IS AFTER vaccinehealthissuedate_2; + + If match1_2 = true + then match2_2 := vaccinegivenwhen_2 IS AFTER vaccinechartedwhen_2; + else match3_2 := vaccinehealthissuedate_2 IS AFTER vaccinechartedwhen_2; + endif; + + If match2_2 = true then givenwins_2 := true; endif; + If match3_2 = true then healthissuewins_2 := true; endif; + If (match2_2 = false) and (match3_2 = false) then chartedwins_2 := true; endif; + + + if nodates_2 = false then + If givenwins_2 = true then latestdate_2 := vaccinegivenwhen_2; endif; + If healthissuewins_2 = true then latestdate_2 := vaccinehealthissuedate_2; endif; + If chartedwins_2 = true then latestdate_2 := vaccinechartedwhen_2; endif; + endif; + + +// Populate Date field + + +// First determine if the field has been manually updated by the nurse (not empty) + + theParameter := first of (thisParameters where thisParameters.Name = "SCHCK_Tetanus date vacc rec"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + datefieldcontents_2 := theObservation.ValueObj.Value; + + if datefieldcontents_2 is null + then datefield_2 := latestdate_2; + else datefield_2 := datefieldcontents_2; + endif; + +// Populate the field if history is found in SCM and the field hasn{{{SINGLE-QUOTE}}}t been overriden by the nurse (not empty) + + If latestdate_2 is not null and datefieldcontents_2 is null + then + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Tetanus date vacc rec"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "DateValue"; + this_currentObj.ValueObj := New DateValueType; + this_currentObj.ValueObj.Value := latestdate_2; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + endif; + + +// REASSESS ONLY SECTION + + + elseIf MLMAction = "Reassess Only" then + + +// Determine if any of the Contraindications boxes are checked + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_TDAP ED vac contra"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + If true not in (theObservation.ValueObj.ListItemsList.IsSelected) + then contraboxchecked := "unknown"; + elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "none") + then contraboxchecked := "false"; + else contraboxchecked := "true"; + endif; + + +// Determine the value of the date given field for the first vaccine + + theParameter := first of (thisParameters where thisParameters.Name = "SCHCK_Tdap date vacc rec ob"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + datefield := theObservation.ValueObj.Value; + if datefield is null then datefield := "unknown"; endif; + + +// Determine the value of the date given field for the second vaccine + + theParameter := first of (thisParameters where thisParameters.Name = "SCHCK_Tetanus date vacc rec"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + datefield_2 := theObservation.ValueObj.Value; + if datefield_2 is null then datefield_2 := "unknown"; endif; + + + + endif; // End of "Reassess Only" Section + + + + + +// ASSESS THE RISK SECTION ("Retrieve and Reassess" or "Reassess Only") + + + if MLMAction = "Retrieve and Reassess" or MLMAction = "Reassess Only" then + + + // set to unknown to satisfy conditions below + + if datefield is null then datefield := "unknown"; endif; + if datefield_2 is null then datefield_2 := "unknown"; endif; + +/* + + + + +// SECTIONS BELOW ARE COMMENTED OUT AS NO ORDER IS PLACED FOR TETANUS OR TDAP WHEN THE PATIENT IS IN THE ED (not removed if needed later) + + + + +// Risk Senarios + + +// Scenarios that will cause an order to be placed + + +If datefield = "unknown" then ordervaccine := "yes"; +formattedTextReason := "Y-1. Order is to be placed since patient has never received a vaccine." ; endif; + + +// Scenarios that will NOT cause an order to be placed + + +If datefield <> "unknown" then ordervaccine := "no"; +formattedTextReason := "N-1. Order is not to be placed since patient has received the vaccine." ; endif; + + + +// Special Handling for Place Order Button Changes + +If trigger = "Order Button NO was selected" then ordervaccine := "no"; +formattedTextReason := formattedTextReason || " ** OVERRIDDEN TO NO BY " || userId || " ** "; endif; + +If trigger = "Order Button YES was selected" and ordervaccine = "no" then +dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n You cannot place an order on this patient. ", "Error","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; +formattedTextReason := formattedTextReason || " ** FAILED OVERRIDE TO YES BY " || userId || " ** "; endif; + +*/ + + + endif; // end of section for assessing risk + + + + endif; // End of Bypass Everything (If MLMAction <> "No Assessment Required") + + + + +// FOR ANY OBSERVATION CHANGE + + +// Select the appropriate Order Vaccine radio button determined by the assessment + +/* + If contraboxchecked = "true" then ordervaccine := "no"; + formattedTextReason := "N-7. Order will not be placed since the vaccine is contraindicated."; endif; + + + + this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_TDAP vac order"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "yes" and ordervaccine = "yes" then selectedItem.IsSelected := true; endif; + if selectedItem.Value = "no" and ordervaccine = "no" then selectedItem.IsSelected := true; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + +*/ + +endif; // End of Observation Event section + + + + + +// DOCUMENT CLOSING SECTION + +/* +IF thisdocumentCommunication.EventType = "DocumentClosing" then + + +// Determine if Place Order button is set to "Yes" + + theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_TDAP vac order"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no") + then placeorder := "no"; endif; + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") + then placeorder := "yes"; endif; + + +// Check for existing Vaccine Order on the account + + (orderpresent) := read + { + " select o.name " +|| " from cv3ordercatalogmasteritem as ocmi with (nolock) " +|| " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid " +|| " and o.ClientGUID = " || ClientGuid || " and o.ChartGUID = " || ChartGuid || " and o.ClientVisitGUID= " || VisitGuid || " " +|| " and (o.name = {{{SINGLE-QUOTE}}}Diphtheria, Pertussis, Tetanus Vaccine{{{SINGLE-QUOTE}}}) " +|| " and o.OrderStatusLevelNum > 15 " + }; +orderpresent_found := count(orderpresent) As Number; + +// If no existing order is found and Place Order button is "Yes" then create a new order + + + + If placeorder = "yes" and orderpresent_found = 0 then + + SessionType := "Standard"; + SessionReason := ""; + RequestingSource := ""; + user_IDType := "Edstan Number (physician)"; + order_Creation_Reason := "From Test MLM"; + + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((thisdocumentCommunication.ClientVisitGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + user_IDCode := read last {"SELECT IDCode FROM CV3User " || " where GUID = " || thisdocumentCommunication.UserGUID}; + RequestingCareProvider_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindById with ( user_IDType, (user_IDCode as STRING) ); + location_guid := read last {"SELECT CurrentLocationGUID FROM CV3ClientVisit where ClientGUID = " || thisdocumentCommunication.ClientGUID}; + location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((location_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + + // Create a new MEDICATION order from a Pre-Filled item + try + Catalog_Item_Name := "Diphtheria, Pertussis, Tetanus Vaccine"; + Catalog_Item_Modifier := "0.5mL, IM, Once"; + Catalog_Item_Version := ""; + Medication_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with Catalog_Item_Name; + PreFilled_MedicationOrder_obj := call {{{SINGLE-QUOTE}}}MedicationOrder{{{SINGLE-QUOTE}}}.CreateMedicationOrder + with + client_visit_obj, // ClientVisit ObjectsPlus object + Medication_catalog_item, // OrderCatalogMasterItem ObjectsPlus object + Catalog_Item_Modifier, // string ItemNameModifier + Catalog_Item_Version, // string ItemNameModifierVersion + order_Creation_Reason, // string CreateReason + RequestingCareProvider_obj , // RequestedBy ObjectsPlus object + RequestingSource, // string RequestedBySource (must be in dictionary) + SessionType, // string SessionType + SessionReason, // string SessionReason + location_obj, // Location ReleaseLocGrpID + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; // AvailabilityOverride eAvailabilityOverride + + + if ( Medication_catalog_item is NOT NULL ) then + void := call PreFilled_MedicationOrder_obj.Save; + void := call PreFilled_MedicationOrder_obj.Dispose; + void:= call Medication_catalog_item.Dispose; + Medication_catalog_item:= null; + endif; + + + endtry; + + catch Exception ex error_occurred := true; error_message := "{{+R}}New prefilled medication order:{{-R}}\n" || ex.Message || "\n\n"; + + if ( Medication_catalog_item is NOT NULL ) then void:= call Medication_catalog_item.Dispose; Medication_catalog_item:= null; endif; + if ( PreFilled_MedicationOrder_obj is NOT NULL ) then void:= call PreFilled_MedicationOrder_obj.Dispose; PreFilled_MedicationOrder_obj:= null; endif; + + Prefilled_MedicationOrder_dest := null; + + endcatch; + + if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; + if ( RequestingCareProvider_obj is NOT NULL ) then void:= call RequestingCareProvider_obj.Dispose; RequestingCareProvider_obj:= null; endif; + if ( location_obj is NOT NULL ) then void:= call location_obj.Dispose; location_obj:= null; endif; + + + endif; // End of Place Order = Yes section + + endif; // End of Close Document +*/ + + + +// Populate the HIS only Assessment Information box + + +// This secton as well as the FormattedText1 := below are for diagnostic purposes only + +dateonly:= SUBSTRING 10 CHARACTERS FROM (datefield as string); +dateonly_2:= SUBSTRING 10 CHARACTERS FROM (datefield_2 as string); + +nowdateonly:= SUBSTRING 10 CHARACTERS FROM (now as string); + + + +Factor5 := "Contraindicated - "|| contraboxchecked; +Factor6 := " Tetanus Last Given Worklist - " || vaccinegivenwhen_2 || "\n Tetanus Last Given Profile - " || vaccinechartedwhennewstyle_2 || "\n Tetanus Last Given Profile Old Style - " || vaccinechartedwhenoldstyle_2 || "\n Tetanus Last Given Health Issue - " || vaccinehealthissuedate_2 || "\n Tetanus Last Given - " || dateonly_2; +Factor7 := " TDAP Last Given Worklist - " || vaccinegivenwhen || "\n TDAP Last Given Profile - " || vaccinechartedwhennewstyle || "\n TDAP Last Given Profile Old Style - " || vaccinechartedwhenoldstyle || "\n TDAP Last Given Health Issue - " || vaccinehealthissuedate || "\n TDAP Last Given - " || dateonly; +Factor9 := "Last Trigger Event - " || nowdateonly || " " || trigger || " by " || userid || " (MLM reaction - " || MLMAction || ")"; + + +formattedText1 := "\n\n" || Factor5 || "\n\n" || Factor6 || "\n\n" || Factor7 || "\n\n" || Factor9 ; + +formattedTextReason := formattedTextReason || formattedText1; + +this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_TDAP ED Risk Assess Details"); +this_currentObj := NEW ObservationType; +this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; +this_currentObj.ParameterGUID := this_parametername.ParameterGUID; +this_currentObj.DataType := "FreeTextValue"; +this_currentObj.ValueObj := New FreeTextValueType; +this_currentObj.ValueObj.Value := formattedTextReason; +thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_URINARY_CATHETER_CHART_ALERT.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_URINARY_CATHETER_CHART_ALERT.mlm new file mode 100644 index 0000000..0fa18a3 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_URINARY_CATHETER_CHART_ALERT.mlm @@ -0,0 +1,183 @@ +maintenance: + + title: DOC_FUNC_URINARY_CATHETER_CHART_ALERT;; + mlmname: DOC_FUNC_URINARY_CATHETER_CHART_ALERT;; + arden: version 2.5;; + version: 5.50;; + institution: Allscripts;; + author: Juliet M. Law ;; + specialist: ;; + date: 2016-01-25;; + validation: testing;; + +library: + purpose: Alert on decrease in Braden Scale Score. + ;; + explanation: On the Adult & OB Assessment/Intervention Flowsheet, display alert daily if "Urinary Catheter Risk Assessment" is not charted. + + Change History + + 01.25.2016 JML CSR 33953: Created + + ;; + keywords: catheter, alert, flowsheet + ;; +knowledge: + type: data-driven;; + data: + + (this_documentCommunication) := argument; + + // RS ADD Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + //Called MLMs to set up the CDS and return obs values + set_cds_vars := MLM {{{SINGLE-QUOTE}}}CALLED_DOC_FS_DEFINITION_MLM{{{SINGLE-QUOTE}}}; + read_obs_value := MLM {{{SINGLE-QUOTE}}}CALLED_DOC_FS_OBS_VALUE_MLM{{{SINGLE-QUOTE}}}; + + + /**************Make Changes To Spelling And Flags In This Section**************/ + //Set up variables; initialize + cath_param := "schck_as Cath Risk Assessment"; + + msg := ""; + + mlm_name := "DOC_FUNC_URINARY_CATHETER_CHART_ALERT"; + + //Set constants indicating document type and event + FLOWSHEET := "Flowsheet"; + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTCLOSING := "DocumentClosing"; + DOCUMENTOPENING := "DocumentOpening"; + + /******************************************************************************/ + + //Initialize DocumentCommunication objects + (this_documentCommunication, client_guid, client_visit_guid, chart_guid, + user_guid, document_type, document_name, event_type, + configuration_guid, this_currentObs, CancelEventFlag, this_fs_doc, + authored_by_guid, isIOFlowsheetFlag, client_document_guid, this_parameters, + this_columnList, this_currentColumn, this_chartedObservationsList, + this_parameters_displayName, current_parameter, current_parameter_name, current_parameter_guid, + current_parameter_datatype, selectedItems, selectedItems_Value, current_value, + diagnostic_message, displayMessageFlag) := call set_cds_vars WITH (this_documentCommunication); + + //Retrieve DocumentType (StructuredNote or Flowsheet) and EventType + this_DocumentType := this_documentCommunication.DocumentType; + this_EventType := this_documentCommunication.EventType; + + display_alert := false; + + foley_order_lst := ("{{{SINGLE-QUOTE}}}Catheter: Foley{{{SINGLE-QUOTE}}}", + "{{{SINGLE-QUOTE}}}Catheter: Indwelling Double Lumen{{{SINGLE-QUOTE}}}", + "{{{SINGLE-QUOTE}}}Catheter: Indwelling Triple Lumen{{{SINGLE-QUOTE}}}"); + + cath_nursing_instr_ord := "Catheter - Nursing Instructions"; + cath_nursing_instr_summary := "Daily assessment of Medical Necessity per the Nurse Driven Protocol"; + + med_nec_invalid_values_lst := ("{{{SINGLE-QUOTE}}}Placed by Urology/Urological Surgery{{{SINGLE-QUOTE}}}", + "{{{SINGLE-QUOTE}}}Hospice/Comfort Care{{{SINGLE-QUOTE}}}", + "{{{SINGLE-QUOTE}}}Chronic Urinary Catheter{{{SINGLE-QUOTE}}}"); + + fire_on_user_lst := ("RN","LPN","GN","IT"); + + + //Retrieve user{{{SINGLE-QUOTE}}}s order role + user_role := read last {"Select occupationcode " + ||" From cv3user " + ||" Where Guid = " || SQL(user_guid) }; + + //Process logic on Flowsheets when the document is closing + if (this_DocumentType = FLOWSHEET AND this_EventType = DOCUMENTOPENING AND ( user_role IN fire_on_user_lst ) ) then + + //Determine if patient has foley catheter order with valid values + cath_order_exists := read last { "SELECT 1" + || " FROM CV3Order as o with (nolock) JOIN CV3OrderCatalogMasterItem AS ocmi with (nolock)" + || " ON o.OrderCatalogMasterItemGUID = ocmi.GUID" + || " JOIN CV3OrderUserData oud WITH (NOLOCK)" + || " ON o.GUID = oud.OrderGUID" + || " AND o.ClientGUID = oud.ClientGUID" + || " WHERE o.ClientGUID = " || Sql(client_guid) + || " AND o.ClientVisitGUID = " || Sql(client_visit_guid) + || " AND o.ChartGUID = " || Sql(chart_guid) + || " AND o.Name IN ( " || foley_order_lst || " )" + || " AND exists ( SELECT 1 FROM CV3ORDER o2" + || " WHERE o2.Name = {{{SINGLE-QUOTE}}}" || cath_nursing_instr_ord || "{{{SINGLE-QUOTE}}}" + || " AND o2.SummaryLine LIKE {{{SINGLE-QUOTE}}}%" || cath_nursing_instr_summary || "%{{{SINGLE-QUOTE}}}" + || " AND o2.ClientGUID = o.ClientGUID" + || " AND o2.ClientVisitGUID = o.ClientVisitGUID" + || " AND o2.ChartGUID = o.ChartGUID" + || " AND ((o2.OrderStatusLevelNum > 15" + || " AND o2.OrderStatusLevelNum NOT IN ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}100{{{SINGLE-QUOTE}}}))" + || " OR o2.OrderStatusCode = {{{SINGLE-QUOTE}}}HOLD{{{SINGLE-QUOTE}}}))" + || " AND ((o.OrderStatusLevelNum > 15" + || " AND o.OrderStatusLevelNum NOT IN ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}100{{{SINGLE-QUOTE}}}))" + || " OR o.OrderStatusCode = {{{SINGLE-QUOTE}}}HOLD{{{SINGLE-QUOTE}}})" }; + + + if ( exists cath_order_exists ) then + //Retrieve current catheter risk assess. parameter + cath_risk_param := first of ( this_parameters WHERE this_parameters.Name = cath_param ); + + if ( exists cath_risk_param ) then + //Call MLM to retrieve value for Catheter Risk Assessment + (this_documentCommunication, cath_obs_new_value, cath_obs_curr_value) := CALL read_obs_value WITH (this_documentCommunication, cath_risk_param.Name, "Read"); + + //If new charted value does not exists, then need to check last time it was charted to determine if alert needed. + if ( NOT ( exists cath_obs_new_value ) ) then + //Retrieve last charted time for this obs + last_cath_chart_date := read last {"SELECT cd.AuthoredDtm" + || " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3ClientDocumentCUR cd WITH (NOLOCK) ON cv.GUID = cd.ClientVisitGUID" + || " AND cv.ClientGUID = cd.ClientGUID" + || " AND cv.ChartGUID = cd.ChartGUID" + || " JOIN CV3ClientDocDetailCUR cdd WITH (NOLOCK) ON cd.GUID = cdd.ClientDocumentGUID" + || " AND cd.ClientGUID = cdd.ClientGUID" + || " JOIN CV3ObservationDocumentCUR od WITH (NOLOCK) ON cdd.ClientDocumentGUID = od.OwnerGUID" + || " LEFT JOIN SCMObsFSListValues fsl WITH (NOLOCK) ON od.ObservationDocumentGUID = fsl.ParentGUID" + || " AND cdd.ClientGUID = fsl.ClientGUID" + || " JOIN CV3ObsCatalogMasterItem ocmi WITH (NOLOCK) ON od.ObsMasterItemGUID = ocmi.GUID" + || " JOIN CV3ObservationCUR o WITH (NOLOCK) ON od.ObservationGUID = o.GUID" + || " JOIN CV3ObsCatalogItem oci WITH (NOLOCK) ON o.ObsItemGUID = oci.GUID" + || " WHERE cd.clientguid = " || Sql(client_guid) + || " AND cd.chartguid = " || Sql(chart_guid) + || " AND cd.ClientVisitGUID = " || Sql(client_visit_guid) + || " AND oci.name = {{{SINGLE-QUOTE}}}" || cath_param || "{{{SINGLE-QUOTE}}}" + || " AND fsl.Value IS NOT NULL" + || " AND cdd.Active = 1" + || " AND od.active = 1" + || " ORDER BY cd.authoreddtm asc"}; + + //Has obs ever been charted? + if ( exists last_cath_chart_date ) then + //Calculate time elapsed since last chart to determine if alert displays + if ( NOW is greater than 24 HOURS from last_cath_chart_date ) then + display_alert := true; + endif; + else + display_alert := true; + endif; + endif; + endif; + + if ( display_alert ) then + msg := "Please complete the Catheter Risk Assessment on this patient."; + dialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with msg, "Catheter Risk Chart Alert", "Ok" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}, "Exclamation" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + endif; + + endif; + endif; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: + + return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_VS_24HRS.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_VS_24HRS.mlm new file mode 100644 index 0000000..8f700ca --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_VS_24HRS.mlm @@ -0,0 +1,515 @@ +maintenance: + + title: Vital Signs - Highs and Lows;; + mlmname: DOC_FUNC_VS_24hrs;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Don Warnick;; + specialist: ;; + date: 2010-02-02;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 02.02.2010 DW Copied from Jacob{{{SINGLE-QUOTE}}}s Springhill MLM stored here under the name DOC_SMC_FUNC_DOC_SMC_VITAL_SIGNS_HIGHS_AND_LOWS_Springhill + 08.18.2014 DW CSR# 32616 Add Newborn & Critical Care values to the Vital Signs Section (re-introduced this MLM & commented out VS section of DOC_ST_Clair_MAIN_PN_MLM) + 09.04.2014 DW CSR# 32175 Add Button for Ortostatic Vital Signs + 09.26.2014 DW HD# 1491452 Round the "Weight Change" value for newborn and adult to 2 digits + 04.18.2015 GOS CSR#33155 Added 3 orthostatic BP Heart Rate [supine, Sitting, Standing] observations in existing query + 10.27.2015 GOS CSR#33428 Added 2 Lbs weight changes observations And Showing Lbs Weight in Vital Sign on SN opening. + 09.08.2016 DW HD# 2316157 - Orthostatic BP not pulling into the EPN - Had to first copy Prod version to Dev as they were very different. Added a dash to the observation name. + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + + +// OBSERVATION CHANGE + + + + if thisDocumentCommunication.EventType = "ChartObservation" + then + + (obsNamesList, lastValuesList, highValuesList, lowValuesList) := read + { + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), name varchar(200), value varchar(500), timstmp datetime, sortseq int, timstmp2 varchar(30) ) " + || " INSERT INTO #tmp_aaa (name,value,timstmp, sortseq) " + || " select ocmi.Name, o.ValueText, od.RecordedDtm, " + || " CASE WHEN Name = {{{SINGLE-QUOTE}}}Supine Systolic BP{{{SINGLE-QUOTE}}} THEN 01 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Supine Diastolic BP{{{SINGLE-QUOTE}}} THEN 02 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Sitting Systolic BP{{{SINGLE-QUOTE}}} THEN 04 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Sitting Diastolic BP{{{SINGLE-QUOTE}}} THEN 05 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Standing Systolic BP{{{SINGLE-QUOTE}}} THEN 07 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Standing Diastolic BP{{{SINGLE-QUOTE}}} THEN 08 " + || " WHEN Name = {{{SINGLE-QUOTE}}}sch_orthostatic heart rate - supine{{{SINGLE-QUOTE}}} THEN 03 " + || " WHEN Name = {{{SINGLE-QUOTE}}}sch_orthostatic heart rate - sitting{{{SINGLE-QUOTE}}} THEN 06 " + || " WHEN Name = {{{SINGLE-QUOTE}}}sch_orthostatic heart rate - standing{{{SINGLE-QUOTE}}} THEN 09 " + || " ELSE 99 " + || " END AS SortSeq " + || " " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " AND ocmi.Name in ({{{SINGLE-QUOTE}}}Supine Systolic BP{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Supine Diastolic BP{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Sitting Systolic BP{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Sitting Diastolic BP{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Standing Systolic BP{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Standing Diastolic BP{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}sch_orthostatic heart rate - supine{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}sch_orthostatic heart rate - sitting{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}sch_orthostatic heart rate - standing{{{SINGLE-QUOTE}}} ) " + || " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " " + || " and cd.iscanceled = 0 " + || " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}Newborn Patient Profile{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}B1. Newborn Vital Signs{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}B2. Newborn Assessment/Intervention{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}1.Vital Signs - Basic{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}1.Vital Signs - Critical Care{{{SINGLE-QUOTE}}}) " + || " order by sortseq , cd.touchedwhen " + || " " + || " update t1 set timstmp2 = t2.timstmp from #tmp_aaa t1 " + || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq = t2.sortseq " + || " delete from #tmp_aaa where timstmp2 is not null " + || " " + || " select name, value, timstmp, sortseq from #tmp_aaa order by timstmp desc, sortseq " + || " drop table #tmp_aaa " + }; + + header1 :="\n\n\b Orthostatic Vital Signs in Past 24 Hours - Last Charted \b0\n\n"; + formattedText1 := " "; + thisdatefield := " "; + yesterday := now-24 hours; + + + indexList := 1 seqto count (obsNamesList); + + for i in indexList do + + obsName := last (first i from obsNamesList); + + // Reformat the Time Stamp + + thisdatefield_unformatted := last (first i from highValuesList); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the first group and charted in the past 24 hours + + if obsName in ("Supine Systolic BP" , "Supine Diastolic BP" , "Sitting Systolic BP" , "Sitting Diastolic BP" , "Standing Systolic BP" , "Standing Diastolic BP","sch_orthostatic heart rate - supine", + "sch_orthostatic heart rate - sitting","sch_orthostatic heart rate - standing" ) + and + thisdatefield_unformatted > yesterday + + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := last (first i from highValuesList); + formattedText1 := thisdatefield_formatted; + endif; + + + if thisdatefield <> last (first i from highValuesList) // new timestamp + then + formattedText1 := formattedText1 || "\n" || thisdatefield_formatted; + thisdatefield := last (first i from highValuesList); + else + formattedText1 := formattedText1 || " " ; + endif; + + + if obsName = "Supine Systolic BP" then formattedText1 := formattedText1 || "\b Supine BP:\b0 "; + elseif obsName = "Supine Diastolic BP" then formattedText1 := formattedText1 || "/"; + elseif obsName = "Sitting Systolic BP" then formattedText1 := formattedText1 || "\b Sitting BP:\b0 "; + elseif obsName = "Sitting Diastolic BP" then formattedText1 := formattedText1 || "/"; + elseif obsName = "Standing Systolic BP" then formattedText1 := formattedText1 || "\b Standing BP:\b0 "; + elseif obsName = "Standing Diastolic BP" then formattedText1 := formattedText1 || "/"; + elseif obsName = "sch_orthostatic heart rate - supine" then formattedText1 := formattedText1 || "\b Supine HR:\b0 "; + elseif obsName = "sch_orthostatic heart rate - sitting" then formattedText1 := formattedText1 || "\b Sitting HR:\b0 "; + elseif obsName = "sch_orthostatic heart rate - standing" then formattedText1 := formattedText1 || "\b Standing HR:\b0 "; + endif; + + formattedText1 := formattedText1 || " "; + formattedText1 := formattedText1 || last (first i from lastValuesList); + + endif; // Obsname amongst the Vital Signs observations + + enddo; + + + // Gather the existing contents of the textbox + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_FT VS, I & O"); + obs := FIRST OF (thisObservations WHERE thisObservations.parameterGUID = theParameter.parameterGUID); + priorcontents := obs.ValueObj.Value; + + formattedTextAll:= priorcontents || header1 || formattedText1; + + + + endif; + + +// DOCUMENT OPEN + + + if thisdocumentCommunication.EventType = "DocumentOpening" + then + + + + (OccCode, userName) := read last {" select OccupationCode, IDCode from CV3USER with (nolock) where guid = " || sql(thisDocumentCommunication.UserGUID) }; +// IF ( OccCode = "IT" AND userName = "jlaw" ) then +// break; +// endif; + + // Query the database for the vitals info + + + (obsNamesList, lastValuesList, highValuesList, lowValuesList) := read + { + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), name varchar(200), value varchar(500), timstmp datetime, sortseq int, timstmp2 varchar(30) ) " + || " INSERT INTO #tmp_aaa (name,value,timstmp, sortseq) " + || " select ocmi.Name, o.ValueText, od.RecordedDtm, " + || " CASE WHEN Name = {{{SINGLE-QUOTE}}}Farenheit{{{SINGLE-QUOTE}}} THEN 01 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Heart Rate{{{SINGLE-QUOTE}}} THEN 02 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Resp Rate{{{SINGLE-QUOTE}}} THEN 03 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Noninvasive Systolic BP{{{SINGLE-QUOTE}}} THEN 04 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Noninvasive Diastolic BP{{{SINGLE-QUOTE}}} THEN 05 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Arterial Systolic BP - Radial{{{SINGLE-QUOTE}}} THEN 06 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Arterial Diastolic BP - Radial{{{SINGLE-QUOTE}}} THEN 07 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Arterial Systolic BP - Second Line{{{SINGLE-QUOTE}}} THEN 08 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Arterial Diastolic - Second Line{{{SINGLE-QUOTE}}} THEN 09 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_vs_pulse ox saturation{{{SINGLE-QUOTE}}} THEN 10 " + || " WHEN Name = {{{SINGLE-QUOTE}}}L/min{{{SINGLE-QUOTE}}} THEN 11 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Height in cm{{{SINGLE-QUOTE}}} THEN 20 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Height in ft{{{SINGLE-QUOTE}}} THEN 21 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Height remainder in inches{{{SINGLE-QUOTE}}} THEN 22 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby a wt gm ob NU{{{SINGLE-QUOTE}}} THEN 23 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby b wt gm ob NU{{{SINGLE-QUOTE}}} THEN 24 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby a wt lb ob NU{{{SINGLE-QUOTE}}} THEN 25 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby a wt oz ob NU{{{SINGLE-QUOTE}}} THEN 26 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby b wt lb ob NU{{{SINGLE-QUOTE}}} THEN 27 " + || " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby b wt oz ob NU{{{SINGLE-QUOTE}}} THEN 28 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - grams{{{SINGLE-QUOTE}}} THEN 29 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - lbs{{{SINGLE-QUOTE}}} THEN 40 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - oz{{{SINGLE-QUOTE}}} THEN 41 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Weight - lbs{{{SINGLE-QUOTE}}} THEN 42 " + || " WHEN Name = {{{SINGLE-QUOTE}}}Weight - kg{{{SINGLE-QUOTE}}} THEN 43 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_vs_Occipital-Frontal Head{{{SINGLE-QUOTE}}} THEN 44 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Stool{{{SINGLE-QUOTE}}}THEN 45 " + || " WHEN Name = {{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Urine{{{SINGLE-QUOTE}}}THEN 46 " + || " ELSE 99 " + || " END AS SortSeq " + || " " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " AND ocmi.Name in ( " + || " {{{SINGLE-QUOTE}}}farenheit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Heart Rate{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Resp Rate{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_vs_pulse ox saturation{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}L/min{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}Noninvasive Diastolic BP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Noninvasive Systolic BP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Arterial Systolic BP - Radial{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Arterial Diastolic BP - Radial{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Arterial Systolic BP - Second Line{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Arterial Diastolic - Second Line{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}AS deliv baby a wt gm ob NU{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}AS deliv baby b wt gm ob NU{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}AS deliv baby a wt lb ob NU{{{SINGLE-QUOTE}}} , " + || " {{{SINGLE-QUOTE}}}AS deliv baby b wt lb ob NU{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}AS deliv baby a wt oz ob NU{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}AS deliv baby b wt oz ob NU{{{SINGLE-QUOTE}}} , " + || " {{{SINGLE-QUOTE}}}SCH_Newborn Weight - grams{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_Newborn Weight - lbs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_Newborn Weight - oz{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}Weight - lbs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Weight - kg{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}Height in ft{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Height remainder in inches{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Height in cm{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCH_vs_Occipital-Frontal Head{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}Current Weight{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Stool{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Urine{{{SINGLE-QUOTE}}} " + || " ) " + || " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " " + || " and cd.iscanceled = 0 " + || " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}Newborn Patient Profile{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}B1. Newborn Vital Signs{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}B2. Newborn Assessment/Intervention{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}1.Vital Signs - Basic{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}1.Vital Signs - Critical Care{{{SINGLE-QUOTE}}}) " + || " order by sortseq , cd.touchedwhen " + || " " + || " update t1 set timstmp2 = t2.timstmp from #tmp_aaa t1 " + || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq = t2.sortseq " + || " update t2 set timstmp2 = {{{SINGLE-QUOTE}}}first weight{{{SINGLE-QUOTE}}}, name = {{{SINGLE-QUOTE}}}First Adult Weight - kg{{{SINGLE-QUOTE}}} from #tmp_aaa t1 " + || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq <> t2.sortseq and t2.name = {{{SINGLE-QUOTE}}}Weight - kg{{{SINGLE-QUOTE}}} " + || " update t2 set timstmp2 = {{{SINGLE-QUOTE}}}first weight lbs{{{SINGLE-QUOTE}}}, name = {{{SINGLE-QUOTE}}}First Adult Weight - lbs{{{SINGLE-QUOTE}}} from #tmp_aaa t1 " // Added By Shivprasad for CSR:33428 on 27 Oct 2015 + || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq <> t2.sortseq and t2.name = {{{SINGLE-QUOTE}}}Weight - lbs{{{SINGLE-QUOTE}}} " // Added By Shivprasad for CSR:33428 on 27 Oct 2015 + || " delete from #tmp_aaa where timstmp2 is not null and timstmp2 <> {{{SINGLE-QUOTE}}}first weight{{{SINGLE-QUOTE}}} And timstmp2 <> {{{SINGLE-QUOTE}}}first weight lbs{{{SINGLE-QUOTE}}} " // Added By Shivprasad for CSR:33428 on 27 Oct 2015 + || " " + || " select name, value, timstmp, sortseq from #tmp_aaa order by timstmp desc, sortseq " + || " drop table #tmp_aaa " + }; + + + + // Process the First Group Data Elements (past 24 hours) + + + header1 :="\b Vital Signs in Past 24 Hours - Last Charted \b0\n\n"; + formattedText1:= " "; + thisdatefield := " "; + yesterday:= now-24 hours; + + indexList := 1 seqto count (obsNamesList); + + for i in indexList do + + obsName := last (first i from obsNamesList); + + // Reformat the Time Stamp + + thisdatefield_unformatted := last (first i from highValuesList); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the first group and charted in the past 24 hours + + if obsName in ("farenheit","Heart Rate","Resp Rate","SCH_vs_pulse ox saturation","L/min", + "Noninvasive Diastolic BP","Noninvasive Systolic BP","Arterial Systolic BP - Radial","Arterial Diastolic BP - Radial", + "Arterial Systolic BP - Second Line","Arterial Diastolic - Second Line" ) + and + thisdatefield_unformatted > yesterday + + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := last (first i from highValuesList); + formattedText1 := thisdatefield_formatted; + endif; + + + if thisdatefield <> last (first i from highValuesList) // new timestamp + then + formattedText1 := formattedText1 || "\n" || thisdatefield_formatted; + thisdatefield := last (first i from highValuesList); + else + formattedText1 := formattedText1 || " " ; + endif; + + + if obsName = "Heart Rate" then formattedText1 := formattedText1 || "\b HR:\b0 "; + elseif obsName = "Farenheit" then formattedText1 := formattedText1 || "\b T:\b0 "; + elseif obsName = "Noninvasive Systolic BP" then formattedText1 := formattedText1 || "\b BP:\b0 "; + elseif obsName = "Noninvasive Diastolic BP" then formattedText1 := formattedText1 || "/"; + elseif obsName = "Arterial Systolic BP - Radial" then formattedText1 := formattedText1 || "\b ART BP:\b0 "; + elseif obsName = "Arterial Diastolic BP - Radial" then formattedText1 := formattedText1 || "/"; + elseif obsName = "Arterial Systolic BP - Second Line" then formattedText1 := formattedText1 || "\b ART BP Second:\b0 "; + elseif obsName = "Arterial Diastolic - Second Line" then formattedText1 := formattedText1 || "/"; + elseif obsName = "Resp Rate" then formattedText1 := formattedText1 || "\b R:\b0 "; + elseif obsName = "SCH_vs_pulse ox saturation" then formattedText1 := formattedText1 || "\b Pulse Ox:\b0 "; + elseif obsName = "L/min" then formattedText1 := formattedText1 || "\b O2 L/min:\b0 "; + endif; + + formattedText1 := formattedText1 || " "; + formattedText1 := formattedText1 || last (first i from lastValuesList); + + endif; // Obsname amongst the Vital Signs observations + + enddo; + + + formattedText1 := header1 || formattedText1; + + + + + // Process the Second Group Data Elements (Start of Chart) + + + + header2 :="\n\n \b Additional Information - Last Charted \b0 \n\n"; + formattedText2:= " "; + thisdatefield := " "; + + + indexList := 1 seqto count (obsNamesList); + for i in indexList do + + obsName := last (first i from obsNamesList); + + + // Reformat the Time Stamp + + + thisdatefield_unformatted := last (first i from highValuesList); + yy:= extract year thisdatefield_unformatted; + mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; + dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; + hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; + mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; + thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; + + + // Proceed if the data part of the second group + + + if obsName in ( + "AS deliv baby a wt gm ob NU" , "AS deliv baby b wt gm ob NU" , "AS deliv baby a wt lb ob NU" , "AS deliv baby b wt lb ob NU" , "AS deliv baby a wt oz ob NU" , "AS deliv baby b wt oz ob NU" , + "SCH_Newborn Weight - grams","SCH_Newborn Weight - lbs","SCH_Newborn Weight - oz", "Weight - lbs","Weight - kg","First Adult Weight - kg","Height in ft" , "Height remainder in inches" , "Height in cm", + "SCH_vs_Occipital-Frontal Head", "Current Weight","SCH_io_newborn_diaper count - Stool" , "SCH_io_newborn_diaper count - Urine" + ) + then + + if thisdatefield = " " // first timestamp + then + thisdatefield := last (first i from highValuesList); + formattedText2 := thisdatefield_formatted; + endif; + + + if thisdatefield <> last (first i from highValuesList) // new timestamp + then + formattedText2 := formattedText2 || "\n" || thisdatefield_formatted; + thisdatefield := last (first i from highValuesList); + else + formattedText2 := formattedText2 || " " ; + endif; + + + if obsName = "SCH_io_newborn_diaper count - Stool" then formattedText2 := formattedText2 || "\b Stool Diaper:\b0 "; + elseif obsName = "SCH_io_newborn_diaper count - Urine" then formattedText2 := formattedText2 || "\b Urine Diaper:\b0 "; + elseif obsName = "SCH_vs_Occipital-Frontal Head" then formattedText2 := formattedText2 || "\b H.C./cm:\b0 "; + elseif obsName = "Height in cm" then formattedText2 := formattedText2 || "\b Ht/cm:\b0 "; + elseif obsName = "Height in ft" then formattedText2 := formattedText2 || "\b Ht/ft:\b0 "; + elseif obsName = "Height remainder in inches" then formattedText2 := formattedText2 || "-"; + elseif obsName = "SCH_Newborn Weight - grams" then formattedText2 := formattedText2 || "\b Wt/gm:\b0 "; curwt:= last (first i from lastValuesList); + elseif obsName = "SCH_Newborn Weight - lbs" then formattedText2 := formattedText2 || "\b Wt/lb:\b0 "; + elseif obsName = "SCH_Newborn Weight - oz" then formattedText2 := formattedText2 || "-"; + elseif obsName = "AS deliv baby a wt gm ob NU" then formattedText2 := formattedText2 || "\b Deliv Wt/gm:\b0 "; delwt:= last (first i from lastValuesList); + elseif obsName = "AS deliv baby b wt gm ob NU" then formattedText2 := formattedText2 || "\b Deliv Wt/gm:\b0 "; delwt:= last (first i from lastValuesList); + elseif obsName = "AS deliv baby a wt lb ob NU" then formattedText2 := formattedText2 || "\b Deliv Wt/lb:\b0 "; + elseif obsName = "AS deliv baby a wt oz ob NU" then formattedText2 := formattedText2 || "-"; + elseif obsName = "AS deliv baby b wt lb ob NU" then formattedText2 := formattedText2 || "\b Deliv Wt/lb:\b0 "; + elseif obsName = "AS deliv baby b wt oz ob NU" then formattedText2 := formattedText2 || "-"; + elseif obsName = "Weight - lbs" then formattedText2 := formattedText2 || "\b Wt/lb:\b0 "; + elseif obsName = "Weight - kg" then formattedText2 := formattedText2 || "\b Wt/kg:\b0 "; lastwt := last (first i from lastValuesList); + elseif obsName = "First Adult Weight - kg" then formattedText2 := formattedText2 || "\b First Wt/kg:\b0 "; firstwt:= last (first i from lastValuesList); + elseif obsName = "First Adult Weight - lbs" then formattedText2 := formattedText2 || "\b First Wt/lb:\b0 "; // Added By Shivprasad for CSR:33428 on 27 Oct 2015 + endif; + + formattedText2 := formattedText2 || " "; + formattedText2 := formattedText2 || last (first i from lastValuesList); + + endif; // Obsname amongst the Additional Information observations + + enddo; + + + + // Calculate the weight change + + + + If exist delwt // Baby since birth weight + + then + wtlabel := "Wt change since birth: \b0 "; + wtscale := " gm "; + wtscalelbs := " lbs "; // Added By Shivprasad for CSR:33428 on 27 Oct 2015 + wtchange := ((curwt as number) - (delwt as number)) formatted with " %.2f %"; + wtchangepcnt := (((curwt as number) - (delwt as number))/(delwt as number) * 100) formatted with " %.2f %%"; + //Start: Added By Shivprasad for CSR:33428 on 27 Oct 2015 + Calc := (wtchange as number) * ("0.00220462" as number) ; + If Calc Is Not Null Then + WtChangeLbs := Read first{" Select Format( " || Calc || " , {{{SINGLE-QUOTE}}}00.00{{{SINGLE-QUOTE}}}) " } ; + // End : Added By Shivprasad for CSR:33428 on 27 Oct 2015 + Endif; + + else // Adult since first weighing + + wtlabel := "Wt change since first weighing: \b0 "; + wtscale := " kg "; + wtscalelbs := " lbs "; // Added By Shivprasad for CSR:33428 on 27 Oct 2015 + wtchange := ((lastwt as number) - (firstwt as number)) formatted with " %.2f %"; + wtchangepcnt := (((lastwt as number) - (firstwt as number)) /(firstwt as number) * 100) formatted with " %.2f %%"; + //Start: Added By Shivprasad for CSR:33428 on 27 Oct 2015 + Calc := (wtchange as number) * ("2.20462" as number) ; + If Calc Is Not Null Then + WtChangeLbs := Read first{" Select Format( " || Calc || " , {{{SINGLE-QUOTE}}}00.00{{{SINGLE-QUOTE}}}) " } ; + Endif; + // End : Added By Shivprasad for CSR:33428 on 27 Oct 2015 + + endif; + + + If wtchange is not null + then + //wtchange := " \n\n\b " || wtlabel || wtchange || wtscale || wtchangepcnt ; + wtchange := " \n\n\b " || wtlabel || WtChangeLbs || wtscalelbs || wtchange || wtscale || wtchangepcnt ; // Added By Shivprasad for CSR:33428 on 27 Oct 2015 + else + wtchange := " "; + endif; + + formattedText2 := header2 || formattedText2 || wtchange; + + + formattedTextAll:= formattedText1 || formattedText2; + + + endif; // Document Open + + + + + // Write to the Structured Note Text Box + + + + If formattedTextAll is not null + + then + + vitalSignsHL := first of (thisParameters where thisParameters.Name = "SCH_MDPN_FT VS, I & O"); + + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := vitalSignsHL.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := formattedTextAll; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + endif; + + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_FUNC_VTE_PHYSICIAN_OVERRIDE.mlm b/MLMStripper/bin/Debug/DOC/DOC_FUNC_VTE_PHYSICIAN_OVERRIDE.mlm new file mode 100644 index 0000000..f42cb20 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_FUNC_VTE_PHYSICIAN_OVERRIDE.mlm @@ -0,0 +1,576 @@ +maintenance: + + title: DOC_FUNC_VTE_PHYSICIAN_OVERRIDE;; + mlmname: DOC_FUNC_VTE_PHYSICIAN_OVERRIDE;; + arden: version 2.50;; + version: 6.10;; + institution: St.Clair Hospital;; + author: Juliet M. Johns;; + specialist: Shawn Head;; + date: 2014-03-24;; + validation: testing;; + +library: + purpose: When Adult Assessment / Intervention flowsheet is opened, alert the user if the physician has entered an override VTE Score + since the last nurse charted VTE score. + + When nurse charts the VTE Risk Assessment, if they select the observation for the physician override, pull in the + observations charted by the physician to determine the override score. + ;; + explanation: + Change history + + 03-24-2014 JML CSR #: 31893, MLM Created. + ;; + keywords: VTE, physician, override + ;; +knowledge: + type: data-driven;; + data: + + //Message box + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + set_cds_vars := MLM {{{SINGLE-QUOTE}}}CALLED_DOC_FS_DEFINITION_MLM{{{SINGLE-QUOTE}}}; + string_parse := MLM {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; + + // Receive arguments from the structured note + (this_DocumentCommunication) := argument; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + ListValueType := OBJECT [ListGuid, ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + //Document Type + FLOWSHEET := "FlowSheet"; + + //Event Types + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTCLOSING := "DocumentClosing"; + DOCUMENTOPENING := "DocumentOpening"; + + fireOnParam := "AS SC vte physician override"; + allZeroOverrides := false; + + (this_documentCommunication, client_guid, client_visit_guid, chart_guid, + user_guid, document_type, document_name, event_type, + configuration_guid, this_currentObs, CancelEventFlag, this_fs_doc, + authored_by_guid, isIOFlowsheetFlag, client_document_guid, this_parameters, + this_columnList, this_currentColumn, this_chartedObservationsList, + this_parameters_displayName, current_parameter, current_parameter_name, current_parameter_guid, + current_parameter_datatype, selectedItems, selectedItems_Value, current_value, + diagnostic_message, displayMessageFlag) := CALL set_cds_vars WITH (this_documentCommunication); + + //Retrieve physician VTE Override value and when it was entered + (overrideName, + overrideValue, + overrideDate) := read last {"SELECT oud.UserDataCode, oud.Value, oud.TouchedWhen" + || " FROM CV3Order as o with (nolock) JOIN CV3OrderCatalogMasterItem AS ocmi with (nolock)" + || " ON o.OrderCatalogMasterItemGUID = ocmi.GUID" + || " JOIN CV3OrderUserData oud with (nolock) " + || " ON o.GUID = oud.OrderGUID" + || " and o.ClientGUID = oud.ClientGUID" + || " WHERE o.ClientGUID = " || Sql(client_guid) + || " AND o.ClientVisitGUID = " || Sql(client_visit_guid) + || " AND o.ChartGUID = " || Sql(chart_guid) + || " AND o.Name = {{{SINGLE-QUOTE}}}VTE Drug Therapy Evaluation{{{SINGLE-QUOTE}}}" + || " AND" + || " ((o.OrderStatusLevelNum > 15" + || " AND o.OrderStatusLevelNum NOT IN ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}}))" + || " OR o.OrderStatusCode = {{{SINGLE-QUOTE}}}HOLD{{{SINGLE-QUOTE}}})" + || " AND (oud.UserDataCode = {{{SINGLE-QUOTE}}}OS_Information5{{{SINGLE-QUOTE}}}" + || " OR oud.UserDataCode = {{{SINGLE-QUOTE}}}OS_Information1{{{SINGLE-QUOTE}}})" + || " ORDER BY o.TouchedWhen ASC"}; + + + if ( overrideName = "OS_Information1" ) then + if ( overrideValue matches pattern "Physician override score = 0.%" ) then + allZeroOverrides := true; + endif; + endif; + + //only trigger on document open + if ( event_type = DOCUMENTOPENING ) then + + OccCode := read last {" select OccupationCode from CV3USER U " + || " where guid = " || sql(user_guid) }; + + + if ( OccCode IN ("RN","GN","SN","IT") ) then + + //Physician override was entered + if ( exists overrideValue ) then + + + //Retrieve last vte charted on flowsheet IF more recent than physician override + (lastVTEChartDate) := read last {"SELECT TOP 1 cd.AuthoredDtm" + || " FROM CV3ClientDocumentCUR cd with (nolock) JOIN CV3ClientDocDetailCUR cdd with (nolock) " + || " ON cd.GUID = cdd.ClientDocumentGUID " + || " AND cd.ClientGUID = cdd.ClientGUID " + || " JOIN CV3ObservationDocumentCUR od with (nolock) " + || " ON cdd.ClientDocumentGUID = od.OwnerGUID " + || " JOIN CV3ObsCatalogMasterItem ocmi with (nolock) " + || " ON od.ObsMasterItemGUID = ocmi.GUID " + || " JOIN CV3ObservationCUR o with (nolock) " + || " ON od.ObservationGUID = o.GUID " + || " JOIN CV3ObsCatalogItem oci with (nolock) " + || " ON o.ObsItemGUID = oci.GUID " + || " WHERE cd.ClientGUID = " || Sql(client_guid) + || " AND cd.ClientVisitGUID = " || Sql(client_visit_guid) + || " AND cd.ChartGUID = " || Sql(chart_guid) + || " AND od.Active = 1 " + || " AND cd.DocumentName = {{{SINGLE-QUOTE}}}2. Adult Assessment/Intervention{{{SINGLE-QUOTE}}}" + || " AND oci.Name = {{{SINGLE-QUOTE}}}AS SC vte score CAL{{{SINGLE-QUOTE}}}" + || " AND cd.AuthoredDtm >= {{{SINGLE-QUOTE}}}" || overrideDate || "{{{SINGLE-QUOTE}}}" + || " ORDER BY cd.AuthoredDtm DESC"}; + + //A VTE was charted on the flowsheet since physician entered override, don{{{SINGLE-QUOTE}}}t show alert + //Otherwise, show alert + if ( NOT ( exists lastVTEChartDate ) ) then + //Show alert + //alertMsg := "A Physician has entered a VTE override score since the last chart time." + // || "\n\nPlease re-assess the VTE Score based on the physician override score."; + alertMsg := "A Physician has entered a VTE override score since the last charted VTE Risk Assessment." + || "\n\nPlease re-assess the VTE Risk Assessment based on the Physician override score."; + + dialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with alertMsg, "Physician VTE Override Score Alert", "OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}, "Exclamation" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + endif; + endif; + endif; + + //IF user selected PHYSICIAN OVERRIDE observation, automatically load selections + elseif ( event_type = CHARTOBSERVATION ) then + + //Only check for existing override values IF a physician override exists + param := first of ( this_parameters WHERE this_parameters.Name = fireOnParam ); + + if ( exists param ) then + paramObs := first of ( this_chartedObservationsList WHERE this_chartedObservationsList.ParameterGUID = param.ParameterGUID ); + paramVal := last of ( paramObs.ValueObj.ListItemsList.Value WHERE paramObs.ValueObj.ListItemsList.IsSelected = true); + + if ( paramVal <> "" ) then + if ( overrideValue <> "" ) then + //Parse override values + (physOverrideValues) := call string_parse WITH overrideValue, "|"; + + //Retrieve AGE observation + vteAge := first of ( this_parameters WHERE this_parameters.Name = "AS SC vte age"); + if ( exists vteAge ) then + ageListValues := vteAge.ConfigurationObj.ListItemsList.Value; + + checkAgeValues := (); + if ( NOT allZeroOverrides ) then + for i in 1 seqto ( count ageListValues ) do + trimAgeValues := TRIM( SUBSTRING (( LENGTH(ageListValues[i]) - 2 ) - 1) CHARACTERS STARTING AT 1 FROM ageListValues[i] ); + if ( trimAgeValues IN physOverrideValues ) then + checkAgeValues := (checkAgeValues, ageListValues[i]); + endif; + enddo; + endif; + + this_AGEObj := NEW ObservationType; + this_AGEObj.ClientDocumentGUID := this_fs_doc.ClientDocumentGUID; + this_AGEObj.ParameterGUID := vteAge.ParameterGUID; + this_AGEObj.DataType := "ListValue"; + this_AGEObj.ValueObj := NEW ListValueType; + this_AGEObj.ValueObj.ListGUID := vteAge.ConfigurationObj.ListGUID; + + listItems := (); + + for item IN vteAge.ConfigurationObj.ListItemsList do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if ( count checkAgeValues = 0 ) then + if ( selectedItem.Value matches pattern "%(0)%" ) then + selectedItem.IsSelected := true; + else + selectedItem.IsSelected := false; + endif; + elseif ( selectedItem.Value IN checkAgeValues ) then + selectedItem.IsSelected := true; + else + selectedItem.IsSelected := false; + endif; + + listItems := (listItems, selectedItem); + enddo; + + this_AGEObj.ValueObj.ListItemsList := listItems; + this_fs_doc.CurrentColumn.ChartedObservationsList := ( this_fs_doc.CurrentColumn.ChartedObservationsList, this_AGEObj); + endif; + + //Retrieve BMI observation + vteBMI := first of ( this_parameters WHERE this_parameters.Name = "AS SC vte bmi"); + if ( exists vteBMI ) then + bmiListValues := vteBMI.ConfigurationObj.ListItemsList.Value; + + checkBMIValues := (); + if ( NOT allZeroOverrides ) then + for i IN 1 seqto ( count bmiListValues ) do + trimBMIValues := Trim(SUBSTRING (( Length(bmiListValues[i]) - 2 ) - 1) CHARACTERS STARTING AT 1 FROM bmiListValues[i]); + + if ( trimBMIValues IN physOverrideValues ) then + checkBMIValues := ( checkBMIValues, bmiListValues[i] ); + endif; + enddo; + endif; + + this_BMIObj := NEW ObservationType; + this_BMIObj.ClientDocumentGUID := this_fs_doc.ClientDocumentGUID; + this_BMIObj.ParameterGUID := vteBMI.ParameterGUID; + this_BMIObj.DataType := "ListValue"; + this_BMIObj.ValueObj := NEW ListValueType; + this_BMIObj.ValueObj.ListGUID := vteBMI.ConfigurationObj.ListGUID; + + listItems := (); + + for item IN vteBMI.ConfigurationObj.ListItemsList do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if ( count checkBMIValues = 0 ) then + if ( selectedItem.Value matches pattern "%(0)%" ) then + selectedItem.IsSelected := true; + else + selectedItem.IsSelected := false; + endif; + elseif ( selectedItem.Value IN checkBMIValues ) then + selectedItem.IsSelected := true; + else + selectedItem.IsSelected := false; + endif; + + listItems := (listItems, selectedItem); + enddo; + + this_BMIObj.ValueObj.ListItemsList := listItems; + this_fs_doc.CurrentColumn.ChartedObservationsList := ( this_fs_doc.CurrentColumn.ChartedObservationsList, this_BMIObj); + endif; + + //Retrieve HISTORY observation + vteHistory := first of ( this_parameters WHERE this_parameters.Name = "AS SC vte history"); + if ( exists vteHistory ) then + + historyValues := vteHistory.ConfigurationObj.ListItemsList.Value; + + checkHistoryValues := (); + if ( NOT allZeroOverrides ) then + for j in 1 seqto ( count historyValues ) do + trimHistoryValues := TRIM( SUBSTRING (( LENGTH(historyValues[j]) - 2 ) - 1 ) CHARACTERS STARTING AT 1 FROM historyValues[j] ); + if ( trimHistoryValues IN physOverrideValues ) then + checkHistoryValues := (checkHistoryValues, historyValues[j]); + endif; + enddo; + endif; + + this_HISTObj := NEW ObservationType; + this_HISTObj.ClientDocumentGUID := this_fs_doc.ClientDocumentGUID; + this_HISTObj.ParameterGUID := vteHistory.ParameterGUID; + this_HISTObj.DataType := "ListValue"; + this_HISTObj.ValueObj := NEW ListValueType; + this_HISTObj.ValueObj.ListGUID := vteHistory.ConfigurationObj.ListGUID; + listItems := (); + + for item IN vteHistory.ConfigurationObj.ListItemsList do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if ( count checkHistoryValues = 0 ) then + if ( selectedItem.Value matches pattern "%(0)%" ) then + selectedItem.IsSelected := true; + else + selectedItem.IsSelected := false; + endif; + elseif ( selectedItem.Value IN checkHistoryValues ) then + selectedItem.IsSelected := true; + else + selectedItem.IsSelected := false; + endif; + + listItems := (listItems, selectedItem); + enddo; + + this_HISTObj.ValueObj.ListItemsList := listItems; + this_fs_doc.CurrentColumn.ChartedObservationsList := ( this_fs_doc.CurrentColumn.ChartedObservationsList, this_HISTObj); + + endif; + + //Retrieve CURRENT STATUS observation + vteCurrStatus := first of ( this_parameters WHERE this_parameters.Name = "AS SC vte current status"); + if ( exists vteCurrStatus ) then + + currStatusValues := vteCurrStatus.ConfigurationObj.ListItemsList.Value; + + checkStatusValues := (); + if ( NOT allZeroOverrides ) then + for k IN 1 seqto ( count currStatusValues ) do + trimCurrStatusValues := TRIM( SUBSTRING (( LENGTH(currStatusValues[k]) - 2 ) - 1 ) CHARACTERS STARTING AT 1 FROM currStatusValues[k] ); + + if ( trimCurrStatusValues IN physOverrideValues ) then + checkStatusValues := ( checkStatusValues, currStatusValues[k] ); + endif; + enddo; + endif; + + this_CURRSTATObj := NEW ObservationType; + this_CURRSTATObj.ClientDocumentGUID := this_fs_doc.ClientDocumentGUID; + this_CURRSTATObj.ParameterGUID := vteCurrStatus.ParameterGUID; + this_CURRSTATObj.DataType := "ListValue"; + this_CURRSTATObj.ValueObj := NEW ListValueType; + this_CURRSTATObj.ValueObj.ListGUID := vteCurrStatus.ConfigurationObj.ListGUID; + listItems := (); + + for item IN vteCurrStatus.ConfigurationObj.ListItemsList do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if ( count checkStatusValues = 0 ) then + if ( selectedItem.Value matches pattern "%(0)%" ) then + selectedItem.IsSelected := true; + else + selectedItem.IsSelected := false; + endif; + elseif ( selectedItem.Value IN checkStatusValues ) then + selectedItem.IsSelected := true; + else + selectedItem.IsSelected := false; + endif; + + listItems := (listItems, selectedItem); + enddo; + + this_CURRSTATObj.ValueObj.ListItemsList := listItems; + this_fs_doc.CurrentColumn.ChartedObservationsList := (this_fs_doc.CurrentColumn.ChartedObservationsList, this_CURRSTATObj); + endif; + + //Retrieve CURRENT LABS observations + vteCurrLabs := first of ( this_parameters WHERE this_parameters.Name = "AS SC vte current labs"); + if ( exists vteCurrLabs ) then + currLabsValues := vteCurrLabs.ConfigurationObj.ListItemsList.Value; + + checkLabValues := (); + if ( NOT allZeroOverrides ) then + for l IN 1 seqto ( count currLabsValues ) do + trimCurrLabsValues := TRIM( SUBSTRING (( LENGTH(currLabsValues[l]) - 2 ) - 1 ) CHARACTERS STARTING AT 1 FROM currLabsValues[l] ); + + if ( trimCurrLabsValues IN physOverrideValues ) then + checkLabValues := ( checkLabValues, currLabsValues[l] ); + endif; + enddo; + endif; + + this_CURRLABObj := NEW ObservationType; + this_CURRLABObj.ClientDocumentGUID := this_fs_doc.ClientDocumentGUID; + this_CURRLABObj.ParameterGUID := vteCurrLabs.ParameterGUID; + this_CURRLABObj.DataType := "ListValue"; + this_CURRLABObj.ValueObj := NEW ListValueType; + this_CURRLABObj.ValueObj.ListGUID := vteCurrLabs.ConfigurationObj.ListGUID; + + listItems := (); + + for item IN vteCurrLabs.ConfigurationObj.ListItemsList do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if ( count checkLabValues = 0 ) then + if ( selectedItem.Value matches pattern "%(0)%" ) then + selectedItem.IsSelected := true; + else + selectedItem.IsSelected := false; + endif; + elseif ( selectedItem.Value IN checkLabValues ) then + selectedItem.IsSelected := true; + else + selectedItem.IsSelected := false; + endif; + + listItems := ( listItems, selectedItem); + enddo; + + this_CURRLABObj.ValueObj.ListItemsList := listItems; + this_fs_doc.CurrentColumn.ChartedObservationsList := ( this_fs_doc.CurrentColumn.ChartedObservationsList, this_CURRLABObj); + endif; + + //Retrieve WOMEN ONLY observation + vteWomenOnly := first of ( this_parameters WHERE this_parameters.Name = "AS SC vte women only"); + if ( exists vteWomenOnly ) then + womenOnlyValues := vteWomenOnly.ConfigurationObj.ListItemsList.Value; + + checkWomenValues := (); + if ( NOT allZeroOverrides ) then + for j IN 1 seqto ( count womenOnlyValues ) do + trimWOValues := Trim( SUBSTRING (( LENGTH(womenOnlyValues[j]) - 2 ) - 1 ) CHARACTERS STARTING AT 1 FROM womenOnlyValues[j] ); + + if ( trimWOValues IN physOverrideValues ) then + checkWomenValues := ( checkWomenValues, womenOnlyValues[j] ); + endif; + enddo; + endif; + + this_WOObj := NEW ObservationType; + this_WOObj.ClientDocumentGUID := this_fs_doc.ClientDocumentGUID; + this_WOObj.ParameterGUID := vteWomenOnly.ParameterGUID; + this_WOObj.DataType := "ListValue"; + this_WOObj.ValueObj := NEW ListValueType; + this_WOObj.ValueObj.ListGUID := vteWomenOnly.ConfigurationObj.ListGUID; + listItems := (); + + for item IN vteWomenOnly.ConfigurationObj.ListItemsList do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if ( count checkWomenValues = 0 ) then + if ( selectedItem.Value matches pattern "%(0)%" ) then + selectedItem.IsSelected := true; + else + selectedItem.IsSelected := false; + endif; + elseif ( selectedItem.Value IN checkWomenValues ) then + selectedItem.IsSelected := true; + else + selectedItem.IsSelected := false; + endif; + + listItems := (listItems, selectedItem); + enddo; + + this_WOObj.ValueObj.ListItemsList := listItems; + this_fs_doc.CurrentColumn.ChartedObservationsList := (this_fs_doc.CurrentColumn.ChartedObservationsList, this_WOObj); + endif; //If exists WomenOnlyParam + + //******************* LOW RISK *************************** + if ( NOT allZeroOverrides ) then + vteScoreParam := first of ( this_parameters WHERE this_parameters.Name = "AS SC vte score CAL" ); + if ( exists vteScoreParam ) then + vteScoreObs := first of ( this_chartedObservationsList WHERE this_chartedObservationsList.ParameterGUID = vteScoreParam.ParameterGUID ); + vteScoreVal := vteScoreObs.ValueObj.Value as number; + endif; + else + vteScoreVal := 0 as number; + endif; + + + lowRiskParam := first of ( this_parameters WHERE this_parameters.Name = "AS SC vte low risk" ); + + if ( exists lowRiskParam ) then + lowRiskScoreObs := first of ( this_chartedObservationsList WHERE this_chartedObservationsList.ParameterGUID = lowRiskParam.ParameterGUID ); + + this_lowRiskObj := NEW ObservationType; + this_lowRiskObj.ClientDocumentGUID := this_fs_doc.ClientDocumentGUID; + this_lowRiskObj.ParameterGUID := lowRiskParam.ParameterGUID; + this_lowRiskObj.DataType := "ListValue"; + this_lowRiskObj.ValueObj := NEW ListValueType; + this_lowRiskObj.ValueObj.ListGUID := lowRiskParam.ConfigurationObj.ListGUID; + + listItems := (); + + for item IN lowRiskParam.ConfigurationObj.ListItemsList do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if ( vteScoreVal < 3 ) then + selectedItem.IsSelected := true; + else + selectedItem.IsSelected := false; + endif; + + listItems := (listItems, selectedItem); + enddo; + + this_lowRiskObj.ValueObj.ListItemsList := listItems; + this_fs_doc.CurrentColumn.ChartedObservationsList := (this_fs_doc.CurrentColumn.ChartedObservationsList, this_lowRiskObj); + endif; + + else + + //Do nothing, tell user no override exists + alertMsg := "No physician vte override score exists."; + dialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with alertMsg, "Physician VTE Override Score Alert", "OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}, "Exclamation" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + this_PhysOverrideObj := NEW ObservationType; + this_PhysOverrideObj.ClientDocumentGUID := this_fs_doc.ClientDocumentGUID; + this_PhysOverrideObj.ParameterGUID := param.ParameterGUID; + this_PhysOverrideObj.DataType := "ListValue"; + this_PhysOverrideObj.ValueObj := NEW ListValueType; + this_PhysOverrideObj.ValueObj.ListGUID := param.ConfigurationObj.ListGUID; + + listItems := (); + + for item IN param.ConfigurationObj.ListItemsList do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + selectedItem.IsSelected := false; + + listItems := (listItems, selectedItem); + enddo; + + this_PhysOverrideObj.ValueObj.ListItemsList := listItems; + this_fs_doc.CurrentColumn.ChartedObservationsList := ( this_fs_doc.CurrentColumn.ChartedObservationsList, this_PhysOverrideObj); + endif; //Override values exist + else + //******************* LOW RISK *************************** + vteScoreParam := first of ( this_parameters WHERE this_parameters.Name = "AS SC vte score CAL" ); + if ( exists vteScoreParam ) then + vteScoreObs := first of ( this_chartedObservationsList WHERE this_chartedObservationsList.ParameterGUID = vteScoreParam.ParameterGUID ); + vteScoreVal := vteScoreObs.ValueObj.Value as number; + endif; + + lowRiskParam := first of ( this_parameters WHERE this_parameters.Name = "AS SC vte low risk" ); + + if ( exists lowRiskParam ) then + lowRiskScoreObs := first of ( this_chartedObservationsList WHERE this_chartedObservationsList.ParameterGUID = lowRiskParam.ParameterGUID ); + + this_lowRiskObj := NEW ObservationType; + this_lowRiskObj.ClientDocumentGUID := this_fs_doc.ClientDocumentGUID; + this_lowRiskObj.ParameterGUID := lowRiskParam.ParameterGUID; + this_lowRiskObj.DataType := "ListValue"; + this_lowRiskObj.ValueObj := NEW ListValueType; + this_lowRiskObj.ValueObj.ListGUID := lowRiskParam.ConfigurationObj.ListGUID; + + listItems := (); + + for item IN lowRiskParam.ConfigurationObj.ListItemsList do + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + if ( vteScoreVal < 3 ) then + selectedItem.IsSelected := true; + else + selectedItem.IsSelected := false; + endif; + + listItems := (listItems, selectedItem); + enddo; + + this_lowRiskObj.ValueObj.ListItemsList := listItems; + this_fs_doc.CurrentColumn.ChartedObservationsList := (this_fs_doc.CurrentColumn.ChartedObservationsList, this_lowRiskObj); + endif; + endif; //Physician Override Value + endif; //If exists Physician Override Param + endif; //Event Type + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_IANDO_FS_CRRT.mlm b/MLMStripper/bin/Debug/DOC/DOC_IANDO_FS_CRRT.mlm new file mode 100644 index 0000000..9aeeb8c --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_IANDO_FS_CRRT.mlm @@ -0,0 +1,464 @@ +maintenance: + + title: DOC_IANDO_FS_CRRT;; + mlmname: DOC_IANDO_FS_CRRT;; + arden: version 2.5;; + version: 1.02;; //Release 5.5 SP1/FP1 and 6.0/6.1 SU2 and higher + institution: St. Clair, Allscrtips;; + author: Shawn Head;; + specialist: Janet Nordin;; + date: 2016-09-22;; + validation: testing;; + +library: + purpose: + + This MLM will automatically update an OUTPUT observation for Fluid Removal - Hemodialysis/CRRT from the "copied forward" or "shared" obsevation from the CRRT flowsheet. + This MLM will also be used on the CRRT flowsheet to complete the 3 way calculation (A - B - C) that SCM cannot handle as it was throwing unhandled exception errors crashing SCM. + ;; + explanation: + + Modification history: + + 09.22.2016 - STH CSR#: 34876 - created + 05.30.2018 - STH Ticket#: 3250761 - Issue identified where Cumulative UF was not populating on first column entry, and also the Total Net Patient Fluid removal was only calculating on first entry. Any modificatoin was not + updating if a value was changed in A, B or C. {Go-Live 5/30/2018} + 06.01.2018 - STH Ticket#: 3250761 - Additional issue found with initial charting not populating the Cumulative UF with the Total Net Patient Fluid on first charting {Go-Live 6-4-2018} + ;; +keywords: Objects Plus, CRRT, RENAL, Hemodialysis, Fluid Removal, I&O Flowsheet update. + ;; +knowledge: + type: data-driven;; + data: + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + this_DocCommObj := argument; + + + ////////////////////////////////////////////////////////////////////////// + // **** START OF USER CONFIGURED CONSTANTS ****// + // Set to true if calculation should be restricted to the current hour + CALC_THIS_HOUR_ONLY := TRUE; + + // The maximum number of hours, from the current column, to look back for + // the charted rate value + MAX_HRS_TO_CHK_RATE := 9; + + //docnames := "({{{SINGLE-QUOTE}}}2. Intake and Output{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_Continuous Renal Replacement Therapy_Version{{{SINGLE-QUOTE}}})"; + + HOURLY_Input_A := "SCH_CRRT_Total hourly input A"; + HOURLY_Output_B := "SCH_CRRT_Total hourly output B"; + CRRT_Ultfilter_C := "SCH_CRRT_Ultrafiltrate Volume C"; + OUTPUT_Dialysis := "SCH_IO_FluidRemoval_Dialysis"; + TOTAL_Net_Fluid_Removal := "SCH_CRRT_Net Patient Fluid Removal_NU"; + CRRT_CU := "SCH_CRRT_Cumulative Ultrafiltration"; + // **** END OF USER CONFIGURED CONSTANTS ****// + ////////////////////////////////////////////////////////////////////////// + + /************************************************************************/ + //*** Variable and Constant Declaration ***// + // + log_execution_info := FALSE; + stop_at_break := FALSE; + + // Document Types + FLOWSHEET := "Flowsheet"; + STRUCTUREDNOTE := "StructuredNote"; + + // Event Types + DOCUMENTOPENING := "DocumentOpening"; + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTCLOSING := "DocumentClosing"; + + // Parameter Types + NUMERICVALUE := "NumericValue"; + FREETEXTVALUE := "FreeTextValue"; + LISTVALUE := "ListValue"; + LISTSETVALUE := "ListSetValue"; + DATEVALUE := "DateValue"; + IOVALUE := "IOValue" ; + GENERICDRIPVALUE := "GenericDripValue" ; + DRIPVALUE := "DripValue" ; + + // set cancelProcessing to TRUE to discard the charted observation + cancelProcessing := FALSE; + + // set debugFlag to TRUE to display a popup dialog with debug information + debugFlag := FALSE; + + //*** Data Structures ***// + // Definitions for subset of data structures that can be used to create + // new objects within the MLM. + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj]; + + DateValueType := OBJECT [Value]; + + FreeTextValueType := OBJECT [Value]; + + ListValueType := OBJECT [ListGUID, ListItemsList, SuggestedTextValue]; + + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + NumericValueType := OBJECT [Value]; + + IOValueType := OBJECT [InValue, OutValue, DayRunningValue, BagNumber, + BagInitialVolume]; + + GenericDripValueType := OBJECT [DoseValue, RateValue]; + DripValueType := OBJECT [Value, BagNumber, BagInitialVolume]; + ListSetValueType := OBJECT [ListValuesList]; + + CumulativeUF_value := (); + CumulativeUF_colDTTM := (); + + // The following variables capture DocumentCommunication object model + // references at the time the mlm is called. + this_ClientGUID := this_DocCommObj.ClientGUID; + this_ChartGUID := this_DocCommObj.ChartGUID; + this_ClientVisitGUID := this_DocCommObj.ClientVisitGUID; + this_ConfigurationGUID := this_DocCommObj.ConfigurationGUID; + + this_currentObs := this_DocCommObj.CurrentObservationObj; + this_Doc := this_DocCommObj.DocumentConfigurationObj; + + this_DocumentType := this_DocCommObj.DocumentType; + this_EventType := this_DocCommObj.EventType; + + IF this_DocumentType = FLOWSHEET THEN + this_fs_colsList := this_Doc.ColumnsList; + this_currentColumn := this_Doc.CurrentColumn; + this_chartedObsList := this_currentColumn.ChartedObservationsList; + ELSEIF this_DocumentType = STRUCTUREDNOTE THEN + this_chartedObsList := this_Doc.ChartedObservationsList; + ENDIF; + this_paramList := this_Doc.ParametersList; + + IF NOT EXISTS this_Doc OR NOT this_Doc.IsIOFlowsheet THEN + errorMessage := errorMessageHeader + || "This MLM can only be used by an I&O Flowsheet."; + ENDIF; + + FirstColDTTM := first(this_fs_colsList.DateTime where this_fs_colsList.Type = "Observation"); + lastColDTTM := last(this_fs_colsList.DateTime where this_fs_colsList.Type = "Observation"); + + OUT_Drainage_Hemo_param := LAST (this_paramList WHERE + this_paramList.Name = OUTPUT_Dialysis);//"SCH_IO_FluidRemoval_Dialysis"); + //BEGIN WORKING SECTION TO ADD OUTPUT AUTOMATICALLY + Input_A_Param := last (this_paramList WHERE + this_paramList.Name = HOURLY_Input_A); + Output_B_Param := last (this_paramList WHERE + this_paramList.Name = HOURLY_Output_B); + OTHER_CRRT_Param := last (this_paramList WHERE + this_paramList.Name = CRRT_Ultfilter_C);//"SCH_CRRT_Cumulative Ultrafiltration"); + Total_NFR_Param := last (this_paramList WHERE + this_paramList.Name = TOTAL_Net_Fluid_Removal); + Cumulative_UF_Param := last (this_paramList WHERE + this_paramList.Name = CRRT_CU); + + if(((this_DocCommObj.EventType = "ChartObservation") and (true)) + or (this_DocCommObj.EventType = "AutoEnter")) then + + for j in 1 seqto (count this_fs_colsList) do + (this_obs) := this_fs_colsList[j].chartedobservationslist; + valobj := null; + Colobj := null; + if(Cumulative_UF_Param.ParameterGUID in (this_obs.ParameterGUID)) then + valobj := last of (this_obs.ValueObj where this_obs.ParameterGUID = Cumulative_UF_Param.ParameterGUID); + Colobj := this_fs_colsList[j]; + if(count(CumulativeUF_value) = 0) then + CumulativeUF_value := (valobj.Value); + else + CumulativeUF_value := (CumulativeUF_value, valobj.Value); + endif; + if(count(CumulativeUF_colDTTM) = 0) then + CumulativeUF_colDTTM := (Colobj.DateTime); + else + CumulativeUF_colDTTM := (CumulativeUF_colDTTM,Colobj.DateTime ); + endif; + endif; + enddo; + + (group,Charted_Value, Charted_Column_DTTM) := read { " select + guid + ,name + into #tmp_obsitems + from CV3ObsCatalogMasterItem with (nolock) + where name = " || sql(CRRT_Ultfilter_C) || " + or name = " || sql(OUTPUT_Dialysis) || " + or name = " || sql(CRRT_CU) || " + select * + INTO #TMP_CD + FROM CV3ClientDocument CD WITH (NOLOCK) + WHERE CLIENTGUID = " || SQL(this_ClientGUID) || " + AND CHARTGUID = " || SQL(this_ChartGUID) || " + AND CLIENTVISITGUID = " || SQL(this_ClientVisitGUID) || " + AND DOCUMENTNAME = " || SQL(this_DocCommObj.DocumentName) || " + and AuthoredDtm >= " || SQL(FirstColDTTM) || " + and AuthoredDtm <= " || SQL(lastColDTTM) || " + + select + case when obsx.OutValue is not null + then obsx.OutValue + else o.ValueText + end as {{{SINGLE-QUOTE}}}value{{{SINGLE-QUOTE}}} + ,cd.AuthoredDtm + ,cd.guid as {{{SINGLE-QUOTE}}}cd_guid{{{SINGLE-QUOTE}}} + ,ocmi2.guid as {{{SINGLE-QUOTE}}}ocmi_guid{{{SINGLE-QUOTE}}} + ,ocmi2.Name + into #tmp_results + from #TMP_CD cd with (nolock) + inner join CV3ClientDocDetail cdd with (nolock) + ON (cdd.ClientDocumentGUID = cd.GUID + AND cdd.ClientGUID = cd.clientguid + and cdd.active = 1) + inner join CV3ObservationDocument od with (nolock) + ON cdd.CLientDocumentGUID = od.OwnerGUID + and od.active = 1 + inner join CV3Observation o with (nolock) + ON o.GUID = od.ObservationGUID + inner join #tmp_obsitems ocmi2 with (nolock) + on od.ObsMasterItemGUID = ocmi2.GUID + and ocmi2.name in({{{SINGLE-QUOTE}}}" || OUTPUT_Dialysis || "{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}" || CRRT_Ultfilter_C || "{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}" || CRRT_CU || "{{{SINGLE-QUOTE}}}) + left Join CV3ObservationXInfo AS obsx + ON (obsx.ObservationXInfoGUID = o.GUID + AND obsx.ArcType = o.ArcType + And obsx.BagVolumeUnit is Not Null ) + + + select {{{SINGLE-QUOTE}}}CRRT_UFV_C{{{SINGLE-QUOTE}}}, r1.value, r1.AuthoredDtm + from #tmp_results r1 with (nolock) + left join #tmp_results r2 with (nolock) + on r1.cd_guid = r2.cd_guid + and r1.ocmi_guid <> r2.ocmi_guid + and r2.name = " || sql(OUTPUT_Dialysis) || " + where r1.name = " || sql(CRRT_Ultfilter_C) || " + and ((r2.ocmi_guid is null) + or cast(r1.AuthoredDtm as varchar) <> cast(r2.AuthoredDtm as varchar) + or (r1.value <> r2.value)) + or + (r2.Name = {{{SINGLE-QUOTE}}}SCH_IO_FluidRemoval_Dialysis{{{SINGLE-QUOTE}}} and r2.value is not null and r1.value is null) + UNION + + SELECT distinct {{{SINGLE-QUOTE}}}Cummulative_CRRT{{{SINGLE-QUOTE}}}, value, authoredDtm + from #tmp_results + where name = " || sql(CRRT_CU) || " + + DROP TABLE #TMP_CD, #tmp_obsitems, #tmp_results "}; + + Charted_CRRT_Value := (); + Charted_CRRT_Column_DTTM := (); + for s in (1 seqto(count(group))) do + if group[s] = "Cummulative_CRRT" then + if(count(CumulativeUF_value) = 0) then + CumulativeUF_value := Charted_Value[s]; + CumulativeUF_colDTTM := Charted_Column_DTTM[s]; + else + CumulativeUF_value := (CumulativeUF_value, Charted_Value[s]); + CumulativeUF_colDTTM := (CumulativeUF_colDTTM, Charted_Column_DTTM[s]); + endif; + + elseif group[s] = "CRRT_UFV_C" then + if(count(Charted_CRRT_Value) = 0) then + Charted_CRRT_Value := Charted_Value[s]; + Charted_CRRT_Column_DTTM := Charted_Column_DTTM[s]; + else + Charted_CRRT_Value := (Charted_CRRT_Value, Charted_Value[s]); + Charted_CRRT_Column_DTTM := (Charted_CRRT_Column_DTTM, Charted_Column_DTTM[s]); + endif; + endif; + enddo; + endif; + + if(this_DocCommObj.EventType = "ChartObservation") then + + Input_A_Obs := last of (this_chartedObsList WHERE this_chartedObsList.ParameterGUID = Input_A_Param.ParameterGUID); + + Output_B_Obs := last of (this_chartedObsList WHERE this_chartedObsList.ParameterGUID = Output_B_Param.ParameterGUID); + + CRRT_Vol_C_Obs := last of (this_chartedObsList WHERE this_chartedObsList.ParameterGUID = OTHER_CRRT_Param.ParameterGUID); + + OUT_Drain_Hemo_Obs := last of (this_chartedObsList WHERE this_chartedObsList.ParameterGUID = OUT_Drainage_Hemo_param.ParameterGUID); + + Total_NFR_Obs := last of (this_chartedObsList WHERE this_chartedObsList.ParameterGUID = Total_NFR_Param.ParameterGUID); + + Cumulative_UF_Obs := last of (this_chartedObsList WHERE this_chartedObsList.ParameterGUID = Cumulative_UF_Param.ParameterGUID); + + crrt_Value := CRRT_Vol_C_Obs.ValueObj.Value; + Hemo_Value := OUT_Drain_Hemo_Obs.ValueObj.OutValue; + Total_NFR_Value := Total_NFR_Obs.ValueObj.Value; + Input_A_Value := Input_A_Obs.ValueObj.Value; + Output_B_Value := Output_B_Obs.ValueObj.Value; + + if(Input_A_Value is not null and Output_B_Value is not null and crrt_Value is not null) then + IF NOT EXISTS Total_NFR_Obs THEN + Total_NFR_Obs := NEW ObservationType; + Total_NFR_Obs.ClientDocumentGUID := + this_currentColumn.ClientDocumentGUID; + Total_NFR_Obs.ParameterGUID := Total_NFR_Param.ParameterGUID; + Total_NFR_Obs.DataType := Total_NFR_Param.DataType; + Total_NFR_Obs.ValueObj := NEW NumericValueType; + + ENDIF; + + Total_NFR_Calc_Val := ((Input_A_Value as number) - (Output_B_Value as number) - (crrt_Value as number)); + + IF Total_NFR_Calc_Val is not null THEN + Total_NFR_Obs.ValueObj.Value := Total_NFR_Calc_Val; + + else + Total_NFR_Obs.ValueObj := null; + void := Total_NFR_Obs.ValueObj.dispose; + Total_NFR_Obs := null; + void := Total_NFR_Obs.dispose; + ENDIF; + endif; + + if(count(CumulativeUF_value) = 0) then + AutoChart_CumulativeUF := Total_NFR_Calc_Val;//0; + else + tempDTTM := ""; + finalDTTM := FirstColDTTM; + finalValue := ""; + for r in (1 seqto(count(CumulativeUF_value))) do + tempDTTM := CumulativeUF_colDTTM[r]; + if(tempDTTM < This_currentColumn.DateTime and tempDTTM >= FinalDTTM) then + finalDTTM := tempDTTM; + finalValue := CumulativeUF_value[r]; + endif; + enddo; + if((finalValue = 0) or (finalValue = "") or (finalValue is null)) then + AutoChart_CumulativeUF := Total_NFR_Calc_Val; + else + AutoChart_CumulativeUF := finalValue + Total_NFR_Calc_Val; + endif; + endif; + + IF NOT EXISTS Cumulative_UF_Obs THEN + Cumulative_UF_Obs := NEW ObservationType; + Cumulative_UF_Obs.ClientDocumentGUID := + this_currentColumn.ClientDocumentGUID; + Cumulative_UF_Obs.ParameterGUID := Cumulative_UF_Param.ParameterGUID; + Cumulative_UF_Obs.DataType := Cumulative_UF_Param.DataType; + Cumulative_UF_Obs.ValueObj := NEW NumericValueType; + + + ENDIF; + + IF AutoChart_CumulativeUF is not null THEN + Cumulative_UF_Obs.ValueObj.Value := AutoChart_CumulativeUF; + else + Cumulative_UF_Obs.ValueObj := null; + void := Cumulative_UF_Obs.ValueObj.dispose; + Cumulative_UF_Obs := null; + void := Cumulative_UF_Obs.dispose; + ENDIF; + + this_currentColumn.ChartedObservationsList := + (this_currentColumn.ChartedObservationsList, Total_NFR_Obs, Cumulative_UF_Obs); + + + if(this_DocCommObj.DocumentName matches pattern "%Intake and Output%") then + volumeFormat := "%" || 4 || "." || 0 || "f"; + abc123 := ((crrt_Value as number) <> (Hemo_Value as number)); + if((Hemo_Value is null) or ((crrt_Value as number) <> (Hemo_Value as number))) then + addoutput := true; + else + addoutput := false; + endif; + + if((((crrt_Value as number) >= 0) or ((crrt_Value as number) <= 0)) and (addoutput)) then + IF NOT EXISTS OUT_Drain_Hemo_Obs THEN + OUT_Drain_Hemo_Obs := NEW ObservationType; + OUT_Drain_Hemo_Obs.ClientDocumentGUID := + this_currentColumn.ClientDocumentGUID; + OUT_Drain_Hemo_Obs.ParameterGUID := OUT_Drainage_Hemo_param.ParameterGUID; + OUT_Drain_Hemo_Obs.DataType := OUT_Drainage_Hemo_param.DataType; + OUT_Drain_Hemo_Obs.ValueObj := NEW IOValueType; + + ENDIF; + + new_calcdVol := (crrt_Value as number); + + IF ((new_calcdVol >= 0) or (new_calcdVol <= 0)) THEN + OUT_Drain_Hemo_Obs.ValueObj.OutValue := new_calcdVol FORMATTED WITH volumeFormat; + else + OUT_Drain_Hemo_Obs.ValueObj := null; + void := OUT_Drain_Hemo_Obs.ValueObj.dispose; + OUT_Drain_Hemo_Obs := null; + void := OUT_Drain_Hemo_Obs.dispose; + ENDIF; + this_currentColumn.ChartedObservationsList := + (this_currentColumn.ChartedObservationsList, OUT_Drain_Hemo_Obs); + endif; + endif; + endif; + + if(this_DocCommObj.EventType = "AutoEnter") then + + if(count(Charted_CRRT_Value)>0) then + num_cols := COUNT this_fs_colsList; + FOR c IN (1 SEQTO num_cols) DO + this_col := this_fs_colsList[c]; + prev_col := this_fs_colsList[c-1]; + + if(this_col.DateTime in Charted_CRRT_Column_DTTM) then + for x in (1 seqto(count(Charted_CRRT_Column_DTTM))) do + + if(Charted_CRRT_Column_DTTM[x] = this_col.DateTime) then + volumeObservation := first of (this_col.ChartedObservationsList WHERE this_col.ChartedObservationsList.ParameterGUID = OTHER_CRRT_Param.ParameterGUID); + + volumeFormat := "%" || 4 || "." || 0 || "f"; + + IF NOT EXISTS volumeObservation THEN + volumeObservation := NEW ObservationType; + volumeObservation.ClientDocumentGUID := + this_col.ClientDocumentGUID; + volumeObservation.ParameterGUID := OUT_Drainage_Hemo_param.ParameterGUID; + volumeObservation.DataType := OUT_Drainage_Hemo_param.DataType; + volumeObservation.ValueObj := NEW IOValueType; + + ENDIF; + + new_calcdVol := (Charted_CRRT_Value[x] as number); + testcalcval := (new_calcdVol as number); + IF ((new_calcdVol >= 0) or (new_calcVol <= 0)) THEN + volumeObservation.ValueObj.OutValue := new_calcdVol FORMATTED WITH volumeFormat; + else + volumeObservation.ValueObj := null; + void := volumeObservation.ValueObj.dispose; + volumeObservation := null; + void := volumeObservation.dispose; + ENDIF; + + this_col.ChartedObservationsList := + (this_fs_colsList[c].ChartedObservationsList, volumeObservation); + + endif; + enddo; + + endif; + + enddo; + ENDIF; + endif; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: + return this_DocCommObj; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_LAUNCH_PDMP_SEARCH.mlm b/MLMStripper/bin/Debug/DOC/DOC_LAUNCH_PDMP_SEARCH.mlm new file mode 100644 index 0000000..0315873 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_LAUNCH_PDMP_SEARCH.mlm @@ -0,0 +1,434 @@ +maintenance: + + title: Doc_Launch_PDMP_Search;; + filename: Doc_Launch_PDMP_Search;; + arden: version 2;; + version: 1.00;; + institution: St. Clair Hospital;; + author: Peggy Karish;; + specialist: Don Warnick;; + date: 2015-03-04;; + validation: testing;; + +library: + purpose: This mlm launches the PDMP Search Objects+ custom application from a document + ;; + explanation: The PDMP Search Objects+ custom application was designed to make searching the Pennsylvania Department of Health Drug Monitoring Program website easier. This MLM will also document + in the Structured Note that the doctor has searched the site. + + Change history + + 04.27.2017 DW CSR# 35436 - PDMP Improvements - Created + 09.28.2018 DW CSR# 36715 Created - PDMP in order session + + + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + + (this_documentCommunication) := argument; + + log_execution_info := FALSE; + str_parse := mlm {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + problemlist := " "; + launchtheapp:= "yes"; + + (thisStructuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + launchtheapp:= "no"; + + + client_visit_guid := this_documentCommunication.clientvisitguid; + client_guid := this_documentCommunication.clientguid; + chart_guid := this_documentCommunication.chartguid; + user_guid := this_documentCommunication.UserGUID; + + user_name := read last {"SELECT + case when middlename is not null then firstname + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + middlename + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + lastname + else firstname + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + lastname + end + FROM CV3User with (nolock) + WHERE GUID = " || Sql(user_guid)} + ; + + + SignificantEvent_dest:= destination { ObjectsPlus } with [ alert_type := "Warning", short_message := "Object created by MLM", priority := "low", scope := "General",rule_group := "Significant Event Object", + rule_number := 2010 ]; + + error_destination := destination { Alert } with [ alert_type := "Warning", short_message := "ObjectsPlus Error from MLM", priority := "low", scope := "chart", Rule_group := "ObjectsPlus Error from MLM", + Rule_number := 1001, Rule_subgroup := "", Send_with_order := "", Alert_dialog_settings := "", Display_alert := true ]; + + + selectedobservationname:= first of (thisparameters.Name where thisparameters.ParameterGUID = this_documentCommunication.CurrentObservationObj.parameterguid); + + + + // Document Open + + + IF this_documentCommunication.EventType = "DocumentOpening" + then + + + // Gather, format, and write the PDMP Search significant events for this visit to a text field + + + pastsearches := read {" select text from CV3ClientEventDeclaration with (nolock) " + || " where Description = {{{SINGLE-QUOTE}}}Checked{{{SINGLE-QUOTE}}} and clientvisitguid = " || client_visit_guid || " and chartguid = " || chart_guid || " and clientguid = " || client_guid || + " and status = {{{SINGLE-QUOTE}}}active{{{SINGLE-QUOTE}}} order by createdwhen desc " }; + + pastsearches_count := count(pastsearches) As Number; + + pastsearch_information:=""; + if pastsearches_count > 0 then + for k in (1 seqto (pastsearches_count )) do + if pastsearches[k] is not null then + pastsearch_information := pastsearch_information || pastsearches[k] || "\n" ; + if k <> pastsearches_count then // not the last in the list + pastsearch_information := pastsearch_information; + endif; + endif; + enddo; + endif; + + + writefield := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Drug MonitorSig Event FT"); + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := writefield.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := pastsearch_information; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); + + + endif; // Document Open + + + + // Chart Observation + +/* + + // A Comment was selected from the list + + + + IF this_documentCommunication.EventType = "ChartObservation" and selectedobservationname = "SCH_MDPN_No Flag List" + + then + + launchtheapp:= "no"; + + + // Concatenate the search date stamp and comments to a text field which will be made into a significant event + + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_Drug Monitor Checked FT"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + search_datestamp := theObservation.ValueObj.Value; + + if search_datestamp is null + then + search_datestamp := "Comment entered without search by " || user_name || " " || extract month now || "/" || extract day now || "/" || extract year now || " "; + + endif; + + + datestamp_and_comments:= search_datestamp; + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_No Flag List"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + + listItems := (); + FOR item IN theParameter.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = selectedItem.Value) + + then datestamp_and_comments := datestamp_and_comments || " " || selectedItem.Value; + endif; + + listItems := (listItems, selectedItem); + + ENDDO; + + writefield := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Drug Monitoring Comment FT"); + newObservation := NEW ObservationType; + newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + newObservation.ParameterGUID := writefield.ParameterGUID; + newObservation.DataType := "FreeTextValue"; + newObservation.ValueObj := NEW FreeTextValueType; + newObservation.ValueObj.Value := datestamp_and_comments; + thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); +*/ + +// ElseIf this_documentCommunication.EventType = "ChartObservation" and selectedobservationname = "SCH_MDPN_Launch PA Drug App" + + + + // The Launch button was selected + + + If this_documentCommunication.EventType = "ChartObservation" and selectedobservationname = "SCH_MDPN_Launch PA Drug App" + + + then + + launchtheapp:= "yes"; + + + // Launch the PDMP Search + + using "LaunchPDMP"; + test:= new net_object {{{SINGLE-QUOTE}}}LaunchPDMP.LaunchPDMPForm{{{SINGLE-QUOTE}}}; + + + + // Reset the launch button + + + theParameterx := first of (thisparameters where thisparameters.Name = "SCH_MDPN_Launch PA Drug App"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameterx.ParameterGUID); + + if this_documentCommunication.CurrentObservationObj.parameterguid = theParameterx.ParameterGUID then + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Launch PA Drug App"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + selectedItem.IsSelected := false; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; + + + + // Some other button was selected (shouldn{{{SINGLE-QUOTE}}}t happen) + + + else + + launchtheapp:= "no"; + + + endif; // ChartObservation + + + ;; + + evoke: // No evoke statement + ;; + + logic: + + + + // Gather Data from the text field that contains search date stamp and comments + + + theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_Drug Monitoring Comment FT"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); + pdmp_search_information := theObservation.ValueObj.Value; + + + + // Document Closing with search information + + + If this_documentCommunication.EventType = "DocumentClosing" and launchtheapp = "no" and pdmp_search_information is not null + + then + + + try + + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((client_visit_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + + endtry; + + catch Exception ex + + error_occurred := true; + error_message := "{{+R}}Retrieve client:{{-R}}\n" || ex.Message || "\n\n"; + if ex.InnerException is not null net_object then + error_message := error_message || "Inner Exception: " || ex.InnerException.Message || "\n\n"; + endif; + + endcatch; + + TimeOfEntry := now ; + + yr := extract year TimeOfEntry; + mn := extract month TimeOfEntry; + dd := extract day TimeOfEntry; + + PartialDate_obj := new net_object {{{SINGLE-QUOTE}}}PartialDate{{{SINGLE-QUOTE}}} with ( + yr as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, // Year + mn as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, // Month + dd as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}} ); // Day + + BBEventTypeCode := "PDMP"; + BBEventText := pdmp_search_information; + LeukRedEventText := "Checked"; + + + // Create Significant Event + + try + + SignificantEvent_obj := call {{{SINGLE-QUOTE}}}SignificantEvent{{{SINGLE-QUOTE}}}.CreateSignificantEvent + with + (client_visit_obj, //ClientVisit + BBEventTypeCode, //TypeCode + LeukRedEventText); //Event + + SignificantEvent_obj.Text := BBEventText; + SignificantEvent_obj.OnsetDate := PartialDate_obj; + SignificantEvent_dest.ObjectsPlus := SignificantEvent_obj; + + void := call SignificantEvent_obj.save; + + endtry; + + catch exception ex + + error_occurred := true; + error_message := error_message || "{{+R}}New Significant Event{{-R}}\n" || ex.Message || "\n\n"; + if ex.InnerException is not null net_object then + error_message := error_message || "Inner Exception: " || ex.InnerException.Message || "\n\n"; + endif; + + if ( SignificantEvent_obj is NOT NULL ) then + void:= call SignificantEvent_obj.Dispose; + SignificantEvent_obj:= null; + endif; + + SignificantEvent_dest := null; + endcatch; + + + if ( client_visit_obj is NOT NULL ) then + void:= call client_visit_obj.Dispose; + client_visit_obj:= null; + endif; + + + endif; + + + // Launch the application + + + if launchtheapp = "yes" + + then + + oeUnsigned:=CALL test.ShowDialog; + + return_string:= test.text; + + + endif; + + + // Application has closed after a search + + +// if return_string = "search completed" + if return_string matches pattern "search completed%" + + then + + SearchAssessment := substring 80 characters starting at 17 from return_string ; +// SearchInformation:= "PDMP Searched by " || user_name || " " || Now; + SearchInformation:= "PDMP Searched by " || user_name || " " || extract month now || "/" || extract day now || "/" || extract year now || " " || extract hour now || ":" || extract minute now || SearchAssessment; + + + + + + // Populate Information Boxes With The Scearh Stamp + + + // Search Stamp Box + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Drug Monitor Checked FT"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := SearchInformation; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + + // Comment Box (search stamp plus physician comments) + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Drug Monitoring Comment FT"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "FreeTextValue"; + this_currentObj.ValueObj := New FreeTextValueType; + this_currentObj.ValueObj.Value := SearchInformation; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; + + + conclude true; // always concludes TRUE + + + ;; + action: + + if Error_occurred + then + write "An error has occured in the MLM {{+B}}Doc_Launch_PDMP_Search {{-B}} " || + "Please notify your System Administrators that an error message has occurred for this patient. They will review the following error message: \n" at error_destination; + write error_message at error_destination; + endif; + + + if EXISTS SignificantEvent_dest then + write true at SignificantEvent_dest; + endif; + + return this_documentCommunication; + + ;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_LOAD_SHIFT_TO_SHIFT_NURSE_REPORT.mlm b/MLMStripper/bin/Debug/DOC/DOC_LOAD_SHIFT_TO_SHIFT_NURSE_REPORT.mlm new file mode 100644 index 0000000..6de999e --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_LOAD_SHIFT_TO_SHIFT_NURSE_REPORT.mlm @@ -0,0 +1,545 @@ +maintenance: + +title: DOC_LOAD_Shift_To_Shift_Nurse_Report;; +mlmname: DOC_LOAD_Shift_To_Shift_Nurse_Report;; +arden: version 2.5;; +version: 5.00;; +institution: Eclipsys Corp ;; +author: Eclipsys Corp;; +specialist: ;; +date: 2011-01-04;; +validation: testing ;; + +library: +purpose: Load H&P Adult SN into Freetext SN + +;; +explanation: + + Load H & P SN into Freetext SN + DEPENDENCIES: + ------------- + None + + CONFIGURATION: + -------------- + Supported Document Types: + [] Flowsheets + [x] Structured Notes + + MLM Events Supported: + [] ChartObservation + [x] DocumentOpening + [] DocumentClosing + + USAGE EXAMPLE: + -------------- + mlm is attached on Form_Open of zzKW_TestTextNote structure note. + mlm will load all the observation entered by used in H&P Adult structure note and fill into Free Text control. + + If user edit and save this document, the contect is not overwritten by H&P Adult SN contect + + 06-30-2016 STH CSR#: 31024 & 34313 - Update shift to shift report to pull additional information that will be helpful and remove some details that are currently being pulled and no longer needed. + {Go-Live scheduled 10/31/2016}. + +;; +keywords: + Document + +;; +knowledge: +type: data-driven;; +data: + //*************************** Make Changes **************************************************// + /* This mlm read all the observation entered in H & P Structure note document. + SXASNObservationForMLMSelPr is the stored procedure used to get the observation result. This result is somewhat preformated + in rtf format. + MLM read the result and format it properly . + Filal rtf string is applied to zzKW_ control. + */ + //*************************** Make Changes END **************************************************// + + (this_documentCommunication) := argument; + //Get The Structure Note + (this_FS_doc) := this_documentCommunication.DocumentConfigurationObj; + //Get the Parameter List + (this_parms) := this_FS_doc.ParametersList; + //Paramters defination + (this_cols) := this_FS_doc.ColumnsList; + (this_curr_col) := this_FS_doc.Currentcolumn; + (this_currentObs) := this_documentCommunication.CurrentObservationObj; + +/* + (This_FreeText_param) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_Oxygen") ; +*/ + (this_curr_valobj) := this_currentObs.valueobj; + + Client_Guid := this_documentCommunication.ClientGUID; + Chart_Guid := this_documentCommunication.ChartGUID; + Client_Visit_Guid := this_documentCommunication.ClientVisitGUID; + Client_Document_GUID := this_FS_doc.ClientDocumentGUID; + + + MLM_DIPA := MLM {{{SINGLE-QUOTE}}}UTIL_OBJECT_DIPA_MLM{{{SINGLE-QUOTE}}}; + + (col1, col2 ) := Read { "SCH_SHIFT_TO_SHIFT_NURSE_REPORT_MLM " || sql(Client_Guid) || ", " || sql(Chart_Guid) || "," || sql(Client_Visit_Guid) }; + index_list := 1 seqto count (col2 ); + abc123 := this_parms.Name; + + for i in index_list do + + + str_col1 := col1[i] as string; + str_col2 := col2[i]; + + + if str_Col1 = "1" then + (This_FreeText_param) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_Vital Signs") ; + + + ObsType := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType := OBJECT [ Value ]; + + newObsVal := NEW ObsType; + newObsVal.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal.ParameterGUID := This_FreeText_param.ParameterGUID; + newObsVal.DataType := "FreeTextValue"; + newObsVal.ValueObj := NEW FreeTextValType; + + newObsVal.Valueobj.Value := str_col2; + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal ); + + + elseif str_Col1 = "2" then + (This_FreeText_param2) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_Oxygen") ; + + + ObsType2 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType2 := OBJECT [ Value ]; + + newObsVal2 := NEW ObsType2; + newObsVal2.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal2.ParameterGUID := This_FreeText_param2.ParameterGUID; + newObsVal2.DataType := "FreeTextValue"; + newObsVal2.ValueObj := NEW FreeTextValType2; + + newObsVal2.Valueobj.Value := str_col2; + + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal2 ); + + elseif str_Col1 = "3" then + (This_FreeText_param3) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_Pain Rating") ; + + + ObsType3 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType3 := OBJECT [ Value ]; + + newObsVal3 := NEW ObsType3; + newObsVal3.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal3.ParameterGUID := This_FreeText_param3.ParameterGUID; + newObsVal3.DataType := "FreeTextValue"; + newObsVal3.ValueObj := NEW FreeTextValType3; + + newObsVal3.Valueobj.Value := str_col2; + + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal3 ); +/* + elseif str_Col1 = "4" then + (This_FreeText_param4) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_Incision") ; + + + ObsType4 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType4 := OBJECT [ Value ]; + + newObsVal4 := NEW ObsType4; + newObsVal4.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal4.ParameterGUID := This_FreeText_param4.ParameterGUID; + newObsVal4.DataType := "FreeTextValue"; + newObsVal4.ValueObj := NEW FreeTextValType4; + + newObsVal4.Valueobj.Value := str_col2; + + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal4 ); + + elseif str_Col1 = "5" then + (This_FreeText_param5) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_Drain") ; + + + ObsType5 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType5 := OBJECT [ Value ]; + + newObsVal5 := NEW ObsType5; + newObsVal5.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal5.ParameterGUID := This_FreeText_param5.ParameterGUID; + newObsVal5.DataType := "FreeTextValue"; + newObsVal5.ValueObj := NEW FreeTextValType5; + + newObsVal5.Valueobj.Value := str_col2; + + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal5 ); + + */ + elseif str_Col1 = "6" then + (This_FreeText_param6) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_Fall Risk") ; + + + ObsType6 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType6 := OBJECT [ Value ]; + + newObsVal6 := NEW ObsType6; + newObsVal6.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal6.ParameterGUID := This_FreeText_param6.ParameterGUID; + newObsVal6.DataType := "FreeTextValue"; + newObsVal6.ValueObj := NEW FreeTextValType6; + + newObsVal6.Valueobj.Value := str_col2; + + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal6 ); + + elseif str_Col1 = "7" then + (This_FreeText_param7) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_Harm Risk") ; + + + ObsType7 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType7 := OBJECT [ Value ]; + + newObsVal7 := NEW ObsType7; + newObsVal7.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal7.ParameterGUID := This_FreeText_param7.ParameterGUID; + newObsVal7.DataType := "FreeTextValue"; + newObsVal7.ValueObj := NEW FreeTextValType7; + + newObsVal7.Valueobj.Value := str_col2; + + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal7 ); + + + elseif str_Col1 = "8" then + (This_FreeText_param8) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_Functional Status") ; + + + ObsType8 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType8 := OBJECT [ Value ]; + + newObsVal8 := NEW ObsType8; + newObsVal8.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal8.ParameterGUID := This_FreeText_param8.ParameterGUID; + newObsVal8.DataType := "FreeTextValue"; + newObsVal8.ValueObj := NEW FreeTextValType8; + + newObsVal8.Valueobj.Value := str_col2; + + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal8 ); + + + elseif str_Col1 = "9" then + (This_FreeText_param9) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_Comment Residence") ; + + + ObsType9 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType9 := OBJECT [ Value ]; + + newObsVal9 := NEW ObsType9; + newObsVal9.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal9.ParameterGUID := This_FreeText_param9.ParameterGUID; + newObsVal9.DataType := "FreeTextValue"; + newObsVal9.ValueObj := NEW FreeTextValType9; + + newObsVal9.Valueobj.Value := str_col2; + + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal9 ); + + elseif str_Col1 = "10" then + + (This_FreeText_param10) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_Functional Status Current PT") ; + + ObsType10 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType10 := OBJECT [ Value ]; + + newObsVal10 := NEW ObsType10; + newObsVal10.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal10.ParameterGUID := This_FreeText_param10.ParameterGUID; + newObsVal10.DataType := "FreeTextValue"; + newObsVal10.ValueObj := NEW FreeTextValType10; + + newObsVal10.Valueobj.Value := str_col2; + + + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal10 ); + +/* + elseif str_Col1 = "11" then + (This_FreeText_param11) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_Functional Status Current OT") ; + + + ObsType11 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType11 := OBJECT [ Value ]; + + newObsVal11 := NEW ObsType11; + newObsVal11.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal11.ParameterGUID := This_FreeText_param11.ParameterGUID; + newObsVal11.DataType := "FreeTextValue"; + newObsVal11.ValueObj := NEW FreeTextValType11; + + + newObsVal11.Valueobj.Value := str_col2; + + + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal11 ); + + +elseif str_Col1 = "12" then + (This_FreeText_param12) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_Functional Status Current ST") ; + + + ObsType12 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType12 := OBJECT [ Value ]; + + newObsVal12 := NEW ObsType12; + newObsVal12.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal12.ParameterGUID := This_FreeText_param12.ParameterGUID; + newObsVal12.DataType := "FreeTextValue"; + newObsVal12.ValueObj := NEW FreeTextValType12; + + newObsVal12.Valueobj.Value := str_col2; + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal12 ); + + + elseif str_Col1 = "13" then + (This_FreeText_param13) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_Orientation") ; + + + ObsType13 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType13 := OBJECT [ Value ]; + + newObsVal13 := NEW ObsType13; + newObsVal13.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal13.ParameterGUID := This_FreeText_param13.ParameterGUID; + newObsVal13.DataType := "FreeTextValue"; + newObsVal13.ValueObj := NEW FreeTextValType13; + + newObsVal13.Valueobj.Value := str_col2; + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal13 ); +*/ + +elseif str_Col1 = "14" then + (This_FreeText_param14) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_Last Medicated") ; + + + ObsType14 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType14 := OBJECT [ Value ]; + + newObsVal14 := NEW ObsType14; + newObsVal14.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal14.ParameterGUID := This_FreeText_param14.ParameterGUID; + newObsVal14.DataType := "FreeTextValue"; + newObsVal14.ValueObj := NEW FreeTextValType14; + + newObsVal14.Valueobj.Value := str_col2; + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal14 ); + + +elseif str_Col1 = "15" then + (This_FreeText_param15) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_MDPN_DischargePlan") ; + + + ObsType15 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType15 := OBJECT [ Value ]; + + newObsVal15 := NEW ObsType15; + newObsVal15.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal15.ParameterGUID := This_FreeText_param15.ParameterGUID; + newObsVal15.DataType := "FreeTextValue"; + newObsVal15.ValueObj := NEW FreeTextValType15; + + newObsVal15.Valueobj.Value := str_col2; + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal15 ); + + +elseif str_Col1 = "16" then + (This_FreeText_param15) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_Braden Risk Score") ; + + + ObsType15 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType15 := OBJECT [ Value ]; + + newObsVal15 := NEW ObsType15; + newObsVal15.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal15.ParameterGUID := This_FreeText_param15.ParameterGUID; + newObsVal15.DataType := "FreeTextValue"; + newObsVal15.ValueObj := NEW FreeTextValType15; + + newObsVal15.Valueobj.Value := str_col2; + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal15 ); + + +elseif str_Col1 = "17" then + (This_FreeText_param15) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_CINA Risk Score") ; + + + ObsType15 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType15 := OBJECT [ Value ]; + + newObsVal15 := NEW ObsType15; + newObsVal15.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal15.ParameterGUID := This_FreeText_param15.ParameterGUID; + newObsVal15.DataType := "FreeTextValue"; + newObsVal15.ValueObj := NEW FreeTextValType15; + + newObsVal15.Valueobj.Value := str_col2; + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal15 ); + + +elseif str_Col1 = "18" then + (This_FreeText_param15) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_NIHSS Risk Score") ; + + + ObsType15 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType15 := OBJECT [ Value ]; + + newObsVal15 := NEW ObsType15; + newObsVal15.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal15.ParameterGUID := This_FreeText_param15.ParameterGUID; + newObsVal15.DataType := "FreeTextValue"; + newObsVal15.ValueObj := NEW FreeTextValType15; + + newObsVal15.Valueobj.Value := str_col2; + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal15 ); + + +elseif str_Col1 = "19" then + (This_FreeText_param15) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_CIWA Risk Score") ; + + + ObsType15 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType15 := OBJECT [ Value ]; + + newObsVal15 := NEW ObsType15; + newObsVal15.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal15.ParameterGUID := This_FreeText_param15.ParameterGUID; + newObsVal15.DataType := "FreeTextValue"; + newObsVal15.ValueObj := NEW FreeTextValType15; + + newObsVal15.Valueobj.Value := str_col2; + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal15 ); + + +elseif str_Col1 = "21" then + (This_FreeText_param15) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_Suicide Risk") ; + + + ObsType15 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType15 := OBJECT [ Value ]; + + newObsVal15 := NEW ObsType15; + newObsVal15.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal15.ParameterGUID := This_FreeText_param15.ParameterGUID; + newObsVal15.DataType := "FreeTextValue"; + newObsVal15.ValueObj := NEW FreeTextValType15; + + newObsVal15.Valueobj.Value := str_col2; + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal15 ); + + +elseif str_Col1 = "99" then + (This_FreeText_param15) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_Education FT MLM") ; + + + ObsType15 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType15 := OBJECT [ Value ]; + + newObsVal15 := NEW ObsType15; + newObsVal15.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal15.ParameterGUID := This_FreeText_param15.ParameterGUID; + newObsVal15.DataType := "FreeTextValue"; + newObsVal15.ValueObj := NEW FreeTextValType15; + + newObsVal15.Valueobj.Value := trim(str_col2); + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal15 ); + +elseif str_Col1 = "100" then + (This_FreeText_param15) := FIRST OF (this_parms WHERE this_parms.NAME = "SCH_NSR_Current Diet") ; + + + ObsType15 := OBJECT [ ObservationGUID, ClientDocumentGUID, + ParameterGUID, DataType, ValueObj ]; + + FreeTextValType15 := OBJECT [ Value ]; + + newObsVal15 := NEW ObsType15; + newObsVal15.ClientDocumentGUID := Client_Document_GUID; // This_FreeText_param.ClientDocumentGUID; + newObsVal15.ParameterGUID := This_FreeText_param15.ParameterGUID; + newObsVal15.DataType := "FreeTextValue"; + newObsVal15.ValueObj := NEW FreeTextValType15; + + newObsVal15.Valueobj.Value := str_col2; + this_fs_doc.ChartedObservationsList := ( this_fs_doc.ChartedObservationsList, newObsVal15 ); +endif; + + + + enddo; + + + + + ;; + +priority: 50 +;; +evoke: +;; +logic: + + /* once document is already saved, do not reload the H&P SN */ + conclude true; + +;; +action: + + return this_documentCommunication; +;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_MD_PROGRESSNOTE.mlm b/MLMStripper/bin/Debug/DOC/DOC_MD_PROGRESSNOTE.mlm new file mode 100644 index 0000000..37194c6 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_MD_PROGRESSNOTE.mlm @@ -0,0 +1,111 @@ +maintenance: + + title: DOC_MD_ProgressNote;; + mlmname: DOC_MD_ProgressNote;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Don Warnick;; + specialist: ;; + date: 2010-02-03;; + validation: testing;; + +library: + purpose: + ;; + explanation: + + + Change history + + 02.03.2010 DW Copied from Jacob{{{SINGLE-QUOTE}}}s Springhill MLM stored here under the name DOC_SMC_VITAL_SIGNS_HIGHS_AND_LOWS_Springhill + 04.07.2010 RS Added logic for Progress Note Printing. Commented out all thisDocumentCommnuication.CancelEvent = true; + 09.19.2011 ACS Added call to new Doc_St_Clair_Main_PN_MLM + 05.01.2012 DW CSR# 26409/26930 Altered per CHF Core Measure requirements and Prism Enhancements + 08.27.2012 DW CSR# 30963 Prism Enhancements - Commented out the Shift to Shift MLM call. Has nothing to do with the PN and is adversly affecting it. + 08.18.2014 DW CSR# 32616 Add Newborn & Critical Care values to the Vital Signs Section (re-introduced DOC_FUNC_VS_24hrs & commented out VS section of DOC_ST_Clair_MAIN_PN_MLM) + 10.20.2014 DW CSR# 32746 (Alert for missing VTE order) & 32675 (Altert for incomplete or missing Admission ORM) + 02.02.2015 DW CSR# 32616 Develop Application to allow for communication between clinical documentation specialist + 05.05.2015 DW CSR# 32359 - Physician CPT codes (processes only on Document Close) + 12.16.2015 DW CSR# 33655 Previnar + 04.27.2017 DW CSR# 35436 - PDMP Improvements + 08.27.2018 DW CSR# 36721 Risk Score Enhancement - increase the score via the EPN + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // Recieve arguments from the structured note +/* + (thisDocumentCommunication) := argument; + + DocVitalsHL := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_CHF{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocVitalsHL WITH thisDocumentCommunication; +*/ +// thisDocumentCommunication.CancelEvent := true; + + (thisDocumentCommunication) := argument; + + // removed 08.30.2012 by DW - has nothing to do with the PN and is adversly affecting it (pulling last AP dispostion) + +// (thisDocumentCommunication) := argument; +// DocVitalsHL3 := MLM {{{SINGLE-QUOTE}}}DOC_LOAD_Shift_To_Shift_Nurse_Report{{{SINGLE-QUOTE}}}; +// thisDocumentCommunication := CALL DocVitalsHL3 WITH thisDocumentCommunication; + + DocVitalsHL2 := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_VS_24hrs{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocVitalsHL2 WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + + + // ACS 20110919 - added + ACS_DOC_PN := MLM {{{SINGLE-QUOTE}}}DOC_ST_Clair_MAIN_PN_MLM{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL ACS_DOC_PN WITH thisDocumentCommunication; + // ACS 20110919 - end of addition + + ACS_DOC_PN := MLM {{{SINGLE-QUOTE}}}DOC_Func_MD_ProgressNote_CoreMeasures{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL ACS_DOC_PN WITH thisDocumentCommunication; + + + DOC_EPN_ALERT := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_EPN_ALERTS{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DOC_EPN_ALERT WITH thisDocumentCommunication; + + + DOC_EPN_ALERT := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_CLIN_DOC_SPECIALIST_CLARIFICATION{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DOC_EPN_ALERT WITH thisDocumentCommunication; + + + DOC_EPN_CHARGING := MLM {{{SINGLE-QUOTE}}}Doc_Func_Launch_Physician_Charge_Builder{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DOC_EPN_CHARGING WITH thisDocumentCommunication; + + + DOC_FUNC_PNEUMOVAX_EPN := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_PNEUMOVAX_EPN{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DOC_FUNC_PNEUMOVAX_EPN WITH thisDocumentCommunication; + + + Doc_Launch_PDMP_Search := MLM {{{SINGLE-QUOTE}}}Doc_Launch_PDMP_Search{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL Doc_Launch_PDMP_Search WITH thisDocumentCommunication; + + + RiskCategory := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_RISK_CATEGORY{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL RiskCategory WITH thisDocumentCommunication; + + +// thisDocumentCommunication.CancelEvent := true; + +// DocPrintOnSave := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_PRINT_ON_SAVE{{{SINGLE-QUOTE}}}; +// thisDocumentCommunication := CALL DocPrintOnSave WITH thisDocumentCommunication; +// thisDocumentCommunication.CancelEvent := true; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_MEWS_SCORE_COLUMN_UPDATE.mlm b/MLMStripper/bin/Debug/DOC/DOC_MEWS_SCORE_COLUMN_UPDATE.mlm new file mode 100644 index 0000000..1df6263 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_MEWS_SCORE_COLUMN_UPDATE.mlm @@ -0,0 +1,354 @@ +maintenance: + + title: ;; + mlmname: DOC_MEWS_SCORE_COLUMN_UPDATE ;; + arden: version 2.5;; + version: 2.00;; + institution: St.Clair Hospital ;; + author: Sandy Zhang ;; + specialist: Janet Nordin ;; + date: 2017-06-23;; + validation: testing;; + +library: + purpose: MEWS stands for Modified Early Warning Sign. The primary purpose of implementing a MEWS Score protocol is to prevent delay in intervention or transfer of critically ill patients. + Update the MEWS Score column with patient{{{SINGLE-QUOTE}}}s MEWS Score. This MEWS score is based on their Level of Consciousness(LOC) and Vitals (Systolic BP, Temp, HR, RR). The MEWS score is also located in the flowsheet: + 2.Adult Assessment/Intervention. This MLM is tied to 2 flowsheets "1.Vital Signs - Basic" and "2. Adult Assessment/Intervention". This MLM is also tied to the enterprise defined column: "MEWS Score". + + ;; + explanation: + + Change history + + 06.23.2017 SZ CSR# 35481 MEWS Score column update - Start of Project + 06.01.2019 SZ CSR# 37867 MEWS MLM change for Capsule project + ;; + keywords: + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + + + (this_doc_com) := argument; + + //** standard includes + standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + error_occurred := false; + error_message := ""; + log_execution_info := false; + + error_destination := destination { Alert } with [ + alert_type := "Warning", + short_message := "ObjectsPlus Error from MLM", + priority := "low", + scope := "chart", + Rule_group := "ObjectsPlus Error from MLM", + Rule_number := 1001, + Rule_subgroup := "", + Send_with_order := "", + Alert_dialog_settings := "", + Display_alert := true ]; + + fs_doc_config_obj := this_doc_com.DocumentConfigurationObj; + this_parms := fs_doc_config_obj.ParametersList; + + // ***********************************************************************************************// + + //get guids + ClientGUID := this_doc_com.ClientGUID; + ChartGUID := this_doc_com.ChartGUID; + ClientVisitGUID := this_doc_com.ClientVisitGUID; + + + // ***********************************************************************************************// + + set_cds_vars := MLM {{{SINGLE-QUOTE}}}CALLED_DOC_FS_DEFINITION_MLM{{{SINGLE-QUOTE}}}; + + (this_documentCommunication, client_guid, client_visit_guid, chart_guid, + user_guid, document_type, document_name, event_type, + configuration_guid, this_currentObs, CancelEventFlag, this_fs_doc, + authored_by_guid, isIOFlowsheetFlag, client_document_guid, this_parameters, + this_columnList, this_currentColumn, this_chartedObservationsList, + this_parameters_displayName, current_parameter, current_parameter_name, current_parameter_guid, + current_parameter_datatype, selectedItems, selectedItems_Value, current_value, + diagnostic_message, displayMessageFlag) := CALL set_cds_vars WITH (this_doc_com); + + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + ListValueType := OBJECT [ListGuid, ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + FreeTextValueType := OBJECT [Value]; + NumericValueType := OBJECT [Value]; + + // gather relevant times + column_date_time := this_currentColumn.DateTime; + back_4_hours := column_date_time -4 hours; + forward_4_hours := column_date_time +4 hours; + + // *****************************************************************************************// + + + + // code here is invoked by charting of {{{SINGLE-QUOTE}}}Farenheit{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Heart Rate{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Resp Rate{{{SINGLE-QUOTE}}}, and/or {{{SINGLE-QUOTE}}}Noninvasive Systolic BP{{{SINGLE-QUOTE}}} in flowsheet #1 (1.Vital Signs - Basic) + if (this_doc_com.documenttype = "Flowsheet" and this_doc_com.DocumentName = "1.Vital Signs - Basic") then + + //get guids for later use + temp_guid := last(this_parms.ParameterGUID where this_parms.Name = "Farenheit") as string; + hr_guid := last(this_parms.parameterguid where this_parms.Name = "Heart Rate") as string; + rr_guid := last(this_parms.ParameterGUID where this_parms.Name = "Resp Rate") as string; + bp_guid := last(this_parms.ParameterGUID where this_parms.Name = "Noninvasive Systolic BP") as string; + + + //get vital values + temp_value := first(this_chartedObservationsList.valueobj.value where this_chartedObservationsList.parameterguid = temp_guid); + hr_value := first(this_chartedObservationsList.valueobj.value where this_chartedObservationsList.parameterguid = hr_guid); + rr_value := first(this_chartedObservationsList.valueobj.value where this_chartedObservationsList.parameterguid = rr_guid); + bp_value := first(this_chartedObservationsList.valueobj.value where this_chartedObservationsList.parameterguid = bp_guid); + + + // *************** get alertness value ************************************************************* // + // get alertness parameter guid + Alertness_parameter_guid := last(this_parms.ParameterGUID where this_parms.Name = "SCH_MEWS Alertness") as string; + + // use alertness parameter guid to find the list item lists + Alertness_listitemslist := first(this_currentColumn.ChartedObservationsList.valueobj where this_currentColumn.ChartedObservationsList.parameterguid = Alertness_parameter_guid); // retired on 7/19 + + // turns true if alertness radio buttons are selected + Alert_SELECTED := first( Alertness_listitemslist.ListItemsList.IsSelected where Alertness_listitemslist.ListItemsList.Value = "Alert"); + Voice_SELECTED := first( Alertness_listitemslist.ListItemsList.IsSelected where Alertness_listitemslist.ListItemsList.Value = "Voice"); + Pain_SELECTED := first( Alertness_listitemslist.ListItemsList.IsSelected where Alertness_listitemslist.ListItemsList.Value = "Pain"); + Unresponsive_SELECTED := first( Alertness_listitemslist.ListItemsList.IsSelected where Alertness_listitemslist.ListItemsList.Value = "Unresponsive"); + + // this turns true if any of any of the above were selected + any_selected := ANY(Alert_SELECTED, Voice_SELECTED, Pain_SELECTED, Unresponsive_SELECTED); + + + if (exist any_selected) then + + if (Alert_SELECTED = true) then + alert_score := 0; + endif; + if (Voice_SELECTED = true) then + alert_score := 1; + endif; + if (Pain_SELECTED = true) then + alert_score := 2; + endif; + if (Unresponsive_SELECTED = true) then + alert_score := 3; + endif; + + endif; + + + // if all of these values (temp_value, hr_value, rr_value, bp_value) are null then assign "yes" to FS_1_nothing_entered. + if not exist (temp_value, hr_value, rr_value, bp_value, alert_score) then + FS_1_nothing_entered := "yes"; + else + + // get the mews score for the temperature + if (temp_value <= 96) then + temp_mews_score := 2; + elseif (temp_value >= 96.1 and temp_value <= 96.9) then + temp_mews_score := 1; + elseif (temp_value >= 97 and temp_value <= 100.5) then + temp_mews_score := 0; + elseif (temp_value >= 100.6 and temp_value <= 101.4) then + temp_mews_score := 1; + elseif (temp_value >= 101.5) then + temp_mews_score := 2; + endif; + + + // get the mews score for the respiratory rate + if (rr_value < 9) then + rr_mews_score := 2; + elseif (rr_value >= 9 and rr_value <= 14) then + rr_mews_score := 0; + elseif (rr_value >= 15 and rr_value <= 20) then + rr_mews_score := 1; + elseif (rr_value >= 21 and rr_value <= 29) then + rr_mews_score := 2; + elseif (rr_value >= 30) then + rr_mews_score := 3; + endif; + + // get the mews score for the heart rate + if (hr_value <= 40) then + hr_mews_score := 3; + elseif (hr_value >= 41 and hr_value <= 50) then + hr_mews_score := 2; + elseif (hr_value >= 51 and hr_value <= 60) then + hr_mews_score := 1; + elseif (hr_value >= 61 and hr_value <= 100) then + hr_mews_score := 0; + elseif (hr_value >= 101 and hr_value <= 115) then + hr_mews_score := 1; + elseif (hr_value >= 116 and hr_value <= 129) then + hr_mews_score := 2; + elseif (hr_value >= 130) then + hr_mews_score := 3; + endif; + + + // get the mews score for the noninvasive systolic bp + if (bp_value <= 70) then + bp_mews_score := 3; + elseif (bp_value >= 71 and bp_value <= 79) then + bp_mews_score := 2; + elseif (bp_value >= 80 and bp_value <= 89) then + bp_mews_score := 1; + elseif (bp_value >= 90 and bp_value <= 150) then + bp_mews_score := 0; + elseif (bp_value >= 151 and bp_value <= 180) then + bp_mews_score := 1; + elseif (bp_value >= 181 and bp_value <= 199) then + bp_mews_score := 2; + elseif (bp_value >= 200) then + bp_mews_score := 3; + endif; + + // add up all the individual MEWS scores + total_mews_score := (bp_mews_score + hr_mews_score + rr_mews_score + temp_mews_score + alert_score); + + + if (exist total_mews_score) then + + + // if this fs DateTime = last fs DateTime then send results to column + last_col := last(this_fs_doc.ColumnsList); + last_col_datetime := last_col.DateTime; + cur_col_datetime := this_currentColumn.DateTime; + + // only send total mews score to status board column if it{{{SINGLE-QUOTE}}}s coming from the most recent column + + (MEWS_score_sql, MEWS_score_sql_time) := read last { + "select" + ||" o.ValueText, od.RecordedDtm" + ||" from CV3ActiveVisitList avl with (nolock)" + ||" join CV3ClientDocumentCUR cd with (nolock) ON cd.ClientGUID = avl.ClientGUID and cd.ChartGUID = avl.ChartGUID and cd.ClientVisitGUID = avl.GUID" + ||" join CV3ClientDocDetailCUR cdd with (nolock) ON cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.ClientGUID AND cdd.ArcType = cd.ArcType" + ||" join CV3ObservationDocumentCUR od with (nolock) ON od.OwnerGUID = cdd.CLientDocumentGUID AND od.ArcType = cdd.ArcType" + ||" join CV3ObsCatalogMasterItem ocmi with (nolock) ON ocmi.GUID = od.ObsMasterItemGUID" + ||" join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID and o.ArcType = cdd.ArcType" + ||" where cd.ClientGUID = " || sql(ClientGUID) + ||" and o.ValueText is not null" + ||" and ocmi.description = {{{SINGLE-QUOTE}}}SCH_MEWS_Total{{{SINGLE-QUOTE}}}" + }; + + + // only send results to status board column if observations entered create the most current muse score + if (cur_col_datetime >= MEWS_score_sql_time) or (not exist MEWS_score_sql_time) then + + // send the total MEWS score to the column + create_mews_column := MLM {{{SINGLE-QUOTE}}}SCH_FUNC_CREATE_ENTERPRISE_DEFINED_COLUMN{{{SINGLE-QUOTE}}}; // MLM that creates the Enterprise Defined Column in the "Action" section of the MLM + EDCObj := OBJECT [column_name,column_value,client_guid,chart_guid,client_visit_guid]; // Create Enterprise Defined Column Obj + mews_score_column:= NEW EDCObj WITH + [ + column_name := "MEWS Score", + column_value := total_mews_score, + client_guid := ClientGUID, + chart_guid := ChartGUID, + client_visit_guid := ClientVisitGUID + ]; + + return_value := call create_mews_column with ( mews_score_column ); + send_to_column := "yes score of " || total_mews_score || " was sent to column"; + + endif; // most current MUSE score check + + // send the total MEWS score to numeric observation box + TOTAL_parameter_guid_FT := last(this_parms.ParameterGUID where this_parms.Name = "SCH_MEWS_Total") as string; + + (this_fs_doc_1) := (this_fs_doc.CurrentColumn); + TotalObservation := NEW ObservationType; + TotalObservation.ClientDocumentGUID:= this_fs_doc.ClientDocumentGUID; + TotalObservation.ParameterGUID := TOTAL_parameter_guid_FT; + TotalObservation.DataType := "Numeric"; + TotalObservation.ValueObj := NEW NumericValueType; + TotalObservation.ValueObj.Value := total_mews_score; + this_fs_doc_1.ChartedObservationsList := (this_fs_doc_1.ChartedObservationsList,TotalObservation); + + // send the temp score to numeric observation box + temp_score_guid := last(this_parms.ParameterGUID where this_parms.Name = "SCH_MEWS Temperature FT") as string; + Temp_Observation := NEW ObservationType; + Temp_Observation.ClientDocumentGUID:= this_fs_doc.ClientDocumentGUID; + Temp_Observation.ParameterGUID := temp_score_guid; + Temp_Observation.DataType := "FreeTextValue"; + Temp_Observation.ValueObj := NEW NumericValueType; + Temp_Observation.ValueObj.Value := temp_mews_score as string; + this_fs_doc_1.ChartedObservationsList := (this_fs_doc_1.ChartedObservationsList, Temp_Observation); + + // send the hr score to numeric observation box + hr_score_guid := last(this_parms.ParameterGUID where this_parms.Name = "SCH_MEWS Heart Rate FT") as string; + HR_Observation := NEW ObservationType; + HR_Observation.ClientDocumentGUID:= this_fs_doc.ClientDocumentGUID; + HR_Observation.ParameterGUID := hr_score_guid; + HR_Observation.DataType := "FreeTextValue"; + HR_Observation.ValueObj := NEW NumericValueType; + HR_Observation.ValueObj.Value := hr_mews_score as string; + this_fs_doc_1.ChartedObservationsList := (this_fs_doc_1.ChartedObservationsList, HR_Observation); + + // send the rr score to numeric observation box + rr_score_guid := last(this_parms.ParameterGUID where this_parms.Name = "SCH_MEWS Respiratory Rate FT") as string; + RR_Observation := NEW ObservationType; + RR_Observation.ClientDocumentGUID:= this_fs_doc.ClientDocumentGUID; + RR_Observation.ParameterGUID := rr_score_guid; + RR_Observation.DataType := "FreeTextValue"; + RR_Observation.ValueObj := NEW NumericValueType; + RR_Observation.ValueObj.Value := rr_mews_score as string; + this_fs_doc_1.ChartedObservationsList := (this_fs_doc_1.ChartedObservationsList, RR_Observation); + + // send the bp score to numeric observation box + bp_score_guid := last(this_parms.ParameterGUID where this_parms.Name = "SCH_MEWS Systolic BP FT") as string; + bp_Observation := NEW ObservationType; + bp_Observation.ClientDocumentGUID:= this_fs_doc.ClientDocumentGUID; + bp_Observation.ParameterGUID := bp_score_guid; + bp_Observation.DataType := "FreeTextValue"; + bp_Observation.ValueObj := NEW NumericValueType; + bp_Observation.ValueObj.Value := bp_mews_score as string; + this_fs_doc_1.ChartedObservationsList := (this_fs_doc_1.ChartedObservationsList, bp_Observation); + + + // send the alertness score to numeric observation box + alertness_score_guid := last(this_parms.ParameterGUID where this_parms.Name = "SCH_MEWS Alertness FT") as string; + alertness_Observation := NEW ObservationType; + alertness_Observation.ClientDocumentGUID:= this_fs_doc.ClientDocumentGUID; + alertness_Observation.ParameterGUID := alertness_score_guid; + alertness_Observation.DataType := "FreeTextValue"; + alertness_Observation.ValueObj := NEW NumericValueType; + alertness_Observation.ValueObj.Value := alert_score as string; + this_fs_doc_1.ChartedObservationsList := (this_fs_doc_1.ChartedObservationsList, alertness_Observation); + + + endif; // (if exist total_mews_score then) execute + endif; // if FS_1_nothing_entered exists then skip this b/c FS #1 didn{{{SINGLE-QUOTE}}}t send any pertinant values + endif; // flowsheet #1 name filter + + + ;; + priority: 50 + ;; + evoke: + ;; + logic: + + conclude true; + ;; + action: return this_doc_com; + + if Error_occurred + then + write "An error has occured in the MLM {{+B}}DOC_MEWS_SCORE_COLUMN_UPDATE{{-B}} Please notify your System Administrators that an error message has occurred for this patient. They will review the following error message: \n" at error_destination; + write error_message at error_destination; + endif; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_NEWBORN_ASSESSMT_DISCHARGE_SUMMARY_TILE.mlm b/MLMStripper/bin/Debug/DOC/DOC_NEWBORN_ASSESSMT_DISCHARGE_SUMMARY_TILE.mlm new file mode 100644 index 0000000..3c4dd97 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_NEWBORN_ASSESSMT_DISCHARGE_SUMMARY_TILE.mlm @@ -0,0 +1,156 @@ +maintenance: + + title: DOC_Newborn_Assessmt_Discharge_Summary_Tile;; + mlmname: DOC_Newborn_Assessmt_Discharge_Summary_Tile;; + arden: version 2.5;; + version: 6.00;; + institution: St. Clair Hospital ;; + author: Shivprasad Jadhav;; + specialist: Shivprasad Jadhav;; + date: 2015-01-16;; + validation: testing;; + +library: + purpose: When user opens document [Newborn Assessment and Discharge Summary] retrieve the same information that is displayed on the Clinical Summary tab. + Clinical Summary Tile: FBC - Newborn Professional Exchange Report. Information will be saved with the document.;; + explanation: + Change History +------------------------------------------------- + + 11-04-2015 GOS MLM Created CSR :32729- Created MLM to Display Clinical Summary info on Structured Note [Newborn Assessment and Discharge Summary] . + + + ;; + keywords: + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + (this_documentCommunication) := argument; + + + MLM_Base := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_NEWBORN_ASSESSSMENT{{{SINGLE-QUOTE}}}; + this_documentCommunication := Call MLM_Base With this_documentCommunication; + + //Get The Structure Note + (this_FS_doc) := this_documentCommunication.DocumentConfigurationObj; + //Get the Parameter List + (this_parms) := this_FS_doc.ParametersList; + //Paramters defination + (this_cols) := this_FS_doc.ColumnsList; + (this_curr_col) := this_FS_doc.Currentcolumn; + (this_currentObs) := this_documentCommunication.CurrentObservationObj; + (this_observations) := this_FS_doc.ChartedObservationsList; + + (UserGUID) := this_documentCommunication.UserGUID ; + (this_curr_valobj) := this_currentObs.valueobj; + // Get the client and visit GUIDs + clientGuid := this_documentCommunication.ClientGUID; + VisitGuid := this_documentCommunication.ClientVisitGUID; + chartGuid := this_documentCommunication.ChartGUID; + Client_Document_GUID := this_FS_doc.ClientDocumentGUID; + + Ord_OBJECT := OBJECT [Obs_BaseName, Obs_name, Obs_val ] ; + Ord_vals := read as Ord_OBJECT + { + " CREATE TABLE #tmp_aaa ( Basename varchar(200), name Varchar(200), value varchar(500) ) " + || " INSERT INTO #tmp_aaa (Basename, name, value ) " + || " select Distinct ocmi.Name,ocmi.LeftJustifiedLabel , Case When oflv.Value is Null Then o.ValueText else oflv.Value end Value " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1 " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " AND ocmi.Name in ( {{{SINGLE-QUOTE}}}AS deliv baby a meconium present yn ob{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}AS deliv baby a time ob DT{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}AS deliv baby b meconium present yn ob{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}AS deliv baby b time ob DT{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}AS deliv baby c meconium present yn ob{{{SINGLE-QUOTE}}}," + || " {{{SINGLE-QUOTE}}}AS deliv baby c time ob DT{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}AS deliv vag type ob{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}AS SC deliv apgar a1 score ob CAL{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}AS SC deliv apgar a10 score ob CAL{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}AS SC deliv apgar a15 score ob CAL{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}AS SC deliv apgar a20 score ob CAL{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}AS SC deliv apgar a5 score ob CAL{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}INV deliv vag assist type ob{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}INV deliv vbac ob{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}PRO gest age comment infant FT{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}PRO gestational age infant NU{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}PRO group b strep ob DT{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}PRO group b strep status{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}PRO growth alteration infant{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCHCK deliv baby a time vag ob DT{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCHCK deliv csect performed{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCHCK gest head graph{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}SCHCK gest lgth graph{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCHCK gest wt graph{{{SINGLE-QUOTE}}}) " + || " Left Join SCMObsFSListValues oflv (nolock) On oflv.ClientGUID= cd.ClientGUID And oflv.ParentGUID = od.ObservationDocumentGUID " + || " where cd.clientvisitguid = " || VisitGuid || " and cd.clientguid = " || clientGuid || " and cd.chartguid = " || chartGuid || " " + || " and cd.iscanceled = 0 " + || " Select Distinct Basename, Name, Stuff(( Select {{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}+ b.value from #tmp_aaa b Where a.Basename=b.basename " + || " 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 {{{SINGLE-QUOTE}}}Value{{{SINGLE-QUOTE}}} from #tmp_aaa a drop table #tmp_aaa" }; + + Ord_Prenatal := OBJECT [Obs_BaseName, Obs_name, Obs_val ] ; + Ord_vals1 := read as Ord_Prenatal + { " CREATE TABLE #tmp_aaaa ( Basename varchar(200), name Varchar(200), value varchar(500) ) " + || " INSERT INTO #tmp_aaaa (Basename, name, value ) " + || " select Distinct ocmi.Name,ocmi.LeftJustifiedLabel , Case When oflv.Value is Null Then o.ValueText else oflv.Value end Value " + || " from CV3ClientDocument cd with (nolock) " + || " join CV3ClientDocDetail cdd with (nolock) ON cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1 " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " AND ocmi.Name in ( {{{SINGLE-QUOTE}}}PRO antibody screen ob DT{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO antibody screen ob FT{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO blood type ob{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO chlamydia post treat ob{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}PRO chlamydia result ob{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO gonorrhea cult post tx ob{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO gonorrhea culture ob{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO gravida ob NU{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}PRO group b strep ob{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO hbsag ob{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO herpes ob{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO herpes repeat ob{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO hiv ob{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}PRO maternal tox result ob{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO maternal tox screen ob{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO msafp result ob FT{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO msafp wks gest ob NU{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}PRO pap smear result abn ob{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO pap smear result ob{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO para ob NU{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO quad marker results ob FT{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}PRO quad marker wks gest ob NU{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO rubella ob{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO triple marker results ob FT{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO triple marker wks gest ob NU{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}PRO vdrl ob{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO vdrl post treat ob{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PRO antibody screen ob routine{{{SINGLE-QUOTE}}}) " + || " Left Join SCMObsFSListValues oflv (nolock) On oflv.ClientGUID= cd.ClientGUID And oflv.ParentGUID = od.ObservationDocumentGUID " + || " where cd.clientvisitguid = " || VisitGuid || " and cd.clientguid = " || clientGuid || " and cd.chartguid = " || chartGuid || " " + || " and cd.iscanceled = 0 " + || " Select * from #tmp_aaaa drop table #tmp_aaaa " }; + + IF Exists Ord_vals THEN + ReturnString := ""; + FOR DataCtr IN 1 SEQTO COUNT OF Ord_vals DO + Ord_Name := Ord_vals.Obs_name[DataCtr] || " " ; + Ord_Value := Ord_vals.Obs_val[DataCtr] ; + ReturnString := ReturnString || Ord_Name || " : " || Ord_Value || " \n"; + ENDDO; + Else + ReturnString := " No Delivery Data Available"; + Endif; + IF Exists Ord_vals1 THEN + + ReturnString1 := ""; + Ord_Name :=""; + Ord_Value := ""; + FOR DataCtr IN 1 SEQTO COUNT OF Ord_vals1 DO + Ord_Name := Ord_vals1.Obs_name[DataCtr] || " " ; + Ord_Value := Ord_vals1.Obs_val[DataCtr] ; + ReturnString1 := ReturnString1 || Ord_Name || " : " || Ord_Value || " \n"; + ENDDO; + Else ReturnString1 := " No Prenatal Data Available"; + Endif; + + + + + //MLM_DIPA := MLM {{{SINGLE-QUOTE}}}UTIL_OBJECT_Customize_DIPA_MLM{{{SINGLE-QUOTE}}}; + + prm_Prenal := First of (this_parms where this_parms.Name = "SCH_NEWBORN_MLM Prenatal Lab Info"); + prm_Delivery := First of (this_parms where this_parms.Name = "SCH_NEWBORN_MLM Mom Info"); + MLM_DIPA := MLM {{{SINGLE-QUOTE}}}UTIL_OBJECT_Customize_DIPA_MLM{{{SINGLE-QUOTE}}}; + if exists ReturnString then + Obs_Delivery := CALL MLM_DIPA WITH this_DocumentCommunication,prm_Delivery, ReturnString as string ; + // Obs_Comf_Mo.ValueObj.SuggestedTextValue := Mo_Sugg ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, Obs_Delivery); + endif; + if exists ReturnString1 then + Obs_Prenatal := CALL MLM_DIPA WITH this_DocumentCommunication,prm_Prenal, ReturnString1 as string ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, Obs_Prenatal); + endif; + + + + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_OBS_ASSESSMENT_CLOSE.mlm b/MLMStripper/bin/Debug/DOC/DOC_OBS_ASSESSMENT_CLOSE.mlm new file mode 100644 index 0000000..78b9439 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_OBS_ASSESSMENT_CLOSE.mlm @@ -0,0 +1,44 @@ +maintenance: + + title: DOC_OBS_ASSESSMENT_CLOSE;; + mlmname: DOC_OBS_ASSESSMENT_CLOSE;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Juliet M. Law;; + specialist: ;; + date: 2016-01-25;; + validation: testing;; + +library: + purpose: + ;; + explanation: + + + Change history + + 01.25.2016 JML CSR 33953 Created; copied from DOC_ADULT_ASSESSMENT_CLOSE + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Receive arguments from the flowsheet + (thisDocumentCommunication) := argument; + + //Call MLM to create dressing change order based on type of line insertion being charted + DocDressingChangeObs := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_CREATE_DRESSING_CHANGE_FROM_LINE_INSERTION_OBS{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocDressingChangeObs WITH thisDocumentCommunication; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_OBS_ASSESSMENT_OPEN.mlm b/MLMStripper/bin/Debug/DOC/DOC_OBS_ASSESSMENT_OPEN.mlm new file mode 100644 index 0000000..f457065 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_OBS_ASSESSMENT_OPEN.mlm @@ -0,0 +1,47 @@ +maintenance: + + title: DOC_OBS_ASSESSMENT_OPEN;; + mlmname: DOC_OBS_ASSESSMENT_OPEN;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Juliet M. Law;; + specialist: ;; + date: 2016-01-25;; + validation: testing;; + +library: + purpose: + ;; + explanation: + + + Change history + + 01.25.2016 JML CSR 33953 Created; copied from DOC_ADULT_ASSESSMENT_OPEN + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Receive arguments from the flowsheet + (thisDocumentCommunication) := argument; + + Doc_VTE_Override := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_VTE_PHYSICIAN_OVERRIDE{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL Doc_VTE_Override WITH thisDocumentCommunication; + + //Call MLM to alert on urinary catheter risk assessment + DocCatheterRiskObs := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_URINARY_CATHETER_CHART_ALERT{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocCatheterRiskObs WITH thisDocumentCommunication; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_OUTPATIENT_CLOSE.mlm b/MLMStripper/bin/Debug/DOC/DOC_OUTPATIENT_CLOSE.mlm new file mode 100644 index 0000000..d71b6e5 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_OUTPATIENT_CLOSE.mlm @@ -0,0 +1,41 @@ +maintenance: + + title: DOC_OUTPATIENT_CLOSE;; + mlmname: DOC_OUTPATIENT_CLOSE;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Shawn Head x7468;; + specialist: ;; + date: 2017-08-23;; + validation: testing;; + +library: + purpose: + ;; + explanation: This MLM will call functional MLMs to be run upon close of the Outpatient documents + + Change history + + 8/25/2017 - CSR#: 35320 - STH - Created + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + (thisDocumentCommunication) := argument; + PrintReports := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_PRINT_OUTPATIENT_REPORTS{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL PrintReports WITH thisDocumentCommunication; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_OUTPATIENT_OPEN.mlm b/MLMStripper/bin/Debug/DOC/DOC_OUTPATIENT_OPEN.mlm new file mode 100644 index 0000000..cbf05a0 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_OUTPATIENT_OPEN.mlm @@ -0,0 +1,45 @@ +maintenance: + + title: DOC_OUTPATIENT_OPEN;; + mlmname: DOC_OUTPATIENT_OPEN;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Shawn Head x7468;; + specialist: ;; + date: 2017-08-23;; + validation: testing;; + +library: + purpose: + ;; + explanation: This MLM will call functional MLMs to be run upon open of the Outpatient documents + + Change history + + 8/23/2017 - CSR#: 35320 STH - Created + 10/8/2019 - SZ - CSR # 37979 - preferred pharmacy for doc changes + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + (thisDocumentCommunication) := argument; + ClearPrintButton := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_OUTPATIENT_CLEARPRINTBUTTON{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL ClearPrintButton WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + PreferredPharmacyTextBox := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_PREFERRED_PHARMACY_TEXT_BOX{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL PreferredPharmacyTextBox WITH thisDocumentCommunication; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_PATIENT_PROFILE.mlm b/MLMStripper/bin/Debug/DOC/DOC_PATIENT_PROFILE.mlm new file mode 100644 index 0000000..9327022 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_PATIENT_PROFILE.mlm @@ -0,0 +1,112 @@ +maintenance: + + title: Patient Profile Assessments;; + mlmname: DOC_Patient_Profile;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Teresa Spicuzza;; + specialist: ;; + date: 2010-02-03;; + validation: testing;; + +library: + purpose: + ;; + explanation: + + + Change history + + 09.09.2010 TS Copied from DOC_MD_PROGRESSNOTE + 09.07.2011 JL Added call to DOC_FUNC_PT_CONSULT_FROM_ADM_OBS + 02.09.2012 DW CSR# 26945 Added call to DOC_FUNC_ADVANCE_DIRECTIVE + 03.06.2012 JL Removed call to DOC_FUNC_PT_CONSULT_FROM_ADM_OBS due to issues noted with solution by Deb Rudar. + 11.15.2012 DW CSR# 30902 POLST + 07.19.2013 DW CSR# 31450 Free Text Meds + 12.-8.2015 GOS CSR#33338- CHF Pharmacy Insuranse MLM + 05.23.2016 DJW CSR#34250 PAWSS + 08.22.2016 DJW CSR# 34849 Patient Header Visit Count Readmission Monitoring + 10.25.2017 SA CSR# 36043 Added call to MLM DOC_SCH_CREATE_CARE_TRANSITION_CONSULT + 10.30.2017 DW CSR# 36030 Elder Risk (renamed Risk Category then renamed Readmission Risk) + 07.25.2018 DW CSR# 36510 Harm to Self or Others - Changes required for inpatient processes + 09.23.2019 JML CSR# 38601/38606 - Display alert on Doc close for Adult Patient Profile - BH Outpatient + when user answers {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to questions under Nutrition / Abuse sections + + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + DocInfluenza := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_INFLUENZA{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocInfluenza WITH thisDocumentCommunication; +// + (thisDocumentCommunication) := argument; + DocPneumovax := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_PNEUMOVAX{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocPneumovax WITH thisDocumentCommunication; +// + (thisDocumentCommunication) := argument; + DocDiabetesRisk := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_DIABETESRISK{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocDiabetesRisk WITH thisDocumentCommunication; +// + (thisDocumentCommunication) := argument; + DocMRSAScreen := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_MRSA_Screen{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocMRSAScreen WITH thisDocumentCommunication; +// + (thisDocumentCommunication) := argument; + DocDTAP := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_ADVANCE_DIRECTIVE{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocDTAP WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + DocDTAP := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_POLST{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocDTAP WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + DocDTAP := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_TDAP{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocDTAP WITH thisDocumentCommunication; + + //(thisDocumentCommunication) := argument; + //DocDTAP := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_FREE_TEXT_MEDS{{{SINGLE-QUOTE}}}; + //thisDocumentCommunication := CALL DocDTAP WITH thisDocumentCommunication; + + // Added By Shivprasad On 08 Dec 2015 for CSR#33338- CHF Pharmacy Insuranse MLM + (thisDocumentCommunication) := argument; + DocCHF := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_ACUTE_CHF_CRITERIA{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocCHF WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + DocPAWSS := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_PAWSS{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocPAWSS WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + DocPatientHeaderVisitCount := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_PATIENT_HEADER_VISIT_COUNT{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocPatientHeaderVisitCount WITH thisDocumentCommunication; + + CareTransitionConsultOrder := MLM {{{SINGLE-QUOTE}}}DOC_SCH_CREATE_CARE_TRANSITION_CONSULT{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL CareTransitionConsultOrder WITH thisDocumentCommunication; + + //Call MLM to create calculate Risk Category + RiskCategory := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_RISK_CATEGORY{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL RiskCategory WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + Suicideorviolent := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_SUICIDAL_OR_VIOLENT{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL Suicideorviolent WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + BHAlerts := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_BEHAVIORAL_HEALTH_OUTPATIENT_ALERTS{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL BHAlerts WITH thisDocumentCommunication; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_PATIENT_PROFILE_INFUSION_OPEN.mlm b/MLMStripper/bin/Debug/DOC/DOC_PATIENT_PROFILE_INFUSION_OPEN.mlm new file mode 100644 index 0000000..b1d8352 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_PATIENT_PROFILE_INFUSION_OPEN.mlm @@ -0,0 +1,56 @@ +maintenance: + + title: DOC_PATIENT_PROFILE_INFUSION_OPEN;; + mlmname: DOC_PATIENT_PROFILE_INFUSION_OPEN;; + arden: version 5.5;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Juliet M. Law;; + specialist: ;; + date: 2013-03-07;; + validation: testing;; + +library: + purpose: + ;; + explanation: + + + + Change history + + 03.07.2013 JML Created + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Recieve arguments from the structured note + + (thisDocumentCommunication) := argument; + DocDTAP := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_GENERIC_MANDATORY_BY_OCCUPATION{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocDTAP WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + DocDTAP2 := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_ADVANCE_DIRECTIVE{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocDTAP2 WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + DocPressureUlcer := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_PRESSURE_ULCER_HEALTH_ISSUE{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocPressureUlcer WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + PreferredPharmacyTextBox := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_PREFERRED_PHARMACY_TEXT_BOX{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL PreferredPharmacyTextBox WITH thisDocumentCommunication; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end:', N'f2d958be-1488-422b-960b-ea90380f5de9', 2, N'DOC_PATIENT_PROFILE_INFUSION_OPEN', N'5.5', N'2.50', CAST(N'2013-03-07T00:00:00.000' AS DateTime), N'31f896ce-340a-ea11-a83f-005056ba872e') diff --git a/MLMStripper/bin/Debug/DOC/DOC_PATIENT_PROFILE_OPEN.mlm b/MLMStripper/bin/Debug/DOC/DOC_PATIENT_PROFILE_OPEN.mlm new file mode 100644 index 0000000..89c30b4 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_PATIENT_PROFILE_OPEN.mlm @@ -0,0 +1,99 @@ +maintenance: + + title: Patient Profile Assessments Open;; + mlmname: DOC_Patient_Profile_Open;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Teresa Spicuzza;; + specialist: ;; + date: 2010-02-03;; + validation: testing;; + +library: + purpose: + ;; + explanation: + + + + Change history + + 02.14.2012 DW CSR# 26945 Created to add a call for DOC_FUNC_ADVANCE_DIRECTIVE + 03.06.2012 JML CSR# 26746 Added a call to DOC_FUNC_PSYCH_OUTPATIENT_PROFILE_FALL_RISK_MEDS_OBS + 08.22.2012 JML CSR# 26414 Added a call to DOC_FUNC_ADULT_PATIENT_PROFILE_CHF + 11.15.2012 DW CSR# 30902 POLST + 01.01.2013 Chintan Tilwa(Allscripts) Added a call to DOC_SCH_Readmission_Risk_Assessments + 05.01.2013 JML CSR# 31395 Added a call to DOC_FUNC_PRESSURE_ULCER_HEALTH_ISSUE + 04.16.2014 DW CSR# 31688 Added a call to Doc_Func_ORM_Orders_Requiring_Followup + 06.10.2014 DW CSR# 31688 Reversed the change above. It was later decided that this is unneded + 05.23.2016 DJW CSR#34250 PAWSS + 08.17.2016 JML Removed calls to Readmission Risk MLMs, which was causing other MLMs to fail + 02.17.2017 STH CSR#: 35129 - ADDED CALL TO DOC_FUNC_HEP_C_SCREENING + 06.21.2017 SZ CSR #35712 Preferred Pharmacy Text Box + 07.26.2017 SZ CSR #35278 Care Transitions note - Preferred Pharmacy Text Box + 07.25.2018 DW CSR# 36510 Harm to Self or Others - Changes required for inpatient processes + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Receive arguments from the structured note + + (thisDocumentCommunication) := argument; + DocDTAP := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_GENERIC_MANDATORY_BY_OCCUPATION{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocDTAP WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + DocDTAP1 := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_ADVANCE_DIRECTIVE{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocDTAP1 WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + DocDTAP2 := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_POLST{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocDTAP2 WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + DocFallRisk := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_PSYCH_OUTPATIENT_PROFILE_FALL_RISK_MEDS_OBS{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocFallRisk WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + DocCHF := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_ADULT_PATIENT_PROFILE_CHF{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocCHF WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + DocPressureUlcer := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_PRESSURE_ULCER_HEALTH_ISSUE{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocPressureUlcer WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + DocPAWSS := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_PAWSS{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocPAWSS WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + HepScreen := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_HEP_C_SCREENING{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL HepScreen with thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + PreferredPharmacyTextBox := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_PREFERRED_PHARMACY_TEXT_BOX{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL PreferredPharmacyTextBox WITH thisDocumentCommunication; + + + (thisDocumentCommunication) := argument; + AutoSelectCareTransition := MLM {{{SINGLE-QUOTE}}}DOC_SCH_AUTOSELECT_Care_Transition_Needs_Assessment{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL AutoSelectCareTransition WITH thisDocumentCommunication; + + + (thisDocumentCommunication) := argument; + Suicideorviolent := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_SUICIDAL_OR_VIOLENT{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL Suicideorviolent WITH thisDocumentCommunication; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_PEDIATRIC_HUMPTY_DUMPTY_AGEGENDER.mlm b/MLMStripper/bin/Debug/DOC/DOC_PEDIATRIC_HUMPTY_DUMPTY_AGEGENDER.mlm new file mode 100644 index 0000000..f0d309f --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_PEDIATRIC_HUMPTY_DUMPTY_AGEGENDER.mlm @@ -0,0 +1,142 @@ +maintenance: + + title: DOC_Pediatric_Humpty_Dumpty_AgeGender ;; + mlmname: DOC_Pediatric_Humpty_Dumpty_AgeGender ;; + arden: version 6.1;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Shivprasad Jadhav ;; + specialist: Shivprasad Jadhav, Allscripts Corporation;; + date: 2015-10-12;; + validation: testing;; + +library: + purpose: Autoselect [Age] and [Gender] of Patient on [2.Pediatric assessment/Intervention] flowsheet under Humpty-Dumpty observation set. + ;; + explanation: + + Change history + + 2015-01-10 GOS CSR 32399 : Create date. + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // Receive arguments from the structured note + (this_documentCommunication) := argument; + + /******************************************************************************/ + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid, ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + //Set Flowsheet DocumentCommunication object model variables via Called MLM + (this_fs_doc) := this_documentCommunication.DocumentConfigurationObj; + (this_parameters) := this_fs_doc.ParametersList; + (this_currentObs) := this_documentCommunication.CurrentObservationObj; + (this_cols) := this_fs_doc.ColumnsList; + (this_curr_col) := this_fs_doc.CurrentColumn; + (this_chartedObs) := this_curr_col.ChartedObservationsList; + + document_type := this_documentCommunication.DocumentType; + event_type := this_documentCommunication.EventType; + + client_guid := this_documentCommunication.ClientGUID; + visit_guid := this_documentCommunication.ClientVisitGUID; + chart_guid := this_documentCommunication.ChartGUID; + + Age := Read First{"Select dbo.AgeCalculation22(cv.ClientGuid, Getdate(), {{{SINGLE-QUOTE}}}y{{{SINGLE-QUOTE}}}) " + || " from cv3ClientVisit cv With (nolock) Join cv3Client c With (nolock) on c.guid=cv.ClientGUID And cv.guid = " || visit_guid ||" "} ; + Gender := Read First{"Select c.GenderCode " + || " from cv3ClientVisit cv With (nolock) Join cv3Client c With (nolock) on c.guid=cv.ClientGUID And cv.guid = " || visit_guid ||" "} ; + If Age < 3 Then + Age_Val := "Less than 3 years old"; + Elseif Age >=3 and Age < 7 Then + Age_Val := "3 to less than 7 years old"; + Elseif Age >=7 and Age < 13 Then + Age_Val := "7 to less than 13 years old"; + Elseif (Age > 13) or (Age =13) Then + Age_Val := "13 years and above"; + Endif; + + If Gender ="Male" Then + Gender_Val:= "Male"; + Elseif Gender = "Female" Then + Gender_Val:= "Female"; + Endif; + + // for Age Selection + Prm_Age := first of ( this_parameters where this_parameters.Name = "SCHCK_PAI_Age A"); + //Prm_Focus := first of ( this_parameters where this_parameters.Name = "schck_pai_ High risk protocol" ); //"SCHCK_PAI_Cognitive Impairment D" "SCHCK_PAI_Environmental Factor E"); + + If exists Prm_Age Then + + this_currentObj2 := NEW ObservationType; + this_currentObj2.ClientDocumentGUID := this_fs_doc.ClientDocumentGUID; + this_currentObj2.ParameterGUID := Prm_Age.ParameterGUID; + this_currentObj2.DataType := "ListValue"; + this_currentObj2.ValueObj := NEW ListValueType; + this_currentObj2.ValueObj.ListGUID := Prm_Age.ConfigurationObj.ListGUID; + listItems := (); + //abb := Prm_Age.ConfigurationObj.ListItemsList.Records__ ; + for item IN Prm_Age.ConfigurationObj.ListItemsList do // Need to Pass the Value as Item for {{{SINGLE-QUOTE}}}LISTITEM{{{SINGLE-QUOTE}}} + + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + If Item.Value = Age_Val Then + selectedItem.IsSelected := true; + Else + selectedItem.IsSelected := False; + EndIf; + listItems := (listItems, selectedItem); + Enddo; + + this_currentObj2.ValueObj.ListItemsList := listItems; + this_fs_doc.CurrentColumn.ChartedObservationsList := (this_fs_doc.CurrentColumn.ChartedObservationsList, this_currentObj2 ); + EndIf; + + // for Gender Selection + Prm_Gender := first of ( this_parameters where this_parameters.Name = "SCHCK_PAI_Gender B"); + If exists Prm_Gender Then + + this_currentObj3 := NEW ObservationType; + this_currentObj3.ClientDocumentGUID := this_fs_doc.ClientDocumentGUID; + this_currentObj3.ParameterGUID := Prm_Gender.ParameterGUID; + this_currentObj3.DataType := "ListValue"; + this_currentObj3.ValueObj := NEW ListValueType; + this_currentObj3.ValueObj.ListGUID := Prm_Gender.ConfigurationObj.ListGUID; + listItems := (); + for item IN Prm_Gender.ConfigurationObj.ListItemsList do // Need to Pass the Value as Item for {{{SINGLE-QUOTE}}}LISTITEM{{{SINGLE-QUOTE}}} + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + If Item.Value = Gender_Val Then + selectedItem.IsSelected := true; + Else + selectedItem.IsSelected := False; + EndIf; + listItems := (listItems, selectedItem); + Enddo; + + this_currentObj3.ValueObj.ListItemsList := listItems; + this_fs_doc.CurrentColumn.ChartedObservationsList := (this_fs_doc.CurrentColumn.ChartedObservationsList, this_currentObj3 ); + EndIf; + // To Set focus on 4rth observation + + //this_documentCommunication.FocusParameterGUID := Prm_Focus.ParameterGUID; + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_PEL_UPDATE.mlm b/MLMStripper/bin/Debug/DOC/DOC_PEL_UPDATE.mlm new file mode 100644 index 0000000..b76f0f1 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_PEL_UPDATE.mlm @@ -0,0 +1,346 @@ +maintenance: + + title: DOC_PEL_UPDATE;; + mlmname: DOC_PEL_UPDATE;; + arden: version 2.5;; + version: 1.02;; //Release 5.5 SP1/FP1 and 6.0/6.1 SU2 and higher + institution: Speed to Value, Allscrtips;; + author: S2V, Philip Thomas (MODIFIED BY SHAWN HEAD);; + specialist: Allscripts Corporation (PLT) (MODIFIED BY SHAWN HEAD);; + date: 2014-06-06;; + validation: testing;; + +library: + purpose: + + This MLM will update the Patient Education Log based upon the Education Outcome Record being charted. For education to be charted you + must attach a Coding Standard of PEL_OBS to the observartion item you want to write to the education log. The education observartion needs to + be a fan out obeservation that will be suggested based on specific Plan of Care{{{SINGLE-QUOTE}}}s. Initially this was setup for COPD, Trauma/Injusry Risk, + Total Knee, Total Hip, and Pneumonia. + ;; + explanation: + This MLM will add a row to the Patient Education Log based upon a observation being charted on the Education outcome Record by calling the stored procedure SXAAmbPatEdLogInsPr to update the Patient Education Log. + + The MLM is triggered based upon the observation having a coding standard of PEL_OBS added to the configuration AND a value being selected that does not contain the word "refused". + + The MLM is currently hardcoded to NOT allow duplicates. In the future if we need to change this we can use a class type or other SCM configuration + elements to identify if it should allow duplicates or not. This is hardcoded as NO_Duplicates = true. + + Allscripts provided this use for the no_duplicates workflow; however at this point we have it hardcoded to true. + If the Class Type Value is "Update All Worklist Events" Then Duplicate entries will be created for this Order Task on the patient chart for each time the task is completed. + If the Class Type Value is "Update Once Per Document Name + Visit + Location" Then NO Duplicate entries if it is the same document name and patient location and visit combined. + -This is the recommended setting to avoid multiple entries for a task that is reset and then marked as done multiple times. + + Any other class type values will create duplicate Education Log entry for each time the task is completed (default behavior). + + + The MLM will update the Education Log with the following parameters: + Education Document Name = Description from Coding Stadandard PEL_OBS added to observartion; // Passed Education Document Name (The Education Order Name) + Document Source = Coded Value from the coding standard PEL_OBS added to observartion; // Hard Coded in MLM as the passed Document Source + User_GUID = EvokingObject.PerformedProviderGUID; // The Task completion Given By user GUID + USER_ID = user_id; // task Entry User ID (not seen) + Education Given Date = charted column date/time // Sets the Education date and time to the task documented values + Comment = not used at this time. // The Education Log comment section from the configured task documentation summary line (accepts 4000 characters) + + Note: The Outcomes cannot be updated with this MLM + + SCM Configuration Tasks: + 1. Add a coding standard to the observation that needs to write to the education log with the coding standard of PEL_OBS + + 2. Set the coded value to the source you want written in the patient education log. + NOTE: Initial install only has Education Outcome Record + + 3. Add a name of the edcucation provided to the Description. This should be the specific education that is being provided to the patient. + NOTE: Initial install only had COPD, Pneumonia, Total Knee, Total Hip, and Trauma/Injury Risk. + + + + Modification history: + + + *** Allscripts Disclaimer: + Client is responsible for all decisions, acts, and omissions of any persons in connection with the delivery of medical care or other services to any patients. + Before any Licensed Materials are placed into a live production environment, it is Client’s responsibility to review and test all Licensed Materials and associated + workflows and other content, as implemented, make independent decisions about system settings and configuration based upon Client’s needs, practices, standards and + environment, and reach its own independent determination that they are appropriate for such live production use. Any such use by Client (or its Authorized Users) + will constitute Client’s representation that it has complied with the foregoing. Client shall ensure that all Authorized Users are appropriately trained in use of + the then-deployed release of the Software prior to their use of the Software in a live production environment. Clinical Materials are tools to assist Authorized + Users in the delivery of medical care, but should not be viewed as prescriptive or authoritative. Clinical Materials are not a substitute for, and Client shall + ensure that each Authorized User applies in conjunction with the use thereof, independent professional medical judgment. Clinical Materials are not designed for use, + and Client shall not use them, in any system that provides medical care without the participation of properly trained personnel. Any live production use of Clinical + Materials by Client (or its Authorized Users) will constitute Client’s acceptance of clinical responsibility for the use of such materials. + + 2014-06-10 STH CSR#: 31688 (MU2) - Modified S2V Sample MLM to use the flowsheet / Plan of Care observations to write to the Patient Education Log based on Kathy Baumgarten approval. + 07.23.2019 TMS CSR#: 37676 - Change log_execution_info to false per upgrade analysis. + ;; +keywords: Objects Plus, Education Log, Worklist, ARRA + ;; +knowledge: + type: data-driven;; + data: + + mlm_name := "DOC_PEL_UPDATE"; + + CR := 13 formatted with "%c"; + LF := 10 formatted with "%c"; + CRLF:= CR||LF; + + //Set to true if a decision.log is needed for diagnostic purposes. Please refer to the CDS Authoring Guides for more information + log_execution_info:= false; + + // Specify which .NET assemblies need to be loaded for ObjectsPlus + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + set_cds_vars := MLM {{{SINGLE-QUOTE}}}CALLED_DOC_FS_DEFINITION_MLM{{{SINGLE-QUOTE}}}; + + + //--------------------------------------------------------------- + // Error destination + //--------------------------------------------------------------- + //"SYSTEM ALERT", + error_destination := destination { Alert } with [ + alert_type := "warning", + short_message := "ObjectsPlus Error from MLM", + priority := "low", + scope := "chart", + Rule_group := "ObjectsPlus Error from MLM", + Rule_number := 1003, + Rule_subgroup := "", + Send_alert_with_order := "", + Alert_dialog_settings := "", + Display_alert := true ]; + + // Receive arguments from the structured note + (this_DocumentCommunication) := argument; + + // Get the user, chart, client and visit GUIDs + if called_by_editor then + userguid := ""; + clientGuid := "9000001860200200"; //Admission, Holly + clientvisitguid := "9000003613200270";//Admission, Holly + chartguid := "9000003613100170";//Admission, Holly + else + userGuid := this_DocumentCommunication.UserGUID; + clientGuid := this_DocumentCommunication.ClientGUID; + clientvisitGuid := this_DocumentCommunication.ClientVisitGUID; + chartGuid := this_DocumentCommunication.ChartGUID; + endif; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + ListValueType := OBJECT [ListGuid, ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + Education_Observartions := OBJECT [SCM_Obs_Name,PEL_SCM_Source,PEL_SCM_DocumentName]; + + //Document Type + FLOWSHEET := "FlowSheet"; + + //Event Types + CHARTOBSERVATION := "ChartObservation"; + DOCUMENTCLOSING := "DocumentClosing"; + DOCUMENTOPENING := "DocumentOpening"; + + (this_documentCommunication, client_guid, client_visit_guid, chart_guid, + user_guid, document_type, document_name, event_type, + configuration_guid, this_currentObs, CancelEventFlag, this_fs_doc, + authored_by_guid, isIOFlowsheetFlag, client_document_guid, this_parameters, + this_columnList, this_currentColumn, this_chartedObservationsList, + this_parameters_displayName, current_parameter, current_parameter_name, current_parameter_guid, + current_parameter_datatype, selectedItems, selectedItems_Value, current_value, + diagnostic_message, displayMessageFlag) := CALL set_cds_vars WITH (this_documentCommunication); + + Error_occurred := false; + SCM_Observartions := new Education_Observartions; + + //get a list of observations that exist in the our observartion catalog that have the PEL_OBS coding standard added to them. + (PEL_OBS_Names, PEL_Source,PEL_Matieral ) := read {" select oci.Name, " + || " oc.CodedValue, oc.CodeDescription from CV3ObsCatalogItem oci " + || " inner join SCMObsCodedValue oc on oci.MasterObsGUID = oc.ParentGUID " + || " where oc.CodingStandards = {{{SINGLE-QUOTE}}}PEL_OBS{{{SINGLE-QUOTE}}} " + || " and oc.active = 1 " + || " and oci.Active = 1 "}; + + //create a list of observation names, configured source, and configured education description based on the coding standard configuration added to the observations in SCM. + SCM_Observartions.SCM_Obs_Name := PEL_OBS_Names; + SCM_Observartions.PEL_SCM_Source := PEL_Source; + SCM_Observartions.PEL_SCM_DocumentName := PEL_Matieral; + + //create a list of charted parameters that exist in the list of observartion names created above. + charted_parameters := (this_parameters where this_parameters.Name is in PEL_OBS_Names); + + //loop through all the charted observrations that also have the proper coding standard added to them to determine in and education log entry needs written into + //the patient education log. + for x in (1 seqto(count(charted_parameters))) do + + + Education_obs := charted_parameters[x]; + //If there are eudcation observations in the charted parameter list then we will continue otherwise the next charted_parameter will be checked until the end of the list. + if ( exists Education_obs ) then + + //get the current column and current charted parameter value based on the education obs cound in the lists. + theCurrentColumn := first of ( this_columnList WHERE this_columnList.ClientDocumentGUID = this_currentObs.ClientDocumentGUID); + current_obs := first of ( theCurrentColumn.ChartedObservationsList WHERE theCurrentColumn.ChartedObservationsList.ParameterGUID = Education_obs.ParameterGUID); + + //as long as the current observartion being charted is in the current column continue otherwise move on and check the next paramter item. + if (exists current_obs) then + //create a list of all the selected values in the lists + Education_ListItemsList := current_obs.ValueObj.ListValuesList.ListItemsList; + All_Education_values := (); + //this for loop combines all the lists. in the inital release verison there are 3 list sets and this will combine them into 1 list. + for y in (1 seqto(count(Education_ListItemsList))) do + All_Education_values := All_Education_values, Education_ListItemsList[y]; + enddo; + + //create a new education list items object to parse through and verify if and what to be added to the education log. + Education_lists_items_obj := new ListValueListItemType; + Education_lists_items_obj := (All_Education_values where All_Education_values.IsSelected = true); + + //creates a variable for the stored procedure observartion name(s) in the list. + SP_Obs_Name := last of (SCM_Observartions.SCM_Obs_Name + where SCM_Observartions.SCM_Obs_Name = Education_obs.Name); + + //creates a variable for the stored procedure observartion source(s) in the list. + SP_Obs_Source := last of (SCM_Observartions.PEL_SCM_Source + where SCM_Observartions.SCM_Obs_Name = Education_obs.Name); + + //creates a variable for the stored procedure observartion Education Document Name(s) in the list. + SP_Obs_DocumentName := last of (SCM_Observartions.PEL_SCM_DocumentName + where SCM_Observartions.SCM_Obs_Name = Education_obs.Name); + + //create a variable for the visit GUID + SP_Visit_GUID := clientvisitGuid; + + //Get the Current Location information + SP_Location_GUID1 := read last {"select CurrentLocationguid " + || " from CV3ClientVisit " + || " where clientguid = " || sql(clientGuid) + || " and ChartGUID = " || sql(chartguid) + || " and guid = " || sql(clientvisitguid) + || " "}; + + //create the other stored procedure values required. + SP_Location_GUID := SP_Location_GUID1 AS NUMBER; + SP_User_GUID := this_DocumentCommunication.UserGUID as number;//"9000002815101190";//user_GUID; + SP_USER_ID := read last { "select IDCode from cv3user where guid = " || sql(SP_User_GUID) }; + SP_Comment := ""; + NO_Duplicates := TRUE; + SP_Given_DTM := theCurrentColumn.DateTime;//"2014-03-20 01:00:00.000"; + + //check to see if "refused" was selected or if there are no items selected at all. + if "refused" in Education_lists_items_obj.Value or count(Education_lists_items_obj) = 0 then + (LOG_TouchedBy, LOG_PatEducationLogID, LOG_ReplTrans) := READ LAST + {" SELECT top 1 LOG.TouchedBy, LOG.PatEducationLogID, LOG.MSrepl_tran_version " + || " FROM SXAAMBPatientEducationLog LOG LEFT JOIN CV3CareProvider ON CV3CareProvider.GUID = LOG.ProviderGUID" + || " LEFT JOIN CV3Location ON CV3Location.GUID = LOG.LocationGUID INNER JOIN CV3ClientVisit ON CV3ClientVisit.GUID = LOG.ClientVisitGUID" + || " INNER JOIN SXAAMBPatientEducationDoc DOC ON DOC.PatEducationDocID = LOG.PatEducationDocID" + || " WHERE CV3ClientVisit.ClientGUID = " || sql(ClientGUID) || " AND CV3ClientVisit.GUID = " || SQL(ClientVisitGUID) + || " AND DOC.DocName = " || SQL(SP_Obs_DocumentName) || " AND CV3Location.GUID = " || SQL(SP_Location_GUID) || " AND LOG.Active = 1" + || " ORDER BY LOG.EducationDtm DESC"}; + //Do not update the Stored Procedure if a duplicate is found for the same Document Name + Visit + Location + + //check to see if the above SQL found an entry in the table for the current education entry. If so delete or deactivate it + If LOG_ReplTrans Is not NULL then + return_status := read {" SXAAmbPatEdLogDelPr " + || " @UserName=" || SQL(LOG_TouchedBy) || "," + || " @PatEducationLogID=" || SQL(LOG_PatEducationLogID) || "," + || " @MSrepl_tran_version=" || SQL(LOG_ReplTrans) }; + Endif; + else + //if refused is not selected AND there are at least 1 item selected in the lists associated with the observartion then we need to add + //the entry to the patient eduaction log. + call_procedure := true; + //If the setting to block duplicate entries based upon Document Name + Visit + Location is enabled then query the + // Education Log to see if an entry already exisits. Ignore update if a record is found. + If NO_Duplicates AND SP_Obs_DocumentName Is Not NULL then + + (LOG_Visit_Number, LOG_Visit_GUID, LOG_DOC_Name, LOG_DOC_Source, LOG_ED_DTM, LOG_Provider_GUID, LOG_Location_GUID, + LOG_Provider_Name, LOG_Location, LOG_ID, LOG_Active, LOG_Comment) := READ LAST + {" SELECT CV3ClientVisit.VisitIDCode as VisitNumber, LOG.ClientVisitGUID as VisitGUID, DOC.DocName, DOC.DocSource," + || " LOG.EducationDtm AS EducationDTM, LOG.ProviderGUID, LOG.LocationGUID, CV3CareProvider.DisplayName," + || " CV3Location.Name AS LocationName, LOG.PatEducationLogID AS GUID, LOG.Active, LOG.Comment" + || " FROM SXAAMBPatientEducationLog LOG LEFT JOIN CV3CareProvider ON CV3CareProvider.GUID = LOG.ProviderGUID" + || " LEFT JOIN CV3Location ON CV3Location.GUID = LOG.LocationGUID INNER JOIN CV3ClientVisit ON CV3ClientVisit.GUID = LOG.ClientVisitGUID" + || " INNER JOIN SXAAMBPatientEducationDoc DOC ON DOC.PatEducationDocID = LOG.PatEducationDocID" + || " WHERE CV3ClientVisit.ClientGUID = " || sql(ClientGUID) || " AND CV3ClientVisit.GUID = " || SQL(ClientVisitGUID) + || " AND DOC.DocName = " || SQL(SP_Obs_DocumentName) || " AND CV3Location.GUID = " || SQL(SP_Location_GUID) || " AND LOG.Active = 1" + || " ORDER BY LOG.EducationDtm DESC"}; + //Do not update the Stored Procedure if a duplicate is found for the same Document Name + Visit + Location + If LOG_ID Is not NULL then + Call_Procedure := FALSE; + Endif; + Endif; + + if SP_Location_GUID is null or SP_Location_GUID = "" or SP_User_GUID is null or SP_User_GUID = "" + or SP_Given_DTM is null or SP_Given_DTM = "" or SP_Visit_GUID is null or SP_Visit_GUID = "" + or SP_Obs_DocumentName is null or SP_Obs_DocumentName = "" or SP_Obs_Source is null or SP_Obs_Source = "" + or SP_USER_ID is null or SP_USER_ID = "" then + + Error_occurred := true; + error_message := "Missing required information: " || crlf; + error_message := error_message || "Location GUID =" || SP_Location_GUID || crlf; + error_message := error_message || "User GUID =" || SP_User_GUID || crlf; + error_message := error_message || "User User ID =" || SP_USER_ID || crlf; + error_message := error_message || "User Give DTTM =" || SP_Given_DTM || crlf; + error_message := error_message || "User Give Visit GUID =" || SP_Visit_GUID || crlf; + error_message := error_message || "User Give DocumentName=" || SP_Obs_DocumentName || crlf; + error_message := error_message || "User Give Source=" || SP_Obs_Source || crlf; + endif; + + //-----//Add an Entry to the Education Log by calling the Stored Procedure to insert a row + If SP_Obs_DocumentName IS NOT NULL and Error_occurred = FALSE and Call_Procedure = true then + return_status := read {" SXAAmbPatEdLogInsPr " + || " @LocationGUID=" || SQL(SP_Location_GUID) || "," + || " @VisitGUID=" || SQL(SP_Visit_GUID) || "," + || " @DocumentName=" || SQL(SP_Obs_DocumentName) || "," + || " @DocumentSource=" || SQL(SP_Obs_Source) || "," + || " @EducationDate=" || SQL(SP_Given_DTM) || "," + || " @ProviderGUID=" || SQL(SP_User_GUID) || "," + || " @UserID=" || SQL(SP_USER_ID) || "," + || " @Comment=" || SQL(SP_Comment) || ",@PatEducationDocID=0"}; + + //If the SP Return Status is not the ED Doc ID then Trigger an Error Message + If return_status Is not number then + Error_occurred := true; + error_message := "Return Status: " || return_status; + Endif; + + endif; + + endif; + + endif; + endif; + enddo; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: + + //Conclude if results were found +// if Error_occurred then +// conclude false; +// else + conclude true; +// endif; + ;; + action: + + if Error_occurred then + write "An error has occured in the MLM {{+B}}" || mlm_name || "{{-B}} " + ||"Please notify your System Administrators that an error message has " + ||"occurred for this patient. They will review the following error " + ||"message: \n" at error_destination; + write error_message at error_destination; + //error_message + Endif; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_PRINT_ED_DCINST.mlm b/MLMStripper/bin/Debug/DOC/DOC_PRINT_ED_DCINST.mlm new file mode 100644 index 0000000..9e2fca2 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_PRINT_ED_DCINST.mlm @@ -0,0 +1,60 @@ +maintenance: + + title: DOC_PRINT_ED_DCINST;; + mlmname: DOC_PRINT_ED_DCINST;; + arden: version 2;; + version: 4.00;; + institution: St Clair Memorial Hospital;; + author: Shawn Head;; + specialist: ;; + date: 2014-01-23;; + validation: testing;; + +library: + purpose: This MLM calls an Objects+ DLL which processes SCM report requests. + + + This MLM will autoprint the ED Discharge instructions AND also send a PDF copy to the PDFHL7 folder + for Dan to process to an HL7 message and send it back into SCM documents tab. + + ;; + explanation: + + +Change history + + 1.23.2014 STH CSR#: 32009 - Created + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + log_execution_info:=FALSE; + + Report_Print_MLM := mlm {{{SINGLE-QUOTE}}}SCH_FUNC_PRINT{{{SINGLE-QUOTE}}}; + + + // New report version "may" be needed. Consult with report team. + + reportname := "ED Discharge Instructions_AP"; logicalprinter := "Ed logicare printer"; physicalprinter:= ""; + void := call Report_Print_MLM with(reportname, logicalprinter, physicalprinter); + + reportname := "ED Discharge Instructions_Text"; logicalprinter := "PDF-EDDCINST"; physicalprinter:= ""; + void := call Report_Print_MLM with(reportname, logicalprinter, physicalprinter); + + ;; + evoke: + ;; + logic: + + conclude true; + + ;; + action: //all of the action is done by the call to the FFI + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_READMISSION_RISK_PLANNING_CLOSE.mlm b/MLMStripper/bin/Debug/DOC/DOC_READMISSION_RISK_PLANNING_CLOSE.mlm new file mode 100644 index 0000000..6dad4ce --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_READMISSION_RISK_PLANNING_CLOSE.mlm @@ -0,0 +1,50 @@ +maintenance: + + title: DOC_READMISSION_RISK_PLANNING_CLOSE;; + mlmname: DOC_READMISSION_RISK_PLANNING_CLOSE;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Janet Nordin;; + specialist: Don Warnick;; + date: 2018-08-31;; + validation: testing;; + +library: + purpose: + ;; + explanation: + + + Change history + + 08.31.2018 DW CSR# 36721 Risk Score Enhancement - increase the score via the EPN - Created + 11.01.2017 DW CSR # 37570 Remove MLM from Care Transitions Consult + 01.23.2019 DW CSR # 37792 Re-introduce MLM from Care Transitions Consult + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + // Recieve arguments from the structured note + + (thisDocumentCommunication) := argument; + + CREATE_CARE_TRANSITION_CONSULT := MLM {{{SINGLE-QUOTE}}}DOC_SCH_CREATE_CARE_TRANSITION_CONSULT{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL CREATE_CARE_TRANSITION_CONSULT WITH thisDocumentCommunication; + + RiskCategory := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_RISK_CATEGORY{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL RiskCategory WITH thisDocumentCommunication; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_READMISSION_RISK_PLANNING_NOTE_MLM.mlm b/MLMStripper/bin/Debug/DOC/DOC_READMISSION_RISK_PLANNING_NOTE_MLM.mlm new file mode 100644 index 0000000..2c81d97 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_READMISSION_RISK_PLANNING_NOTE_MLM.mlm @@ -0,0 +1,308 @@ +maintenance: + + title: DOC_Readmission_Risk_Planning_Note_MLM;; + mlmname: DOC_Readmission_Risk_Planning_Note_MLM;; + arden: version 5.5;; + version: 15.10;; + institution: St.Clair Hospital;; + author: ;; + specialist: SHAMI SHARMA;; + date: 2018-03-05;; + validation: testing;; + +library: + purpose: + ;; + explanation: + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + /*------------------MAKE CHANGES IN THIS SECTION ONLY----------------------------*/ + RRP_Diet_consult_Order := "Dietitian Consult"; + RRP_Rehab_Order := "Cardiac/Pulmonary Rehab Screening"; + RRP_Edu_Order := "Diabetes Education, Outpatient"; + Pul_health_Order := "Pulmonary Health Education Consult"; + + DietConsult := ("SCH_RRP_Dietician Consult","SCH_RRP_COPD Dietician Consult","SCH_RRP_MI_Dietician Consult","SCH_RRP_DIab_Dietician Consult"); + Rehab_Screen := ("SCH_RRP_Cardiac Rehab Screening","SCH_RRP_COPD Pulmonary Rehab Screening Referral","SCH_RRP_MI_Cardiac Rehab Screening Referral"); + Diab_Edu_Ref := "SCH_RRP_DIab_Diabetes Education Referral"; + Smoker_Res := "SCH_RRP_Smoker_Provide Smoking Cessation resources as applicable"; + + FireOnRRP := "Readmission Risk Planning"; + // Default values when creating orders + SessionType := "Standard"; + SessionReason := ""; + RequestingSource := ""; + user_IDType := "Primary"; + order_creation_reason := "From MLM"; + + /*-----------------END EDIT SECTION---------------------------------------------*/ + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + set_cds_vars := MLM {{{SINGLE-QUOTE}}}CALLED_DOC_FS_DEFINITION_MLM{{{SINGLE-QUOTE}}}; + RRP_Auto_Order_mlm := MLM {{{SINGLE-QUOTE}}}SCH_Create_Readmission_Risk_Order{{{SINGLE-QUOTE}}}; + + Readmission_Risk_Order := destination { ObjectsPlus } with + [ alert_type := "Warning", + short_message := "Object created by MLM", + priority := "low", + scope := "chart", + rule_group := "Order Object", + rule_number := 2010 ]; + + error_destination := destination { Alert } with [ + alert_type := "Warning", + short_message := "ObjectsPlus Error from MLM", + priority := "low", + scope := "chart", + Rule_group := "ObjectsPlus Error from MLM", + Rule_number := 1003, + Rule_subgroup := "", + Send_alert_with_order := "", + Alert_dialog_settings := "", + Display_alert := true ]; + + (thisDocumentCommunication) := argument; + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (this_currentObs) := thisDocumentCommunication.CurrentObservationObj; + (this_cols) := thisStructuredNoteDoc.ColumnsList; + (this_curr_col) := thisStructuredNoteDoc.CurrentColumn; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + callingobsvals := thisDocumentCommunication.CurrentObservationObj; + callingobsname := first of (thisParameters where thisParameters.ParameterGUID = callingobsvals.ParameterGUID); + callingobs := first of (thisobservations where thisobservations.ParameterGUID = callingobsname.ParameterGUID); + + IF(callingobs.DataType = "ListValue") then + callingobsval := (callingobs.ValueObj.ListItemsList.Value where callingobs.ValueObj.ListItemsList.IsSelected = true); + Else + callingobsval := callingobs.ValueObj.Value; + endif; + for j in 1 seqto count callingobsval do + If EXISTS callingobsval[j] then + callingobsval := callingobsval[j]; + Endif; + Enddo; + + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + UserGuid := thisDocumentCommunication.UserGUID; + currentlocationGUID := read last { "select currentlocationguid from cv3clientvisit where clientguid = " || sql(clientGuid) || " and guid = " || sql(visitGuid) || " "}; + + Dup_RRPOrdersDiet := Read last { " select name from cv3order + where ClientGUID = " || sql(clientGuid) + || " and ClientVisitGUID = " || sql(visitGuid) + || " and name = {{{SINGLE-QUOTE}}}Dietitian Consult{{{SINGLE-QUOTE}}} + and orderstatuslevelnum < 55 and OrderStatusCode = {{{SINGLE-QUOTE}}}AUA1{{{SINGLE-QUOTE}}} and active = 1 " }; + Dup_RRPOrders_Rehab := Read last { " select name from cv3order + where ClientGUID = " || sql(clientGuid) + || " and ClientVisitGUID = " || sql(visitGuid) + || " and name ={{{SINGLE-QUOTE}}}Cardiac/Pulmonary Rehab Screening{{{SINGLE-QUOTE}}} + and orderstatuslevelnum < 55 and OrderStatusCode = {{{SINGLE-QUOTE}}}AUA1{{{SINGLE-QUOTE}}} and active = 1 " }; + Dup_RRPOrders_Edu := Read last { " select name from cv3order + where ClientGUID = " || sql(clientGuid) + || " and ClientVisitGUID = " || sql(visitGuid) + || " and name = {{{SINGLE-QUOTE}}}Diabetes Education, Outpatient{{{SINGLE-QUOTE}}} + and orderstatuslevelnum < 55 and OrderStatusCode = {{{SINGLE-QUOTE}}}AUA1{{{SINGLE-QUOTE}}} and active = 1 " }; + Dup_RRPOrders_Pulm := Read last { " select name from cv3order + where ClientGUID = " || sql(clientGuid) + || " and ClientVisitGUID = " || sql(visitGuid) + || " and name = {{{SINGLE-QUOTE}}}Pulmonary Health Education Consult{{{SINGLE-QUOTE}}} + and orderstatuslevelnum < 55 and OrderStatusCode = {{{SINGLE-QUOTE}}}AUA1{{{SINGLE-QUOTE}}} and active = 1 " }; + + if (Dup_RRPOrdersDiet is NULL OR Dup_RRPOrdersDiet ="") then + PlaceOrderConsult := true; + ELSE + PlaceOrderConsult := False; + Endif; + + If (Dup_RRPOrders_Rehab is NULL OR Dup_RRPOrders_Rehab ="") then + PlaceOrderRehab := true; + ELSE + PlaceOrderRehab := False; + endif; + + If (Dup_RRPOrders_Edu is NULL OR Dup_RRPOrders_Edu ="") then + PlaceOrderEdu := true; + ELSE + PlaceOrderEdu := False; + endif; + + if (Dup_RRPOrders_Pulm is NULL OR Dup_RRPOrders_Pulm ="") then + PlaceOrderPulm := true; + ELSE + PlaceOrderPulm := False; + endif; + + + IF (callingobsname.Name in DietConsult) THEN + + IF ( "Yes" in callingobsval AND PlaceOrderConsult) THEN + ChartAutoOrderDiet := true; + Order_Name := RRP_Diet_consult_Order ; + IF(callingobsname.Name = "SCH_RRP_Dietician Consult")THEN + Order_Reason := "Heart Savior Dietary Education"; + ELSEIF (callingobsname.Name = "SCH_RRP_COPD Dietician Consult") THEN + Order_Reason := "Heart Savior Dietary Education"; + ELSEIF (callingobsname.Name = "SCH_RRP_MI_Dietician Consult") THEN + Order_Reason := "Consult Dietary for Pulmonary Diet"; + ELSEIF (callingobsname.Name = "SCH_RRP_DIab_Dietician Consult") THEN + Order_Reason := "Diabetic Diet Education"; + ENDIF; + ELSEIF(PlaceOrderConsult = False)THEN + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with " Dietitian Consult Order is already placed on this patient", "Duplicate Order ","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + + ENDIF; + + IF(callingobsname.Name in Rehab_Screen) then + if("Yes" in callingobsval and PlaceOrderRehab) then + ChartAutoOrderRehab := true; + order_Name := RRP_Rehab_Order; + ELSEIF(PlaceOrderRehab = False)THEN + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with " Cardiac/Pulmonary Rehab Screening Order is already placed on this patient", "Duplicate Order ","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + ENDIF; + IF(callingobsname.Name in Diab_Edu_Ref) then + if("Yes" in callingobsval and PlaceOrderEdu) then + ChartAutoOrderEdu := true; + order_Name := RRP_Edu_Order; + ELSEIF(PlaceOrderEdu = False)THEN + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with " Diabetes Education, Outpatient Order is already placed on this patient", "Duplicate Order ","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + + ENDIF; + IF(callingobsname.Name in Smoker_Res) then + if("Yes" in callingobsval and PlaceOrderPulm) then + ChartAutoOrderPulm := true; + Order_Name := Pul_health_Order; + + ELSEIF(PlaceOrderPulm = False)THEN + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with " Pulmonary Health Education Consult Order is already placed on this patient", "Duplicate Order ","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + endif; + ENDIF; + + IF (ChartAutoOrderDiet OR ChartAutoOrderRehab OR ChartAutoOrderEdu OR ChartAutoOrderPulm) then + dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with + "Clicking Yes will automatically place an order for " || (order_Name as string) || ". \n\nAre you sure you want to place the order now?", + "Auto Order " || (order_Name as string) || "?", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + If ((dialogResult as string) in ("Yes")) then + + try + + // ClientVisit object + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey + with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + // GENERAL catalog item object + general_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName + with order_Name; + // CareProvider Object + requesting_care_provider_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey + with ((UserGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + + // Location Object + location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey + with ((currentlocationGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); + // Create GENERAL order + GeneralOrder_Obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder + with client_visit_obj, + general_catalog_item, + order_creation_reason, + requesting_care_provider_obj, + RequestingSource, + SessionType, + SessionReason, + location_obj, + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; + + if (order_Name = "Dietitian Consult") then + val1 := call GeneralOrder_obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with "NUTR_Consult Reasons",Order_Reason ; + endif; + + if (order_Name = "Cardiac/Pulmonary Rehab Screening") then + val2 := call GeneralOrder_obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with "Cardiac/Pulmonary Rehab Screening","Other (Specify in Comment Section Below)" ; + GeneralOrder_obj.SpecialInstructions := "Set up for Outpatient Services" ; + Endif; + + + if (order_Name = "Diabetes Education, Outpatient") then + GeneralOrder_obj.SpecialInstructions := "Screen for Outpatient Services" ; + endif; + + if (order_Name = "Pulmonary Health Education Consult") then + val5 := call GeneralOrder_obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with "RESP Pulmonary Health Education","Smoking Cessation" ; + GeneralOrder_obj.SpecialInstructions := "Smoker" ; + endif; + + GeneralOrder_obj.RequestedDate := "T"; + + void := call GeneralOrder_Obj.Save; + void := call GeneralOrder_Obj.Dispose; + + endtry; + + // Exception Handling + catch Exception ex + error_occurred := true; + error_message := "{{+R}}New General order:{{-R}}\n" || + ex.Message || "\n\n"; + endcatch; + + // Clean UP + if (location_obj IS NOT NULL) then + void := call location_obj.Dispose; + location_obj := NULL; + endif; + + if (requesting_care_provider_obj IS NOT NULL) then + void := call requesting_care_provider_obj.Dispose; + requesting_care_provider_obj := NULL; + endif; + + if (general_catalog_item IS NOT NULL) then + void := call general_catalog_item.Dispose; + general_catalog_item := NULL; + endif; + + if (client_visit_obj IS NOT NULL) then + void := call client_visit_obj.Dispose; + client_visit_obj := NULL; + endif; + endif; + ENDIF; + + ;; + evoke: + ;; + logic: conclude true; + + ;; + action: + if Error_occurred + then + write "An error has occured in the MLM {{+B}}DOC_FUNC_HEP_C_SCREENING{{-B}} " || + "Please notify your System Administrators that an error message has " || + "occurred for this patient. They will review the following error " || + "message: \n" at error_destination; + + write "1. " || error_message at error_destination; + + endif; + + + //return thisDocumentCommunication; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_AUTOSELECT_ANESTHESIA_INSTRUCTION.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_AUTOSELECT_ANESTHESIA_INSTRUCTION.mlm new file mode 100644 index 0000000..835ae7f --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_AUTOSELECT_ANESTHESIA_INSTRUCTION.mlm @@ -0,0 +1,142 @@ +maintenance: + + title: DOC_SCH_AUTOSELECT_ANESTHESIA_INSTRUCTION ;; + mlmname: DOC_SCH_AUTOSELECT_ANESTHESIA_INSTRUCTION;; + arden: version 2.5;; + version: 1.00;; + institution: St.Clair Hospital ;; + author: Ankit Mistry ;; + specialist: ;; + date: 2017-08-23;; + validation: testing;; + +library: + purpose: + When user select “You received IV Sedation or General Anesthesia, for next 24 hours:" + - It will auto select all the 4 options: + 1) Have a responsible adult stay with you + 2) Do not make important personal decisions or sign lega documents + 3) No driving or operating dangerous machinery + 4) No alcoholic beverages + When user de-select “You received IV Sedation or General Anesthesia, for next 24 hours:" + - It will auto de-select all the 4 options: + 1) Have a responsible adult stay with you + 2) Do not make important personal decisions or sign lega documents + 3) No driving or operating dangerous machinery + 4) No alcoholic beverages + ;; + explanation: + + Change History + + ;; + keywords: + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + (this_documentCommunication) := argument; + + ST_OBS_A := "SCH OR_DIOS_GA MSSD"; + ST_OBS_B := "SCH OR_DIOS_General Anesthesia"; + ST_OBS_C := "SCH OR_DIOS_General Anesthesia PH"; + + //grab values we are interested in + /*DocumentName := this_documentCommunication.DocumentName ; + thisStructuredNoteDoc := this_documentCommunication.DocumentConfigurationObj; + thisParameters := thisStructuredNoteDoc.ParametersList; + thisObservations := thisStructuredNoteDoc.ChartedObservationsList;*/ + + (this_doc) := this_documentCommunication.DocumentConfigurationObj; + (this_ParametersList) := this_doc.ParametersList; + (this_parameters) := this_Doc.ParamatersList.records__; + (this_currentObs) := this_documentCommunication.CurrentObservationObj; + this_CurrentObsName := FIRST OF (this_parameters.Name WHERE this_parameters.ParameterGUID = this_currentObs.ParameterGUID); + this_CurrentListvalue := FIRST OF (this_currentObs.ValueObj.ListItemsList.Value WHERE this_currentObs.ValueObj.ListItemsList.IsSelected = TRUE); + this_ListValues := (this_currentObs.ValueObj.ListItemsList.Value WHERE this_currentObs.ValueObj.ListItemsList.IsSelected = TRUE); + this_ListValues_Unchecked := FIRST OF (this_currentObs.ValueObj.ListItemsList.Value WHERE this_currentObs.ValueObj.ListItemsList.IsSelected = FALSE); + this_ListValues_checked := FIRST OF (this_currentObs.ValueObj.ListItemsList.Value WHERE this_currentObs.ValueObj.ListItemsList.IsSelected = TRUE); + this_DocumentType := this_documentcommunication.DocumentType; + (this_ClientDocumentGUID) := this_Doc.ClientDocumentGUID; + + this_ClientDocumentGUID := this_Doc.ClientDocumentGUID; + this_chartedObservationsList := this_Doc.ChartedObservationsList; + + this_EventType := this_documentCommunication.EventType; + this_ClientGUID := this_documentCommunication.ClientGUID; + this_ChartGUID := this_documentCommunication.ChartGUID; + this_ConfigurationGUID := this_documentCommunication.ConfigurationGUID; + + zz:= this_doc.ParametersList.Records__; + z1 := FIRST OF (zz WHERE zz.Name = ST_OBS_B); + zzz2 := FIRST OF (this_ParametersList.ParameterGUID WHERE this_ParametersList.Name = ST_OBS_B); + + + Rad_prm_Name := FIRST OF (this_ParametersList.Name WHERE this_ParametersList.Name = ST_OBS_B); + Rad_True := FIRST OF (this_currentObs.ValueObj.ListItemsList.Value WHERE this_currentObs.ParameterGUID = zzz2 AND this_currentObs.ValueObj.ListItemsList.IsSelected = TRUE); + Rad_False := FIRST OF (this_currentObs.ValueObj.ListItemsList.Value WHERE this_currentObs.ParameterGUID = zzz2 AND this_currentObs.ValueObj.ListItemsList.IsSelected = FALSE); + + + + CALLED_DOM_MLM := MLM {{{SINGLE-QUOTE}}}CALLED_DOM_CCC{{{SINGLE-QUOTE}}}; + SuggestedTextValue := ""; + REPLACE_APPEND := "Replace"; + + Parm := OBJECT [ListValue, IsSelected]; + Parms := (); + + //break; + + IF this_CurrentListvalue = "IV Sedation/General Anesthesia, for next 24 hours" AND EXISTS Rad_True THEN + ParmObj := NEW Parm WITH "Have a responsible adult stay with you", TRUE; + Parms := ParmObj; + ParmObj := NEW Parm WITH "Do not make important personal decisions or sign legal documents", TRUE; + Parms := Parms, ParmObj; + ParmObj := NEW Parm WITH "No driving or operating dangerous machinery", TRUE; + Parms := Parms, ParmObj; + ParmObj := NEW Parm WITH "No alcoholic beverages", TRUE; + Parms := Parms, ParmObj; + + this_documentCommunication := CALL CALLED_DOM_MLM WITH (this_documentCommunication,ST_OBS_A , Parms, SuggestedTextValue, REPLACE_APPEND); + //break; + ELSEIF EXISTS this_ListValues_Unchecked THEN + ParmObj := NEW Parm WITH "IV Sedation/General Anesthesia, for next 24 hours" , FALSE; + + //ParmObj := NEW Parm WITH "Have a responsible adult stay with you", FALSE; + Parms := ParmObj; + + this_documentCommunication := CALL CALLED_DOM_MLM WITH (this_documentCommunication,ST_OBS_B , Parms, SuggestedTextValue, REPLACE_APPEND); + + + + ENDIF; + + IF Rad_prm_Name = "SCH OR_DIOS_General Anesthesia" AND EXISTS Rad_False THEN + ParmObj := NEW Parm WITH "Have a responsible adult stay with you" , FALSE; + Parms := ParmObj; + ParmObj := NEW Parm WITH "Do not make important personal decisions or sign legal documents", FALSE; + Parms := Parms, ParmObj; + ParmObj := NEW Parm WITH "No driving or operating dangerous machinery", FALSE; + Parms := Parms, ParmObj; + ParmObj := NEW Parm WITH "No alcoholic beverages", FALSE; + Parms := Parms, ParmObj; + + //break; + this_documentCommunication := CALL CALLED_DOM_MLM WITH (this_documentCommunication,ST_OBS_A , Parms, SuggestedTextValue, REPLACE_APPEND); + +ENDIF; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: + conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_AUTOSELECT_CARE_TRANSITION_NEEDS_ASSESSMENT.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_AUTOSELECT_CARE_TRANSITION_NEEDS_ASSESSMENT.mlm new file mode 100644 index 0000000..4769c1e --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_AUTOSELECT_CARE_TRANSITION_NEEDS_ASSESSMENT.mlm @@ -0,0 +1,223 @@ +maintenance: + + title: DOC_SCH_AUTOSELECT_Care_Transition_Needs_Assessment ;; + mlmname: DOC_SCH_AUTOSELECT_Care_Transition_Needs_Assessment;; + arden: version 2.5;; + version: 1.00;; + institution: St.Clair Hospital ;; + author: Shubhang Acharya ;; + specialist: ;; + date: 2017-10-31;; + validation: testing;; + +library: + purpose: + If Care Transition Order is charted for (Quality_Freq_IP_Adm_ED_Visit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Quality_Multi_High_Risk_Diag{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Quality_New_Onset{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Quality_Uncontrolled_CHF{{{SINGLE-QUOTE}}}, + {{{SINGLE-QUOTE}}}Quality_Poly-pharmacy{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Quality_Limited_support_system{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Quality_Post-dc_compliance{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Quality_New_Med_Edu{{{SINGLE-QUOTE}}}) Data Item then + Auto Select Value of Care Transition Needs Assessment according to that in Initial Discharge Planning Note + + History + 09.24.2019 TMS CSR # 38444 Add 2 new additional observations. + ;; + explanation: + + + ;; + keywords: + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + (this_documentCommunication) := argument; + + ST_OBS_A := "SCH_info list"; + + + //grab values we are interested in + /*DocumentName := this_documentCommunication.DocumentName ; + thisStructuredNoteDoc := this_documentCommunication.DocumentConfigurationObj; + thisParameters := thisStructuredNoteDoc.ParametersList; + thisObservations := thisStructuredNoteDoc.ChartedObservationsList;*/ + + (this_doc) := this_documentCommunication.DocumentConfigurationObj; + (this_ParametersList) := this_doc.ParametersList; + (this_parameters) := this_Doc.ParamatersList.records__; + (this_currentObs) := this_documentCommunication.CurrentObservationObj; + this_CurrentObsName := FIRST OF (this_parameters.Name WHERE this_parameters.ParameterGUID = this_currentObs.ParameterGUID); + this_CurrentListvalue := FIRST OF (this_currentObs.ValueObj.ListItemsList.Value WHERE this_currentObs.ValueObj.ListItemsList.IsSelected = TRUE); + this_ListValues := (this_currentObs.ValueObj.ListItemsList.Value WHERE this_currentObs.ValueObj.ListItemsList.IsSelected = TRUE); + this_ListValues_Unchecked := FIRST OF (this_currentObs.ValueObj.ListItemsList.Value WHERE this_currentObs.ValueObj.ListItemsList.IsSelected = FALSE); + this_ListValues_checked := FIRST OF (this_currentObs.ValueObj.ListItemsList.Value WHERE this_currentObs.ValueObj.ListItemsList.IsSelected = TRUE); + this_DocumentType := this_documentcommunication.DocumentType; + (this_ClientDocumentGUID) := this_Doc.ClientDocumentGUID; + + this_ClientDocumentGUID := this_Doc.ClientDocumentGUID; + this_chartedObservationsList := this_Doc.ChartedObservationsList; + + this_EventType := this_documentCommunication.EventType; + this_ClientVisitGUID := this_documentCommunication.ClientVisitGUID; + this_ClientGUID := this_documentCommunication.ClientGUID; + this_ChartGUID := this_documentCommunication.ChartGUID; + this_ConfigurationGUID := this_documentCommunication.ConfigurationGUID; + + zz:= this_doc.ParametersList.Records__; + z1 := FIRST OF (zz WHERE zz.Name = ST_OBS_B); + zzz2 := FIRST OF (this_ParametersList.ParameterGUID WHERE this_ParametersList.Name = ST_OBS_B); + + + Rad_prm_Name := FIRST OF (this_ParametersList.Name WHERE this_ParametersList.Name = ST_OBS_B); + Rad_True := FIRST OF (this_currentObs.ValueObj.ListItemsList.Value WHERE this_currentObs.ParameterGUID = zzz2 AND this_currentObs.ValueObj.ListItemsList.IsSelected = TRUE); + Rad_False := FIRST OF (this_currentObs.ValueObj.ListItemsList.Value WHERE this_currentObs.ParameterGUID = zzz2 AND this_currentObs.ValueObj.ListItemsList.IsSelected = FALSE); + + ParmObj := OBJECT[DataItemName, DataItemValue]; + + ParmObjs := READ AS ParmObj {"Select OUD.UserDataCode,OUD.Value From CV3ClientVisit CV WITH (NOLOCK) + INNER JOIN CV3Order O WITH (NOLOCK) + ON CV.GUID = O.ClientVisitGUID + AND CV.ClientGUID = O.ClientGUID + AND O.Name = {{{SINGLE-QUOTE}}}Care Transitions Consult{{{SINGLE-QUOTE}}} + INNER JOIN CV3OrderUserData OUD WITH (NOLOCK) + ON OUD.OrderGUID = O.GUID + AND OUD.ClientGUID = CV.ClientGUID + AND OUD.UserDataCode IN ({{{SINGLE-QUOTE}}}Quality_Freq_IP_Adm_ED_Visit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Quality_Multi_High_Risk_Diag{{{SINGLE-QUOTE}}}, + {{{SINGLE-QUOTE}}}Quality_New_Onset{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Quality_Uncontrolled_CHF{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Quality_Poly-pharmacy{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Quality_Limited_support_system{{{SINGLE-QUOTE}}}, + {{{SINGLE-QUOTE}}}Quality_Post-dc_compliance{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Quality_New_Med_Edu{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Quality_Financial_Hardship{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Quality_Medication_Compliance{{{SINGLE-QUOTE}}}) + WHERE O.OrderStatusCode = {{{SINGLE-QUOTE}}}AUA1{{{SINGLE-QUOTE}}} AND + O.ClientvisitGUID = " || SQL(this_ClientVisitGUID) || " + AND O.ClientGUID = "|| SQL(this_ClientGUID) ||""}; + + + FOR i IN 1 Seqto Count Of ParmObjs Do + Test := ParmObjs[i]; + IF test.DataItemName = "Quality_Freq_IP_Adm_ED_Visit" THEN + ChartOBs1 := 1; + ELSEIF test.DataItemName = "Quality_Multi_High_Risk_Diag" THEN + ChartOBs2 := 1; + ELSEIF test.DataItemName = "Quality_New_Onset" THEN + ChartOBs3 := 1; + ELSEIF test.DataItemName = "Quality_Uncontrolled_CHF" THEN + ChartOBs4 := 1; + ELSEIF test.DataItemName = "Quality_Poly-pharmacy" THEN + ChartOBs5 := 1; + ELSEIF test.DataItemName = "Quality_Limited_support_system" THEN + ChartOBs6 := 1; + ELSEIF test.DataItemName = "Quality_Post-dc_compliance" THEN + ChartOBs7 := 1; + ELSEIF test.DataItemName = "Quality_New_Med_Edu" THEN + ChartOBs8 := 1; + ELSEIF test.DataItemName = "Quality_Financial_Hardship" THEN + ChartOBs9 := 1; + ELSEIF test.DataItemName = "Quality_Medication_Compliance" THEN + ChartOBs10 := 1; + + ENDIF; + // break; + ENDDO; + + + CALLED_DOM_MLM := MLM {{{SINGLE-QUOTE}}}CALLED_DOM_CCC{{{SINGLE-QUOTE}}}; + SuggestedTextValue := ""; + REPLACE_APPEND := "Replace"; + + Parm := OBJECT [ListValue, IsSelected]; + Parms := (); + + + IF ChartObs1 = 1 THEN + ParmObj1 := NEW Parm WITH "Frequent IP admissions/ED Visits", TRUE; + Parms := ParmObj1; + ELSE + ParmObj1 := NEW Parm WITH "Frequent IP admissions/ED Visits", FALSE; + Parms := ParmObj1; + ENDIF; + + IF ChartObs2 = 1 THEN + ParmObj1 := NEW Parm WITH "Complex/High-Risk Diagnoses (at least 2: CHF/HTN/DM/COPD)", TRUE; + Parms := Parms, ParmObj1; + ELSE + ParmObj1 := NEW Parm WITH "Complex/High-Risk Diagnoses (at least 2: CHF/HTN/DM/COPD)", FALSE; + Parms := Parms, ParmObj1; + ENDIF; + + IF ChartObs3 = 1 THEN + ParmObj1 := NEW Parm WITH "New onset CHF/HTN/DM/COPD diagnosis", TRUE; + Parms := Parms, ParmObj1; + ELSE + ParmObj1 := NEW Parm WITH "New onset CHF/HTN/DM/COPD diagnosis", FALSE; + Parms := Parms, ParmObj1; + ENDIF; + + IF ChartObs4 = 1 THEN + ParmObj1 := NEW Parm WITH "Uncontrolled CHF/HTN/DM/COPD diagnosis", TRUE; + Parms := Parms, ParmObj1; + ELSE + ParmObj1 := NEW Parm WITH "Uncontrolled CHF/HTN/DM/COPD diagnosis", FALSE; + Parms := Parms, ParmObj1; + ENDIF; + + IF ChartObs5 = 1 THEN + ParmObj1 := NEW Parm WITH "New medication education (>2 new meds or new high alert medication)", TRUE; + Parms := Parms, ParmObj1; + ELSE + ParmObj1 := NEW Parm WITH "New medication education (>2 new meds or new high alert medication)", FALSE; + Parms := Parms, ParmObj1; + ENDIF; + + IF ChartObs6 = 1 THEN + ParmObj1 := NEW Parm WITH "Poly-pharmacy ( > 7 chronic oral medications; excluding OTC/herbals)", TRUE; + Parms := Parms, ParmObj1; + ELSE + ParmObj1 := NEW Parm WITH "Poly-pharmacy ( > 7 chronic oral medications; excluding OTC/herbals)", FALSE; + Parms := Parms, ParmObj1; + ENDIF; + + IF ChartObs7 = 1 THEN + ParmObj1 := NEW Parm WITH "Limited support system", TRUE; + Parms := Parms, ParmObj1; + ELSE + ParmObj1 := NEW Parm WITH "Limited support system", FALSE; + Parms := Parms, ParmObj1; + ENDIF; + + IF ChartObs8 = 1 THEN + ParmObj1 := NEW Parm WITH "Post-discharge compliance concerns", TRUE; + Parms := Parms, ParmObj1; + ELSE + ParmObj1 := NEW Parm WITH "Post-discharge compliance concerns", FALSE; + Parms := Parms, ParmObj1; + ENDIF; + + IF ChartObs9 = 1 THEN + ParmObj1 := NEW Parm WITH "Financial hardship for obtaining meds", TRUE; + Parms := Parms, ParmObj1; + ELSE + ParmObj1 := NEW Parm WITH "Financial hardship for obtaining meds", FALSE; + Parms := Parms, ParmObj1; + ENDIF; + + IF ChartObs10 = 1 THEN + ParmObj1 := NEW Parm WITH "Medication compliance concerns", TRUE; + Parms := Parms, ParmObj1; + ELSE + ParmObj1 := NEW Parm WITH "Medication compliance concerns", FALSE; + Parms := Parms, ParmObj1; + ENDIF; + + + + this_documentCommunication := CALL CALLED_DOM_MLM WITH (this_documentCommunication,ST_OBS_A , Parms, SuggestedTextValue, REPLACE_APPEND); + + ;; + priority: 50 + ;; + evoke: + ;; + logic: + conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_CHART_PLAN_OF_CARE_VALUE.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_CHART_PLAN_OF_CARE_VALUE.mlm new file mode 100644 index 0000000..a9e9bbd --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_CHART_PLAN_OF_CARE_VALUE.mlm @@ -0,0 +1,85 @@ +maintenance: + + title: DOC_SCH_Chart_Plan_of_Care_Value ;; + mlmname: DOC_SCH_Chart_Plan_of_Care_Value;; + arden: version 2.5;; + version: 1.00;; + institution: St.Clair Hospital ;; + author: Shubhang Acharya ;; + specialist: ;; + date: 2017-11-02;; + validation: testing;; + +library: + purpose: + Purpose of the MLM is to chart the Plan of Care Observation value from previously charted Diabetes Assessment Outpatient - Follow Up Note document. + ;; + explanation: + Modification History: + ---------------------------------------- + #1 11/02/17 Shubhang Acharya CSR# 35527: MLM Created + + ;; + keywords: + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + (this_documentCommunication) := argument; + + ST_OBS_A := "SCH_diab_plan of care previous FU"; + + + //grab values we are interested in + /*DocumentName := this_documentCommunication.DocumentName ; + thisStructuredNoteDoc := this_documentCommunication.DocumentConfigurationObj; + thisParameters := thisStructuredNoteDoc.ParametersList; + thisObservations := thisStructuredNoteDoc.ChartedObservationsList;*/ + + (this_doc) := this_documentCommunication.DocumentConfigurationObj; + (this_ParametersList) := this_doc.ParametersList; + (this_parameters) := this_Doc.ParamatersList.records__; + (this_currentObs) := this_documentCommunication.CurrentObservationObj; + this_CurrentObsName := FIRST OF (this_parameters.Name WHERE this_parameters.ParameterGUID = this_currentObs.ParameterGUID); + this_CurrentListvalue := FIRST OF (this_currentObs.ValueObj.ListItemsList.Value WHERE this_currentObs.ValueObj.ListItemsList.IsSelected = TRUE); + this_ListValues := (this_currentObs.ValueObj.ListItemsList.Value WHERE this_currentObs.ValueObj.ListItemsList.IsSelected = TRUE); + this_ListValues_Unchecked := FIRST OF (this_currentObs.ValueObj.ListItemsList.Value WHERE this_currentObs.ValueObj.ListItemsList.IsSelected = FALSE); + this_ListValues_checked := FIRST OF (this_currentObs.ValueObj.ListItemsList.Value WHERE this_currentObs.ValueObj.ListItemsList.IsSelected = TRUE); + this_DocumentType := this_documentcommunication.DocumentType; + (this_ClientDocumentGUID) := this_Doc.ClientDocumentGUID; + + this_ClientDocumentGUID := this_Doc.ClientDocumentGUID; + this_chartedObservationsList := this_Doc.ChartedObservationsList; + + this_EventType := this_documentCommunication.EventType; + this_ClientVisitGUID := this_documentCommunication.ClientVisitGUID; + this_ClientGUID := this_documentCommunication.ClientGUID; + this_ChartGUID := this_documentCommunication.ChartGUID; + this_ConfigurationGUID := this_documentCommunication.ConfigurationGUID; + + Parms := READ LAST{"EXEC SCH_Chart_Plan_Of_Care " || " " || sql(this_ClientVisitGUID) || "," || SQl(this_ClientGUID)}; + + CALLED_DOM_MLM := MLM {{{SINGLE-QUOTE}}}CALLED_DOM_CCC{{{SINGLE-QUOTE}}}; + SuggestedTextValue := ""; + REPLACE_APPEND := "Replace"; + + //IF Not EXISTS this_doc.ClientDocumentGUID THEN + this_documentCommunication := CALL CALLED_DOM_MLM WITH (this_documentCommunication,ST_OBS_A , Parms, SuggestedTextValue, REPLACE_APPEND); + //ENDIF; + +//break; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: + conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_CREATE_CARE_TRANSITION_CONSULT.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_CREATE_CARE_TRANSITION_CONSULT.mlm new file mode 100644 index 0000000..45aad3f --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_CREATE_CARE_TRANSITION_CONSULT.mlm @@ -0,0 +1,236 @@ +maintenance: + + title: DOC_SCH_CREATE_CARE_TRANSITION_CONSULT;; + mlmname: DOC_SCH_CREATE_CARE_TRANSITION_CONSULT;; + arden: version 2.5;; + version: 0.00;; + institution: ;; + author: Shubhang Acharya ;; + specialist: ;; + date: 2017-10-25;; + validation: testing;; + +library: + purpose: Place Care Transition Consult Order + ;; + explanation: When user charts specific observation in Document "Initial Discharge Planning Note", then need to auto place "Care Transition Consult Order" + + Change history + + 11.01.2017 DW CSR # 37570 Remove from production (and delete...do not need) + 01.23.2019 DW CSR # 37792 Re-introduce MLM + 09.24.2019 TMS CSR # 38444 Update MLM with 2 new observations. + + + ;; + keywords: + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + (this_documentCommunication) := ARGUMENT; + + (this_Doc) := this_documentCommunication.DocumentConfigurationObj; + (this_parameters) := this_Doc.ParametersList; + + (this_ClientDocumentGUID) := this_Doc.ClientDocumentGUID; + this_chartedObservationsList := this_Doc.ChartedObservationsList; + + this_ClientGUID := this_documentCommunication.ClientGUID; + this_ChartGUID := this_documentCommunication.ChartGUID; + this_ClientVisitGUID := this_documentCommunication.ClientVisitGUID; + this_User := this_Doc.AuthoredByGUID; + this_user_name := READ LAST {"SELECT DisplayName FROM CV3User WITH(NOLOCK) WHERE GUID = " || SQL(this_User)}; + Order_Name := "Care Transitions Consult"; + location_guid := read last {"SELECT CurrentLocationGUID FROM CV3ClientVisit WITH(NOLOCK) WHERE GUID = " || SQL(this_ClientVisitGUID)}; + + Parm_Name := "sch_info list"; + + Parm_GUID := FIRST OF (this_parameters.ParameterGUID WHERE this_parameters.Name = Parm_Name); + + Parm_Obj := FIRST OF (this_chartedObservationsList WHERE this_chartedObservationsList.ParameterGUID = Parm_GUID); + Test := Parm_Obj.ValueObj.ListItemsList; + + //Test_User_GUID := this_documentCommunication.UserGUID; + //Test_User_Name := READ LAST {"SELECT DisplayName FROM CV3USer WITH(NOLOCK) WHERE GUID = " || SQL(Test_User_GUID) || " AND Active = 1"}; + + //IF Test_User_Name IN ("Nordin, Janet","Nordin, Janet M","Nordin, Janet TEST","nordin, Janet Test","Acharya, Shubhang") THEN + FOR i IN Test Do + IF i.Value = "Frequent Visits IP/ED (>3 in 6 months)" AND i.IsSelected = true THEN + ChartOBs1 := 1; + ELSEIF i.Value = "Complex/High-Risk Diagnoses (at least 2: CHF/HTN/DM/COPD)" AND i.IsSelected = true THEN + ChartOBs2 := 1; + ELSEIF i.Value = "New onset CHF/HTN/DM/COPD diagnosis" AND i.IsSelected = true THEN + ChartOBs3 := 1; + ELSEIF i.Value = "Uncontrolled CHF/HTN/DM/COPD diagnosis" AND i.IsSelected = true THEN + ChartOBs4 := 1; + ELSEIF i.Value = "Poly-pharmacy ( > 7 chronic oral medications; excluding OTC/herbals)" AND i.IsSelected = true THEN + ChartOBs5 := 1; + ELSEIF i.Value = "Limited support system" AND i.IsSelected = true THEN + ChartOBs6 := 1; + ELSEIF i.Value = "Post-discharge compliance concerns" AND i.IsSelected = true THEN + ChartOBs7 := 1; + ELSEIF i.Value = "New medication education (>2 new meds or new high alert medication)" AND i.IsSelected = true THEN + ChartOBs8 := 1; + ELSEIF i.Value = "Financial hardship for obtaining meds" AND i.IsSelected = true THEN + ChartOBs9 := 1; + ELSEIF i.Value = "Medication compliance concerns" AND i.IsSelected = true THEN + ChartOBs10 := 1; + ENDIF; + ENDDO; + + IF (ChartOBs1 = 1) OR (ChartOBs2 = 1) OR (ChartOBs3 = 1) OR (ChartOBs4 = 1) OR (ChartOBs5 = 1) OR (ChartOBs6 = 1) OR (ChartOBs7 = 1) OR (ChartOBs8 = 1) OR (ChartOBs9 = 1) OR (ChartOBs10 = 1) THEN + //IF EXISTS Parm_Obj Then + Consult_Orders_Charted := READ LAST {"SELECT O.GUID + FROM CV3Order O WITH(NOLOCK) + INNER JOIN CV3OrderCatalogMasterItem OCMI WITH(NOLOCK) + ON OCMI.GUID = O.OrderCatalogMasterItemGUID + AND OCMI.Active = 1 + AND O.Active = 1 + WHERE O.ClientGUID = " || SQL(this_ClientGUID) + || " AND O.ChartGUID = " || SQL(this_ChartGUID) + || " AND O.ClientVisitGUID = " || SQL(this_ClientVisitGUID) + || " AND orderstatuslevelnum < 55 + AND OrderStatusCode = {{{SINGLE-QUOTE}}}AUA1{{{SINGLE-QUOTE}}} + AND OCMI.Name IN ({{{SINGLE-QUOTE}}}Care Transitions Consult{{{SINGLE-QUOTE}}})"}; + + + + IF NOT EXISTS Consult_Orders_Charted THEN + order_Creation_Reason := "From MLM"; + RequestingSource := ""; + SessionType := "Standard"; + SessionReason := ""; //SessionReason should be blank for Session Type "Standard Orders" + Order_Type := "GeneralOrder"; + orderItemModifier := " "; + + CatalogItemName1 := Order_Name; + + IF ChartObs1 = 1 THEN + OrderDataItem1 := "Quality_Freq_IP_Adm_ED_Visit"; + OrderDataItemValue1 := 1 AS Boolean; + ELSE + OrderDataItem1 := "Quality_Freq_IP_Adm_ED_Visit"; + OrderDataItemValue1 := 0 AS Boolean; + ENDIF; + + IF ChartObs2 = 1 THEN + OrderDataItem2 := "Quality_Multi_High_Risk_Diag"; + OrderDataItemValue2 := 1 AS Boolean; + ELSE + OrderDataItem2 := "Quality_Multi_High_Risk_Diag"; + OrderDataItemValue2 := 0 AS Boolean; + ENDIF; + + IF ChartObs3 = 1 THEN + OrderDataItem3 := "Quality_New_Onset"; + OrderDataItemValue3 := 1 AS Boolean; + ELSE + OrderDataItem3 := "Quality_New_Onset"; + OrderDataItemValue3 := 0 AS Boolean; + ENDIF; + + IF ChartObs4 = 1 THEN + OrderDataItem4 := "Quality_Uncontrolled_CHF"; + OrderDataItemValue4 := 1 AS Boolean; + ELSE + OrderDataItem4 := "Quality_Uncontrolled_CHF"; + OrderDataItemValue4 := 0 AS Boolean; + ENDIF; + + IF ChartObs5 = 1 THEN + OrderDataItem5 := "Quality_Poly-pharmacy"; + OrderDataItemValue5 := 1 AS Boolean; + ELSE + OrderDataItem5 := "Quality_Poly-pharmacy"; + OrderDataItemValue5 := 0 AS Boolean; + ENDIF; + + IF ChartObs6 = 1 THEN + OrderDataItem6 := "Quality_Limited_support_system"; + OrderDataItemValue6 := 1 AS Boolean; + ELSE + OrderDataItem6 := "Quality_Limited_support_system"; + OrderDataItemValue6 := 0 AS Boolean; + ENDIF; + + IF ChartObs7 = 1 THEN + OrderDataItem7 := "Quality_Post-dc_compliance"; + OrderDataItemValue7 := 1 AS Boolean; + ELSE + OrderDataItem7 := "Quality_Post-dc_compliance"; + OrderDataItemValue7 := 0 AS Boolean; + ENDIF; + + IF ChartObs8 = 1 THEN + OrderDataItem8 := "Quality_New_Med_Edu"; + OrderDataItemValue8 := 1 AS Boolean; + ELSE + OrderDataItem8 := "Quality_New_Med_Edu"; + OrderDataItemValue8 := 0 AS Boolean; + ENDIF; + + + IF ChartObs9 = 1 THEN + OrderDataItem9 := "Quality_Financial_Hardship"; + OrderDataItemValue9 := 1 AS Boolean; + ELSE + OrderDataItem9 := "Quality_Financial_Hardship"; + OrderDataItemValue9 := 0 AS Boolean; + ENDIF; + + + IF ChartObs10 = 1 THEN + OrderDataItem10 := "Quality_Medication_Compliance"; + OrderDataItemValue10 := 1 AS Boolean; + ELSE + OrderDataItem10 := "Quality_Medication_Compliance"; + OrderDataItemValue10 := 0 AS Boolean; + ENDIF; + + + Auto_Gen_Order := MLM {{{SINGLE-QUOTE}}}SCH_Called_Auto_Order_General{{{SINGLE-QUOTE}}}; + + TRY + Var := CALL Auto_Gen_Order WITH (this_ClientVisitGUID,this_ChartGUID,this_ClientGUID,this_User,Location_GUID,CatalogItemName1,OrderDataItem1,OrderDataItemValue1,OrderDataItem2,OrderDataItemValue2,OrderDataItem3,OrderDataItemValue3,OrderDataItem4,OrderDataItemValue4,OrderDataItem5,OrderDataItemValue5,OrderDataItem6,OrderDataItemValue6,OrderDataItem7,OrderDataItemValue7,OrderDataItem8,OrderDataItemValue8,OrderDataItem9,OrderDataItemValue9,OrderDataItem10,OrderDataItemValue10,Order_Creation_Reason); +/* Var := CALL Auto_Gen_Order WITH this_ClientVisitGUID, + this_ClientGUID, + this_User, + location_guid, + Order_Type, + Order_Name, + orderItemModifier, + order_Creation_Reason, + RequestingSource, + SessionType, + SessionReason; */ + + ENDTRY; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}New General order:{{-R}}\n" || + ex.Message || "\n\n"; + endcatch; + ENDIF; + + + ENDIF; + //ENDIF; + + + ;; + priority: 50 + ;; + evoke: + ;; + logic: + CONCLUDE TRUE; + ;; + action: + RETURN this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_CREATE_ORDER_DECREASE_FUNCTION.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_CREATE_ORDER_DECREASE_FUNCTION.mlm new file mode 100644 index 0000000..b2269b8 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_CREATE_ORDER_DECREASE_FUNCTION.mlm @@ -0,0 +1,228 @@ +maintenance: + + title: DOC_SCH_CREATE_ORDER_DECREASE_FUNCTION;; + mlmname: DOC_SCH_CREATE_ORDER_DECREASE_FUNCTION;; + arden: version 2.5;; + version: 1.00;; + institution: SCH;; + author: Shubhang Acharya;; + specialist: ;; + date: 2017-07-31;; + validation: testing;; + +library: + purpose: + Create Decrease Function Order + ;; + explanation: + This MLM is called in MLM "DOC_ADULT_ASSESSMENT_CLOSE" to create Decrease Function - PT/OT to Screen Order. + Order should be created when any of the following values are charted in flowsheet "Adult Assessment/Intervention" after 48 hours of admission. + + 1. Bedrest + 2. Dangle at bedside + 3. Turned/repositioned every 2 hours + 4. Bedside commode + + Modification History: + -------------------------------------------------- + #1 08.01.2017 SAcharya - CSR# 35187: MLM Created. + #2 09.14.2017 SAcharya - CSR# 35917: Need to Chart order only if observation is documented from 8:00 AM - 8:00 PM and OT and PT orders are not charted on patients. + #3 01.31.2018 AMistry - CSR# 35187: Changed Order Name to "Decrease Function - PT/OT to Screen" from "Decrease Function". + #4 02.12.2018 AMistry - CSR# 36290: Change Logic to place 2 orders (Decrease Function - OT to Screen,Decrease Function - PT to Screen) instead of 1 order(Decrease Function - PT/OT to Screen). + ;; + keywords: + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + (this_documentCommunication) := argument; + //Get The Structure Note + (this_FS_doc) := this_documentCommunication.DocumentConfigurationObj; + //Get the Parameter List + (this_parms) := this_FS_doc.ParametersList; + prm := first of (this_parms where this_parms.Name = "INV activity assist level"); + + error_occurred := False; + error_message := ""; + + // Specify which .NET assemblies need to be loaded for ObjectsPlus + standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + Order_Create_MLM := MLM {{{SINGLE-QUOTE}}}SCH_Create_General_Order{{{SINGLE-QUOTE}}}; + //Order_Name := "Decrease Function"; //#3 +// Order_Name := "Decrease Function - PT/OT to Screen"; //#3 + DF_OT_2_SC_Order_Name := "Decrease Function - OT to Screen"; //#4 + DF_PT_2_SC_Order_Name := "Decrease Function - PT to Screen"; //#4 + + Client_Guid := this_documentCommunication.ClientGUID; + Chart_Guid := this_documentCommunication.ChartGUID; + Client_Visit_Guid := this_documentCommunication.ClientVisitGUID; + //User_GUID := this_documentCommunication.UserGUID; + + MLM_Time := NOW; + SQL_Time := READ LAST {"IF CAST(" || SQL (MLM_Time) || " AS TIME) BETWEEN {{{SINGLE-QUOTE}}}08:00{{{SINGLE-QUOTE}}} AND {{{SINGLE-QUOTE}}}20:00{{{SINGLE-QUOTE}}} + BEGIN + SELECT 1 + END + ELSE + BEGIN + SELECT 0 + END"}; + + PT_Orders_Charted := READ LAST {"SELECT O.GUID + FROM CV3Order O WITH(NOLOCK) + INNER JOIN CV3OrderCatalogMasterItem OCMI WITH(NOLOCK) + ON OCMI.GUID = O.OrderCatalogMasterItemGUID + AND OCMI.Active = 1 + AND O.Active = 1 + WHERE O.ClientGUID = " || SQL(Client_Guid) + || " AND O.ChartGUID = " || SQL(Chart_Guid) + || " AND O.ClientVisitGUID = " || SQL(Client_Visit_Guid) + || " AND orderstatuslevelnum < 55 + AND OrderStatusCode = {{{SINGLE-QUOTE}}}AUA1{{{SINGLE-QUOTE}}} + AND OCMI.Name IN ({{{SINGLE-QUOTE}}}Occupational Therapy Evaluate and Treat{{{SINGLE-QUOTE}}} + ,{{{SINGLE-QUOTE}}}Occupational Therapy Evaluation Only{{{SINGLE-QUOTE}}} + ,{{{SINGLE-QUOTE}}}Occupational Therapy Re-Evaluation Only{{{SINGLE-QUOTE}}} + ,{{{SINGLE-QUOTE}}}Occupational Therapy Re-Eval and Treat{{{SINGLE-QUOTE}}} + ,{{{SINGLE-QUOTE}}}Physical Therapy Evaluate and Treat{{{SINGLE-QUOTE}}} + ,{{{SINGLE-QUOTE}}}Physical Therapy Re-Eval and Treat{{{SINGLE-QUOTE}}} + ,{{{SINGLE-QUOTE}}}Physical Therapy Evaluation Only{{{SINGLE-QUOTE}}} + ,{{{SINGLE-QUOTE}}}Physical Therapy Re-Evaluation Only{{{SINGLE-QUOTE}}})"}; + + //Go ahead only if observation is being charted from 8:00 AM - 8:00 PM and above PT and OT orders are not charted on patient + IF (SQL_Time = 1) AND NOT EXISTS PT_Orders_Charted THEN +//break; + //IF NOT EXISTS PT_Orders_Charted THEN + Obs_Value := (); + Obs_Value := this_documentCommunication.CurrentObservationObj.ValueObj.ListItemsList.Value + WHERE this_documentCommunication.CurrentObservationObj.ValueObj.ListItemsList.isselected = true + AND this_documentCommunication.CurrentObservationObj.ParameterGUID = prm.ParameterGUID; + + Val1 := "bedrest"; + Val2 := "dangle at bedside"; + Val3 := "turned/repositioned every two hours"; + Val4 := "bedside commode"; + + IF (Val1 IN Obs_Value) OR (Val2 IN Obs_Value) OR (Val3 IN Obs_Value) OR (Val4 IN Obs_Value) THEN + Chk_Val := 1; + ELSE + Chk_Val := 0; + ENDIF; + + IF Chk_Val = 1 THEN + //Check if observation is being charted after 48 hours of admission + Adm_Dtm_Diff := READ FIRST { "SELECT DATEDIFF(HOUR,AdmitDtm,GETDATE()) + FROM CV3ClientVisit WITH(NOLOCK) + WHERE GUID = " || SQL(Client_Visit_Guid) }; + //#4 : START + //Check for duplicate Order + Chk_Dup_OT_Order := READ LAST + { " SELECT name + FROM CV3Order WITH(NOLOCK) + WHERE ClientGUID = " || SQL(Client_Guid) + || " AND ClientVisitGUID = " || SQL(Client_Visit_Guid) + || " AND name = " || SQL(DF_OT_2_SC_Order_Name) //#3 + || " AND orderstatuslevelnum < 55 + AND OrderStatusCode = {{{SINGLE-QUOTE}}}AUA1{{{SINGLE-QUOTE}}} + AND active = 1 " }; + Chk_Dup_PT_Order := READ LAST + { " SELECT name + FROM CV3Order WITH(NOLOCK) + WHERE ClientGUID = " || SQL(Client_Guid) + || " AND ClientVisitGUID = " || SQL(Client_Visit_Guid) + || " AND name = " || SQL(DF_PT_2_SC_Order_Name) + || " AND orderstatuslevelnum < 55 + AND OrderStatusCode = {{{SINGLE-QUOTE}}}AUA1{{{SINGLE-QUOTE}}} + AND active = 1 " }; + //#4 : END + + IF (Adm_Dtm_Diff > 48) THEN //#4 + //IF NOT EXISTS Chk_Dup_Order THEN + //Initialize variables + order_Creation_Reason := "From MLM"; + RequestingSource := ""; + SessionType := "Standard"; + SessionReason := ""; //SessionReason should be blank for Session Type "Standard Orders" + Order_Type := "GeneralOrder"; + orderItemModifier := " "; + + location_guid := read last {"SELECT CurrentLocationGUID FROM CV3ClientVisit WITH(NOLOCK) WHERE GUID = " || SQL(Client_Visit_Guid)}; + + //Attending Provider + User_GUID := READ FIRST {"SELECT TOP 1 CP.GUID + FROM CV3CareProvider CP (NOLOCK) + INNER JOIN CV3CareProviderVisitRole CPVR (NOLOCK) + ON CP.GUID = CPVR.ProviderGUID + AND CPVR.ClientGUID = " || SQL (Client_Guid) + || " AND CPVR.ClientVisitGUID = " || SQL(Client_Visit_Guid) + || " AND CPVR.RoleCode = {{{SINGLE-QUOTE}}}Attending{{{SINGLE-QUOTE}}} + AND CPVR.Active = 1 + AND CP.Active = 1 + AND CP.TypeCode = {{{SINGLE-QUOTE}}}Physician{{{SINGLE-QUOTE}}} + ORDER BY CPVR.CreatedWhen DESC"}; + + Auto_Gen_Order := MLM {{{SINGLE-QUOTE}}}SCH_Auto_Generate_Orders{{{SINGLE-QUOTE}}}; + //#4: START + IF NOT EXISTS Chk_Dup_OT_Order THEN + TRY + Var := CALL Auto_Gen_Order WITH Client_Visit_Guid, + Client_Guid, + User_GUID, + location_guid, + Order_Type, + DF_OT_2_SC_Order_Name, + orderItemModifier, + order_Creation_Reason, + RequestingSource, + SessionType, + SessionReason; + ENDTRY; + catch Exception ex + error_occurred := true; + error_message := "{{+R}}New General order:{{-R}}\n" || + ex.Message || "\n\n"; + endcatch; + ENDIF; + + IF NOT EXISTS Chk_Dup_PT_Order THEN + TRY + Var := CALL Auto_Gen_Order WITH Client_Visit_Guid, + Client_Guid, + User_GUID, + location_guid, + Order_Type, + DF_PT_2_SC_Order_Name, + orderItemModifier, + order_Creation_Reason, + RequestingSource, + SessionType, + SessionReason; + ENDTRY; + catch Exception ex + error_occurred := true; + error_message := "{{+R}}New General order:{{-R}}\n" || + ex.Message || "\n\n"; + endcatch; + ENDIF; + //#4: END + ENDIF;// IF (Adm_Dtm_Diff > 48) AND NOT EXISTS Chk_Dup_Order + ENDIF;// IF Chk_Val = 1 + ENDIF;// IF (SQL_Time = 1) AND NOT EXISTS PT_Orders_Charted + +//break; + ;; + priority: 50 + ;; + evoke: + ;; + logic: + Conclude True; + ;; + action: + Return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_LAUNCH_DIALOGBOX.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_LAUNCH_DIALOGBOX.mlm new file mode 100644 index 0000000..c1bb462 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_LAUNCH_DIALOGBOX.mlm @@ -0,0 +1,116 @@ +maintenance: + + title: DOC_SCH_Launch_Dialogbox ;; + mlmname: DOC_SCH_Launch_Dialogbox ;; + arden: version 4.5;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Shivprasad Jadhav;; + specialist: ;; + date: 2015-05-12;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change history + + 12.05.2015 DW CSR#33287 Add a Launch Order Entry And Order Reconciliation Manager . + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Recieve arguments from the structured note + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + (this_currentObj) := thisdocumentCommunication.CurrentObservationObj; + comm_obj := thisDocumentCommunication.primaryobj; + + OrderEntryLaunch := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Launch Orders"); + selectedItems := (this_currentObj.ValueObj.ListItemsList WHERE this_currentObj.ValueObj.ListItemsList.IsSelected = true); + currentObj_selectedItems := selectedItems.value ; + //====================================================================================================== +// Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + DateValueType := OBJECT [Value]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + +// To Unselect The Radio Button + launchordrec := false; + theParameterx := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Launch Orders"); + theObservation := first of (thisObservations where thisObservations.ParameterGUID = theParameterx.ParameterGUID); + if thisDocumentCommunication.CurrentObservationObj.Parameterguid = theParameterx.ParameterGUID then + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Launch Orders"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + + selectedItem.IsSelected := false; + + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); + + endif; +//========================================================================================================== + MLM_Name := MLM {{{SINGLE-QUOTE}}}SCH_Dialog_Operations{{{SINGLE-QUOTE}}} ; + +// SCH_DI OrdRec Launch + launchordrec := false; + //theParameterx := first of (thisparameters where thisparameters.Name = "SCH_DI Launch Ord Rec"); + // theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameterx.ParameterGUID); + + +// OBSERVATION CHANGE + for current_item in currentObj_selectedItems do + + + If current_item = "***LAUNCH ORDER ENTRY to Complete***" Then + + Status := call MLM_Name with visitGuid ,"OrderEntry"; + + EndIf ; + If current_item = "***LAUNCH ORDER RECONCILIATION**" Then + + //Status := call MLM_Name with visitGuid,"OrderReconciliationManager"; + OrderRecall := MLM {{{SINGLE-QUOTE}}}Doc_Call_Med_Rec{{{SINGLE-QUOTE}}}; + Void := Call OrderRecall With thisDocumentCommunication ; + + EndIf ; + Enddo; + + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_HEALTH_ISSUE_CHF.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_HEALTH_ISSUE_CHF.mlm new file mode 100644 index 0000000..abc1400 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_HEALTH_ISSUE_CHF.mlm @@ -0,0 +1,216 @@ +maintenance: + + title: DOC_SCH_Readmission_Health_Issue_CHF;; + mlmname: DOC_SCH_Readmission_Health_Issue_CHF;; + arden: version 5.5;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Chintan Tilwa;; + specialist: ;; + date: 2012-10-15;; + validation: testing;; + +library: + purpose: This MLM will create a Health Issue when an observation is charted on Readmission Risk Assessment. ;; + explanation: Create CHF HI if one does not already exist + + + Change history + + 10.15.2012 CT CSR# 30880 - Created by GOS for Readmission Initiative Project. + 09.30.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 HI Dynamic Creation with all details Like ICD10 Code, Snowmed Code etc And Duplicate HI Check Change. + 10.12.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 Coding Scheme [ICD10] And Duplicate Check of HI . + + + ;; + keywords: ;; +knowledge: + type: data-driven;; + data: + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + + +// Determine which of the Chronic Conditions boxes is checked + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_CK_Chronic Conditions"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = this_parametername.ParameterGUID); + + If true in (theObservation.ValueObj.ListItemsList.IsSelected where + theObservation.ValueObj.ListItemsList.Value = "CHF" + ) then chronic := "CHF"; + endif; + +// If the patient have health issue, determine if they already have a Health Issue in their record + + If chronic = "CHF" then + + (CHFHI) := read + { + " select distinct hi.shortname " + || "from cv3healthissuedeclaration hi with (nolock) " + || "join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID " + || "where hi.clientguid = " || clientGuid || " and hi.active = 1 and hi.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " + || "and hi.typecode not in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}chronic dx{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}dx comments{{{SINGLE-QUOTE}}}) " + || " And hi.ICD10Code is not null " // Added By Shivprasad on 29 Sept 2015 for ICD9-10 Changes + || "and ( " + || "hi.text like {{{SINGLE-QUOTE}}}%CHF%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%CHF%{{{SINGLE-QUOTE}}} or " + || "hi.text like {{{SINGLE-QUOTE}}}%Congestive Heart Failure%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Congestive Heart Failure%{{{SINGLE-QUOTE}}} or " + || "(case when chi.typecode = {{{SINGLE-QUOTE}}}imo{{{SINGLE-QUOTE}}} then substring(chi.code, 5, 20) " + || " when chi.TypeCode = {{{SINGLE-QUOTE}}}icd9{{{SINGLE-QUOTE}}} then chi.code " + || " when chi.TypeCode = {{{SINGLE-QUOTE}}}icd10{{{SINGLE-QUOTE}}} then chi.code end ) in ({{{SINGLE-QUOTE}}}428.0{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}I50.9{{{SINGLE-QUOTE}}}) " // 10.12.2015-CSR#23359- ICD10 Coding Scheme and HI Duplicate check + || " ) " + || " AND ({{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} AND ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}3{{{SINGLE-QUOTE}}} OR ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}} AND hi.ChartGUID = " || SQL(chartGuid) || " ) OR hi.ClientVisitGUID = " || SQL(visitGuid) || " ) ) " + }; + + +// Notify the user if a new Health Issue is about to be created and permit them to reverse them to cancel the process + + If not exists CHFHI AND thisDocumentCommunication.EventType <> "DocumentOpening" then + + dlg_result := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with + "\n This selection will create a chronic health issue of {{{SINGLE-QUOTE}}}" || chronic || "{{{SINGLE-QUOTE}}}" || + "\n\n Click {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to confirm your selection. " || + "\n\n Click {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} if you wish to change your selection. " || + "\n " + ,"Confirm CHF Documentation ", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + +// If the user responds by cliking the "Yes" button, proceed with creating the order + + If (dlg_result as string) = "Yes" then + + try + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}Retrieve client:{{-R}}\n" || + ex.Message || "\n\n"; + if ex.InnerException is not null net_object then + error_message := error_message || "Inner Exception: " || ex.InnerException.Message || "\n\n"; + endif; + if ( client_visit_obj is NOT NULL ) then + void:= call client_visit_obj.Dispose; client_visit_obj:= null; + endif; + endcatch; + + try + //--------------------------------------------------------- + // New HealthIssue Example + //--------------------------------------------------------- + + If chronic = "CHF" then issuename := "CHF (congestive heart failure)"; + issuecode := "I50.9"; //"428.0"; // 10.12.2015-CSR#23359- ICD10 Coding Scheme and HI Duplicate check + endif; + + NewHealthIssueHIType := "Problem-Chronic"; + NewHealthIssueHICode := issuecode; + NewHealthIssueHIScheme := "ICD10" ; //"ICD9"; // 10.12.2015-CSR#23359- ICD10 Coding Scheme and HI Duplicate check + + dd := EXTRACT Day now; + mn := EXTRACT Month now; + yr := EXTRACT Year now; + +//--Start: CSR 23359-ICD9-ICD10 HI Change Added By shivprasad + Terms := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.FindIMOTerms with (NewHealthIssueHIScheme,NewHealthIssueHICode); + FOR i IN 1 SEQTO (Terms.Count as Number ) DO + HI_obj := Terms[i]; + HI_Name := HI_obj.TermName as string; + If HI_Name = issuename then + HI_NO := i ; + Endif; + ENDDO; + If HI_NO is Null Then + HI_NO :=1 ; + Endif; + New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with (client_visit_obj, NewHealthIssueHIType, Terms[HI_NO]); + +//--End Added by Shivprasad + + //New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with (client_visit_obj, NewHealthIssueHIType, NewHealthIssueHIScheme, NewHealthIssueHICode ); + + PartialDate_obj := new net_object {{{SINGLE-QUOTE}}}PartialDate{{{SINGLE-QUOTE}}} with (yr as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, mn as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, dd as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}} ); + New_HealthIssue_obj.OnsetDate := PartialDate_obj; + New_HealthIssue_obj.Text := "Created from Readmission Risk Assessment . " ; + New_HealthIssue_obj.Name := issuename; + + + if ( New_HealthIssue_obj is NOT NULL ) then + void := call New_HealthIssue_obj.Save; + void := call New_HealthIssue_obj.Dispose; + endif; + + if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; + + endtry; + + catch exception ex + error_occurred := true; + if ( New_HealthIssue_obj is NOT NULL ) then void:= call New_HealthIssue_obj.Dispose; New_HealthIssue_obj:= null; endif; + endcatch; + + + + Elseif (dlg_result as string) = "No" then + + //void:= ""; + lst1 := theObservation.valueObj.ListItemsList ; + + for i in lst1 do + if i.Isselected = true and i.value = "CHF" then + i.IsSelected := FALSE ; + endif; + enddo; + + endif; // If exists CHFHI + + endif; // If (dlg_result as string) = "Yes" + +endif; // If chronic = "CHF" + + + ;; + evoke: + ;; + logic: + +conclude true; + + ;; + action: + + + return thisDocumentCommunication; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_HEALTH_ISSUE_COPD.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_HEALTH_ISSUE_COPD.mlm new file mode 100644 index 0000000..1fd86ab --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_HEALTH_ISSUE_COPD.mlm @@ -0,0 +1,209 @@ +maintenance: + + title: DOC_SCH_Readmission_Health_Issue_COPD;; + mlmname: DOC_SCH_Readmission_Health_Issue_COPD;; + arden: version 5.5;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Chintan Tilwa;; + specialist: ;; + date: 2012-10-15;; + validation: testing;; + +library: + purpose: This MLM will create a Health Issue when an observation is charted on Readmission Risk Assessment. ;; + explanation: + Change History + ------------------------------------------------------------------------------------ + 09.30.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 HI Dynamic Creation with all details Like ICD10 Code, Snowmed Code etc And Duplicate HI Check Change. + 10.12.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 Coding Scheme [ICD10] And Duplicate Check of HI . +;; + keywords: ;; +knowledge: + type: data-driven;; + data: + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + + +// Determine which of the Chronic Conditions boxes is checked + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_CK_Chronic Conditions"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = this_parametername.ParameterGUID); + + + If true in (theObservation.ValueObj.ListItemsList.IsSelected where + theObservation.ValueObj.ListItemsList.Value = "COPD" + ) then chronic := "COPD"; + endif; + + +If chronic = "COPD" then + +(COPDHI) := read + { + " select distinct hi.shortname " + || "from cv3healthissuedeclaration hi with (nolock) " + || "join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID " + || "where hi.clientguid = " || clientGuid || " and hi.active = 1 and hi.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " + || "and hi.typecode not in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}chronic dx{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}dx comments{{{SINGLE-QUOTE}}}) " + || "And hi.ICD10Code is not null " // Added By Shivprasad on 29 Sept 2015 for ICD9-10 Changes + || "and ( " + || "hi.text like {{{SINGLE-QUOTE}}}%copd%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%copd%{{{SINGLE-QUOTE}}} or " + || "(case when chi.typecode = {{{SINGLE-QUOTE}}}imo{{{SINGLE-QUOTE}}} then substring(chi.code, 5, 20) " + || " when chi.TypeCode = {{{SINGLE-QUOTE}}}icd9{{{SINGLE-QUOTE}}} then chi.code " + || " when chi.TypeCode = {{{SINGLE-QUOTE}}}icd10{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}496{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}J44.9{{{SINGLE-QUOTE}}}) " // 10.12.2015-CSR#23359- ICD10 Coding Scheme and HI Duplicate check + || " ) " + || " AND ({{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} AND ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}3{{{SINGLE-QUOTE}}} OR ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}} AND hi.ChartGUID = " || SQL(chartGuid) || " ) OR hi.ClientVisitGUID = " || SQL(visitGuid) || " ) ) " + }; + +// Notify the user if a new Health Issue is about to be created and permit them to reverse them to cancel the process + + If not exists COPDHI AND thisDocumentCommunication.EventType <> "DocumentOpening" then + + dlg_result := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with + "\n This selection will create a chronic health issue of {{{SINGLE-QUOTE}}}" || chronic || "{{{SINGLE-QUOTE}}}" || + "\n\n Click {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to confirm your selection. " || + "\n\n Click {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} if you wish to change your selection. " || + "\n " + ,"Confirm COPD Documentation ", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + +// If the user responds by cliking the "Yes" button, proceed with creating the order + + If (dlg_result as string) = "Yes" then + + try + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}Retrieve client:{{-R}}\n" || + ex.Message || "\n\n"; + if ex.InnerException is not null net_object then + error_message := error_message || "Inner Exception: " || ex.InnerException.Message || "\n\n"; + endif; + if ( client_visit_obj is NOT NULL ) then + void:= call client_visit_obj.Dispose; client_visit_obj:= null; + endif; + endcatch; + + try + //--------------------------------------------------------- + // New HealthIssue Example + //--------------------------------------------------------- + + If chronic = "COPD" then issuename := "COPD (chronic obstructive pulmonary disease)"; + issuecode := "J44.9"; //"496"; // 10.12.2015-CSR#23359- ICD10 Coding Scheme and HI Duplicate check + endif; + + NewHealthIssueHIType := "Problem-Chronic"; + NewHealthIssueHICode := issuecode; + NewHealthIssueHIScheme := "ICD10" ; //"ICD9"; // 10.12.2015-CSR#23359- ICD10 Coding Scheme and HI Duplicate check + + dd := EXTRACT Day now; + mn := EXTRACT Month now; + yr := EXTRACT Year now; + +//--Start: CSR 23359-ICD9-ICD10 HI Change Added By shivprasad + Terms := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.FindIMOTerms with (NewHealthIssueHIScheme,NewHealthIssueHICode); + FOR i IN 1 SEQTO (Terms.Count as Number ) DO + HI_obj := Terms[i]; + HI_Name := HI_obj.TermName as string; + If HI_Name = issuename then + HI_NO := i ; + Endif; + ENDDO; + If HI_NO is Null Then + HI_NO :=1 ; + Endif; + New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with (client_visit_obj, NewHealthIssueHIType, Terms[HI_NO]); + +//--End Added by Shivprasad + + //New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with (client_visit_obj, NewHealthIssueHIType, NewHealthIssueHIScheme, NewHealthIssueHICode ); + + + PartialDate_obj := new net_object {{{SINGLE-QUOTE}}}PartialDate{{{SINGLE-QUOTE}}} with (yr as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, mn as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, dd as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}} ); + New_HealthIssue_obj.OnsetDate := PartialDate_obj; + New_HealthIssue_obj.Text := "Created from Readmission Risk Assessment . " ; + New_HealthIssue_obj.Name := issuename; + + + if ( New_HealthIssue_obj is NOT NULL ) then + void := call New_HealthIssue_obj.Save; + void := call New_HealthIssue_obj.Dispose; + endif; + + if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; + + endtry; + + catch exception ex + error_occurred := true; + if ( New_HealthIssue_obj is NOT NULL ) then void:= call New_HealthIssue_obj.Dispose; New_HealthIssue_obj:= null; endif; + endcatch; + + + + Elseif (dlg_result as string) = "No" then + + //void:= ""; + lst1 := theObservation.valueObj.ListItemsList ; + + for i in lst1 do + if i.Isselected = true and i.value = "COPD" then + i.IsSelected := FALSE ; + endif; + enddo; + + endif; // If exists COPDHI + + endif; // If (dlg_result as string) = "Yes" + +endif; // If chronic = "COPD" + + ;; + evoke: + ;; + logic: + +conclude true; + + ;; + action: + + + return thisDocumentCommunication; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_HEALTH_ISSUE_DIABETES.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_HEALTH_ISSUE_DIABETES.mlm new file mode 100644 index 0000000..8baf358 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_HEALTH_ISSUE_DIABETES.mlm @@ -0,0 +1,223 @@ +maintenance: + + title: DOC_SCH_Readmission_Health_Issue_Diabetes;; + mlmname: DOC_SCH_Readmission_Health_Issue_Diabetes;; + arden: version 5.5;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Chintan Tilwa;; + specialist: ;; + date: 2012-10-15;; + validation: testing;; + +library: + purpose: This MLM will create a Health Issue when an observation is charted on Readmission Risk Assessment. ;; + explanation: +Change History +----------------------------------------- + 09.30.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 HI Dynamic Creation with all details Like ICD10 Code, Snowmed Code etc And Duplicate HI Check Change. + 10.12.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 Coding Scheme [ICD10] And Duplicate Check of HI . +;; + keywords: ;; +knowledge: + type: data-driven;; + data: + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + // Determine which of the Chronic Conditions boxes is checked + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_CK_Chronic Conditions"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = this_parametername.ParameterGUID); + + If true in (theObservation.ValueObj.ListItemsList.IsSelected where + theObservation.ValueObj.ListItemsList.Value = "Diabetes" + ) then chronic := "Diabetes"; + endif; + + this_parametername1 := first of (thisParameters where thisParameters.Name = "SCH_CK_Diagnosis Risk"); + theObservation1 := first of (thisobservations where thisobservations.ParameterGUID = this_parametername1.ParameterGUID); + + If true in (theObservation1.ValueObj.ListItemsList.IsSelected where + theObservation1.ValueObj.ListItemsList.Value = "New Onset Diabetes" + ) then chronic := "Diabetes"; + endif; + +// If the patient have health issue, determine if they already have a Health Issue in their record + + If chronic = "Diabetes" then +(DiabetesHI) := read + { + " select distinct hi.shortname " + || "from cv3healthissuedeclaration hi with (nolock) " + || "join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID " + || "where hi.clientguid = " || clientGuid || " and hi.active = 1 and hi.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " + || "and hi.typecode not in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}chronic dx{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}dx comments{{{SINGLE-QUOTE}}}) " + || "and hi.ICD10Code is not null " // Added By Shivprasad on 29 Sept 2015 for ICD9-10 Changes + || "and ( " + || "hi.text like {{{SINGLE-QUOTE}}}%Diabetes%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Diabetes%{{{SINGLE-QUOTE}}} or " + || "(case when chi.typecode = {{{SINGLE-QUOTE}}}imo{{{SINGLE-QUOTE}}} then substring(chi.code, 5, 20) " + || " when chi.TypeCode = {{{SINGLE-QUOTE}}}icd9{{{SINGLE-QUOTE}}} then chi.code " + || " when chi.TypeCode = {{{SINGLE-QUOTE}}}icd10{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}250.00{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}E11.9{{{SINGLE-QUOTE}}})" //CSR#23359-ICD9-ICD10 HI Change for Code Scheme ICD10- Added By shivprasad + || " ) and ( " + || "hi.description not like {{{SINGLE-QUOTE}}}Diabetes, Gestational%{{{SINGLE-QUOTE}}} or hi.shortname not like {{{SINGLE-QUOTE}}}Diabetes, Gestational%{{{SINGLE-QUOTE}}})" + + || " AND ({{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} AND ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}3{{{SINGLE-QUOTE}}} OR ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}} AND hi.ChartGUID = " || SQL(chartGuid) || " ) OR hi.ClientVisitGUID = " || SQL(visitGuid) || " ) ) " + }; + +// Notify the user if a new Health Issue is about to be created and permit them to reverse them to cancel the process + + If not exists DiabetesHI AND thisDocumentCommunication.EventType <> "DocumentOpening" then + + dlg_result := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with + "\n This selection will create a chronic health issue of {{{SINGLE-QUOTE}}}" || chronic || "{{{SINGLE-QUOTE}}}" || + "\n\n Click {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to confirm your selection. " || + "\n\n Click {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} if you wish to change your selection. " || + "\n " + ,"Confirm Diabetes Documentation ", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + +// If the user responds by cliking the "Yes" button, proceed with creating the order + + If (dlg_result as string) = "Yes" then + + try + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}Retrieve client:{{-R}}\n" || + ex.Message || "\n\n"; + if ex.InnerException is not null net_object then + error_message := error_message || "Inner Exception: " || ex.InnerException.Message || "\n\n"; + endif; + if ( client_visit_obj is NOT NULL ) then + void:= call client_visit_obj.Dispose; client_visit_obj:= null; + endif; + endcatch; + + try + //--------------------------------------------------------- + // New HealthIssue Example + //--------------------------------------------------------- + + + If chronic = "Diabetes" then issuename := "Diabetes mellitus"; + issuecode := "E11.9";//"250.00"; CSR#23359-ICD9-ICD10 HI Change for Code Scheme ICD10- Added By shivprasad + endif; + + NewHealthIssueHIType := "Problem-Chronic"; + NewHealthIssueHICode := issuecode; + NewHealthIssueHIScheme := "ICD10"; //"ICD9"; CSR#23359-ICD9-ICD10 HI Change for Code Scheme ICD10- Added By shivprasad + + dd := EXTRACT Day now; + mn := EXTRACT Month now; + yr := EXTRACT Year now; + +//--Start: CSR 23359-ICD9-ICD10 HI Change Added By shivprasad + Terms := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.FindIMOTerms with (NewHealthIssueHIScheme,NewHealthIssueHICode); + FOR i IN 1 SEQTO (Terms.Count as Number ) DO + HI_obj := Terms[i]; + HI_Name := HI_obj.TermName as string; + If HI_Name = issuename then + HI_NO := i ; + Endif; + ENDDO; + If HI_NO is Null Then + HI_NO :=1 ; + Endif; + New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with (client_visit_obj, NewHealthIssueHIType, Terms[HI_NO]); + +//--End Added by Shivprasad + + //New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with (client_visit_obj, NewHealthIssueHIType, NewHealthIssueHIScheme, NewHealthIssueHICode ); + + PartialDate_obj := new net_object {{{SINGLE-QUOTE}}}PartialDate{{{SINGLE-QUOTE}}} with (yr as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, mn as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, dd as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}} ); + New_HealthIssue_obj.OnsetDate := PartialDate_obj; + New_HealthIssue_obj.Text := "Created from Readmission Risk Assessment . " ; + New_HealthIssue_obj.Name := issuename; + + + if ( New_HealthIssue_obj is NOT NULL ) then + void := call New_HealthIssue_obj.Save; + void := call New_HealthIssue_obj.Dispose; + endif; + + if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; + + endtry; + + catch exception ex + error_occurred := true; + if ( New_HealthIssue_obj is NOT NULL ) then void:= call New_HealthIssue_obj.Dispose; New_HealthIssue_obj:= null; endif; + endcatch; + + + + Elseif (dlg_result as string) = "No" then + + //void:= ""; + lst1 := theObservation.valueObj.ListItemsList ; + lst2 := theObservation1.valueObj.ListItemsList ; + for i in lst1 do + if i.Isselected = true and i.value = "Diabetes" then + i.IsSelected := FALSE ; + endif; + enddo; + for i in lst2 do + if i.Isselected = true and i.value = "New Onset Diabetes" then + i.IsSelected := FALSE ; + endif; + enddo; + + + endif; // If exists DiabetesHI + + endif; // If (dlg_result as string) = "Yes" + +endif; // If chronic = "Diabetes" + + + ;; + evoke: + ;; + logic: + +conclude true; + + ;; + action: + + + return thisDocumentCommunication; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_HEALTH_ISSUE_RENAL.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_HEALTH_ISSUE_RENAL.mlm new file mode 100644 index 0000000..89be8e6 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_HEALTH_ISSUE_RENAL.mlm @@ -0,0 +1,210 @@ +maintenance: + + title: DOC_SCH_Readmission_Health_Issue_Renal;; + mlmname: DOC_SCH_Readmission_Health_Issue_Renal;; + arden: version 5.5;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Chintan Tilwa;; + specialist: ;; + date: 2012-10-15;; + validation: testing;; + +library: + purpose: This MLM will create a Health Issue when an observation is charted on Readmission Risk Assessment. ;; + explanation: +Change history +------------------------------ + 09.30.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 HI Dynamic Creation with all details Like ICD10 Code, Snowmed Code etc And Duplicate HI Check Change. + 10.12.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 Coding Scheme [ICD10] And Duplicate Check of HI . +;; + keywords: ;; +knowledge: + type: data-driven;; + data: + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + +// Determine which of the Chronic Conditions boxes is checked + + this_parametername := first of (thisParameters where thisParameters.Name = "SCH_CK_Chronic Conditions"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = this_parametername.ParameterGUID); + + If true in (theObservation.ValueObj.ListItemsList.IsSelected where + theObservation.ValueObj.ListItemsList.Value = "Renal Failure" + ) then chronic := "Renal Failure"; + endif; + +// If the patient have health issue, determine if they already have a Health Issue in their record + + If chronic = "Renal Failure" then + + (RenalHI) := read + { + " select distinct hi.shortname " + || "from cv3healthissuedeclaration hi with (nolock) " + || "join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID " + || "where hi.clientguid = " || clientGuid || " and hi.active = 1 and hi.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " + || "and hi.typecode not in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}chronic dx{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}dx comments{{{SINGLE-QUOTE}}}) " + || "And hi.ICD10Code is not null " // Added By Shivprasad on 29 Sept 2015 for ICD9-10 Changes + || "and ( " + || "hi.text like {{{SINGLE-QUOTE}}}%Renal Failure%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Renal Failure%{{{SINGLE-QUOTE}}} or " + || "(case when chi.typecode = {{{SINGLE-QUOTE}}}imo{{{SINGLE-QUOTE}}} then substring(chi.code, 5, 20) " + || " when chi.TypeCode = {{{SINGLE-QUOTE}}}icd9{{{SINGLE-QUOTE}}} then chi.code " + || " when chi.TypeCode = {{{SINGLE-QUOTE}}}icd10{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}586{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}N19{{{SINGLE-QUOTE}}}) " //CSR#23359-ICD9-ICD10 HI Change for Code Scheme ICD10- Added By shivprasad + || " ) " + || " AND ({{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} AND ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}3{{{SINGLE-QUOTE}}} OR ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}} AND hi.ChartGUID = " || SQL(chartGuid) || " ) OR hi.ClientVisitGUID = " || SQL(visitGuid) || " ) ) " + }; + + +// Notify the user if a new Health Issue is about to be created and permit them to reverse them to cancel the process + + If not exists RenalHI AND thisDocumentCommunication.EventType <> "DocumentOpening" then + + dlg_result := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with + "\n This selection will create a chronic health issue of {{{SINGLE-QUOTE}}}" || chronic || "{{{SINGLE-QUOTE}}}" || + "\n\n Click {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to confirm your selection. " || + "\n\n Click {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} if you wish to change your selection. " || + "\n " + ,"Confirm Renal Failure Documentation ", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + +// If the user responds by cliking the "Yes" button, proceed with creating the order + + If (dlg_result as string) = "Yes" then + + try + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}Retrieve client:{{-R}}\n" || + ex.Message || "\n\n"; + if ex.InnerException is not null net_object then + error_message := error_message || "Inner Exception: " || ex.InnerException.Message || "\n\n"; + endif; + if ( client_visit_obj is NOT NULL ) then + void:= call client_visit_obj.Dispose; client_visit_obj:= null; + endif; + endcatch; + + try + //--------------------------------------------------------- + // New HealthIssue Example + //--------------------------------------------------------- + + + If chronic = "Renal Failure" then issuename := "Renal failure"; + issuecode := "N19" ; //"586"; CSR#23359-ICD9-ICD10 HI Change for Code Scheme ICD10- Added By shivprasad + endif; + + NewHealthIssueHIType := "Problem-Chronic"; + NewHealthIssueHICode := issuecode; + NewHealthIssueHIScheme := "ICD10" ;// "ICD9"; CSR#23359-ICD9-ICD10 HI Change for Code Scheme ICD10- Added By shivprasad + + dd := EXTRACT Day now; + mn := EXTRACT Month now; + yr := EXTRACT Year now; + +//--Start: CSR 23359-ICD9-ICD10 HI Change Added By shivprasad + Terms := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.FindIMOTerms with (NewHealthIssueHIScheme,NewHealthIssueHICode); + FOR i IN 1 SEQTO (Terms.Count as Number ) DO + HI_obj := Terms[i]; + HI_Name := HI_obj.TermName as string; + If HI_Name = issuename then + HI_NO := i ; + Endif; + ENDDO; + If HI_NO is Null Then + HI_NO :=1 ; + Endif; + New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with (client_visit_obj, NewHealthIssueHIType, Terms[HI_NO]); + +//--End Added by Shivprasad + + //New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with (client_visit_obj, NewHealthIssueHIType, NewHealthIssueHIScheme, NewHealthIssueHICode ); + + PartialDate_obj := new net_object {{{SINGLE-QUOTE}}}PartialDate{{{SINGLE-QUOTE}}} with (yr as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, mn as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, dd as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}} ); + New_HealthIssue_obj.OnsetDate := PartialDate_obj; + New_HealthIssue_obj.Text := "Created from Readmission Risk Assessment . " ; + New_HealthIssue_obj.Name := issuename; + + + if ( New_HealthIssue_obj is NOT NULL ) then + void := call New_HealthIssue_obj.Save; + void := call New_HealthIssue_obj.Dispose; + endif; + + if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; + + endtry; + + catch exception ex + error_occurred := true; + if ( New_HealthIssue_obj is NOT NULL ) then void:= call New_HealthIssue_obj.Dispose; New_HealthIssue_obj:= null; endif; + endcatch; + + + + Elseif (dlg_result as string) = "No" then + + //void:= ""; + lst1 := theObservation.valueObj.ListItemsList ; + + for i in lst1 do + if i.Isselected = true and i.value = "Renal Failure" then + i.IsSelected := FALSE ; + endif; + enddo; + + endif; // If exists RenalHI + + endif; // If (dlg_result as string) = "Yes" + +endif; // If chronic = "Renal Failure" + + + ;; + evoke: + ;; + logic: + +conclude true; + + ;; + action: + + + return thisDocumentCommunication; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_RISK_ASSESSMENTS.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_RISK_ASSESSMENTS.mlm new file mode 100644 index 0000000..a2fd874 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_RISK_ASSESSMENTS.mlm @@ -0,0 +1,245 @@ +maintenance: + + title: DOC_SCH_Readmission_Risk_Assessments;; + mlmname: DOC_SCH_Readmission_Risk_Assessments;; + arden: version 2.5;; + version: 5.50;; + institution: SCH ;; + author: Chintan Tilwa ;; + specialist: ;; + date: 2012-10-10;; + validation: testing;; +library: + purpose: + ;; + explanation: + + Change history + + 10.15.2012 CT CSR# 30880 - Created by GOS for Readmission Initiative Project + 04.30.2013 DW CSR# 31334 - Adjusted to support the re-configuration of Pregnancy & Lactation questions + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + (this_documentCommunication) := argument; + + //Get The Structure Note + (this_FS_doc) := this_documentCommunication.DocumentConfigurationObj; + //Get the Parameter List + (this_parms) := this_FS_doc.ParametersList; + //Paramters defination + (this_cols) := this_FS_doc.ColumnsList; + (this_curr_col) := this_FS_doc.Currentcolumn; + (this_currentObs) := this_documentCommunication.CurrentObservationObj; + (this_observations) := this_FS_doc.ChartedObservationsList; + (this_curr_valobj) := this_currentObs.valueobj; + + if ((this_documentCommunication.DocumentName = "Adult Patient Profile") OR + (this_documentCommunication.DocumentName = "Adult Patient Profile - Observation")) then + + MLM_DIPA := MLM {{{SINGLE-QUOTE}}}UTIL_OBJECT_Customize_DIPA_MLM{{{SINGLE-QUOTE}}}; + + Client_GUID := this_documentCommunication.ClientGUID; + Client_Visit_GUID := this_documentCommunication.ClientVisitGUID; + + prm1 := first of (this_parms where this_parms.Name = "SCH_CK_Prior Pattern_2"); + Obs := first of (this_observations where this_observations.ParameterGUID = prm1.ParameterGUID ); + lst1 := Obs.valueObj.ListItemsList ; + + (Pre_Visit) := Read Last {"select COUNT(1) as No_Visit from CV3ClientVisit where ClientGUID = " || SQL(Client_GUID) || " and GUID <> " || SQL(Client_Visit_GUID) || " and TypeCode in ({{{SINGLE-QUOTE}}}Inpatient{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Emergency{{{SINGLE-QUOTE}}}) and (AdmitDtm between GETDATE()-90 and GETDATE())"}; + + (Pat_Falls) := Read Last {"select Description from CV3ClientEventDeclaration where ClientGUID = " || SQL(Client_GUID) || " and TypeCode = {{{SINGLE-QUOTE}}}Fall History{{{SINGLE-QUOTE}}} and Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}}"}; + + + //sel1 := last of( lst1.Value where lst1.IsSelected = true ); + + final_List := (); + + If Pre_Visit > 3 Then + + final_List := final_List , ">3 hospitalizations or ER Visits in past 3 months" ; + + endif; + + If exist Pat_Falls Then + + final_List := final_List , "History of Falls" ; + + endif; + + for i in lst1 do + if i.Isselected = true then + final_List := final_List , i.Value ; + endif; + enddo; + + obs1 := CALL MLM_DIPA WITH this_DocumentCommunication, prm1, final_List; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs1); + + + MLM_Score := MLM {{{SINGLE-QUOTE}}}DOC_SCH_Readmission_Risk_Score{{{SINGLE-QUOTE}}}; + obs_Score := Call MLM_Score With this_documentCommunication; + + MLM_Obs_Score := MLM {{{SINGLE-QUOTE}}}DOC_SCH_Readmission_Risk_Observation_Score{{{SINGLE-QUOTE}}}; + obs1_Score := Call MLM_Obs_Score With this_documentCommunication; + + + //Clear Session variables + local_session := CDS_SESSION.local; + local_session.SessionReadmissionPharmacy := ""; + local_session.SessionReadmissionDiagnosis := ""; + local_session.SessionReadmissionDischarge := ""; + local_session.SessionReadmissionFunctional := ""; + local_session.SessionReadmissionDevice := ""; + local_session.SessionReadmissionNutritional := ""; + local_session.SessionReadmissionSmoking := ""; + local_session.SessionReadmissionDiagnosisForMessage := ""; + local_session.SessionNutritionalForMessage := ""; + //local_session.SessionReadmissionScore := ""; + local_session.SessionDeviceMessage := ""; + local_session.SessionSmokingForMessage := ""; + + + // Set session object for risks that are selected + + + prm := first of (this_parms where this_parms.Name = "SCH_CK_Nutritional Risk"); + Obs := first of (this_observations where this_observations.ParameterGUID = prm.ParameterGUID); + lst1 := Obs.valueObj.ListItemsList ; + + strSelectedNut := ""; + for i in lst1 do + if i.Isselected = true Then + If i.value <> "No Nutritional Risk Criteria" then + List1 := List1 , i.Value ; + EndIF; + strSelectedNut := strSelectedNut || "`" || i.Value; + endif; + enddo; + local_session.SessionNutritionalForMessage := strSelectedNut; + + + prm := first of (this_parms where this_parms.Name = "SCH_CK_Device(s) on admission, ED, and OR"); + Obs := first of (this_observations where this_observations.ParameterGUID = prm.ParameterGUID); + lst1 := Obs.valueObj.ListItemsList ; + + SessionDeviceMessage := local_session.sessionDeviceMessage ; + + for i in lst1 do + if i.Isselected = true Then + strSelectedDev := strSelectedDev || ", " || i.Value; + endif; + + enddo; + local_session.sessionDeviceMessage := strSelectedDev; + + strSelectedNut := ""; + prm := first of (this_parms where this_parms.Name = "SCH_CK_Smoking Risk"); + Obs := first of (this_observations where this_observations.ParameterGUID = prm.ParameterGUID); + lst1 := Obs.valueObj.ListItemsList ; + + for i in lst1 do + if i.Isselected = true Then + strSelectedNut := strSelectedNut || "`" || i.Value; + endif; + enddo; + local_session.SessionSmokingForMessage := strSelectedNut; + + + prm := first of (this_parms where this_parms.Name = "SCH_CK_Diagnosis Risk"); + Obs := first of (this_observations where this_observations.ParameterGUID = prm.ParameterGUID); + lst1 := Obs.valueObj.ListItemsList ; + sel1Col := lst1.Value where lst1.IsSelected = true ; + + if "New Onset Diabetes" in sel1Col then + local_session.SessionReadmissionDiagnosisForMessage := "New Onset Diabetes"; + EndIF; + + + + // Determine if the patient Pregnacy Risk is N/A (males and females not of child bearing age) + + + (gender, patientage) := read last + { + " select " + ||" gendercode, case when " + ||" right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (datepart (MM,getdate()) as varchar),2) + right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (datepart (DD,getdate()) as varchar),2) < " + ||" right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (birthmonthnum as varchar),2) + right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (birthdaynum as varchar),2) " + ||" then datediff (yy, cast (birthyearnum as varchar) ,getdate()) -1 " + ||" else datediff (yy, cast (birthyearnum as varchar) ,getdate()) " + ||" end " + ||" from cv3client with (nolock) where guid = " || Client_GUID || " " + }; + + if (patientage as number) <= 9 or (patientage as number) >= 56 or gender = "male" + then + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Set Pregnant to N/A + + this_parametername := first of (this_parms where this_parms.Name = "SCH_PRO fem repro pg yn"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= this_FS_doc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "not applicable" then selectedItem.IsSelected := true; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + this_FS_doc.ChartedObservationsList := (this_FS_doc.ChartedObservationsList, this_currentObj); + + // Set Breast Feeding to N/A + + this_parametername := first of (this_parms where this_parms.Name = "SCH_PRO fem repro breastfeed yn"); + this_currentObj := NEW ObservationType; + this_currentObj.ClientDocumentGUID:= this_FS_doc.ClientDocumentGUID; + this_currentObj.ParameterGUID := this_parametername.ParameterGUID; + this_currentObj.DataType := "ListValue"; + this_currentObj.ValueObj := New ListValueType; + this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; + + listItems := (); + FOR item IN this_parametername.ConfigurationObj.ListItemsList DO + selectedItem := NEW ListValueListItemType; + selectedItem.ListItemGUID := item.ListItemGUID; + selectedItem.Value := item.Value; + if selectedItem.Value = "not applicable" then selectedItem.IsSelected := true; endif; + listItems := (listItems, selectedItem); + ENDDO; + this_currentobj.ValueObj.ListItemsList := listItems; + this_FS_doc.ChartedObservationsList := (this_FS_doc.ChartedObservationsList, this_currentObj); + + + endif; + + endif; + ;; + priority: 50 + ;; + evoke: + ;; + logic: + Conclude true; + ;; + action: + return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_RISK_CHRONIC.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_RISK_CHRONIC.mlm new file mode 100644 index 0000000..a965544 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_RISK_CHRONIC.mlm @@ -0,0 +1,197 @@ +maintenance: + + title: DOC_SCH_Readmission_Risk_Chronic ;; + mlmname: DOC_SCH_Readmission_Risk_Chronic ;; + arden: version 2.5;; + version: 5.50;; + institution: SCH ;; + author: Chintan Tilwa ;; + specialist: ;; + date: 2012-10-10;; + validation: testing;; +library: + purpose: + ;; + explanation: + + + Change history + + 09.10.2015 DW CSR# 23359 - ICD10 + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + (this_documentCommunication) := argument; + + //Get The Structure Note + (this_FS_doc) := this_documentCommunication.DocumentConfigurationObj; + //Get the Parameter List + (this_parms) := this_FS_doc.ParametersList; + //Paramters defination + (this_cols) := this_FS_doc.ColumnsList; + (this_curr_col) := this_FS_doc.Currentcolumn; + (this_currentObs) := this_documentCommunication.CurrentObservationObj; + (this_observations) := this_FS_doc.ChartedObservationsList; + (this_curr_valobj) := this_currentObs.valueobj; + + MLM_DIPA := MLM {{{SINGLE-QUOTE}}}UTIL_OBJECT_Customize_DIPA_MLM{{{SINGLE-QUOTE}}}; + + Client_GUID := this_documentCommunication.ClientGUID; + Client_Visit_GUID := this_documentCommunication.ClientVisitGUID; + ChartGUID := this_documentCommunication.ChartGUID; + + prm1 := first of (this_parms where this_parms.Name = "SCH_CK_Retrieve_Chronic Conditions"); + Obs1 := first of (this_observations where this_observations.ParameterGUID = prm1.ParameterGUID ); + lst1 := Obs1.valueObj.ListItemsList ; + sel1 := first of( lst1.Value where lst1.IsSelected = true ); + + prm2 := first of (this_parms where this_parms.Name = "SCH_CK_Chronic Conditions"); + + /* Replaced with ICD10 project + (Pat_Chronic) := Read {"Select Distinct hi.shortname + from CV3HealthIssueDeclaration hi (nolock) + join CV3CodedHealthIssue chi (nolock) on chi.GUID = hi.CodedHealthIssueGUID + where hi.ClientGUID = " || SQL(Client_GUID) || " + and hi.active = 1 and hi.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} + and hi.typecode not in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}chronic dx{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}dx comments{{{SINGLE-QUOTE}}}) + and (hi.text like {{{SINGLE-QUOTE}}}%Diabetes%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Diabetes%{{{SINGLE-QUOTE}}} or + hi.text like {{{SINGLE-QUOTE}}}%Renal Failure%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Renal Failure%{{{SINGLE-QUOTE}}} or + hi.text like {{{SINGLE-QUOTE}}}%CHF%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%CHF%{{{SINGLE-QUOTE}}} or + hi.text like {{{SINGLE-QUOTE}}}%Congestive Heart Failure%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Congestive Heart Failure%{{{SINGLE-QUOTE}}} or + hi.text like {{{SINGLE-QUOTE}}}%copd%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%copd%{{{SINGLE-QUOTE}}} or + (case when chi.typecode = {{{SINGLE-QUOTE}}}imo{{{SINGLE-QUOTE}}} then substring(chi.code, 5, 20) when chi.TypeCode = {{{SINGLE-QUOTE}}}icd9{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}586{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}250.00{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}496{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}428.0{{{SINGLE-QUOTE}}})) + and (hi.description not like {{{SINGLE-QUOTE}}}Diabetes, Gestational%{{{SINGLE-QUOTE}}} or hi.shortname not like {{{SINGLE-QUOTE}}}Diabetes, Gestational%{{{SINGLE-QUOTE}}}) + AND ({{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} AND ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}3{{{SINGLE-QUOTE}}} OR ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}} AND hi.ChartGUID = " || SQL(ChartGUID) || " ) OR hi.ClientVisitGUID = " || SQL(Client_Visit_GUID) || " ) ) " +}; + */ + + (Pat_Chronic) := Read {"Select Distinct hi.shortname + from CV3HealthIssueDeclaration hi (nolock) + join CV3CodedHealthIssue chi (nolock) on chi.GUID = hi.CodedHealthIssueGUID + where hi.ClientGUID = " || SQL(Client_GUID) || " + and hi.active = 1 and hi.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} + and hi.typecode not in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}chronic dx{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}dx comments{{{SINGLE-QUOTE}}}) + and (hi.text like {{{SINGLE-QUOTE}}}%Diabetes%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Diabetes%{{{SINGLE-QUOTE}}} or + hi.text like {{{SINGLE-QUOTE}}}%Renal Failure%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Renal Failure%{{{SINGLE-QUOTE}}} or + hi.text like {{{SINGLE-QUOTE}}}%CHF%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%CHF%{{{SINGLE-QUOTE}}} or + hi.text like {{{SINGLE-QUOTE}}}%Congestive Heart Failure%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Congestive Heart Failure%{{{SINGLE-QUOTE}}} or + hi.text like {{{SINGLE-QUOTE}}}%copd%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%copd%{{{SINGLE-QUOTE}}} or + ( + (hi.ICD9Code is null and chi.code in ({{{SINGLE-QUOTE}}}586{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}250.00{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}496{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}428.0{{{SINGLE-QUOTE}}}) ) + or + (hi.ICD9Code is not null and hi.ICD9Code in ({{{SINGLE-QUOTE}}}586{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}250.00{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}496{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}428.0{{{SINGLE-QUOTE}}}) ) + ) + ) + and (hi.description not like {{{SINGLE-QUOTE}}}Diabetes, Gestational%{{{SINGLE-QUOTE}}} or hi.shortname not like {{{SINGLE-QUOTE}}}Diabetes, Gestational%{{{SINGLE-QUOTE}}}) + AND ({{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} AND ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}3{{{SINGLE-QUOTE}}} OR ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}} AND hi.ChartGUID = " || SQL(ChartGUID) || " ) OR hi.ClientVisitGUID = " || SQL(Client_Visit_GUID) || " ) ) " +}; + + + + final_List1 := (); + final_Text := "" ; + final_Text1 := "" ; + final_Text2 := "" ; + final_Text3 := "" ; + final_Text4 := "" ; + + Pat_Chronic_List := 1 seqto (count Pat_Chronic); + + For i in Pat_Chronic_List do + + If ( Pat_Chronic[i] Matches pattern "%Diabetes%" ) Then + + final_List1 := final_List1 , "Diabetes" ; + final_Text1 := Pat_Chronic[i] ; + + Elseif ( Pat_Chronic[i] Matches pattern "%Renal Failure%" ) Then + + final_List1 := final_List1 , "Renal Failure" ; + final_Text2 := Pat_Chronic[i] ; + + Elseif ( Pat_Chronic[i] Matches pattern "%CHF%" or Pat_Chronic[i] Matches pattern "%Congestive Heart Failure%" ) Then + + final_List1 := final_List1 , "CHF" ; + final_Text3 := Pat_Chronic[i] ; + + Elseif ( Pat_Chronic[i] Matches pattern "%copd%" ) Then + + final_List1 := final_List1 , "COPD" ; + final_Text4 := Pat_Chronic[i] ; + + endif; + + Enddo; + + If final_Text1 <> "" then + final_Text := final_Text1; + Endif; + If final_Text2 <> "" then + if final_Text <> "" then + final_Text := final_Text || ", " || final_Text2 ; + else + final_Text := final_Text2; + endif; + Endif; + If final_Text3 <> "" then + if final_Text <> "" then + final_Text := final_Text || ", " || final_Text3 ; + else + final_Text := final_Text3; + endif; + Endif; + If final_Text4 <> "" then + if final_Text <> "" then + final_Text := final_Text || ", " || final_Text4 ; + else + final_Text := final_Text4; + endif; + Endif; + + prm3 := first of (this_parms where this_parms.Name = "SCH_CK_Retrieve_Chronic Conditions_FT"); + + If ( sel1 = "" OR sel1 is null ) then + + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm2, ""; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + + obs3 := CALL MLM_DIPA WITH this_DocumentCommunication, prm3, "" ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs3); + + Endif; + + If ( sel1 = "Retrieve Chronic Conditions Related History" ) then + + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm2, final_List1; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + + obs3 := CALL MLM_DIPA WITH this_DocumentCommunication, prm3, final_Text ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs3); + + Endif; + + MLM_Score := MLM {{{SINGLE-QUOTE}}}DOC_SCH_Readmission_Risk_Score{{{SINGLE-QUOTE}}}; + obs_Score := Call MLM_Score With this_documentCommunication; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: + Conclude true; + ;; + action: + return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_RISK_OBSERVATION_SCORE.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_RISK_OBSERVATION_SCORE.mlm new file mode 100644 index 0000000..1254eac --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_RISK_OBSERVATION_SCORE.mlm @@ -0,0 +1,258 @@ +maintenance: + + title: DOC_SCH_Readmission_Risk_Observation_Score;; + mlmname: DOC_SCH_Readmission_Risk_Observation_Score;; + arden: version 2.5;; + version: 5.50;; + institution: SCH ;; + author: Chintan Tilwa ;; + specialist: ;; + date: 2012-10-10;; + validation: testing;; +library: + purpose: + ;; + explanation: + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + (this_documentCommunication) := argument; + + local_session := CDS_SESSION.local; + + //Get The Structure Note + (this_FS_doc) := this_documentCommunication.DocumentConfigurationObj; + //Get the Parameter List + (this_parms) := this_FS_doc.ParametersList; + //Paramters defination + (this_cols) := this_FS_doc.ColumnsList; + (this_curr_col) := this_FS_doc.Currentcolumn; + (this_currentObs) := this_documentCommunication.CurrentObservationObj; + (this_observations) := this_FS_doc.ChartedObservationsList; + (this_curr_valobj) := this_currentObs.valueobj; + + MLM_DIPA := MLM {{{SINGLE-QUOTE}}}UTIL_OBJECT_Customize_DIPA_MLM{{{SINGLE-QUOTE}}}; + + MLM_HI := MLM {{{SINGLE-QUOTE}}}DOC_SCH_Readmission_Health_Issue_CHF{{{SINGLE-QUOTE}}}; + obs_HI := Call MLM_HI With this_documentCommunication; + + MLM_HI1 := MLM {{{SINGLE-QUOTE}}}DOC_SCH_Readmission_Health_Issue_COPD{{{SINGLE-QUOTE}}}; + obs_HI1 := Call MLM_HI1 With this_documentCommunication; + + MLM_HI2 := MLM {{{SINGLE-QUOTE}}}DOC_SCH_Readmission_Health_Issue_Diabetes{{{SINGLE-QUOTE}}}; + obs_HI2 := Call MLM_HI2 With this_documentCommunication; + + MLM_HI3 := MLM {{{SINGLE-QUOTE}}}DOC_SCH_Readmission_Health_Issue_Renal{{{SINGLE-QUOTE}}}; + obs_HI3 := Call MLM_HI3 With this_documentCommunication; + + Client_GUID := this_documentCommunication.ClientGUID; + Client_Visit_GUID := this_documentCommunication.ClientVisitGUID; + + prm1 := first of (this_parms where this_parms.Name = "SCH_CK_Prior Pattern_2"); + Obs1 := first of (this_observations where this_observations.ParameterGUID = prm1.ParameterGUID); + lst1 := Obs1.valueObj.ListItemsList ; + sel1 := first of ( lst1.Value where lst1.IsSelected = true and lst1.Value = ">3 hospitalizations or ER Visits in past 3 months" ); + sel2 := first of ( lst1.Value where lst1.IsSelected = true and lst1.Value = "History of Falls" ); + + If ( sel1 = ">3 hospitalizations or ER Visits in past 3 months" ) Then + val1 := 1; + Endif; + If ( sel2 = "History of Falls" ) Then + val2 := 1; + Endif; + + prm2 := first of (this_parms where this_parms.Name = "SCH_CK_Chronic Conditions"); + Obs2 := first of (this_observations where this_observations.ParameterGUID = prm2.ParameterGUID); + lst2 := Obs2.valueObj.ListItemsList ; + + sel3 := first of ( lst2.Value where lst2.IsSelected = true and lst2.Value = "CHF" ) ; + sel4 := first of ( lst2.Value where lst2.IsSelected = true and lst2.Value = "COPD" ) ; + sel5 := first of ( lst2.Value where lst2.IsSelected = true and lst2.Value = "Diabetes" ) ; + sel6 := first of ( lst2.Value where lst2.IsSelected = true and lst2.Value = "Renal Failure" ) ; + + If ( sel3 = "CHF" ) Then + val3 := 1; + Endif; + If ( sel4 = "COPD" ) Then + val4 := 1; + Endif; + If ( sel5 = "Diabetes" ) Then + val5 := 1; + Endif; + If ( sel6 = "Renal Failure" ) Then + val6 := 1; + Endif; + + prm3 := first of (this_parms where this_parms.Name = "SCH_CK_Risk Factors"); + Obs3 := first of (this_observations where this_observations.ParameterGUID = prm3.ParameterGUID); + lst3 := Obs3.valueObj.ListItemsList ; + + sel7 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "More than 2 secondary diagnoses" ) ; + sel8 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Low social economic status or limited financial resources" ) ; + sel9 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Lives alone" ) ; + sel10 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Limited support network" ) ; + sel11 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "ADL assistance needed" ) ; + sel12 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Home safety risks" ) ; + sel13 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Dyspnea" ) ; + sel14 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Pressure or Stasis Ulcer" ) ; + sel15 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Short life expectancy" ) ; + sel16 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Help with managing medications needed" ) ; + sel17 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Non-compliance with medication regimen" ) ; + sel18 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Difficulty reading" ) ; + sel19 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Confusion" ) ; + //break; + + If ( sel7 = "More than 2 secondary diagnoses" ) Then + val7 := 1; + Endif; + If ( sel8 = "Low social economic status or limited financial resources" ) Then + val8 := 1; + Endif; + If ( sel9 = "Lives alone" ) Then + val9 := 1; + Endif; + If ( sel10 = "Limited support network" ) Then + val10 := 1; + Endif; + If ( sel11 = "ADL assistance needed" ) Then + val11 := 1; + Endif; + If ( sel12 = "Home safety risks" ) Then + val12 := 1; + Endif; + If ( sel13 = "Dyspnea" ) Then + val13 := 1; + Endif; + If ( sel14 = "Pressure or Stasis Ulcer" ) Then + val14 := 1; + Endif; + If ( sel15 = "Short life expectancy" ) Then + val15 := 1; + Endif; + If ( sel16 = "Help with managing medications needed" ) Then + val16 := 1; + Endif; + If ( sel17 = "Non-compliance with medication regimen" ) Then + val17 := 1; + Endif; + If ( sel18 = "Difficulty reading" ) Then + val18 := 1; + Endif; + If ( sel19 = "Confusion" ) Then + val19 := 1; + Endif; + + + val1 := val1 as number ; + val2 := val2 as number ; + val3 := val3 as number ; + val4 := val4 as number ; + val5 := val5 as number ; + val6 := val6 as number ; + val7 := val7 as number ; + val8 := val8 as number ; + val9 := val9 as number ; + val10 := val10 as number ; + val11 := val11 as number ; + val12 := val12 as number ; + val13 := val13 as number ; + val14 := val14 as number ; + val15 := val15 as number ; + val16 := val16 as number ; + val17 := val17 as number ; + val18 := val18 as number ; + val19 := val19 as number ; + + varscore := 0; + + if val1 is not null + then varscore := varscore + val1; + Endif; + if val2 is not null + then varscore := varscore + val2; + Endif; + if val3 is not null + then varscore := varscore + val3; + Endif; + if val4 is not null + then varscore := varscore + val4; + Endif; + if val5 is not null + then varscore := varscore + val5; + Endif; + if val6 is not null + then varscore := varscore + val6; + Endif; + if val7 is not null + then varscore := varscore + val7; + Endif; + if val8 is not null + then varscore := varscore + val8; + Endif; + if val9 is not null + then varscore := varscore + val9; + Endif; + if val10 is not null + then varscore := varscore + val10; + Endif; + if val11 is not null + then varscore := varscore + val11; + Endif; + if val12 is not null + then varscore := varscore + val12; + Endif; + if val13 is not null + then varscore := varscore + val13; + Endif; + if val14 is not null + then varscore := varscore + val14; + Endif; + if val15 is not null + then varscore := varscore + val15; + Endif; + if val16 is not null + then varscore := varscore + val16; + Endif; + if val17 is not null + then varscore := varscore + val17; + Endif; + if val18 is not null + then varscore := varscore + val18; + Endif; + if val19 is not null + then varscore := varscore + val19; + Endif; + + + prm4 := First of (this_parms where this_parms.Name = "SCH_CK_Total Score"); + selList := varscore ; + local_session.SessionReadmissionScore := varscore ; + + prmans := first of (this_parms where this_parms.Name = "SCH_CK_Calculate Score"); + Obsans := first of (this_observations where this_observations.ParameterGUID = prmans.ParameterGUID ); + lstans := Obsans.valueObj.ListItemsList ; + selans := first of( lstans.Value where lstans.IsSelected = true ); + + If ( selans = "Yes" or selans = "Recalculate" ) then + Obs4 := CALL MLM_DIPA WITH this_DocumentCommunication, prm4, selList ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, Obs4); + Endif; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: + Conclude true; + ;; + action: + return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_RISK_SCORE.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_RISK_SCORE.mlm new file mode 100644 index 0000000..204c1cb --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_RISK_SCORE.mlm @@ -0,0 +1,279 @@ +maintenance: + + title: DOC_SCH_Readmission_Risk_Score;; + mlmname: DOC_SCH_Readmission_Risk_Score;; + arden: version 2.5;; + version: 5.50;; + institution: SCH ;; + author: Chintan Tilwa ;; + specialist: ;; + date: 2012-10-10;; + validation: testing;; +library: + purpose: + ;; + explanation: + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + (this_documentCommunication) := argument; + + local_session := CDS_SESSION.local; + + //Get The Structure Note + (this_FS_doc) := this_documentCommunication.DocumentConfigurationObj; + //Get the Parameter List + (this_parms) := this_FS_doc.ParametersList; + //Paramters defination + (this_cols) := this_FS_doc.ColumnsList; + (this_curr_col) := this_FS_doc.Currentcolumn; + (this_currentObs) := this_documentCommunication.CurrentObservationObj; + (this_observations) := this_FS_doc.ChartedObservationsList; + (this_curr_valobj) := this_currentObs.valueobj; + + MLM_DIPA := MLM {{{SINGLE-QUOTE}}}UTIL_OBJECT_Customize_DIPA_MLM{{{SINGLE-QUOTE}}}; + + MLM_HI := MLM {{{SINGLE-QUOTE}}}DOC_SCH_Readmission_Health_Issue_CHF{{{SINGLE-QUOTE}}}; + obs_HI := Call MLM_HI With this_documentCommunication; + + MLM_HI1 := MLM {{{SINGLE-QUOTE}}}DOC_SCH_Readmission_Health_Issue_COPD{{{SINGLE-QUOTE}}}; + obs_HI1 := Call MLM_HI1 With this_documentCommunication; + + MLM_HI2 := MLM {{{SINGLE-QUOTE}}}DOC_SCH_Readmission_Health_Issue_Diabetes{{{SINGLE-QUOTE}}}; + obs_HI2 := Call MLM_HI2 With this_documentCommunication; + + MLM_HI3 := MLM {{{SINGLE-QUOTE}}}DOC_SCH_Readmission_Health_Issue_Renal{{{SINGLE-QUOTE}}}; + obs_HI3 := Call MLM_HI3 With this_documentCommunication; + + Client_GUID := this_documentCommunication.ClientGUID; + Client_Visit_GUID := this_documentCommunication.ClientVisitGUID; + + prm1 := first of (this_parms where this_parms.Name = "SCH_CK_Prior Pattern_2"); + Obs1 := first of (this_observations where this_observations.ParameterGUID = prm1.ParameterGUID); + lst1 := Obs1.valueObj.ListItemsList ; + sel1 := first of ( lst1.Value where lst1.IsSelected = true and lst1.Value = ">3 hospitalizations or ER Visits in past 3 months" ); + sel2 := first of ( lst1.Value where lst1.IsSelected = true and lst1.Value = "History of Falls" ); + + If ( sel1 = ">3 hospitalizations or ER Visits in past 3 months" ) Then + val1 := 1; + Endif; + If ( sel2 = "History of Falls" ) Then + val2 := 1; + Endif; + + prm2 := first of (this_parms where this_parms.Name = "SCH_CK_Chronic Conditions"); + Obs2 := first of (this_observations where this_observations.ParameterGUID = prm2.ParameterGUID); + lst2 := Obs2.valueObj.ListItemsList ; + + prm3a := first of (this_parms where this_parms.Name = "SCH_CK_Diagnosis Risk"); + Obs3a := first of (this_observations where this_observations.ParameterGUID = prm3a.ParameterGUID); + lst3a := Obs3a.valueObj.ListItemsList ; + + sel3 := first of ( lst2.Value where lst2.IsSelected = true and lst2.Value = "CHF" ) ; + sel4 := first of ( lst2.Value where lst2.IsSelected = true and lst2.Value = "COPD" ) ; + sel5 := first of ( lst2.Value where lst2.IsSelected = true and lst2.Value = "Diabetes" ) ; + sel5a := first of ( lst3a.Value where lst3a.IsSelected = true and lst3a.Value = "New Onset Diabetes" ) ; + sel6 := first of ( lst2.Value where lst2.IsSelected = true and lst2.Value = "Renal Failure" ) ; + + If ( sel3 = "CHF" ) Then + val3 := 1; + Endif; + If ( sel4 = "COPD" ) Then + val4 := 1; + Endif; + If ( sel5 = "Diabetes" ) Then + val5 := 1; + Endif; + If ( sel6 = "Renal Failure" ) Then + val6 := 1; + Endif; + + prm3 := first of (this_parms where this_parms.Name = "SCH_CK_Risk Factors"); + Obs3 := first of (this_observations where this_observations.ParameterGUID = prm3.ParameterGUID); + lst3 := Obs3.valueObj.ListItemsList ; + prm3b := first of (this_parms where this_parms.Name = "SCH_CK_Discharge Risk"); + Obs3b := first of (this_observations where this_observations.ParameterGUID = prm3b.ParameterGUID); + lst3b := Obs3b.valueObj.ListItemsList ; + prm3c := first of (this_parms where this_parms.Name = "SCH_CK_Functional Risk"); + Obs3c := first of (this_observations where this_observations.ParameterGUID = prm3c.ParameterGUID); + lst3c := Obs3c.valueObj.ListItemsList ; + + sel7 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "More than 2 secondary diagnoses" ) ; + sel8 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Low social economic status or limited financial resources" ) ; + sel9 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Lives alone" ) ; + sel9c := first of ( lst3c.Value where lst3c.IsSelected = true and lst3c.Value = "Patient Lives Alone-Can{{{SINGLE-QUOTE}}}t Transfer" ) ; + sel10 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Limited support network" ) ; + sel10b := first of ( lst3b.Value where lst3b.IsSelected = true and lst3b.Value = "Compromised patient who lacks caregiver support" ) ; + sel11 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "ADL assistance needed" ) ; + sel11c := first of ( lst3c.Value where lst3c.IsSelected = true and lst3c.Value = "Decreased Ability to do ADL{{{SINGLE-QUOTE}}}s last week" ) ; + sel12 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Home safety risks" ) ; + sel13 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Dyspnea" ) ; + sel14 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Pressure or Stasis Ulcer" ) ; + sel15 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Short life expectancy" ) ; + sel15a := first of ( lst3a.Value where lst3a.IsSelected = true and lst3a.Value = "End of Life issues/Hospice" ) ; + sel16 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Help with managing medications needed" ) ; + sel16b := first of ( lst3b.Value where lst3b.IsSelected = true and lst3b.Value = "Medication Assistance" ) ; + sel17 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Non-compliance with medication regimen" ) ; + sel18 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Difficulty reading" ) ; + sel19 := first of ( lst3.Value where lst3.IsSelected = true and lst3.Value = "Confusion" ) ; + //break; + + If ( sel7 = "More than 2 secondary diagnoses" ) Then + val7 := 1; + Endif; + If ( sel8 = "Low social economic status or limited financial resources" ) Then + val8 := 1; + Endif; + If ( sel9 = "Lives alone" ) Then + val9 := 1; + Endif; + If ( sel10 = "Limited support network" ) Then + val10 := 1; + Endif; + If ( sel11 = "ADL assistance needed" ) Then + val11 := 1; + Endif; + If ( sel12 = "Home safety risks" ) Then + val12 := 1; + Endif; + If ( sel13 = "Dyspnea" ) Then + val13 := 1; + Endif; + If ( sel14 = "Pressure or Stasis Ulcer" ) Then + val14 := 1; + Endif; + If ( sel15 = "Short life expectancy" ) Then + val15 := 1; + Endif; + If ( sel16 = "Help with managing medications needed" ) Then + val16 := 1; + Endif; + If ( sel17 = "Non-compliance with medication regimen" ) Then + val17 := 1; + Endif; + If ( sel18 = "Difficulty reading" ) Then + val18 := 1; + Endif; + If ( sel19 = "Confusion" ) Then + val19 := 1; + Endif; + + + val1 := val1 as number ; + val2 := val2 as number ; + val3 := val3 as number ; + val4 := val4 as number ; + val5 := val5 as number ; + val6 := val6 as number ; + val7 := val7 as number ; + val8 := val8 as number ; + val9 := val9 as number ; + val10 := val10 as number ; + val11 := val11 as number ; + val12 := val12 as number ; + val13 := val13 as number ; + val14 := val14 as number ; + val15 := val15 as number ; + val16 := val16 as number ; + val17 := val17 as number ; + val18 := val18 as number ; + val19 := val19 as number ; + + varscore := 0; + + if val1 is not null + then varscore := varscore + val1; + Endif; + if val2 is not null + then varscore := varscore + val2; + Endif; + if val3 is not null + then varscore := varscore + val3; + Endif; + if val4 is not null + then varscore := varscore + val4; + Endif; + if val5 is not null + then varscore := varscore + val5; + Endif; + if val6 is not null + then varscore := varscore + val6; + Endif; + if val7 is not null + then varscore := varscore + val7; + Endif; + if val8 is not null + then varscore := varscore + val8; + Endif; + if val9 is not null + then varscore := varscore + val9; + Endif; + if val10 is not null + then varscore := varscore + val10; + Endif; + if val11 is not null + then varscore := varscore + val11; + Endif; + if val12 is not null + then varscore := varscore + val12; + Endif; + if val13 is not null + then varscore := varscore + val13; + Endif; + if val14 is not null + then varscore := varscore + val14; + Endif; + if val15 is not null + then varscore := varscore + val15; + Endif; + if val16 is not null + then varscore := varscore + val16; + Endif; + if val17 is not null + then varscore := varscore + val17; + Endif; + if val18 is not null + then varscore := varscore + val18; + Endif; + if val19 is not null + then varscore := varscore + val19; + Endif; + + + prm4 := First of (this_parms where this_parms.Name = "SCH_CK_Total Score"); + selList := varscore ; + local_session.SessionReadmissionScore := varscore ; + + prmans := first of (this_parms where this_parms.Name = "SCH_CK_Calculate Score"); + Obsans := first of (this_observations where this_observations.ParameterGUID = prmans.ParameterGUID ); + lstans := Obsans.valueObj.ListItemsList ; + selans := first of( lstans.Value where lstans.IsSelected = true ); + + If ( selans = "Yes" or selans = "Recalculate" ) then + Obs4 := CALL MLM_DIPA WITH this_DocumentCommunication, prm4, selList ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, Obs4); + Endif; + + + + //MLM_EOL := MLM {{{SINGLE-QUOTE}}}DOC_SCH_Readmission_Risk_Select_Reverse{{{SINGLE-QUOTE}}}; + //obs_EOL := Call MLM_EOL With this_documentCommunication; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: + Conclude true; + ;; + action: + return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_RISK_SELECT.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_RISK_SELECT.mlm new file mode 100644 index 0000000..c09370f --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_READMISSION_RISK_SELECT.mlm @@ -0,0 +1,649 @@ +maintenance: + + title: DOC_SCH_Readmission_Risk_Select;; + mlmname: DOC_SCH_Readmission_Risk_Select;; + arden: version 2.5;; + version: 5.50;; + institution: SCH ;; + author: Chintan Tilwa ;; + specialist: ;; + date: 2012-09-14;; + validation: testing;; + +library: + purpose: + ;; + explanation: + Change History + ----------------------------------------------------------------------- + 03/07/2017 SSJ CSR #35407- Commented By Shivprasad to hide message {{{SINGLE-QUOTE}}}By selecting a Nutritional Risk, the Prealbumin and Daily Order for Prealbumin have automatically been created{{{SINGLE-QUOTE}}} + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + (this_documentCommunication) := argument; + //Get The Structure Note + (this_FS_doc) := this_documentCommunication.DocumentConfigurationObj; + //Get the Parameter List + (this_parms) := this_FS_doc.ParametersList; + //Paramters defination + (this_cols) := this_FS_doc.ColumnsList; + (this_curr_col) := this_FS_doc.Currentcolumn; + (this_currentObs) := this_documentCommunication.CurrentObservationObj; + (this_observations) := this_FS_doc.ChartedObservationsList; + + local_session := CDS_SESSION.local; + + MLM_DIPA := MLM {{{SINGLE-QUOTE}}}UTIL_OBJECT_Customize_DIPA_MLM{{{SINGLE-QUOTE}}}; + + MLM_HI2 := MLM {{{SINGLE-QUOTE}}}DOC_SCH_Readmission_Health_Issue_Diabetes{{{SINGLE-QUOTE}}}; + obs_HI2 := Call MLM_HI2 With this_documentCommunication; + + this_curr_obs := last (this_FS_doc.chartedobservationslist); + this_current_prm := first of (this_parms where this_parms.parameterGUID = this_currentObs.ParameterGUID); + cur_name := this_current_prm.Name; + +/*************************************************************************************************************/ + + + + + If (cur_name = "SCH_CK_Pharmacy Risk") then + + sel1 := "" ; + sel2 := "" ; + prm := first of (this_parms where this_parms.Name = "SCH_CK_Pharmacy Risk"); + Obs := first of (this_observations where this_observations.ParameterGUID = prm.ParameterGUID); + lst1 := Obs.valueObj.ListItemsList ; + sel1 := First of( lst1.Value Where lst1.IsSelected = true ); + sel1Col := lst1.Value where lst1.IsSelected = true ; + sel2 := First Of( lst1.Value where lst1.IsSelected = true and lst1.Value <> "No Pharmacy Risk Criteria" ) ; + sel2Col := lst1.Value where lst1.IsSelected = true and lst1.Value <> "No Pharmacy Risk Criteria" ; + sessionPharmacy := local_session.SessionReadmissionPharmacy ; + + if sessionPharmacy = "" and (sel1 <> "" ) then + sessionPharmacy := sel1; + local_session.SessionReadmissionPharmacy := sel1; + endif; + + if sessionPharmacy = "No Pharmacy Risk Criteria" and sel1 IS NULL and sel2 IS NULL then + local_session.SessionReadmissionPharmacy := ""; + endif; + + if sessionPharmacy <> "" and sessionPharmacy <> "No Pharmacy Risk Criteria" and "No Pharmacy Risk Criteria" not in sel1Col then + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, sel2Col ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + local_session.SessionReadmissionPharmacy := ""; + endif; + + if sessionPharmacy <> "No Pharmacy Risk Criteria" and sel2 <> "" then + local_session.SessionReadmissionPharmacy := ""; + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, sel2Col ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + endif; + + if sessionPharmacy = "No Pharmacy Risk Criteria" and sel1 <> "No Pharmacy Risk Criteria" then + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, "No Pharmacy Risk Criteria" ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + endif; + + if sessionPharmacy = "No Pharmacy Risk Criteria" and sel1 IS NULL then + local_session.SessionReadmissionPharmacy := ""; + endif; + + Endif; + +/*************************************************************************************************************/ + + If (cur_name = "SCH_CK_Diagnosis Risk") then + + sel1 := "" ; + sel2 := "" ; + prm := first of (this_parms where this_parms.Name = "SCH_CK_Diagnosis Risk"); + Obs := first of (this_observations where this_observations.ParameterGUID = prm.ParameterGUID); + lst1 := Obs.valueObj.ListItemsList ; + sel1 := First of( lst1.Value Where lst1.IsSelected = true ); + sel1Col := lst1.Value where lst1.IsSelected = true ; + sel2 := First Of( lst1.Value where lst1.IsSelected = true and lst1.Value <> "No Diagnosis Risk Criteria" ) ; + sel2Col := lst1.Value where lst1.IsSelected = true and lst1.Value <> "No Diagnosis Risk Criteria" ; + sessionDiagnosis := local_session.SessionReadmissionDiagnosis ; + sessionDiagnosisForMessage := local_session.SessionReadmissionDiagnosisForMessage ; + + if "New Onset Diabetes" matches pattern sessionDiagnosisForMessage then + if "New Onset Diabetes" in sel1Col then + local_session.SessionReadmissionDiagnosisForMessage := "New Onset Diabetes"; + Else + local_session.SessionReadmissionDiagnosisForMessage := ""; + EndIF; + x := 1; + Else + if "New Onset Diabetes" in sel1Col and sessionDiagnosis <> "No Diagnosis Risk Criteria" then + this_documentCommunication.DisplayMessage := TRUE; + this_documentCommunication.Message := "By selecting New Onset Diabetes- an order for a Dietitian Consult (New Onset Diabetes) has automatically been created"; + local_session.SessionReadmissionDiagnosisForMessage := "New Onset Diabetes"; + Else + local_session.SessionReadmissionDiagnosisForMessage := ""; + EndIF; + Endif; + + if sessionDiagnosis = "" and (sel1 <> "" ) then + sessionDiagnosis := sel1; + local_session.SessionReadmissionDiagnosis := sel1; + endif; + + if sessionDiagnosis = "No Diagnosis Risk Criteria" and sel1 IS NULL and sel2 IS NULL then + local_session.SessionReadmissionDiagnosis := ""; + endif; + + if sessionDiagnosis <> "" and sessionDiagnosis <> "No Diagnosis Risk Criteria" and "No Diagnosis Risk Criteria" not in sel1Col then + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, sel2Col ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + local_session.SessionReadmissionDiagnosis := ""; + endif; + + if sessionDiagnosis <> "No Diagnosis Risk Criteria" and sel2 <> "" then + local_session.SessionReadmissionDiagnosis := ""; + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, sel2Col ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + endif; + + if sessionDiagnosis = "No Diagnosis Risk Criteria" and sel1 <> "No Diagnosis Risk Criteria" then + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, "No Diagnosis Risk Criteria" ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + endif; + + if sessionDiagnosis = "No Diagnosis Risk Criteria" and sel1 IS NULL then + local_session.SessionReadmissionDiagnosis := ""; + endif; + + Endif; + +/*************************************************************************************************************/ + + + If (cur_name = "SCH_CK_Discharge Risk") then + + sel1 := "" ; + sel2 := "" ; + prm := first of (this_parms where this_parms.Name = "SCH_CK_Discharge Risk"); + Obs := first of (this_observations where this_observations.ParameterGUID = prm.ParameterGUID); + lst1 := Obs.valueObj.ListItemsList ; + sel1 := First of( lst1.Value Where lst1.IsSelected = true ); + sel1Col := lst1.Value where lst1.IsSelected = true ; + sel2 := First Of( lst1.Value where lst1.IsSelected = true and lst1.Value <> "No Discharge Risk Criteria" ) ; + sel2Col := lst1.Value where lst1.IsSelected = true and lst1.Value <> "No Discharge Risk Criteria" ; + sessionDischarge := local_session.SessionReadmissionDischarge ; + + if sessionDischarge = "" and (sel1 <> "" ) then + sessionDischarge := sel1; + local_session.SessionReadmissionDischarge := sel1; + endif; + + if sessionDischarge = "No Discharge Risk Criteria" and sel1 IS NULL and sel2 IS NULL then + local_session.SessionReadmissionDischarge := ""; + endif; + + if sessionDischarge <> "" and sessionDischarge <> "No Discharge Risk Criteria" and "No Discharge Risk Criteria" not in sel1Col then + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, sel2Col ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + local_session.SessionReadmissionDischarge := ""; + endif; + + if sessionDischarge <> "No Discharge Risk Criteria" and sel2 <> "" then + local_session.SessionReadmissionDischarge := ""; + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, sel2Col ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + endif; + + if sessionDischarge = "No Discharge Risk Criteria" and sel1 <> "No Discharge Risk Criteria" then + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, "No Discharge Risk Criteria" ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + endif; + + if sessionDischarge = "No Discharge Risk Criteria" and sel1 IS NULL then + local_session.SessionReadmissionDischarge := ""; + endif; + + Endif; + +/*************************************************************************************************************/ + + + If (cur_name = "SCH_CK_Functional Risk") then + + sel1 := "" ; + sel2 := "" ; + prm := first of (this_parms where this_parms.Name = "SCH_CK_Functional Risk"); + Obs := first of (this_observations where this_observations.ParameterGUID = prm.ParameterGUID); + lst1 := Obs.valueObj.ListItemsList ; + sel1 := First of( lst1.Value Where lst1.IsSelected = true ); + sel1Col := lst1.Value where lst1.IsSelected = true ; + sel2 := First Of( lst1.Value where lst1.IsSelected = true and lst1.Value <> "No Functional Risk Criteria" ) ; + sel2Col := lst1.Value where lst1.IsSelected = true and lst1.Value <> "No Functional Risk Criteria" ; + sessionFunctional := local_session.SessionReadmissionFunctional ; + + if sessionFunctional = "" and (sel1 <> "" ) then + sessionFunctional := sel1; + local_session.SessionReadmissionFunctional := sel1; + endif; + + if sessionFunctional = "No Functional Risk Criteria" and sel1 IS NULL and sel2 IS NULL then + local_session.SessionReadmissionFunctional := ""; + endif; + + if sessionFunctional <> "" and sessionFunctional <> "No Functional Risk Criteria" and "No Functional Risk Criteria" not in sel1Col then + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, sel2Col ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + local_session.SessionReadmissionFunctional := ""; + endif; + + if sessionFunctional <> "No Functional Risk Criteria" and sel2 <> "" then + local_session.SessionReadmissionFunctional := ""; + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, sel2Col ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + endif; + + if sessionFunctional = "No Functional Risk Criteria" and sel1 <> "No Functional Risk Criteria" then + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, "No Functional Risk Criteria" ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + endif; + + if sessionFunctional = "No Functional Risk Criteria" and sel1 IS NULL then + local_session.SessionReadmissionFunctional := ""; + endif; + + Endif; + +/*************************************************************************************************************/ + + + + If (cur_name = "SCH_CK_Device(s) on admission, ED, and OR") then + + sel1 := "" ; + sel2 := "" ; + prm := first of (this_parms where this_parms.Name = "SCH_CK_Device(s) on admission, ED, and OR"); + Obs := first of (this_observations where this_observations.ParameterGUID = prm.ParameterGUID); + lst1 := Obs.valueObj.ListItemsList ; + sel1 := First of( lst1.Value Where lst1.IsSelected = true ); + sel1Col := lst1.Value where lst1.IsSelected = true ; + sel2 := First Of( lst1.Value where lst1.IsSelected = true and lst1.Value <> "No Devices Present" ) ; + sel2Col := lst1.Value where lst1.IsSelected = true and lst1.Value <> "No Devices Present" ; + sessionDevice := local_session.SessionReadmissionDevice ; + sel3 := Last of( lst1.Value Where lst1.IsSelected = true ); + + + + for i in lst1 do + if i.Isselected = true and i.value not in ("Catheter: Foley","Catheter: IV","No Devices Present") then + List1 := List1 , i.Value ; + endif; + enddo; + + CurrList_counter := 1 seqto count List1; + for CC in CurrList_counter do + CountNo := CC ; + Enddo; + + //start + + SessionDeviceMessage := local_session.sessionDeviceMessage ; + + for i in lst1 do + if i.Isselected = true Then + If i.value <> "No Devices Present" then + List1 := List1 , i.Value ; + EndIF; + strSelectedDev := strSelectedDev || ", " || i.Value; + endif; + + enddo; + + + if SessionDeviceMessage = "" then + if sel3 = "Catheter: Port" or sel3 = "Catheter: Central Line" or sel3 = "Catheter: PICC Line" then + //show alert + this_DocumentCommunication.DisplayMessage := True; + this_DocumentCommunication.Message := "By selecting a Port, Central Line or PICC Line, an Infusion Center Consult has been automatically been created"; + + EndIF; + local_session.sessionDeviceMessage := sel3; + + ElseIF SessionDeviceMessage Matches Pattern "%Port%" or + SessionDeviceMessage Matches Pattern "%Central%" or + SessionDeviceMessage Matches Pattern "%PICC%" Then + + local_session.sessionDeviceMessage := strSelectedDev; + + Else + if sel3 is null then + local_session.sessionDeviceMessage := ""; + ElseIf sel3 = "Catheter: Port" or sel3 = "Catheter: Central Line" or sel3 = "Catheter: PICC Line" then + //show alert + this_DocumentCommunication.DisplayMessage := True; + this_DocumentCommunication.Message := "By selecting a Port, Central Line or PICC Line, an Infusion Center Consult has been automatically been created"; + local_session.sessionDeviceMessage := strSelectedDev; + EndIF; + EndIF; + + //end + + if sessionDevice = "" and (sel1 <> "" ) then + sessionDevice := sel1; + local_session.SessionReadmissionDevice := sel1; + endif; + + if sessionDevice = "No Devices Present" and sel1 IS NULL and sel2 IS NULL then + local_session.SessionReadmissionDevice := ""; + endif; + + if sessionDevice <> "" and sessionDevice <> "No Devices Present" and "No Devices Present" not in sel1Col then + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, sel2Col ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + local_session.SessionReadmissionDevice := ""; + endif; + + if sessionDevice <> "No Devices Present" and sel2 <> "" then + local_session.SessionReadmissionDevice := ""; + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, sel2Col ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + endif; + + if sessionDevice = "No Devices Present" and sel1 <> "No Devices Present" then + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, "No Devices Present" ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + endif; + + if sessionDevice = "No Devices Present" and sel1 IS NULL then + local_session.SessionReadmissionDevice := ""; + endif; + + Endif; + +/*************************************************************************************************************/ + + + If (cur_name = "SCH_CK_Nutritional Risk") then + + sel1 := "" ; + sel2 := "" ; + prm := first of (this_parms where this_parms.Name = "SCH_CK_Nutritional Risk"); + Obs := first of (this_observations where this_observations.ParameterGUID = prm.ParameterGUID); + lst1 := Obs.valueObj.ListItemsList ; + sel1 := First of( lst1.Value Where lst1.IsSelected = true ); + sel1Col := lst1.Value where lst1.IsSelected = true ; + sel2 := First Of( lst1.Value where lst1.IsSelected = true and lst1.Value <> "No Nutritional Risk Criteria" ) ; + sel2Col := lst1.Value where lst1.IsSelected = true and lst1.Value <> "No Nutritional Risk Criteria" ; + sessionNutritional := local_session.SessionReadmissionNutritional ; + + sessionNutritionalForMessage := local_session.SessionNutritionalForMessage ; + + strSelectedNut := ""; + + for i in lst1 do + if i.Isselected = true Then + If i.value <> "No Nutritional Risk Criteria" then + List1 := List1 , i.Value ; + EndIF; + strSelectedNut := strSelectedNut || "`" || i.Value; + endif; + + enddo; + + if sessionNutritionalForMessage = "" and sel1 <> "No Nutritional Risk Criteria" then + this_DocumentCommunication.DisplayMessage := False; // True --- CSR #35407- Commented By Shivprasad to hide message + this_DocumentCommunication.Message := "By selecting a Nutritional Risk, the Prealbumin and Daily Order for Prealbumin have automatically been created"; + local_session.SessionNutritionalForMessage := strSelectedNut; + + ElseIf sel1 is null then + local_session.SessionNutritionalForMessage := ""; + + ElseIf sessionNutritionalForMessage matches pattern "`" and sel1 <> "" then + local_session.SessionNutritionalForMessage := strSelectedNut; + + ElseIf sel1 = "No Nutritional Risk Criteria" then + local_session.SessionNutritionalForMessage := strSelectedNut; + EndIF; + + + if sessionNutritional = "" and (sel1 <> "" ) then + sessionNutritional := sel1; + local_session.SessionReadmissionNutritional := sel1; + endif; + + if sessionNutritional = "No Nutritional Risk Criteria" and sel1 IS NULL and sel2 IS NULL then + local_session.SessionReadmissionNutritional := ""; + endif; + + if sessionNutritional <> "" and sessionNutritional <> "No Nutritional Risk Criteria" and "No Nutritional Risk Criteria" not in sel1Col then + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, sel2Col ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + local_session.SessionReadmissionNutritional := ""; + endif; + + if sessionNutritional <> "No Nutritional Risk Criteria" and sel2 <> "" then + local_session.SessionReadmissionNutritional := ""; + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, sel2Col ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + endif; + + if sessionNutritional = "No Nutritional Risk Criteria" and sel1 <> "No Nutritional Risk Criteria" then + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, "No Nutritional Risk Criteria" ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + endif; + + if sessionNutritional = "No Nutritional Risk Criteria" and sel1 IS NULL then + local_session.SessionReadmissionNutritional := ""; + endif; + + Endif; + +/*************************************************************************************************************/ + + + If (cur_name = "SCH_CK_Smoking Risk") then + + sel1 := "" ; + sel2 := "" ; + prm := first of (this_parms where this_parms.Name = "SCH_CK_Smoking Risk"); + Obs := first of (this_observations where this_observations.ParameterGUID = prm.ParameterGUID); + lst1 := Obs.valueObj.ListItemsList ; + sel1 := First of( lst1.Value Where lst1.IsSelected = true ); + sel1Col := lst1.Value where lst1.IsSelected = true ; + sel2 := First Of( lst1.Value where lst1.IsSelected = true and lst1.Value <> "No Smoking Risk" ) ; + sel2Col := lst1.Value where lst1.IsSelected = true and lst1.Value <> "No Smoking Risk" ; + sessionSmoking := local_session.SessionReadmissionSmoking ; + SessionSmokingForMessage := local_session.SessionSmokingForMessage ; + + strSelectedNut := ""; + + for i in lst1 do + if i.Isselected = true Then + If i.value <> "No Smoking Risk" then + List1 := List1 , i.Value ; + EndIF; + strSelectedNut := strSelectedNut || "`" || i.Value; + endif; + + enddo; + + if SessionSmokingForMessage = "" and sel1 <> "No Smoking Risk" then + this_DocumentCommunication.DisplayMessage := True; + this_DocumentCommunication.Message := "By selecting Smoking Risk Order- an order for a Pulmonary Health Education Consult has automatically been created"; + local_session.SessionSmokingForMessage := strSelectedNut; + ElseIf sel1 is null then + local_session.SessionSmokingForMessage := ""; + ElseIf SessionSmokingForMessage matches pattern "`" and sel1 <> "" then + local_session.SessionSmokingForMessage := strSelectedNut; + ElseIf sel1 = "No Smoking Risk" then + local_session.SessionSmokingForMessage := strSelectedNut; + EndIF; + + if sessionSmoking = "" and (sel1 <> "" ) then + sessionSmoking := sel1; + local_session.SessionReadmissionSmoking := sel1; + endif; + + if sessionSmoking = "No Smoking Risk" and sel1 IS NULL and sel2 IS NULL then + local_session.SessionReadmissionSmoking := ""; + endif; + + if sessionSmoking <> "" and sessionSmoking <> "No Smoking Risk" and "No Smoking Risk" not in sel1Col then + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, sel2Col ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + local_session.SessionReadmissionSmoking := ""; + endif; + + if sessionSmoking <> "No Smoking Risk" and sel2 <> "" then + local_session.SessionReadmissionSmoking := ""; + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, sel2Col ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + endif; + + if sessionSmoking = "No Smoking Risk" and sel1 <> "No Smoking Risk" then + obs2 := CALL MLM_DIPA WITH this_DocumentCommunication, prm, "No Smoking Risk" ; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + endif; + + if sessionSmoking = "No Smoking Risk" and sel1 IS NULL then + local_session.SessionReadmissionSmoking := ""; + endif; + + Endif; + +/***********************************************************************************************************************************/ + + listChronic := (); + prm11 := first of (this_parms where this_parms.Name = "SCH_CK_Chronic Conditions"); + ObsChronic := first of (this_observations where this_observations.ParameterGUID = prm11.ParameterGUID ); + lstChronic := ObsChronic.valueObj.ListItemsList ; + + for i in lstChronic do + if i.Isselected = true then + listChronic := listChronic , i.Value ; + endif; + enddo; + + final_List1 := (); + final_List1 := listChronic ; + + prmDiag := first of (this_parms where this_parms.Name = "SCH_CK_Diagnosis Risk"); + ObsDiag := first of (this_observations where this_observations.ParameterGUID = prmDiag.ParameterGUID); + lstDiag := ObsDiag.valueObj.ListItemsList ; + selDiag1 := first of ( lstDiag.Value where lstDiag.IsSelected = true and lstDiag.Value = "New Onset Diabetes" ) ; + + if selDiag1 = "New Onset Diabetes" and local_session.SessionReadmissionDiagnosis = "" then + final_List1:= final_List1 , "Diabetes" ; + Endif; + + obs11 := CALL MLM_DIPA WITH this_DocumentCommunication, prm11, final_List1; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs11); + + listRisk := (); + prm22 := first of (this_parms where this_parms.Name = "SCH_CK_Risk Factors"); + ObsRisk := first of (this_observations where this_observations.ParameterGUID = prm22.ParameterGUID ); + lstRisk := ObsRisk.valueObj.ListItemsList ; + + for i in lstRisk do + if i.Isselected = true then + //if i.Value not in ("Lives alone", "Limited support network", "ADL assistance needed", "Short life expectancy", "Help with managing medications needed", "Pressure or Stasis Ulcer") then + listRisk := listRisk , i.Value ; + //Endif; + endif; + enddo; + + final_List := (); + final_List := listRisk ; + + selDiag := first of ( lstDiag.Value where lstDiag.IsSelected = true and lstDiag.Value = "End of Life issues/Hospice" ) ; + + if selDiag = "End of Life issues/Hospice" and local_session.SessionReadmissionDiagnosis = "" then + final_List:= final_List , "Short life expectancy" ; + Endif; + + + prmDisc := first of (this_parms where this_parms.Name = "SCH_CK_Discharge Risk"); + ObsDisc := first of (this_observations where this_observations.ParameterGUID = prmDisc.ParameterGUID); + lstDisc := ObsDisc.valueObj.ListItemsList ; + selDiscCompro := First of( lstDisc.Value where lstDisc.IsSelected = true and lstDisc.Value = "Compromised patient who lacks caregiver support" ); + selDiscMed := First of( lstDisc.Value where lstDisc.IsSelected = true and lstDisc.Value = "Medication Assistance" ); + + if selDiscCompro = "Compromised patient who lacks caregiver support" and local_session.SessionReadmissionDischarge = "" then + final_List:= final_List , "Limited support network"; + Endif; + + + if selDiscMed = "Medication Assistance" and local_session.SessionReadmissionDischarge = "" then + final_List:= final_List , "Help with managing medications needed"; + Endif; + + + prmFunc := first of (this_parms where this_parms.Name = "SCH_CK_Functional Risk"); + ObsFunc := first of (this_observations where this_observations.ParameterGUID = prmFunc.ParameterGUID); + lstFunc := ObsFunc.valueObj.ListItemsList ; + selFuncDec := First of( lstFunc.Value where lstFunc.IsSelected = true and lstFunc.Value = "Decreased Ability to do ADL{{{SINGLE-QUOTE}}}s last week" ); + selFuncPat := First of( lstFunc.Value where lstFunc.IsSelected = true and lstFunc.Value = "Patient Lives Alone-Can{{{SINGLE-QUOTE}}}t Transfer" ); + + if selFuncDec = "Decreased Ability to do ADL{{{SINGLE-QUOTE}}}s last week" and local_session.SessionReadmissionFunctional = "" then + final_List:= final_List , "ADL assistance needed"; + Endif; + + if selFuncPat = "Patient Lives Alone-Can{{{SINGLE-QUOTE}}}t Transfer" and local_session.SessionReadmissionFunctional = "" then + final_List:= final_List , "Lives alone"; + Endif; + + prmNutr := first of (this_parms where this_parms.Name = "SCH_CK_Nutritional Risk"); + ObsNutr := first of (this_observations where this_observations.ParameterGUID = prmNutr.ParameterGUID); + lstNutr := ObsNutr.valueObj.ListItemsList ; + selNutrDecu := First of( lstNutr.Value where lstNutr.IsSelected = true and lstNutr.Value = "Decubitis Pressure Ulcer Present" ); + + if selNutrDecu = "Decubitis Pressure Ulcer Present" and local_session.SessionReadmissionNutritional = "" then + final_List:= final_List , "Pressure or Stasis Ulcer"; + Endif; + + + obs22 := CALL MLM_DIPA WITH this_DocumentCommunication, prm22, final_List; + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs22); + + MLM_Score := MLM {{{SINGLE-QUOTE}}}DOC_SCH_Readmission_Risk_Score{{{SINGLE-QUOTE}}}; + obs_Score := Call MLM_Score With this_documentCommunication; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: + conclude true; + ;; + action: + return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_SHIFT_TO_SHIFT_REPORT.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_SHIFT_TO_SHIFT_REPORT.mlm new file mode 100644 index 0000000..506c8bf --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_SHIFT_TO_SHIFT_REPORT.mlm @@ -0,0 +1,259 @@ +maintenance: + + title: DOC_SCH_SHIFT_TO_SHIFT_REPORT;; + mlmname: DOC_SCH_SHIFT_TO_SHIFT_REPORT;; + arden: version 2.5;; + version: 6.00;; + institution: St. Clair Hospital ;; + author: Shivprasad Jadhav;; + specialist: Shubha Rai;; + date: 2015-01-16;; + validation: testing;; + +library: + purpose: Pull the latest disability risk observations data from Flowsheet [OB Assessment /Intervention ] to Structure note[ Shift to Shift Reprt] Observation ;; + explanation: + Change History +------------------------------------------------- + + 06-03-2015 GOS MLM Created CSR :33112- Request Bed Workflow. + 06-30-2016 STH CSR#: 31024 & 34313 - Update shift to shift report to pull additional information that will be helpful and remove some details that are currently being pulled and no longer needed. + {Go-Live 10/31/2016}. + + ;; + keywords: + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + (this_documentCommunication) := argument; + + + MLM_Base := MLM {{{SINGLE-QUOTE}}}DOC_LOAD_Shift_To_Shift_Nurse_Report{{{SINGLE-QUOTE}}} ; + this_documentCommunication := Call MLM_Base With this_documentCommunication; + + //Get The Structure Note + (this_FS_doc) := this_documentCommunication.DocumentConfigurationObj; + //Get the Parameter List + (this_parms) := this_FS_doc.ParametersList; + //Paramters defination + (this_cols) := this_FS_doc.ColumnsList; + (this_curr_col) := this_FS_doc.Currentcolumn; + (this_currentObs) := this_documentCommunication.CurrentObservationObj; + (this_observations) := this_FS_doc.ChartedObservationsList; + + (UserGUID) := this_documentCommunication.UserGUID ; + (this_curr_valobj) := this_currentObs.valueobj; + // Get the client and visit GUIDs + clientGuid := this_documentCommunication.ClientGUID; + visitGuid := this_documentCommunication.ClientVisitGUID; + chartGuid := this_documentCommunication.ChartGUID; + Client_Document_GUID := this_FS_doc.ClientDocumentGUID; + + Ord_OBJECT := OBJECT [Obs_name, Obs_val , Obs_sug, Obs_Row] ; + Ord_vals := read as Ord_OBJECT + { + " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), name varchar(200), value varchar(500), timstmp datetime, sortseq int, timstmp2 varchar(30) ) " + || " INSERT INTO #tmp_aaa (name,value,timstmp, sortseq) " + || " select ocmi.Name, oflv.Value, cd.AuthoredDtm, " + || "CASE WHEN Name = {{{SINGLE-QUOTE}}}SCHCK_VisuallyImpaired{{{SINGLE-QUOTE}}} THEN 01 " + || "WHEN Name = {{{SINGLE-QUOTE}}}SCHCK_Hearing Impaired{{{SINGLE-QUOTE}}} THEN 02 " + || "WHEN Name = {{{SINGLE-QUOTE}}}SCHCK_Limited English{{{SINGLE-QUOTE}}} THEN 03 " + || "WHEN Name = {{{SINGLE-QUOTE}}}SCHCK_Mobility Impaired{{{SINGLE-QUOTE}}} THEN 04 " + || "WHEN Name = {{{SINGLE-QUOTE}}}SCHCK_Immobility Risk – Special Call Bell{{{SINGLE-QUOTE}}} THEN 05 " + || "ELSE 99 " + || "END AS SortSeq " + || " " + || "from CV3ClientDocument cd with (nolock) " + || "join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) " + || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " + || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " + || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " + || " AND ocmi.Name in ({{{SINGLE-QUOTE}}}SCHCK_VisuallyImpaired{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCHCK_Hearing Impaired{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCHCK_Limited English{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCHCK_Mobility Impaired{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCHCK_Immobility Risk – Special Call Bell{{{SINGLE-QUOTE}}}) " + || " Join SCMObsFSListValues oflv (nolock) On oflv.ClientGUID= cd.ClientGUID And oflv.ParentGUID = od.ObservationDocumentGUID " + || " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " " + || " and cd.iscanceled = 0 " + || " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}2. Adult Assessment/Intervention{{{SINGLE-QUOTE}}}," //{{{SINGLE-QUOTE}}}2. Pediatric Assessment/Intervention{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}A2. OB Assessment/Intervention{{{SINGLE-QUOTE}}}, + || " {{{SINGLE-QUOTE}}}ED Adult Assessment/Intervention{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}ED Pediatric Assessment/Intervention{{{SINGLE-QUOTE}}}) " + || " order by sortseq , cd.touchedwhen " + + || " Delete from #tmp_aaa Where timstmp < (Select DateAdd(minute, 0, Max(Timstmp) ) from #tmp_aaa ) " + + //|| " SELECT Name, STUFF((SELECT {{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}} + CAST([value] AS VARCHAR(MAX)) FROM #tmp_aaa WHERE (name = Results.name) FOR XML PATH({{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}),TYPE ).value({{{SINGLE-QUOTE}}}.{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}VARCHAR(MAX){{{SINGLE-QUOTE}}}) " + //|| " ,1,2,{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}) as NameValues FROM #tmp_aaa Results GROUP BY name " + // inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq = t2.sortseq " + //|| " delete from #tmp_aaa where timstmp2 is not null " + || " select Name, value, ROW_NUMBER() OVER(Partition By Name ORDER BY value DESC) AS Row Into #abc from #tmp_aaa " + || " Select Name, Value ,Case When Value Not in ({{{SINGLE-QUOTE}}}Braile patient handbook{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Service animal{{{SINGLE-QUOTE}}}, " + || " {{{SINGLE-QUOTE}}}Interpreter Service contacted{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Interpreter present during consent{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Interpreter present during physician visit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Interpreter present{{{SINGLE-QUOTE}}} " + || " ,{{{SINGLE-QUOTE}}}Read lips{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}TDD phone{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Pen & Paper{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Text cell phone{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Language line{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Service animal present{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Special call bell present{{{SINGLE-QUOTE}}} ) " + || " Then Value End as SuggestedVal, Row From #abc " + || " drop table #tmp_aaa drop table #abc " + }; + + + + + // Visually Impaired + vi_val1 := first of(Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_VisuallyImpaired" And Ord_vals.Obs_Row = 1 ); + vi_val2 := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_VisuallyImpaired" And Ord_vals.Obs_Row = 2 ); + vi_val3 := first of(Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_VisuallyImpaired" And Ord_vals.Obs_Row = 3 ); + vi_Sugg := first of(Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_VisuallyImpaired" And Ord_vals.Obs_sug is Not Null ); + + Var1 := vi_val1, vi_val2, vi_val3; + + // Hearing Impaired + Hi_val1 := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Hearing Impaired" And Ord_vals.Obs_Row = 1 ); + Hi_val2 := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Hearing Impaired" And Ord_vals.Obs_Row = 2 ); + Hi_val3 := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Hearing Impaired" And Ord_vals.Obs_Row = 3 ); + Hi_val4 := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Hearing Impaired" And Ord_vals.Obs_Row = 4 ); + Hi_val5 := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Hearing Impaired" And Ord_vals.Obs_Row = 5 ); + Hi_val6 := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Hearing Impaired" And Ord_vals.Obs_Row = 6 ); + Hi_val7 := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Hearing Impaired" And Ord_vals.Obs_Row = 7 ); + Hi_val8 := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Hearing Impaired" And Ord_vals.Obs_Row = 8 ); + Hi_val9 := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Hearing Impaired" And Ord_vals.Obs_Row = 9 ); + Hi_Sugg := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Hearing Impaired" And Ord_vals.Obs_sug is Not Null ); + + Var2 := Hi_val1, Hi_val2, Hi_val3, Hi_val4, Hi_val5, Hi_val6, Hi_val7, Hi_val8, Hi_val9; + + // Limited English Impaired + En_val1 := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Limited English" And Ord_vals.Obs_Row = 1 ); + En_val2 := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Limited English" And Ord_vals.Obs_Row = 2 ); + En_Sugg := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Limited English" And Ord_vals.Obs_sug is Not Null ); + Var3 := En_val1, En_val2 ; + // Mobility Impaired-Service Animal Present + Mo_val1 := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Mobility Impaired" And Ord_vals.Obs_Row = 1 ); + Mo_val2 := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Mobility Impaired" And Ord_vals.Obs_Row = 2 ); + Mo_val3 := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Mobility Impaired" And Ord_vals.Obs_Row = 3 ); + Mo_Sugg := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Mobility Impaired" And Ord_vals.Obs_sug is Not Null ); + Var4 := Mo_val1, Mo_val2, Mo_val3; + + // Mobility Impaired- Special Call Bell + Mo1_val1 := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Immobility Risk – Special Call Bell" And Ord_vals.Obs_Row = 1 ); + Mo1_val2 := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Immobility Risk – Special Call Bell" And Ord_vals.Obs_Row = 2 ); + Mo1_val3 := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Immobility Risk – Special Call Bell" And Ord_vals.Obs_Row = 3 ); + Mo1_Sugg := first of (Ord_vals.Obs_val where Ord_vals.Obs_name = "SCHCK_Immobility Risk – Special Call Bell" And Ord_vals.Obs_sug is Not Null ); + Var5 := Mo1_val1, Mo1_val2, Mo1_val3; + + + MLM_DIPA := MLM {{{SINGLE-QUOTE}}}UTIL_OBJECT_Customize_DIPA_MLM{{{SINGLE-QUOTE}}}; + + prm_Comf_mes := First of (this_parms where this_parms.Name = "SCH_NSR_Visually Impaired"); + prm_Comf_mes1 := First of (this_parms where this_parms.Name = "SCH_NSR_Hearing Impaired"); + prm_Comf_Eng := First of (this_parms where this_parms.Name = "SCH_NSR_Limited English"); + prm_Comf_Mo := First of (this_parms where this_parms.Name = "SCH_NSR_Mobility Impaired"); + prm_Comf_Mo1 := First of (this_parms where this_parms.Name = "SCH_NSR_Immobility Risk – Special Call Bell"); + + + /*if exists Var1 then + + Obs_Comf_Vi := CALL MLM_DIPA WITH this_DocumentCommunication,prm_Comf_mes, Var1 as string ; + Obs_Comf_Vi.ValueObj.SuggestedTextValue := vi_Sugg ; // "Vishal"; + + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList,Obs_Comf_Vi ); + endif; */ + + +//To Clear the existing Charted Values========================================================================================= + + Obs_Comf_Vi := CALL MLM_DIPA WITH this_DocumentCommunication,prm_Comf_mes, "" as string ; + Obs_Comf_Vi.ValueObj.SuggestedTextValue := vi_Sugg ; + + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList,Obs_Comf_Vi ); + /*-------------------------------------------------------------------*/ + Obs_Comf_mes1 := CALL MLM_DIPA WITH this_DocumentCommunication,prm_Comf_mes1, "" As String ; + Obs_Comf_mes1.ValueObj.SuggestedTextValue := Hi_Sugg ; + + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList,Obs_Comf_mes1 ); + /*-------------------------------------------------------------------*/ + + Obs_Comf_Eng := CALL MLM_DIPA WITH this_DocumentCommunication,prm_Comf_Eng, "" As String ; + Obs_Comf_Eng.ValueObj.SuggestedTextValue := En_Sugg ; + + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, + Obs_Comf_Eng); + /*-------------------------------------------------------------------*/ + Obs_Comf_Mo := CALL MLM_DIPA WITH this_DocumentCommunication,prm_Comf_Mo, "" As String ; + Obs_Comf_Mo.ValueObj.SuggestedTextValue := Mo_Sugg ; + + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, + Obs_Comf_Mo); + /*-------------------------------------------------------------------*/ + Obs_Comf_Mo1 := CALL MLM_DIPA WITH this_DocumentCommunication,prm_Comf_Mo1, "" As String ; + Obs_Comf_Mo1.ValueObj.SuggestedTextValue := Mo1_Sugg ; + + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, + Obs_Comf_Mo1); + + + +//=============================================================================================================================== + + if exists Var1 then + + Obs_Comf_Vi := CALL MLM_DIPA WITH this_DocumentCommunication,prm_Comf_mes, Var1 as string ; + Obs_Comf_Vi.ValueObj.SuggestedTextValue := vi_Sugg ; + + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList,Obs_Comf_Vi ); + + + + endif; + + if exists Var2 then + Obs_Comf_mes1 := CALL MLM_DIPA WITH this_DocumentCommunication,prm_Comf_mes1, Var2 as string ; + Obs_Comf_mes1.ValueObj.SuggestedTextValue := Hi_Sugg ; + + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList,Obs_Comf_mes1 ); + endif; + + if exists Var3 then + + Obs_Comf_Eng := CALL MLM_DIPA WITH this_DocumentCommunication,prm_Comf_Eng, Var3 as string ; + Obs_Comf_Eng.ValueObj.SuggestedTextValue := En_Sugg ; + + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, + Obs_Comf_Eng); + endif; + if exists Var4 then + + Obs_Comf_Mo := CALL MLM_DIPA WITH this_DocumentCommunication,prm_Comf_Mo, Var4 as string ; + Obs_Comf_Mo.ValueObj.SuggestedTextValue := Mo_Sugg ; + + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, + Obs_Comf_Mo); + endif; + + if exists Var5 then + + Obs_Comf_Mo1 := CALL MLM_DIPA WITH this_DocumentCommunication,prm_Comf_Mo1, Var5 as string ; + Obs_Comf_Mo1.ValueObj.SuggestedTextValue := Mo1_Sugg ; + + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + this_documentCommunication.DocumentConfigurationObj.ChartedObservationsList, + Obs_Comf_Mo1); + endif; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_SMP_MEDS_SURGICAL_CASE.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_SMP_MEDS_SURGICAL_CASE.mlm new file mode 100644 index 0000000..867b5b1 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_SMP_MEDS_SURGICAL_CASE.mlm @@ -0,0 +1,755 @@ +maintenance: + + title: Document Surgical Case Medication Fields;; + mlmname: DOC_SCH_SMP_MEDS_SURGICAL_CASE;; + arden: version 2.5;; + version: 16.30;; + institution: Allscripts ;; + author: Allscripts;; + specialist: ;; + date: 2017-02-17;; + validation: testing;; + + +library: + purpose: Demonstrates the ability to pull surgical case info into the structured note when the document is opened and when it is saved. + ;; + explanation: Demonstrates the ability to pull surgical case info. + +//// Change History for SCH ///////////////////////////////////////////// + + + + + 03/08/17 - added (NOLOCK) to SQL fetches + + 04/13/17 - inital deploy to DEV 163 at SCH + 04/14/17 - add "Drugs " as a Medication section to fetch from + 04/26/17 - addition for clearing Dose Route and Site - when Clear Meds hit + 05/11/17 - update for all the rest of the Meds Observations + + 11/20/17 - update for pull of only Active meds from teh current Preference card in case of switch of Cards + 04/04/18 - update for getting the Name of the Generic supply item if admin{{{SINGLE-QUOTE}}}ed as a med + 04/11/18 - update enhancement comment out above 04/04/18 overwrite of Med name + and addition of Comment observations + + 05/04/18 - Ray Latimer HD 3203018 updates for reload of meds to hold their position - new ones move to end + + ***08/01/16 - Allscripts - try fix for Participants to use external_participant_name if no Staff/CV3User configuration +/////////////////////////////////////////////////////////////////////////////// + + To use this mlm the following needs to be done: + 1) Create two Observation Items. + For example, name them "Surgical Case Number" and "Surgical Case Info". + + Name - "Surgical Case Number" + Data Definition - Data Type: Free text; Maximum Input Length: 500; Maximum Number of Lines: 1; + Field Height: 1; Field Width: 200; (or it could be anything you want)1 + Enable Formatting Text: Unchecked + Row Label Definition - Left Justified: Surgical Case Number; Modify Parameter/Filter: Surgical Case Number; + Security - No Editing: true; Add some rights + + Name - "Surgical Case Info" + Data Definition - Data Type: Free text; Maximum Input Length: 50000; Maximum Number of Lines: 9999; + Field Height: 100; Field Width: 100; (or it could be anything you want) + Enable Formatting Text: Checked + Row Label Definition - Left Justified: Surgical Case Info; Modify Parameter/Filter: Surgical Case Info; + Security - No Editing: true; Add some rights + + 2) Create one Observation Set. + For example, name it "Surgical Case Details Set". + + Set Type: Unbordered + Add Set Items and add the two Observation Items from above. + + 3) Create one Observation Group. + For example, name it "Surgical Case Details Group". + + Add Items and add the Unbordered Observation Set, "Surgical Case Details Set". + Positioning - Set the row numbers and column numbers. + + 4) Create a Structured Note. + For example, name it "Surgical Case Structured Note". + + Add Attributes: Select the Observation Group: "Surgical Case Details Group". + Click on the Surgical Case Number and in Called MLM, select + Click on the Surgical Case Info and in Called MLM, select + + 5) Create a Document. + For example, name it "Surgical Case Document". + + Opening MLM and Closing MLM: DOC_SMP_SURGICAL_CASE + Data Collection: Structured Note + Search and select "Surgical Case Structured Note". + Security - Add some rights + + 6) Set the variables, case_number_parameter_name and case_info_parameter, on this MLM with the Observation Items names created on Step 1 above. + + For example, + + case_number_parameter_name := "Surgical Case Number"; + case_info_parameter_name := "Surgical Case Info"; + + 7) Set the variable, is_display_message, on this MLM if a message should display when opening the document. + + For example, + + is_display_message := true; + + 8) Ensure that the user has the right "Can Add Document Topic to SN". + + 9) Set the Environment Profile - Documents > Structured Notes > DocumentTopic to TRUE. When viewing the document, the Document Topic will + contain the Case Number. Also, the document name will be appended with the Case Number. + + 10) From Gateway, select a Surgical Case. From the Document Entry Worksheet, enter "Surgical Case Document". The document + should display with the case number and case details of the case in context. User can edit the Surgical Case from the Case Details tab/window. + On saving the document, the latest case details will be saved on the document. + + ;; + keywords: RTF, Document Called MLM , Surgical Case + ;; +knowledge: + type: data-driven;; + data: + (this_documentCommunication) := argument; + + /*******************Make Changes To Spelling And Flags In This Section******************/ + + +// References the LOCAL SESSION object +/// 01/12/17 - for Medication section + local_session := cds_session.local; + + + standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + /* Set to true if a decision.log is needed.*/ + log_execution_info := false; + + /* Set to parameter name of the free text observation item representing the case number. */ + case_number_parameter_name := "SRG UH Surgical Case Number"; //"OR Surgical Case Number FT"; + + /* Set to parameter name of the free text observation item representing the case info. */ + case_info_parameter_name := "SRG UH Surgical Case Info FT"; //"OR Surgical Case Info FT"; + + /* Set to true if displaying a message when opening the document. */ + is_display_message := false; + +/// SCH observations //////////////////////////////////// + + + + medic_list_0 := "SRG SCH med _ FT" ; //, "SRG SCH med 2 FT", "SRG SCH med 3 FT", "SRG SCH med 4 FT", "SRG SCH med 5 FT" ; //, + + ///get all of the observations: + +medic_list := ""; + //by_whom:= ""; +/// 04/11/18 - addition to enhancement for COmment Obs + +medic_com_list:= "" ; + + FOR i in 1 seqto 20 DO + wr_param := call (medic_list_0 as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "_", i as string ; + //wr_ft := call (spec_ft as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "_", i as string ; + if i = 1 then + medic_list:= wr_param; + //by_whom:= wr_ft; + else + medic_list:= medic_list, wr_param; + //by_whom:= by_whom, wr_ft; + endif; +/// 04/11/18 - enhancmenet update + get_repl:= i||" Comment" ; + wr_param_c := call (medic_list_0 as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "_", get_repl as string ; + //wr_ft := call (spec_ft as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "_", i as string ; + if i = 1 then + medic_com_list:= wr_param_c; + //by_whom:= wr_ft; + else + medic_com_list:= medic_com_list, wr_param_c; + //by_whom:= by_whom, wr_ft; + endif; + ENDDO; + +//////////////////////////////////////////// + + med_clear := "SRG SCH med 1 Clear Contents", "SRG SCH med 2 Clear Contents", "SRG SCH med 3 Clear Contents", "SRG SCH med 4 Clear Contents", + "SRG SCH med 5 Clear Contents" ; // ,"SRG UH SED Med 6 Clear Contents" ,"SRG UH SED Med 7 Clear Contents" ,"SRG UH SED Med 8 Clear Contents" , + //"SRG UH SED Med 9 Clear Contents" , + //"SRG UH SED Med 10 Clear Contents" , + //"SRG UH SED Med 11 Clear Contents", "SRG UH SED Med 12 Clear Contents", "SRG UH SED Med 13 Clear Contents", "SRG UH SED Med 14 Clear Contents", + //"SRG UH SED Med 15 Clear Contents" ,"SRG UH SED Med 16 Clear Contents" ,"SRG UH SED Med 17 Clear Contents" ,"SRG UH SED Med 18 Clear Contents" , + //"SRG UH SED Med 19 Clear Contents" , + //"SRG UH SED Med 20 Clear Contents" + //; +// 01/16/17 - med reload observation + + med_load:= "SRG SCH med Reload" ; +//////////////////////////////////////////////////////// + + /***************************************************************************************/ + + /*** Variable and Constant Declaration ***/ + + (this_structuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (this_parameters) := this_structuredNoteDoc.ParametersList; + (this_chartedObservationsList) := this_structuredNoteDoc.ChartedObservationsList; + (this_eventType) :=this_documentCommunication.EventType; + (this_currentObj) := this_documentCommunication.CurrentObservationObj; + + current_parameter := FIRST OF (this_Parameters + WHERE this_parameters.ParameterGUID = this_CurrentObj.ParameterGUID); + current_parameter_name := current_parameter.name ; + cur_obs:= FIRST OF (this_parameters WHERE this_parameters.name = current_parameter_name) ; + cur_obj:= FIRST OF (this_Parameters + WHERE this_parameters.ParameterGUID = cur_obs.ParameterGUID); + cur_val_obj := cur_obj.valueobj; + cur_val_text := this_currentObj.ValueObj.Value; //cur_val_obj.value; + get_vals:= this_currentObj.ValueObj.Records__ ; + get_val_list:= get_vals.ListItemsList.IsSelected; //Value; //Records__; //this_currentObj.ValueObj.ListValue ; + ct_lst:= count get_val_list; + + + +//break; + if called_by_editor then + client_guid := read last {ClientInfo: GUID}; + client_visit_guid := read last {ClientVisit: GUID}; + chart_guid := read last{ClientVisit: ChartGUID}; + ///testin /// CONVERT(varchar, CONVERT(datetime, cpt.InDateTimeUTC)), + case_id:= 443; //492; // 569; //356; + (it_ItemID, it_Item, it_catno, it_desc, it_supNotes, it_Dispodtm, it_Manu, it_Charge, + it_serial, it_lot, it_site, it_quant, it_ExpMM, it_expDD, it_expYYYY, + it_DispoID, + it_Intact, it_Stored, it_Follow, it_PrepStart , it_PrepStop, it_user, it_tnotes ):= read // it_xml, + {" select sdi.ItemID, sdi.ItemName,csi.CatalogNumber, csi.ItemMasterDescription, csi.Notes, " + || " CONVERT(varchar, CONVERT(datetime, csi.DispositionDateUTC)), inv.SourceName, cc.Code, " + ||" csid.SerialNumber, csid.LotNumber, csid.SiteName, csid.Quantity, csid.ExpirationMonth, csid.ExpirationDay, csid.ExpirationYear, " + ||" csid.DispositionID," + ||" csit.IsIntact, csit.CorrectTemperatureStoredType, csit.ManufacturerInstructFollowType, " + ||" CONVERT(varchar, CONVERT(datetime, csit.PreparationStartedDateTimeUTC)), CONVERT (varchar, CONVERT(datetime, csit.PreparationEndedDateTimeUTC)), " + || " u.DisplayName, csit.Notes " // csit.DetailXML, + ||" from sxasrgcase c " + ||" left join SXASRGCaseItem ci on ci.CaseID = c.CaseID " + ||" inner join sxasrgdepartmentsurgicalitem sdi on sdi.ItemID = ci.ItemID " + ||" left join SXASRGCaseItemSupplementalInfo csi on csi.CaseItemID = ci.CaseItemID " + ||" left outer join SXASRGCaseItemSupplementalInfoDtl csid on csid.CaseItemSupplementalInfoID = csi.CaseItemSupplementalInfoID " + ||" left join SXASRGInvSource inv on inv.SourceID = csi.SourceID " + ||" left join SXASRGChargeCode cc on cc.ChargeCodeID = csi.ChargeCodeID " + ||" left outer join SXASRGCaseItemTissue csit on (csit.CaseItemSupplementalInfoDtlID = csid.CaseItemSupplementalInfoDtlID and csit.Active = 1 ) " + ||" left outer join SXASRGCaseItemTissueSurgeryStaffXRef itst on itst.CaseItemTissueID = csit.CaseItemTissueID " + ||" left outer join SXASRGSurgeryStaff sss on sss.SurgeryStaffID = itst.SurgeryStaffID " + ||" left outer join cv3user u on u.guid = sss.userguid " + ||" where c.CaseID = " || SQL(case_id) }; + // || " and csit.Active = 1 " } ;// + + + ct_item_check:= count it_item where it_intact <> "null" ; //it_user; + ct_item:= count it_item ; + //break; + + /////////////////////////////////////////////// + endif; + + /*** RTF Formatting variables ***/ + HEADER1_ON:="\f1\fs28 \b1"; + HEADER1_OFF:="\b0 \fs0"; + HEADER2_ON:="\f1\fs24 \b1"; + HEADER2_OFF:="\b0 \fs0"; + BODY_TAG:="\fs20"; + BOLD_ON:="\b1"; + BOLD_OFF:="\b0"; + ITALIC_ON:="\i"; + ITALIC_OFF:="\i0"; + TAB:="\tab"; + + /*** RTF Grid Formatting variables ***/ + GRID_START:="\par"; + ROW_START := "\trowd\trgaph144"; + CELL_BORDER := "\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs"; + CELL_START := "\cellx"; + CELL_END := "\intbl\cell"; + ROW_END := "\row"; + GRID_END:="\pard"; + + called_dom_mlm := MLM {{{SINGLE-QUOTE}}}CALLED_RPM_DOM_MLM{{{SINGLE-QUOTE}}} ; + +///02/17/17 - for inital section of charting SED MEds + // Get the case id of the case in context + case_id := this_documentCommunication.CaseId ; + + +IF +/// Now for - medication Clear and reload section + this_eventType = "ChartObservation" + + AND + (current_parameter_name IN med_clear) //or current_parameter_name IN frozen_param) + then + get_select:= "%true"; + if (string(get_val_list)) matches pattern get_select //get_select in get_val_list //exists cur_val_text + then + get_cl_obs:= first of ( medic_list where current_parameter_name = med_clear ); +/// 01/13/17 - for reload of meds upon clear + get_cl_med:= FIRST OF (this_Parameters + WHERE this_parameters.Name = get_cl_obs); + get_cl_obj:= first of (this_chartedObservationsList WHERE this_chartedObservationsList.ParameterGUID = get_cl_med.ParameterGUID); + med_val_obj := get_cl_obj.Records__ ;//valueobj; + med_val_text := get_cl_obj.ValueObj.Value; + local_session.CCC_ChartedObs:= local_session.CCC_ChartedObs, med_val_text; +/// 01/18/17 - to determine if the Mixed With? observation has been valued + /* mix_obs := call (current_parameter_name as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "Clear Contents", "Mixed With?" as string; + get_mix_med:= FIRST OF (this_Parameters + WHERE this_parameters.Name = mix_obs); + get_mix_obj:= first of (this_chartedObservationsList WHERE this_chartedObservationsList.ParameterGUID = get_mix_med.ParameterGUID); + //med_val_obj := get_cl_obj.Records__ ;//valueobj; + mix_val_text := get_mix_obj.ValueObj.Value; +*/ +///////////////////////////////////////////////////// + med_desc := ""; // null; + this_documentCommunication := call called_dom_mlm with + (this_documentCommunication, get_cl_obs, med_desc, sugg_txt_value, update_type); + this_documentCommunication := call called_dom_mlm with + (this_documentCommunication, current_parameter_name, null, sugg_txt_value, update_type); +/// 04/26/17 - addition for clearing Dose Route and Site + dose_obs := call (current_parameter_name as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "Clear Contents", "Dose FT" as string; + rout_obs := call (current_parameter_name as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "Clear Contents", "Route" as string; + site_obs := call (current_parameter_name as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "Clear Contents", "Site" as string; + + this_documentCommunication := call called_dom_mlm with + (this_documentCommunication, dose_obs, med_desc, sugg_txt_value, update_type); + + this_documentCommunication := call called_dom_mlm with + (this_documentCommunication, rout_obs, null, sugg_txt_value, update_type); + this_documentCommunication := call called_dom_mlm with + (this_documentCommunication, site_obs, null, sugg_txt_value, update_type); +///////////////////////////////////////////////////////////////////////////////////////////////////////// + //endif; +/// 01/13/17 - now for reload without the cleared meds +/// 01/18/17 - added to not re_load and Move if the clear happened where a Mix of meds was + If not (exists mix_val_text) or mix_val_text is null + then +///////////////////////////////////// + (get_med0, get_qty0, get_comm_0) := read { " select sai.ItemName, cai.UsedCount, cai.Notes from SXASRGCase ca (NOLOCK) " + ||" Join SXASRGCaseItem cai (NOLOCK) on ( cai.CaseID = ca.CaseID and cai.Active = 1 ) " + ||" join SXASRGInventorySection sis (NOLOCK) on sis.InventorySectionID = cai.InventorySectionID " + ||" join SXASRGDepartmentSurgicalItem sai (NOLOCK) on ( sai.DepartmentSurgicalItemID = cai.DepartmentSurgicalItemID and sai.Active = 1) " + ||" where (sis.Code like {{{SINGLE-QUOTE}}}Medic%{{{SINGLE-QUOTE}}} or sis.Code like {{{SINGLE-QUOTE}}}Drug%{{{SINGLE-QUOTE}}} ) and cai.usedcount > 0 " + ||" AND ca.CaseId = " || SQL(case_id)}; //{{{SINGLE-QUOTE}}}c00408{{{SINGLE-QUOTE}}} " }; + + get_med:= get_med0 where they not in local_session.CCC_ChartedObs ; + get_qty:= get_qty0 where get_med0 in get_med; + + ct_meds:= count get_med; + IF ct_meds > 0 then + hold_obs:= ""; +////// 01/20/17 - keep track of meds if observationskipped due to Mixed With? + re_do:= 0; + + FOR i in 1 seqto count medic_list DO //ct_meds DO + qty_i:= get_qty[i] as number; + med_i:= get_med[i]; +/// 01/20/17 - value + if re_do <> 0 then + qty_i := get_qty[re_do] as number; + med_i:= get_med[re_do]; + endif; + /// 01/20/17 - for not writing into med fields for Mix and beyond then meds + mix_obs_0 := call (medic_list[i] as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "Medication", "Med" as string; + mix_obs_1 := call (mix_obs_0 as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "FT", "Mixed With?" as string; + get_mix_med_r:= FIRST OF (this_Parameters WHERE this_parameters.Name = mix_obs_1); + get_mix_obj_r:= first of (this_chartedObservationsList WHERE + this_chartedObservationsList.ParameterGUID = get_mix_med_r.ParameterGUID); + mix_val_text_r := get_mix_obj_r.ValueObj.Value; + /// ///////////////////////// + + if exists med_i and qty_i >=1 +//// 01/20/17 - added for revalue + //AND NOT (exists mix_val_text_r) + then + if exists mix_val_text_r + then +/// 01/23/17 - update to value re_do to i only if it is 0 + /// for additional logic upon reload of all meds when clear has been hit + /// 01/23/17 - for reload of meds upon clear + get_c_med:= FIRST OF (this_Parameters + WHERE this_parameters.Name = medic_list[i]); + get_c_obj:= first of (this_chartedObservationsList + WHERE this_chartedObservationsList.ParameterGUID = get_c_med.ParameterGUID); + //med_c_obj := get_c_obj.Records__ ;//valueobj; + med_c_text := get_c_obj.ValueObj.Value; +//////////////////////////////////// + if exists med_c_text and med_c_text = med_i + then + stop:=1; + elseif re_do = 0 then + re_do:= i ; + endif; +///// end of re_do valuationif mix_val_text_r + //FOR e in 1 seqto count medic_list DO + //if (medic_list[e] in hold_obs ) then + //stop:= 1; + else // write med to Observation + target_param := medic_list[i]; + hold_obs:= hold_obs, medic_list[i]; + //break; +/// for additional logic upon reload of all meds when clear has been hit + /// 01/23/17 - for reload of meds upon clear + //get_c_med:= FIRST OF (this_Parameters + // WHERE this_parameters.Name = target_param); + //get_c_obj:= first of (this_chartedObservationsList WHERE this_chartedObservationsList.ParameterGUID = get_c_med.ParameterGUID); + //med_c_obj := get_c_obj.Records__ ;//valueobj; + // med_c_text := get_c_obj.ValueObj.Value; +//////////////////////////////////// + // if exists med_c_text and med_c_text = med_i + // then + // stop:=1; + //else + //// 01/23/17 - added to skip over valuing + this_documentCommunication := call called_dom_mlm with + (this_documentCommunication, target_param, med_i, sugg_txt_value, update_type); + +/// 01/23/17 - do not set redo - increment if it already has a value > 0 + If re_do <> 0 then //re_do:= 0; + re_do:= re_do + 1; + ENDIF; + endif; + else /// remainder of observations get "" + target_param := medic_list[i]; + this_documentCommunication := call called_dom_mlm with + (this_documentCommunication, target_param, "", sugg_txt_value, update_type); + //re_do:= 0; + //endif; + //ENDDO; // loop through obs list + endif; // qty_i >=1 +/// for testing + user_guid:= this_documentCommunication.UserGuid; + userid:= read last {" select IDCode from cv3user where guid = "|| sql (user_guid) }; + if userid matches pattern "service%" + then + ray:=1; + //break; + endif; + ENDDO; /// Loop through meds + + // now clear out any further + /* get_extras:= medic_list where they not in hold_obs; + FOr i in 1 seqto count get_extras DO + target_d := get_extras[i]; + get_d_med:= FIRST OF (this_Parameters + WHERE this_parameters.Name = target_d); + get_d_obj:= first of (this_chartedObservationsList WHERE this_chartedObservationsList.ParameterGUID = get_d_med.ParameterGUID); + // med_val_obj := get_cl_obj.Records__ ;//valueobj; + med_d_text := get_d_obj.ValueObj.Value; + if exists med_d_text and med_d_text <> "" then + this_documentCommunication := call called_dom_mlm with + (this_documentCommunication, target_d, "", sugg_txt_value, update_type); + endif; + ENDDO; + */ + ENDIF; // ct meds > 0 +/// 01/18/17 - for determinationnot to reload + ENDIF; // if not exists mix_ val + + //////////// end of reload ////////////////////////////////// + /// for testing + user_guid:= this_documentCommunication.UserGuid; + userid:= read last {" select IDCode from cv3user where guid = "|| sql (user_guid) }; + if userid matches pattern "service%" + then + ray:=1; + // break; + endif; + + endif; // if (string(get_val_list)) matches pattern get_select +//////////// and of charting specimens///////////////////////// + +/// add "ELSE" to the orignal "IF" below + /// 01/17/17 - update for Reload medications + // Chart the case number and case info observation items when opening and closing the document + ELSEIf this_eventType = "DocumentOpening" //or this_eventType = "DocumentClosing" then + OR (this_eventType = "ChartObservation" + AND + (current_parameter_name IN med_load) ) + then + stop_it:= 0; +/// 12/28/16 - addition for fetching Medications Items charted in IntraOp - Usage Tabs + IF this_eventType = "DocumentOpening" then + local_session.CCC_ChartedObs := null; + + med_targ_param:= first of (this_parameters WHERE this_parameters.Name = medic_list[1] ); + + get_cl_obj:= first of (this_chartedObservationsList WHERE this_chartedObservationsList.ParameterGUID = med_targ_param.ParameterGUID); + med_val_obj := get_cl_obj.Records__ ;//valueobj; + med_val_text := get_cl_obj.ValueObj.Value; + if exists med_val_text then + stop_it := 1; + + + + endif; + + + + // medic_targ_val_obj := medic_targ_parameter.valueobj; + /// medic_targ_text := medic_targ_val_obj.value; + + ENDIF; /// document opening // " //, sis.Code +re_flag:=0; +/// 01/17/17 - n0w null out Re-load observation + if this_eventType = "ChartObservation" + AND + (current_parameter_name IN med_load) + then + this_documentCommunication := call called_dom_mlm with + (this_documentCommunication, current_parameter_name, null, sugg_txt_value, update_type); + re_flag:=1; + ///05/08/18 - to re load first check with val text from meds observations already there + pre_obs:= ""; + pre_val:= ""; + FOR i in 1 seqto count medic_list DO //ct_meds DO + /// 01/20/17 - for not writing into med fields for + + get_mix_med_r:= FIRST OF (this_Parameters WHERE this_parameters.Name = medic_list[i] ); + get_mix_obj_r:= first of (this_chartedObservationsList WHERE + this_chartedObservationsList.ParameterGUID = get_mix_med_r.ParameterGUID); + mix_val_text_r := get_mix_obj_r.ValueObj.Value; + /// ///////////////////////// + if exists mix_val_text_r then + if pre_obs = "" then + pre_obs:= medic_list[i]; + pre_val:= mix_val_text_r; + else + pre_obs:= pre_obs, medic_list[i]; + pre_val:= pre_val, mix_val_text_r; + endif; + endif; + enddo; + + ///////////////////////////////////////////////////////////////////////////// + endif; + +/// 01/17/17 + If stop_it = 0 then + (get_med0, get_qty0, get_comm_0) := read { " select sai.ItemName, cai.UsedCount, cai.Notes from SXASRGCase ca (NOLOCK) " + ||" Join SXASRGCaseItem cai (NOLOCK) on ( cai.CaseID = ca.CaseID and cai.Active = 1 ) " + ||" join SXASRGInventorySection sis (NOLOCK) on sis.InventorySectionID = cai.InventorySectionID " + ||" join SXASRGDepartmentSurgicalItem sai (NOLOCK) on ( sai.DepartmentSurgicalItemID = cai.DepartmentSurgicalItemID and sai.Active = 1) " + ||" where (sis.Code like {{{SINGLE-QUOTE}}}Medic%{{{SINGLE-QUOTE}}} or sis.Code like {{{SINGLE-QUOTE}}}Drug%{{{SINGLE-QUOTE}}} ) and cai.usedcount > 0 " + ||" AND ca.CaseId = " || SQL(case_id) }; //|| " order by sai.ItemName asc " }; //{{{SINGLE-QUOTE}}}c00408{{{SINGLE-QUOTE}}} " }; + + /// 01/17/17 - update to pull those not stored in Local session + //get_med:= get_med0 where they not in local_session.CCC_ChartedObs; + //get_qty:= get_qty0 where get_med0 in get_med; + +/// 05/08/18 - for reload - check previous + if re_flag > 0 then //exists pre_obs and pre_obs <> "" then + ct_pre:= count pre_val; + get_med := get_med0 where they not in pre_val ; + // break; + get_qty:= get_qty0 where get_med0 in get_med ; + get_comm_0 := get_comm_0 where get_med0 in get_med ; + + else + /// 01/17/17 - update to pull those not stored in Local session + get_med:= get_med0 where they not in local_session.CCC_ChartedObs; + get_qty:= get_qty0 where get_med0 in get_med; + // break; + endif; + +/////////////////////////////////////// + ct_meds:= count get_med; + + IF ct_meds > 0 then + hold_obs:= ""; + add_meds:= 0; + FOR i in 1 seqto ct_meds DO + + qty_i:= get_qty[i] as number; + med_i:= get_med[i]; + // add_meds:= 0; + ct_meds := ct_meds + add_med; + +//// 04/04/18 - update for getting the Name of the Generic supply item if admin{{{SINGLE-QUOTE}}}ed as a med + if // med_i matches pattern "Generic%" + exists get_comm_0[i] + then + // med_i := get_comm_0[i]; +/// 04/11/18 - update enhancement comment out above 04/04/18 overwrite of Med name + med_i_com := get_comm_0[i]; + else + med_i_com := null; + endif; +//////////////////////////////////////////////////////////////////////////////// + + if qty_i >=1 then +/// 01/20/17 - re-up loop through med_list obs tonot value if "Mixed With?" is valued + stop_loop:= 0; + FOR e in 1 seqto count medic_list DO + med_to:= medic_list[e] ; + com_to:= medic_com_list[e] ; + + mix_obs_0 := call (med_to as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "Medication", "Med" as string; + mix_obs := call (mix_obs_0 as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "FT", "Mixed With?" as string; +/// 05/04/18 - switch to look at the target med FT (med_to) + get_mix_med:= FIRST OF (this_Parameters WHERE this_parameters.Name = med_to); + get_mix_obj:= first of (this_chartedObservationsList WHERE + this_chartedObservationsList.ParameterGUID = get_mix_med.ParameterGUID); + //med_val_obj := get_cl_obj.Records__ ;//valueobj; + mix_val_text := get_mix_obj.ValueObj.Value; + +///////////////////////////////////////////////////////// + IF this_eventType = "DocumentOpening" //then + and (med_to in hold_obs ) then + stop:= 1; + //hold_obs:= hold_obs, med_to ; + //endif; +/// 05/08/18 - for excluding already loaded Meds Obs on reload + + elseif med_to in pre_obs + then + stop:= 1; + hold_obs:= hold_obs, med_to ; +/// 05/04/18 add to hold onto the MEd Text that is in that occupied Obs + elseif exists mix_val_text AND (mix_val_text <> "" or mix_val_text is not null) + and med_i <> mix_val_text + then + hold_obs:= hold_obs, med_to, mix_val_text ; +//05/04/18 put the skipped at the end + if not (med_i in hold_obs )and med_i <> mix_val_text then + get_med := get_med, med_i; + get_comm_0:= get_comm_0, get_comm_0[i]; + //ct_meds := ct_meds + 1; + add_meds:=add_meds + 1; + + endif; + /// 05/04/18 - to stop the loop if no more meds to go through + // elseif e > (ct_meds + 1) and hold_obs <> "" then + // stop_loop:= 1; +//////////////////////////////////////////////////////////////////////////////////// + elseif +/// 05/04/18 - replace this last condition to ensure populate next free obs + //not (exists mix_val_text) then //AND not(med_i in hold_obs) then + stop_loop = 0 then + target_param := med_to ; //medic_list[i]; +/// 04/11/18 update + target_param_com := com_to; +/// 05/04 /1 - addition to not hold Obs that do not get populated + // if exists med_i then + ///////////////////////////////////////////////////////////// + hold_obs:= hold_obs, med_to; //, med_i; // medic_list[i]; + pre_obs:= pre_obs, med_to; + pre_val:= pre_val, med_i; + + // endif; // end of 05/04/18 addition +/// write to med +/// 05/04/18 if the Med is in MEd Text (hold_obs) that is in that occupied Obs then DON{{{SINGLE-QUOTE}}}T ADD IT + if med_i in hold_obs + then + stop:=2; + else +/////////////////////////////////////////////////////////////// + this_documentCommunication := call called_dom_mlm with + (this_documentCommunication, target_param, med_i, sugg_txt_value, update_type); + endif; /// med_i in hold obs + +/// 05/02/18 - addition to hold added meds in place + /// local_session.CCC_ChartedObs := local_session.CCC_ChartedObs, med_i ; + +/// 04/11/18 - for writing to COmment if there is one + if exists med_i_com then + this_documentCommunication := call called_dom_mlm with + (this_documentCommunication, target_param_com, med_i_com, sugg_txt_value, update_type); + endif; + + stop_loop := 1; + /// 05/04/18 - to stop the loop if no more meds to go through + elseif e > (ct_meds + 1) and hold_obs <> "" then + stop_loop:= 1; +//////////////////////////////////////////////////////////////////////////////////// + endif; + + ENDDO; // loop through obs list +/// 05/03/18 - testing + if i in (8) then + Mayray:= med_i, med_to; + //break; + endif; +////////////////////////// +///////////////////////// end of added loop for med obs - Mixed with///////////////////// + endif; // qty_i >=1 + + if not exists ct_meds then + ct_meds := count get_med; + endif; +/// 05/04/18 - fix for > 1 additionof meds + // ct_meds := ct_meds + add_meds; + /// 05/04/18 + if re_flag > 0 then + //if i = ct_meds then + //ct_meds:= ct_meds + re_flag; //add_meds; + add_med := get_med where they not in med_i; + ct_add:= count add_med; + get_med := get_med, add_med; + add_comm_0 := get_comm_0 where get_med0 in add_med ; + get_comm_0:= get_comm_0, add_comm_0 ; + add_qty:= get_qty0 where get_med0 in add_med ; + get_qty:= get_qty, add_qty ; + if exists ct_add then + ct_meds := count get_med ; //ct_meds + ct_add ; + endif; + add_meds:= ct_add ;//0; + // break; + //re_flag:= 0; + //endif; + endif; + +/// 05/03/18 - testing + if i in (8) then + Mayray:= med_i, med_to; + // break; + endif; +////////////////////////// +/////////////////////////////////////////////////////////////// + ENDDO; /// Loop through meds + //local_session.ccc_lv:= hold_obs; + ENDIF; // ct meds > 0 + ENDIF; // if stop_it = 0 // for med obs valuation + +ENDIF; /// chart observation or DOc Open and chart observation + +/////////////////////////////////////////////////// +/// 01/16/17 - re-arrange for opening again - after work above with re-load + +/// for testing + user_guid:= this_documentCommunication.UserGuid; + userid:= read last {" select IDCode from cv3user where guid = "|| sql (user_guid) }; + if userid matches pattern "service%" + then + ray:=1; + // break; + endif; + + //////////////// + + Debug := is_display_message; // Set Debug := TRUE to see Message in document + document_communication_message := "Parameter Name " || case_number_parameter_name || " Event " || this_eventType || " Case Number " || case_number; + this_documentCommunication.DisplayMessage := is_display_message; + this_documentCommunication.Message := document_communication_message ; + + ;; + + evoke: + ;; + + logic: + conclude true; + ;; + + action: + return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_SMP_SURGICAL_CASE.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_SMP_SURGICAL_CASE.mlm new file mode 100644 index 0000000..e3741c1 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_SMP_SURGICAL_CASE.mlm @@ -0,0 +1,1271 @@ +maintenance: + + title: Document Surgical Case Fields;; + mlmname: DOC_SCH_SMP_SURGICAL_CASE;; + arden: version 2.5;; + version: 16.3 ;; + institution: St Claire ;; + author: Allscripts;; + specialist: Gail G. ;; + date: 2017-04-05;; + validation: testing;; + + +library: + purpose: Demonstrates the ability to pull surgical case info into the structured note when the document is opened and when it is saved. + ;; + explanation: Demonstrates the ability to pull surgical case info. + +//// Change History for SHC ///////////////////////////////////////////// + + + 10/14/16 - Allscripts - updated fetch and display for insertion of Implant Tissue section + into the new_case_info_value for writing to case_info_parameter_name + + 02/07/17 - update for Reload Surgery observation from Gail G. + + + 04/05/17 - initial update to SHC configuration for init deploy- and update Tissue- Implant fetch/display + 04/07/17 - details reload observation + + 04/13/17 Add call to Meds MLM for load + + 08/16/17 Add call to "DOC_CALL_SPECIMEN_PATHOLOGY" + + 12/08/17 - updated for Rita J. to fetch /display for Procedure Dxs + 12/15/17 - now for Post Op and Pre Op - and into PRocedures grids + + 01/03/18 - update to adjust for width of paper on preview - and the extra column for Pre Post Dx + 01/22/18 - updated Dispostion for SCH config + 01/23/18 - update to put Level infront of the number + 02/05/18 - addition for displaying the edited Name from the Supplemental FORm + 02/23/18 - update to pull only Active case Items ci.Active = 1 + + 04/19/18 - update to put ASA infront of the number for the ASA into the Grid + 04/23/18 - change back to Read disposition from config of order for Dispo of Implant + 07/24/19 - STH - CSR#: 37676 - Add new "Physical Status" value that is now used for ASA score to the Surgical Case information section. + ***08/01/16 - Allscripts - try fix for Participants to use external_participant_name if no Staff/CV3User configuration + +/////////////////////////////////////////////////////////////////////////////// + + To use this mlm the following needs to be done: + 1) Create two Observation Items. + For example, name them "Surgical Case Number" and "Surgical Case Info". + + Name - "Surgical Case Number" + Data Definition - Data Type: Free text; Maximum Input Length: 500; Maximum Number of Lines: 1; + Field Height: 1; Field Width: 200; (or it could be anything you want)1 + Enable Formatting Text: Unchecked + Row Label Definition - Left Justified: Surgical Case Number; Modify Parameter/Filter: Surgical Case Number; + Security - No Editing: true; Add some rights + + Name - "Surgical Case Info" + Data Definition - Data Type: Free text; Maximum Input Length: 50000; Maximum Number of Lines: 9999; + Field Height: 100; Field Width: 100; (or it could be anything you want) + Enable Formatting Text: Checked + Row Label Definition - Left Justified: Surgical Case Info; Modify Parameter/Filter: Surgical Case Info; + Security - No Editing: true; Add some rights + + 2) Create one Observation Set. + For example, name it "Surgical Case Details Set". + + Set Type: Unbordered + Add Set Items and add the two Observation Items from above. + + 3) Create one Observation Group. + For example, name it "Surgical Case Details Group". + + Add Items and add the Unbordered Observation Set, "Surgical Case Details Set". + Positioning - Set the row numbers and column numbers. + + 4) Create a Structured Note. + For example, name it "Surgical Case Structured Note". + + Add Attributes: Select the Observation Group: "Surgical Case Details Group". + Click on the Surgical Case Number and in Called MLM, select + Click on the Surgical Case Info and in Called MLM, select + + 5) Create a Document. + For example, name it "Surgical Case Document". + + Opening MLM and Closing MLM: DOC_SMP_SURGICAL_CASE + Data Collection: Structured Note + Search and select "Surgical Case Structured Note". + Security - Add some rights + + 6) Set the variables, case_number_parameter_name and case_info_parameter, on this MLM with the Observation Items names created on Step 1 above. + + For example, + + case_number_parameter_name := "Surgical Case Number"; + case_info_parameter_name := "Surgical Case Info"; + + 7) Set the variable, is_display_message, on this MLM if a message should display when opening the document. + + For example, + + is_display_message := true; + + 8) Ensure that the user has the right "Can Add Document Topic to SN". + + 9) Set the Environment Profile - Documents > Structured Notes > DocumentTopic to TRUE. When viewing the document, the Document Topic will + contain the Case Number. Also, the document name will be appended with the Case Number. + + 10) From Gateway, select a Surgical Case. From the Document Entry Worksheet, enter "Surgical Case Document". The document + should display with the case number and case details of the case in context. User can edit the Surgical Case from the Case Details tab/window. + On saving the document, the latest case details will be saved on the document. + + ;; + keywords: RTF, Document Called MLM , Surgical Case + ;; +knowledge: + type: data-driven;; + data: + (this_documentCommunication) := argument; + + /*******************Make Changes To Spelling And Flags In This Section******************/ + + +// References the LOCAL SESSION object +/// 01/12/17 - for Medication section + local_session := cds_session.local; + + + /* Set to true if a decision.log is needed.*/ + log_execution_info := false; + + /* Set to parameter name of the free text observation item representing the case number. */ + case_number_parameter_name := "Surgical Case Number"; //"OR Surgical Case Number FT"; + + /* Set to parameter name of the free text observation item representing the case info. */ + case_info_parameter_name := "Surgical Case Info"; // FT"; //"OR Surgical Case Info FT"; + + /* Set to true if displaying a message when opening the document. */ + is_display_message := false; + + + + +// 02/07/17 - med reload observation + + med_load:= "Reload surg details" ; +//////////////////////////////////////////////////////// + + /***************************************************************************************/ + + /*** Variable and Constant Declaration ***/ + + (this_structuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (this_parameters) := this_structuredNoteDoc.ParametersList; + (this_chartedObservationsList) := this_structuredNoteDoc.ChartedObservationsList; + (this_eventType) :=this_documentCommunication.EventType; + (this_currentObj) := this_documentCommunication.CurrentObservationObj; + (this_DocumentName) := this_documentCommunication.DocumentName; + + current_parameter := FIRST OF (this_Parameters + WHERE this_parameters.ParameterGUID = this_CurrentObj.ParameterGUID); + current_parameter_name := current_parameter.name ; + cur_obs:= FIRST OF (this_parameters WHERE this_parameters.name = current_parameter_name) ; + cur_obj:= FIRST OF (this_Parameters + WHERE this_parameters.ParameterGUID = cur_obs.ParameterGUID); + cur_val_obj := cur_obj.valueobj; + cur_val_text := this_currentObj.ValueObj.Value; //cur_val_obj.value; + get_vals:= this_currentObj.ValueObj.Records__ ; + get_val_list:= get_vals.ListItemsList.IsSelected; //Value; //Records__; //this_currentObj.ValueObj.ListValue ; + ct_lst:= count get_val_list; + +//break; + if called_by_editor then + client_guid := read last {ClientInfo: GUID}; + client_visit_guid := read last {ClientVisit: GUID}; + chart_guid := read last{ClientVisit: ChartGUID}; + ///testin /// CONVERT(varchar, CONVERT(datetime, cpt.InDateTimeUTC)), + case_id:= 569; //492; // 569; //356; + (it_ItemID, it_Item, it_catno, it_desc, it_supNotes, it_Dispodtm, it_Manu, it_Charge, + it_serial, it_lot, it_site, it_quant, it_ExpMM, it_expDD, it_expYYYY, + it_DispoID, + it_Intact, it_Stored, it_Follow, it_PrepStart , it_PrepStop, it_user, it_tnotes ):= read // it_xml, + {" select sdi.ItemID, sdi.ItemName,csi.CatalogNumber, csi.ItemMasterDescription, csi.Notes, " + || " CONVERT(varchar, CONVERT(datetime, csi.DispositionDateUTC)), inv.SourceName, cc.Code, " + ||" csid.SerialNumber, csid.LotNumber, csid.SiteName, csid.Quantity, csid.ExpirationMonth, csid.ExpirationDay, csid.ExpirationYear, " + ||" csid.DispositionID," + ||" csit.IsIntact, csit.CorrectTemperatureStoredType, csit.ManufacturerInstructFollowType, " + ||" CONVERT(varchar, CONVERT(datetime, csit.PreparationStartedDateTimeUTC)), CONVERT (varchar, CONVERT(datetime, csit.PreparationEndedDateTimeUTC)), " + || " u.DisplayName, csit.Notes " // csit.DetailXML, + ||" from sxasrgcase c " + ||" left join SXASRGCaseItem ci on ci.CaseID = c.CaseID " + ||" inner join sxasrgdepartmentsurgicalitem sdi on sdi.ItemID = ci.ItemID " + ||" left join SXASRGCaseItemSupplementalInfo csi on csi.CaseItemID = ci.CaseItemID " + ||" left outer join SXASRGCaseItemSupplementalInfoDtl csid on csid.CaseItemSupplementalInfoID = csi.CaseItemSupplementalInfoID " + ||" left join SXASRGInvSource inv on inv.SourceID = csi.SourceID " + ||" left join SXASRGChargeCode cc on cc.ChargeCodeID = csi.ChargeCodeID " + ||" left outer join SXASRGCaseItemTissue csit on (csit.CaseItemSupplementalInfoDtlID = csid.CaseItemSupplementalInfoDtlID and csit.Active = 1 ) " + ||" left outer join SXASRGCaseItemTissueSurgeryStaffXRef itst on itst.CaseItemTissueID = csit.CaseItemTissueID " + ||" left outer join SXASRGSurgeryStaff sss on sss.SurgeryStaffID = itst.SurgeryStaffID " + ||" left outer join cv3user u on u.guid = sss.userguid " + ||" where c.CaseID = " || SQL(case_id) }; + // || " and csit.Active = 1 " } ;// + + + ct_item_check:= count it_item where it_intact <> "null" ; //it_user; + ct_item:= count it_item ; + //break; + + /////////////////////////////////////////////// + endif; + + /*** RTF Formatting variables ***/ + HEADER1_ON:="\f1\fs28 \b1"; + HEADER1_OFF:="\b0 \fs0"; + HEADER2_ON:="\f1\fs24 \b1"; + HEADER2_OFF:="\b0 \fs0"; + BODY_TAG:="\fs20"; + BOLD_ON:="\b1"; + BOLD_OFF:="\b0"; + ITALIC_ON:="\i"; + ITALIC_OFF:="\i0"; + TAB:="\tab"; +/// 03/23/17 - addition for formatting + SP:= 32 formatted with "%c"; + SP2:= SP||SP; //||SP||SP||SP; + SP3:= SP||SP||SP; + SP5:= SP2||SP3; + + + /*** RTF Grid Formatting variables ***/ + GRID_START:="\par"; + ROW_START := "\trowd\trgaph144"; + CELL_BORDER := "\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs"; + CELL_START := "\cellx"; + CELL_END := "\intbl\cell"; + ROW_END := "\row"; + GRID_END:="\pard"; + + called_dom_mlm := MLM {{{SINGLE-QUOTE}}}CALLED_RPM_DOM_MLM{{{SINGLE-QUOTE}}} ; + +///12/27/16 - for inital section of charting Specimen and fetching PreOp Dx + // Get the case id of the case in context + case_id := this_documentCommunication.CaseId ; +/// 12/08/17 - change for Rita J - to get into grid + IF this_eventType = "DocumentOpening" +///01/03/18 - addition for closing // this_eventType = "ChartObservation" + or this_eventType = "DocumentClosing" + + //AND + // (current_parameter_name IN specimen_param or current_parameter_name IN frozen_param) + //AND exists cur_val_text + + then + if exists case_id then + (case_number, anesthesia_type, case_status):= read last{"SELECT c.CaseIdentifier FROM SXASRGCase c " + // LEFT JOIN SXASRGAnesthesiaType at ON c.AnesthesiaTypeID = at.AnesthesiaTypeID + // INNER JOIN SXASRGCaseStatus cs ON c.CaseStatusID = cs.CaseStatusID + ||" WHERE c.CaseID = " || SQL(case_id)}; + +/// 01/19/17 - updated SQL to get only the PreOp (planned procedure) diagnosis + // with this: + // || " where ((cai.HasBeenPerformed = 1 and cai.AssociatedCaseProcedureID is not null) " + // ||" OR cai.HasBeenPerformed = 0 )and cai.Active = 1 and cai.IsPrimary = 1 " + +/* (dx_scheme_0,dx_code_0, dx_desc_0, ca_desc, ca_pre, ca_post) := read + { "select cad. codingscheme, cad.Code, cad.Description, cai.HealthIssueCodeDescription, pre.CasePreOpInfoID, post.CasePostOpInfoID " + || " from SXASRGCase ca " + || " Join SXASRGCaseProcedure cai on cai.CaseID = ca.CaseID " + || " left outer join SXASRGCaseProcedureDiagnosis cad on cad.CaseProcedureID = cai.CaseProcedureID " + ||" left outer join SXASRGCasePreOpInfo pre on pre.caseID = ca.CaseID " + ||" left outer join SXASRGCasePostOpInfo post on post.caseID = ca.CaseID " + + || " where ((cai.HasBeenPerformed = 1 and cai.AssociatedCaseProcedureID is not null) " + ||" OR cai.HasBeenPerformed = 0 )and " + || " cai.Active = 1 and cai.IsPrimary = 1 AND cad.Active = 1 " + || " AND ca.CaseIDentifier = " || SQL(case_number)}; +*/ +/// 12/15/17 - replace above with SQL for each pre/post + +// pre op diagnosis for planned procedures + (dx_scheme_0,dx_code_0, dx_desc_0, ca_desc ) := read last + { " select cpd.codingscheme, cpd.Code, cpd.Description, cp.HealthIssueCodeDescription " + ||" from SXASRGCase c " + ||" inner join SXASRGCaseProcedure cp on cp.CaseID = c.CaseID " + ||" left join SXASRGCaseProcedureDiagnosis cpd on cpd.CaseProcedureID = cp.CaseProcedureID " + ||" where (cp.HasBeenPerformed = 0 or (cp.HasBeenPerformed = 1 and cp.AssociatedCaseProcedureID is not null))" + ||" and cp.Active = 1 " + ||" and cpd.Active = 1 " + ||" and c.CaseIdentifier = " || SQL(case_number) + }; + + +// post op diagnosis for performed procedures + (dx_scheme_1,dx_code_1, dx_desc_1, ca_desc1) := read last + { "select cpd.codingscheme, cpd.Code, cpd.Description, cp.HealthIssueCodeDescription " + ||" from SXASRGCase c " + ||" inner join SXASRGCaseProcedure cp on cp.CaseID = c.CaseID " + ||" left join SXASRGCaseProcedureDiagnosis cpd on cpd.CaseProcedureID = cp.CaseProcedureID " + ||" where cp.HasBeenPerformed = 1 " + ||" and cp.AssociatedCaseProcedureID is null " + ||" and cp.Active = 1 " + ||" and cpd.Active = 1" + ||" and c.CaseIdentifier = " || SQL(case_number) + }; + + + + dx_code:= //first of + dx_code_0; + //dx_desc::= ""; //=// first of + //dx_desc_0; + ct_dxd:= count dx_desc_0; + ct_dxd1:= count dx_desc_1; +/// PRE process + if ct_dxd > 0 then + hold_cd:= ""; + for i in 1 seqto count dx_desc_0 DO + dxcs:= dx_scheme_0[i]; + dxc:= dx_code_0[i]; + dxd:= dx_desc_0[i]; + dx_comb:= dxcs||" "||dxc||" "||dxd; + if dxc in hold_cd + then + stop:=1; + elseif + /// 01/18/17 - to not value nulls int he string + dx_comb matches pattern "null%" + then + stop :=1; + else + hold_cd:= hold_cd, dxc; + if i=1 then + dx_desc:= dx_comb; //dxc||" "||dxd; + else + dx_desc:= dx_desc||";\n"|| dx_comb; //dxc||" "||dxd; + endif; + endif; + + enddo; + endif; + + /// POST process + if ct_dxd1 > 0 then + hold_cd1:= ""; + for i in 1 seqto count dx_desc_1 DO + dxcs1:= dx_scheme_1[i]; + dxc1:= dx_code_1[i]; + dxd1:= dx_desc_1[i]; + dx_comb1:= dxcs1||" "||dxc1||" "||dxd1; + if dxc1 in hold_cd1 + then + stop:=1; + elseif + /// 01/18/17 - to not value nulls int he string + dx_comb1 matches pattern "null%" + then + stop :=2; + else + hold_cd1:= hold_cd1, dxc1; + if i=1 then + dx_desc1:= dx_comb1; //dxc||" "||dxd; + else + dx_desc1:= dx_desc1||";\n"|| dx_comb1; //dxc||" "||dxd; + endif; + endif; + + enddo; + endif; + + endif; // exists caseid + + /// 01/05/17 - now here do loop + if current_parameter_name IN specimen_param then + get_chart:= specimen_param; + get_write:= spec_dx; + elseif + current_parameter_name IN frozen_param then + get_chart:= frozen_param; + get_write:= froz_dx; + endif; + FOR i in 1 seqto count get_chart DO + ch_param:= get_chart[i]; + wr_param:= get_write[i]; + if current_parameter_name = ch_param then +/// 02/21/17 - here for Order logic? + target_param:= wr_param; + //else + //target_param:= froz_dx; + endif; + ENDDO; + //break; + /// + + // break; + ENDIF; // then if cur_parameter name n... + +//////////// and of charting specimens///////////////////////// + +/// add "ELSE" to the orignal "IF" below + /// 01/17/17 - update for Reload medications + // Chart the case number and case info observation items when opening and closing the document + // ELSE +if this_eventType = "DocumentOpening" or this_eventType = "DocumentClosing" //then + OR (this_eventType = "ChartObservation" + AND + (current_parameter_name IN med_load) ) + + then + stop_it:= 0; + + +/// 02/07/17 - n0w null out Re-load observation + if this_eventType = "ChartObservation" + AND + (current_parameter_name IN med_load) + then + this_documentCommunication := call called_dom_mlm with + (this_documentCommunication, current_parameter_name, null, sugg_txt_value, update_type); + + endif; + +/// 04/13/17 Add call to Meds MLM for load + /// - here for call Med MLM to load any meds + get_med_sed:= MLM {{{SINGLE-QUOTE}}}DOC_SCH_SMP_MEDS_SURGICAL_CASE{{{SINGLE-QUOTE}}} ; + retn_val := call get_med_sed with this_documentCommunication ; + +/////////////////////////////////////////////////////////////////////// + + +//ENDIF; /// chart observation or DOc Open and chart observation + +/////////////////////////////////////////////////// +/// 01/16/17 - re-arrange for opening again - after work above with re-load +//IF this_eventType = "DocumentOpening" or this_eventType = "DocumentClosing" then + + case_number_parameter:= first of (this_parameters WHERE this_parameters.Name = case_number_parameter_name); + case_info_parameter:= first of (this_parameters WHERE this_parameters.Name = case_info_parameter_name); + + // Ensure that the case number and case info observation items are on the structured note + if exists case_number_parameter and exists case_info_parameter then + + // Get the case id of the case in context + case_id := this_documentCommunication.CaseId ; + + if exists case_id then + + ////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Get the case + ////////////////////////////////////////////////////////////////////////////////////////////////////////// + + (case_number, anesthesia_type, case_status, asa_physical_status):= read last{"SELECT top 1 c.CaseIdentifier, at.Code, cs.Code, PhysicalStatus FROM SXASRGCase c + LEFT JOIN SXASRGAnesthesiaType at ON c.AnesthesiaTypeID = at.AnesthesiaTypeID + INNER JOIN SXASRGCaseStatus cs ON c.CaseStatusID = cs.CaseStatusID + WHERE c.CaseID = " || SQL(case_id)}; + + // Add the case number observation item value + new_case_number_value := "Case Number: " || case_number; + + // Create the title and grid to contain the case info observation item value for the case status and anesthesia type + new_case_info_value := "\n" || HEADER1_ON || "Surgical Case Information:" || HEADER1_OFF || "\n" || BODY_TAG; + + new_case_info_value := new_case_info_value || GRID_START || ROW_START; + new_case_info_value := new_case_info_value || CELL_BORDER || CELL_START || 2500 || BOLD_ON || "Case Status" || BOLD_OFF || CELL_END; + new_case_info_value := new_case_info_value || CELL_BORDER || CELL_START || 4500 || case_status|| CELL_END; + new_case_info_value := new_case_info_value || ROW_END; + new_case_info_value := new_case_info_value || CELL_BORDER || CELL_START || 2500 || BOLD_ON || "Anesthesia Type" || BOLD_OFF || CELL_END; + + if anesthesia_type is null then + anesthesia_type := ""; + endif; + + new_case_info_value := new_case_info_value || CELL_BORDER || CELL_START || 4500 || anesthesia_type || CELL_END; + new_case_info_value := new_case_info_value || ROW_END; + + /// 12/08/17 - for Rita J. to fetch /display for Procedure Dxs + /* If exists dx_desc and not(dx_desc matches pattern "null%" ) + then + new_case_info_value := new_case_info_value || ROW_END; + new_case_info_value := new_case_info_value || CELL_BORDER || CELL_START || 2000 || BOLD_ON || "Pre-OP Diagnoses" || BOLD_OFF || CELL_END; + new_case_info_value := new_case_info_value || CELL_BORDER || CELL_START || 4000 || dx_desc || CELL_END; + endif; + /// 12/15/17 - now for Post Op + If exists dx_desc1 and not(dx_desc1 matches pattern "null%" ) + then + new_case_info_value := new_case_info_value || ROW_END; + new_case_info_value := new_case_info_value || CELL_BORDER || CELL_START || 2000 || BOLD_ON || "Post-OP Diagnoses" || BOLD_OFF || CELL_END; + new_case_info_value := new_case_info_value || CELL_BORDER || CELL_START || 4000 || dx_desc1 || CELL_END; + endif; + */ + //////////////////////////////////////////////////////////////////// + + //new_case_info_value := new_case_info_value || ROW_END || GRID_END; + + if(asa_physical_status is null OR asa_physical_status = "") then + asa_physical_status := ""; + endif; + //new_case_info_value := new_case_info_value || GRID_START || ROW_START; + new_case_info_value := new_case_info_value || CELL_BORDER || CELL_START || 2500 || BOLD_ON || "Physical Status(ASA)" || BOLD_OFF || CELL_END; + new_case_info_value := new_case_info_value || CELL_BORDER || CELL_START || 4500 || asa_physical_status || CELL_END; + new_case_info_value := new_case_info_value || ROW_END; + new_case_info_value := new_case_info_value || GRID_END; + + ////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Get the case planned procedures + ////////////////////////////////////////////////////////////////////////////////////////////////////////// + + planned_procedures := GRID_START || BOLD_ON || "Planned Procedures: " || "\n" || BOLD_OFF; + + (procedure_name_list, + surgery_staff_name_list, + preference_card_name_list, + procedure_description_list, + is_primary_procedure_list + ):= read {"SELECT + p.Name as ProcedureName, + u.DisplayName as SurgeryStaffFullName, + pc.Name as PreferenceCardName, + cp.Description, + cp.IsPrimary + FROM SXASRGCaseProcedure cp + LEFT JOIN SXASRGCasePreferenceCard cpc ON (cp.CaseProcedureId = cpc.CaseProcedureId AND cp.CaseId = cpc.CaseId AND ( cpc.Active IS NULL OR cpc.Active = 1 )) + LEFT JOIN SXASRGPreferenceCard pc ON cpc.PreferenceCardId = pc.PreferenceCardId + INNER JOIN SXASRGSurgeryStaff staff ON (cp.SurgeryStaffID = staff.SurgeryStaffID) + INNER JOIN CV3User u ON staff.UserGUID = u.GUID + INNER JOIN SXASRGProcedure p ON (cp.ProcedureID = p.ProcedureID) + WHERE cp.CaseID = " || SQL(case_id) || + "AND cp.Active = 1 + AND ((cp.HasBeenPerformed = 0) OR (cp.HasBeenPerformed = 1 AND cp.AssociatedCaseProcedureID > 0)) + ORDER BY cp.SequenceNumber " + }; + + ii := 0; +/// 12/15/17 + column_count := 6; + column_index := 1; + column_header_list := ("Name", "Provider", "Preference Card", "Description", "Primary", "Pre-Op Dx" ); + + // add grid header + planned_procedures := planned_procedures || ROW_START; + while (column_index <= column_count) do + column_width:= column_index * 2000; +/// 01/03/18 - to adjust for width of paper on preview + if column_index = 5 then + column_width:= 9100 ; + elseif + column_index = 6 then + column_width:= 10600 ; + endif; +////////////////////////////////////////////////////// + planned_procedures := planned_procedures || CELL_BORDER || CELL_START || column_width || BOLD_ON || column_header_list[column_index] || BOLD_OFF || CELL_END; + column_index := column_index + 1; + enddo; + + planned_procedures := planned_procedures || ROW_END; + + // add grid content + for procedure_name in procedure_name_list do + ii := ii + 1; + + surgery_staff_name := last(first ii from surgery_staff_name_list); + preference_card_name := last(first ii from preference_card_name_list); + procedure_description := last(first ii from procedure_description_list); + is_primary_procedure := last(first ii from is_primary_procedure_list); +/// 12/15/17 + If exists dx_desc and not(dx_desc matches pattern "null%" ) + then + is_pre_dx:= dx_desc; + else + is_pre_dx:= ""; + endif; +///////////////////// + if preference_card_name is null then + preference_card_name := ""; + endif; + + if procedure_description is null then + procedure_description := ""; + endif; + + column_index := 1; +/// 12/15/17 + column_content_list := (procedure_name, surgery_staff_name, preference_card_name, procedure_description, is_primary_procedure, is_pre_dx); + + planned_procedures := planned_procedures || ROW_START; + + // fill each cell + while (column_index <= column_count) do + column_width:= column_index * 2000; +/// 01/03/18 - to adjust for width of paper on preview + if column_index = 5 then + column_width:= 9100 ; + elseif + column_index = 6 then + column_width:= 10600 ; + endif; +////////////////////////////////////////////////////// + planned_procedures := planned_procedures || CELL_BORDER || CELL_START || column_width || column_content_list[column_index] || CELL_END; + column_index := column_index + 1; + enddo; + + planned_procedures := planned_procedures || ROW_END; + enddo; + + new_case_info_value := new_case_info_value || planned_procedures || GRID_END || "\n"; + + ////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Get the case performed procedures + ////////////////////////////////////////////////////////////////////////////////////////////////////////// + + performed_procedures := GRID_START || BOLD_ON || "Performed Procedures: \n" || BOLD_OFF; + + (procedure_name_list, + surgery_staff_name_list, + preference_card_name_list, + procedure_description_list, + is_primary_procedure_list + ):= read {"SELECT + p.Name as ProcedureName, + u.DisplayName as SurgeryStaffFullName, + pc.Name as PreferenceCardName, + cp.Description, + cp.IsPrimary + FROM SXASRGCaseProcedure cp + LEFT JOIN SXASRGCasePreferenceCard cpc ON (cp.CaseProcedureId = cpc.CaseProcedureId AND cp.CaseId = cpc.CaseId AND ( cpc.Active IS NULL OR cpc.Active = 1 )) + LEFT JOIN SXASRGPreferenceCard pc ON cpc.PreferenceCardId = pc.PreferenceCardId + INNER JOIN SXASRGSurgeryStaff staff ON (cp.SurgeryStaffID = staff.SurgeryStaffID) + INNER JOIN CV3User u ON staff.UserGUID = u.GUID + INNER JOIN SXASRGProcedure p ON (cp.ProcedureID = p.ProcedureID) + WHERE cp.CaseID = " || SQL(case_id) || + "AND cp.Active = 1 + AND cp.HasBeenPerformed = 1 + AND (cp.AssociatedCaseProcedureID = 0 OR cp.AssociatedCaseProcedureID IS NULL) + ORDER BY cp.SequenceNumber " + }; + + ii := 0; +/// 12/15/17 + column_count := 6; + column_index := 1; + column_header_list := ("Name", "Provider", "Preference Card", "Description", "Primary", "Post-Op Dx" ); + + // add grid header + performed_procedures := performed_procedures || ROW_START; + while (column_index <= column_count) do + column_width:= column_index * 2000; +/// 01/03/18 - to adjust for width of paper on preview + if column_index = 5 then + column_width:= 9100 ; + elseif + column_index = 6 then + column_width:= 10600 ; + endif; +////////////////////////////////////////////////////// + performed_procedures := performed_procedures || CELL_BORDER || CELL_START || column_width || BOLD_ON || column_header_list[column_index] || BOLD_OFF || CELL_END; + column_index := column_index + 1; + enddo; + performed_procedures := performed_procedures || ROW_END; + + // add grid content + for procedure_name in procedure_name_list do + ii := ii + 1; + + surgery_staff_name := last(first ii from surgery_staff_name_list); + preference_card_name := last(first ii from preference_card_name_list); + procedure_description := last(first ii from procedure_description_list); + is_primary_procedure := last(first ii from is_primary_procedure_list); +/// 12/15/17 + If exists dx_desc1 and not(dx_desc1 matches pattern "null%" ) + then + is_pre_dx1:= dx_desc1; + else + is_pre_dx1:= ""; + endif; +///////////////////// + if preference_card_name is null then + preference_card_name := ""; + endif; + + if procedure_description is null then + procedure_description := ""; + endif; + + column_index := 1; +/// 12/15/17 + column_content_list := (procedure_name, surgery_staff_name, preference_card_name, procedure_description, is_primary_procedure, is_pre_dx1); + + performed_procedures := performed_procedures || ROW_START; + + // fill each cell + while (column_index <= column_count) do + column_width:= column_index * 2000; +/// 01/03/18 - to adjust for width of paper on preview + if column_index = 5 then + column_width:= 9100 ; + elseif + column_index = 6 then + column_width:= 10600 ; + endif; +////////////////////////////////////////////////////// + performed_procedures := performed_procedures || CELL_BORDER || CELL_START || column_width || column_content_list[column_index] || CELL_END; + column_index := column_index + 1; + enddo; + + performed_procedures := performed_procedures || ROW_END; + enddo; + + new_case_info_value := new_case_info_value || performed_procedures || GRID_END || "\n"; + + ////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Get the case participants + ////////////////////////////////////////////////////////////////////////////////////////////////////////// + + participants := GRID_START || BOLD_ON || "Participants: \n" || BOLD_OFF; + + (participant_id_list, + external_participant_name_list, + role_list, + comments_list, + surgery_staff_name_list + ):= read { + "SELECT + cp.CaseParticipantID, + cp.ExternalParticipantName, + role.Code, + cp.Comments, + u.DisplayName AS SurgeryStaffFullName + FROM SXASRGCaseParticipant cp + LEFT JOIN SXASRGSurgeryRole role ON cp.SurgeryRoleID = role.SurgeryRoleID + LEFT JOIN SXASRGSurgeryStaff staff ON (cp.SurgeryStaffID = staff.SurgeryStaffID) + LEFT JOIN CV3User u ON staff.UserGUID = u.GUID + WHERE cp.CaseID = " || SQL(case_id) || + "AND cp.Active = 1 + ORDER BY cp.SortSequenceNum " + }; + + (participant_time_id_list, + participant_time_participant_id_list, + time_in_list, + time_out_list + ):= read { + "SELECT + cpt.CaseParticipantTimeID, + cpt.CaseParticipantID, + CONVERT(varchar, CONVERT(datetime, cpt.InDateTimeUTC)), + CONVERT(varchar, CONVERT(datetime, cpt.OutDateTimeUTC)) + FROM SXASRGCaseParticipantTime cpt + INNER JOIN SXASRGCaseParticipant cp ON (cpt.CaseParticipantID = cp.CaseParticipantID) + WHERE cp.CaseID = " || SQL(case_id) || + "AND cp.Active = 1 + AND cpt.Active = 1 + ORDER BY cpt.CaseParticipantID, cpt.InDateTimeUTC " + }; + tstcaseid := case_id; + + ii := 0; + column_count := 5; + column_index := 1; + column_header_list := ("Role", "Name", "Comments", "Time In", "Time Out"); + + // add grid header + participants := participants || ROW_START; + while (column_index <= column_count) do + column_width:= column_index * 2000; + participants := participants || CELL_BORDER || CELL_START || column_width || BOLD_ON || column_header_list[column_index] || BOLD_OFF || CELL_END; + column_index := column_index + 1; + enddo; + participants := participants || ROW_END; + + for participant_id in participant_id_list do + ii := ii + 1; + + external_participant_name := last(first ii from external_participant_name_list); + role := last(first ii from role_list); + comments := last(first ii from comments_list); + surgery_staff_name := last(first ii from surgery_staff_name_list); + +/// 08/1/16 - use external_participant_name if no Staff CV3User configuration + if not exists surgery_staff_name AND (exists external_participant_name) then //and external_participant_name <> "") then + + surgery_staff_name := trim (string external_participant_name) ; +/// 01/23/18 - update to put Level infront of the number + if role = "Level" then + surgery_staff_name := string ("Level "||surgery_staff_name); + endif; +/// 04/19/18 - update to put ASA infront of the number for the ASA into the Grid + if role = "ASA" then + surgery_staff_name := trim (string ("ASA: "||surgery_staff_name)) ; + endif; + endif; + +//////////////////////////////////////// + + if external_participant_name is null then + external_participant_name := ""; + endif; + + if role is null then + role := ""; + endif; + + if comments is null then + comments := ""; + endif; + + if surgery_staff_name is null then + surgery_staff_name := ""; + endif; + + if not exists surgery_staff_name then + surgery_staff_name := trim (string external_participant_name) ; + endif; + + + column_index := 1; + column_content_list := (role, surgery_staff_name, comments ); + + participants := participants || ROW_START; + + // fill each cell + column_count := 3; + while (column_index <= column_count) do + column_width:= column_index * 2000; + participants := participants || CELL_BORDER || CELL_START || column_width || column_content_list[column_index] || CELL_END; + column_index := column_index + 1; + enddo; + + // add time for participant, same participant could have multiple times + jj := 0; + is_same_participant := false; + for participant_time_id in participant_time_id_list do + jj := jj + 1; + + participant_time_participant_id := last(first jj from participant_time_participant_id_list); + if(participant_time_participant_id = participant_id) then + time_in := last(first jj from time_in_list); + time_out := last(first jj from time_out_list); + + if time_in is null then + time_in := "."; + endif; + + if time_out is null then + time_out := "."; + endif; + + column_content_time_list := (" " || time_in, " " || time_out); + + // add new row with empty cells for role, staff and comments if the time is for the same participant + if is_same_participant = true then + column_count := 3; + column_index := 1; + participants := participants || ROW_END || ROW_START; + while (column_index <= column_count) do + column_width:= column_index * 2000; + participants := participants || CELL_BORDER || CELL_START || column_width || " " || CELL_END; + column_index := column_index + 1; + enddo; + endif; + + // fill the time in and time out cells + column_count := 5; + while (column_index <= column_count) do + column_width:= column_index * 2000; + participants := participants || CELL_BORDER || CELL_START || column_width || column_content_time_list[column_index - 3] || CELL_END; + column_index := column_index + 1; + enddo; + + is_same_participant := true; + else + is_same_participant := false; + endif; + + enddo; + + participants := participants || ROW_END; + enddo; + + new_case_info_value := new_case_info_value || participants || GRID_END || "\n"; + + ////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Get the case event times + ////////////////////////////////////////////////////////////////////////////////////////////////////////// + + case_events := GRID_START || BOLD_ON || "Times: \n" || BOLD_OFF; + + (event_id_list, + event_date_time_list, + event_time_label_list + ):= read { + "SELECT + e.CaseEventID, + CONVERT(varchar, CONVERT(datetime, et.EventDateTimeUTC)), + et.EventTimeLabel + FROM SXASRGCaseEvent e + INNER JOIN SXASRGCaseEventTime et ON e.CaseEventID = et.CaseEventID + WHERE e.CaseID = " || SQL(case_id) || + "AND e.Active = 1 + ORDER BY et.SortSequenceNum " + }; + + ii := 0; + column_count := 2; + column_index := 1; + column_header_list := ("Type", "Time"); + + // add grid header + case_events := case_events || ROW_START; + while (column_index <= column_count) do + column_width:= column_index * 3500; + case_events := case_events || CELL_BORDER || CELL_START || column_width || BOLD_ON || column_header_list[column_index] || BOLD_OFF || CELL_END; + column_index := column_index + 1; + enddo; + case_events := case_events || ROW_END; + + // add grid content + for event_id in event_id_list do + ii := ii + 1; + + event_date_time := last(first ii from event_date_time_list); + event_time_label := last(first ii from event_time_label_list); + + if event_date_time is null then + event_date_time := ""; + endif; + + column_index := 1; + column_content_list := (event_time_label, " " || event_date_time); + + case_events := case_events || ROW_START; + + // fill each cell + while (column_index <= column_count) do + column_width:= column_index * 3500; + case_events := case_events || CELL_BORDER || CELL_START || column_width || column_content_list[column_index] || CELL_END; + column_index := column_index + 1; + enddo; + + case_events := case_events || ROW_END; + enddo; + + new_case_info_value := new_case_info_value || case_events || GRID_END || "\n"; + +/// 07/13/16 - for insertion of Implant Tissue section into the new_case_info_value //////////////////////// + + + standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + IT_Header:= ""; + rtn_str:= ""; + hold_it:= ""; +/// 02/23/18 - update to pull only Active case Items ci.Active = 1 + (it_ItemID, it_Item, it_catno, it_desc, it_supNotes, it_itemname, it_Dispodtm, it_Manu, it_Charge, + it_serial, it_lot, it_site, it_siteg, it_quant, it_ExpMM, it_expDD, it_expYYYY, + it_DispoID, it_DtlID, ti_DtlID, + it_Intact, it_Stored, it_Follow, it_PrepStart , it_PrepStop, it_user, it_tnotes ):= read // it_xml, + {" select sdi.ItemID, sdi.ItemName,csi.CatalogNumber, csi.ItemMasterDescription, csi.Notes, csi.ItemName, " + || " CONVERT(varchar, CONVERT(datetime, csi.DispositionDateUTC)), inv.SourceName, cc.Code, " + ||" csid.SerialNumber, csid.LotNumber, csid.SiteName, csid.SiteGUID, csid.Quantity, csid.ExpirationMonth, csid.ExpirationDay, csid.ExpirationYear, " + ||" csid.DispositionID, csid.CaseItemSupplementalInfoDtlID, csit.CaseItemSupplementalInfoDtlID, " + ||" csit.IsIntact, csit.CorrectTemperatureStoredType, csit.ManufacturerInstructFollowType, " + ||" CONVERT(varchar, CONVERT(datetime, csit.PreparationStartedDateTimeUTC)), CONVERT(varchar, CONVERT(datetime, csit.PreparationEndedDateTimeUTC)), " + || " u.DisplayName, csit.Notes " // csit.DetailXML, + ||" from sxasrgcase c " + ||" left join SXASRGCaseItem ci on ci.CaseID = c.CaseID " + ||" inner join sxasrgdepartmentsurgicalitem sdi on sdi.ItemID = ci.ItemID " + ||" left join SXASRGCaseItemSupplementalInfo csi on csi.CaseItemID = ci.CaseItemID " + ||" left outer join SXASRGCaseItemSupplementalInfoDtl csid on csid.CaseItemSupplementalInfoID = csi.CaseItemSupplementalInfoID " + ||" left join SXASRGInvSource inv on inv.SourceID = csi.SourceID " + ||" left join SXASRGChargeCode cc on cc.ChargeCodeID = csi.ChargeCodeID " + ||" left outer join SXASRGCaseItemTissue csit on (csit.CaseItemSupplementalInfoDtlID = csid.CaseItemSupplementalInfoDtlID and csit.Active = 1 ) " + ||" left outer join SXASRGCaseItemTissueSurgeryStaffXRef itst on itst.CaseItemTissueID = csit.CaseItemTissueID " + ||" left outer join SXASRGSurgeryStaff sss on sss.SurgeryStaffID = itst.SurgeryStaffID " + ||" left outer join cv3user u on u.guid = sss.userguid " + ||" where c.CaseID = " || SQL(case_id) + || " and ci.Active = 1 " } ;// + // ||" and c.ClientVisitGUID = {{{SINGLE-QUOTE}}}1052700270{{{SINGLE-QUOTE}}} " + // ||" where c.CaseID = 356 " + + ct_item_check:= count it_item where it_dispoID is not null ; //<> "null" ; //it_user; + ct_item:= count it_item ; + + if ct_item > 0 then //exists it_user then + IT_Header := " Implant-Tissue: " ; + IT_Head:= HEADER2_ON||IT_Header||HEADER2_OFF||"\n"||Body_tag; //:="\b0 \fs0"; + //rtn_str:= IT_Head; + + not_in:= "<","/",">" ; + + FOR i in 1 seqto ct_item DO + +/// format certain data + /* if it_dispoID[i] = 1 then it_dispoID[i] := "Explanted"; endif; + if it_dispoID[i] = 2 then it_dispoID[i] := "Implanted"; endif; + if it_dispoID[i] = 3 then it_dispoID[i] := "Implanted and Removed"; endif; + if it_dispoID[i] = 6 then it_dispoID[i] := "Wasted"; endif; + + + if it_intact[i] then it_intact[i] := "Intact"; elseif not( it_intact[i]) then it_intact[i] := "Not Intact"; endif; + if it_stored[i] = 1 then it_stored[i] := "Yes"; elseif it_stored[i] = 2 then it_stored[i] := "No"; else it_stored[i] := "N/A"; endif; + if it_follow[i] = 1 then it_follow[i] := "Yes"; elseif it_follow[i] = 2 then it_follow[i] := "No"; else it_follow[i] := "N/A"; endif; + */ +/// 12/02/16 - change the display of notes_comments + /* if exists it_tnotes[i] then + note_comment := it_tnotes[i]; + else + note_comment := ""; + endif; + */ + //:= tab||"\b1 Notes/Comments: \b0 "||it_tnotes[i]||"\n" ; else note_comment:= "\n"; endif; + + crtab:= "\n"||tab||tab||" "; +/// 02/02/18 - addition for displaying the edited Name from the Supplemental FORm + IF it_item[i] matches pattern "Generic%" + then + if exists it_itemname[i] then + it_item[i] := it_itemname[i] ; + endif; + + ENDIF; + + + +/////////////////////////////////////////////////////////////////// + + if exists it_xml[i] then + it_xml[i] := string (it_xml[i]); + it_xml0:= call (it_xml[i] as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "", "" as string; + it_xml1:= call (it_xml0 as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "", " = " as string; + it_xml3:= call (it_xml2 as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "", crtab as string; //"\n" + it_xml4:= call (it_xml3 as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "", "\n" as string; + + endif; +if it_dispoId[i] is not null then // <> "null" then // it_dispoId + if not (it_itemID[i] in hold_it) then +/// 03/07/17 - for it_serial, it_lot, it_site, it_quant, it_ExpMM, it_expDD, it_expYYYY, it_DispoID, + get_ser_0:= it_serial where it_itemID = it_itemID[i]; + get_lot_0:= it_lot where it_itemID = it_itemID[i]; + get_site_0:= it_site where it_itemID = it_itemID[i]; + get_siteg_0:= it_siteg where it_itemID = it_itemID[i]; + get_quant_0:= it_quant where it_itemID = it_itemID[i]; + get_dispo_0:= it_DispoID where it_itemID = it_itemID[i]; + get_expMM_0:= it_ExpMM where it_itemID = it_itemID[i]; + get_expDD_0:= it_ExpDD where it_itemID = it_itemID[i]; + get_expYYYY_0:= it_ExpYYYY where it_itemID = it_itemID[i]; + get_it_dtl:= it_DtlID where it_itemID = it_itemID[i]; + get_ti_dtl:= ti_DtlID where it_itemID = it_itemID[i]; + +/// supp details + get_user0:= it_user where it_itemID = it_itemID[i]; + get_PrepStart0:= it_PrepStart where it_itemID = it_itemID[i]; + get_PrepStop0:= it_PrepStop where it_itemID = it_itemID[i]; + get_Intact0:= it_Intact where it_itemID = it_itemID[i]; + get_stored0:= it_stored where it_itemID = it_itemID[i]; + get_follow0:= it_follow where it_itemID = it_itemID[i]; + get_notes0:= it_tnotes where it_itemID = it_itemID[i]; + +//// 03/08/17 for tissue details + +////////////////////////// +/// 04/23/18 - for duplicates + hld_det:= ""; + hld_dtl:= ""; //""; + for m in 1 seqto count get_lot_0 DO + //////////////////////////////////////////// +/// 01/22/18 - updated for SCH config +/// 04/23/18 - change back to Explanted second - Implanted first and others in order for Dispo of Implant +// update to read from SXASRGDispistion + if exists get_dispo_0[m] then + s_dispo:= get_dispo_0[m]; + get_dispo_m:= read last { " select Code from SXASRGDisposition where Active = 1 and DispositionID = " || sql (s_dispo) }; + /* if get_dispo_0[m] = 1 then get_dispo_0[m] := "Implanted"; endif; + // "Explanted"; endif; + if get_dispo_0[m] = 9 then get_dispo_0[m] := "Explanted"; endif; + // "Implanted"; endif; + if get_dispo_0[m] = 6 then get_dispo_0[m] := "Implanted and Removed"; endif; + if get_dispo_0[m] = 8 then get_dispo_0[m] := "Wasted"; endif; + */ + else + get_dispo_m := ""; + endif; + ///////////////////////////////////////// +/// 03/13/17 - for site from Dictionary if not free text + IF get_site_0[m] is null and exists get_siteg_0[m] + then + get_dict_g:= get_siteg_0[m] ; + get_val:= read last { " select value from CV3UserDictionaryValue uv " + ||" where uv.guid = " || sql (get_dict_g) }; + if exists get_val then + get_site_0d := get_val; + endif; + else + get_site_0d:= get_site_0[m]; + ENDIF; +///////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////// +/// 04/23/18- fix dupl details + if get_ser_0[m] not in hold_det +/// 09/06/17 - to pick up "null " serial numbers + OR (get_ser_0[m] is null OR get_ser_0[m] = "null") +then + if hld_dtl = "" then + hld_dtl:= "\b1 Serial #: \b0 "||get_ser_0[m]||" "||"\b1 Lot #: \b0 "||get_lot_0[m]||" "||"\b1 Qty: \b0 "||get_quant_0[m] + // ||" "||"\b1 Site: \b0 "||get_site_0d ||" "||"\b1 Dispo: \b0 "||get_dispo_0[m]||" "|| + ||" "||"\b1 Site: \b0 "||get_site_0d ||"\n"||tab||"\b1 Disposition: \b0 "||get_dispo_m||" "|| + "\b1 Expiry Dt: \b0 "||get_expMM_0[m]||"/"||get_expDD_0[m]||"/"||get_expyyyy_0[m]||"\n"; //||tab ; + else + hld_dtl:= hld_dtl||"\b1 Serial #: \b0 "||get_ser_0[m]||" "||"\b1 Lot #: \b0 "||get_lot_0[m]||" "||"\b1 Qty: \b0 "||get_quant_0[m] + // ||" "||"\b1 Site: \b0 "||get_site_0d ||" "||"\b1 Dispo: \b0 "||get_dispo_0[m]||" "|| + ||" "||"\b1 Site: \b0 "||get_site_0d ||"\n"||tab||"\b1 Disposition: \b0 "||get_dispo_m||" "|| + "\b1 Expiry Dt: \b0 "||get_expMM_0[m]||"/"||get_expDD_0[m]||"/"||get_expyyyy_0[m]||"\n"; //||tab ; + endif; + hold_det:= hold_det, get_ser_0[m] ; + ENDIF; + /* original SCH pre 04/23/18 + hld_dtl:= hld_dtl||"\b1 Serial #: \b0 "||get_ser_0[m]||" "||"\b1 Lot #: \b0 "||get_lot_0[m]||" "||"\b1 Qty: \b0 "||get_quant_0[m] + // ||" "||"\b1 Site: \b0 "||get_site_0d ||" "||"\b1 Dispo: \b0 "||get_dispo_0[m]||" "|| + ||" "||"\b1 Site: \b0 "||get_site_0d ||"\n"||tab||"\b1 Disposition: \b0 "|| get_dispo_0[m]||" "|| + "\b1 Expiry Dt: \b0 "||get_expMM_0[m]||"/"||get_expDD_0[m]||"/"||get_expyyyy_0[m]||"\n"; //||tab ; + */ +////////////////////////////////// +/// for tissue details for each supp details + get_user:= null; + get_PrepStart:= null; + get_PrepStop:= null; + get_Intact:= null; + get_stored:= null; + get_follow:= null; + get_notes:= null; + + get_sup_d:= null; + if get_ti_dtl[m] = get_it_dtl[m] then + get_Intact:=get_Intact0[m]; // first of (get_Intact0 where get_ti_dtl[m] = get_it_dtl[m] ); // it_itemID = it_itemID[i] AND + if get_Intact then get_Intact := "Intact"; elseif not( get_Intact ) then get_Intact := "Not Intact"; endif; + get_Stored:= get_Stored0[m]; //first of (get_Stored0 where get_ti_dtl[m] = get_it_dtl[m] ); + if get_Stored = 1 then get_Stored := "Yes"; elseif get_Stored = 2 then get_Stored := "No"; else get_Stored := "N/A"; endif; + get_follow:= get_follow0[m];//first of (get_follow0 where get_ti_dtl[m] = get_it_dtl[m] ); + if get_follow = 1 then get_follow := "Yes"; elseif get_follow = 2 then get_follow := "No"; else get_follow := "N/A"; endif; + + get_PrepStart := get_PrepStart0[m]; //first of (get_PrepStart0 where get_ti_dtl[m] = get_it_dtl [m] ); + get_PrepStop := get_PrepStop0[m];//first of (get_PrepStop0 where get_ti_dtl[m] = get_it_dtl[m] ); + // it_user + get_user := get_user0[m]; //first of (get_user0 where get_ti_dtl[m] = get_it_dtl[m] ); + get_notes := get_notes0[m];// first of (get_notes0 where get_ti_dtl[m] = get_it_dtl[m] ); + if exists get_user or exists get_PrepStart or exists get_Intact // or get_stored or exists get_follow + then + /// tab||" + get_sup_d:= tab||" \b1 State of package: \b0 "||get_Intact ||"\n"||tab||"\b1 Stored at Temp: \b0 "||get_Stored ||"\n" + ||tab||"\b1 Manufacturer Instructions followed: \b0 "||get_follow ||"\n" + //||tab||"\b1 Tissue Reconstitution/Note: \b0 "||"\n"||tab||tab||" "||it_xml4[i]||"\n"||note_comment //||"\n" + ||tab||"\b1 Tissue Reconstitution/Note: \b0 "||"\n"||tab||tab||" "||get_notes ||"\n" + ||tab||"\b1 Prepared By: \b0 "||get_user ||"\n" + ||tab||"\b1 Prep Start: \b0 "||get_PrepStart ||" "||"\b1 Prep Stop: \b0 "||get_PrepStop ||"\n\n"; + else + get_sup_d := "\n"; //||tab||"\n"; + endif; + else + get_sup_d := "\n"; //||tab||"\n"; + endif; +/////////////////////////////// + if exists get_sup_d then + hld_dtl:= hld_dtl||get_sup_d; + endif; + enddo; +/////////////////////////////////////////////////////////////////////// + //get_item:= "\b1 Item: \b0 "||it_item[i]||tab||"\b1 Catalog #: \b0 "||it_catno[i]||" "||"\b1 Charge Code: \b0 "||it_charge[i]||"\n\n"; + get_item:= "\b1 Item: \b0 "||it_item[i]||tab||"\b1 Cat #: \b0 "||it_catno[i]||" "||"\b1 Chrg Code: \b0 "||it_charge[i]||"\n\n"; + + get_sup:= tab||"\b1 Item ID: \b0 "||it_itemID[i]||tab||tab||"\b1 Description: \b0 "||it_desc [i]||"\n" + ||tab||"\b1 Notes: \b0 "||it_supNotes[i]||"\n" + ||tab||"\b1 Manufacturer: \b0 "||it_manu[i]||"\n" + ||tab||"\b1 Disposition Dt: \b0 "||it_dispodtm[i]||"\n\n"//tab||tab||"\b1 Expiration: \b0 "||it_expMM[i]||"/"||it_expDD[i]||"/"||it_expyyyy[i]||"\n" + || hld_dtl||"\n\n" ; +/// 03/07/17 - Update for building multi details on Supplemental Item details + + hold_it:= hold_it, it_itemID[i]; + + rtn_str:= rtn_str||get_item||get_sup ; //||get_sup_d ; + endif;/// not item in hold_it +endif; // if It_dispoID + ENDDO; + + if rtn_str <> "" then + rtn_str:= IT_Head||rtn_str; + endif; + /// for testing + user_guid:= this_documentCommunication.UserGuid; + userid:= read last {" select IDCode from cv3user where guid = "|| sql (user_guid) }; + if userid matches pattern "service%" + then + ray:=1; + //break; + endif; + + //////////////// + + new_case_info_value := new_case_info_value || rtn_str; //IT_Head; + Endif; /// exists it user + +/// /// 03/17/17 - for insertion of Chargeable Item section into the new_case_info_value //////////////////////// +/// 07/12/17 - Place for Items - removed out per meeting + + +//////////////////////////////// end of items ////////////////////////////////////////////////////// + /// for testing + user_guid:= this_documentCommunication.UserGuid; + userid:= read last {" select IDCode from cv3user where guid = "|| sql (user_guid) }; + if userid matches pattern "service%" + then + ray:=1; + endif; + + //////////////// +////////////////////////////////////////////////////////////////////////////////////// + + // Set the Document Topic with the Case Number so that the Case Number appears beside the Document Name on the structured note + this_structuredNoteDoc.DocumentTopic := case_number; + + // Chart the free text observation items for case number and case info on the structured note + this_documentCommunication := call called_dom_mlm with (this_documentCommunication, case_number_parameter_name, new_case_number_value, sugg_txt_value, update_type); + this_documentCommunication := call called_dom_mlm with (this_documentCommunication, case_info_parameter_name, new_case_info_value, sugg_txt_value, update_type); + + endif; //exists case_id then + endif; // exists target_parameter + endif; // this_eventType = "DocumentOpening" + +/// for testing + user_guid:= this_documentCommunication.UserGuid; + userid:= read last {" select IDCode from cv3user where guid = "|| sql (user_guid) }; + if userid matches pattern "rlatimer%" + then + ray:=1; + break; + endif; + + //////////////// + + Debug := is_display_message; // Set Debug := TRUE to see Message in document + document_communication_message := "Parameter Name " || case_number_parameter_name || " Event " || this_eventType || " Case Number " || case_number; + this_documentCommunication.DisplayMessage := is_display_message; + this_documentCommunication.Message := document_communication_message ; + + + /* + if(this_eventType = "DocumentClosing" and this_DocumentName = "Endo Intraoperative Nursing") + then + DOC_CALL_SPECIMEN_PATHOLOGY := MLM {{{SINGLE-QUOTE}}}DOC_CALL_SPECIMEN_PATHOLOGY{{{SINGLE-QUOTE}}}; + (this_documentCommunication) := CALL DOC_CALL_SPECIMEN_PATHOLOGY with this_documentCommunication; + break; + endif; + break; + */ + ;; + + evoke: + ;; + + logic: + conclude true; + ;; + + action: + return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_SRG_GET_PARTICIPANT_SELECT.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_SRG_GET_PARTICIPANT_SELECT.mlm new file mode 100644 index 0000000..512b419 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_SRG_GET_PARTICIPANT_SELECT.mlm @@ -0,0 +1,478 @@ +maintenance: + + title: Document Surgical Participants;; + mlmname: DOC_SCH_SRG_GET_PARTICIPANT_SELECT;; + arden: version 2.5;; + version: 16.3 ;; + institution: St Claire ;; + author: Allscripts;; + specialist: Gail G. ;; + date: 2017-05-05;; + validation: testing;; + + +library: + purpose: Demonstrates the ability to pull surgical participants into the structured note when observation is selected + ;; + explanation: Demonstrates the ability to pull surgical case info. + +//// Change History ///////////////////////////////////////////// + + + 10/14/16 - Allscripts - updated fetch and display for insertion of Implant Tissue section + into the new_case_info_value for writing to case_info_parameter_name + + 02/21/17 - update observations to init dialoge for observation tofill with participant. + + 05/05/17 - Initial deploy into St Claire DEV + 05/05/17 - update for rest of Meds Obs by whom + 05/10/17 - update for all 20 Admin By whom observations + 04/11/18 - null out the launch observation for another selection + 04/16/18 - adjust the nulling for best results of writing to the Observation + + ***08/01/16 - Allscripts - try fix for Participants to use external_participant_name if no Staff/CV3User configuration +/////////////////////////////////////////////////////////////////////////////// + + To use this mlm the following needs to be done: + 1) Create two Observation Items. + For example, name them "Surgical Case Number" and "Surgical Case Info". + + Name - "Surgical Case Number" + Data Definition - Data Type: Free text; Maximum Input Length: 500; Maximum Number of Lines: 1; + Field Height: 1; Field Width: 200; (or it could be anything you want)1 + Enable Formatting Text: Unchecked + Row Label Definition - Left Justified: Surgical Case Number; Modify Parameter/Filter: Surgical Case Number; + Security - No Editing: true; Add some rights + + Name - "Surgical Case Info" + Data Definition - Data Type: Free text; Maximum Input Length: 50000; Maximum Number of Lines: 9999; + Field Height: 100; Field Width: 100; (or it could be anything you want) + Enable Formatting Text: Checked + Row Label Definition - Left Justified: Surgical Case Info; Modify Parameter/Filter: Surgical Case Info; + Security - No Editing: true; Add some rights + + 2) Create one Observation Set. + For example, name it "Surgical Case Details Set". + + Set Type: Unbordered + Add Set Items and add the two Observation Items from above. + + 3) Create one Observation Group. + For example, name it "Surgical Case Details Group". + + Add Items and add the Unbordered Observation Set, "Surgical Case Details Set". + Positioning - Set the row numbers and column numbers. + + 4) Create a Structured Note. + For example, name it "Surgical Case Structured Note". + + Add Attributes: Select the Observation Group: "Surgical Case Details Group". + Click on the Surgical Case Number and in Called MLM, select + Click on the Surgical Case Info and in Called MLM, select + + 5) Create a Document. + For example, name it "Surgical Case Document". + + Opening MLM and Closing MLM: DOC_SMP_SURGICAL_CASE + Data Collection: Structured Note + Search and select "Surgical Case Structured Note". + Security - Add some rights + + 6) Set the variables, case_number_parameter_name and case_info_parameter, on this MLM with the Observation Items names created on Step 1 above. + + For example, + + case_number_parameter_name := "Surgical Case Number"; + case_info_parameter_name := "Surgical Case Info"; + + 7) Set the variable, is_display_message, on this MLM if a message should display when opening the document. + + For example, + + is_display_message := true; + + 8) Ensure that the user has the right "Can Add Document Topic to SN". + + 9) Set the Environment Profile - Documents > Structured Notes > DocumentTopic to TRUE. When viewing the document, the Document Topic will + contain the Case Number. Also, the document name will be appended with the Case Number. + + 10) From Gateway, select a Surgical Case. From the Document Entry Worksheet, enter "Surgical Case Document". The document + should display with the case number and case details of the case in context. User can edit the Surgical Case from the Case Details tab/window. + On saving the document, the latest case details will be saved on the document. + + ;; + keywords: RTF, Document Called MLM , Surgical Case + ;; +knowledge: + type: data-driven;; + data: + (this_documentCommunication) := argument; + + /*******************Make Changes To Spelling And Flags In This Section******************/ + + +// References the LOCAL SESSION object +/// 01/12/17 - for Medication section + local_session := cds_session.local; + + + standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + /* Set to true if a decision.log is needed.*/ + log_execution_info := false; + + /* Set to parameter name of the free text observation item representing the case number. */ + case_number_parameter_name := "Surgical Case Number"; //"OR Surgical Case Number FT"; + + /* Set to parameter name of the free text observation item representing the case info. */ + case_info_parameter_name := "Surgical Case Info"; // FT"; //"OR Surgical Case Info FT"; + + /* Set to true if displaying a message when opening the document. */ + is_display_message := false; + +/// SCH observations //////////////////////////////////// + + select_param:= "SRG SCH Med _ By"; //, "CINV OR Drain Securement 2", "CINV OR Drain Securement 3", "CINV OR Drain Securement 4", + + + + spec_ft:= "SRG SCH Med by _ FT" ; //, "CINV OR Drain Secured by whom 2 FT" , "CINV OR Drain Secured by whom 3 FT", + +///get all of the observations: + +select_by := ""; +by_whom:= ""; + + FOR i in 1 seqto 20 DO + wr_param := call (select_param as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "_", i as string ; + wr_ft := call (spec_ft as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "_", i as string ; + if i = 1 then + select_by:= wr_param; + by_whom:= wr_ft; + else + select_by:= select_by, wr_param; + by_whom:= by_whom, wr_ft; + endif; + + ENDDO; + + // 02/07/17 - med reload observation + + med_load:= "Reload surg details" ; +//////////////////////////////////////////////////////// + + /***************************************************************************************/ + + /*** Variable and Constant Declaration ***/ + + (this_structuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (this_parameters) := this_structuredNoteDoc.ParametersList; + (this_chartedObservationsList) := this_structuredNoteDoc.ChartedObservationsList; + (this_eventType) :=this_documentCommunication.EventType; + (this_currentObj) := this_documentCommunication.CurrentObservationObj; + + current_parameter := FIRST OF (this_Parameters + WHERE this_parameters.ParameterGUID = this_CurrentObj.ParameterGUID); + current_parameter_name := current_parameter.name ; + cur_obs:= FIRST OF (this_parameters WHERE this_parameters.name = current_parameter_name) ; + cur_obj:= FIRST OF (this_Parameters + WHERE this_parameters.ParameterGUID = cur_obs.ParameterGUID); + cur_val_obj := cur_obj.valueobj; + cur_val_text := this_currentObj.ValueObj.Value; //cur_val_obj.value; + get_vals:= this_currentObj.ValueObj.Records__ ; + get_val_list:= get_vals.ListItemsList.IsSelected; //Value; //Records__; //this_currentObj.ValueObj.ListValue ; + ct_lst:= count get_val_list; + + + +//break; + if called_by_editor then + client_guid := read last {ClientInfo: GUID}; + client_visit_guid := read last {ClientVisit: GUID}; + chart_guid := read last{ClientVisit: ChartGUID}; + ///testin /// CONVERT(varchar, CONVERT(datetime, cpt.InDateTimeUTC)), + case_id:= 569; //492; // 569; //356; + (it_ItemID, it_Item, it_catno, it_desc, it_supNotes, it_Dispodtm, it_Manu, it_Charge, + it_serial, it_lot, it_site, it_quant, it_ExpMM, it_expDD, it_expYYYY, + it_DispoID, + it_Intact, it_Stored, it_Follow, it_PrepStart , it_PrepStop, it_user, it_tnotes ):= read // it_xml, + {" select sdi.ItemID, sdi.ItemName,csi.CatalogNumber, csi.ItemMasterDescription, csi.Notes, " + || " CONVERT(varchar, CONVERT(datetime, csi.DispositionDateUTC)), inv.SourceName, cc.Code, " + ||" csid.SerialNumber, csid.LotNumber, csid.SiteName, csid.Quantity, csid.ExpirationMonth, csid.ExpirationDay, csid.ExpirationYear, " + ||" csid.DispositionID," + ||" csit.IsIntact, csit.CorrectTemperatureStoredType, csit.ManufacturerInstructFollowType, " + ||" CONVERT(varchar, CONVERT(datetime, csit.PreparationStartedDateTimeUTC)), CONVERT (varchar, CONVERT(datetime, csit.PreparationEndedDateTimeUTC)), " + || " u.DisplayName, csit.Notes " // csit.DetailXML, + ||" from sxasrgcase c " + ||" left join SXASRGCaseItem ci on ci.CaseID = c.CaseID " + ||" inner join sxasrgdepartmentsurgicalitem sdi on sdi.ItemID = ci.ItemID " + ||" left join SXASRGCaseItemSupplementalInfo csi on csi.CaseItemID = ci.CaseItemID " + ||" left outer join SXASRGCaseItemSupplementalInfoDtl csid on csid.CaseItemSupplementalInfoID = csi.CaseItemSupplementalInfoID " + ||" left join SXASRGInvSource inv on inv.SourceID = csi.SourceID " + ||" left join SXASRGChargeCode cc on cc.ChargeCodeID = csi.ChargeCodeID " + ||" left outer join SXASRGCaseItemTissue csit on (csit.CaseItemSupplementalInfoDtlID = csid.CaseItemSupplementalInfoDtlID and csit.Active = 1 ) " + ||" left outer join SXASRGCaseItemTissueSurgeryStaffXRef itst on itst.CaseItemTissueID = csit.CaseItemTissueID " + ||" left outer join SXASRGSurgeryStaff sss on sss.SurgeryStaffID = itst.SurgeryStaffID " + ||" left outer join cv3user u on u.guid = sss.userguid " + ||" where c.CaseID = " || SQL(case_id) }; + // || " and csit.Active = 1 " } ;// + + + ct_item_check:= count it_item where it_intact <> "null" ; //it_user; + ct_item:= count it_item ; + //break; + + /////////////////////////////////////////////// + endif; + + /*** RTF Formatting variables ***/ + HEADER1_ON:="\f1\fs28 \b1"; + HEADER1_OFF:="\b0 \fs0"; + HEADER2_ON:="\f1\fs24 \b1"; + HEADER2_OFF:="\b0 \fs0"; + BODY_TAG:="\fs20"; + BOLD_ON:="\b1"; + BOLD_OFF:="\b0"; + ITALIC_ON:="\i"; + ITALIC_OFF:="\i0"; + TAB:="\tab"; + + /*** RTF Grid Formatting variables ***/ + GRID_START:="\par"; + ROW_START := "\trowd\trgaph144"; + CELL_BORDER := "\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs"; + CELL_START := "\cellx"; + CELL_END := "\intbl\cell"; + ROW_END := "\row"; + GRID_END:="\pard"; + + standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + called_dom_mlm := MLM {{{SINGLE-QUOTE}}}CALLED_RPM_DOM_MLM{{{SINGLE-QUOTE}}} ; + func_UDDD := MLM {{{SINGLE-QUOTE}}}UTIL_LAUNCH_LISTBOX_DYNAMIC_UDD_Sch{{{SINGLE-QUOTE}}}; + +//wkst_string := call {{{SINGLE-QUOTE}}}SCMLib.HVCLogon.HVCLogonObj{{{SINGLE-QUOTE}}}.GetWorkstationGUID; +//wkst_name := call {{{SINGLE-QUOTE}}}SCMLib.HVCLogon.HVCLogonObj{{{SINGLE-QUOTE}}}.GetWorkstationName; + +///12/27/16 - for inital section of charting Specimen and fetching PreOp Dx + // Get the case id of the case in context + case_id := this_documentCommunication.CaseId ; + + get_part_id:= "{{{SINGLE-QUOTE}}}"||case_id||"{{{SINGLE-QUOTE}}}"; + + + IF this_eventType = "ChartObservation" + + //AND + // (current_parameter_name IN select_param ) //or current_parameter_name IN frozen_param) + //AND exists cur_val_text + + then + if exists case_id then + + ////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Get the case participants + ////////////////////////////////////////////////////////////////////////////////////////////////////////// + + participants := GRID_START || BOLD_ON || "Participants: \n" || BOLD_OFF; + +/// text SQL for the call to Dialogue + staff_name_list:= + "SELECT isnull(u.DisplayName, cp.ExternalParticipantName) " + || " FROM SXASRGCaseParticipant cp " + || " LEFT JOIN SXASRGSurgeryRole role ON cp.SurgeryRoleID = role.SurgeryRoleID " + || " LEFT JOIN SXASRGSurgeryStaff staff ON (cp.SurgeryStaffID = staff.SurgeryStaffID) " + || " LEFT JOIN CV3User u ON staff.UserGUID = u.GUID " + || " WHERE cp.CaseID = "||get_part_id ||" AND cp.Active = 1 " + || " ORDER BY cp.SortSequenceNum " ; + +/*"SELECT u.DisplayName AS SurgeryStaffFullName + FROM SXASRGCaseParticipant cp + LEFT JOIN SXASRGSurgeryRole role ON cp.SurgeryRoleID = role.SurgeryRoleID + LEFT JOIN SXASRGSurgeryStaff staff ON (cp.SurgeryStaffID = staff.SurgeryStaffID) + LEFT JOIN CV3User u ON staff.UserGUID = u.GUID + WHERE cp.CaseID = get_part_id AND cp.Active = 1 + ORDER BY cp.SortSequenceNum " ; + isnull(u.DisplayName, cp.ExternalParticipantName) AS SurgeryStaffFullName + //u.DisplayName + */ + + /* ( + surgery_staff_name_list + ):= read { + "SELECT + cp.CaseParticipantID, + cp.ExternalParticipantName, + role.Code, + cp.Comments, + u.DisplayName AS SurgeryStaffFullName + FROM SXASRGCaseParticipant cp + LEFT JOIN SXASRGSurgeryRole role ON cp.SurgeryRoleID = role.SurgeryRoleID + LEFT JOIN SXASRGSurgeryStaff staff ON (cp.SurgeryStaffID = staff.SurgeryStaffID) + LEFT JOIN CV3User u ON staff.UserGUID = u.GUID + WHERE cp.CaseID = " || SQL(case_id) || + "AND cp.Active = 1 + ORDER BY cp.SortSequenceNum " + }; + */ + + + endif; + + /// 01/05/17 - now here do loop + //if current_parameter_name IN specimen_param then + get_chart:= specimen_param; + get_write:= spec_dx; + endif; + FOR i in 1 seqto count select_by DO + ch_param:= select_by[i]; + wr_param:= by_whom[i]; + if current_parameter_name = ch_param then + target_param:= wr_param; +/// null out the launch observation for another selection + this_documentCommunication := call called_dom_mlm with + (this_documentCommunication, current_parameter_name, null, sugg_txt_value, update_type); +/// 02/21/17 - here for DIalogue logic + get_val_list:= string (get_val_list); + If get_val_list matches pattern "%,false, false%" // ,false, false + then + Consultant:= ""; + update_type:= "Replace"; + else + /// call dialogue box + + Consultant := CALL func_UDDD with staff_name_list; + update_type:= "REPLACE"; + endif; + +/// call here to get dialogue + //else + //target_param:= froz_dx; + endif; + ENDDO; + //break; + /// + IF exists Consultant // and (cur_val_text is not null or cur_val_text <> "") + then + + is_true:= "true"; + //get_true:= get_val_list where they in is_true; + + //If get_val_list matches pattern "%true%" then + dx_desc:= string (dx_desc); + //else + //dx_desc:= "No PreOp Dx recorded for this Procedure"; + + //endif; //exists dx_code + + cons_str:= string (Consultant); + //else + //cons_str:= ""; + //endif; +////////////////////////////////////////////////////////// + user_guid:= this_documentCommunication.UserGuid; + userid:= read last {" select IDCode from cv3user where guid = "|| sql (user_guid) }; + if userid matches pattern "rlatimer%" + then + ray:=1; + break; + endif; + /////////////////////////////////////////////////////// +/// added to ensure just one participant into Admin By + this_documentCommunication := call called_dom_mlm with + (this_documentCommunication, target_param, null, sugg_txt_value, update_type); +/////////////////////////////////////// + this_documentCommunication := call called_dom_mlm with + (this_documentCommunication, target_param, Cons_str, sugg_txt_value, update_type); +/// null out the launch observation for another selection + // 04/16/18 - move this to above + // this_documentCommunication := call called_dom_mlm with + // (this_documentCommunication, current_parameter_name, null, sugg_txt_value, update_type); + // endif; +/// for if user nulls out the site + /* ELSEIF not (exists cur_val_text) or cur_val_text = "" + then + dx_desc := ""; //null; + this_documentCommunication := call called_dom_mlm with + (this_documentCommunication, target_param, dx_desc, sugg_txt_value, update_type); + */ + ENDIF; // cur_val_text exists + //break; + // ENDIF; // then if cur_parameter name n... + +//////////// and of charting specimens///////////////////////// + /// for testing + // state_obj:= read last { StateInfo: this }; + //get_state:= state_obj.Records__; + /// applicationName=Scheduling + //get_wkst:= state_obj.WorkstationName; + user_guid:= this_documentCommunication.UserGuid; + userid:= read last {" select IDCode from cv3user where guid = "|| sql (user_guid) }; + if userid matches pattern "rlatimer%" + then + ray:=1; + //break; + endif; + + //get_state:= state_obj.Records__; + /// applicationName=Scheduling + //get_wkst:= state_obj.WorkstationName; + //////////////// + + //new_case_info_value := new_case_info_value || rtn_str; //IT_Head; + //Endif; /// exists it user + + + + + + + + + +////////////////////////////////////////////////////////////////////////////////////// + + /* // Set the Document Topic with the Case Number so that the Case Number appears beside the Document Name on the structured note + this_structuredNoteDoc.DocumentTopic := case_number; + + // Chart the free text observation items for case number and case info on the structured note + this_documentCommunication := call called_dom_mlm with (this_documentCommunication, case_number_parameter_name, new_case_number_value, sugg_txt_value, update_type); + this_documentCommunication := call called_dom_mlm with (this_documentCommunication, case_info_parameter_name, new_case_info_value, sugg_txt_value, update_type); + + endif; //exists case_id then + endif; // exists target_parameter + endif; // this_eventType = "DocumentOpening" +*/ + +/// for testing + user_guid:= this_documentCommunication.UserGuid; + userid:= read last {" select IDCode from cv3user where guid = "|| sql (user_guid) }; + if userid matches pattern "rlatimer%" + then + ray:=1; + //break; + endif; + + //////////////// + + Debug := is_display_message; // Set Debug := TRUE to see Message in document + document_communication_message := "Parameter Name " || case_number_parameter_name || " Event " || this_eventType || " Case Number " || case_number; + this_documentCommunication.DisplayMessage := is_display_message; + this_documentCommunication.Message := document_communication_message ; + + ;; + + evoke: + ;; + + logic: + conclude true; + ;; + + action: + return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_TRIAGE_NOTE_SCREENING.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_TRIAGE_NOTE_SCREENING.mlm new file mode 100644 index 0000000..a162ab4 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_TRIAGE_NOTE_SCREENING.mlm @@ -0,0 +1,204 @@ +maintenance: + + title: DOC_SCH_Triage_Note_Screening;; + mlmname: DOC_SCH_Triage_Note_Screening;; + arden: version 2.5;; + version: 5.50;; + institution: SCH ;; + author: Shivprasad Jadhav;; + specialist: ;; + date: 2015-03-05;; + validation: testing;; +library: + purpose: MLM used to create 4 health issue [Visually Impaired, Hearing Impaired, Mobility impaired and Limited English ] on Disability Risk Observation setin following Stuctured note. + In Some Stuctured note it create Dynamic order on close event. It is Part of Disability Risk Workflow. + 1) Ed triage note,2) Ob patient profile, 3) Pediatric patient profile 4) Adult patient profile, 5) Adult patient profile- observation ,6) Adult patient profile behavioral + 1) Adult assessment flow sheet, 2) Pediatric flow sheet, 3) Ob assessment flow sheet + ;; + explanation: + + + Change history + + 03.05.2015 SJ CSR# 33112 Created MLM + 09.08.2016 DW HD# 2200677 - Disability Risk MLM - Duplicate Health Issue - copied Prod version over dev as they didn{{{SINGLE-QUOTE}}}t match. Made no logic change + + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + (thisdocumentCommunication) := argument; + + //local_session := CDS_SESSION.local; + + //Get The Structure Note + (this_FS_doc) := thisdocumentCommunication.DocumentConfigurationObj; + //Get the Parameter List + (this_parms) := this_FS_doc.ParametersList; + //Paramters defination + (this_cols) := this_FS_doc.ColumnsList; + (this_curr_col) := this_FS_doc.Currentcolumn; + (this_currentObs) := thisdocumentCommunication.CurrentObservationObj; + (this_observations) := this_FS_doc.ChartedObservationsList; + (this_curr_valobj) := this_currentObs.valueobj; + + local_session := CDS_SESSION.local; + + MLM_DIPA := MLM {{{SINGLE-QUOTE}}}UTIL_OBJECT_Customize_DIPA_MLM{{{SINGLE-QUOTE}}}; + + MLM_HI := MLM {{{SINGLE-QUOTE}}}DOC_SCH_Triage_Screening_Visual{{{SINGLE-QUOTE}}}; + obs_HI := Call MLM_HI With thisdocumentCommunication; + + MLM_HI1 := MLM {{{SINGLE-QUOTE}}}DOC_SCH_Triage_Screening_Hearing{{{SINGLE-QUOTE}}}; + obs_HI1 := Call MLM_HI1 With thisdocumentCommunication; + + MLM_HI2 := MLM {{{SINGLE-QUOTE}}}DOC_SCH_Triage_Screening_Limited_English{{{SINGLE-QUOTE}}}; + obs_HI2 := Call MLM_HI2 With thisdocumentCommunication; + + MLM_HI3 := MLM {{{SINGLE-QUOTE}}}DOC_SCH_Triage_Screening_Mobility_Impaired{{{SINGLE-QUOTE}}}; + obs_HI3 := Call MLM_HI3 With thisdocumentCommunication; + + Client_GUID := thisdocumentCommunication.ClientGUID; + Client_Visit_GUID := thisdocumentCommunication.ClientVisitGUID; + + this_curr_obs := last (this_FS_doc.chartedobservationslist); + this_current_prm := first of (this_parms where this_parms.parameterGUID = this_currentObs.ParameterGUID); + cur_name := this_current_prm.Name; + +/*************************************************************************************************************/ + + If (cur_name = "SCH_Ped_Special need") then + + sel1 := "" ; + sel2 := "" ; + prm := first of (this_parms where this_parms.Name = "SCH_Ped_Special need"); + Obs := first of (this_observations where this_observations.ParameterGUID = prm.ParameterGUID); + lst1 := Obs.valueObj.ListItemsList ; + sel1 := First of( lst1.Value Where lst1.IsSelected = true ); + sel1Col := lst1.Value where lst1.IsSelected = true ; + sel2 := First Of( lst1.Value where lst1.IsSelected = true ) ; + sel2Col := lst1.Value where lst1.IsSelected = true ; + SessionSpecialNeed := local_session.SessionPediatricSpecialNeed ; + SessionSpecialNeedForMessage := local_session.SessionPediatricSpecialNeedForMessage ; + + + + if SessionSpecialNeed = "" and (sel1 <> "" ) then + SessionSpecialNeed := sel1; + local_session.SessionPediatricSpecialNeed := sel1; + endif; + + if SessionSpecialNeed = "No Diagnosis Risk Criteria" and sel1 IS NULL and sel2 IS NULL then + local_session.SessionPediatricSpecialNeed := ""; + endif; + + if SessionSpecialNeed <> "No Diagnosis Risk Criteria" and sel2 <> "" then + local_session.SessionPediatricSpecialNeed := ""; + obs2 := CALL MLM_DIPA WITH thisDocumentCommunication, prm, sel2Col ; + thisdocumentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + thisdocumentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + endif; + + + Endif; + +/*************************************************************************************************************/ + + If (cur_name = "sch_obpt_Special Need") then + + sel1 := "" ; + sel2 := "" ; + prm := first of (this_parms where this_parms.Name = "sch_obpt_Special Need"); + Obs := first of (this_observations where this_observations.ParameterGUID = prm.ParameterGUID); + lst1 := Obs.valueObj.ListItemsList ; + sel1 := First of( lst1.Value Where lst1.IsSelected = true ); + sel1Col := lst1.Value where lst1.IsSelected = true ; + sel2 := First Of( lst1.Value where lst1.IsSelected = true ) ; + sel2Col := lst1.Value where lst1.IsSelected = true ; + SessionSpecialNeed := local_session.SessionPediatricSpecialNeed ; + SessionSpecialNeedForMessage := local_session.SessionPediatricSpecialNeedForMessage ; + + + + if SessionSpecialNeed = "" and (sel1 <> "" ) then + SessionSpecialNeed := sel1; + local_session.SessionPediatricSpecialNeed := sel1; + endif; + + if SessionSpecialNeed = "No Diagnosis Risk Criteria" and sel1 IS NULL and sel2 IS NULL then + local_session.SessionPediatricSpecialNeed := ""; + endif; + + if SessionSpecialNeed <> "No Diagnosis Risk Criteria" and sel2 <> "" then + local_session.SessionPediatricSpecialNeed := ""; + obs2 := CALL MLM_DIPA WITH thisDocumentCommunication, prm, sel2Col ; + thisdocumentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + thisdocumentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + endif; + + + Endif; + +/*************************************************************************************************************/ + + If (cur_name = "SCH_Adultpt_Special need") then + + sel1 := "" ; + sel2 := "" ; + prm := first of (this_parms where this_parms.Name = "SCH_Adultpt_Special need"); + Obs := first of (this_observations where this_observations.ParameterGUID = prm.ParameterGUID); + lst1 := Obs.valueObj.ListItemsList ; + sel1 := First of( lst1.Value Where lst1.IsSelected = true ); + sel1Col := lst1.Value where lst1.IsSelected = true ; + sel2 := First Of( lst1.Value where lst1.IsSelected = true ) ; + sel2Col := lst1.Value where lst1.IsSelected = true ; + SessionSpecialNeed := local_session.SessionPediatricSpecialNeed ; + SessionSpecialNeedForMessage := local_session.SessionPediatricSpecialNeedForMessage ; + + + + if SessionSpecialNeed = "" and (sel1 <> "" ) then + SessionSpecialNeed := sel1; + local_session.SessionPediatricSpecialNeed := sel1; + endif; + + if SessionSpecialNeed = "No Diagnosis Risk Criteria" and sel1 IS NULL and sel2 IS NULL then + local_session.SessionPediatricSpecialNeed := ""; + endif; + + if SessionSpecialNeed <> "No Diagnosis Risk Criteria" and sel2 <> "" then + local_session.SessionPediatricSpecialNeed := ""; + obs2 := CALL MLM_DIPA WITH thisDocumentCommunication, prm, sel2Col ; + thisdocumentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + thisdocumentCommunication.DocumentConfigurationObj.ChartedObservationsList, obs2); + endif; + + + Endif; + +/*************************************************************************************************************/ + + + +;; + priority: 50 + ;; + evoke: + ;; + logic: + Conclude true; + ;; + action: + return thisdocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_TRIAGE_SCREENING_HEARING.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_TRIAGE_SCREENING_HEARING.mlm new file mode 100644 index 0000000..9716499 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_TRIAGE_SCREENING_HEARING.mlm @@ -0,0 +1,324 @@ +maintenance: + + title: DOC_SCH_Triage_Screening_Hearing;; + mlmname: DOC_SCH_Triage_Screening_Hearing;; + arden: version 5.5;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Shivprasad Jadhav;; + specialist: ;; + date: 2015-03-05;; + validation: testing;; +library: + purpose: This MLM will create a Health Issue when an observation is charted on ED Triage Note. ;; + explanation: Create Hearing Impaired HI if one does not already exist + + + + Change history + + 09.30.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 HI Dynamic Creation with all details Like ICD10 Code, Snowmed Code etc And Duplicate HI Check Change. + 10.12.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 Coding Scheme [ICD10] And Duplicate Check of HI . + 09.08.2016 DW HD# 2200677 - Disability Risk MLM - Duplicate Health Issue - copied Prod version over dev as they didn{{{SINGLE-QUOTE}}}t match. Altered HI lookup to interrogate all visits + + + ;; + keywords: ;; +knowledge: + type: data-driven;; + data: + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + +z:=thisParameters.Records__; + + + +// for ed Triage Note----------------------------------------------------------------------------------------------------- + + this_parametername := first of (thisParameters where thisParameters.Name = "sch_edtriage_Special need"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = this_parametername.ParameterGUID); + + If true in (theObservation.ValueObj.ListItemsList.IsSelected where + theObservation.ValueObj.ListItemsList.Value = "Deaf" + ) then chronic := "Deaf"; + endif; + +// for Pediatric Patient Profile ----------------------------------------------------------------------------------------- + this_parametername1 := first of (thisParameters where thisParameters.Name = "SCH_Ped_Special need"); + theObservation1 := first of (thisobservations where thisobservations.ParameterGUID = this_parametername1.ParameterGUID); + + If true in (theObservation1.ValueObj.ListItemsList.IsSelected where + theObservation1.ValueObj.ListItemsList.Value = "Deaf" + ) then chronic := "Deaf"; + endif; + +// for OB Patient Profile ----------------------------------------------------------------------------------------- + this_parametername2 := first of (thisParameters where thisParameters.Name = "sch_obpt_Special Need"); + theObservation2 := first of (thisobservations where thisobservations.ParameterGUID = this_parametername2.ParameterGUID); + + If true in (theObservation2.ValueObj.ListItemsList.IsSelected where + theObservation2.ValueObj.ListItemsList.Value = "Deaf" + ) then chronic := "Deaf"; + endif; +// for Adult Patient Profile ----------------------------------------------------------------------------------------- + this_parametername3 := first of (thisParameters where thisParameters.Name = "SCH_Adultpt_Special need"); + theObservation3 := first of (thisobservations where thisobservations.ParameterGUID = this_parametername3.ParameterGUID); + + If true in (theObservation3.ValueObj.ListItemsList.IsSelected where + theObservation3.ValueObj.ListItemsList.Value = "Deaf" + ) then chronic := "Deaf"; + endif; +//------------------------------------------------------------------------------------------------------------------------- + + + +// If the patient have health issue, determine if they already have a Health Issue in their record + + If chronic = "Deaf" then + + +//----------------------for PPM Alert to Careprovider ---------------------- + CurrentLocation, Account := read last {"Select CurrentLocation, VisitIDCode From cv3Clientvisit with (nolock) Where Guid = " || SQL(visitGuid)||" " }; + EndOfUnit := find "-" in string CurrentLocation; + + If EndofUnit <> 0 + then Unit:= SUBSTRING EndOfUnit -1 CHARACTERS STARTING AT 1 from CurrentLocation; + else Unit:= CurrentLocation; + endif; + + // Send a Text Message Section + + PhoneNumber := read last {" select p.AreaCode + p.PhoneNumber from CV3User u with (nolock) join Cv3Phone p with (nolock) on p.PersonGUID = u.GUID " || + " where u.displayname = {{{SINGLE-QUOTE}}}SCM, Text Messaging{{{SINGLE-QUOTE}}} and p.PhoneNote = {{{SINGLE-QUOTE}}}PPM{{{SINGLE-QUOTE}}} And p.Active =1 "}; + + Page_MLM := mlm {{{SINGLE-QUOTE}}}SCH_FUNC_PAGE{{{SINGLE-QUOTE}}}; + MessageSubject:= "Important Message"; + MessageBody := " Please call unit " || Unit || " Account # " || Account || " for Disability Risk - Deaf"; + PPMvoid := call Page_MLM with(PhoneNumber, MessageSubject, MessageBody); + //PPMvoid := call Page_MLM with("shivprasad.jadhav@stclair.org", MessageSubject, MessageBody); + +//--------------------------------------- + + + (HearingImpHI) := read {" select distinct hi.shortname " + || "from cv3healthissuedeclaration hi with (nolock) " + || "join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID " + || "where hi.clientguid = " || clientGuid || " and hi.active = 1 and hi.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " + || " and hi.typecode = {{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}} " + || "And hi.ICD10Code is not null " // Added By Shivprasad on 29 Sept 2015 for ICD9-10 Changes + || "and ( " + || "hi.text like {{{SINGLE-QUOTE}}}%Deaf%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Deaf%{{{SINGLE-QUOTE}}} or " + || " " + || "(Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}} then chi.code when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD10{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}389.9{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}H91.90{{{SINGLE-QUOTE}}}) " //CSR#23359-ICD9-ICD10 HI Change for Code Scheme ICD10- Added By shivprasad + || " ) " + }; + +// 09.08.2016 DW HD# 2200677 - removed the firstline and replaced the second line below which will direct the SQL to look across all visits for a chronic HI + +// || " AND ({{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} AND ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}} OR ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}} AND hi.ChartGUID = " || SQL(chartGuid) || " ) OR hi.ClientVisitGUID = " || SQL(visitGuid) || " ) ) " +// || "and hi.typecode not in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}chronic dx{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}dx comments{{{SINGLE-QUOTE}}}) " + + +// Notify the user if a new Health Issue is about to be created and permit them to reverse them to cancel the process + + If not exists HearingImpHI AND thisDocumentCommunication.EventType <> "DocumentOpening" then + + dlg_result := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with + "\n This selection will create a chronic health issue of {{{SINGLE-QUOTE}}}" || chronic || "{{{SINGLE-QUOTE}}}" || + "\n\n Click {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to confirm your selection. " || + "\n\n Click {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} if you wish to change your selection. " || + "\n " + ,"Confirm {{{SINGLE-QUOTE}}}" || chronic || "{{{SINGLE-QUOTE}}} Documentation ", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; + + +// If the user responds by cliking the "Yes" button, proceed with creating the order + + If (dlg_result as string) = "Yes" then + + try + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}Retrieve client:{{-R}}\n" || + ex.Message || "\n\n"; + if ex.InnerException is not null net_object then + error_message := error_message || "Inner Exception: " || ex.InnerException.Message || "\n\n"; + endif; + if ( client_visit_obj is NOT NULL ) then + void:= call client_visit_obj.Dispose; client_visit_obj:= null; + endif; + endcatch; + +/* + + +// 09.08.2016 DW HD# 2200677 - moved this earlier in the logic + +//----------------------for PPM Alert to Careprovider ---------------------- + CurrentLocation, Account := read last {"Select CurrentLocation, VisitIDCode From cv3Clientvisit with (nolock) Where Guid = " || SQL(visitGuid)||" and VisitStatus = {{{SINGLE-QUOTE}}}ADM{{{SINGLE-QUOTE}}}" }; + EndOfUnit := find "-" in string CurrentLocation; + + If EndofUnit <> 0 + then Unit:= SUBSTRING EndOfUnit -1 CHARACTERS STARTING AT 1 from CurrentLocation; + else Unit:= CurrentLocation; + endif; + + // Send a Text Message Section + + PhoneNumber := read last {" select p.AreaCode + p.PhoneNumber from CV3User u with (nolock) join Cv3Phone p with (nolock) on p.PersonGUID = u.GUID " || + " where u.displayname = {{{SINGLE-QUOTE}}}SCM, Text Messaging{{{SINGLE-QUOTE}}} and p.PhoneNote = {{{SINGLE-QUOTE}}}PPM{{{SINGLE-QUOTE}}} And p.Active =1 "}; + + Page_MLM := mlm {{{SINGLE-QUOTE}}}SCH_FUNC_PAGE{{{SINGLE-QUOTE}}}; + MessageSubject:= "Important Message"; + MessageBody := " Please call unit " || Unit || " Account # " || Account || " for Disability Risk - Deaf"; + PPMvoid := call Page_MLM with(PhoneNumber, MessageSubject, MessageBody); + //PPMvoid := call Page_MLM with("shivprasad.jadhav@stclair.org", MessageSubject, MessageBody); + +//--------------------------------------- +*/ + try + //--------------------------------------------------------- + // New HealthIssue Example + //--------------------------------------------------------- + + If chronic = "Deaf" then + issuename := "Deaf"; + issuecode := "H91.90" ; // "389.9"; //CSR#23359-ICD9-ICD10 HI Change for Code Scheme ICD10- Added By shivprasad + endif; + + NewHealthIssueHIType := "Problem-Chronic"; + NewHealthIssueHICode := issuecode; + NewHealthIssueHIScheme := "ICD10" ; //"ICD9"; //CSR#23359-ICD9-ICD10 HI Change for Code Scheme ICD10- Added By shivprasad + + dd := EXTRACT Day now; + mn := EXTRACT Month now; + yr := EXTRACT Year now; +/* + New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with + (client_visit_obj, NewHealthIssueHIType, NewHealthIssueHIScheme, NewHealthIssueHICode); + + + PartialDate_obj := new net_object {{{SINGLE-QUOTE}}}PartialDate{{{SINGLE-QUOTE}}} with (yr as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, mn as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, dd as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}} ); + New_HealthIssue_obj.OnsetDate := PartialDate_obj; + New_HealthIssue_obj.Text := "Created from ED Triage Note Screening. " ; + New_HealthIssue_obj.Name := issuename; + //New_HealthIssue_obj.ICD10Code := "H91.90" As String; + //New_HealthIssue_obj.SNOMEDCTCode := "15188001"; +*/ +//--Start: CSR 23359-ICD9-ICD10 HI Change Added By shivprasad + Terms := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.FindIMOTerms with (NewHealthIssueHIScheme,issuecode); + + FOR i IN 1 SEQTO (Terms.Count as Number ) DO + HI_obj := Terms[i]; + HI_Name := HI_obj.TermName as string; + if HI_Name = issuename then + HI_NO := i ; + Endif; + ENDDO; + If HI_NO is Null Then HI_NO :=1 ; Endif; + + New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with + (client_visit_obj, NewHealthIssueHIType, Terms[HI_NO]); +// end of code + //Terms := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.FindIMOTerms with (NewHealthIssueHIScheme,issuecode); + //New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with + // (client_visit_obj, NewHealthIssueHIType, Terms[8]); + PartialDate_obj := new net_object {{{SINGLE-QUOTE}}}PartialDate{{{SINGLE-QUOTE}}} with (yr as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, mn as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, dd as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}} ); + New_HealthIssue_obj.OnsetDate := PartialDate_obj; + New_HealthIssue_obj.Text := "Created from ED Triage Note Screening. " ; + New_HealthIssue_obj.Name := issuename; + + + if ( New_HealthIssue_obj is NOT NULL ) then + void := call New_HealthIssue_obj.Save; + void := call New_HealthIssue_obj.Dispose; + endif; + + if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; + + endtry; + + catch exception ex + error_occurred := true; + if ( New_HealthIssue_obj is NOT NULL ) then void:= call New_HealthIssue_obj.Dispose; New_HealthIssue_obj:= null; endif; + endcatch; + + + + Elseif (dlg_result as string) = "No" then + lst1 := theObservation.valueObj.ListItemsList ; + for i in lst1 do + if i.IsSelected = true And i.value = "Deaf" Then + i.IsSelected := false ; + endif; + enddo; + lst2 := theObservation1.valueObj.ListItemsList ; + for i in lst2 do + if i.Isselected = true and i.value = "Deaf" then + i.IsSelected := FALSE ; + endif; + enddo; + lst3 := theObservation2.valueObj.ListItemsList ; + for i in lst3 do + if i.Isselected = true and i.value = "Deaf" then + i.IsSelected := FALSE ; + endif; + enddo; + lst4 := theObservation3.valueObj.ListItemsList ; + for i in lst4 do + if i.Isselected = true and i.value = "Deaf" then + i.IsSelected := FALSE ; + endif; + enddo; + + endif; // If exists CHFHI + + endif; // If (dlg_result as string) = "Yes" + +endif; + +;; + evoke: + ;; + logic: + +conclude true; + + ;; + action: + + + return thisDocumentCommunication; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_TRIAGE_SCREENING_LIMITED_ENGLISH.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_TRIAGE_SCREENING_LIMITED_ENGLISH.mlm new file mode 100644 index 0000000..df12665 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_TRIAGE_SCREENING_LIMITED_ENGLISH.mlm @@ -0,0 +1,309 @@ +maintenance: + + title: DOC_SCH_Triage_Screening_Limited_English;; + mlmname: DOC_SCH_Triage_Screening_Limited_English;; + arden: version 5.5;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Shivprasad Jadhav;; + specialist: ;; + date: 2015-03-05;; + validation: testing;; +library: + purpose: This MLM will create a Health Issue when an observation is charted on ED Triage Note. ;; + explanation: Create Limited English HI if one does not already exist + + + + Change history + + 09.30.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 HI Dynamic Creation with all details Like ICD10 Code, Snowmed Code etc And Duplicate HI Check Change. + 10.12.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 Coding Scheme [ICD10] And Duplicate Check of HI . + 09.08.2016 DW HD# 2200677 - Disability Risk MLM - Duplicate Health Issue - copied Prod version over dev as they didn{{{SINGLE-QUOTE}}}t match. Altered HI lookup to interrogate all visits + + + ;; + keywords: ;; +knowledge: + type: data-driven;; + data: + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + + +// Determine which of the Chronic Conditions boxes is checked + + this_parametername := first of (thisParameters where thisParameters.Name = "sch_edtriage_Special need"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = this_parametername.ParameterGUID); + + If true in (theObservation.ValueObj.ListItemsList.IsSelected where + theObservation.ValueObj.ListItemsList.Value = "Limited English" + ) then chronic := "Limited English"; + endif; +// for Pediatric Patient Profile ----------------------------------------------------------------------------------------- + this_parametername1 := first of (thisParameters where thisParameters.Name = "SCH_Ped_Special need"); + theObservation1 := first of (thisobservations where thisobservations.ParameterGUID = this_parametername1.ParameterGUID); + + If true in (theObservation1.ValueObj.ListItemsList.IsSelected where + theObservation1.ValueObj.ListItemsList.Value = "Limited English" + ) then chronic := "Limited English"; + endif; +// for OB Patient Profile ----------------------------------------------------------------------------------------- + this_parametername2 := first of (thisParameters where thisParameters.Name = "sch_obpt_Special Need"); + theObservation2 := first of (thisobservations where thisobservations.ParameterGUID = this_parametername2.ParameterGUID); + + If true in (theObservation2.ValueObj.ListItemsList.IsSelected where + theObservation2.ValueObj.ListItemsList.Value = "Limited English" + ) then chronic := "Limited English"; + endif; +// for Adult Patient Profile ----------------------------------------------------------------------------------------- + this_parametername3 := first of (thisParameters where thisParameters.Name = "SCH_Adultpt_Special need"); + theObservation3 := first of (thisobservations where thisobservations.ParameterGUID = this_parametername3.ParameterGUID); + + If true in (theObservation3.ValueObj.ListItemsList.IsSelected where + theObservation3.ValueObj.ListItemsList.Value = "Limited English" + ) then chronic := "Limited English"; + endif; +//------------------------------------------------------------------------------------------------------------------------- + + +// If the patient have health issue, determine if they already have a Health Issue in their record + + If chronic = "Limited English" then + +//----------------------for PPM Alert to Careprovider ---------------------- + CurrentLocation, Account := read last {"Select CurrentLocation, VisitIDCode From cv3Clientvisit with (nolock) Where Guid = " || SQL(visitGuid)||" " }; + EndOfUnit := find "-" in string CurrentLocation; + + If EndofUnit <> 0 + then Unit:= SUBSTRING EndOfUnit -1 CHARACTERS STARTING AT 1 from CurrentLocation; + else Unit:= CurrentLocation; + endif; + + // Send a Text Message Section + + PhoneNumber := read last {" select p.AreaCode + p.PhoneNumber from CV3User u with (nolock) join Cv3Phone p with (nolock) on p.PersonGUID = u.GUID " || + " where u.displayname = {{{SINGLE-QUOTE}}}SCM, Text Messaging{{{SINGLE-QUOTE}}} and p.PhoneNote = {{{SINGLE-QUOTE}}}PPM{{{SINGLE-QUOTE}}} And p.Active =1 "}; + + Page_MLM := mlm {{{SINGLE-QUOTE}}}SCH_FUNC_PAGE{{{SINGLE-QUOTE}}}; + MessageSubject:= "Important Message"; + MessageBody := " Please call unit " || Unit || " Account # " || Account || " for Disability Risk - Limited English"; + PPMvoid := call Page_MLM with(PhoneNumber, MessageSubject, MessageBody); + +//--------------------------------------- + + + + (LimitedEnglishpHI) := read {" select distinct hi.shortname " + || "from cv3healthissuedeclaration hi with (nolock) " + || "join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID " + || "where hi.clientguid = " || clientGuid || " and hi.active = 1 and hi.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " + || " and hi.typecode = {{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}} " + || "And hi.ICD10Code is not null " // Added By Shivprasad on 29 Sept 2015 for ICD9-10 Changes + || "and ( " + || "hi.text like {{{SINGLE-QUOTE}}}%Non-English speaking patient%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Non-English speaking patient%{{{SINGLE-QUOTE}}} or " + || " " + || "(Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}} then chi.code when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD10{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}V40.1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}R47.89{{{SINGLE-QUOTE}}}) " //CSR#23359-ICD9-ICD10 HI Change for Code Scheme ICD10- Added By shivprasad + || " ) " + }; + +// 09.08.2016 DW HD# 2200677 - removed the firstline and replaced the second line below which will direct the SQL to look across all visits for a chronic HI + +// || " AND ({{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} AND ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}} OR ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}} AND hi.ChartGUID = " || SQL(chartGuid) || " ) OR hi.ClientVisitGUID = " || SQL(visitGuid) || " ) ) " +// || "and hi.typecode not in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}chronic dx{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}dx comments{{{SINGLE-QUOTE}}}) " + + +// Notify the user if a new Health Issue is about to be created and permit them to reverse them to cancel the process + + If not exists LimitedEnglishpHI AND thisDocumentCommunication.EventType <> "DocumentOpening" then + + dlg_result := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with + "\n This selection will create a chronic health issue of {{{SINGLE-QUOTE}}}" || chronic || "{{{SINGLE-QUOTE}}}" || + "\n\n Click {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to confirm your selection. " || + "\n\n Click {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} if you wish to change your selection. " || + "\n " + ,"Confirm {{{SINGLE-QUOTE}}}" || chronic || "{{{SINGLE-QUOTE}}} Documentation ", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}} ; + + +// If the user responds by cliking the "Yes" button, proceed with creating the order + + If (dlg_result as string) = "Yes" then + + try + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}Retrieve client:{{-R}}\n" || + ex.Message || "\n\n"; + if ex.InnerException is not null net_object then + error_message := error_message || "Inner Exception: " || ex.InnerException.Message || "\n\n"; + endif; + if ( client_visit_obj is NOT NULL ) then + void:= call client_visit_obj.Dispose; client_visit_obj:= null; + endif; + endcatch; + +/* + +// 09.08.2016 DW HD# 2200677 - moved this earlier in the logic + +//----------------------for PPM Alert to Careprovider ---------------------- + CurrentLocation, Account := read last {"Select CurrentLocation, VisitIDCode From cv3Clientvisit with (nolock) Where Guid = " || SQL(visitGuid)||" and VisitStatus = {{{SINGLE-QUOTE}}}ADM{{{SINGLE-QUOTE}}}" }; + EndOfUnit := find "-" in string CurrentLocation; + + If EndofUnit <> 0 + then Unit:= SUBSTRING EndOfUnit -1 CHARACTERS STARTING AT 1 from CurrentLocation; + else Unit:= CurrentLocation; + endif; + + // Send a Text Message Section + + PhoneNumber := read last {" select p.AreaCode + p.PhoneNumber from CV3User u with (nolock) join Cv3Phone p with (nolock) on p.PersonGUID = u.GUID " || + " where u.displayname = {{{SINGLE-QUOTE}}}SCM, Text Messaging{{{SINGLE-QUOTE}}} and p.PhoneNote = {{{SINGLE-QUOTE}}}PPM{{{SINGLE-QUOTE}}} And p.Active =1 "}; + + Page_MLM := mlm {{{SINGLE-QUOTE}}}SCH_FUNC_PAGE{{{SINGLE-QUOTE}}}; + MessageSubject:= "Important Message"; + MessageBody := " Please call unit " || Unit || " Account # " || Account || " for Disability Risk - Limited English"; + PPMvoid := call Page_MLM with(PhoneNumber, MessageSubject, MessageBody); + +//--------------------------------------- +*/ + try + //--------------------------------------------------------- + // New HealthIssue Example + //--------------------------------------------------------- + + If chronic = "Limited English" then issuename := "Non-English speaking patient"; + issuecode := "R47.89" ;//"V40.1"; //CSR#23359-ICD9-ICD10 HI Change for Code Scheme ICD10- Added By shivprasad + endif; + + NewHealthIssueHIType := "Problem-Chronic"; + NewHealthIssueHICode := issuecode; + NewHealthIssueHIScheme := "ICD10" ;// "ICD9"; //CSR#23359-ICD9-ICD10 HI Change for Code Scheme ICD10- Added By shivprasad + + dd := EXTRACT Day now; + mn := EXTRACT Month now; + yr := EXTRACT Year now; + +//--Start: CSR 23359-ICD9-ICD10 HI Change Added By shivprasad + Terms := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.FindIMOTerms with (NewHealthIssueHIScheme,issuecode); + FOR i IN 1 SEQTO (Terms.Count as Number ) DO + HI_obj := Terms[i]; + HI_Name := HI_obj.TermName as string; + If HI_Name = issuename then + HI_NO := i ; + Endif; + ENDDO; + If HI_NO is Null Then + HI_NO :=1 ; + Endif; + New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with (client_visit_obj, NewHealthIssueHIType, Terms[HI_NO]); + +//--End Added by Shivprasad + + + //New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with + // (client_visit_obj, NewHealthIssueHIType, NewHealthIssueHIScheme, NewHealthIssueHICode ); + + PartialDate_obj := new net_object {{{SINGLE-QUOTE}}}PartialDate{{{SINGLE-QUOTE}}} with (yr as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, mn as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, dd as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}} ); + New_HealthIssue_obj.OnsetDate := PartialDate_obj; + New_HealthIssue_obj.Text := "Created from ED Triage Note Screening. " ; + New_HealthIssue_obj.Name := issuename; + + + if ( New_HealthIssue_obj is NOT NULL ) then + void := call New_HealthIssue_obj.Save; + void := call New_HealthIssue_obj.Dispose; + endif; + + if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; + + endtry; + + catch exception ex + error_occurred := true; + if ( New_HealthIssue_obj is NOT NULL ) then void:= call New_HealthIssue_obj.Dispose; New_HealthIssue_obj:= null; endif; + endcatch; + + + + Elseif (dlg_result as string) = "No" then + + //void:= ""; + lst1 := theObservation.valueObj.ListItemsList ; + for i in lst1 do + if i.Isselected = true and i.value = "Limited English" then + i.IsSelected := FALSE ; + endif; + enddo; + lst2 := theObservation1.valueObj.ListItemsList ; + for i in lst2 do + if i.Isselected = true and i.value = "Limited English" then + i.IsSelected := FALSE ; + endif; + enddo; + lst3 := theObservation2.valueObj.ListItemsList ; + for i in lst3 do + if i.Isselected = true and i.value = "Limited English" then + i.IsSelected := FALSE ; + endif; + enddo; + lst4 := theObservation3.valueObj.ListItemsList ; + for i in lst4 do + if i.Isselected = true and i.value = "Limited English" then + i.IsSelected := FALSE ; + endif; + enddo; + + endif; + + endif; + +endif; + + + ;; + evoke: + ;; + logic: + +conclude true; + + ;; + action: + + + return thisDocumentCommunication; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_TRIAGE_SCREENING_MOBILITY_IMPAIRED.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_TRIAGE_SCREENING_MOBILITY_IMPAIRED.mlm new file mode 100644 index 0000000..122a7e6 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_TRIAGE_SCREENING_MOBILITY_IMPAIRED.mlm @@ -0,0 +1,318 @@ +maintenance: + + title: DOC_SCH_Triage_Screening_Mobility_Impaired;; + mlmname: DOC_SCH_Triage_Screening_Mobility_Impaired;; + arden: version 5.5;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Shivprasad Jadhav;; + specialist: ;; + date: 2015-03-05;; + validation: testing;; +library: + purpose: This MLM will create a Health Issue when an observation is charted on ED Triage Note. ;; + explanation: Create Mobility Impaired HI if one does not already exist + + + + Change history + + 06.02.2012 GOS CSR:33112 - Created MLM + 09.30.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 HI Dynamic Creation with all details Like ICD10 Code, Snowmed Code etc And Duplicate HI Check Change. + 10.12.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 Coding Scheme [ICD10] And Duplicate Check of HI . + 09.08.2016 DW HD# 2200677 - Disability Risk MLM - Duplicate Health Issue - copied Prod version over dev as they didn{{{SINGLE-QUOTE}}}t match. Altered HI lookup to interrogate all visits + + + ;; + keywords: ;; +knowledge: + type: data-driven;; + data: + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + + +// Determine which of the Chronic Conditions boxes is checked + + this_parametername := first of (thisParameters where thisParameters.Name = "sch_edtriage_Special need"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = this_parametername.ParameterGUID); + + + If true in (theObservation.ValueObj.ListItemsList.IsSelected where + theObservation.ValueObj.ListItemsList.Value in( "Immobility Risk – Service Animal","Immobility Risk – Special Call Bell" ) + ) then chronic := "Mobility Impaired"; + endif; +// for Pediatric Patient Profile ----------------------------------------------------------------------------------------- + this_parametername1 := first of (thisParameters where thisParameters.Name = "SCH_Ped_Special need"); + theObservation1 := first of (thisobservations where thisobservations.ParameterGUID = this_parametername1.ParameterGUID); + + If true in (theObservation1.ValueObj.ListItemsList.IsSelected where + theObservation1.ValueObj.ListItemsList.Value in( "Immobility Risk – Service Animal","Immobility Risk – Special Call Bell" ) + ) then chronic := "Mobility Impaired"; + endif; +// for OB Patient Profile ----------------------------------------------------------------------------------------- + this_parametername2 := first of (thisParameters where thisParameters.Name = "sch_obpt_Special Need"); + theObservation2 := first of (thisobservations where thisobservations.ParameterGUID = this_parametername2.ParameterGUID); + + If true in (theObservation2.ValueObj.ListItemsList.IsSelected where + theObservation2.ValueObj.ListItemsList.Value in( "Immobility Risk – Service Animal","Immobility Risk – Special Call Bell" ) + ) then chronic := "Mobility Impaired" ; + endif; +// for Adult Patient Profile ----------------------------------------------------------------------------------------- + this_parametername3 := first of (thisParameters where thisParameters.Name = "SCH_Adultpt_Special need"); + theObservation3 := first of (thisobservations where thisobservations.ParameterGUID = this_parametername3.ParameterGUID); + + If true in (theObservation3.ValueObj.ListItemsList.IsSelected where + theObservation3.ValueObj.ListItemsList.Value in( "Immobility Risk – Service Animal","Immobility Risk – Special Call Bell" ) + ) then chronic := "Mobility Impaired" ; + endif; +//------------------------------------------------------------------------------------------------------------------------- + + + +// If the patient have health issue, determine if they already have a Health Issue in their record + + If chronic = "Mobility Impaired" then + +//----------------------for PPM Alert to Careprovider ---------------------- + CurrentLocation, Account := read last {"Select CurrentLocation, VisitIDCode From cv3Clientvisit with (nolock) Where Guid = " || SQL(visitGuid)||" " }; + EndOfUnit := find "-" in string CurrentLocation; + + If EndofUnit <> 0 + then Unit:= SUBSTRING EndOfUnit -1 CHARACTERS STARTING AT 1 from CurrentLocation; + else Unit:= CurrentLocation; + endif; + + // Send a Text Message Section + + PhoneNumber := read last {" select p.AreaCode + p.PhoneNumber from CV3User u with (nolock) join Cv3Phone p with (nolock) on p.PersonGUID = u.GUID " || + " where u.displayname = {{{SINGLE-QUOTE}}}SCM, Text Messaging{{{SINGLE-QUOTE}}} and p.PhoneNote = {{{SINGLE-QUOTE}}}PPM{{{SINGLE-QUOTE}}} And p.Active =1 "}; + + Page_MLM := mlm {{{SINGLE-QUOTE}}}SCH_FUNC_PAGE{{{SINGLE-QUOTE}}}; + MessageSubject:= "Important Message"; + MessageBody := " Please call unit " || Unit || " Account # " || Account || " for Disability Risk - Mobility Impaired "; + PPMvoid := call Page_MLM with(PhoneNumber, MessageSubject, MessageBody); + +//--------------------------------------- + + + + + (MobilityImpHI) := read {" select distinct hi.shortname " + || "from cv3healthissuedeclaration hi with (nolock) " + || "join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID " + || "where hi.clientguid = " || clientGuid || " and hi.active = 1 and hi.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " + || " and hi.typecode = {{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}} " + || " And hi.ICD10Code is not null " // Added By Shivprasad on 29 Sept 2015 for ICD9-10 Changes + || "and ( " + || "hi.text like {{{SINGLE-QUOTE}}}%Mobility impaired%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Ill-defined disease%{{{SINGLE-QUOTE}}} or " + || " " + || "(Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}} then chi.code when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD10{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}799.89{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Z74.09{{{SINGLE-QUOTE}}}) " //CSR#23359-ICD9-ICD10 HI Change for Code Scheme ICD10- Added By shivprasad + || " ) " + }; + +// 09.08.2016 DW HD# 2200677 - removed the firstline and replaced the second line below which will direct the SQL to look across all visits for a chronic HI + +// || " AND ({{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} AND ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}} OR ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}} AND hi.ChartGUID = " || SQL(chartGuid) || " ) OR hi.ClientVisitGUID = " || SQL(visitGuid) || " ) ) " +// || "and hi.typecode not in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}chronic dx{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}dx comments{{{SINGLE-QUOTE}}}) " + + +// Notify the user if a new Health Issue is about to be created and permit them to reverse them to cancel the process + + If not exists MobilityImpHI AND thisDocumentCommunication.EventType <> "DocumentOpening" then + + dlg_result := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with + "\n This selection will create a chronic health issue of {{{SINGLE-QUOTE}}}" || chronic || "{{{SINGLE-QUOTE}}}" || + "\n\n Click {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to confirm your selection. " || + "\n\n Click {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} if you wish to change your selection. " || + "\n " + ,"Confirm {{{SINGLE-QUOTE}}}" || chronic || "{{{SINGLE-QUOTE}}} Documentation ", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}} ; + + +// If the user responds by cliking the "Yes" button, proceed with creating the order + + If (dlg_result as string) = "Yes" then + + try + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}Retrieve client:{{-R}}\n" || + ex.Message || "\n\n"; + if ex.InnerException is not null net_object then + error_message := error_message || "Inner Exception: " || ex.InnerException.Message || "\n\n"; + endif; + if ( client_visit_obj is NOT NULL ) then + void:= call client_visit_obj.Dispose; client_visit_obj:= null; + endif; + endcatch; +/* + + +// 09.08.2016 DW HD# 2200677 - moved this earlier in the logic + +//----------------------for PPM Alert to Careprovider ---------------------- + CurrentLocation, Account := read last {"Select CurrentLocation, VisitIDCode From cv3Clientvisit with (nolock) Where Guid = " || SQL(visitGuid)||" and VisitStatus = {{{SINGLE-QUOTE}}}ADM{{{SINGLE-QUOTE}}}" }; + EndOfUnit := find "-" in string CurrentLocation; + + If EndofUnit <> 0 + then Unit:= SUBSTRING EndOfUnit -1 CHARACTERS STARTING AT 1 from CurrentLocation; + else Unit:= CurrentLocation; + endif; + + // Send a Text Message Section + + PhoneNumber := read last {" select p.AreaCode + p.PhoneNumber from CV3User u with (nolock) join Cv3Phone p with (nolock) on p.PersonGUID = u.GUID " || + " where u.displayname = {{{SINGLE-QUOTE}}}SCM, Text Messaging{{{SINGLE-QUOTE}}} and p.PhoneNote = {{{SINGLE-QUOTE}}}PPM{{{SINGLE-QUOTE}}} And p.Active =1 "}; + + Page_MLM := mlm {{{SINGLE-QUOTE}}}SCH_FUNC_PAGE{{{SINGLE-QUOTE}}}; + MessageSubject:= "Important Message"; + MessageBody := " Please call unit " || Unit || " Account # " || Account || " for Disability Risk - Mobility Impaired "; + PPMvoid := call Page_MLM with(PhoneNumber, MessageSubject, MessageBody); + +//--------------------------------------- +*/ + try + //--------------------------------------------------------- + // New HealthIssue Example + //--------------------------------------------------------- + + If chronic = "Mobility Impaired" then issuename := "Mobility impaired"; + issuecode := "Z74.09" ; //"799.89"; //CSR#23359-ICD9-ICD10 HI Change for Code Scheme ICD10- Added By shivprasad + endif; + + NewHealthIssueHIType := "Problem-Chronic"; + NewHealthIssueHICode := issuecode; + NewHealthIssueHIScheme := "ICD10"; //"ICD9"; //CSR#23359-ICD9-ICD10 HI Change for Code Scheme ICD10- Added By shivprasad + + dd := EXTRACT Day now; + mn := EXTRACT Month now; + yr := EXTRACT Year now; + + Terms := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.FindIMOTerms with (NewHealthIssueHIScheme,issuecode); + + +//--Start: CSR 23359-ICD9-ICD10 HI Change Added By shivprasad + Terms := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.FindIMOTerms with (NewHealthIssueHIScheme,NewHealthIssueHICode); + FOR i IN 1 SEQTO (Terms.Count as Number ) DO + HI_obj := Terms[i]; + HI_Name := HI_obj.TermName as string; + If HI_Name = issuename then + HI_NO := i ; + Endif; + ENDDO; + If HI_NO is Null Then + HI_NO :=1 ; + Endif; + New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with (client_visit_obj, NewHealthIssueHIType, Terms[HI_NO]); + +//--End Added by Shivprasad + + /* Terms := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.FindIMOTerms with (NewHealthIssueHIScheme,issuecode); + New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with + (client_visit_obj, NewHealthIssueHIType, Terms[177]); */ + + //New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with + // (client_visit_obj, NewHealthIssueHIType, NewHealthIssueHIScheme, NewHealthIssueHICode ); + + PartialDate_obj := new net_object {{{SINGLE-QUOTE}}}PartialDate{{{SINGLE-QUOTE}}} with (yr as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, mn as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, dd as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}} ); + New_HealthIssue_obj.OnsetDate := PartialDate_obj; + New_HealthIssue_obj.Text := "Created from ED Triage Note Screening. " ; + New_HealthIssue_obj.Name := issuename; + + + if ( New_HealthIssue_obj is NOT NULL ) then + void := call New_HealthIssue_obj.Save; + void := call New_HealthIssue_obj.Dispose; + endif; + + if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; + + endtry; + + catch exception ex + error_occurred := true; + if ( New_HealthIssue_obj is NOT NULL ) then void:= call New_HealthIssue_obj.Dispose; New_HealthIssue_obj:= null; endif; + endcatch; + + + + Elseif (dlg_result as string) = "No" then + + lst1 := theObservation.valueObj.ListItemsList ; + for i in lst1 do + if i.Isselected = true and i.value in( "Immobility Risk – Service Animal","Immobility Risk – Special Call Bell" ) then + i.IsSelected := FALSE ; + endif; + enddo; + lst2 := theObservation1.valueObj.ListItemsList ; + for i in lst2 do + if i.Isselected = true and i.value in( "Immobility Risk – Service Animal","Immobility Risk – Special Call Bell" ) then + i.IsSelected := FALSE ; + endif; + enddo; + lst3 := theObservation2.valueObj.ListItemsList ; + for i in lst3 do + if i.Isselected = true and i.value in( "Immobility Risk – Service Animal","Immobility Risk – Special Call Bell" ) then + i.IsSelected := FALSE ; + endif; + enddo; + lst4 := theObservation3.valueObj.ListItemsList ; + for i in lst4 do + if i.Isselected = true and i.value in( "Immobility Risk – Service Animal","Immobility Risk – Special Call Bell" ) then + i.IsSelected := FALSE ; + endif; + enddo; + + endif; + + endif; + +endif; + + + ;; + evoke: + ;; + logic: + +conclude true; + + ;; + action: + + + return thisDocumentCommunication; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SCH_TRIAGE_SCREENING_VISUAL.mlm b/MLMStripper/bin/Debug/DOC/DOC_SCH_TRIAGE_SCREENING_VISUAL.mlm new file mode 100644 index 0000000..c4e884f --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SCH_TRIAGE_SCREENING_VISUAL.mlm @@ -0,0 +1,324 @@ +maintenance: + + title: DOC_SCH_Triage_Screening_Visual;; + mlmname: DOC_SCH_Triage_Screening_Visual;; + arden: version 5.5;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Shivprasad Jadhav;; + specialist: ;; + date: 2015-03-05;; + validation: testing;; +library: + purpose: This MLM will create a Health Issue when an observation is charted on ED Triage Note. ;; + explanation: Create Visually Impaired HI if one does not already exist + + + + Change history + + 06.02.2012 GOS CSR:33112 - Created MLM + 09.30.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 HI Dynamic Creation with all details Like ICD10 Code, Snowmed Code etc And Duplicate HI Check Change. + 10.12.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 Coding Scheme [ICD10] And Duplicate Check of HI . + 09.08.2016 DW HD# 2200677 - Disability Risk MLM - Duplicate Health Issue - copied Prod version over dev as they didn{{{SINGLE-QUOTE}}}t match. Altered HI lookup to interrogate all visits + + + + ;; + keywords: ;; +knowledge: + type: data-driven;; + data: + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + + + +// Determine which of the Chronic Conditions boxes is checked + + this_parametername := first of (thisParameters where thisParameters.Name = "sch_edtriage_Special need"); + theObservation := first of (thisobservations where thisobservations.ParameterGUID = this_parametername.ParameterGUID); + + If true in (theObservation.ValueObj.ListItemsList.IsSelected where + theObservation.ValueObj.ListItemsList.Value = "Blind" + ) then chronic := "Blind"; // chronic := "Visually Impaired"; + endif; + + + this_parametername1 := first of (thisParameters where thisParameters.Name = "SCH_Ped_Special need"); + theObservation1 := first of (thisobservations where thisobservations.ParameterGUID = this_parametername1.ParameterGUID); + + If true in (theObservation1.ValueObj.ListItemsList.IsSelected where + theObservation1.ValueObj.ListItemsList.Value = "Blind" + ) then chronic := "Blind"; + endif; + +// for OB Patient Profile ----------------------------------------------------------------------------------------- + this_parametername2 := first of (thisParameters where thisParameters.Name = "sch_obpt_Special Need"); + theObservation2 := first of (thisobservations where thisobservations.ParameterGUID = this_parametername2.ParameterGUID); + + If true in (theObservation2.ValueObj.ListItemsList.IsSelected where + theObservation2.ValueObj.ListItemsList.Value = "Blind" + ) then chronic := "Blind"; + endif; +// for Adult Patient Profile ----------------------------------------------------------------------------------------- + this_parametername3 := first of (thisParameters where thisParameters.Name = "SCH_Adultpt_Special need"); + theObservation3 := first of (thisobservations where thisobservations.ParameterGUID = this_parametername3.ParameterGUID); + + If true in (theObservation3.ValueObj.ListItemsList.IsSelected where + theObservation3.ValueObj.ListItemsList.Value = "Blind" + ) then chronic := "Blind"; + endif; +//------------------------------------------------------------------------------------------------------------------------- + + + +// If the patient have health issue, determine if they already have a Health Issue in their record + + If chronic = "Blind" then + + +//----------------------for PPM Alert to Careprovider ---------------------- + CurrentLocation, Account := read last {"Select CurrentLocation, VisitIDCode From cv3Clientvisit with (nolock) Where Guid = " || SQL(visitGuid)||" " }; + EndOfUnit := find "-" in string CurrentLocation; + + If EndofUnit <> 0 + then Unit:= SUBSTRING EndOfUnit -1 CHARACTERS STARTING AT 1 from CurrentLocation; + else Unit:= CurrentLocation; + endif; + + // Send a Text Message Section + + PhoneNumber := read last {" select p.AreaCode + p.PhoneNumber from CV3User u with (nolock) join Cv3Phone p with (nolock) on p.PersonGUID = u.GUID " || + " where u.displayname = {{{SINGLE-QUOTE}}}SCM, Text Messaging{{{SINGLE-QUOTE}}} and p.PhoneNote = {{{SINGLE-QUOTE}}}PPM{{{SINGLE-QUOTE}}} And p.Active =1 "}; + + Page_MLM := mlm {{{SINGLE-QUOTE}}}SCH_FUNC_PAGE{{{SINGLE-QUOTE}}}; + MessageSubject:= "Important Message"; + MessageBody := " Please call unit " || Unit || " Account # " || Account || " for Disability Risk - Blind "; + PPMvoid := call Page_MLM with(PhoneNumber, MessageSubject, MessageBody); + +//--------------------------------------- + + + + (VisualImpHI) := read {" select distinct hi.shortname " + || "from cv3healthissuedeclaration hi with (nolock) " + || "join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID " + || "where hi.clientguid = " || clientGuid || " and hi.active = 1 and hi.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " + || " and hi.typecode = {{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}} " + || " And hi.ICD10Code is not null " // Added By Shivprasad on 29 Sept 2015 for ICD9-10 Changes + || "and ( " + || "hi.text like {{{SINGLE-QUOTE}}}%Blind%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%Blind%{{{SINGLE-QUOTE}}} or " + || " " + || "(Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}} then chi.code when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}369.00{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}H54.0{{{SINGLE-QUOTE}}}) " //CSR#23359-ICD9-ICD10 HI Change for Code Scheme ICD10- Added By shivprasad + || " ) " + }; + + +// 09.08.2016 DW HD# 2200677 - removed the firstline and replaced the second line below which will direct the SQL to look across all visits for a chronic HI + +// || " AND ({{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} AND ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}} OR ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}} AND hi.ChartGUID = " || SQL(chartGuid) || " ) OR hi.ClientVisitGUID = " || SQL(visitGuid) || " ) ) " +// || "and hi.typecode not in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}chronic dx{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}dx comments{{{SINGLE-QUOTE}}}) " + + +// Notify the user if a new Health Issue is about to be created and permit them to reverse them to cancel the process + + If not exists VisualImpHI AND thisDocumentCommunication.EventType <> "DocumentOpening" then + + dlg_result := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with + "\n This selection will create a chronic health issue of {{{SINGLE-QUOTE}}}" || chronic || "{{{SINGLE-QUOTE}}}" || + "\n\n Click {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} to confirm your selection. " || + "\n\n Click {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} if you wish to change your selection. " || + "\n " + ,"Confirm {{{SINGLE-QUOTE}}}" || chronic || "{{{SINGLE-QUOTE}}} Documentation ", "YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}} ; + + +// If the user responds by cliking the "Yes" button, proceed with creating the order + + If (dlg_result as string) = "Yes" then + + try + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + endtry; + + catch Exception ex + error_occurred := true; + error_message := "{{+R}}Retrieve client:{{-R}}\n" || + ex.Message || "\n\n"; + if ex.InnerException is not null net_object then + error_message := error_message || "Inner Exception: " || ex.InnerException.Message || "\n\n"; + endif; + if ( client_visit_obj is NOT NULL ) then + void:= call client_visit_obj.Dispose; client_visit_obj:= null; + endif; + endcatch; + +/* + +// 09.08.2016 DW HD# 2200677 - moved this earlier in the logic + +//----------------------for PPM Alert to Careprovider ---------------------- + CurrentLocation, Account := read last {"Select CurrentLocation, VisitIDCode From cv3Clientvisit with (nolock) Where Guid = " || SQL(visitGuid)||" and VisitStatus = {{{SINGLE-QUOTE}}}ADM{{{SINGLE-QUOTE}}}" }; + EndOfUnit := find "-" in string CurrentLocation; + + If EndofUnit <> 0 + then Unit:= SUBSTRING EndOfUnit -1 CHARACTERS STARTING AT 1 from CurrentLocation; + else Unit:= CurrentLocation; + endif; + + // Send a Text Message Section + + PhoneNumber := read last {" select p.AreaCode + p.PhoneNumber from CV3User u with (nolock) join Cv3Phone p with (nolock) on p.PersonGUID = u.GUID " || + " where u.displayname = {{{SINGLE-QUOTE}}}SCM, Text Messaging{{{SINGLE-QUOTE}}} and p.PhoneNote = {{{SINGLE-QUOTE}}}PPM{{{SINGLE-QUOTE}}} And p.Active =1 "}; + + Page_MLM := mlm {{{SINGLE-QUOTE}}}SCH_FUNC_PAGE{{{SINGLE-QUOTE}}}; + MessageSubject:= "Important Message"; + MessageBody := " Please call unit " || Unit || " Account # " || Account || " for Disability Risk - Blind "; + PPMvoid := call Page_MLM with(PhoneNumber, MessageSubject, MessageBody); + +//--------------------------------------- +*/ + try + //--------------------------------------------------------- + // New HealthIssue Example + //--------------------------------------------------------- + + If chronic = "Blind" then issuename := "Blind"; + issuecode := "H54.0" ; //"369.00"; //CSR#23359-ICD9-ICD10 HI Change for Code Scheme ICD10- Added By shivprasad + endif; + + NewHealthIssueHIType := "Problem-Chronic"; + NewHealthIssueHICode := issuecode; + NewHealthIssueHIScheme := "ICD10" ; //"ICD9"; //CSR#23359-ICD9-ICD10 HI Change for Coding Scheme ICD10- Added By shivprasad + + dd := EXTRACT Day now; + mn := EXTRACT Month now; + yr := EXTRACT Year now; + + Terms := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.FindIMOTerms with (NewHealthIssueHIScheme,issuecode); + +//--Start: CSR 23359-ICD9-ICD10 HI Change Added By shivprasad + Terms := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.FindIMOTerms with (NewHealthIssueHIScheme,NewHealthIssueHICode); + FOR i IN 1 SEQTO (Terms.Count as Number ) DO + HI_obj := Terms[i]; + HI_Name := HI_obj.TermName as string; + If HI_Name = issuename then + HI_NO := i ; + Endif; + ENDDO; + If HI_NO is Null Then + HI_NO :=1 ; + Endif; + New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with (client_visit_obj, NewHealthIssueHIType, Terms[HI_NO]); + +//--End Added by Shivprasad + + /* Terms := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.FindIMOTerms with (NewHealthIssueHIScheme,issuecode); + + New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with + (client_visit_obj, NewHealthIssueHIType, Terms[8]); */ + + //New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with + // (client_visit_obj, NewHealthIssueHIType, NewHealthIssueHIScheme, NewHealthIssueHICode ); + + PartialDate_obj := new net_object {{{SINGLE-QUOTE}}}PartialDate{{{SINGLE-QUOTE}}} with (yr as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, mn as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, dd as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}} ); + New_HealthIssue_obj.OnsetDate := PartialDate_obj; + New_HealthIssue_obj.Text := "Created from ED Triage Note Screening. " ; + New_HealthIssue_obj.Name := issuename; + + + if ( New_HealthIssue_obj is NOT NULL ) then + void := call New_HealthIssue_obj.Save; + void := call New_HealthIssue_obj.Dispose; + endif; + + if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; + + endtry; + + catch exception ex + error_occurred := true; + if ( New_HealthIssue_obj is NOT NULL ) then void:= call New_HealthIssue_obj.Dispose; New_HealthIssue_obj:= null; endif; + endcatch; + + + + Elseif (dlg_result as string) = "No" then + + //void:= ""; + lst1 := theObservation.valueObj.ListItemsList ; + for i in lst1 do + if i.Isselected = true and i.value = "Blind" then + i.IsSelected := FALSE ; + endif; + enddo; + + lst2 := theObservation1.valueObj.ListItemsList ; + for i in lst2 do + if i.Isselected = true and i.value = "Blind" then + i.IsSelected := FALSE ; + endif; + enddo; + lst3 := theObservation2.valueObj.ListItemsList ; + for i in lst3 do + if i.Isselected = true and i.value = "Blind" then + i.IsSelected := FALSE ; + endif; + enddo; + lst4 := theObservation3.valueObj.ListItemsList ; + for i in lst4 do + if i.Isselected = true and i.value = "Blind" then + i.IsSelected := FALSE ; + endif; + enddo; + + + endif; // If exists CHFHI + + endif; // If (dlg_result as string) = "Yes" + +endif; // If chronic = "CHF" + + + ;; + evoke: + ;; + logic: + +conclude true; + + ;; + action: + + + return thisDocumentCommunication; + + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SELECT_PRINT_DISCHAGE_INSTRUCTIONS.mlm b/MLMStripper/bin/Debug/DOC/DOC_SELECT_PRINT_DISCHAGE_INSTRUCTIONS.mlm new file mode 100644 index 0000000..541878b --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SELECT_PRINT_DISCHAGE_INSTRUCTIONS.mlm @@ -0,0 +1,46 @@ +maintenance: + + title: DOC_SELECT_PRINT_DISCHAGE_INSTRUCTIONS;; + mlmname: DOC_SELECT_PRINT_DISCHAGE_INSTRUCTIONS;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Janet Nordin;; + specialist: Don Warnick ;; + date: 2017-10-31;; + validation: testing;; + +library: + purpose: + ;; + explanation: This MLM will call functional MLMs to be run upon selection of the "Print Discharge Instructons" button + + Change history + + 10.31.2017 DW CSR# 36030 Elder Risk (renamed Risk Category then renamed Readmission Risk) + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + (thisDocumentCommunication) := argument; + DischargeSummary := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_DISCHARGE_SUMMARY{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DischargeSummary WITH thisDocumentCommunication; + + + (thisDocumentCommunication) := argument; + RiskCategory := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_RISK_CATEGORY{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL RiskCategory WITH thisDocumentCommunication; + + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SEPSIS_STATUS_BOARD_COLUMN_ED.mlm b/MLMStripper/bin/Debug/DOC/DOC_SEPSIS_STATUS_BOARD_COLUMN_ED.mlm new file mode 100644 index 0000000..841b567 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SEPSIS_STATUS_BOARD_COLUMN_ED.mlm @@ -0,0 +1,317 @@ +maintenance: + + title: DOC_SEPSIS_STATUS_BOARD_COLUMN_ED;; + mlmname: DOC_SEPSIS_STATUS_BOARD_COLUMN_ED;; + arden: version 4.5;; + version: 2.00;; + institution: St. Clair Hospital ;; + author: Sandy Zhang ;; + specialist: Peggy Karish ;; + date: 2017-05-03;; + validation: testing;; + +library: + purpose: Update the SIRS Alert column of ED status board with "Potential SIRS" if a patient has a combination of abnormal lab values and vital signs. This MLM determines potentially septic patients + at an early stage and helps ED physicians initiate early stage therapy to reduce mortality attributed to sepsis and SIRS. + ;; + explanation: + Change history + + 05.03.2017 SZ CSR# 35113 SIRS Sepsis Alert ED + + ;; + keywords: SIRS, sepsis + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + + (this_doc_com) := argument; + + /*************Make changes to spelling and flags in this section****************/ + //parameter names in config + temp_param := "sch_edtriage_fahrenheit NU"; + hr_param := "sch_edtriage_heart rate"; + rr_param := "sch_edtriage_resp rate"; + + column_name1 := "Sepsis Alert"; + column_value1 := "Potential SIRS"; + + //associated configurations (in config tools): + //Struct Note: "sch_edtriage_triage note" + //FS Catalog: "SCH_Vital Sign_ED_Version" + //Doc. Cat. - Flowsheet: "1. Vital Sign - ED" + //Doc. Cat. - Structured Note: "ED Triage Note" + + //associated MLMs: + // universal mlm for closing of Flowsheet: DOC_ED_VITAL_SIGNS_CLOSE + // universal MLM for closing of Structured Note: DOC_ED_TRIAGE_NOTE_CLOSE + + //when moving live, these 2 MLMs need to be added to prodiction: + // 1) DOC_SEPSIS_STATUS_BOARD_COLUMN_ED + // 2) DOC_ED_VITAL_SIGNS_CLOSE + // 3) then change config for Doc. Cat. - Flowsheet: "1. Vital Sign - ED" + /********************************************************************************/ + + //** setting up for Lab Section conditional ** + standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + error_occurred := false; + error_message := ""; + log_execution_info := false; + + // Error Destinations + error_destination := destination { Alert } with [alert_type := "Warning",short_message := "ObjectsPlus Error from MLM",priority := "low",scope := "chart",Rule_group := "ObjectsPlus Error from MLM", + Rule_number := 1003,Rule_subgroup := "",Send_alert_with_order := "", Alert_dialog_settings := "",Display_alert := true ]; + + If called_by_editor then EvokingObject := read last { Observation: This }; endif; // If called by the editor + + // Declaring evoking event triggers + observation_enter_event := event {ObservationEnter ANY Observation: WHERE Itemname matches pattern "Immature Granulocyte %" or Itemname = "Band % (Manual)" or Itemname = "White Blood Cell Count" }; + + // set default of no for lab result of interest variable + labresultofinterest := "no"; + + + // This conditional checks the source that{{{SINGLE-QUOTE}}}s evoking this MLM and grabs value from the source to be stored for future use. + // ** Lab Section ** First if statement checks if evoking object is the Lab result coming in from interface + if (evokingobject is not null) then + + // get and store GUIDs for the evoking lab value + (ClientGUID, ChartGUID, ClientVisitGUID) := read last {Observation: clientGuid, chartguid, clientvisitguid REFERENCING EvokingObject}; + + // get and store lab value {{{SINGLE-QUOTE}}}as a number{{{SINGLE-QUOTE}}} and name of lab value + (resultValue, itemname) := read last {Observation: Value,itemname REFERENCING EvokingObject}; + resultValueNumeric := resultValue as number; + + + // conditional to set labresultofinterest to {{{SINGLE-QUOTE}}}yes{{{SINGLE-QUOTE}}} if value is abnormal + if (itemname = "Immature Granulocyte %" and resultValueNumeric > 10.0) then + labresultofinterest := "yes"; + elseif (itemname = "White Blood Cell Count" and (resultValueNumeric < 4.0 or resultValueNumeric > 12.0)) then + labresultofinterest := "yes"; + elseif (itemname = "Band % (Manual)" and resultValueNumeric > 3.0) then + labresultofinterest := "yes"; + endif; + + // ** Flowsheet Vital Signs Section ** Checks if the evoking object is a flowsheet and if so then it stores values from the flowsheet for future use. + // Associated with config tools Doc. Cat.: "1. Vital Sign - ED" + elseif (this_doc_com.documenttype = "flowsheet") then + + fs_doc_config_obj := this_doc_com.DocumentConfigurationObj; + this_parms := fs_doc_config_obj.ParametersList; + this_cols := fs_doc_config_obj.ColumnsList; + + //get guids + ClientGUID := this_doc_com.ClientGUID; + ChartGUID := this_doc_com.ChartGUID; + ClientVisitGUID := this_doc_com.ClientVisitGUID; + + //initialize our validation lists + temp_val_list := (); + hr_val_list := (); + rr_val_list := (); + + //get guids for later use + temp_guid := last(this_parms.ParameterGUID where this_parms.Name = temp_param) as string; + hr_guid := last(this_parms.parameterguid where this_parms.Name = hr_param) as string; + rr_guid := last(this_parms.ParameterGUID where this_parms.Name = rr_param) as string; + + //March across the columns and get observation values and add them to previously inialized lists. <-- this feature doesn{{{SINGLE-QUOTE}}}t work anymore as chartedobservationslist[i] returns () empty list for all columns + //except current column. I kept this code since I can still get current column values using it. + for j in 1 seqto (count this_cols) do //loops through each column + (this_obs) := this_cols[j].chartedobservationslist; //the chartedObservationsList of each column is suppoed to bring up: observationGUID, clientDocumentGUID, ParameterGUID, DataType, and ValueObj + + //if the temperature guid is in the + if temp_guid is in (this_obs.parameterguid) then //if guid for temperature matches the parameterguid for + temp_val_obj := (this_obs.valueobj where this_obs.parameterguid = temp_guid); //now put it in the list + temp_val_list := temp_val_list,(temp_val_obj.value as number); + endif; + + if hr_guid is in (this_obs.parameterguid) then //if guid for temperature matches the parameterguid for + hr_val_obj := (this_obs.valueobj where this_obs.parameterguid = hr_guid); //now put it in the list + hr_val_list := hr_val_list, (hr_val_obj.value as number); + endif; + + if rr_guid is in (this_obs.parameterguid) then //if guid for temperature matches the parameterguid for + rr_val_obj := (this_obs.valueobj where this_obs.parameterguid = rr_guid); //now put it in the list + rr_val_list := rr_val_list, (rr_val_obj.value as number); + endif; + enddo; + + + // determine the maximum of values from each list + current_col_temp := max(temp_val_list); + current_col_hr := max(hr_val_list); + current_col_rr := max(rr_val_list); + + if (current_col_temp >= 100.4 or current_col_temp < 96.8) then + TEMP_DOC_abnormal := true; + endif; + + if (current_col_hr > 100) then + HR_DOC_abnormal := true; + endif; + + if (current_col_rr >= 22) then + RR_DOC_abnormal := true; + endif; + + + + // ** Structured Notes Vital Signs Section ** Checks if the evoking object is a structured note and if so then it stores values from structured sote for future use. + // Associated with config tools Doc. Cat.: "ED Triage Note" + elseif (this_doc_com.documenttype = "structurednote") then + + + fs_doc_config_obj := this_doc_com.DocumentConfigurationObj; + this_parms := fs_doc_config_obj.ParametersList; + this_obs_list := fs_doc_config_obj.ChartedObservationsList; + + //get guids + ClientGUID := this_doc_com.ClientGUID; + ChartGUID := this_doc_com.ChartGUID; + ClientVisitGUID := this_doc_com.ClientVisitGUID; + + //get parameter guids by matching parameter names. (EX. parameter name for temperature is "sch_edtriage_fahrenheit NU" + temp_guid := last(this_parms.ParameterGUID where this_parms.Name = temp_param) as string; + hr_guid := last(this_parms.parameterguid where this_parms.Name = hr_param) as string; + rr_guid := last(this_parms.ParameterGUID where this_parms.Name = rr_param) as string; + + //get the recently entered values for temp, hr, and rr by matching parameterguids. For some reason the values are returned with a {{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}} in front indicating a list + temp_list := (this_obs_list.valueobj.value where this_obs_list.parameterguid = temp_guid); //now put it in the list + hr_list := (this_obs_list.valueobj.value where this_obs_list.parameterguid = hr_guid); //now put it in the list + rr_list := (this_obs_list.valueobj.value where this_obs_list.parameterguid = rr_guid); //now put it in the list + + //grabs the largest number of the list + current_SN_temp := MAX(temp_list); + current_SN_hr := MAX(hr_list); + current_SN_rr := MAX(rr_list); + + if (current_SN_temp >= 100.4 or current_SN_temp < 96.8) then + TEMP_DOC_abnormal := true; + endif; + + if (current_SN_hr > 100) then + HR_DOC_abnormal := true; + endif; + + if (current_SN_rr >= 22) then + RR_DOC_abnormal := true; + endif; + + endif; //end of entire lab/flowsheet/SN conditional + + + + /*Common section***************************************************************************************/ + // using sql to grab abnormal vitall sign values and storing them as a list + vitalsigns := read + { + "select" + ||" case when ocmi.description = {{{SINGLE-QUOTE}}}Heart Rate{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}}" + ||" when ocmi.description = {{{SINGLE-QUOTE}}}Fahrenheit{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}}" + ||" when ocmi.description = {{{SINGLE-QUOTE}}}Respiratory Rate{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}3{{{SINGLE-QUOTE}}}" + ||" end" + ||" from CV3ActiveVisitList avl with (nolock)" + ||" join CV3ClientDocumentCUR cd with (nolock) ON cd.ClientGUID = avl.ClientGUID and cd.ChartGUID = avl.ChartGUID and cd.ClientVisitGUID = avl.GUID " + ||" join CV3ClientDocDetailCUR cdd with (nolock) ON cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.ClientGUID AND cdd.ArcType = cd.ArcType" + ||" join CV3ObservationDocumentCUR od with (nolock) ON od.OwnerGUID = cdd.CLientDocumentGUID AND od.ArcType = cdd.ArcType" + ||" join CV3ObsCatalogMasterItem ocmi with (nolock) ON ocmi.GUID = od.ObsMasterItemGUID" + ||" join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID and o.ArcType = cdd.ArcType" + ||" where cd.ClientGUID = " || sql(ClientGUID) + ||" and avl.VisitStatus = {{{SINGLE-QUOTE}}}adm{{{SINGLE-QUOTE}}} and avl.CurrentLocation like {{{SINGLE-QUOTE}}}er%{{{SINGLE-QUOTE}}} and avl.DischargeDtm is null" + ||" and od.active = 1 and cdd.active = 1 and cd.IsCanceled = 0" + ||" and cd.DocumentName in ({{{SINGLE-QUOTE}}}ED Triage Note{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}1. Vital Sign - ED{{{SINGLE-QUOTE}}})" + ||" and ( (ocmi.description = {{{SINGLE-QUOTE}}}Heart Rate{{{SINGLE-QUOTE}}} and o.ValueText > 100)" + ||" or (ocmi.description = {{{SINGLE-QUOTE}}}Fahrenheit{{{SINGLE-QUOTE}}} and (o.ValueText >= 100.4 or o.ValueText < 96.8))" + ||" or (ocmi.description = {{{SINGLE-QUOTE}}}Respiratory Rate{{{SINGLE-QUOTE}}} and o.ValueText >= 22) )" + }; + + // these variables turn true if certain abnormal vital sign values are present, these numbers (1,2,3) correlate with SQL above. + HR_sql_abnormal := 1 IS IN (vitalsigns as number); + TEMP_sql_abnormal := 2 IS IN (vitalsigns as number); + RR_sql_abnormal := 3 IS IN (vitalsigns as number); + + + + //grab any of the patient{{{SINGLE-QUOTE}}}s abnormal lab values + lab_of_interest_sql := read last + { + " select top 1(bo.value)" + || " from CV3ActiveVisitList avl with (nolock)" + || " left join CV3BasicObservation bo with (nolock) on bo.ClientGUID = avl.ClientGUID and bo.ChartGUID = avl.ChartGUID and bo.ClientVisitGUID = avl.guid" + || " where avl.VisitStatus = {{{SINGLE-QUOTE}}}adm{{{SINGLE-QUOTE}}} and avl.CurrentLocation like {{{SINGLE-QUOTE}}}er%{{{SINGLE-QUOTE}}} and avl.DischargeDtm is null" + || " and" + || " (" + || " ( bo.ItemName = {{{SINGLE-QUOTE}}}White Blood Cell Count{{{SINGLE-QUOTE}}} and (bo.value < 4.00 or bo.value > 12.00) ) or" + || " ( bo.ItemName = {{{SINGLE-QUOTE}}}Immature Granulocyte %{{{SINGLE-QUOTE}}} and bo.value > 10.0 ) or" + || " (bo.ItemName like {{{SINGLE-QUOTE}}}%Band%{{{SINGLE-QUOTE}}} and bo.value > 3.0 )" + || " )" + || " and bo.ishistory = 0" + || " and avl.ClientGUID = " || sql(ClientGUID) + }; + + //if there is any abnormal lab value, then we have a lab result of interest + if (lab_of_interest_sql is not null) then + labresultofinterest := "yes"; + endif; + + //Setting up our mlm to be called and our object. Instantiate sepsis_column using our created object. + create_ED_column := MLM {{{SINGLE-QUOTE}}}SCH_FUNC_CREATE_ENTERPRISE_DEFINED_COLUMN{{{SINGLE-QUOTE}}}; // MLM that creates the Enterprise Defined Column in the "Action" section of the MLM + EDCObj := OBJECT [column_name,column_value,client_guid,chart_guid,client_visit_guid]; // Create Enterprise Defined Column Obj + Sepsis_Column:= NEW EDCObj WITH + [ + column_name := column_name1, + column_value := column_value1, + client_guid := ClientGUID, + chart_guid := ChartGUID, + client_visit_guid := ClientVisitGUID + ]; + + + // Checks if WBC/Bands/granulocytes are abnormal, if so then proceed. If normal then jump down to elseif. + if (labresultofinterest = "yes") then + // Checks if temp is abnormal. If so then fire sepsis display, if normal then proceed to check HR/RR. + if ((TEMP_sql_abnormal = true) or (TEMP_DOC_abnormal = true)) then + //calls our MLM with instantiated object + return_value := call create_ED_column with ( Sepsis_Column ); + // Checks if HR/RR is abnormal, if so then fire sepsis display. If normal then stop. + elseif ((HR_sql_abnormal = true) or (HR_DOC_abnormal = true) or (RR_sql_abnormal = true) or (RR_DOC_abnormal = true)) then + //calls our MLM with instantiated object + return_value := call create_ED_column with ( Sepsis_Column ); + endif; + + + // enter this conditional only if WBC/Bands/granulocytes are normal + // Checks if temperature is normal. If abnormal, then proceed, if normal then stop. + elseif ((TEMP_sql_abnormal = true) or (TEMP_DOC_abnormal = true)) then + // Checks if hr/rr are abnormal, if so then fire sepsis display, if normal then stop + if ((HR_sql_abnormal = true) or (HR_DOC_abnormal = true) or (RR_sql_abnormal = true) or (RR_DOC_abnormal = true)) then + //calls our MLM with instantiated object + return_value := call create_ED_column with ( Sepsis_Column ); + endif; + endif; + + + + ;; + priority: 50 + ;; + evoke: observation_enter_event; + ;; + logic: conclude true; + ;; + action: return this_doc_com; + + if Error_occurred + then + write "An error has occured in the MLM {{+B}}DOC_SEPSIS_STATUS_BOARD_COLUMN_ED{{-B}} Please notify your System Administrators that an error message has occurred for this patient. They will review the following error message: \n" at error_destination; + write error_message at error_destination; + endif; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SMP_CHECK_DAYLIGHT_SAVINGS_TIME.mlm b/MLMStripper/bin/Debug/DOC/DOC_SMP_CHECK_DAYLIGHT_SAVINGS_TIME.mlm new file mode 100644 index 0000000..c65c860 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SMP_CHECK_DAYLIGHT_SAVINGS_TIME.mlm @@ -0,0 +1,96 @@ +maintenance: + + title: DOC_SMP_CHECK_DAYLIGHT_SAVINGS_TIME;; + mlmname: DOC_SMP_CHECK_DAYLIGHT_SAVINGS_TIME;; + arden: version 2.5;; + version: 16.3;; + institution: ALLSCRIPTS;; + author: ALLSCIPTS SUPPORT;; + specialist: ;; + date: 2019-02-19;; + validation: testing;; + +library: + purpose: + To prevent duplicate time column issues by blocking the saving of documents between + 2:00 AM and 2:59 AM for clients who have not installed SCM 16.3 CU15 or SCM 17.3 CU5. + This MLM must be attached to all Structured Notes that fan out to Flowsheets. + +*** Allscripts Disclaimer: + Client is responsible for all decisions, acts, and omissions of any persons in connection with the delivery of medical care or other services to any patients. + Before any Licensed Materials are placed into a live production environment, it is Client’s responsibility to review and test all Licensed Materials and associated + workflows and other content, as implemented, make independent decisions about system settings and configuration based upon Client’s needs, practices, standards and + environment, and reach its own independent determination that they are appropriate for such live production use. Any such use by Client (or its Authorized Users) + will constitute Client’s representation that it has complied with the foregoing. Client shall ensure that all Authorized Users are appropriately trained in use of + the then-deployed release of the Software prior to their use of the Software in a live production environment. Clinical Materials are tools to assist Authorized + Users in the delivery of medical care, but should not be viewed as prescriptive or authoritative. Clinical Materials are not a substitute for, and Client shall + ensure that each Authorized User applies in conjunction with the use thereof, independent professional medical judgment. Clinical Materials are not designed for use, + and Client shall not use them, in any system that provides medical care without the participation of properly trained personnel. Any live production use of Clinical + Materials by Client (or its Authorized Users) will constitute Client’s acceptance of clinical responsibility for the use of such materials. + ;; + explanation: + MLM will check the service date time, or authored date time if service date time is not used, and prevent the saving of the note + if the time is between 2:00 AM and 2:59 on the date of daylight savings time change. + + Change history + + 03.05.2019 DW CSR# 38048 - Alert to mitigate Daylight Savings Time issue present 16.3 CU10 PR54 (corrected later) + + + ;; + keywords: + Daylight Savings Time, DST + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + thisDocumentCommunication := argument; + thisStructuredNote := thisDocumentCommunication.DocumentConfigurationObj; + +//DSTDate is defaulted to March 10, 2019. Clients outside of United States and Canada +//must set DSTDate to the date daylight savings time begins for their location. + DSTDate := "March 10,2019"; + // DSTDate := "March 08,2019"; + + BlockStart := DSTDate || " 2:00 AM"; + BlockEnd := DSTDate || " 2:59 AM"; + DSTMessage := "Daylight Savings Time has occurred.\n" + || "You can not enter a note between \n" + || "2:00 AM and 2:59 AM on " || DSTDate || ". \n" + || "Please change the time on the note"; + + BlockStart := BlockStart as time; + BlockEnd := BlockEnd as time; + + if exists thisStructuredNote.ServiceDateTime then + DocumentTime := thisStructuredNote.ServiceDateTime; + else + DocumentTime := thisStructuredNote.AuthoredDateTime; + endif; + + BlockStartSQL := read last {"Select " || SQL(BlockStart)}; + BlockEndSQL := read last {"Select " || SQL(BlockEnd)}; + DocumentTimeSQL := read last {"Select " || SQL(DocumentTime)}; + + if DocumentTimeSQL >= BlockStartSQL and DocumentTimeSQL <= BlockEndSQL then + thisDocumentCommunication.DisplayMessage := true; + thisDocumentCommunication.Message := DSTMessage; + thisDocumentCommunication.CancelEvent := true; + endif; + + + ;; + priority: 50 + ;; + evoke: + ;; + logic: + Conclude true; + ;; + action: + return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_STD_HOME_MED_SUMMARY.mlm b/MLMStripper/bin/Debug/DOC/DOC_STD_HOME_MED_SUMMARY.mlm new file mode 100644 index 0000000..75aaac5 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_STD_HOME_MED_SUMMARY.mlm @@ -0,0 +1,474 @@ +maintenance: + + title: Home Medication Summary upon Discharge;; + mlmname: DOC_STD_HOME_MED_SUMMARY;; + arden: version 2.5;; + version: 5.50;; //FP1 + institution: Allscripts, Standard Document Called MLM ;; + author: Allscripts Healthcare Solutions, Inc. ;; + specialist: ;; + date: 2011-09-07;; + validation: testing ;; + +library: + purpose: This MLM demonstrates the ability to generate a list of home medication + for patient upon discharge. + ;; + explanation: As part of discharge workflow, hospitals are obliged to provide the patient + with a document/report that list all of the home medications patient will + be sent home with. Currently, there is no easy way to enable users to create + such document/report. To resolve that MLMs is created to get patient’s home + medication records from Outpatient Medication Profile tables. Once the + medication records are retrieved into the Structured Note, the hospital + can save the note as patient’s documentation + + ;; + keywords: Discharge; home medication; Document Called MLM + ;; +knowledge: + type: data-driven;; + data: + + (this_documentCommunication) := argument; + + /***********Make Changes To Spelling And Flags In This Section**********/ + /* Set to true if a decision.log is needed.*/ + log_execution_info := false; + /************************************************************************/ + + + + //*** Variable and Constant Declaration ***// + // this is the Part III MLM that updates the document object. + WriteToNote_MLM := MLM {{{SINGLE-QUOTE}}}STD_FUNC_DOC_WRITE_TO_DOCUMENT{{{SINGLE-QUOTE}}} ; + REPLACECHAR_MLM := MLM {{{SINGLE-QUOTE}}}STD_FUNC_DOC_REPLACE_CHAR{{{SINGLE-QUOTE}}}; + // this is the parameter in the structure note, charting on it triggers this MLM. + target_parameter_name := "med_rec_summary_text";//"Out_Patient_Rx_Reconciliation" ; + TAB := 9 formatted with "%c" ; + (this_structuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (this_parameters) := this_structuredNoteDoc.ParametersList; + (this_event) := this_documentCommunication.EventType ; + (client_guid) := this_documentCommunication.ClientGUID; + (client_chart_guid) := this_documentCommunication.ChartGUID; + (client_visit_guid) := this_documentCommunication.ClientVisitGUID; + (this_document_name) := this_documentCommunication.DocumentName ; + (this_parameters_display_name) := this_parameters.DisplayName ; + (this_currentObj) := this_documentCommunication.CurrentObservationObj ; + + + return_string:=""; + target_parameter := first of (this_Parameters + WHERE this_Parameters.Name = target_parameter_name); + + if called_by_editor then + (client_visit_guid, client_guid, client_chart_guid) := + READ LAST{ClientVisit:GUID,ClientGUID, ChartGUID}; + endif; + + ReviewStatus :=READ FIRST {"SELECT ReviewStatusType FROM SXAAMBOrderMedRecReview " || + "WHERE ClientGUID= " || sql(client_guid) || " and VisitGUID= " || + sql(client_visit_guid) }; + DischargeReconcileStatus :=READ FIRST {"SELECT ReconcileStatusType from CV3OrderReconcile " || + "WHERE ClientGUID = " || sql(client_guid) || " AND ClientVisitGUID = " || + sql(client_visit_guid) }; + if (not exists DischargeReconcileStatus) then DischargeReconcileStatus:=1; endif; + if (not exists ReviewStatus) then ReviewStatus:=0; endif; + Med_Obj := OBJECT [ PrescriptionID,Name, GenericNameID,GenericItemID,Instructions, + Comments,IsFreeText,ChangeDesc ] ; + + + HomeMeds:= READ AS Med_Obj{" exec SXASvcHomeMedsSELPR " + || sql(client_guid) + || "," || sql(client_visit_guid) }; + + DischargeMeds:= READ AS Med_Obj{" exec SXASvcDischargeMedsSELPR " + || sql(client_guid) + || "," || sql(client_visit_guid) }; + + + IF EXIST HomeMeds AND Exist DischargeMeds THEN + tmpHomeMed2 := new med_Obj;tmpHomeMed2 := (); + FOR ictr IN 1 SEQTO COUNT OF DischargeMeds DO // loop through DischargeMeds + tmpHomeMed := (HomeMeds WHERE + HomeMeds.GenericNameID = DischargeMeds[ictr].GenericNameID OR + (HomeMeds.IsFreeText = 1 AND DischargeMeds[ictr].IsFreeText = 1 AND + HomeMeds.Name = DischargeMeds[ictr].Name)); + + if not exists tmpHomeMed then + DischargeMeds[ictr].ChangeDesc := "NEW"; + else + tmpHomeMed2 := (tmpHomeMed WHERE ( + ( (tmpHomeMed.GenericItemID is null AND + DischargeMeds[ictr].GenericItemID is null OR + tmpHomeMed.GenericItemID = DischargeMeds[ictr].GenericItemID) AND + (tmpHomeMed.Instructions is null AND + DischargeMeds[ictr].Instruction is null OR + tmpHomeMed.Instructions = DischargeMeds[ictr].Instructions) + ) OR + (tmpHomeMed.IsFreeText = 1 AND + DischargeMeds[ictr].IsFreeText = 1 AND + tmpHomeMed.Name = DischargeMeds[ictr].Name AND + tmpHomeMed.Instructions = DischargeMeds[ictr].Instructions + ) + ) + ); + + + if exists tmpHomeMed2 then + DischargeMeds[ictr].ChangeDesc := "NO CHANGE" ; + else + DischargeMeds[ictr].ChangeDesc := "CHANGED" ; + Endif; + + // Reset + tmpHomeMed:=""; + tmpHomeMed2:=""; + endif; + ENDDO; + + FOR ictr IN 1 SEQTO COUNT OF HomeMeds DO + tmpDCMed := new med_Obj; + + tmpDCMed := (DischargeMeds WHERE + DischargeMeds.GenericNameID = HomeMeds[ictr].GenericNameID OR + (DischargeMeds.IsFreeText = 1 AND HomeMeds[ictr].IsFreeText = 1 AND + DischargeMeds.Name = HomeMeds[ictr].Name )); + if not exist tmpDCMed then + HomeMeds[ictr].ChangeDesc := "STOP"; + endif; //if not exist tmpDCMed then + ENDDO; // FOR ictr IN 1 SEQTO COUNT OF HomeMeds DO + ELSEIF NOT EXIST HomeMeds AND EXIST DischargeMeds THEN + FOR ictr IN 1 SEQTO COUNT OF DischargeMeds DO + DischargeMeds[ictr].ChangeDesc := "NEW"; + ENDDO; + ELSEIF EXIST HomeMeds AND NOT EXIST DischargeMeds THEN + FOR ictr IN 1 SEQTO COUNT OF HomeMeds DO + HomeMeds[ictr].ChangeDesc := "STOP"; + ENDDO; + ENDIF; // IF EXIST HomeMeds AND Exist DischargeMeds THEN + + HEADER1_ON:="\f1\fs28 \b1"; + HEADER1_OFF:="\b0 \fs0"; + HEADER2_ON:="\f1\fs24 \b1"; + HEADER2_OFF:="\b0 \fs0"; + HEADER3_ON:="\f1\fs22 \b1"; + HEADER3_OFF:="\b0 \fs0"; + BODY_TAG:="\fs20"; + BOLD_ON:="\b1"; + BOLD_OFF:="\b0"; + ITALIC_ON:="\i"; + ITALIC_OFF:="\i0"; + BULLETPREFIX:= + "{\*\pn\pnlvlblt\pnf1\pnindent0{\pntxtb\{{{SINGLE-QUOTE}}}B7}}\fi-360\li720\sa200\sl276\slmult1 "; + BULLETPREFIX_L2:= + "{\*\pn\pnlvlblt\pnf1\pnindent0{\pntxtb\{{{SINGLE-QUOTE}}}B7}}\fi-360\li1080\sa200\sl276\slmult1 "; + BULLETPREFIX_L3:= + "{\*\pn\pnlvlblt\pnf1\pnindent0{\pntxtb\{{{SINGLE-QUOTE}}}B7}}\fi-360\li1440\sa200\sl276\slmult1 "; + BULLETPOSTFIX:="\pard"; + BULLET_ON:="{\pntext\f1\{{{SINGLE-QUOTE}}}B7\tab}";//"\bullet"; + BULLET_OFF:="\par"; + NOTDONE_STRING:="Home Medication Collection/Verification was NOT DONE for the visit in context," + || "unable to determine Patient{{{SINGLE-QUOTE}}}s Home Medications on Admission."; + NOTDONE_DISCHARGE_STRING:="Home Medication Collection/Verification was NOT DONE for the " || + "visit in context, unable to determine Patient{{{SINGLE-QUOTE}}}s Home Medications on Discharge."; + HOME_MED_STRING :="Patient{{{SINGLE-QUOTE}}}s Home Medications On Admission\n"; + + if (ReviewStatus = 2) then // Complete + H_return_string:= HEADER1_ON|| HOME_MED_STRING|| HEADER1_OFF; + elseif (ReviewStatus=1) then // InComplete + H_return_string:= HEADER2_ON||"Home Medication Collection/Verification was " || + "INCOMPLETE for the visit in context.\n" || + "\n" || + HEADER1_ON || HOME_MED_STRING || HEADER1_OFF || + "\n" || + HEADER2_ON || "The following Patient’s Home Medications on Admission" || + " have been verified:\n"||HEADER2_OFF; + else // Not Done + H_return_string:= HEADER1_ON|| HOME_MED_STRING|| HEADER1_OFF; + H_return_string:= H_return_string || "\n"; + H_return_string:= H_return_string || HEADER2_ON || NOTDONE_STRING || HEADER2_OFF; + endif; + + if (not exists HomeMeds) then + if (ReviewStatus=2) then + H_return_string:=H_return_string || + BOLD_ON ||"Verified patient not taking any medication on Admission"||BOLD_OFF; + elseif (ReviewStatus=1) then + H_return_string:=H_return_string || + BOLD_ON ||"No Patient Home Medications on Admission were verified."||BOLD_OFF; + endif; + else + H_return_string:= H_return_string || "\n"; + H_return_string:= H_return_string || BULLETPREFIX; + endif; + + if exists HomeMeds then + for ictr IN 1 SEQTO COUNT OF HomeMeds do + //H_return_string:= H_return_string || TAB || BULLET; + H_return_string:= H_return_string || BODY_TAG; + H_return_string:= H_return_string || BULLET_ON; + H_return_string:= H_return_string || BOLD_ON || LOWERCASE HomeMeds[ictr].Name + || BOLD_OFF ; + if (exists HomeMeds[ictr].Instructions and + LENGTH(TRIM(HomeMeds[ictr].Instructions))>0 ) then + tmpInst := Trim HomeMeds[ictr].Instructions; + H_return_string:= H_return_string || " : " || tmpInst; + endif; + if (exists HomeMeds[ictr].Comments and + LENGTH(TRIM(HomeMeds[ictr].Comments))>0) then + tmpComments := Trim HomeMeds[ictr].Comments; + tmpComments2:=CALL REPLACECHAR_MLM WITH tmpComments, "\n"; + H_return_string:=H_return_string || ITALIC_ON || + " . Comments: " || tmpComments2 || ITALIC_OFF; + endif; + H_return_string:= H_return_string || BULLET_OFF; + enddo; + H_return_string:=H_return_string || BULLETPOSTFIX; + endif; + + + + DISCHARGE_MED_STRING :="\n\nPatient{{{SINGLE-QUOTE}}}s Home Medications on Discharge"; + DISCHARGE_WARNING_STRING:="The category for the medication below is based on " || + "an incomplete review of medication on Discharge:"; + RECONCILIATION_WARNING_STRING:="\nThe category for the medication below is based " || + "on an incomplete Discharge Reconciliation process on Discharge:"; + RECONCILIATION_DISCHARGE_WARNING_STRING:="\nThe category for the medication below " || + "is based on an incomplete review of medication on Admission and " || + "an incomplete Discharge Reconciliation process on Discharge:\n"; + if (ReviewStatus = 2) then // complete + if (DischargeReconcileStatus = 2) then // complete + DC_return_string:= HEADER1_ON || DISCHARGE_MED_STRING || HEADER1_OFF || + BULLET_OFF || BULLETPOSTFIX; + else // incomplete or something else + DC_return_string:= HEADER1_ON || DISCHARGE_MED_STRING || HEADER1_OFF || + BULLET_OFF || BULLETPOSTFIX; + DC_return_string:= DC_return_string || HEADER2_ON || RECONCILIATION_WARNING_STRING || + HEADER2_OFF; + DC_return_string:= DC_return_string || "\n"; + endif; + DC_return_string:= DC_return_string || "\n"; + elseif (ReviewStatus = 1) then // incomplete + if (DischargeReconcileStatus = 2) then // complete + DC_return_string:= HEADER1_ON || DISCHARGE_MED_STRING || HEADER1_OFF; + DC_return_string:= DC_return_string || "\n"; + DC_return_string:= DC_return_string || HEADER2_ON || DISCHARGE_WARNING_STRING || + HEADER2_OFF; + DC_return_string:= DC_return_string || "\n"; + else // incomplete or some other status + DC_return_string:= HEADER1_ON || DISCHARGE_MED_STRING || HEADER1_OFF || + BULLET_OFF || BULLETPOSTFIX; + DC_return_string:= DC_return_string || HEADER2_ON ||RECONCILIATION_DISCHARGE_WARNING_STRING || + HEADER2_OFF; + DC_return_string:= DC_return_string || "\n"; + endif; + else // not done + DC_return_string:= HEADER1_ON || DISCHARGE_MED_STRING || HEADER1_OFF; + DC_return_string:= DC_return_string || "\n\n"; + DC_return_string:= DC_return_string || HEADER2_ON || NOTDONE_DISCHARGE_STRING || + HEADER2_OFF; + DC_return_string:= DC_return_string || "\n"; + endif; + + if (not exists HomeMeds AND not exists DischargeMeds) then + if (ReviewStatus=2) then + DC_return_string:=DC_return_string || BOLD_ON || + "No medication is required on Discharge"||BOLD_OFF; + elseif (ReviewStatus=1) then + DC_return_string:=DC_return_string || BOLD_ON || + "No medication is required on Discharge."||BOLD_OFF; + endif; + endif; + + IF ReviewStatus = 1 OR ReviewStatus = 2 THEN + // Stop + IF exists HomeMeds Then //AND exists DischargeMeds THEN + STOPMeds := new Med_Obj ; + STOPMeds := (HomeMeds WHERE HomeMeds.ChangeDesc = "STOP"); + STOP_MED_STRING :=" Stop taking the following Medication"; + if (exists STOPMeds) then + DC_return_string:= DC_return_string || "\n"; + DC_return_string:= DC_return_string || BULLETPREFIX; + DC_return_string:= DC_return_string || BULLET_ON; + DC_return_string:= DC_return_string || HEADER2_ON || STOP_MED_STRING || HEADER2_OFF; + DC_return_string:= DC_return_string || BULLET_OFF; + DC_return_string:= DC_return_string || BULLETPOSTFIX; + DC_return_string:= DC_return_string || BULLETPREFIX_L2; + for ictr IN 1 SEQTO COUNT OF STOPMeds do + DC_return_string:= DC_return_string || BODY_TAG; + DC_return_string:= DC_return_string || BULLET_ON; + DC_return_string:= DC_return_string || BOLD_ON || + LOWERCASE STOPMeds[ictr].Name || BOLD_OFF; + if (exists STOPMeds[ictr].Instructions and + LENGTH(TRIM(STOPMeds[ictr].Instructions))>0) then + DC_return_string:= DC_return_string || " : " || STOPMeds[ictr].Instructions; + endif; + if (exists HomeMeds[ictr].Comments and + LENGTH(TRIM(HomeMeds[ictr].Comments))>0) then + tmpComments := Trim STOPMeds[ictr].Comments; + tmpComments2:=CALL REPLACECHAR_MLM WITH tmpComments, "\n"; + DC_return_string:=DC_return_string || ITALIC_ON ||" . Comments: "; + DC_return_string:=DC_return_string || tmpComments2 || ITALIC_OFF ; + endif; + DC_return_string:=DC_return_string || BULLET_OFF; + enddo; + DC_return_string:= DC_return_string || BULLETPOSTFIX; + endif; + endif; + + if (exists DischargeMeds) then + // Continue taking the following medication + if (ReviewStatus <> 0) then + CONTINUE_MED_STRING:=" Continue taking the following medication:"; + DC_return_string:=DC_return_string || BULLET_ON; + DC_return_string:=DC_return_string || BULLETPREFIX; + DC_return_string:=DC_return_string || HEADER2_ON || CONTINUE_MED_STRING || HEADER2_OFF; + DC_return_string:=DC_return_string || BULLET_OFF; + DC_return_string:=DC_return_string || BULLETPOSTFIX; + endif; + + // No Change + SameMeds := new med_Obj ; + SameMeds := (DischargeMeds WHERE DischargeMeds.ChangeDesc = "NO CHANGE"); + if exists SameMeds then + DC_return_string:=DC_return_string || BULLET_ON; + DC_return_string:=DC_return_string || BULLETPREFIX_L2; + DC_return_string:=DC_return_string || HEADER3_ON || + " These medications are NOT CHANGED:" || HEADER3_OFF; + DC_return_string:=DC_return_string || BULLET_OFF; + DC_return_string:=DC_return_string || BULLETPOSTFIX; + DC_return_string:=DC_return_string || BODY_TAG; + DC_return_string:= DC_return_string || BULLETPREFIX_L3; + for ictr IN 1 SEQTO COUNT OF SameMeds do + DC_return_string:= DC_return_string || BULLET_ON; + DC_return_string:= DC_return_string || BOLD_ON || + LOWERCASE SameMeds[ictr].Name || BOLD_OFF; + if (exists SameMeds[ictr].Instructions and + LENGTH(TRIM(SameMeds[ictr].Instructions))>0) then + DC_return_string:= DC_return_string || " : " || SameMeds[ictr].Instructions; + endif; + if (exists SameMeds[ictr].Comments and + LENGTH(TRIM(SameMeds[ictr].Comments))>0) then + tmpComments := Trim SameMeds[ictr].Comments; + tmpComments2:=CALL REPLACECHAR_MLM WITH tmpComments, "\n"; + DC_return_string:=DC_return_string || ITALIC_ON || " . Comments: "; + DC_return_string:=DC_return_string || tmpComments2 || ITALIC_OFF ; + endif; + DC_return_string:= DC_return_string || BULLET_OFF; + enddo; //for ictr IN 1 SEQTO COUNT OF SameMeds do + DC_return_string:=DC_return_string || BULLETPOSTFIX; + endif; //if exist SameMeds then + + // Change + ChangedMeds := new med_Obj ; + ChangedMeds := (DischargeMeds WHERE DischargeMeds.ChangeDesc = "CHANGED"); + if exists ChangedMeds then + DC_return_string:= DC_return_string || "\n"; + DC_return_string:= DC_return_string || BULLETPREFIX_L2; + DC_return_string:= DC_return_string || BULLET_ON; // level 2 bullets + DC_return_string:= DC_return_string || HEADER3_ON || + " These medications are CHANGED: " || HEADER3_OFF; + DC_return_string:= DC_return_string || BULLET_OFF; + DC_return_string:= DC_return_string || BULLETPOSTFIX; + DC_return_string:= DC_return_string || BODY_TAG; + DC_return_string:= DC_return_string || BULLETPREFIX_L3; + for ictr IN 1 SEQTO COUNT OF ChangedMeds do + DC_return_string:= DC_return_string || BULLETPREFIX_L3; // level 3 bullets + DC_return_string:= DC_return_string || BULLET_ON; + DC_return_string:= DC_return_string || BOLD_ON || + LOWERCASE ChangedMeds[ictr].Name || BOLD_OFF; + if (exists ChangedMeds[ictr].Instructions and + LENGTH(TRIM(ChangedMeds[ictr].Instructions))>0) then + DC_return_string:= DC_return_string || " : " || ChangedMeds[ictr].Instructions; + endif; + + if (exists ChangedMeds[ictr].Comments and + LENGTH(TRIM(ChangedMeds[ictr].Comments))>0) then + tmpComments:=Trim ChangedMeds[ictr].Comments; + tmpComments2:=CALL REPLACECHAR_MLM WITH tmpComments, "\n"; + DC_return_string:=DC_return_string || ITALIC_ON || ". Comments: "; + DC_return_string:=DC_return_string || tmpComments2 || "\n" || ITALIC_OFF; + endif; + DC_return_string:= DC_return_string || BULLET_OFF; + enddo; //for ictr IN 1 SEQTO COUNT OF ChangedMeds do + DC_return_string:= DC_return_string || BULLETPOSTFIX; + endif; //if exist ChangedMeds then + + // New + NewMeds := new med_Obj ; + NewMeds := (DischargeMeds WHERE DischargeMeds.ChangeDesc = "NEW"); + if exists NewMeds then + NEW_MED_STRING := " Start taking the following NEW medication:"; + DC_return_string:= DC_return_string || BULLET_ON; + DC_return_string:= DC_return_string || BULLETPREFIX; + DC_return_string:= DC_return_string || HEADER2_ON || NEW_MED_STRING || HEADER2_OFF; + DC_return_string:= DC_return_string || BULLET_OFF; + DC_return_string:= DC_return_string || BULLETPOSTFIX; + DC_return_string:= DC_return_string || BULLETPREFIX_L2; + for ictr IN 1 SEQTO COUNT OF NewMeds do + DC_return_string:= DC_return_string || BODY_TAG; + DC_return_string:= DC_return_string || BULLET_ON; + DC_return_string:= DC_return_string || BOLD_ON || + LOWERCASE NewMeds[ictr].Name || BOLD_OFF; + HasInstruction := exists NewMeds[ictr].Instructions and + LENGTH(TRIM(NewMeds[ictr].Instructions)) <> 0; + if (HasInstruction) then + tmpI:=call REPLACECHAR_MLM WITH NewMeds[ictr].Instructions,"\n", "."; + DC_return_string:= DC_return_string || " : " || tmpI; + endif; + + if (exists NewMeds[ictr].Comments and + LENGTH(TRIM(NewMeds[ictr].Comments)) <> 0 ) then + tmpComments:=Trim NewMeds[ictr].Comments; + tmpComments2:=CALL REPLACECHAR_MLM WITH tmpComments, "\n"; + if (not HasInstruction) then + DC_return_string:=DC_return_string || " : "; + endif; + DC_return_string:=DC_return_string || ITALIC_ON; + DC_return_string:=DC_return_string || " Comments: "; + DC_return_string:=DC_return_string || tmpComments2 || ITALIC_OFF; + endif; + DC_return_string:= DC_return_string || BULLET_OFF; + enddo; //for ictr IN 1 SEQTO COUNT OF ChangedMeds do + DC_return_string:= DC_return_string || BULLETPOSTFIX; + endif; //if exist NewMeds then + endif; // if exists DischargeMeds + ENDIF; // IF ReviewStatus < 1 THEN + + if (exists H_return_string) then + return_string := return_string || H_return_string; + endif; + + if( exists S_return_string) then + return_string:= return_string || S_return_string; + endif; + return_string:=return_string || DC_return_string; + + + IF exists return_string THEN + newValue := return_string; + sugg_txt_value:= "" ; + // REPLACE_APPEND "Replace" or "Append" will affect FreeTextValue Data Types + REPLACE_APPEND := "Replace" ; + this_documentCommunication := CALL WriteToNote_MLM WITH + (this_documentCommunication, target_parameter_name,newValue,sugg_txt_value,REPLACE_APPEND); + ENDIF; + + + + + + +////////////////////////////////////////////////////////////////////////////////////////////// + + ;; + evoke: + ;; + logic: + conclude true; + ;; + action: + return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_ST_CLAIR_MAIN_PN_MLM.mlm b/MLMStripper/bin/Debug/DOC/DOC_ST_CLAIR_MAIN_PN_MLM.mlm new file mode 100644 index 0000000..4014ade --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_ST_CLAIR_MAIN_PN_MLM.mlm @@ -0,0 +1,2811 @@ +maintenance: + + title: DOC_ST_Clair_MAIN_PN_MLM ;; + mlmname: DOC_ST_Clair_MAIN_PN_MLM;; + arden: version 2.5;; + version: 5.50;; + institution: St. Clair;; + author: ACS;; + specialist: Allscripts Custom Services;; + date: 2011-09-05;; + validation: testing;; + +library: + purpose: Primary document-called MLM to populate the Physician Progress note + ;; + explanation: + This MLM will use MLM CONFIG TOOL to create and MAP the client specific items, + both on the document and (partially) for lookup. + This MLM should call the lookup and writing MLM for ALL respective data lookups + and writes. It should NOT PERFORM ANY OTHER LOOKUPS OR WRITES ON ITS OWN. + + It should only + • perform the lookup of the site specific mapped data items using the values + provided in the MLM config tool + • When necessary, call the lookup MLM, providing the proper arguments, + derived from the site specific mapped data + • When necessary, call the writer MLM, providing the proper arguments, + derived from the site specific mapped data + DEPENDENCIES: + ------------- + ACS_Generic_Lookup + MLM_config_tool_reader + DOC_Results_Grid + STD_DOC_FUNC_CHART_OBSERVATION_HELPER_JAB + + SOFTWARE REQUIREMENTS: + ---------------------- + Requires Sunrise 5.5 + Requires Installation of MLM Configuration Tool (by M Mansoor) + + CONFIGURATION: + -------------- + Supported Document Types: + [ ] Flowsheets + [X] Structured Notes + + MLM Events Supported: + [X] ChartObservation + [X] DocumentOpening + [ ] DocumentClosing + + Change history + + 05.01.2012 DW CSR# 26409/26930 Altered per CHF Core Measure requirements and Prism Enhancements + 08.27.2012 DW CSR# 30963 Prism Enhancements - Do not pull VS information upon open for modification + 08.18.2014 DW CSR# 32616 Add Newborn & Critical Care values to the Vital Signs Section (re-introduced DOC_FUNC_VS_24hrs & commented out VS section of this MLM) + 09.10.2014 DW CSR# 32281 Med Section + 01.06.2015 DW CSR# 32476 Call MLM for Vital Sign and Urine Output for All observations Charted in last 24 Hrs. + 05.11.2015 DW CSR# 32981 Call MLM for Vital Sign for Max Temp charted in last 24 hours. + 19.05.2015 DW CSR# 32982 Add Skipped Doses to Phy. Progress Note => {{{SINGLE-QUOTE}}}Medication and Allergies{{{SINGLE-QUOTE}}}=> {{{SINGLE-QUOTE}}}Active Medications with detail{{{SINGLE-QUOTE}}} radio button + 12.08.2015 JML CSR# 33879 Modified how the Document Topic is set to append the physician specialty on the end of the document name; + new obs was added to note that allows physician to either select the specialty under which they are dictating + the note, or automatically append the specialty defined in their user profile. + 04.21.2016 STH CSR# 32165 update to include the new tranfusion product names Platelet Products, Cryoprecipitate, and Fresh Frozen Plasma {go-live 4/27/2016} + 06/15/2016 STH CSR# 34735 Create MLM for Ostomy Totalling for past 24 hours. {Go-Live 6/21/2106} + 09/13/2016 DW HD# 1843849 - Added code to limit the code to procees active medications and lab results only when the button is clicked....had been double populating upon close. + 03/20/2017 DW CSR# 35114 - Retrieve new test "Glucose, BGM Confirmation" + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + + (this_documentCommunication) := argument; + /****************** Make Your code stretch NO WIDER THAN THIS! *************************/ + +/*############################################################################################################################################################### +//Used for MLM configuration tool. + | | | | | | | + + + +HI_type_chief_complaint |Health Issue: Name of the Chief complaint Health Issue |0| Historical | CV3HealthIssueType | Code | Active=1 +HI_type_problem_list |Health Issue: Historical list of all the patient{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}s current problems | 1| Historical | CV3HealthIssueType | Code | Active=1 +rpm_ip_note_tokens_ss | Observation: List item obs in Progress Note that user will select to populated data | 0| Current | cv3obscatalogmasteritem | Name | StructureNote +rpm_ip_note_tokens_rtf | Observation: Text obs in Progress Note that will be populated with user requested data | 0| Current | cv3obscatalogmasteritem | Name | StructureNote +labelService | Observation: List Item obs in Progress Note that will be populated with user requested data | 0| Current | CV3UserDictionary | Code | ListItems +labelLOS | Observation: List Item obs in Progress Note that will be populated with user requested data | 0| Current | CV3UserDictionary | Code | ListItems +labelProblems | Observation: List Item obs in Progress Note that will be populated with user requested data | 0| Current | CV3UserDictionary | Code | ListItems +labelVS| Observation: List Item obs in Progress Note that will be populated with user requested data | 0| Current | CV3UserDictionary | Code | ListItems +obs_name_hr | Observations: Redent list of recorded Vital Sign HR from flow sheets | 1| Historical | cv3obscatalogmasteritem| Name | Active=1 +obs_name_temp | Observations: Redent list of recorded Vital Sign Temperatures from flow sheets | 1| Historical | cv3obscatalogmasteritem| Name | Active=1 +obs_name_sbp | Observations: Redent list of recorded Vital Sign SBP from flow sheets | 1| Historical | cv3obscatalogmasteritem| Name | Active=1 +obs_name_dbp | Observations: Redent list of recorded Vital Sign DBP from flow sheets | 1| Historical | cv3obscatalogmasteritem| Name | Active=1 +obs_name_rr | Observations: Redent list of recorded Vital Sign RR flow sheets | 1| Historical | cv3obscatalogmasteritem| Name | Active=1 +obs_name_pulseox | Observations: Redent list of recorded Vital Sign Pulse Ox from flow sheets | 1| Historical | cv3obscatalogmasteritem| Name | Active=1 +obs_name_o2 | Observations: Redent list of recorded Vital Sign Oxygen from flow sheets | 1| Historical | cv3obscatalogmasteritem| Name | Active=1 +labelIO24| Observation: List Item obs in Progress Note that requests 24 hour Input/Output summary data | 0| Current | CV3UserDictionary | Code | ListItems +labelIOSOC| Observation: List Item obs in Progress Note that requests Input/Output summary data since Start of Chart | 0| Current | CV3UserDictionary | Code | ListItems +labelIODrains_shft| Observation: List Item obs in Progress Note that requests shift Output summary data for DRAINS | 0| Current | CV3UserDictionary | Code | ListItems +labelIONG_shft| Observation: List Item obs in Progress Note that requests shift Output summary data for NG tubes | 0| Current | CV3UserDictionary | Code | ListItems +obs_name_drains | Observations: Recent list of recorded DRAIN OUPUT on flow sheets | 1| Historical | cv3obscatalogmasteritem| Name | Active=1 +obs_name_io_ng | Observations: Recent list of recorded Naso-Gastric OUPUT on flow sheets | 1| Historical | cv3obscatalogmasteritem| Name | Active=1 +Med_OralRouteNotPrn_list | Orders: Codes that limit medication orders to an ORAL route, only | 1| Historical | CV3OrderRoute | Name | Active=1 +labelActiveMeds| Observation: List Item obs in Progress Note that requests 24 hour Input/Output summary data | 0| Current | CV3UserDictionary | Code | ListItems +ord_active_meds| Orders: Codes that limit medication orders to Active, only | 1| Historical | CV3Order | TypeCode | Active=1 +labelActiveAbx| Observation: List Item obs in Progress Note that requests 24 hour Input/Output summary data | 0| Current | CV3UserDictionary | Code | ListItems +ord_active_abx| Orders: Codes that limit medication orders to Active, only | 1| Historical | CV3ClassType | Code | Active=1 +labelLabresults| Observation: List Item obs in Progress Note that requests 24 hour Input/Output summary data | 0| Current | CV3UserDictionary | Code | ListItems +ord_lab_results| Orders: Codes that limit medication orders to Active, only | 1| Historical | CV3Order | Name | Active=1 +active_abx_meds|Orders: Codes that limit medication Abx orders to Active, only | 1| Historical | CV3Ordercatalogmasteritem | TherapeuticCategory | Active=1 +labelBloodProd| Observation: List Item obs in Progress Note that requests Blood Products orders | 0| Current | CV3UserDictionary | Code | ListItems +labelBldProds| Observation: List Item obs in Progress Note that requests Blood Products orders |1| Current | CV3UserDictionary | Code | ListItems +labelCardiac| Observation: List Item obs in Progress Note that requests Cardiac group |1| Current | CV3UserDictionary | Code | ListItems +labelCoag| Observation: List Item obs in Progress Note that requests Coag group |1| Current | CV3UserDictionary | Code | ListItems +ord_coag_meds| Orders: Codes that limit medication orders to caog selection, only | 1| Historical | CV3Order | Name | Active=1 +blood_prod_tokens_rtf | Observation: Text obs in Progress Note to be populated with user requested Bld Prod | 0| Current | cv3obscatalogmasteritem | Name | StructureNote +ord_bloodprod| Orders: Codes that limit Transfusion orders to Active, only | 1| Historical | CV3Order | Name | Active=1 +labelEndocrine| Observation: List Item obs in Progress Note that requests Endocrine group |1| Current | CV3UserDictionary | Code | ListItems +active_endo_meds|Orders: Codes that limit medication Endocrine orders to Active, only | 1| Historical | CV3Ordercatalogmasteritem | TherapeuticCategory | Active=1 +labelGastro| Observation: List Item obs in Progress Note that requests Gastro group |1| Current | CV3UserDictionary | Code | ListItems +med_image_from| Observation: DateTime FROM item for Medical Imaging |0| Current | cv3obscatalogmasteritem | Name | StructureNote +med_image_to| Observation: DateTime TO item for Medical Imaging |0| Current | cv3obscatalogmasteritem | Name | StructureNote +med_image_period_list | Observation: LIST in Progress Note that user will select choose med image period | 0| Current | cv3obscatalogmasteritem | Name | StructureNote +label_med_image_24h| Observation: List Item obs in Progress Note for med images in past 24 hours |0| Current | CV3UserDictionary | Code | ListItems +label_med_image_48h| Observation: List Item obs in Progress Note for med images in past 48 hours |0| Current | CV3UserDictionary | Code | ListItems +med_image_text_rtf | Observation: Text obs in Progress Note that will be populated with medical image impressions | 0| Current | cv3obscatalogmasteritem | Name | StructureNote +med_image_review_cat|Results: Codes that limit review categore to MEDICAL IMAGE only | 1| Historical | CV3OrderReviewCategory | code | Active=1 +labelID| Observation: List Item obs in Progress Note that requests Inf Disease group |1| Current | CV3UserDictionary | Code | ListItems +ord_ID_meds|Orders: Codes that limit medication ID Abx orders , anti-infectives only | 1| Historical | CV3Ordercatalogmasteritem | TherapeuticCategory | Active=1 +lab_ID_results| Orders: Codes that limit ID Lab results, only | 1| Historical | CV3Order | Name | Active=1 +labelLineAccess| Observation: List Item obs in Progress Note that requests Inf Disease group |1| Current | CV3UserDictionary | Code | ListItems +obs_name_lines | Observations: Recent list of recorded Line Access Location/Dtm from flow sheets | 1| Historical | cv3obscatalogmasteritem| Name | Active=1 +labelVent| Observation: List Item obs in Progress Note that requests Mechanical Vent group |1| Current | CV3UserDictionary | Code | ListItems +obs_name_vents | Observations: Recent list of recorded Vent Settings obs from flow sheets | 1| Historical | cv3obscatalogmasteritem| Name | Active=1 +labelPulmonary| Observation: List Item obs in Progress Note that requests Pulmonary group |1| Current | CV3UserDictionary | Code | ListItems +ord_Pulmon_meds|Orders: Codes that limit medication Pulmonary orders , bronchodialators only | 1| Historical | CV3Ordercatalogmasteritem | TherapeuticCategory | Active=1 +Pulmon_image_rev| Orders: Codes that limit images/impressions for Pulmonary selection, only | 1| Historical | CV3Order | Name | Active=1 +labelNeuro| Observation: List Item obs in Progress Note that requests Neurology group |1| Current | CV3UserDictionary | Code | ListItems +Neuro_image_rev| Orders: Codes that limit images/impressions for Neurology selection, only | 1| Historical | CV3Order | Name | Active=1 +cm_ami_list | Observation: LIST in Progress Note that user will select choose AMI CORE MEASURE | 0| Current | cv3obscatalogmasteritem | Name | StructureNote +label_cm_ami| Observation: List Item obs in Progress Note for AMI CORE MEASURE |0| Current | CV3UserDictionary | Code | ListItems +cm_ami_text_rtf | Observation: Text obs in Progress Note that will be populated with AMI CORE MEASURE data | 0| Current | cv3obscatalogmasteritem | Name | StructureNote +cm_ami_type_problem_list |Health Issue: Historical list of all the ICD9 codes related to AMI | 1| Historical | CV3CodedHealthIssue | Code | Active=1 +cm_ami_meds|Orders: Codes that limit medication orders to AMI related only | 1| Historical | CV3Ordercatalogmasteritem | TherapeuticCategory | Active=1 +labelRenal|Observation: List Item obs in Progress Note that requests Renal group |1| Current | CV3UserDictionary | Code | ListItems +lab_Renal_results| Orders: Codes that limit Renal Lab results, only | 1| Historical | CV3Order | Name | Active=1 +cm_stroke_list | Observation: LIST in Progress Note that user will select choose STROKE CORE MEASURE | 0| Current | cv3obscatalogmasteritem | Name | StructureNote +label_cm_stroke| Observation: List Item obs in Progress Note for STROKE CORE MEASURE |0| Current | CV3UserDictionary | Code | ListItems +cm_stroke_text_rtf | Observation: Text obs in Progress Note that will be populated with STROKE CORE MEASURE data | 0| Current | cv3obscatalogmasteritem | Name | StructureNote +cm_stroke_type_problem_list |Health Issue: Historical list of all the ICD9 codes related to STROKE CM | 1| Historical | CV3CodedHealthIssue | Code | Active=1 +cm_ord_stroke| Orders: Codes that limit STROKE CM (PT, Anti-Emb) orders to Active, only | 1| Historical | CV3Order | Name | Active=1 +cm_chf_list | Observation: LIST in Progress Note that user will select choose CHF CORE MEASURE | 0| Current | cv3obscatalogmasteritem | Name | StructureNote +label_cm_chf| Observation: List Item obs in Progress Note for CHF CORE MEASURE |0| Current | CV3UserDictionary | Code | ListItems +cm_chf_text_rtf | Observation: Text obs in Progress Note that will be populated with CHF CORE MEASURE data | 0| Current | cv3obscatalogmasteritem | Name | StructureNote +cm_chf_type_problem_list |Health Issue: Historical list of all the ICD9 codes related to CHF | 1| Historical | CV3CodedHealthIssue | Code | Active=1 +cm_chf_meds|Orders: Codes that limit medication orders to CHF related only | 1| Historical | CV3Ordercatalogmasteritem | TherapeuticCategory | Active=1 +cm_vte_list | Observation: LIST in Progress Note that user will select choose VTE CORE MEASURE | 0| Current | cv3obscatalogmasteritem | Name | StructureNote +label_cm_vte| Observation: List Item obs in Progress Note for VTE CORE MEASURE |0| Current | CV3UserDictionary | Code | ListItems +cm_vte_text_rtf | Observation: Text obs in Progress Note that will be populated with VTE CORE MEASURE data | 0| Current | cv3obscatalogmasteritem | Name | StructureNote +cm_vte_type_problem_list |Health Issue: Historical list of all the ICD9 codes related to VTE | 1| Historical | CV3CodedHealthIssue | Code | Active=1 +cm_vte_meds|Orders: Codes that limit medication orders to VTE related only | 1| Historical | CV3Ordercatalogmasteritem | TherapeuticCategory | Active=1 +cm_heart_type_problem_list |Health Issue: Historical list of all the ICD9 codes related to VTE | 1| Historical | CV3CodedHealthIssue | Code | Active=1 and code like {{{SINGLE-QUOTE}}}410%{{{SINGLE-QUOTE}}} +cm_chf_arb_list | Observation: ARB List in Progress Note CHF CORE MEASURE | 0| Current | cv3obscatalogmasteritem | Name | StructureNote +cm_chf_ace_list | Observation: ACE List in Progress Note CHF CORE MEASURE | 0| Current | cv3obscatalogmasteritem | Name | StructureNote + + +/*################################################################################################################################################################*/ + + /***************************** Make Changes HERE ***************************************/ + + /******************************* End of Changes ****************************************/ + + // References the LOCAL SESSION object + local_session := cds_session.local; // for local_session.ACSPNGroupSelections + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + //Initialize Variables and Constants Declaration + + (this_structuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; + (this_parameters) := this_structuredNoteDoc.ParametersList; + (this_chartedObservationsList) := this_structuredNoteDoc.ChartedObservationsList; + (this_currentObj) := this_documentCommunication.CurrentObservationObj; + (client_guid) := this_documentCommunication.ClientGUID; + (client_chart_guid) := this_documentCommunication.ChartGUID; + (client_visit_guid) := this_documentCommunication.ClientVisitGUID; + (user_guid) := this_documentCommunication.UserGUID; + (client_document_guid) := this_structuredNoteDoc.ClientDocumentGUID ; + (doc_name) := this_documentCommunication.DocumentName ; + (this_parameter_name) := this_parameters.DisplayName ; + (theEvent) :=this_documentCommunication.EventType ; + (this_parameter_nameis) :=this_parameters.Name ; + current_parameter := FIRST OF (this_Parameters WHERE this_parameters.ParameterGUID = this_CurrentObj.ParameterGUID); + current_parameter_name := current_parameter.name ; + current_parameter_guid := current_parameter.ParameterGuid ; + current_parameter_DataType := current_parameter.DataType ; + selectedItems := (this_currentObj.ValueObj.ListItemsList WHERE this_currentObj.ValueObj.ListItemsList.IsSelected = true); + currentObj_selectedItems := selectedItems.value ; + countOf_selectedItems := COUNT OF currentObj_selectedItems ; + DocumentTopic := this_structuredNoteDoc.DocumentTopic; + + //List Variables + All_Attributes_Lst:=(); //List object attributes retrieved (“name”, “itemname”, etc.) + All_Values_Lst:=(); //List of values for the attribute(s) + All_UoM_Lst:=(); //List of UOMs (units of measure) for the attributes + All_Med_Rel_Dttm_Lst:=(); //List of medically relevant times /(“performeddtm”,“significantdtm”, etc.) + All_Start_Time_Lst:=(); //List of start times (if relevant) + All_Stop_Time_Lst:=(); //List of stop tiames (if relevant) + All_User_Guid_Lst:=(); //List of userguids who entered data. + All_Significant_Data_Lst:=(); //List of other “significant data” as a text field. + All_Sig_Count_Lst := (); //List of significant counts. + All_Sig_Nt_Count_Lst := (); // List Of Significant Doses Not Given Count || Added By Shivprasad Jadhav For CSR : 32982 + current_item_list := (); // items currently to be processed + + //SET THE DEFAULT VALUES of Variables to be passed to ACS_Generic_Lookup MLM + + Is_Historical := "Historical" ; //“historical” or “current” (indicates whether to use SQL or current object navigation) + Retreive_Object := ""; //Object to retrieve (“HealthIssue”, “order”, “allergy”, “observation”, etc.) + Retreive_Attribute := ""; //Attribute to retrieve (“name”, “itemname”, etc.) + Filterable_Attribute := ""; //Filterable attribute (“name”,“itemname”,“typecode”, etc.) + Filterable_Operator := ""; //Filterable operator (“=”, “in”, “matches pattern”, etc.) + Filterable_Value :=""; //Filterable value(s) (“chronic”, “antibiotic”, “(‘480.00’,’480.30’)”, etc.) + Additional_condition := ""; //Additional condition(s) (“orderstatuslevelnum between 55 and 60”, “performedtm > dateadd(-24, hh, getdate()”, etc.) + topic_var:= ""; //this_documentCommunication.DocumentTopic; + msg := ""; //message + Selected_groups := (); // for groupings section, uses the local_config object; + + //Tab definitions and formating + TAB := 9 FORMATTED WITH "%C" ; + TAB2 := TAB || TAB ; + TAB3 := TAB || TAB || TAB; + Token:= ""; //Token for deciding which list item is selected + Result_String := ""; //String which is return from this MLM + CR := 13 formatted with "%c"; + LF := 10 formatted with "%c"; + CRLF:= CR||LF; + SP:= 32 formatted with "%c"; + SP2:= SP||SP; + SP3:= SP||SP||SP; + + // "hidden" terminator characters for parsing/deleting text: + (blt_char, par_char) := read first{"select char(8), char(20)"}; + + //********************Lookup Site Specific Configured items***************************// + //Called MLM{{{SINGLE-QUOTE}}}s + Get_mlm_Generic_Lookup_data := MLM {{{SINGLE-QUOTE}}}ACS_Generic_Lookup{{{SINGLE-QUOTE}}}; + Get_result_impression_lookup := MLM {{{SINGLE-QUOTE}}}ACS_result_impression_Lookup{{{SINGLE-QUOTE}}}; + Get_mlm_config_data := MLM {{{SINGLE-QUOTE}}}MLM_config_tool_reader{{{SINGLE-QUOTE}}}; + called_DOC_Results_Grid := MLM {{{SINGLE-QUOTE}}}DOC_Results_Grid{{{SINGLE-QUOTE}}}; + Called_DOM_mlm := MLM {{{SINGLE-QUOTE}}}STD_DOC_FUNC_CHART_OBSERVATION_HELPER_JAB{{{SINGLE-QUOTE}}}; + parse_mlm:= MLM {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; + set_contingency_question := mlm {{{SINGLE-QUOTE}}}ACS_obs_select_func_on_lookup{{{SINGLE-QUOTE}}}; + VitalSignsMLM := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_VS_24hrs{{{SINGLE-QUOTE}}}; +//Added By Shivprasad for Vital Sign and Urine Obs Capture + VitalSignsMLM1 := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_Last_24hrs{{{SINGLE-QUOTE}}}; //Added By Shivprasad for Vital Sign and Urine Obs Capture + VitalSignsMLM1N := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_Newborn_Last_24hrs{{{SINGLE-QUOTE}}}; //MLM Added for Newborn Assessment and Discharge Summary document (CSR-33427) (Vikas) + VitalSignsMLM_MaxTemp := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_Max_Temperature{{{SINGLE-QUOTE}}}; //Added By Shivprasad for Vital Sign and Urine Obs Capture + VitalSignsMLM_MaxTempN := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_Newborn_Max_Temperature{{{SINGLE-QUOTE}}}; //MLM Added for Newborn Assessment and Discharge Summary document (CSR-33427) (Vikas) + UnineOutputMLM := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_Last_24hrs_Urine{{{SINGLE-QUOTE}}}; //Added By Shivprasad for Vital Sign and Urine Obs Capture + UnineOutputMLMN := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_Newborn_Last_24hrs_Urine{{{SINGLE-QUOTE}}}; //MLM Added for Newborn Assessment and Discharge Summary document (CSR-33427) (Vikas) + OstomyOutputMLM := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_Last_24hrs_Ostomy{{{SINGLE-QUOTE}}}; //Added By Shawn Head for Vital Sign and Ostomy Obs Capture + OstomyOutputMLMN := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_Newborn_Last_24hrs_Ostomy{{{SINGLE-QUOTE}}}; //Added By Shawn Head for Vital Sign and Ostomy Obs Capture + // pull all config data for this mlm + MLM_Name := "DOC_ST_Clair_MAIN_PN_MLM"; + + //Retrieve the local site configured values from MLM configuration tool. + (var_id, mlm_var_list, site_config_name_list) := CALL Get_mlm_config_data WITH MLM_Name; + + labelService := FIRST (site_config_name_list WHERE (mlm_var_list = "labelService")); + labelLOS := FIRST (site_config_name_list WHERE (mlm_var_list = "labelLOS")); + + // Vitals - labels and items + labelVS := FIRST (site_config_name_list WHERE (mlm_var_list = "labelVS")); + obs_name_hr := FIRST (site_config_name_list WHERE (mlm_var_list = "obs_name_hr")); + obs_name_sbp := FIRST (site_config_name_list WHERE (mlm_var_list = "obs_name_sbp")); + obs_name_dbp := FIRST (site_config_name_list WHERE (mlm_var_list = "obs_name_dbp")); + obs_name_temp := FIRST (site_config_name_list WHERE (mlm_var_list = "obs_name_temp")); + obs_name_rr := FIRST (site_config_name_list WHERE (mlm_var_list = "obs_name_rr")); + obs_name_o2 := FIRST (site_config_name_list WHERE (mlm_var_list = "obs_name_o2")); + obs_name_pulseox := FIRST (site_config_name_list WHERE (mlm_var_list = "obs_name_pulseox")); + height_in_cm := "{{{SINGLE-QUOTE}}}height in cm{{{SINGLE-QUOTE}}}"; + weight_in_gm := "{{{SINGLE-QUOTE}}}SCH_Newborn Weight - grams{{{SINGLE-QUOTE}}}"; + weight_in_kg := "{{{SINGLE-QUOTE}}}Weight - kg{{{SINGLE-QUOTE}}}"; + vs_name_list := obs_name_hr, obs_name_sbp, obs_name_dbp, obs_name_temp, obs_name_rr, obs_name_o2, obs_name_pulseox, height_in_cm, weight_in_gm, weight_in_kg; + + // I&O - labels and items + labelIO24 := FIRST (site_config_name_list WHERE (mlm_var_list = "labelIO24")); + labelIOSOC := FIRST (site_config_name_list WHERE (mlm_var_list = "labelIOSOC")); + labelIODrains_shft := FIRST (site_config_name_list WHERE (mlm_var_list = "labelIODrains_shft")); + labelIONG_shft := FIRST (site_config_name_list WHERE (mlm_var_list = "labelIONG_shft")); + obs_name_drains := FIRST (site_config_name_list WHERE (mlm_var_list = "obs_name_drains")); + obs_name_io_ng := FIRST (site_config_name_list WHERE (mlm_var_list = "obs_name_io_ng")); + + // Active Meds - label and items + labelMeds := FIRST (site_config_name_list WHERE (mlm_var_list = "labelactivemeds")); + ord_summ_meds := FIRST (site_config_name_list WHERE (mlm_var_list = "ord_active_meds")); + + // Active Antibiotics - label and items + labelAbx := FIRST (site_config_name_list WHERE (mlm_var_list = "labelactiveAbx")); + /// previous fetch by classType + ord_class_abx := FIRST (site_config_name_list WHERE (mlm_var_list = "active_abx_meds")); + + // Lab Results - label and items + labelLab := FIRST (site_config_name_list WHERE (mlm_var_list = "labelLabresults")); + ord_lab_results := FIRST (site_config_name_list WHERE (mlm_var_list = "ord_lab_results")); + + // Medical Imaging - label and items + med_image_from := FIRST (site_config_name_list WHERE (mlm_var_list = "med_image_from")); + med_image_to := FIRST (site_config_name_list WHERE (mlm_var_list = "med_image_to")); + med_image_period_list := FIRST (site_config_name_list WHERE (mlm_var_list = "med_image_period_list")); + label_med_image_24h := FIRST (site_config_name_list WHERE (mlm_var_list = "label_med_image_24h")); + label_med_image_48h := FIRST (site_config_name_list WHERE (mlm_var_list = "label_med_image_48h")); + med_image_text_rtf := FIRST (site_config_name_list WHERE (mlm_var_list = "med_image_text_rtf")); + + //// Specialty Groupings + labelbloodprod :=FIRST (site_config_name_list WHERE (mlm_var_list = "labelBldProds")); + ord_products := FIRST (site_config_name_list WHERE (mlm_var_list = "ord_bloodprod")); + labelcardiac :=FIRST (site_config_name_list WHERE (mlm_var_list = "labelCardiac")); + labelcoag :=FIRST (site_config_name_list WHERE (mlm_var_list = "labelCoag")); + labelendo := FIRST (site_config_name_list WHERE (mlm_var_list = "labelEndocrine")); + ord_class_endo := FIRST (site_config_name_list WHERE (mlm_var_list = "active_endo_meds")); + labelgastro := FIRST (site_config_name_list WHERE (mlm_var_list = "labelGastro")); + labelID := FIRST (site_config_name_list WHERE (mlm_var_list = "labelID")); + ord_id_meds := FIRST (site_config_name_list WHERE (mlm_var_list = "ord_ID_meds")); + lab_id_results := FIRST (site_config_name_list WHERE (mlm_var_list = "lab_id_results")); + labelLineAccess:= FIRST (site_config_name_list WHERE (mlm_var_list = "labelLineAccess")); + obs_name_lines := FIRST (site_config_name_list WHERE (mlm_var_list = "obs_name_lines")); + labelVent := FIRST (site_config_name_list WHERE (mlm_var_list = "labelVent")); + obs_name_vents := FIRST (site_config_name_list WHERE (mlm_var_list = "obs_name_vents")); + labelPulmonary := FIRST (site_config_name_list WHERE (mlm_var_list = "labelPulmonary")); + ord_pulmon_meds:= FIRST (site_config_name_list WHERE (mlm_var_list = "ord_pulmon_meds")); + Pulmon_image_rev:=FIRST (site_config_name_list WHERE (mlm_var_list = "Pulmon_image_rev")); + labelNeuro := FIRST (site_config_name_list WHERE (mlm_var_list = "labelNeuro")); + Neuro_image_rev:= FIRST (site_config_name_list WHERE (mlm_var_list = "Neuro_image_rev")); + labelRenal := FIRST (site_config_name_list WHERE (mlm_var_list = "labelRenal")); + lab_renal_results:=FIRST(site_config_name_list WHERE(mlm_var_list = "lab_renal_results")); + ////////// end groupings + + labelProblems := FIRST (site_config_name_list WHERE (mlm_var_list = "labelProblems")); + rpm_ip_note_tokens_ss := FIRST (site_config_name_list WHERE (mlm_var_list = "rpm_ip_note_tokens_ss")); + rpm_ip_note_tokens_rtf := FIRST (site_config_name_list WHERE (mlm_var_list = "rpm_ip_note_tokens_rtf")); + + + // Determine if the Document is being modified (versus a new document) + + if this_structuredNoteDoc.isnew = true + then document_is_being_modified := "false"; + else document_is_being_modified := "true"; + endif; + + + + //****************Define the Logic based on the config values.************************// + + + // Preselection Items to be processed on document opening + + + items_on_open_list := (labelService, LabelLOS, LabelVS); + + + + if theEvent = "DocumentOpening" then // set the items that need to be processed + + current_item_list := items_on_open_list; + + // Upon Document Opening, set the local session object with prior GROUPING selections + + group_param := first of (this_parameters where (this_parameters.name MATCHES PATTERN "%SCH_MDPN_Grouping Disease%")); + group_obs := first of (this_chartedObservationsList where (this_chartedObservationsList.parameterguid = group_param.parameterguid)); + group_list := (group_obs.ValueObj.ListItemsList WHERE group_obs.ValueObj.ListItemsList.IsSelected = true); + + if exists group_list.value then + local_session.ACSPNGroupSelections := group_list.value; + else + local_session.ACSPNGroupSelections := (); + endif; + + else + + current_item_list := current_item_list, currentObj_selectedItems[1]; + + endif; // Document Opening + + + + for current_item in current_item_list do + + If current_parameter_name is in ("SCH_MDPN_Picklist_Serv, LOS, Subjective","SCH_MDPN_Picklist_VS, I & O", + "SCH_MDPN_Picklist_Subjective","SCH_MDPN_Picklist_Lab Results","SCH_MDPN_Picklist_Meds","SCH_NEWBORN_vs") //Added SCH_NEWBORN_vs to include Newborn Assessment and Discharge Summary document (CSR-33427) (Vikas) + OR theEvent = "DocumentOpening" Then + + Is_Historical := "Historical"; + + // Assign the values before calling the function + + + If current_item = "Introduction" Then + Token:="|introduction|" ; + + ElseIf current_item = labelService Then + Token:= "|Service|"; + Retreive_Object := "Service"; + target_parameter_name := "SCH_MDPN_FT Serv, LOS, Subj"; + + ElseIf current_item = labelLOS Then + Token:= "|hospitalday|"; + Retreive_Object := "LOS"; + target_parameter_name := "SCH_MDPN_FT Serv, LOS, Subj"; + + + + // August 27 2012 DW added code to prevent VS data from being updated upon document modification + + ElseIf (current_item = labelVS and theEvent = "chartobservation") or + (current_item = labelVS and theEvent = "documentopening" and document_is_being_modified = "false") + Then + +// Commented out this section for CSR# 32616 re-introduced DOC_FUNC_VS_24hrs for Vital Signt data (added dummy line to keep the above "ELSEIF" in place) + + Token:= "|vitals|"; + Retreive_Object := "Vitals"; + Filterable_Attribute := "ocmi.name"; + Filterable_Operator := "IN" ; + Filterable_Value := vs_name_list; + target_parameter_name := "SCH_MDPN_FT VS, I & O"; + + ElseIf current_item = labelIO24 Then + Token:= "|IO24|"; + Retreive_Object := "IO24"; + target_parameter_name := "SCH_MDPN_FT VS, I & O"; + + ElseIf current_item = "I & O (Start of Chart)" Then + Token:= "|IOSOC|"; + Retreive_Object := "IOSOC"; + target_parameter_name := "SCH_MDPN_FT VS, I & O"; + + ElseIf current_item = labelIODrains_shft Then + Token:= "|IO_Drains_shift|"; + Retreive_Object := "IO_Drains_shift"; + Filterable_Attribute := "ocmi.name"; + Filterable_Operator := "IN" ; + Filterable_Value := obs_name_drains; + target_parameter_name := "SCH_MDPN_FT VS, I & O"; + + ElseIf current_item = labelIONG_shft Then + Token:= "|IO_NG_shift|"; + Retreive_Object := "IO_NG_shift"; + Filterable_Attribute := "ocmi.name"; + Filterable_Operator := "IN" ; + Filterable_Value := obs_name_io_ng; + target_parameter_name := "SCH_MDPN_FT VS, I & O"; + + ElseIf current_item = "Orthostatic BP-HR" Then + + this_documentCommunication := CALL VitalSignsMLM WITH this_documentCommunication; + +// Added by Shivprasad Jadhav On 17 Dec 2014 + ElseIf current_item = "All VS Last 24 hrs" then //"ALL Vital Sign Last 24 Hours" Then //"All VS Last 24 hrs" Then + Filterable_Attribute := "ocmi.name"; + Filterable_Operator := "IN" ; + target_parameter_name := "SCH_MDPN_FT VS, I & O"; + + + If current_parameter_name = "SCH_NEWBORN_vs" then //Added if section for Newborn Assessment and Discharge Summary document (CSR-33427) (Vikas) + this_documentCommunication := CALL VitalSignsMLM1N WITH this_documentCommunication; + else + this_documentCommunication := CALL VitalSignsMLM1 WITH this_documentCommunication; + endif; + + + ElseIf current_item = "Temp Max - 24 hours" then //Temp Max - 24 hours + Filterable_Attribute := "ocmi.name"; + Filterable_Operator := "IN" ; + target_parameter_name := "SCH_MDPN_FT VS, I & O"; + + If current_parameter_name = "SCH_NEWBORN_vs" then //Added if section for Newborn Assessment and Discharge Summary document (CSR-33427) (Vikas) + this_documentCommunication := CALL VitalSignsMLM_MaxTempN WITH this_documentCommunication; + else + this_documentCommunication := CALL VitalSignsMLM_MaxTemp WITH this_documentCommunication; + endif; + + ElseIf current_item = "Ostomy Output" then + Filterable_Attribute := "ocmi.name"; + Filterable_Operator := "IN" ; + target_parameter_name := "SCH_MDPN_FT VS, I & O"; + + If current_parameter_name = "SCH_NEWBORN_vs" then //Added if section for Newborn Assessment and Discharge Summary document (CSR-33427) (Vikas) + this_documentCommunication := CALL OstomyOutputMLMN WITH this_documentCommunication; + else + this_documentCommunication := CALL OstomyOutputMLM WITH this_documentCommunication; + endif; + + ElseIf current_item = "Urine Output Last 24 hrs" then + Filterable_Attribute := "ocmi.name"; + Filterable_Operator := "IN" ; + target_parameter_name := "SCH_MDPN_FT VS, I & O"; + a := EvokingEvent; + + + If current_parameter_name = "SCH_NEWBORN_vs" then //Added if section for Newborn Assessment and Discharge Summary document (CSR-33427) (Vikas) + this_documentCommunication := CALL UnineOutputMLMN WITH this_documentCommunication; + else + this_documentCommunication := CALL UnineOutputMLM WITH this_documentCommunication; + endif; + +// Written By Shivprasad + ElseIf current_item = labelmeds Then + Token:= "|Active Medications|"; + Retreive_Object := "Orders"; + Filterable_Attribute := "o.typecode"; + Filterable_Operator := "IN" ; + Filterable_Value := ord_summ_meds; + target_parameter_name := "SCH_MDPN_FT Meds"; + + ElseIf current_item = labelabx Then + Token:= "|Active Antibiotics|"; + Retreive_Object := "Orders"; + Filterable_Attribute := "ocmi.TherapeuticCategory"; + Filterable_Operator := "IN"; + Filterable_Value := ord_class_abx; + target_parameter_name := "SCH_MDPN_FT Meds"; + + ElseIf current_item = "Active Medications with Detail" Then + Token:= "|Active Medications with Detail|"; + Retreive_Object := "Orders"; + Filterable_Attribute := "o.typecode"; + Filterable_Operator := "IN" ; + Filterable_Value := ord_summ_meds; + target_parameter_name := "SCH_MDPN_FT Meds"; + + ElseIf current_item = "Clear All" and current_parameter.Name = "SCH_MDPN_Picklist_Meds" Then + target_parameter_name := "SCH_MDPN_FT Meds"; + this_documentCommunication := CALL Called_DOM_Mlm WITH (this_documentCommunication, target_parameter_name, ("","Replace")); + + + ElseIf current_item = labelLab Then + Token:= "|Lab Results|"; + Retreive_Object := "Lab Results"; + Filterable_Attribute := "o.name"; + Filterable_Operator := "IN" ; + Filterable_Value := ord_lab_results; + target_parameter_name := "SCH_MDPN_FT Labs"; + + //get local site configured values for Health Issues from MLM configuration tool. + + ElseIf current_item = labelProblems Then + Token:="|problems|" ; + HI_type_problem_list := FIRST (site_config_name_list WHERE (mlm_var_list = "HI_type_problem_list")); + Retreive_Object := "HealthIssue"; + Retreive_Attribute := "hi.shortname"; + Filterable_Attribute := "typecode"; + Filterable_Operator := "IN" ; + Filterable_Value :=HI_type_problem_list; + Additional_condition := ""; + + ElseIf current_item = "Subjective"Then + Token:= "|Subjective|"; + target_parameter_name := "SCH_MDPN_Subjective"; + + + EndIf; + + + // clear target area + + //this_documentCommunication := CALL Called_DOM_Mlm WITH (this_documentCommunication, target_parameter_name, ("","Replace")); + + + // Medical Imaging + + elseif current_parameter_name in (med_image_from, med_image_to, med_image_period_list) then + + target_parameter_name := med_image_text_rtf; + this_documentCommunication := CALL Called_DOM_Mlm WITH (this_documentCommunication, target_parameter_name, ("","Replace")); + + // get/set TO date - default = NOW + + to_date_param := FIRST OF (this_parameters WHERE this_parameters.name = med_image_to); + to_date_obs := FIRST OF (this_ChartedObservationsList WHERE this_ChartedObservationsList.parameterGUID = to_date_param.parameterGUID); + to_date := to_date_obs.valueobj.value; + + from_date_param := FIRST OF (this_parameters WHERE this_parameters.name = med_image_from); + from_date_obs := FIRST OF (this_ChartedObservationsList WHERE this_ChartedObservationsList.parameterGUID = from_date_param.parameterGUID); + from_date := from_date_obs.valueobj.value; + + period_param := first of (this_parameters WHERE this_parameters.name = med_image_period_list); + period_obs := FIRST OF (this_ChartedObservationsList WHERE this_ChartedObservationsList.parameterGUID = period_param.parameterGUID); + + if exists period_obs.valueobj then + period_item := first of (period_obs.valueobj.listitemslist where period_obs.valueobj.listitemslist.isselected = true); + period_selected := first of (period_obs.valueobj.listitemslist.value where period_obs.valueobj.listitemslist.isselected = true); + endif; + + if current_parameter_name = med_image_period_list then + to_date_obs.valueobj.value := currenttime; + + if current_item = label_med_image_24h then + Additional_condition := " performeddtm > dateadd(hh, -24, getdate()) "; + from_date_obs.valueobj.value := currenttime - 24 hours; + + elseif current_item = label_med_image_48h then + Additional_condition := " performeddtm > dateadd(hh, -48, getdate()) "; + from_date_obs.valueobj.value := currenttime - 48 hours; + + endif; + + else + if exists to_date and exists from_date then + period_obs.valueobj := null; + Additional_condition := " performeddtm between " || sql(from_date) || " and " || sql(to_date) ; + endif; + + endif; + + // some time frame has be specified ... get the impressions from Review category: "Medical Imaging" + + if exists Additional_condition and additional_condition <> "" then + Token:= "|MedImage|"; + Retreive_Attribute := "text_val"; + Retreive_Object := "Results"; + Filterable_Attribute := "r.code"; + Filterable_Operator := "=" ; + Filterable_Value := "Medical Imaging"; + endif; + + // Diagnostic groupings ... retrieve previously selected grouping items + + ElseIf current_parameter_name MATCHES PATTERN "%SCH_MDPN_Grouping Disease%" then + + Selected_groups := local_session.ACSPNGroupSelections; + test_char1:= ","; + test_char2:="{{{SINGLE-QUOTE}}}"; + target_parameter_name := "SCH_MDPN_Groupings"; + test_local:= (); + + // Get current text in the "write to" target field. This will be used for dup checking + + rtf_target_param := FIRST OF (this_parameters WHERE this_parameters.name = target_parameter_name); + rtf_target_obs := FIRST OF (this_ChartedObservationsList WHERE this_ChartedObservationsList.parameterGUID = rtf_target_param.parameterGUID); + rtf_target_val_obj := rtf_target_obs.valueobj; + rtf_target_text := rtf_target_val_obj.value; + + // Logic for DE-SELECTION of a group item if that happened + if any (Selected_groups is not in currentObj_selectedItems) then //item UNselected + unsel_item := first of (Selected_groups where it is not in currentObj_selectedItems); + txt_start := find ("\b "|| unsel_item) in string rtf_target_text; // find the start of the text that needs to be removed (use value selected) + txt_end := find blt_char in string rtf_target_text starting at txt_start; // find end of the text that needs to be removed (use hidden char terminator) + + if (txt_start > 0 and txt_end > 0) then + // get the pre and post text that needs to remain + pre_txt := substring (txt_start - 1) characters starting at 1 from rtf_target_text; + post_txt := substring (length rtf_target_text - txt_end) characters starting at (txt_end + 1) from rtf_target_text; + rtf_target_val_obj.value := (trim pre_txt) || (trim post_txt); // Replace the target text with the "edited" version + endif; + + // Remove deselected item from session object list + local_session.ACSPNGroupSelections := local_session.ACSPNGroupSelections where it is in currentObj_selectedItems; + + // Logic for SELECTION of a group item if that happened + elseif any (currentObj_selectedItems is not in Selected_groups) then + sel_item := first of (currentObj_selectedItems where it is not in selected_groups); // new item SELECTED + local_session.ACSPNGroupSelections := local_session.ACSPNGroupSelections, sel_item; // add selected item to the session object list + + /// value selections in Groupings + ext_item := extract characters sel_item; //current_item ; + match_item:= string (ext_item where they not in test_char1); + ext_bld := extract characters labelbloodprod ; + match_bld := string (ext_bld where they not in test_char2); + ext_car := extract characters labelcardiac ; + match_car := string (ext_car where they not in test_char2); + ext_coag := extract characters labelcoag ; + match_coag:= string (ext_coag where they not in test_char2); + ext_endo := extract characters labelendo ; + match_endo:= string (ext_endo where they not in test_char2); + ext_gastro:= extract characters labelgastro ; + match_gastro:= string (ext_gastro where they not in test_char2); + ext_ID := extract characters labelID ; + match_ID := string (ext_ID where they not in test_char2); + ext_LA := extract characters labelLineAccess ; + match_LA := string (ext_LA where they not in test_char2); + ext_vent := extract characters labelvent ; + match_vent:= string (ext_vent where they not in test_char2); + ext_pulmon:= extract characters labelpulmonary ; + match_pulmon:= string (ext_pulmon where they not in test_char2); + ext_neuro := extract characters labelneuro ; + match_neuro:= string (ext_neuro where they not in test_char2); + ext_renal := extract characters labelrenal ; + match_renal:= string (ext_renal where they not in test_char2); + + if match_item = match_bld then + Token:= "|Blood Products|"; + Retreive_Object := "Orders"; + Filterable_Attribute := "o.name"; + Filterable_Operator := "IN" ; + Filterable_Value := " {{{SINGLE-QUOTE}}}Transfuse Cryoprecipitate{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Cryoprecipitate{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Transfuse FFP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Fresh Frozen Plasma{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Transfuse Platelets{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Platelet Products{{{SINGLE-QUOTE}}} " ||", {{{SINGLE-QUOTE}}}Red Cell Products{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Transfuse Granulocytes{{{SINGLE-QUOTE}}} "; // ord_products ; + + elseif + match_item = match_car then + Token:= "|Cardiac|"; + Retreive_Object := "Lab Results"; //"Cardiac Tests"; + Filterable_Attribute := "o.name"; + Filterable_Operator := "IN" ; + Filterable_Value := " {{{SINGLE-QUOTE}}}CPK Isoenzymes{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}CPK MB{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}CPK Total{{{SINGLE-QUOTE}}}" ||",{{{SINGLE-QUOTE}}}Troponin T{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}NT Pro BNP{{{SINGLE-QUOTE}}}"; //ord_products ; + + elseif + match_item = match_coag then + Token:= "|Coagulation|"; + Retreive_Object := "Lab Results"; //"Coag Tests"; + Filterable_Attribute := "o.name"; + Filterable_Operator := "IN" ; + Filterable_Value := " {{{SINGLE-QUOTE}}}Prothrombin/INR{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}APTT{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Fibrinogen{{{SINGLE-QUOTE}}}" ||",{{{SINGLE-QUOTE}}}CBC No Diff (Hemogram Only){{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}CBC (Includes Diff){{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}CBC with Manual Diff{{{SINGLE-QUOTE}}} ";// + + elseif + match_item = match_endo then + Token:= "|Endocrine|"; + Retreive_Object := "Lab Results"; //"Endocrine"; + Filterable_Attribute := "o.name"; + Filterable_Operator := "IN" ; + Filterable_Value := " {{{SINGLE-QUOTE}}}Free T3{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Free T4{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}TSH-3rd Gen{{{SINGLE-QUOTE}}}" ||",{{{SINGLE-QUOTE}}}Cortisol Level Baseline{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Cortisol Level AM{{{SINGLE-QUOTE}}}," + ||" {{{SINGLE-QUOTE}}}Cortisol Level PM{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Glucose Bedside{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Glucose Bedside.{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Glucose Fasting{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Glucose Non-Fasting{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Hemoglobin A1C{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Glucose, BGM Confirmation{{{SINGLE-QUOTE}}} "; + + elseif + match_item = match_gastro then + Token:= "|Gastro|"; + Retreive_Object := "Lab Results"; //"Endocrine"; + Filterable_Attribute := "o.name"; + Filterable_Operator := "IN" ; + Filterable_Value := " {{{SINGLE-QUOTE}}}Amylase Plasma/Serum{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Lipase{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Occult Blood{{{SINGLE-QUOTE}}}" ||", {{{SINGLE-QUOTE}}}Liver Panel{{{SINGLE-QUOTE}}} "; + + elseif + match_item = match_ID then + Token:= "|Infectious Disease|"; + Retreive_Object := "Micro Results"; + Filterable_Attribute := "o.name"; + Filterable_Operator := "IN" ; + Filterable_Value := lab_id_results; + + elseif + match_item = match_LA then + Token:= "|Line Access|"; + Retreive_Object := "Vitals"; + Filterable_Attribute := "ocmi.name"; + Filterable_Operator := "IN" ; + Filterable_Value := obs_name_lines; + Additional_condition := "Line Access"; + + elseif + match_item = match_vent then + Token:= "|Mechanical Ventilation|"; + Retreive_Object := "Vitals"; + Filterable_Attribute := "ocmi.name"; + Filterable_Operator := "IN" ; + Filterable_Value := obs_name_vents; + + elseif + match_item = match_pulmon then + Token:= "|Pulmonary|"; + Retreive_Object := "Lab Results"; + Filterable_Attribute := "o.name"; + Filterable_Operator := "IN" ; + Filterable_Value := " {{{SINGLE-QUOTE}}}Blood Gas Arterial{{{SINGLE-QUOTE}}} "; //obs_name_vents; + + elseif + match_item = match_neuro then + Token:= "|Neurology|"; + + elseif match_item = match_renal then + Token:= "|Renal|"; + Retreive_Object := "Lab Results"; + Filterable_Attribute := "o.name"; + Filterable_Operator := "IN" ; + Filterable_Value := lab_renal_results; + + endif; // match_item = match_bld + + endif; //ext_item is not in Selected_groups + + Endif; // current_parameter_name MATCHES PATTERN "%SCH_MDPN_Grouping Disease%" + + // Get current text in the "write to" target field (This will be used for dup checking) + rtf_target_param := FIRST OF (this_parameters WHERE this_parameters.name = target_parameter_name); + rtf_target_obs := FIRST OF (this_ChartedObservationsList WHERE this_ChartedObservationsList.parameterGUID = rtf_target_param.parameterGUID); + rtf_target_val_obj := rtf_target_obs.valueobj; + rtf_target_text := rtf_target_val_obj.value; + + if called_by_editor then + (client_guid, client_visit_guid, client_chart_guid) := read last {clientvisit: clientguid, guid, chartguid}; + Token:= "|IOSOC|"; + Retreive_Object := "IOSOC"; + target_parameter_name := "SCH_MDPN_FT VS, I & O"; + endif; + + + // Call ACS_Generic_Lookup MLM to retrieve patient data + + (All_Attributes_Lst, All_Values_Lst, All_UoM_Lst, All_Med_Rel_Dttm_Lst, All_Start_Time_Lst, All_Stop_Time_Lst, + All_User_Guid_Lst, All_Significant_Data_Lst, this_documentCommunication, All_Sig_Count_Lst, All_Sig_Nt_Count_Lst) := CALL Get_mlm_Generic_Lookup_data WITH + (this_documentCommunication, client_guid, client_visit_guid,client_chart_guid, Is_Historical,Retreive_Object,Retreive_Attribute, + Filterable_Attribute, Filterable_Operator,Filterable_Value, Additional_condition); + //,All_Sig_Nt_Count_Lst Added to Above Receivable Variables list-Added by shivprasad for CSR:32982 + + // Service + + If Token = "|Service|" and (not (rtf_target_text matches pattern "%Service:%") + or (rtf_target_text matches pattern "%Service:%") is null) Then + + If Exists All_Values_Lst Then // If exists Then Assigning the Result to the local session object + Result_String := Result_String || "\b Service: \b0 " || FIRST OF (All_Values_Lst) ; + + Else + Result_String := "\b No Service Data Available. \b0" ; + + EndIf; + + topic_var:= FIRST OF (All_Values_Lst) ; // Populate Topic with Service + + + // Health Issues + + ElseIf Token = "|problems|" Then + + If Exists All_Attributes_Lst Then + Result_String := "\b Problems: \b0 \n" ; + For i IN 1 SEQTO count of All_Attributes_Lst Do + Result_String := Result_String || i ||". " || All_Attributes_Lst[i]|| "\n" ; + EndDo; //For i IN SEQTO count of allHealthIssues Do + Else + Result_String := "\b No Problems Listed. \b0" ; + EndIf; //All_Attributes_Lst +/* + +// Commented out this section for CSR# 32616 re-introduced DOC_FUNC_VS_24hrs for Vital Signt data + + // Vitals + + ElseIf Token = "|Vitals|" Then + If Exists All_Attributes_Lst Then + test_null:= null; + Result_String_1 := "\b Vital Signs-Last Charted: \b0"; + + t_val_0:= last of (All_Values_Lst where (All_Attributes_Lst="Farenheit" )); + t_time := last of (All_Med_Rel_Dttm_Lst where (All_Attributes_Lst="Farenheit")); + t_val:= tab || "\b T: \b0 "||string (t_val_0 where it not in test_null) || sp2; //tab; + + hr_val_0 := last of (All_Values_Lst where (All_Attributes_Lst = "Heart Rate" )); + hr_time := last of (All_Med_Rel_Dttm_Lst where (All_Attributes_Lst="Heart Rate")); + hr_val:=tab || "\b HR: \b0 "||string (hr_val_0 where it not in test_null )|| sp2; //tab; + + sbp_val := last of (All_Values_Lst where (All_Attributes_Lst = "Noninvasive Systolic BP" )); + dbp_val := last of (All_Values_Lst where (All_Attributes_Lst="Noninvasive Diastolic BP" )); + bp_time := last of (All_Med_Rel_Dttm_Lst where (All_Attributes_Lst = "Noninvasive Systolic BP" )); + bp_val:=tab||"\b BP: \b0 "||string(sbp_val||" / "||dbp_val) || sp2 where sbp_val not in test_null or dbp_val not in test_null; + + rr_val_0 := last of (All_Values_Lst where (All_Attributes_Lst="Resp Rate")); + rr_time := last of (All_Med_Rel_Dttm_Lst where (All_Attributes_Lst="Resp Rate")); + rr_val:= tab||"\b R: \b0 "||string (rr_val_0 where it not in test_null) || sp2; //tab; + + pox_val_0 := last of (All_Values_Lst where (All_Attributes_Lst = "SCH_vs_pulse ox saturation" )) ; + pox_time := last of (All_Med_Rel_Dttm_Lst where (All_Attributes_Lst="SCH_vs_pulse ox saturation")); + pox_val:=tab ||"\b Pulse Ox: \b0 "||string (pox_val_0 where it not in test_null) || sp2; //tab; + + o2_val_0 := last of (All_Values_Lst where (All_Attributes_Lst="L/min")); + o2_time := last of (All_Med_Rel_Dttm_Lst where (All_Attributes_Lst="L/min")); + o2_val:=tab||"\b O2 L/min: \b0 "||string (o2_val_0 where it not in test_null) || sp2; //tab; + + ht_cm_0 := last of (All_Values_Lst where (All_Attributes_Lst="height in cm")); + ht_cm_time := last of (All_Med_Rel_Dttm_Lst where (All_Attributes_Lst="height in cm")); + ht_cm_val:=tab||"\b Ht/cm: \b0 "||string (ht_cm_0 where it not in test_null) || sp2; //tab; + + wt_gm_0 := last of (All_Values_Lst where (All_Attributes_Lst="SCH_Newborn Weight - grams")); + wt_gm_02 := first of (All_Values_Lst where (All_Attributes_Lst="SCH_Newborn Weight - grams")); + wt_gm_pcnt:= ((wt_gm_02 as number) - (wt_gm_0 as number)) / (wt_gm_02 as number) * 100 ; + if (wt_gm_pcnt < 0) then gainloss := "gain"; else gainloss := "loss"; endif; + wt_gm_0 := wt_gm_0 || " (" || round abs wt_gm_pcnt || "% " || gainloss || ")"; + wt_gm_time := last of (All_Med_Rel_Dttm_Lst where (All_Attributes_Lst="SCH_Newborn Weight - grams")); + wt_gm_val:=tab||"\b Wt/gm: \b0 "||string (wt_gm_0 where it not in test_null) || sp2; //tab; + + wt_kg_0 := last of (All_Values_Lst where (All_Attributes_Lst="Weight - kg")); + wt_kg_02 := first of (All_Values_Lst where (All_Attributes_Lst="Weight - kg")); + wt_kg_pcnt:= ((wt_kg_02 as number) - (wt_kg_0 as number)) / (wt_kg_02 as number) * 100 ; + if (wt_kg_pcnt < 0) then gainloss := "gain"; else gainloss := "loss"; endif; + wt_kg_0 := wt_kg_0 || " (" || round abs wt_kg_pcnt || "% " || gainloss || ")"; + wt_kg_time := last of (All_Med_Rel_Dttm_Lst where (All_Attributes_Lst="Weight - kg")); + wt_kg_val:=tab||"\b Wt/kg: \b0 "||string (wt_kg_0 where it not in test_null) || sp2; //tab; + + + sorted_time_list := reverse (sort data All_Med_Rel_Dttm_Lst); + last_vs_time := now + 1 hour; + Result_string_2 := ""; + + for vs_time in sorted_time_list do + vs_line := ""; + if vs_time <> last_vs_time then + if t_time = vs_time then vs_line := vs_line || t_val; endif; + if hr_time = vs_time then vs_line := vs_line || hr_val; endif; + if bp_time = vs_time then vs_line := vs_line || bp_val; endif; + if rr_time = vs_time then vs_line := vs_line || rr_val; endif; + if pox_time = vs_time then vs_line := vs_line || pox_val; endif; + if o2_time = vs_time then vs_line := vs_line || o2_val; endif; + if ht_cm_time = vs_time then vs_line := vs_line || ht_cm_val; endif; + if wt_gm_time = vs_time then vs_line := vs_line || wt_gm_val; endif; + if wt_kg_time = vs_time then vs_line := vs_line || wt_kg_val; endif; + last_vs_time := vs_time; + if vs_line <> "" then + Result_string_2 := Result_string_2 || "\n" || vs_time || vs_line; + endif; + endif; + enddo; + + Result_string:=Result_string_1||Result_string_2; + + Else + Result_String := "\b No vitals recorded. \b0" ; + + EndIf; //All_Attributes_Lst +*/ + // I & O + + ElseIf Token is in ("|IO_Drains_shift|", "|IO_NG_shift|") Then + + if Token = "|IO_Drains_shift|" then + Result_String_1 := "I & O Drains"; + elseif token = "|IO_NG_shift|" then + Result_String_1 := "I & O NG Tube"; + endif; + + If exists All_Values_Lst and any(All_Values_Lst is number) Then + Result_String := "\b Output Total for " ||Result_String_1 || " last shift: \b0 " || int(All_Values_Lst[1]) ; + Else + Result_String := "\b The Output Total for last shift is not available for \b0" || Result_String_1; + EndIf; + + ElseIf Token is in ( "|IO24|","|IOSOC|") Then + + if Token = "|IO24|" then + Result_String_1 := "for the last 24 hours are "; + + elseif Token = "|IOSOC|" then + Result_String_1 := "from the start of this chart are "; + endif; + + If exists All_Values_Lst and any(All_Values_Lst is number) Then + Result_String := "\b Intake and Output Totals: \b0 \n" || Result_string_1 ||": \n" || "\b Intake" || TAB3 || "Output"|| + TAB2 || "Net \b0 \n" || int(All_Values_Lst[1]) || TAB3 || int(All_Values_Lst[2]) || TAB2 || + int(All_Values_Lst[3]) ; + Else + Result_String := "\b The Intake AND Output Totals " || Result_String_1 || " not available \b0"; + EndIf; + + // Active Med Orders/Active Antibiotics + + // HD Ticket 1843849 - Added code to limit the code to procees only when the button is clicked....had been double populating upon close. + + // ElseIf Token IN ("|Active Medications|", "|Active Antibiotics|","|Active Medications with Detail|") Then + ElseIf Token IN ("|Active Medications|", "|Active Antibiotics|","|Active Medications with Detail|") and theEvent = "chartobservation" Then + + current:= now; + test_enter:=(CRLF," "); + If Exists All_Attributes_Lst Then + + if Token = "|Active Medications|" then + Result_String := "\b All Active Medication Orders: \b0 \n" ; + elseIf Token ="|Active Medications with Detail|" then + Result_String := "\b All Active Medication Orders with Details: \b0 \n" ; + else + Result_String := "\b All Active Antibiotic Orders: \b0 \n" ; + meds_sorted_list := (); + meds_unsorted_list := (); + endif; + + For i IN 1 SEQTO count of All_Attributes_Lst Do + len_ad_in_i := length All_Start_Time_Lst[i]; + len_val_i := length All_Values_Lst[i]; + + if len_ad_in_i > 70 then + val_i := substring (len_val_i - len_ad_in_i) characters from All_Values_Lst[i]; + val_i := val_i || " <+ ADDED INSTRUCTIONS...>"; + else + val_i := All_Values_Lst[i]; + endif; + + count_crlf := 0; // newline counter + crlf_start := 1; // newline start position + last_crlf := 0; // last newline position + + while (find CRLF in string val_i starting at crlf_start) > 0 do + count_crlf := count_crlf + 1; // increment newline counter + ext_all_val:= extract characters val_i; // All_Values_Lst[i]; + ct_vals:= count ext_all_val; // count chars in summary line + ret_val:= find CRLF in string val_i starting at crlf_start; // from the last newline. + sub_num:= (ct_vals - ret_val) - 1; + fst_val:= string (first (ret_val -1) from ext_all_val); // string b4 newline + + if not exists fst_val or fst_val = "null" then + fst_val := ""; // gets rid of NULLs + endif; + + lst_val:= string (last sub_num from ext_all_val); // string after newline + crlf_start := ret_val + 1; // reset last found newline position + + if count_crlf > 1 or (ret_val - last_crlf) > 70 then // put in requested indents + val_i := fst_val|| LF||CR || " " || lst_val; + last_crlf := ret_val; + + else + val_i := fst_val || ", " || lst_val; // replace newline with comma + endif; + enddo; + + ext_all_val:= extract characters All_Med_Rel_Dttm_Lst[i]; + lst_val := trim(string (first 16 from ext_all_val)); + ext_task_time := extract characters All_Significant_Data_Lst[i]; + task_time := trim(string (first 16 from ext_task_time)); + + dose_info := " "; + if Token <> "|Active Medications|" then + dose_info := " Order/Start: " || lst_val ; + endif; + + if exists task_time and task_time <> "null" and Token <> "|Active Medications|" then + dose_info := dose_info || " Last Given:" || task_time || " Doses Given:" || All_Sig_Count_Lst[i]; + endif; + + If Token ="|Active Medications with Detail|" Then + //val_i := val_i || " " || dose_info; + val_i := val_i || " " || dose_info ||" Skipped Doses:" || All_Sig_Nt_Count_Lst[i]; // Added By Shivprasad Jadhav For CSR : 32982 + Else + val_i := val_i || " " || dose_info; + Endif; + s_aali := All_Attributes_Lst[i] ; + + + a_a_l_i := read last{"select " || sql(s_aali) || " "}; + +/* + if length s_aali <= 40 then + a_a_l_i := read last{"select convert(char(40), " || sql(s_aali) || ")"}; + + if length s_aali < 20 then + a_a_l_i := a_a_l_i || tab; + endif; + + elseif length s_aali <= 80 then + a_a_l_i := read last{"select convert(char(80), " || sql(s_aali) || ")"}; + else + a_a_l_i := read last{"select convert(char(125), " || sql(s_aali) || ")"}; + + endif; +*/ + + meds_unsorted_list := meds_unsorted_list , + a_a_l_i || val_i; + + EndDo; //For i IN SEQTO count of all Do + + + meds_sorted_list := sort data ((meds_unsorted_list where it is present) as string); + + for j in 1 seqto count meds_sorted_list do + Result_String := Result_String ||"\b "||" "|| j ||" \b0. " || meds_sorted_list[j] || "\n" ; + + enddo; + + + Else + + If Token ="|Active Medications|" then + Result_String := "\b No Active Medications Ordered. \b0 \n" ; + + elseIf Token ="|Active Medications with Detail|" then + Result_String := "\b No Active Medications Ordered.. \b0 \n" ; + else + Result_String := "\b No Active Antibiotics Ordered. \b0 \n" ; + endif; + + EndIf; //All_Attributes_Lst + + + // Lab Results + + // HD Ticket 1843849 - Added code to limit the code to procees only when the button is clicked....had been double populating upon close. + + // ElseIf Token = "|Lab Results|" Then + ElseIf Token = "|Lab Results|" and theEvent = "chartobservation" Then + + current:= now; + test_enter:=(CRLF," "); + test_null:= null; + str_h:= null; + str_l:= null; + str_e:= null; + str_p:= null; + str_a:= null; + str_cb:= null; + str_cd:= null; + str_cr:= null; + str_bm:= null; + str_bu:= null; + str_h_dt:= null; + str_l_dt:= null; + str_e_dt:= null; + str_p_dt:= null; + str_a_dt:= null; + str_cb_dt:= null; + str_cd_dt:= null; + str_cr_dt:= null; + str_bm_dt:= null; + str_bu_dt:= null; + + str_labs:= str_h,str_l,str_e,str_p,str_a,str_cb,str_cd,str_cr,str_bm ; + str_dts:= str_h_dt,str_l_dt,str_e_dt,str_p_dt,str_a_dt,str_cb_dt,str_cd_dt, str_cr_dt,str_bm_dt ; + + ct_slabs:= count str_labs; + ct_dts:= count str_dts; + + If Exists All_Attributes_Lst Then + /// pre-processing into panels + rem_tick:= "{{{SINGLE-QUOTE}}}"; + overall_results:=""; + ext_ord_labs:= extract characters ord_lab_results; + lst_ord_labs:= string (ext_ord_labs where they not in rem_tick); + lab_o_list := call parse_mlm with lst_ord_labs, ","; // parse into separate lists + + All_Attributes_Lst:= reverse All_Attributes_Lst; + All_Med_Rel_Dttm_Lst := reverse All_Med_Rel_Dttm_Lst ; + All_UoM_Lst:= reverse All_UoM_Lst; + All_Values_Lst:= reverse All_Values_Lst; + All_Start_Time_Lst:= reverse All_Start_Time_Lst; + All_Stop_Time_Lst:= reverse All_Stop_Time_Lst; //holds ResultItemCodes + All_Significant_Data_Lst:= reverse All_Significant_Data_Lst; + All_Sig_Count_Lst := reverse All_Sig_Count_Lst; + + interm_results:=""; + interm_results_ap:= ""; + interm_results_b:= ""; + interm_results_bmp:= ""; + interm_results_cbc:= ""; + interm_results_h:= ""; + interm_results_e:= ""; + interm_results_as:= ""; + interm_results_cr:= ""; + interm_results_l:= ""; + int_val_str:=""; + + For i in 1 seqto count All_Attributes_Lst Do + if All_Attributes_Lst[i] = lab_o_list[1] then + l_date:= maximum (All_Med_Rel_Dttm_Lst where All_Attributes_Lst[i] = lab_o_list[1]); + + if str_a IS NULL and (All_Med_Rel_Dttm_Lst[i] = l_date) then + l_date:= (All_Med_Rel_Dttm_Lst[i]); + use_date:=(l_date) FORMATTED WITH "%.4t"||":" ; + str_a:= CRLF||CRLF|| use_date ||" Last Resulted "||lab_o_list[1]||"\n"||All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + interm_results_ap:= interm_results_ap, l_date; + + elseif (NOT ((All_Med_Rel_Dttm_Lst[i]) IN interm_results_ap)) then + l_date:= (All_Med_Rel_Dttm_Lst[i]); + use_date:=(l_date) FORMATTED WITH "%.4t"||":" ; + str_a:= str_a, CRLF|| CRLF || use_date || " Resulted " || lab_o_list[1] || "\n" || All_Stop_Time_Lst[i] || ":" || All_Values_Lst[i]|| ", "; + interm_results_ap:= interm_results_ap, l_date; + + else + str_a:= str_a,All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + + endif; + + str_a_dt:=str_a_dt,(All_Med_Rel_Dttm_Lst[i] FORMATTED WITH "%.4t"); + + elseif All_Attributes_Lst[i] IN (lab_o_list[2]) + AND All_Stop_Time_Lst[i] in ("NA", "K", "CO2", "CL", "BUN", "CREAT", "Glu") + then + l_date_1:= maximum (All_Med_Rel_Dttm_Lst where All_Attributes_Lst matches pattern "Ba%" ); + + if str_bm IS NULL and (All_Med_Rel_Dttm_Lst[i] = l_date_1) then + l_date:= (All_Med_Rel_Dttm_Lst[i]); + use_date:=(l_date) FORMATTED WITH "%.4t"||":" ; + str_bm:= CRLF||CRLF|| use_date||" Last Resulted BMP \n" ||All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + interm_results_bmp:= interm_results_bmp, l_date; + + elseif (NOT ((All_Med_Rel_Dttm_Lst[i]) IN interm_results_bmp)) then + l_date:= (All_Med_Rel_Dttm_Lst[i]); + use_date:=(l_date) FORMATTED WITH "%.4t"||":" ; + str_bm:= str_bm, CRLF||CRLF|| use_date ||" Resulted BMP \n" ||All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + interm_results_bmp:= interm_results_bmp, l_date; + + else + str_bm:= str_bm,All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + + endif; + + str_bm_dt:=str_bm_dt,(All_Med_Rel_Dttm_Lst[i] FORMATTED WITH "%.4t"); + + elseif All_Attributes_Lst[i] IN (lab_o_list[3]) then + l_date:= maximum (All_Med_Rel_Dttm_Lst where All_Attributes_Lst matches pattern "BU%" ); + + if str_bu IS NULL and All_Med_Rel_Dttm_Lst[i] = l_date then + l_date:= (All_Med_Rel_Dttm_Lst[i]); + use_date:=(l_date) FORMATTED WITH "%.4t"||":" ; + str_bu:= CRLF||CRLF|| use_date||" Last Resulted BUN \n" ||All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + interm_results_b:= interm_results_b, l_date; + + elseif NOT ((All_Med_Rel_Dttm_Lst[i]) IN interm_results_b) then + l_date:= (All_Med_Rel_Dttm_Lst[i]); + use_date:=(l_date) FORMATTED WITH "%.4t"||":" ; + str_bu:= str_bu,CRLF||CRLF|| use_date||" Resulted BUN \n" ||All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + interm_results_b:= interm_results_b, l_date; + + else + str_bu:= str_bu,All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + + endif; + str_bu_dt:=str_bu_dt,(All_Med_Rel_Dttm_Lst[i] FORMATTED WITH "%.4t"); + + elseif All_Attributes_Lst[i] IN (lab_o_list[4], lab_o_list[5]) + AND All_Stop_Time_Lst[i] in ( "WBC", "Hgb", "HCT", "PLTC") then + + if All_Stop_Time_Lst[i] = "PLTC" then + All_Stop_Time_Lst[i] := "PLT"; + endif; + + l_date_1:= maximum (All_Med_Rel_Dttm_Lst where All_Attributes_Lst matches pattern "CBC%" ); + + if str_cb IS NULL and // or + (All_Med_Rel_Dttm_Lst[i] = l_date_1) then + l_date:= (All_Med_Rel_Dttm_Lst[i]); + use_date:=(l_date) FORMATTED WITH "%.4t"||":" ; + str_cb:= CRLF||CRLF|| use_date ||" Last Resulted CBC \n" ||All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + interm_results_cbc:= interm_results_cbc, l_date; + + elseif (NOT ((All_Med_Rel_Dttm_Lst[i]) IN interm_results_cbc)) then + l_date:= (All_Med_Rel_Dttm_Lst[i]); + use_date:=(l_date) FORMATTED WITH "%.4t"||":" ; + str_cb:= str_cb, CRLF||CRLF|| use_date ||" Resulted CBC \n" ||All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + interm_results_cbc:= interm_results_cbc, l_date; + + else + str_cb:= str_cb,All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + + endif; + + str_cb_dt:=str_cb_dt,(All_Med_Rel_Dttm_Lst[i] FORMATTED WITH "%.4t"); + + elseif All_Attributes_Lst[i] = lab_o_list[6] then + l_date_1:= maximum (All_Med_Rel_Dttm_Lst where All_Attributes_Lst[i] = lab_o_list[6]); + + if str_cr IS NULL and (All_Med_Rel_Dttm_Lst[i] = l_date_1) then + l_date:= (All_Med_Rel_Dttm_Lst[i]); + use_date:=(l_date) FORMATTED WITH "%.4t"||":" ; + str_cr:= CRLF||CRLF|| use_date ||" Last Resulted "||lab_o_list[6] ||"\n"||All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + interm_results_cr:= interm_results_cr, l_date; + + elseif (NOT ((All_Med_Rel_Dttm_Lst[i]) IN interm_results_cr)) then + l_date:= (All_Med_Rel_Dttm_Lst[i]); + use_date:=(l_date) FORMATTED WITH "%.4t"||":" ; + str_cr:= str_cr, CRLF||CRLF|| use_date ||" Last Resulted " ||lab_o_list[6]||"\n" ||All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + interm_results_cr:= interm_results_cr, l_date; + + else + str_cr:= str_cr,All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + + endif; + + str_cr_dt:=str_cr_dt,(All_Med_Rel_Dttm_Lst[i] FORMATTED WITH "%.4t"); + + elseif All_Attributes_Lst[i] = lab_o_list[7] + AND All_Stop_Time_Lst[i] in ("NA", "K", "CO2", "CL", "BUN", "Cr", "Glu") + then + l_date_1:= maximum (All_Med_Rel_Dttm_Lst where All_Attributes_Lst matches pattern "Electrolyte%" ); + + if str_e IS NULL and (All_Med_Rel_Dttm_Lst[i] = l_date_1) then + l_date:= (All_Med_Rel_Dttm_Lst[i]); + use_date:=(l_date) FORMATTED WITH "%.4t"||":" ; + str_e:= str_e, CRLF||CRLF|| use_date ||" Last Resulted " ||lab_o_list[7]||"\n" ||All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + interm_results_e:= interm_results_e, l_date; + + elseif (NOT ((All_Med_Rel_Dttm_Lst[i]) IN interm_results_e)) then + l_date:= (All_Med_Rel_Dttm_Lst[i]); + use_date:=(l_date) FORMATTED WITH "%.4t"||":" ; + str_e:= str_e, CRLF||CRLF|| use_date ||" Resulted "||lab_o_list[7]||"\n" ||All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + interm_results_e:= interm_results_e, l_date; + + else + str_e:= str_e,All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + + endif; + + str_e_dt:=str_e_dt,(All_Med_Rel_Dttm_Lst[i]FORMATTED WITH "%.4t"); + + elseif All_Attributes_Lst[i] = lab_o_list[8] then + l_date_1:= maximum (All_Med_Rel_Dttm_Lst where All_Attributes_Lst[i] = lab_o_list[8]); + + if str_h IS NULL and (All_Med_Rel_Dttm_Lst[i] = l_date_1) then + l_date:= (All_Med_Rel_Dttm_Lst[i]); + use_date:=(l_date) FORMATTED WITH "%.4t"||":" ; + str_h:= CRLF||CRLF|| use_date ||" Last Resulted H & H \n " ||All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + interm_results_h:= interm_results_h, l_date; + + elseif (NOT ((All_Med_Rel_Dttm_Lst[i]) IN interm_results_h)) then + l_date:= (All_Med_Rel_Dttm_Lst[i]); + use_date:=(l_date) FORMATTED WITH "%.4t"||":" ; + str_h:= str_h, CRLF||CRLF|| use_date ||" Resulted H & H \n "||All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + interm_results_h:= interm_results_h, l_date; + else + + str_h:= str_h,All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + + endif; + + str_h_dt:=str_h_dt,(All_Med_Rel_Dttm_Lst[i] FORMATTED WITH "%.4t"); + + elseif All_Attributes_Lst[i] = lab_o_list[9] AND All_Stop_Time_Lst[i] in ("SGOT","SGPT","AlkP","BiliT","Alb","Prot") then + l_date_1:= maximum (All_Med_Rel_Dttm_Lst where All_Attributes_Lst = lab_o_list[9]); + + if str_l IS NULL and //then + (All_Med_Rel_Dttm_Lst[i] = l_date_1) then + l_date:= (All_Med_Rel_Dttm_Lst[i]); + use_date:=(l_date) FORMATTED WITH "%.4t"||":" ; + str_l:= CRLF||CRLF|| use_date ||" Last Resulted "||lab_o_list[9] ||"\n" ||All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + interm_results_l:= interm_results_l, l_date; + + elseif (NOT ((All_Med_Rel_Dttm_Lst[i]) IN interm_results_l)) then + l_date:= (All_Med_Rel_Dttm_Lst[i]); + use_date:=(l_date) FORMATTED WITH "%.4t"||":" ; + str_l:= str_l, CRLF||CRLF|| use_date ||" Resulted " ||lab_o_list[9]||"\n" ||All_Stop_Time_Lst[i]||":"|| All_Values_Lst[i]||", "; + interm_results_l:= interm_results_l, l_date; + + else + str_l:= str_l,All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + + endif; + + str_l_dt:=str_l_dt,(All_Med_Rel_Dttm_Lst[i] FORMATTED WITH "%.4t")as time; + + elseif All_Attributes_Lst[i] = lab_o_list[10] then + + if str_p IS NULL then + l_date:= (All_Med_Rel_Dttm_Lst[i]); + use_date:=(l_date) FORMATTED WITH "%.4t"||":" ; + str_p:= CRLF||CRLF|| use_date ||" Last Resulted PT/INR \n" ||All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + interm_results:= interm_results, l_date; + + elseif NOT ((All_Med_Rel_Dttm_Lst[i]) IN interm_results) then + l_date:= (All_Med_Rel_Dttm_Lst[i]); + use_date:=(l_date) FORMATTED WITH "%.4t"||":" ; + str_p:= str_p,CRLF||CRLF|| use_date ||" Resulted PT/INR \n" ||All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + interm_results:= interm_results, l_date; + + else + str_p:= str_p,All_Stop_Time_Lst[i]||":"||All_Values_Lst[i]||", "; + + endif; + + str_p_dt:=str_p_dt,(All_Med_Rel_Dttm_Lst[i] FORMATTED WITH "%.4t") ; + + endif; + + enddo; + + str_labs:= str_h,str_l,str_e,str_p,str_a,str_cb,str_cd,str_cr,str_bm, str_bu ; + str_dts:= str_h_dt,str_l_dt,str_e_dt,str_p_dt,str_a_dt,str_cb_dt,str_cd_dt, str_cr_dt,str_bm_dt, str_bu_dt ; + ct_slabs:= count str_labs; + ct_dts:= count str_dts; + + for r in 1 seqto ct_slabs DO + + if str_labs[r] is not NULL then + overall_results:=overall_results||str_labs[r]; + endif; + + enddo; + + Result_String := "\b Lab Results: \b0 " ||overall_results ; + else + + Result_String := "\b No Lab Results Reported. \b0" ; + + EndIf; // if All_Attributes_Lst + + // Subjective + + ElseIf Token = "|Subjective|" Then + Result_String := "\b Subjective: \b0" ; + + + // Blood Products Groupings + + + ElseIf Token = "|Blood Products|" and (not (rtf_target_text matches pattern "%Blood Prod%") + or (rtf_target_text matches pattern "%Blood Prod%") is null) then + current:= now; + test_enter:=(CRLF," "); + target_parameter_name := "SCH_MDPN_Groupings"; + + If Exists All_Attributes_Lst Then + Result_String := "\b Blood Products \b0"||CRLF||tab||"\b Blood Products: \b0 \n" ; + For i IN 1 SEQTO count of All_Attributes_Lst Do + ext_all_val:= extract characters All_Med_Rel_Dttm_Lst[i]; + lst_val:= string (first 16 from ext_all_val); + Result_String := Result_String ||tab || All_Attributes_Lst[i]||", Ordered: "||lst_val|| "\n" ; + EndDo; //For i IN SEQTO count of all Do + + Else + Result_String := "\b Blood Products \b0" || CRLF || tab || "No Active Blood Products Ordered. \n" ; + + EndIf; //All_Attributes_Lst + + Result_String := Result_String || blt_char; + + + // Cardiac Groupings + + + ElseIf Token = "|Cardiac|" and (not (rtf_target_text matches pattern "%Cardiac%") + or (rtf_target_text matches pattern "%Cardiac%") is null) Then + current:= now; + test_enter:=(CRLF," "); + target_parameter_name := "SCH_MDPN_Groupings"; + Result_String := "\b Cardiac \b0"||CRLF; + + If Exists All_Attributes_Lst Then + Result_String := Result_String ||tab||"\b Cardiac Tests: \b0 \n" ; + + For i IN 1 SEQTO count of All_Attributes_Lst Do + ext_all_val:= extract characters All_Med_Rel_Dttm_Lst[i]; + lst_val:= string (first 16 from ext_all_val); + + if All_UoM_Lst[i] is null then + All_UoM_Lst[i] := " "; + endif; + + if All_Stop_Time_lst[i] matches pattern "TNT%" then + All_Stop_Time_lst[i]:= All_Attributes_Lst[i]; + endif; + + if not (All_Values_Lst[i] matches pattern "NOTE%") then + Result_String := Result_String ||tab || lst_val || ", " || All_Stop_Time_lst[i] || ": "|| All_Values_Lst[i] || sp || All_UoM_Lst[i] || "\n" ; + endif; + + EndDo; //For i IN SEQTO count of all Do + + Else + Result_String := Result_String ||"No Cardiac Lab Tests Performed. \n" ; + + EndIf; //All_Attributes_Lst + + // Orders + + Retreive_Object := "Orders"; + Filterable_Attribute := "o.name"; + Filterable_Operator := "IN" ; + Filterable_Value := "{{{SINGLE-QUOTE}}}Pharmaceutical Stress Echocardiogram{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Stress Echo{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Echo 2D M Mode + Color Doppler (Routine){{{SINGLE-QUOTE}}}" + || ",{{{SINGLE-QUOTE}}}Exercise Radionuclide Stress{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}EKG 12 Lead{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}EKG 12 Lead PRN Chest Pain{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Right Heart Cath{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Left Heart Cath{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Right + Left Heart Cath{{{SINGLE-QUOTE}}}" + || ",{{{SINGLE-QUOTE}}}Right + Left Heart Cath with Grafts{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Left Heart Cath with Grafts{{{SINGLE-QUOTE}}}"; + + + // Call ACS_Generic_Lookup MLM to retrieve patient data + + (All_Attributes_Lst, All_Values_Lst, All_UoM_Lst, All_Med_Rel_Dttm_Lst, All_Start_Time_Lst, All_Stop_Time_Lst, + All_User_Guid_Lst, All_Significant_Data_Lst, this_documentCommunication, All_Sig_Count_Lst) := CALL Get_mlm_Generic_Lookup_data WITH + (this_documentCommunication, client_guid, client_visit_guid,client_chart_guid, Is_Historical,Retreive_Object,Retreive_Attribute, + Filterable_Attribute, Filterable_Operator,Filterable_Value, Additional_condition); + + + If Exists All_Attributes_Lst Then + Result_String := Result_String ||tab || "\b Cardiac Orders: \b0 \n" ; + For i IN 1 SEQTO count of All_Attributes_Lst Do + ext_all_val:= extract characters All_Med_Rel_Dttm_Lst[i]; + lst_val:= string (first 16 from ext_all_val); + Result_String := Result_String ||tab || All_Attributes_Lst[i]||", Ordered: "||lst_val|| "\n" ; + EndDo; //For i IN SEQTO count of all Do + + Else + + Result_String := Result_String || tab || "No Active Cardiac Tests Ordered. \n" ; + endif; + + // Observations + + Retreive_Object := "Vitals"; + Filterable_Attribute := "ocmi.name"; + Filterable_Operator := "IN" ; + Filterable_Value := "{{{SINGLE-QUOTE}}}rhythm{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}heart sounds{{{SINGLE-QUOTE}}}"; + + + // Call ACS_Generic_Lookup MLM to retrieve patient data + + (All_Attributes_Lst, All_Values_Lst, All_UoM_Lst, All_Med_Rel_Dttm_Lst, All_Start_Time_Lst, All_Stop_Time_Lst, + All_User_Guid_Lst, All_Significant_Data_Lst, this_documentCommunication, All_Sig_Count_Lst) := CALL Get_mlm_Generic_Lookup_data WITH + (this_documentCommunication, client_guid, client_visit_guid,client_chart_guid, Is_Historical,Retreive_Object,Retreive_Attribute, + Filterable_Attribute, Filterable_Operator,Filterable_Value, Additional_condition); + + + If Exists All_Attributes_Lst Then + test_null:= null; + Result_String_1 := "\b Cardiac observations-Last Charted: \b0 "; + + hs_val_0 := last of (All_Values_Lst where (All_Attributes_Lst="Heart sounds")); + hs_time := last of (All_Med_Rel_Dttm_Lst where (All_Attributes_Lst="Heart sounds")); + hs_val:=tab||"Heart Sounds: "||string (hs_val_0 where it not in test_null) || tab; + + hr_val_0 := last of (All_Values_Lst where (All_Attributes_Lst="Rhythm")); + hr_time := last of (All_Med_Rel_Dttm_Lst where (All_Attributes_Lst="Rhythm")); + hr_val:=tab||"Rhythm: "||string (hr_val_0 where it not in test_null) || tab; + + sorted_time_list := reverse (sort data All_Med_Rel_Dttm_Lst); + last_vs_time := now + 1 hour; + Result_string_2 := ""; + + for vs_time in sorted_time_list do + vs_line := ""; + if vs_time <> last_vs_time then + if hs_time = vs_time then vs_line := vs_line || hs_val; endif; + if hr_time = vs_time then vs_line := vs_line || hr_val; endif; + last_vs_time := vs_time; + if vs_line <> "" then + Result_string_2 := Result_string_2 || "\n" || tab2 || vs_time || vs_line; + endif; + endif; + enddo; + + Result_string := Result_String || tab || Result_string_1 || Result_string_2 ||"\n"; + + Else + Result_String := Result_String || tab || "No Cardiac observations Recorded.\n"; + + endif; + + // Impressions + + Retreive_Attribute := "text_val"; + Retreive_Object := "Results"; + Filterable_Attribute := "itemname"; + Filterable_Operator := "IN" ; + Filterable_Value := + "{{{SINGLE-QUOTE}}}Cardiac Cath Right{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Cardiac Cath Left Routine{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Cardiac Cath Left + Right{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Cardiac Cath Left with Grafts{{{SINGLE-QUOTE}}}" + ||", {{{SINGLE-QUOTE}}}Cardiac Cath Right + Left w/Grafts{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Pharmaceutical Stress Echocardiogram{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Stress Echo{{{SINGLE-QUOTE}}}" + ||", {{{SINGLE-QUOTE}}}Echo 2D M Mode + Color Doppler (Routine){{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Exercise Radionuclide Stress{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}EKG 12 Lead PRN Chest Pain{{{SINGLE-QUOTE}}}" + ||", {{{SINGLE-QUOTE}}}EKG 12 Lead{{{SINGLE-QUOTE}}}"; + Additional_condition := " performeddtm > dateadd(mm, -24, getdate()) "; + + + // Call Impression Lookup MLM to get patient data + + (All_Attributes_Lst, All_Med_Rel_Dttm_Lst, All_Values_Lst) := CALL Get_result_impression_lookup WITH + (client_guid, client_visit_guid, client_chart_guid, Is_Historical, Retreive_Object, Retreive_Attribute, + Filterable_Attribute, Filterable_Operator, Filterable_Value, Additional_condition); + + If Exists All_Attributes_Lst Then + for k in 1 seqto count All_Attributes_Lst do + Result_string := Result_String || "\n" || All_Attributes_Lst[k] || " " || All_Med_Rel_Dttm_Lst[k] || ": " + || All_Values_Lst[k] || "\n" ; + enddo; + + Else + Result_String := Result_String || tab || "No diagnostic impressions Recorded. \n" ; + + endif; + + Result_String := Result_String || blt_char; + + + // Coagulation Groupings + + + ElseIf Token = "|Coagulation|" + and (not (rtf_target_text matches pattern "%Coagulation%") or (rtf_target_text matches pattern "%Coagulation%") is null) Then + current:= now; + test_enter:=(CRLF," "); + target_parameter_name := "SCH_MDPN_Groupings"; + Result_String := "\b Coagulation \b0 "||CRLF; + + If Exists All_Attributes_Lst Then + All_Attributes_Lst:= reverse All_Attributes_Lst; + All_Med_Rel_Dttm_Lst := reverse All_Med_Rel_Dttm_Lst ; + All_UoM_Lst:= reverse All_UoM_Lst; + All_Values_Lst:= reverse All_Values_Lst; + All_Start_Time_Lst:= reverse All_Start_Time_Lst; + All_Significant_Data_Lst:= reverse All_Significant_Data_Lst; + All_Sig_Count_Lst := reverse All_Sig_Count_Lst; + All_Stop_Time_lst:= reverse All_Stop_Time_lst; // holds ResultItemCode + Result_String := Result_String ||tab|| "\b Coagulation Tests: \b0 \n" ; + + For i IN 1 SEQTO count of All_Attributes_Lst Do + ext_all_val:= extract characters All_Med_Rel_Dttm_Lst[i]; + lst_val:= string (first 16 from ext_all_val); + + if not (All_Stop_Time_lst[i] in ("ABBASO","ABEOS","ABLYM", "ABMONO", "ABNEUT","EBASO", "HYPOC", "EEOS", "ELYMPH", "EMONOS", + "ABASO", "AEOS", "ABAN","ALYM", "AMON", "BAND","APOLY", "BASO", "ANISO", "MICRO","META","MONO", "NEUABS","POLY","EOS","LYMPH", "MACRO", "NRBC", "REALY","RMOR", + "MCH", "MCV", "RDWCV", "RDWSD","MCHC", "MPV", "ENEUT", "RDW", "RMARK","RCOM", "WCOM", "PCOM" )) then + + if All_UoM_Lst[i] is null then + All_UoM_Lst[i] := " "; + endif; + + if All_Stop_Time_Lst[i] = "PLTC" then + All_Stop_Time_Lst[i] := "PLT"; + endif; + + if All_Stop_Time_Lst[i] = "FIBR" then + All_Stop_Time_Lst[i] := All_Start_Time_Lst[i]; // "Fibrinogen"; + endif; + + Result_String := Result_String ||tab + ||lst_val|| ", " || All_Stop_Time_lst[i]||": " ||All_Values_Lst[i]||sp||All_UoM_Lst[i]|| "\n" ; + endif; + + EndDo; //For i IN SEQTO count of all Do + + Else + Result_String := Result_String || "No Coagulation Studies Performed. \n" ; + + EndIf; //All_Attributes_Lst + + // Orders + + Retreive_Object := "Orders"; + Filterable_Attribute := "o.name"; + Filterable_Operator := "Like" ; + Filterable_Value := ( "Enoxaparin Inj","Rivaroxaban 10mg Tab","Heparin","Warfarin","Coumadin","Lovenox","Pradaxa","Argatoban" ); + Additional_condition := " o.typecode = {{{SINGLE-QUOTE}}}medication{{{SINGLE-QUOTE}}} "; + + + // Call ACS_Generic_Lookup MLM to retrieve patient data + + (All_Attributes_Lst, All_Values_Lst, All_UoM_Lst, All_Med_Rel_Dttm_Lst, All_Start_Time_Lst, All_Stop_Time_Lst, + All_User_Guid_Lst, All_Significant_Data_Lst, this_documentCommunication, All_Sig_Count_Lst) := CALL Get_mlm_Generic_Lookup_data WITH + (this_documentCommunication, client_guid, client_visit_guid,client_chart_guid, Is_Historical,Retreive_Object,Retreive_Attribute, + Filterable_Attribute, Filterable_Operator,Filterable_Value, Additional_condition); + + + If Exists All_Attributes_Lst Then + Result_String := Result_String || tab || "\b AntiCoag Orders: \b0 \n" ; + For i IN 1 SEQTO count of All_Attributes_Lst Do + ext_all_val:= extract characters All_Med_Rel_Dttm_Lst[i]; + lst_val := string (first 16 from ext_all_val); + ext_task_time := extract characters All_Significant_Data_Lst[i]; + task_time := string (first 16 from ext_task_time); + Result_String := Result_String || tab || All_Attributes_Lst[i] || ", Ordered: " || lst_val ; + + if exists task_time and task_time <> "null" + then + Result_String := Result_String || tab || ", Given: " || task_time ; + endif; + + Result_String := Result_String || "\n" ; + + EndDo; //For i IN SEQTO count of all Do + + Else + Result_String := Result_String ||tab || "No Anticoagulants Ordered. \n" ; + + endif; + + Result_String := Result_String || blt_char; + + + // Endocrine Groupings + + + ElseIf Token = "|Endocrine|" and (not (rtf_target_text matches pattern "%Endocrine%") + or (rtf_target_text matches pattern "%Endocrine%") is null) Then + current:= now; + test_enter:=(CRLF," "); + target_parameter_name := "SCH_MDPN_Groupings"; + Result_String := "\b Endocrine \b0 "||CRLF; + + If Exists All_Attributes_Lst Then + All_Attributes_Lst:= reverse All_Attributes_Lst; + All_Med_Rel_Dttm_Lst := reverse All_Med_Rel_Dttm_Lst ; + All_UoM_Lst:= reverse All_UoM_Lst; + All_Values_Lst:= reverse All_Values_Lst; + All_Start_Time_Lst:= reverse All_Start_Time_Lst; + All_Significant_Data_Lst:= reverse All_Significant_Data_Lst; + All_Sig_Count_Lst := reverse All_Sig_Count_Lst; + All_Stop_Time_lst:= reverse All_Stop_Time_lst; // holds ResultItemCode + Result_String := Result_String ||tab|| "\b Endocrine Tests: \b0 \n" ; + + For i IN 1 SEQTO count of All_Attributes_Lst Do + ext_all_val:= extract characters All_Med_Rel_Dttm_Lst[i]; + lst_val:= string (first 16 from ext_all_val); + + // Format for Display + + if All_Stop_Time_lst[i] matches pattern "Guide%" then All_Stop_Time_lst[i] := null; + elseif All_Stop_Time_lst[i] matches pattern "PEC%" then All_Stop_Time_lst[i] := "HgbA1C"; + elseif All_Stop_Time_lst[i] matches pattern "GLUF%" then All_Stop_Time_lst[i] := "Glucose-Fasting"; + elseif All_Stop_Time_lst[i] matches pattern "GLUB%" then All_Stop_Time_lst[i] := "Glucose-Bedside"; + elseif All_Stop_Time_lst[i] matches pattern "GLU%" then All_Stop_Time_lst[i] := "Glucose-Non-Fasting"; + elseif All_Stop_Time_lst[i] matches pattern "CORT%" then All_Stop_Time_lst[i] := All_Start_Time_Lst[i]; + elseif All_Stop_Time_lst[i] matches pattern "TSH3%" then All_Stop_Time_lst[i] := "TSH 3rd Gen"; + elseif All_Stop_Time_lst[i] matches pattern "GLUCON%" then All_Stop_Time_lst[i] := "Glucose, BGM Confirmation"; + endif; + + if all_uom_lst[i] is not null then + Result_String := Result_String ||tab ||lst_val|| ", " || All_Stop_Time_lst[i]||": " ||All_Values_Lst[i]||sp||All_UoM_Lst[i]|| "\n" ; + endif; + + EndDo; //For i IN SEQTO count of all Do + + Else + + Result_String := Result_String || "No Endocrine Studies Performed. \n" ; + + EndIf; //All_Attributes_Lst + + // Orders + + Retreive_Object := "Orders"; //"Therap_Cat_Orders"; //"Abx Orders"; + Filterable_Attribute := "ocmi.TherapeuticCategory"; //"ct.code"; + Filterable_Operator := "IN"; + Filterable_Value := ord_class_endo; + + + // Call ACS_Generic_Lookup MLM to retrieve patient data + + (All_Attributes_Lst, All_Values_Lst, All_UoM_Lst, All_Med_Rel_Dttm_Lst, All_Start_Time_Lst, All_Stop_Time_Lst, + All_User_Guid_Lst, All_Significant_Data_Lst, this_documentCommunication, All_Sig_Count_Lst) := CALL Get_mlm_Generic_Lookup_data WITH + (this_documentCommunication, client_guid, client_visit_guid,client_chart_guid, Is_Historical,Retreive_Object,Retreive_Attribute, + Filterable_Attribute, Filterable_Operator,Filterable_Value, Additional_condition); + + + If Exists All_Attributes_Lst Then + Result_String := Result_String || tab || "\b Endocrine Orders: \b0 \n" ; + + For i IN 1 SEQTO count of All_Attributes_Lst Do + ext_all_val:= extract characters All_Med_Rel_Dttm_Lst[i]; + lst_val := string (first 16 from ext_all_val); + ext_task_time := extract characters All_Significant_Data_Lst[i]; + task_time := string (first 16 from ext_task_time); + + Result_String := Result_String || tab || All_Attributes_Lst[i] || ", Ordered: " || lst_val ; + + if exists task_time and task_time <> "null" then + Result_String := Result_String || tab || ", Given: " || task_time ; + endif; + + Result_String := Result_String || "\n" ; + + EndDo; //For i IN SEQTO count of all Do + + Else + Result_String := Result_String ||tab || "No Endocrine Meds Ordered. \n" ; + + endif; + + Result_String := Result_String || blt_char; + + + // Gastro Groupings + + + ElseIf Token = "|Gastro|" and (not (rtf_target_text matches pattern "%Gastro%") + or (rtf_target_text matches pattern "%Gastro%") is null) Then + current:= now; + test_enter:=(CRLF," "); + target_parameter_name := "SCH_MDPN_Groupings"; + Result_String := "\b Gastro \b0"||CRLF; + + If Exists All_Attributes_Lst Then + + All_Attributes_Lst:= reverse All_Attributes_Lst; + All_Med_Rel_Dttm_Lst := reverse All_Med_Rel_Dttm_Lst ; + All_UoM_Lst:= reverse All_UoM_Lst; + All_Values_Lst:= reverse All_Values_Lst; + All_Start_Time_Lst:= reverse All_Start_Time_Lst; + All_Significant_Data_Lst:= reverse All_Significant_Data_Lst; + All_Sig_Count_Lst := reverse All_Sig_Count_Lst; + All_Stop_Time_lst:= reverse All_Stop_Time_lst; // holds ResultItemCode + Result_String := Result_String ||tab||"\b Gastro Tests: \b0 \n" ; + + For i IN 1 SEQTO count of All_Attributes_Lst Do + ext_all_val:= extract characters All_Med_Rel_Dttm_Lst[i]; + lst_val:= string (first 16 from ext_all_val); + + if All_UoM_Lst[i] is null then + All_UoM_Lst[i] := " "; + endif; + + if All_Attributes_Lst[i] matches pattern "Occult%" then + + if All_Values_Lst[i] is null then + all_values_lst[i]:= string (All_Significant_Data_Lst[i]) ; + endif; + + All_Stop_Time_lst[i]:= All_Attributes_Lst[i]; + + endif; + // format Liver Panel et al for display + + if All_Stop_Time_lst[i] matches pattern "BILIT%" then All_Stop_Time_lst[i] := "Bili Total"; + elseif All_Stop_Time_lst[i] matches pattern "BILID%" then All_Stop_Time_lst[i] := "Bili Direct"; + elseif All_Stop_Time_lst[i] matches pattern "ALKP%" then All_Stop_Time_lst[i] := "Alk Phos"; + elseif All_Stop_Time_lst[i] matches pattern "ALB%" then All_Stop_Time_lst[i] := "Albumin"; + elseif All_Stop_Time_lst[i] matches pattern "PROT%" then All_Stop_Time_lst[i] := "Protein"; + elseif All_Stop_Time_lst[i] matches pattern "AMY%" then All_Stop_Time_lst[i] := "Amylase"; + elseif All_Stop_Time_lst[i] matches pattern "LIP%" then All_Stop_Time_lst[i] := All_Start_Time_Lst[i]; + endif; + + Result_String := Result_String ||tab ||lst_val|| ", " || All_Stop_Time_lst[i]||": "||All_Values_Lst[i] ||sp||All_UoM_Lst[i]|| "\n" ; + EndDo; //For i IN SEQTO count of all Do + + Else + Result_String := Result_String || "No Gastro Tests Performed. \n" ; + + EndIf; //All_Attributes_Lst + + // Impressions + + Retreive_Attribute := "text_val"; + Retreive_Object := "Results"; + Filterable_Attribute := "itemname"; + Filterable_Operator := "IN" ; + Filterable_Value := "{{{SINGLE-QUOTE}}}Pelvic Comp T Abd Only{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Abdomen Ultrasound{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Abdomen Limited Ultrasound{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}CT Abdomen{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}CT Abdomen Enhanced{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}CT Abdomen Unenhanced{{{SINGLE-QUOTE}}}" + ||",{{{SINGLE-QUOTE}}}CT Abdomen + Pelvis{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Hepatobiliary Scan{{{SINGLE-QUOTE}}}" ; + + + // Call Impression Lookup MLM to get patient data + + (All_Attributes_Lst, All_Med_Rel_Dttm_Lst, All_Values_Lst) := CALL Get_result_impression_lookup WITH + (client_guid, client_visit_guid, client_chart_guid, Is_Historical, Retreive_Object, Retreive_Attribute, + Filterable_Attribute, Filterable_Operator, Filterable_Value, Additional_condition); + + + If Exists All_Attributes_Lst Then + + for k in 1 seqto count All_Attributes_Lst do + Result_string := Result_String || "\n" || All_Attributes_Lst[k] || " " || All_Med_Rel_Dttm_Lst[k] || ": " || All_Values_Lst[k] || "\n" ; + enddo; + Else + Result_String := Result_String || tab || "No diagnostic impressions Recorded.\n"; + + endif; + + Result_String := Result_String || blt_char; + + + // Infectious Disease Groupings + + + ElseIf Token = "|Infectious Disease|" and (not (rtf_target_text matches pattern "%Infectious Disease%") + or (rtf_target_text matches pattern "%Infectious Disease%") is null ) Then + current:= now; + test_enter:=(CRLF," "); + target_parameter_name := "SCH_MDPN_Groupings"; + Result_String := "\b Infectious Disease \b0"||CRLF; + +//====CSR : 32981 : Add max Temp ======================================= + this_documentCommunication := CALL VitalSignsMLM_MaxTemp WITH this_documentCommunication; + Max_Temp_Val := local_session.ACS_FormatedText; +If Max_Temp_Val is Null Then +Max_Temp_Val := "No Temperatures Recorded. \n"; +Endif; + header1 :="\n\n\b Max Temperature in Past 24 Hours\b0\n\n"; + Final_Max_Temp := header1 || Max_Temp_Val ; + +//=================================================================================== + If Exists All_Attributes_Lst Then Result_String := Result_String || tab || "\b Infectious Disease Tests: \b0 \n" ; + + For i IN 1 SEQTO count of All_Attributes_Lst Do + ext_all_val:= extract characters All_Med_Rel_Dttm_Lst[i]; + lst_val:= string (first 10 from ext_all_val); + + if not (All_Stop_Time_lst[i] + in ("RBC", "HGB", "HCT", "MCV", "MCH", "MCHC", "RDW", "PLTC", "MPV", "RDWCV", "RDWSD" )) then + + // First check to see if in Value or in Textual observation + + if All_Values_Lst[i] is null then + all_values_lst[i]:= string (All_Significant_Data_Lst[i]) ; + Result_String := Result_String ||tab||All_Values_Lst[i]||sp3|| tab||lst_val|| "\n" ; + + else + if All_UoM_Lst[i] is null then + All_UoM_Lst[i] := " "; + endif; + + Result_String := Result_String ||tab ||lst_val|| ", " || All_Stop_Time_lst[i]||": " ||All_Values_Lst[i]||sp||All_UoM_Lst[i]|| "\n" ; + + endif; + + endif; + + EndDo; //For i IN SEQTO count of all Do + + Else + Result_String := Result_String || "No Infectious Disease Studies Performed. \n" ; + EndIf; //All_Attributes_Lst + + // Orders + + Retreive_Object := "Orders"; //"Therap_Cat_Orders"; //"Abx Orders"; + Filterable_Attribute := "ocmi.TherapeuticCategory"; //"ct.code"; + Filterable_Operator := "IN"; + Filterable_Value := ord_id_meds; + Additional_condition := "All"; + + + // Call ACS_Generic_Lookup MLM to retrieve patient data + + (All_Attributes_Lst, All_Values_Lst, All_UoM_Lst, All_Med_Rel_Dttm_Lst, All_Start_Time_Lst, All_Stop_Time_Lst, + All_User_Guid_Lst, All_Significant_Data_Lst, this_documentCommunication, All_Sig_Count_Lst) := CALL Get_mlm_Generic_Lookup_data WITH + (this_documentCommunication, client_guid, client_visit_guid,client_chart_guid, Is_Historical,Retreive_Object,Retreive_Attribute, + Filterable_Attribute, Filterable_Operator,Filterable_Value, Additional_condition); + + + If Exists All_Attributes_Lst Then + Result_String := Result_String || tab || "\b Infectious Disease Orders: \b0 \n" ; + + For i IN 1 SEQTO count of All_Attributes_Lst Do + ext_all_val:= extract characters All_Med_Rel_Dttm_Lst[i]; + lst_val := string (first 16 from ext_all_val); + ext_task_time := extract characters All_Significant_Data_Lst[i]; + task_time := string (first 16 from ext_task_time); + s_aali := All_Attributes_Lst[i] ; + + if length s_aali <= 40 then + a_a_l_i := read last{"select convert(char(40), " || sql(s_aali) || ")"}; + + if length s_aali < 20 then + a_a_l_i := a_a_l_i || tab; + endif; + + elseif length s_aali <= 80 then + a_a_l_i := read last{"select convert(char(80), " || sql(s_aali) || ")"}; + + else + a_a_l_i := read last{"select convert(char(125), " || sql(s_aali) || ")"}; + + endif; + + Result_String := Result_String || tab || a_a_l_i || ", Order/Start: " || lst_val ; + + if exists task_time and task_time <> "null" then + Result_String := Result_String || tab || " Last Given: " || task_time || " Doses Given: " || All_Sig_Count_Lst[i]; + endif; + + if All_user_guid_lst[i] IN ("CAN","CANC","DISC") then + Result_String := Result_String || tab || ", Stop Date: " || All_Stop_Time_lst[i] ; + endif; + + len_val_i := length All_Values_Lst[i]; + + if len_val_i > 70 then + val_i := substring 70 characters from All_Values_Lst[i]; + val_i := val_i || " <+ ADDED INSTRUCTIONS...>"; + + else + val_i := All_Values_Lst[i]; + + endif; + + // Remove newlines from summary + + count_crlf := 0; // newline counter + crlf_start := 1; // newline start position + last_crlf := 0; // last newline position + + while (find CRLF in string val_i starting at crlf_start) > 0 do + count_crlf := count_crlf + 1; // increment newline counter + ct_vals:= length val_i; + ret_val:= find CRLF in string val_i starting at crlf_start; // from last newline. + sub_num:= (ct_vals - ret_val) ; //- 1; + fst_val:= substring (ret_val -1) characters from val_i; + + if not exists fst_val or fst_val = "null" then + fst_val := ""; // gets rid of NULLs + endif; + + lst_val:= substring (sub_num) characters starting at ( ret_val + 1 ) from val_i; + crlf_start := ret_val + 1; // reset last found newline position + val_i := (trim (fst_val)) || " " || (trim (lst_val) ) ; // replace newline with comma + + enddo; + + Result_String := Result_string || "\n" || tab || val_i || "\n"; + + EndDo; //For i IN SEQTO count of all Do + + Else + + Result_String := Result_String ||tab || "No Infectious Disease Meds Ordered. \n" ; + + endif; + + + // Observations + + Retreive_Object := "Vitals"; + Filterable_Attribute := "ocmi.name"; + Filterable_Operator := "IN" ; + Filterable_Value := "{{{SINGLE-QUOTE}}}farenheit{{{SINGLE-QUOTE}}} "; + + + // Call ACS_Generic_Lookup MLM to retrieve patient data + + (All_Attributes_Lst, All_Values_Lst, All_UoM_Lst, All_Med_Rel_Dttm_Lst, All_Start_Time_Lst, All_Stop_Time_Lst, + All_User_Guid_Lst, All_Significant_Data_Lst, this_documentCommunication, All_Sig_Count_Lst) := CALL Get_mlm_Generic_Lookup_data WITH + (this_documentCommunication, client_guid, client_visit_guid,client_chart_guid, Is_Historical,Retreive_Object,Retreive_Attribute, + Filterable_Attribute, Filterable_Operator,Filterable_Value, Additional_condition); + + + If Exists All_Attributes_Lst Then + test_null:= null; + Result_String_1 := "\b Temperatures-Charted: \b0 "; + hs_val_0 := last of (All_Values_Lst where (All_Attributes_Lst="Farenheit")); + hs_time := last of (All_Med_Rel_Dttm_Lst where (All_Attributes_Lst="Farenheit")); + hs_val:=tab||"Temperature: "||string (hs_val_0 where it not in test_null) || tab; + sorted_time_list := reverse (All_Med_Rel_Dttm_Lst); + sorted_val_list := reverse (All_Values_Lst); + last_vs_time := now + 1 hour; + Result_string_2 := ""; + ct_times:= count sorted_val_list; + + for te in 1 seqto ct_times DO + vs_time:= (sorted_time_list[te]) ; + vs_line := ""; + val_temp:= sorted_val_list[te]; + vs_line := vs_line ||tab|| val_temp; + + if val_temp is not null then + + if vs_line <> "" then + Result_string_2 := Result_string_2 || "\n" || tab2 || vs_time || vs_line; + endif; + + endif; // val_temp is not null + + enddo; + + //Result_string := Result_String || tab || Result_string_1 || Result_string_2; + Result_string := Result_String || tab || Result_string_1 || Result_string_2 ||Final_Max_Temp|| "\n \n" ; // CSR:32981 - Max Temp added in earlier code + + Else + Result_String := Result_String || tab || "No Temperatures Recorded. \n" ; + + endif; + + Result_String := Result_String || blt_char; + + + // Catheter Line Access Groupings + + + ElseIf Token = "|Line Access|" and (not (rtf_target_text matches pattern "%Line%") + or (rtf_target_text matches pattern "%Line%") is null) Then + current:= now; + test_enter:=(CRLF," "); + target_parameter_name := "SCH_MDPN_Groupings"; + Result_String := "\b Line Access \b0"||CRLF; + + If Exists All_Attributes_Lst Then + test_null:= null; + Result_String := Result_String ||tab|| "\b Lines: \b0 \n"; + + // Arterial Line Catheter + + al_val_0 := reverse (All_Values_Lst where (All_Attributes_Lst="INV art line location")); //last of + al_time := reverse (All_Med_Rel_Dttm_Lst where (All_Attributes_Lst="INV art line location")); //last of + al_ind:=null; + + for i in 1 seqto count(al_time) do + if al_time[i] in al_ind then + stop:=1; + else + al_ind:= al_ind, al_time[i]; + endif; + enddo; + + al_ind:= al_ind where they not in test_null; + al_val_ind:= null; + + for c in 1 seqto count al_ind DO + al_temp_0:= al_val_0 where al_time in al_ind[c]; + al_val_temp:=tab||"Art Line: "|| (al_temp_0 ) || CRLF; + al_val_ind:= al_val_ind, al_val_temp; + enddo; + + al_val_ind:= al_val_ind where they not in test_null; + + // Central Line Catheter + + cl_val_0 := reverse (All_Values_Lst where (All_Attributes_Lst="INV central line location")); //last of + cl_time := reverse (All_Med_Rel_Dttm_Lst where (All_Attributes_Lst="INV central line location"));//last of + cl_ind:=null; + + for i in 1 seqto count(cl_time) do + if cl_time[i] in cl_ind then + stop:=1; + else + cl_ind:= cl_ind, cl_time[i]; + endif; + + enddo; + + cl_ind:= cl_ind where they not in test_null; + cl_val_ind:= null; + + for c in 1 seqto count cl_ind DO + cl_temp_0:= cl_val_0 where cl_time in cl_ind[c]; + cl_val_temp:=tab||"Central Line: "|| (cl_temp_0 ) || CRLF; + cl_val_ind:= cl_val_ind, cl_val_temp; + enddo; + + cl_val_ind:= cl_val_ind where they not in test_null; + + // Mid Line Catheter + + ml_val_0 := reverse (All_Values_Lst where (All_Attributes_Lst="INV midline cath location")); //last of + ml_time := reverse (All_Med_Rel_Dttm_Lst where (All_Attributes_Lst="INV midline cath location")); //last of + ml_ind:=null; + + for i in 1 seqto count(ml_time) do + if ml_time[i] in ml_ind then + stop:=1; + else + ml_ind:= ml_ind, ml_time[i]; + endif; + enddo; + + ml_ind:= ml_ind where they not in test_null; + ml_val_ind:= null; + + for c in 1 seqto count ml_ind DO + ml_temp_0:= ml_val_0 where ml_time in ml_ind[c]; + ml_val_temp:=tab||"Midline Cath: "|| (ml_temp_0 ) || CRLF; + ml_val_ind:= ml_val_ind, ml_val_temp; + enddo; + + ml_val_ind:= ml_val_ind where they not in test_null; + + // PA Catheter + + pa_val_0 := reverse (All_Values_Lst where (All_Attributes_Lst="INV pa cath location")); //last of + pa_time := reverse (All_Med_Rel_Dttm_Lst where (All_Attributes_Lst="INV pa cath location")); //last of + pa_ind:=null; + + for i in 1 seqto count(pa_time) do + if pa_time[i] in pa_ind then + stop:=1; + else + pa_ind:= pa_ind, pa_time[i]; + endif; + enddo; + + pa_ind:= pa_ind where they not in test_null; + pa_val_ind:= null; + + for c in 1 seqto count pa_ind DO + pa_temp_0:= pa_val_0 where pa_time in pa_ind[c]; + pa_val_temp:=tab||"PA Cath: "|| (pa_temp_0 ) || CRLF; + pa_val_ind:= pa_val_ind, pa_val_temp; + enddo; + + pa_val_ind:= pa_val_ind where they not in test_null; + + // PICC Line Catheter + + pi_val_0 := reverse (All_Values_Lst where (All_Attributes_Lst="INV picc location")); //last of + pi_time := reverse (All_Med_Rel_Dttm_Lst where (All_Attributes_Lst="INV picc location")); //last of + pi_ind:=null; + + for i in 1 seqto count(pi_time) do + if pi_time[i] in pi_ind then + stop:=1; + else + pi_ind:= pi_ind, pi_time[i]; + endif; + enddo; + + pi_ind:= pi_ind where they not in test_null; + pi_val_ind:= null; + + for c in 1 seqto count pi_ind DO + pi_temp_0:= pi_val_0 where pi_time in pi_ind[c]; + pi_val_temp:=tab||"PICC: "|| (pi_temp_0 ) || CRLF; + pi_val_ind:= pi_val_ind, pi_val_temp; + enddo; + + pi_val_ind:= pi_val_ind where they not in test_null; + + // Vascular Access Catheter + + va_val_0 := reverse(All_Values_Lst where (All_Attributes_Lst="INV vasc access port location")); //last of + va_time := reverse (All_Med_Rel_Dttm_Lst where (All_Attributes_Lst="INV vasc access port location")); //last of + va_ind:=null; + + for i in 1 seqto count(va_time) do + if va_time[i] in va_ind then + stop:=1; + else + va_ind:= va_ind, va_time[i]; + endif; + enddo; + + va_ind:= va_ind where they not in test_null; + va_val_ind:= null; + + for c in 1 seqto count va_ind DO + va_temp_0:= va_val_0 where va_time in va_ind[c]; + va_val_temp:=tab||"Vasc Access: "|| (va_temp_0 ) || CRLF; + va_val_ind:= va_val_ind, va_val_temp; + enddo; + + va_val_ind:= va_val_ind where they not in test_null; + + // SCHCK PICC Line Catheter + + p2_val_0 := reverse (All_Values_Lst where (All_Attributes_Lst="schck_INV picc location 2")); //last of + p2_time := reverse (All_Med_Rel_Dttm_Lst where (All_Attributes_Lst="schck_INV picc location 2"));//last of + p2_ind:=null; + + for i in 1 seqto count(p2_time) do + if p2_time[i] in p2_ind then + stop:=1; + else + p2_ind:= p2_ind, p2_time[i]; + endif; + enddo; + + p2_ind:= p2_ind where they not in test_null; + p2_val_ind:= null; + + for c in 1 seqto count p2_ind DO + p2_temp_0:= p2_val_0 where p2_time in p2_ind[c]; + p2_val_temp:=tab||"PICC line 2: "|| (p2_temp_0 ) || CRLF; + p2_val_ind:= p2_val_ind, p2_val_temp; + enddo; + + p2_val_ind:= p2_val_ind where they not in test_null; + line_tms:= al_ind, cl_ind, ml_ind, pa_ind, pi_ind, va_ind, p2_ind; + line_vals:= al_val_ind, cl_val_ind, ml_val_ind, pa_val_ind, pi_val_ind, va_val_ind, p2_val_ind; + line_tmlst:=null; + + for i in 1 seqto count(line_tms) do + if line_tms[i] in line_tmlst then + stop:=1; + else + line_tmlst:= line_tmlst, line_tms[i]; + endif; + enddo; + + line_tmlst:= line_tmlst where they not in test_null; + + sorted_time_list := line_tmlst; //(sort data All_Med_Rel_Dttm_Lst); + last_vs_time := now + 1 hour; + Result_string_2 := ""; + + for vs_time in sorted_time_list do + + vs_line := ""; + if vs_time <> last_vs_time then + + for a in 1 seqto count al_ind do if al_ind[a] = vs_time then vs_line := vs_line || al_val_ind[a]; endif; enddo; + for a in 1 seqto count cl_ind do if cl_ind[a] = vs_time then vs_line := vs_line || cl_val_ind[a]; endif; enddo; + for a in 1 seqto count ml_ind do if ml_ind[a] = vs_time then vs_line := vs_line || ml_val_ind[a]; endif; enddo; + for a in 1 seqto count pa_ind do if pa_ind[a] = vs_time then vs_line := vs_line || pa_val_ind[a]; endif; enddo; + for a in 1 seqto count pi_ind do if pi_ind[a] = vs_time then vs_line := vs_line || pi_val_ind[a]; endif; enddo; + for a in 1 seqto count va_ind do if va_ind[a] = vs_time then vs_line := vs_line || va_val_ind[a]; endif; enddo; + for a in 1 seqto count p2_ind do if p2_ind[a] = vs_time then vs_line := vs_line || p2_val_ind[a]; endif; enddo; + + last_vs_time := vs_time; + + if vs_line <> "" then + Result_string_2 := Result_string_2 || "\n" || tab || vs_time ||CRLF|| vs_line||"\n"; + endif; + + endif; + + enddo; + + Result_string := Result_String || tab || Result_string_2 || "\n" ; + + Else + Result_String := Result_String || "No Lines Recorded. \n" ; + + endif; + Result_String := Result_String || blt_char; + + + // Mechanical Ventilation Groupings + + + ElseIf Token = "|Mechanical Ventilation|" and (not (rtf_target_text matches pattern "%Mechanical Vent%") + or (rtf_target_text matches pattern "%Mechanical Vent%") is null ) Then + current:= now; + test_enter:=(CRLF," "); + target_parameter_name := "SCH_MDPN_Groupings"; + Result_String := "\b Mechanical Ventilation \b0"||CRLF; + + If Exists All_Attributes_Lst Then + test_null:= null; + Result_String := Result_String ||tab|| "\b Ventilation: \b0 \n" ; + + // Airway Size + + al_val_0 := last of (All_Values_Lst where (All_Attributes_Lst="AS airway size")); + al_uom := last of (All_Uom_Lst where (All_Attributes_Lst="AS airway size")); + + if al_val_0 is not null then + al_val:=tab||"ETT Size: "||tab2||string (al_val_0 ) || sp2 ||string (al_uom where it not in test_null)||CRLF; + Result_String:= Result_String|| al_val; + endif; + + // Airway Site + + as_val_0 := last of (All_Values_Lst where (All_Attributes_Lst="AS airway site appear")); + as_uom := last of (All_Uom_Lst where (All_Attributes_Lst="AS airway site appear")); + + if as_val_0 is not null then + as_val:=tab||"ETT Placement at Lip: "||tab||string (as_val_0) || sp2 ||string (as_uom where it not in test_null)||CRLF; + Result_String:= Result_String|| as_val; + endif; + + // Ventilator Mode + + vm_val_0 := last of (All_Values_Lst where (All_Attributes_Lst="SCH_vs_ventilator mode")); + vm_uom := last of (All_Uom_Lst where (All_Attributes_Lst="SCH_vs_ventilator mode")); + + if vm_val_0 is not null then + vm_val:=tab||"Vent Mode: "|| tab2 ||string (vm_val_0) || sp2 ||string (vm_uom where it not in test_null)||CRLF; + Result_String:= Result_String|| vm_val; + endif; + + // Set Rate f(M) + + sm_val_0 := last of (All_Values_Lst where (All_Attributes_Lst="SCHCK_Set Rate f(M)/min NU")); + sm_uom := last of (All_Uom_Lst where (All_Attributes_Lst="SCHCK_Set Rate f(M)/min NU")); + + if sm_val_0 is not null then + sm_val:=tab||"Set Rate f(M): "||tab2||string (sm_val_0) || sp2 ||string (sm_uom where it not in test_null)||CRLF; + Result_String:= Result_String|| sm_val; + endif; + + // Set Rate f(a) + + sa_val_0 := last of (All_Values_Lst where (All_Attributes_Lst="SCHCK_Set Rate f(A)/min NU")); + sa_uom := last of (All_Uom_Lst where (All_Attributes_Lst="SCHCK_Set Rate f(A)/min NU")); + + if sa_val_0 is not null then + sa_val:=tab||"Set Rate f(A): "||tab2||string (sa_val_0) || sp2 ||string (sa_uom where it not in test_null)||CRLF; + Result_String:= Result_String|| sa_val; + endif; + + // PeaK Pressure + + pp_val_0 := last of (All_Values_Lst where (All_Attributes_Lst="SCHCK_Peak Pressure")); + pp_uom := last of (All_Uom_Lst where (All_Attributes_Lst="SCHCK_Peak Pressure")); + + if pp_val_0 is not null then + pp_val:=tab||"Peak Pressure: " ||tab|| string (pp_val_0) || sp2 ||string (pp_uom where it not in test_null)||CRLF; + Result_String:= Result_String|| pp_val; + endif; + + // Vent FiO2 + + vf_val_0 := last of (All_Values_Lst where (All_Attributes_Lst="Ventilator FiO2")); + vf_uom := last of (All_Uom_Lst where (All_Attributes_Lst="Ventilator FiO2")); + + if vf_val_0 is not null then + vf_val:=tab||"Ventilator FiO2: "||tab||string (vf_val_0) || sp2 ||string (vf_uom where it not in test_null)||CRLF; + Result_String:= Result_String|| vf_val; + endif; + + // CPAP/BiPAP + + cp_val_0 := last of (All_Values_Lst where (All_Attributes_Lst="SCHCK_CPAP/BiPAP")); + cp_uom := last of (All_Uom_Lst where (All_Attributes_Lst="SCHCK_CPAP/BiPAP")); + + if cp_val_0 is not null + then + cp_val:=tab||"CPAP/BIPAP: "||tab2||string (cp_val_0) || sp2 ||string (cp_uom where it not in test_null) ||CRLF; + Result_String:= Result_String|| cp_val; + endif; + + Else + Result_String := Result_String || "No Mechanical Ventilation Charted. \n" ; + + endif; + + Result_String := Result_String || "\n" || blt_char; + + + // Pulmonary Groupings + + + ElseIf Token = "|Pulmonary|" and (not (rtf_target_text matches pattern "%Pulmonary%") + or (rtf_target_text matches pattern "%Pulmonary%") is null) Then + current:= now; + test_enter:=(CRLF," "); + target_parameter_name := "SCH_MDPN_Groupings"; + Result_String := "\b Pulmonary \b0"||CRLF; + + If Exists All_Attributes_Lst Then + + All_Attributes_Lst:= reverse All_Attributes_Lst; + All_Med_Rel_Dttm_Lst := reverse All_Med_Rel_Dttm_Lst ; + All_UoM_Lst:= reverse All_UoM_Lst; + All_Values_Lst:= reverse All_Values_Lst; + All_Start_Time_Lst:= reverse All_Start_Time_Lst; + All_Significant_Data_Lst:= reverse All_Significant_Data_Lst; + All_Sig_Count_Lst := reverse All_Sig_Count_Lst; + All_Stop_Time_lst:= reverse All_Stop_Time_lst; //has ResutlItemCodes + Result_String := Result_String ||tab|| "\b Pulmonary Tests: \b0 \n" ; + + For i IN 1 SEQTO count of All_Attributes_Lst Do + ext_all_val:= extract characters All_Med_Rel_Dttm_Lst[i]; + lst_val:= string (first 16 from ext_all_val); + + // PH, PCO2, P02, 02, SAT + + if All_Start_Time_Lst[i] in ("pH Arterial","pCO2 Arterial","pO2 Arterial","O2 Content Arterial","O2 Saturation Arterial") then + + if All_UoM_Lst[i] is null then + All_UoM_Lst[i] := " "; + endif; + + Result_String := Result_String ||tab ||lst_val|| ", " || All_Start_Time_Lst[i]||": "||All_Values_Lst[i] ||sp||All_UoM_Lst[i]|| "\n" ; + endif; + + EndDo; //For i IN SEQTO count of all Do + + Else + + Result_String := Result_String ||tab || "No Pulmonary Tests (ABGs) Performed. \n"; + + + EndIf; //All_Attributes_Lst + + + // Orders + + Retreive_Object := "Orders"; + Filterable_Attribute := "o.name"; + Filterable_Operator := "IN" ; + Filterable_Value := "{{{SINGLE-QUOTE}}}Spontaneous Aerosol{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Continuous Bronchodilator{{{SINGLE-QUOTE}}} "; + + + // Call ACS_Generic_Lookup MLM to retrieve patient data + + (All_Attributes_Lst, All_Values_Lst, All_UoM_Lst, All_Med_Rel_Dttm_Lst, All_Start_Time_Lst, All_Stop_Time_Lst, + All_User_Guid_Lst, All_Significant_Data_Lst, this_documentCommunication, All_Sig_Count_Lst) := CALL Get_mlm_Generic_Lookup_data WITH + (this_documentCommunication, client_guid, client_visit_guid,client_chart_guid, Is_Historical,Retreive_Object,Retreive_Attribute, + Filterable_Attribute, Filterable_Operator,Filterable_Value, Additional_condition); + + + If Exists All_Attributes_Lst Then + Result_String := Result_String ||tab || "\b Pulmonary Active Spontaneous/Continuous Orders: \b0 \n" ; + + For i IN 1 SEQTO count of All_Attributes_Lst Do + ext_val:= extract characters All_Values_Lst[i]; + ct_vals:= count ext_val; + ret_val_1:= find "-" in string All_Values_Lst[i]; + sub_num:= (ct_vals - ret_val_1) - 1; + last_val_1:= ( last sub_num from ext_val); + ct_v_1:= count last_val_1; + last_val:= string( last_val_1); //sub_num from ext_val); + l_last_v:= find CRLF in string last_val; + + if l_last_v > 0 then + sub2:= (l_last_v)-1; + last_val_2:= string (first sub2 from last_val_1); + last_val:= last_val_2; + endif; + + ext_all_val:= extract characters All_Med_Rel_Dttm_Lst[i]; + lst_val:= string (first 16 from ext_all_val); + + Result_String := Result_String ||tab || All_Attributes_Lst[i]||": "||last_val||", Ordered: "||lst_val ; + + if exists task_time and task_time <> "null" then + Result_String := Result_String || tab || ", Given: " || task_time ; + endif; + + Result_String := Result_String || "\n" ; + + EndDo; //For i IN SEQTO count of all Do + + Else + Result_String := Result_String ||tab || "No Active Pulmonary Spontaneous/Continuous Ordered. \n" ; + endif; + + + // Bronchodialators Therapeutic class + + Retreive_Object := "Orders"; //"Therap_Cat_Orders"; //"Abx Orders"; + Filterable_Attribute := "ocmi.TherapeuticCategory"; //"ct.code"; + Filterable_Operator := "IN"; + Filterable_Value := ord_pulmon_meds; + + + // Call ACS_Generic_Lookup MLM to retrieve patient data + + (All_Attributes_Lst, All_Values_Lst, All_UoM_Lst, All_Med_Rel_Dttm_Lst, All_Start_Time_Lst, All_Stop_Time_Lst, + All_User_Guid_Lst, All_Significant_Data_Lst, this_documentCommunication, All_Sig_Count_Lst) := CALL Get_mlm_Generic_Lookup_data WITH + (this_documentCommunication, client_guid, client_visit_guid,client_chart_guid, Is_Historical,Retreive_Object,Retreive_Attribute, + Filterable_Attribute, Filterable_Operator,Filterable_Value, Additional_condition); + + + If Exists All_Attributes_Lst Then + Result_String := Result_String || tab || "\b Pulmonary Bronchodilator Orders: \b0 \n" ; + + For i IN 1 SEQTO count of All_Attributes_Lst Do + ext_all_val:= extract characters All_Med_Rel_Dttm_Lst[i]; + lst_val := string (first 16 from ext_all_val); + ext_task_time := extract characters All_Significant_Data_Lst[i]; + task_time := string (first 16 from ext_task_time); + Result_String := Result_String || tab || All_Attributes_Lst[i] || ", Ordered: " || lst_val ; + + if exists task_time and task_time <> "null" then + Result_String := Result_String || tab || ", Given: " || task_time ; + endif; + + Result_String := Result_String || "\n" ; + + EndDo; //For i IN SEQTO count of all Do + + Else + Result_String := Result_String ||tab || "No Active Bronchodilators Ordered. \n" ; + + endif; + + // Observations + + Retreive_Object := "Vitals"; + Filterable_Attribute := "ocmi.name"; + Filterable_Operator := "IN" ; + Filterable_Value := " {{{SINGLE-QUOTE}}}L/min{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}L/min Device{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCH_vs_pulse ox saturation{{{SINGLE-QUOTE}}}" ; + + + // Call ACS_Generic_Lookup MLM to retrieve patient data + + (All_Attributes_Lst, All_Values_Lst, All_UoM_Lst, All_Med_Rel_Dttm_Lst, All_Start_Time_Lst, All_Stop_Time_Lst, + All_User_Guid_Lst, All_Significant_Data_Lst, this_documentCommunication, All_Sig_Count_Lst) := CALL Get_mlm_Generic_Lookup_data WITH + (this_documentCommunication, client_guid, client_visit_guid,client_chart_guid, Is_Historical,Retreive_Object,Retreive_Attribute, + Filterable_Attribute, Filterable_Operator,Filterable_Value, Additional_condition); + + + If Exists All_Attributes_Lst Then + test_null:= null; + Result_String := Result_String ||tab || "\b Pulmonary observations-Charted: \b0 \n"; + + // Device + + dev_val_0 := last of (All_Values_Lst where (All_Attributes_Lst="L/min Device")); + dev_uom := last of (All_Uom_Lst where (All_Attributes_Lst="L/min Device")); + + if dev_val_0 is not null then + dev_val:=tab||"O2 Therapy: "||tab||string (dev_val_0 ) || sp2 ||string (dev_uom where it not in test_null)||CRLF; + Result_String:= Result_String|| dev_val; + endif; + + // Flow + + fl_val_0 := last of (All_Values_Lst where (All_Attributes_Lst="L/min")); + fl_uom := last of (All_Uom_Lst where (All_Attributes_Lst="L/min")); + + if fl_val_0 is not null then + fl_val:=tab||"Flow: "||tab2||string (fl_val_0) || sp2 ||string (fl_uom where it not in test_null)||CRLF; + Result_String:= Result_String|| fl_val; + endif; + + // Pulse Oximeter + + po_val_0 := last of (All_Values_Lst where (All_Attributes_Lst="SCH_vs_pulse ox saturation")); + po_uom := last of (All_Uom_Lst where (All_Attributes_Lst="SCH_vs_pulse ox saturation")); + + if po_val_0 is not null then + po_val:=tab||"Pulse Ox : "||tab||string (po_val_0) || sp2 ||string (po_uom where it not in test_null)||CRLF; + Result_String:= Result_String|| po_val; + endif; + + Result_String:= Result_String|| CRLF; + + Else + Result_String := Result_String || tab || "No Pulmonary Observations Recorded. \n" ; + + endif; + + // Impressions + + Retreive_Attribute := "text_val"; + Retreive_Object := "Results"; + Filterable_Attribute := "itemname"; + Filterable_Operator := "IN" ; + Filterable_Value := Pulmon_image_rev; + Additional_condition := " performeddtm > dateadd(mm, -24, getdate()) "; + + + // Call Impression Lookup MLM to get patient data + + (All_Attributes_Lst, All_Med_Rel_Dttm_Lst, All_Values_Lst) := CALL Get_result_impression_lookup WITH + (client_guid, client_visit_guid, client_chart_guid, Is_Historical, Retreive_Object, Retreive_Attribute, + Filterable_Attribute, Filterable_Operator, Filterable_Value, Additional_condition); + + + If Exists All_Attributes_Lst Then + + for k in 1 seqto count All_Attributes_Lst do + Result_string := Result_String || "\b Pulmonary Diagnostic Images \b0 \n" ||tab|| All_Attributes_Lst[k] || " " || All_Med_Rel_Dttm_Lst[k] || ": " || All_Values_Lst[k] || "\n" ; + enddo; + + Else + Result_String := Result_String || tab || "No Pulmonary diagnostic impressions Recorded. \n" ; + + endif; + + Result_String := Result_String || blt_char; + + + // Neurology Groupings + + + ElseIf Token = "|Neurology|" and (not (rtf_target_text matches pattern "%Neuro%") + or (rtf_target_text matches pattern "%Neuro%") is null) Then + current:= now; + test_enter:=(CRLF," "); + target_parameter_name := "SCH_MDPN_Groupings"; + Result_String := "\b Neurology \b0"||CRLF; + + // Impressions + + Retreive_Attribute := "text_val"; + Retreive_Object := "Results"; + Filterable_Attribute := "itemname"; + Filterable_Operator := "IN" ; + Filterable_Value := neuro_image_rev; + + + // Call Impression Lookup MLM to get patient data + + (All_Attributes_Lst, All_Med_Rel_Dttm_Lst, All_Values_Lst) := CALL Get_result_impression_lookup WITH + (client_guid, client_visit_guid, client_chart_guid, Is_Historical, Retreive_Object, Retreive_Attribute, + Filterable_Attribute, Filterable_Operator, Filterable_Value, Additional_condition); + + + If Exists All_Attributes_Lst Then + + for k in 1 seqto count All_Attributes_Lst do + Result_string := Result_String || "\n" || All_Attributes_Lst[k] || " " || All_Med_Rel_Dttm_Lst[k] || ": " || All_Values_Lst[k] || "\n" ; + enddo; + + Else + Result_String := Result_String || tab || "No diagnostic impressions Recorded. \n" ; + + endif; + + Result_String := Result_String || blt_char; + + + // Renal Groupings + + + ElseIf Token = "|Renal|" and (not (rtf_target_text matches pattern "%Renal%") + or(rtf_target_text matches pattern "%Renal%") is null) Then + current:= now; + test_enter:=(CRLF," "); + target_parameter_name := "SCH_MDPN_Groupings"; + Result_String := "\b Renal \b0"||CRLF; + + If Exists All_Attributes_Lst Then + All_Attributes_Lst:= reverse All_Attributes_Lst; + All_Med_Rel_Dttm_Lst := reverse All_Med_Rel_Dttm_Lst ; + All_UoM_Lst:= reverse All_UoM_Lst; + All_Values_Lst:= reverse All_Values_Lst; + All_Start_Time_Lst:= reverse All_Start_Time_Lst; + All_Significant_Data_Lst:= reverse All_Significant_Data_Lst; + All_Sig_Count_Lst := reverse All_Sig_Count_Lst; + All_Stop_Time_lst:= reverse All_Stop_Time_lst; + + Result_String := Result_String ||tab||"\b Renal Tests: \b0 \n" ; + + For i IN 1 SEQTO count of All_Attributes_Lst Do + ext_all_val:= extract characters All_Med_Rel_Dttm_Lst[i]; + lst_val:= string (first 16 from ext_all_val); + + if All_UoM_Lst[i] is null then + All_UoM_Lst[i] := " "; + endif; + + Result_String := Result_String ||tab ||lst_val|| ", " || All_Stop_Time_lst[i]||": "||All_Values_Lst[i] ||sp||All_UoM_Lst[i]|| "\n" ; + EndDo; //For i IN SEQTO count of all Do + + Else + Result_String := Result_String ||"No Renal Lab Tests Performed. \n" ; + + endif; + + + /// I& O for the last 24 hours + + Retreive_Object := "IO24"; + + // Call ACS_Generic_Lookup MLM to retrieve patient data + + (All_Attributes_Lst, All_Values_Lst, All_UoM_Lst, All_Med_Rel_Dttm_Lst, All_Start_Time_Lst, All_Stop_Time_Lst, + All_User_Guid_Lst, All_Significant_Data_Lst, this_documentCommunication, All_Sig_Count_Lst) := CALL Get_mlm_Generic_Lookup_data WITH + (this_documentCommunication, client_guid, client_visit_guid,client_chart_guid, Is_Historical,Retreive_Object,Retreive_Attribute, + Filterable_Attribute, Filterable_Operator,Filterable_Value, Additional_condition); + + + Result_String_1 := "for the last 24 hours are "; + If exists All_Values_Lst and any(All_Values_Lst is number) Then + Result_String_r := "\n \b Intake and Output Totals: \b0 " || Result_string_1 ||": \n" || "\b Intake" || TAB3 || "Output"|| TAB2 + || "Net \b0 \n" || int(All_Values_Lst[1]) || TAB3 || int(All_Values_Lst[2]) || TAB2 || int(All_Values_Lst[3]) ; + Result_string:= Result_string|| Result_string_r||"\n"; + Else + Result_String := Result_string|| "\nIntake AND Output Totals " || Result_String_1 || " not available " || "\n" ; + + EndIf; + + Result_String := Result_String || blt_char; + + + // Medical Imaging + + ElseIf Token = "|MedImage|" then + + + // Call Impression Lookup MLM to get patient data + + (All_Attributes_Lst, All_Med_Rel_Dttm_Lst, All_Values_Lst) := CALL Get_result_impression_lookup WITH + (client_guid, client_visit_guid, client_chart_guid, Is_Historical, Retreive_Object, Retreive_Attribute, + Filterable_Attribute, Filterable_Operator, Filterable_Value, Additional_condition); + + If Exists All_Attributes_Lst Then + + for k in 1 seqto count All_Attributes_Lst do + Result_string := Result_String || "\n" || All_Attributes_Lst[k] || " " || All_Med_Rel_Dttm_Lst[k] || ": " || All_Values_Lst[k]; + enddo; + + Else + Result_String := Result_String || tab || "No IMAGE diagnostic impressions Recorded. \n" ; + endif; + + + + //*********************************** LOS *********************************/ + + ElseIf Token = "|hospitalday|" and (not (rtf_target_text matches pattern "%Hospital Day:%") + or (rtf_target_text matches pattern "%Hospital Day:%") is null) Then + // If exists Then Assigning the Result to the local session object + If Exists All_Values_Lst Then + Result_String := Result_String || FIRST OF (All_Values_Lst) ; + Else + Result_String := "\b No LOS Data Available. \b0" ; + EndIf; + + EndIf; //Token + + // Calls the STD_DOC_FUNC_CHART_OBSERVATION_HELPER_JAB which writes data to the note + + if Result_String <> "" then + this_documentCommunication:= CALL Called_DOM_Mlm WITH (this_documentCommunication,target_parameter_name,(Result_String,"Append")); //Appending the result with existing value. + endif; + + if theEvent = "DocumentOpening" then + Result_String := ""; + endif; + + Enddo; // for current_item in current_item_list + + + if ( theEvent = "DocumentClosing" ) then + + //Retrieve Type of Service Parameter + typeof_service_param := first of ( this_parameters WHERE ( this_parameters.Name = "SCH_MDPN_CCM_Service provider" ) ); + typeof_service_obs := first of (this_chartedObservationsList WHERE ( this_chartedObservationsList.ParameterGUID = typeof_service_param.ParameterGUID ) ); + typeof_service := first of ( typeof_service_obs.ValueObj.ListItemsList WHERE typeof_service_obs.ValueObj.ListItemsList.IsSelected = true ); + + if ( ( typeof_service.value is not null ) OR ( typeof_service.value <> "" ) ) then + this_documentCommunication.DocumentTopic := typeof_service.value; + this_structuredNoteDoc.DocumentTopic := typeof_service.value; + else + //Need to retrieve logged in user{{{SINGLE-QUOTE}}}s discipline + discipline_var := read last {"Select 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(user_guid) + || " AND cp.Active = 1 " + || " Order by d.TouchedWhen"}; + + this_documentCommunication.DocumentTopic := discipline_var; + this_structuredNoteDoc.DocumentTopic := discipline_var; + + endif; + + endif; + +/* +dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with + "#2 \n this_documentCommunication.DocumentTopic = " || this_documentCommunication.DocumentTopic + || "\n structuredNoteDoc.DocumentTopic = " || structuredNoteDoc.DocumentTopic +, "Error","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; +*/ + + if msg <> "" then //display message to user + this_documentCommunication.DisplayMessage := true; + this_documentCommunication.Message := msg; + endif; + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return this_documentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SUNRISE_SURGICAL_NOTES_OPEN.mlm b/MLMStripper/bin/Debug/DOC/DOC_SUNRISE_SURGICAL_NOTES_OPEN.mlm new file mode 100644 index 0000000..53434fd --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SUNRISE_SURGICAL_NOTES_OPEN.mlm @@ -0,0 +1,49 @@ +maintenance: + + title: DOC_SUNRISE_SURGICAL_NOTES_OPEN;; + mlmname: DOC_SUNRISE_SURGICAL_NOTES_OPEN;; + arden: version 2.5;; + version: 1.00;; + institution: St. Clair Hospital;; + author: Shawn Head x7468 - Allscripts/St. Clair Hospital;; + specialist: ;; + date: 2017-06-20;; + validation: testing;; + +library: + purpose: Used to call other MLM{{{SINGLE-QUOTE}}}s required to execute on Sunrise Surgical Notes when Opened. + ;; + explanation: + Change History + + 06.20.2017 - STH - CSR#: 35320 - Created + ;; + keywords: + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + (thisDocumentCommunication) := argument; + + // Call MLM to to pull surgical case information into note. + SURGICAL_CASE_DETAILS := MLM {{{SINGLE-QUOTE}}}DOC_SCH_SMP_SURGICAL_CASE{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL SURGICAL_CASE_DETAILS WITH thisDocumentCommunication; + + //Call MLM to default OBS values based on Configured Observation on structured note. + DEFAULT_OBS_VALUES := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_DEFAULT_OBS_VALUES{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DEFAULT_OBS_VALUES WITH thisDocumentCommunication; + + + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_SZ_TESTING4.mlm b/MLMStripper/bin/Debug/DOC/DOC_SZ_TESTING4.mlm new file mode 100644 index 0000000..014b3b2 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_SZ_TESTING4.mlm @@ -0,0 +1,154 @@ +maintenance: + + title: ;; + mlmname: DOC_SZ_TESTING4;; + arden: version 2.5;; + version: 0.00;; + institution: ;; + author: ;; + specialist: ;; + date: 2017-06-04;; + validation: testing;; + +library: + purpose: UPDATE THE SEPSIS COLUMN WITH "POTENTIAL SIRS" GIVEN ABNORMAL LAB AND/OR VITALS ;; + explanation: + ;; + keywords: + ;; + citations: + ;; +knowledge: + type: data-driven;; + data: + + (this_doc_com) := argument; + + /*************Make changes to spelling and flags in this section****************/ + //parameter names in config + temp_param := "sch_edtriage_fahrenheit NU"; + hr_param := "sch_edtriage_heart rate"; + rr_param := "sch_edtriage_resp rate"; + + column_name1 := "Sepsis Alert"; + column_value1 := "Potential SIRS"; + + //associated configurations (in config tools): + //Struct Note: "sch_edtriage_triage note" + //FS Catalog: "SCH_Vital Sign_ED_Version" + //Doc. Cat. - Flowsheet: "1. Vital Sign - ED" + //Doc. Cat. - Structured Note: "ED Triage Note" + + //associated MLMs: + // universal mlm for closing of Flowsheet: DOC_ED_VITAL_SIGNS_CLOSE + // universal MLM for closing of Structured Note: DOC_ED_TRIAGE_NOTE_CLOSE + + //when moving live, these 2 MLMs need to be added to production: + // 1) DOC_SEPSIS_STATUS_BOARD_COLUMN_ED + // 2) DOC_ED_VITAL_SIGNS_CLOSE + // 3) then add DOC_ED_VITAL_SIGNS_CLOSE to "Closing MLM" setting in Doc. Cat. - Flowsheet: "1. Vital Sign - ED" in config tools + // 4) update Called MLM to "" under attributes tab for Struct Note: "sch_edtriage_triage note" + /********************************************************************************/ + + if (this_doc_com.documenttype = "flowsheet") then + + fs_doc_config_obj := this_doc_com.DocumentConfigurationObj; + this_parms := fs_doc_config_obj.ParametersList; + this_cols := fs_doc_config_obj.ColumnsList; + + //get guids + ClientGUID := this_doc_com.ClientGUID; + ChartGUID := this_doc_com.ChartGUID; + ClientVisitGUID := this_doc_com.ClientVisitGUID; + + //initialize our validation lists + temp_val_list := (); + hr_val_list := (); + rr_val_list := (); + + //get guids for later use + temp_guid := last(this_parms.ParameterGUID where this_parms.Name = temp_param) as string; + hr_guid := last(this_parms.parameterguid where this_parms.Name = hr_param) as string; + rr_guid := last(this_parms.ParameterGUID where this_parms.Name = rr_param) as string; + + //March across the columns and get observation values and add them to previously inialized lists. <-- this feature doesn{{{SINGLE-QUOTE}}}t work anymore as chartedobservationslist[i] returns () empty list for all columns + //except current column. I kept this code since I can still get current column values using it. + for j in 1 seqto (count this_cols) do //loops through each column + (this_obs) := this_cols[j].chartedobservationslist; //the chartedObservationsList of each column is suppoed to bring up: observationGUID, clientDocumentGUID, ParameterGUID, DataType, and ValueObj + + //if the temperature guid is in the + if temp_guid is in (this_obs.parameterguid) then //if guid for temperature matches the parameterguid for + temp_val_obj := (this_obs.valueobj where this_obs.parameterguid = temp_guid); //now put it in the list + temp_val_list := temp_val_list,(temp_val_obj.value as number); + endif; + + if hr_guid is in (this_obs.parameterguid) then //if guid for temperature matches the parameterguid for + hr_val_obj := (this_obs.valueobj where this_obs.parameterguid = hr_guid); //now put it in the list + hr_val_list := hr_val_list, (hr_val_obj.value as number); + endif; + + if rr_guid is in (this_obs.parameterguid) then //if guid for temperature matches the parameterguid for + rr_val_obj := (this_obs.valueobj where this_obs.parameterguid = rr_guid); //now put it in the list + rr_val_list := rr_val_list, (rr_val_obj.value as number); + endif; + enddo; + + + // determine the maximum of values from each list + current_col_temp := max(temp_val_list); + current_col_hr := max(hr_val_list); + current_col_rr := max(rr_val_list); + + if (current_col_temp >= 100.4 or current_col_temp < 96.8) then + TEMP_DOC_abnormal := true; + endif; + + if (current_col_hr > 100) then + HR_DOC_abnormal := true; + endif; + + if (current_col_rr >= 22) then + RR_DOC_abnormal := true; + endif; + endif; + + + //Setting up our mlm to be called and our object. Instantiate sepsis_column using our created object. + create_ED_column := MLM {{{SINGLE-QUOTE}}}SCH_FUNC_CREATE_ENTERPRISE_DEFINED_COLUMN{{{SINGLE-QUOTE}}}; // MLM that creates the Enterprise Defined Column in the "Action" section of the MLM + EDCObj := OBJECT [column_name,column_value,client_guid,chart_guid,client_visit_guid]; // Create Enterprise Defined Column Obj + Sepsis_Column:= NEW EDCObj WITH + [ + column_name := column_name1, + column_value := column_value1, + client_guid := ClientGUID, + chart_guid := ChartGUID, + client_visit_guid := ClientVisitGUID + ]; + + + + + // enter this conditional only if WBC/Bands/granulocytes are normal + // Checks if temperature is normal. If abnormal, then proceed, if normal then stop. + if (TEMP_DOC_abnormal = true) then + // Checks if hr/rr are abnormal, if so then fire sepsis display, if normal then stop + if ((HR_DOC_abnormal = true) or (RR_DOC_abnormal = true)) then + //calls our MLM with instantiated object + return_value := call create_ED_column with ( Sepsis_Column ); + endif; + endif; + + + BREAK; + + ;; + priority: 50 + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return this_doc_com; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_TOBACCO_ASSESSMENT_SELECTIONS.mlm b/MLMStripper/bin/Debug/DOC/DOC_TOBACCO_ASSESSMENT_SELECTIONS.mlm new file mode 100644 index 0000000..0d06f87 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_TOBACCO_ASSESSMENT_SELECTIONS.mlm @@ -0,0 +1,126 @@ +maintenance: + + title: DOC_Tobacco_Assessment_Selections ;; + mlmname: DOC_Tobacco_Assessment_Selections ;; + arden: version 5.5;; + version: 2.50;; + institution: St.Clair Hospital;; + author: Shivprasad Jadhav;; + specialist: ;; + date: 2015-05-10;; + validation: testing;; +library: + purpose: On Adult patient profile Structure note, if the first list item is selected ‘recognizing danger situations’ + then developing coping skills and provided basic information + about quitting should also get selected. This should only occur when the location is of ‘PSYE’ and PSYW’.;; + explanation: Select the Check boxex + + Change history + --------------------------------- + 2015-10-06 GOS Created CSR#33406 + + ;; + keywords: ;; +knowledge: + type: data-driven;; + data: + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + // Recieve arguments from the structured note + (thisDocumentCommunication) := argument; + + // Extract interesting parts of the object model + (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; + (thisParameters) := thisStructuredNoteDoc.ParametersList; + (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; + + // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate + ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; + FreeTextValueType := OBJECT [Value]; + + ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; + ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; + + // Get the client and visit GUIDs + clientGuid := thisDocumentCommunication.ClientGUID; + visitGuid := thisDocumentCommunication.ClientVisitGUID; + chartGuid := thisDocumentCommunication.ChartGUID; + +// For Adult Patient Profile ----------------------------------------------------------------------------------------------------- + + this_parametername := Last of (thisParameters where thisParameters.Name = "SCHCK Tobacco Use Practical Counseling/Education"); + theObservation := Last of (thisobservations where thisobservations.ParameterGUID = this_parametername.ParameterGUID); + + +/*a:=theObservation.ValueObj.ListItemsList.Records__ ; +b:= Last of ( theObservation Where theObservation.ValueObj.ListItemsList.IsSelected= True ); +d:= b.ValueObj.Records__ ; +c:=b.ValueObj.ListItemsList.Value ; */ + + If true in (theObservation.ValueObj.ListItemsList.IsSelected where + theObservation.ValueObj.ListItemsList.Value = "recognizing danger situations" + ) then chronic := "recognizing danger situations"; + endif; + + +(LocationLevelCode) := read last { "select Top 1 case when cc.typecode = {{{SINGLE-QUOTE}}}unit{{{SINGLE-QUOTE}}} then cc.levelcode when b.typecode={{{SINGLE-QUOTE}}}unit{{{SINGLE-QUOTE}}} then b.levelcode when a.typecode={{{SINGLE-QUOTE}}}unit{{{SINGLE-QUOTE}}} then a.levelcode " +|| " when cv3l.typecode={{{SINGLE-QUOTE}}}unit{{{SINGLE-QUOTE}}} then cv3l.levelcode else null end as Unit From CV3ClientVisit CV With (nolock) " +|| " Inner Join Cv3Location L With (nolock) On L.Guid=CV.CurrentLocationGUID AND CV.Active=1 AND CV.VisitStatus={{{SINGLE-QUOTE}}}ADM{{{SINGLE-QUOTE}}} " +|| " Left Join Cv3ClientVisitLocation CVL With (nolock) ON CVL.ClientVisitGUID=CV.GUID Left Join CV3Location CV3L On CV3L.GUID=CVL.LocationGUID " +|| " Left Join CV3Location a With (nolock) on CV3L.parentguid= a.guid Left Join CV3Location b With (nolock) on a.parentguid = b.guid " +|| " left join cv3location cc With (nolock) on b.parentguid = cc.guid " +|| " WHERE CVL.Status={{{SINGLE-QUOTE}}}CUR{{{SINGLE-QUOTE}}} and CV.GUID = " || visitGuid || " " }; + + + If chronic = "recognizing danger situations" And LocationLevelCode In ("PSYE","PSYW") Then + + MLM_DIPA := MLM {{{SINGLE-QUOTE}}}UTIL_OBJECT_Customize_DIPA_MLM{{{SINGLE-QUOTE}}}; + + prm_Comf_mes := First of (thisParameters where thisParameters.Name = "SCHCK Tobacco Use Practical Counseling/Education"); + Var1 := "recognizing danger situations" ,"developing coping skills" ,"provided basic information about quitting"; + + //recognizing danger situations, developing coping skills, provided basic information about quitting, provided exit care packet based on readiness to learn, refuses counseling/education + + If true in (theObservation.ValueObj.ListItemsList.IsSelected where + theObservation.ValueObj.ListItemsList.Value = "provided exit care packet based on readiness to learn" + ) then Var1 := Var1 , "provided exit care packet based on readiness to learn"; + endif; + If true in (theObservation.ValueObj.ListItemsList.IsSelected where + theObservation.ValueObj.ListItemsList.Value = "refuses counseling/education" + ) then Var1 := Var1 , "refuses counseling/education"; + endif; + + //To Clear the existing Charted Values========================================================================================= + + //Obs_Comf_Vi := CALL MLM_DIPA WITH thisDocumentCommunication,prm_Comf_mes, "" as string ; + //Obs_Comf_Vi.ValueObj.SuggestedTextValue := vi_Sugg ; + + //thisDocumentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + // thisDocumentCommunication.DocumentConfigurationObj.ChartedObservationsList,Obs_Comf_Vi ); + //------------------------------------------------------------------- + + + Obs_Comf_Vi := CALL MLM_DIPA WITH thisDocumentCommunication,prm_Comf_mes, Var1 as string ; + //Obs_Comf_Vi.ValueObj.SuggestedTextValue := vi_Sugg ; + + thisDocumentCommunication.DocumentConfigurationObj.ChartedObservationsList := ( + thisDocumentCommunication.DocumentConfigurationObj.ChartedObservationsList,Obs_Comf_Vi ); + + Endif; +;; + evoke: + ;; + logic: + conclude true; + ;; + action: + return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/DOC/DOC_VACCINE_PROTOCOLS.mlm b/MLMStripper/bin/Debug/DOC/DOC_VACCINE_PROTOCOLS.mlm new file mode 100644 index 0000000..29bd139 --- /dev/null +++ b/MLMStripper/bin/Debug/DOC/DOC_VACCINE_PROTOCOLS.mlm @@ -0,0 +1,64 @@ +maintenance: + + title: Vaccine Protocol Assessments;; + mlmname: DOC_Vaccine_Protocols;; + arden: version 5.0;; + version: 2.00;; + institution: St.Clair Hospital;; + author: Teresa Spicuzza;; + specialist: ;; + date: 2010-02-03;; + validation: testing;; + +library: + purpose: + ;; + explanation: This "master" MLM calls others for the Pediatric Patient Profile. + + + Change history + + 09.09.2010 TS Copied from DOC_MD_PROGRESSNOTE + 01.26.2011 TS Added call for Diabetes risk assessment + 09.21.2011 DW Removed call for Diabetes risk assessment + 02.08.2012 DW CSR# 26309 - added TDAP MLM + 02.08.2012 DW CSR# 26945 Added call to DOC_FUNC_ADVANCE_DIRECTIVE + 07.19.2013 DW CSR# 31450 Free Text Meds + + ;; + keywords: + ;; +knowledge: + type: data-driven;; + data: + // Recieve arguments from the structured note + + (thisDocumentCommunication) := argument; + DocInfluenza := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_INFLUENZA{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocInfluenza WITH thisDocumentCommunication; +// + (thisDocumentCommunication) := argument; + DocPneumovax := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_PNEUMOVAX{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocPneumovax WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + DocDTAP := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_ADVANCE_DIRECTIVE{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocDTAP WITH thisDocumentCommunication; + + (thisDocumentCommunication) := argument; + DocDTAP := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_TDAP{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocDTAP WITH thisDocumentCommunication; +/* + (thisDocumentCommunication) := argument; + DocDTAP := MLM {{{SINGLE-QUOTE}}}DOC_FUNC_FREE_TEXT_MEDS{{{SINGLE-QUOTE}}}; + thisDocumentCommunication := CALL DocDTAP WITH thisDocumentCommunication; +*/ + ;; + evoke: + ;; + logic: conclude true; + ;; + action: return thisDocumentCommunication; + ;; +Urgency: 50;; +end: diff --git a/MLMStripper/bin/Debug/FLUENCY/FLUENCY_SSO_LOGON.mlm b/MLMStripper/bin/Debug/FLUENCY/FLUENCY_SSO_LOGON.mlm new file mode 100644 index 0000000..37df501 --- /dev/null +++ b/MLMStripper/bin/Debug/FLUENCY/FLUENCY_SSO_LOGON.mlm @@ -0,0 +1,60 @@ +maintenance: + +title: Fluency_SSO_Logon;; +mlmname: Fluency_SSO_Logon;; +arden: version 2.5;; +version: 5.00;; +institution: Eclipsys, Sample MLM;; +author: MModal - Justin Pihony;; +specialist: ;; +date: 2012-10-03;; +validation: testing;; +library: +purpose: +;; +explanation: Send the username to Fluency so that it can load when Sunrise starts + + Change history + + 02.02.2010 DW CSR# 31658 Initial Load + 12.03.2019 DW CSR# 37676 18.4 Upgrade (loaded in conjuction w/ 10.0.689.1865 to correct physician logon crashing issue) + + +;; +keywords: User ;; +knowledge: +type: data-driven;; +data: +USING "mscorlib, Version=2.0.0.0, Culture=neutral,PublicKeyToken=b77a5c561934e089"; +//(this_documentCommunication) := argument; +// Specify which .NET assemblies need to be loaded for ObjectsPlus +standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; +include standard_libs; +/**************Make Changes To Spelling And Flags In This Section**************/ +/* Set to true if logging is needed.*/ +log_execution_info:= false; +Activate_Application_trigger:= EVENT { ActivateApplication User UserInfo}; +(User_Name) := read last +{ UserInfo: IDCode}; +;; +evoke: +Activate_Application_trigger; +;; +logic: +conclude true; +;; +action: +try +mModalStub := call {{{SINGLE-QUOTE}}}Reflection.Assembly{{{SINGLE-QUOTE}}}.LoadFile with "C:\\MModal\\Server\\RemoteService.dll"; +windowLoader := call mModalStub.CreateInstance with "FDLink.SSOClient"; +voidResult := call windowLoader.Initialize; +voidResult := call windowLoader.Logon with User_Name; +endtry; +catch exception DictationServerException + ErrorMessage := "An error has been encountered while trying to sign on to Fluency Direct. Please contact your administrator if this problem persists.\n\n\n\nException:" || + DictationServerException; + //this_documentCommunication.DisplayMessage := true; + //this_documentCommunication.Message := "An error has been encountered while trying to sign on to Fluency Direct. Please contact your administrator if this problem persists.\n\n\n\nException:" || DictationServerException ; +endcatch; +;; +end: diff --git a/MLMStripper/bin/Debug/FORM/FORM_ACCESS_MANAGER_HIE_CONSENT_UPDATE.mlm b/MLMStripper/bin/Debug/FORM/FORM_ACCESS_MANAGER_HIE_CONSENT_UPDATE.mlm new file mode 100644 index 0000000..2f8d765 --- /dev/null +++ b/MLMStripper/bin/Debug/FORM/FORM_ACCESS_MANAGER_HIE_CONSENT_UPDATE.mlm @@ -0,0 +1,100 @@ +maintenance: + + title: Form_Access_Manager_HIE_Consent_Update;; + mlmname: Form_Access_Manager_HIE_Consent_Update;; + arden: version 2;; + version: 4.50;; + institution: St Clair;; + author: Bryan Berkeybile, Eclipsys Corp;; + specialist: ;; + date: 2018-01-15;; + validation: testing;; + +library: + purpose: Edits for Access Manager/Enterprise Scheduling HIE field that are completed in Acute Care / Comments. + + ;; + + explanation: This MLM is attached to Form {{{SINGLE-QUOTE}}}Registration Patient - Supplemental{{{SINGLE-QUOTE}}} found in "SCM Configuration Tools / Dictionary Maintenance / Called MLM Form Config (AM)". + It will check to see if a patient has entries for the HIE, if not it will query the comments in Acute Care and pull those values to the HIE items + on the Reg Pat-Supplemental tab. If there are no HIE values for a patient, and there are no comments for HIE, the values will remain blank and mandatory to be filled in. + + + Change history + + 01.15.2018 BB CSR# 26413 - Created + + + ;; + keywords: Called MLMs, Form fields + ;; +knowledge: + type: data-driven;; + data: + + + + (this_communication, this_form, client_info_obj ) := argument; + log_execution_info := FALSE; + error_message:=""; + standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + field_list:= this_form.fields; + + CallingEvent := this_communication.CallingEvent; + CallingField :=this_communication.CallingFieldName; + + + HIE_Auth := last of (field_list where field_list.DataItemName = "SER-HIEAUTH" ); + HIE_Date := last of (field_list where field_list.DataItemName = "SER-HIEDATE" ); + + +// FORM INFO + + + If CallingEvent = "FormOpen" + + then + + ClientGuid := this_communication.ClientGUID; + + (Auth_Results) := read last { " select distinct cd.Text" + || " from CV3CommentDeclaration cd with (nolock) " + || " JOIN cv3clientvisit cv with (nolock) on cv.ClientGUID = cd.ClientGUID " + || " where cv.clientguid = " || sql(ClientGUID) + || " AND cd.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " + || " AND cd.typecode = {{{SINGLE-QUOTE}}}HIE Consent Val{{{SINGLE-QUOTE}}} " }; + + (Date_Results) := read last { " select distinct convert(varchar, convert(datetime, cd.Text), 110)" + || " from CV3CommentDeclaration cd with (nolock) " + || " JOIN cv3clientvisit cv with (nolock) on cv.ClientGUID = cd.ClientGUID " + || " where cv.clientguid = " || sql(ClientGUID) + || " AND cd.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " + || " AND cd.typecode = {{{SINGLE-QUOTE}}}HIE Consent Dat{{{SINGLE-QUOTE}}} " }; + + if HIE_Auth.value is null + Then HIE_Auth.value := Auth_Results; + endif; + + + if (HIE_Date.value is null) + Then HIE_Date.value := Date_Results; + endif; + + + endif; + + + ;; + evoke: + ;; + logic: + + conclude true; + ;; + action: + + return this_communication, this_form; + ;; +end: diff --git a/MLMStripper/bin/Debug/FORM/FORM_ACCESS_MANAGER_OP_SERVICE_AREA_UPDATE.mlm b/MLMStripper/bin/Debug/FORM/FORM_ACCESS_MANAGER_OP_SERVICE_AREA_UPDATE.mlm new file mode 100644 index 0000000..b723137 --- /dev/null +++ b/MLMStripper/bin/Debug/FORM/FORM_ACCESS_MANAGER_OP_SERVICE_AREA_UPDATE.mlm @@ -0,0 +1,138 @@ +maintenance: + + title: FORM_Access_Manager_OP_Service_Area_Update;; + mlmname: FORM_Access_Manager_OP_Service_Area_Update;; + arden: version 2;; + version: 4.50;; + institution: St Clair;; + author: Juliet M. Law;; + specialist: Peggy Leschak;; + date: 2018-09-28;; + validation: testing;; + +library: + purpose: Updates outpatient status board Service Area enterprised defined columns + + ;; + + explanation: This MLM is attached to Form {{{SINGLE-QUOTE}}}Registration Visit - SER- OP Service Area{{{SINGLE-QUOTE}}}. It will update enterprise defined columns on outpatient status boards when registration changes + the OP Service Area form on the Visit Registration. + + + Change history + + 2018.09.28 JML WO Incident # 3377118 - Created. + + + ;; + keywords: Called MLMs, Form fields + ;; +knowledge: + type: data-driven;; + data: + + + + (this_communication, this_form, client_info_obj ) := argument; + + log_execution_info := FALSE; + error_message:=""; + + standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + //Include generic function to update enterprise defined column + update_ED_column := MLM {{{SINGLE-QUOTE}}}SCH_FUNC_CREATE_ENTERPRISE_DEFINED_COLUMN{{{SINGLE-QUOTE}}}; + + //Create Enterprise Defined Column Obj + EDCObj := OBJECT [ + column_name, + column_value, + client_guid, + chart_guid, + client_visit_guid + ]; + + field_list:= this_form.fields; + CallingEvent := this_communication.CallingEvent; + CallingField :=this_communication.CallingFieldName; + ClientGUID := this_communication.ClientGUID; + VisitGUID := this_communication.ClientVisitGUID; + ChartGUID := this_communication.ChartGUID; + + // Retrieve form fields + OP_Svc_1 := first of ( field_list WHERE field_list.DataItemName = "SER-OP SERVICE 1" ); + OP_Svc_Time_1 := first of ( field_list WHERE field_list.DataItemName = "SER-OP SERV TIME 1" ); + + OP_Svc_2 := first of ( field_list WHERE field_list.DataItemName = "SER-OP SERVICE 2" ); + OP_Svc_Time_2 := first of ( field_list WHERE field_list.DataItemName = "SER-OP SERV TIME 2" ); + + OP_Svc_3 := first of ( field_list WHERE field_list.DataItemName= "SER-OP SERVICE 3" ); + OP_Svc_Time_3 := first of ( field_list WHERE field_list.DataItemName = "SER-OP SERV TIME 3" ); + + OP_Svc_4 := first of ( field_list WHERE field_list.DataItemName = "SER-OP SERVICE 4" ); + OP_Svc_Time_4 := first of ( field_list WHERE field_list.DataItemName = "SER-OP SERV TIME 4" ); + + if ( CallingEvent = "FieldChange" ) then + if ( CallingField = "SER-OP SERVICE 1" ) then + //Call EDC MLM + col_name := "Service 1"; + col_value := OP_Svc_1.Value; + endif; + if ( CallingField = "SER-OP SERV TIME 1" ) then + col_name := "Time 1"; + col_value := OP_Svc_Time_1.Value; + endif; + + if ( CallingField = "SER-OP SERVICE 2" ) then + col_name := "Service 2"; + col_value := OP_Svc_2.Value; + endif; + if( CallingField = "SER-OP SERV TIME 2" ) then + col_name := "Time 2"; + col_value := OP_Svc_Time_2.Value; + endif; + + if ( CallingField = "SER-OP SERVICE 3" ) then + col_name := "Service 3"; + col_value := OP_Svc_3.Value; + endif; + if ( CallingField = "SER-OP SERV TIME 3" ) then + col_name := "Time 3"; + col_value := OP_Svc_Time_3.Value; + endif; + + if ( CallingField = "SER-OP SERVICE 4" ) then + col_name := "Service 4"; + col_value := OP_Svc_4.Value; + endif; + if ( CallingField = "SER-OP SERV TIME 4" ) then + col_name := "Time 4"; + col_value := OP_Svc_Time_4.Value; + endif; + endif; + + + ;; + evoke: + ;; + logic: + + SvcLoc := NEW EDCObj WITH [ + column_name := col_name, + column_value := col_value, + client_guid := ClientGUID, + chart_guid := ChartGUID, + client_visit_guid := VisitGUID + ]; + + //Call function to update enterprise defined column + return_value := call update_ED_column WITH ( SvcLoc ); + + conclude true; + ;; + action: + + return this_communication, this_form; + ;; +end: diff --git a/MLMStripper/bin/Debug/FORM/FORM_ACCESS_MANAGER_SIGNATURE_CAPTURE_UPDATE.mlm b/MLMStripper/bin/Debug/FORM/FORM_ACCESS_MANAGER_SIGNATURE_CAPTURE_UPDATE.mlm new file mode 100644 index 0000000..9ff8364 --- /dev/null +++ b/MLMStripper/bin/Debug/FORM/FORM_ACCESS_MANAGER_SIGNATURE_CAPTURE_UPDATE.mlm @@ -0,0 +1,193 @@ +maintenance: + + title: Form_Access_Manager_Signature_Capture_Update;; + mlmname: Form_Access_Manager_Signature_Capture_Update;; + arden: version 2;; + version: 4.50;; + institution: St Clair;; + author: Don Warnick, Eclipsys Corp;; + specialist: ;; + date: 2017-10-12;; + validation: testing;; + +library: + purpose: Edits for Access Manager/Enterprise Scheduling demographic field edits + + ;; + + explanation: This MLM is attached to Form Fields found on form "SER-SignCaptureDocs" + + + Change history + + 10.12.2017 DW CSR# 26413 - Created + + + ;; + keywords: Called MLMs, Form fields + ;; +knowledge: + type: data-driven;; + data: + + + + (this_communication, this_form, client_info_obj ) := argument; + log_execution_info := FALSE; + error_message:=""; + standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + field_list:= this_form.fields; + + CallingEvent := this_communication.CallingEvent; + CallingField :=this_communication.CallingFieldName; + + + ClientGuid := this_communication.ClientGUID; + ClientVisitGuid := this_communication.ClientVisitGuid; + ChartGuid := this_communication.ChartGUID; + + error_destination := destination { Alert } with [ alert_type:= "Warning",short_message:= "ObjectsPlus Error from MLM",priority:= "low",scope:= "chart",Rule_group:= "ObjectsPlus Error from MLM",Rule_number:= 1003,Rule_subgroup := "",Send_with_order:= "",Alert_dialog_settings:= "",Display_alert:= true ]; + + BloodRefusalField := last of (field_list where field_list.DataItemName = "SER-REQUEST NO BLOOD OR PRODU" ); + + + //Check for Blood Refusal Comment + + + BloodRefusalComment:= Read Last {"select cd.guid + from CV3ClientVisit cv with (nolock) + join CV3CommentDeclaration cd with (nolock) on cv.GUID = cd.ClientVisitGUID and cv.ClientGUID = cd.ClientGUID + where cv.ClientGUID = " || ClientGuid || " and cv.GUID = " || ClientVisitGuid || " and cd.TypeCode = {{{SINGLE-QUOTE}}}Blood Refusal{{{SINGLE-QUOTE}}} and cd.Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} + "}; + + + // Form Open + + + If CallingEvent = "FormOpen" + + then + + //Check for Signed Documents + + + DocumentNameList, DocumentDateList := read + { " + CREATE TABLE #tmp_aaa (ID int IDENTITY(1, 1), documentname varchar(60), documentdate datetime, deletefield varchar (6)) + INSERT INTO #tmp_aaa (documentname,documentdate) + select cd.DocumentName, cd.CreatedWhen + from CV3ClientDocumentCUR cd with (nolock) + where cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || ClientVisitGuid || " + order by cd.DocumentName, cd.CreatedWhen + update t1 set deletefield = {{{SINGLE-QUOTE}}}delete{{{SINGLE-QUOTE}}} from #tmp_aaa t1 + inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.documentname = t2.documentname + delete from #tmp_aaa where deletefield = {{{SINGLE-QUOTE}}}delete{{{SINGLE-QUOTE}}} + select documentname, cast (convert(char(10), documentdate,110) as varchar) from #tmp_aaa + "}; + + if exists DocumentNameList + + then + indexList := 1 seqto count (DocumentDateList); + for j in indexList do + ThisDocumentDate := last (first j from DocumentDateList); + ThisDocumentName := last (first j from DocumentNameList); + + DocumentField := last of (field_list where field_list.Label = ThisDocumentName ); + DocumentField.value := ThisDocumentDate; + enddo; + + endif; + + + // Update the Blood Refusal field with the appropriate value + + If exists BloodRefusalComment + then + BloodRefusalField.value := "Y"; + else + BloodRefusalField.value := ""; + endif; + + + endif; // Form Open + + + + // Form Close + + + + If CallingEvent = "FormClose" + + then + + + // If a the field is blank and there is a comment, delete the comment + + + If BloodRefusalField.value is null and exists BloodRefusalComment // Delete the "Blood Refusal" comment + + then + + try + Discontinue_Comment_obj := call {{{SINGLE-QUOTE}}}PatientComment{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ( (BloodRefusalComment as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}} ); + empty := call Discontinue_Comment_obj.Discontinue; + void := call Discontinue_Comment_obj.Save; + endtry; + + catch exception ex + error_occurred := true; + error_message := error_message || "{{+R}}Discontinue Comment:{{-R}}\n" || ex.Message || "\n\n"; + if ex.InnerException is not null net_object then error_message := error_message || "Inner Exception: " || ex.InnerException.Message || "\n\n"; endif; + if ( Discontinue_Comment_obj is NOT NULL ) then void:= call Discontinue_Comment_obj.Dispose; Discontinue_Comment_obj:= null; endif; + endcatch; + + endif; + + + // If a the field is Y and there is no comment, create a comment + + + If BloodRefusalField.value = "Y" and not exists BloodRefusalComment // Add the "Blood Refusal" comment + + then + + try + client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((ClientVisitGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; + New_Comment_obj := call {{{SINGLE-QUOTE}}}PatientComment{{{SINGLE-QUOTE}}}.CreatePatientComment with client_visit_obj,"Blood Refusal"; + New_Comment_obj.Text := "Y"; + void := call New_Comment_obj.Save; + endtry; + + catch exception ex + error_occurred:= true; + error_message := "{{+R}}New Comment:{{-R}}\n" || ex.Message || "\n\n"; + if ex.InnerException is not null net_object then error_message := error_message || "Inner Exception: " || ex.InnerException.Message || "\n\n"; endif; + if ( New_Comment_obj is NOT NULL ) then void:= call New_Comment_obj.Dispose; New_Comment_obj:= null; endif; + if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; + endcatch; + + + endif; + + + + endif; // Form Close + + + + ;; + evoke: + ;; + logic: + + conclude true; + ;; + action: + + return this_communication, this_form; + ;; +end: diff --git a/MLMStripper/bin/Debug/FORM/FORM_ACETYLCYSTEINE_NEW_ORDER.mlm b/MLMStripper/bin/Debug/FORM/FORM_ACETYLCYSTEINE_NEW_ORDER.mlm new file mode 100644 index 0000000..5d507b2 --- /dev/null +++ b/MLMStripper/bin/Debug/FORM/FORM_ACETYLCYSTEINE_NEW_ORDER.mlm @@ -0,0 +1,134 @@ +maintenance: + + title: FORM_ACETYLCYSTEINE_NEW_ORDER;; + mlmname: FORM_ACETYLCYSTEINE_NEW_ORDER;; + arden: version 2.5;; + version: 5.50;; + institution: St Clair Hospital;; + author: Juliet M. Law, Allscripts ;; + specialist: Bryan Berkeybile, Allscripts;; + date: 2013-06-17;; + validation: testing;; + +library: + purpose: + ;; + + explanation: This MLM is called from ... + + Change history + 2013.06.17 JML CSR 30931: Created + 2013.07.19 BDB Updated the Rate Data Item as original was not crossing to WORx. Then updated BaseSolution Dose, as the + calculation did not need to occur on the Form. Then updated Rate value, as the calculation changed + due to the BaseSolution change. + + + + ;; + keywords: Called MLMs + ;; +knowledge: + type: data-driven;; + data: + + + standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + + HoldOrder_RequestedTime := mlm {{{SINGLE-QUOTE}}}FORM_HOLDORDER_REQUESTEDTIME{{{SINGLE-QUOTE}}}; + + // This MLM is passed three arguments, of types + // communication_type, form_type and client info object respectively. + + (this_communication, // Communication object + this_form, // Form object + client_info_obj //Arden ClientInfo object + ) := argument; + + /*******************Make Changes To Spelling And Flags In This Section*******************/ + + /* Set to true if a decision.log is needed.*/ + log_execution_info := FALSE; + + + /***************************************************************************************/ + + // Initialize error message + error_message:=""; + + // Assigns fields passed in the Form object to the Field object + field_list:= this_form.fields; + CallingEvent := this_communication.CallingEvent; + CallingField := this_communication.CallingFieldName; + ClientGuid := this_communication.ClientGUID; + ChartGuid := this_communication.ChartGUID; + FormName := this_form.Name; + + //Retrieve Fields + Dosage_Low := first of (field_list WHERE field_list.DataItemName = "DosageLow"); + Dosage_Low_fld := Dosage_Low.Value; + + Rate_fld := first of (field_list WHERE field_list.DataItemName = "PRX_IVRATE"); //[BB changed to test updates to UDDI - Was: "OrderIVRate"] + Order_IV_Rate := Rate_fld.Value; + + Instructions_fld := first of (field_list WHERE field_list.DataItemName = "AdminInstructions"); + + + //Add call to FORM_HOLDORDER_REQUESTEDTIME MLM to handle conflict of both MLMs need called on Form Open + (this_communication, this_form) := call HoldOrder_RequestedTime WITH this_communication, this_form, client_info_obj; + + if (CallingEvent = "FormOpen") then + if (Instructions_fld.Value = "Run for 1 hour") then + if (Dosage_Low_fld > 0) then + + Rate_fld.Value := ROUND( ( Dosage_Low_fld / 200 ) + 200 ); + + endif; + elseif (Instructions_fld.Value = "Run for 4 hours") then + if (Dosage_Low_fld > 0) then + + Rate_fld.Value := ROUND( ( ( Dosage_Low_fld / 200 ) + 500 ) / 4 ); + + endif; + elseif (Instructions_fld.Value = "Run for 16 hours") then + if (Dosage_Low_fld > 0) then + + Rate_fld.Value := ROUND( ( ( Dosage_Low_fld / 200 ) + 1000 ) / 16 ); + + endif; + + endif; + elseif (CallingEvent = "FieldChange") then + + if (CallingField = "DosageLow") then + + if (Instructions_fld.Value = "Run for 1 hour") then + + Rate_fld.Value := ROUND (( Dosage_Low_fld / 200 ) + 200 ); + + elseif (Instructions_fld.Value = "Run for 4 hours") then + + Rate_fld.Value := ROUND( ( ( Dosage_Low_fld / 200 ) + 500 ) / 4 ); + + elseif (Instructions_fld.Value = "Run for 16 hours") then + + Rate_fld.Value := ROUND( ( ( Dosage_Low_fld / 200 ) + 1000 ) / 16 ); + + endif; + endif; + endif; + ;; + evoke: // No evoke statement + ;; + logic: + + conclude true; + ;; + action: + // This MLM returns two parameters, of types communication_type and form_type respectively. + return this_communication, this_form; + ;; +end: diff --git a/MLMStripper/bin/Debug/FORM/FORM_ACS_SAME_DAY_ORDER_REPLACEMENT.mlm b/MLMStripper/bin/Debug/FORM/FORM_ACS_SAME_DAY_ORDER_REPLACEMENT.mlm new file mode 100644 index 0000000..efa4ef4 --- /dev/null +++ b/MLMStripper/bin/Debug/FORM/FORM_ACS_SAME_DAY_ORDER_REPLACEMENT.mlm @@ -0,0 +1,604 @@ +maintenance: + + title: FORM_ACS_SAME_DAY_ORDER_REPLACEMENT ;; + mlmname: FORM_ACS_SAME_DAY_ORDER_REPLACEMENT;; + arden: version 2.5;; + version: 16.3;; + institution: Allscripts;; + author: Allscripts Healthcare Solutions, Inc.;; + specialist: St Clair - Maria Pest;; + date: 2017-12-21;; + validation: testing;; + +/* P r o p r i e t a r y N o t i c e */ +/* Unpublished (c) 2013 - 2015 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: MLM to replace the current evoking order with a new order on the worksheet. + ;; + explanation: + Present actionable alert if any of 3 lab orders already done on current calendar day + ;; + keywords: ObjectsPlus/XA, Order + ;; +knowledge: + type: data-driven;; + data: +(this_communication, // Communication object + this_form, // Form object + client_info_obj //Arden ClientInfo object + ) := argument; + primary_obj := this_communication.PrimaryObj; + + OrdersList := ("Basic Metabolic Panel" + ,"Basic Metabolic Panel Fasting" + ,"Comprehensive Metabolic Panel" + ,"Comprehensive Metabolic Panel Fasting" + ,"CBC (Includes Diff)" + ,"CBC with Manual Diff"); + + if this_communication.FormType = "Order" + and this_communication.PrimaryObj.IsPartOfSet + and this_communication.PrimaryObj.name is in OrdersList then + + local_session := cds_session.local; + + ReplacementOrderInfoObj := object [OrderName,RequestedDate,RequestedTime,FormFields,TouchedWhen]; + + ReplacementOrderInfo := NEW ReplacementOrderInfoObj with + (this_communication.PrimaryObj.name + ,(first of (this_form.Fields where this_form.Fields.DataItemName = "RequestedDate")).Value + ,(first of (this_form.Fields where this_form.Fields.DataItemName = "RequestedTime")).Value + ,this_form.Fields + ,NOW); + local_session.ACS_OrderReplacmentOrderInfo := (local_session.ACS_OrderReplacmentOrderInfo,ReplacementOrderInfo); + endif; + + if this_communication.FormType = "Order" + and (not exists(primary_obj.Modifier) or primary_obj.Modifier = "" or primary_obj.Modifier is null) //Ignore repeat orders + and this_communication.OrderSet = "No" + and this_communication.PrimaryObj.name is in OrdersList then + + // Specify which .NET assemblies need to be loaded for ObjectsPlus + standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; + include standard_libs; + + // Using assembly and namespace + using "ObjectsPlusXA.SCM.Forms"; + using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; + using namespace "System.Collections.Generic"; + + CALLED_LAUNCH_LISTBOX_MLM := MLM {{{SINGLE-QUOTE}}}CALLED_LAUNCH_LISTBOX_MULTI_SELECT_ACS{{{SINGLE-QUOTE}}}; + + /*******************Make Changes To Spelling And Flags In This Section*******************/ + + /* Set to true if a decision.log is needed.*/ + log_execution_info := false; + + /* Set to false if not need to display Order Form dialog. + If it{{{SINGLE-QUOTE}}}s set to true, order form will be displayed and the order will be + saved to order entry worksheet when OK is clicked from the order form. */ + display_order_form := false; + + /* Set to false if not to cancel the current order */ + cancel_current_order := true; + + showReplacementMessage := false; + + /***************************************************************************************/ + + // Initialize error message + error_message:=""; + error_occurred := false; + info_message := ""; + + // Assigns fields passed in the Form object to the Field object + field_list:= this_form.fields; + + ClientGuid := this_communication.ClientGUID; + ClientVisitGUID := this_communication.ClientVisitGUID; + ChartGUID := this_communication.ChartGUID; + UserGUID := this_communication.UserGUID; + + primary_object := this_communication.primaryObj; + order_name := primary_object.name; + OrderName := order_name; + CallingFieldName := this_communication.CallingFieldName; + field_list := this_form.fields; + + // set up date range to check if there is a duplicate Order. + requestedDateFieldValue := (first of (this_form.Fields where this_form.Fields.DataItemName = "RequestedDate")).Value; + requestedTimeFieldValue := (first of (this_form.Fields where this_form.Fields.DataItemName = "RequestedTime")).Value; + + if(requestedDateFieldValue = "T")then + ClientVisit_TimeZone := read last {ClientVisit: TimeZone }; + theDate := NOW as TIME ClientVisit_TimeZone; + if(theDate is null or theDate = null or not exists theDate)then + theDate := NOW as TIME; + endif; + + else + theDate := requestedDateFieldValue; + endif; + + begin_date_str := ((extract year theDate) as string) || "-" || + (extract month theDate) formatted with "%0.2d" || "-" || + (extract day theDate) formatted with "%0.2d" || " 00:00:00"; + end_date_str := ((extract year theDate) as string) || "-" || + (extract month theDate) formatted with "%0.2d" || "-" || + (extract day theDate) formatted with "%0.2d" || " 23:59:59"; + + SQLOrderNamesList := ""; + if(OrderName is in ("Basic Metabolic Panel","Basic Metabolic Panel Fasting"))then + SQLOrderNamesList := "{{{SINGLE-QUOTE}}}Basic Metabolic Panel{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Basic Metabolic Panel Fasting{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Comprehensive Metabolic Panel{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Comprehensive Metabolic Panel Fasting{{{SINGLE-QUOTE}}}"; + endif; + if(OrderName is in ("Comprehensive Metabolic Panel","Comprehensive Metabolic Panel Fasting"))then + SQLOrderNamesList := "{{{SINGLE-QUOTE}}}Basic Metabolic Panel{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Basic Metabolic Panel Fasting{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Comprehensive Metabolic Panel{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Comprehensive Metabolic Panel Fasting{{{SINGLE-QUOTE}}}"; + endif; + if(OrderName is in ("CBC (Includes Diff)","CBC with Manual Diff"))then + SQLOrderNamesList := "{{{SINGLE-QUOTE}}}CBC (Includes Diff){{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}CBC with Manual Diff{{{SINGLE-QUOTE}}}"; + endif; + + if(SQLOrderNamesList <> "")then + + query := "select top 1 Name, RequestedDate,RequestedDtm,CV3Order.CreatedWhen,CV3OrderStatus.Description,CV3OrderStatus.LevelNumber,SignificantDtm" + || " from CV3Order" + || " left outer join CV3OrderStatus on CV3OrderStatus.Code = CV3Order.OrderStatusCode and CV3OrderStatus.Active = 1" + || " where ClientGUID = " || ClientGuid + || " and ChartGUID = " || ChartGUID + || " and ClientVisitGUID = " || ClientVisitGUID + || " and CV3Order.Active = 1 and CV3Order.Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} and OrderStatusLevelNum <> 69 and OrderStatusCode <> {{{SINGLE-QUOTE}}}CANP{{{SINGLE-QUOTE}}} and Name in (" || SQLOrderNamesList || ")" + || " and CV3OrderStatus.[Description] not in ({{{SINGLE-QUOTE}}}Repeat Generation Finished{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Active Master Order{{{SINGLE-QUOTE}}})" + || " and (RequestedDtm between " || SQL(begin_date_str) || " and " || SQL(end_date_str) + || " OR (RequestedDtm is null and RequestedDate = {{{SINGLE-QUOTE}}}T{{{SINGLE-QUOTE}}} and CV3Order.CreatedWhen between " || SQL(begin_date_str) || " and " || SQL(end_date_str) + || ")) ORDER BY RequestedDate,CV3Order.CreatedWhen"; + + (FoundOrderName, RequestedDate,RequestedDtm,CreatedWhen,OrderStatus,OrderStatusLevelNum,SignificantDtm) := read last {"" || query}; + + if(OrderStatusLevelNum = 10)then + OrderStatus := "Pending"; + endif; + if(OrderStatusLevelNum = 50)then + OrderStatus := "Active"; + endif; + if(OrderStatusLevelNum = 60)then + OrderStatus := "Received"; + endif; + if(OrderStatusLevelNum = 100)then + OrderStatus := "Completed"; + endif; + if((OrderStatusLevelNum as number) is in (80,83,85))then + OrderStatus := "Resulted"; + endif; + + + if(exists(CreatedWhen) and CreatedWhen is not null)then + ExisitingDuplicateOrderCnt := 1; + else + ExisitingDuplicateOrderCnt := 0; + endif; + + if(ExisitingDuplicateOrderCnt > 0)then + + if(OrderName in ("Basic Metabolic Panel","Basic Metabolic Panel Fasting")) then + SelectionMode := "Multiple"; + ReplaceOrdersList := ("Lytes" + ,"Sodium Plasma/Serum" + ,"Potassium Plasma/Serum" + ,"Chloride Plasma/Serum" + ,"Carbon Dioxide (CO2)" + ,"BUN" + ,"Creatinine" + ,"Glucose Non-Fasting" + ,"Calcium Plasma/Serum"); + endif; + if(OrderName in ("Comprehensive Metabolic Panel","Comprehensive Metabolic Panel Fasting")) then + SelectionMode := "Multiple"; + ReplaceOrdersList := ("Lytes" + ,"Sodium Plasma/Serum" + ,"Potassium Plasma/Serum" + ,"Chloride Plasma/Serum" + ,"Carbon Dioxide (CO2)" + ,"AST/SGOT" + ,"ALT/SGPT" + ,"Albumin Plasma/Serum" + ,"Alkaline Phosphatase" + ,"Bilirubin Total" + ,"BUN" + ,"Creatinine" + ,"Calcium Plasma/Serum" + ,"Glucose Non-Fasting" + ,"Protein Plasma/Serum"); + endif; + if(OrderName in ("CBC (Includes Diff)","CBC with Manual Diff")) then + ReplaceOrdersList := ("CBC No Diff (Hemogram Only)" + ,"Hemoglobin and Hematocrit" + ,"Platelet Count" + ,"H&H and Platelet Count" + ); + endif; + + if(SignificantDtm is not null)then + DisplayDate := SignificantDtm; + else + if(RequestedDate = "T")then + DisplayDate := CreatedWhen; + else + DisplayDate := RequestedDtm; + endif; + endif; + //drop the seconds + DisplayDate := DisplayDate as string; + DisplayDate := substring length(DisplayDate)-3 characters from DisplayDate; + myMessage := "{{{SINGLE-QUOTE}}}" || FoundOrderName || "{{{SINGLE-QUOTE}}} already found for " || DisplayDate || " and is " || OrderStatus || ".\n\n"; + if(FoundOrderName matches pattern "%CBC%")then + myMessage := myMessage || "-Select Cancel to Cancel THIS order\n-Select Yes to choose alternate tests (CBC No Diff, H&H, Platelet)\n-Select No to proceed with this order\n"; + else + myMessage := myMessage || "-Select Cancel to Cancel THIS order\n-Select Yes to choose individual chemistry tests\n-Select No to proceed with this order\n"; + endif; + DialogResult := CALL {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with myMessage as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}, "Duplicate Daily Lab Alert" as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}},"YesNoCancel" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; + if((DialogResult as string) = "Yes")then + result := call CALLED_LAUNCH_LISTBOX_MLM with ReplaceOrdersList, SelectionMode, "Select Orders"; + ReplaceOrderNameList := result; + + //break out {{{SINGLE-QUOTE}}}break out{{{SINGLE-QUOTE}}} items + tmp := (); + for item in ReplaceOrderNameList do + BreakOutItems := (); + if(item = "Lytes")then + BreakOutItems := ("Sodium Plasma/Serum","Potassium Plasma/Serum","Chloride Plasma/Serum","Carbon Dioxide (CO2)"); + endif; + if(item = "H&H and Platelet Count")then + BreakOutItems := ("Hemoglobin and Hematocrit","Platelet Count"); + endif; + if(count BreakOutItems > 0)then + for BOItem in BreakOutItems do + if(BOItem is not in ReplaceOrderNameList)then + tmp := (tmp,BOItem); + endif; + enddo; + else + tmp := (tmp,item); + endif; + enddo; + ReplaceOrderNameList := tmp; + + ReplaceOrderNames := ""; + for ReplaceOrderName in ReplaceOrderNameList do + if(ReplaceOrderNames = "")then + ReplaceOrderNames := "{{{SINGLE-QUOTE}}}" || ReplaceOrderName || "{{{SINGLE-QUOTE}}}"; + else + ReplaceOrderNames := ReplaceOrderNames || ", {{{SINGLE-QUOTE}}}" || ReplaceOrderName || "{{{SINGLE-QUOTE}}}"; + endif; + enddo; + endif; + + //get this new order{{{SINGLE-QUOTE}}}s UDDIs + for item in ReplaceOrderNameList do + if(QueryList is null)then + QueryList := (SQL(item)); + else + QueryList := (QueryList,SQL(item)); + endif; + enddo; + UDDIObj := OBJECT [ItemName,DataItemCode,DataTypeCode]; + newOrderUDDISQL := "select + CV3OrderCatalogMasterItem.Name + ,CV3OrderEntryField.DataItemCode + ,CV3DataItem.DataTypeCode + from + CV3OrderCatalogMasterItem (nolock) + join CV3OrderEntryForm (nolock) on CV3OrderEntryForm.FormGUID = CV3OrderCatalogMasterItem.EntryFormGUID + and CV3OrderEntryForm.IsCurrent = 1 + and CV3OrderEntryForm.Active = 1 + join CV3OrderEntryField + on CV3OrderEntryField.OrderEntryFormGUID = CV3OrderEntryForm.guid + and CV3OrderEntryField.Active = 1 + join CV3DataItem on CV3DataItem.Code = CV3OrderEntryField.DataItemCode + where + CV3OrderCatalogMasterItem.Active = 1 + and CV3OrderCatalogMasterItem.Name in (" || QueryList || ")"; + newOrderUDDIInfo := read as UDDIObj {"" || newOrderUDDISQL}; + + endif; + + endif; + + endif; + +/* +if(userguid = "1000001084119001")then + uo := read {UnsubmittedOrders : this}; + uor := uo.records__; + break; +endif; +*/ + + ;; + evoke: // No evoke statement + ;; + logic: + + if(order_name NOT in ("Basic Metabolic Panel" + ,"Basic Metabolic Panel Fasting" + ,"Comprehensive Metabolic Panel" + ,"Comprehensive Metabolic Panel Fasting" + ,"CBC (Includes Diff)" + ,"CBC with Manual Diff"))then + conclude true; + else + + + if(ExisitingDuplicateOrderCnt = 0)then + conclude true; + endif; + + if((DialogResult as string) = "No")then + //do no intervention + conclude true; + endif; + + if((DialogResult as string) = "Cancel" OR (COUNT ReplaceOrderNameList = 0) )then + //want to cancel the order + this_communication.PrimaryObj.CancelOrder := true; + conclude true; + endif; + + + // The new order can be added only if the current order + // was entered from order entry worksheet + if this_communication.FormType = "Order" //.OrderCanBeCanceled = true + then + try + //----------------------------------------------------------- + // Retrieve current order entry batch. + // The new order can be added only if the parent order + // belongs to the order entry batch + // object owned by the OrderEntryWorksheet. + //----------------------------------------------------------- + worksheetInfo := call {{{SINGLE-QUOTE}}}OrderEntryBatch{{{SINGLE-QUOTE}}}.GetCurrent; + orderBatch := worksheetInfo; + + if worksheetInfo is NULL OR + "OrderEntryWorksheet" <> (worksheetInfo.OrderBatchOwner as String) + then + // If current order entry batch is not OrderEntryWorksheet, + // do not continue with the order replacement. + // Still conclude true to return communication and form objects. + conclude true; + endif; + + this_communication.PrimaryObj.CancelOrder := cancel_current_order; + if(cancel_current_order and NOT this_communication.PrimaryObj.OrderCanBeCanceled)then + void := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "Current Order {{{SINGLE-QUOTE}}}" || OrderName || "{{{SINGLE-QUOTE}}} cannot be Canceled. It must be manually removed from the Order Entry Worksheet."; + endif; + + if cancel_current_order = true + then + info_message := "The order is canceled by MLM."; + endif; + endtry; + catch Exception ex + error_occurred := true; + error_message := ex.Message; + endcatch; + + if error_occurred = false then + //---------------------------------------------------------------------- + // Create a new DIAGNOSTIC order from a catalog item + //---------------------------------------------------------------------- + try + order_Creation_Reason := "Replacing order: " || EvokingObject.Name; + + for ReplaceOrderName in ReplaceOrderNameList do + + // get CatalogMasterItem ObjectsPlus object + ReplaceOrder_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName + with ReplaceOrderName; + + // Create the order + // Session information has been retrieved from the current worksheet if there + // already exists unsubmitted orders. + // The AvailabilityOverride flag is set to AlwaysOverride which will override any + // availabilty policy defined for this order that defines + // this item as not available at this location. The user still need to have the + // correct override right. + Order_obj := call orderBatch.CreateDiagnosticOrder + with + ReplaceOrder_catalog_item, // OrderCatalogMasterItem ObjectsPlus object + order_Creation_Reason, // Create Reason + "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}, // AvailabilityOverride + false, // suppresss messages + (Active_OrderGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}, // Created from order primary key + true; // Mandatory on Worksheet + + + // check if needs to show the order form of the new order + if display_order_form then + order_form_obj:= new NET_OBJECT {{{SINGLE-QUOTE}}}OrderForm{{{SINGLE-QUOTE}}}; + order_form_obj.Order := Order_obj; + dialog_return_value := call order_form_obj.ShowDialog; + // when OK button is clicked from the new order{{{SINGLE-QUOTE}}}s form + // the order will be added to the order entry worksheet unsubmitted list by SCM + // no Save command needs to be called in MLM + if (dialog_return_value as String) = "OK" then + // update the informational message to indicate the new order is created + info_message := info_message + || "\n" || "Order " || ReplaceOrderName || " is created."; + endif; + else + + //freqCodeValue_obj := new net_object {{{SINGLE-QUOTE}}}Frequency{{{SINGLE-QUOTE}}} with "before meals"; + + //Order_obj.RequestedDate := "T"; + //Order_obj.RequestedTime := "Routine"; + if(RequestedDateFieldValue = "T")then + Order_obj.RequestedDate := RequestedDateFieldValue; + else + order_date_str := ((extract year (RequestedDateFieldValue AS TIME)) as string) || "-" || + (extract month (RequestedDateFieldValue AS TIME)) formatted with "%0.2d" || "-" || + (extract day (RequestedDateFieldValue AS TIME)) formatted with "%0.2d"; + Order_obj.RequestedDate := order_date_str; + endif; + Order_obj.RequestedTime := RequestedTimeFieldValue.ReqTimeCode; + + //Order_obj.Frequency := freqCodeValue_obj; + //Order_obj.StopDate := "T+4"; + + conditionalOrderFieldValue := (first of (this_form.Fields where this_form.Fields.DataItemName = "ConditionalOrder")).Value; + if(ConditionalOrderFieldValue.IsConditional)then//this_communication.PrimaryObj.IsConditional)then + Reason := ConditionalOrderFieldValue.Reason as string; + Activations := ConditionalOrderFieldValue.Number as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}; + conditional := new net_object {{{SINGLE-QUOTE}}}ConditionalOrder{{{SINGLE-QUOTE}}} with Activations as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, Reason as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}; + Order_obj.ConditionalOrder := conditional; + endif; + + //UDO_list := EVOKINGOBJECT.OrderUserData.RECORDS__ ; + UDO_list := this_form.Fields; + for x in (1 seqto count UDO_list)do + if(UDO_list[x].value is not null)then + //newOrderUDDI := last of (newOrderUDDIInfo WHERE newOrderUDDIInfo.ItemName = ReplaceOrder_catalog_item.Name and newOrderUDDIInfo.DataItemCode = UDO_list[x].UserDataCode); + newOrderUDDI := last of (newOrderUDDIInfo WHERE newOrderUDDIInfo.ItemName = ReplaceOrder_catalog_item.Name and newOrderUDDIInfo.DataItemCode = UDO_list[x].DataItemName); + if(newOrderUDDI is not null)then + if(newOrderUDDI.DataTypeCode in ("Restricted Dictionary", "Free Format Text","Suggested Dictionary"))then + value := UDO_list[x].value as string; + if(value <> "")then + void := CALL Order_obj.{{{SINGLE-QUOTE}}}SetFormFieldReadOnly{{{SINGLE-QUOTE}}} with newOrderUDDI.DataItemCode as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}, 0 as {{{SINGLE-QUOTE}}}Boolean{{{SINGLE-QUOTE}}}; + retval := call Order_obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with newOrderUDDI.DataItemCode as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}, value as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}; + endif; + endif; + if(newOrderUDDI.DataTypeCode = "Checkbox")then + value := UDO_list[x].value as number; + if(value = 1)then + void := CALL Order_obj.{{{SINGLE-QUOTE}}}SetFormFieldReadOnly{{{SINGLE-QUOTE}}} with newOrderUDDI.DataItemCode as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}, 0 as {{{SINGLE-QUOTE}}}Boolean{{{SINGLE-QUOTE}}}; + retval := call Order_Obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with newOrderUDDI.DataItemCode as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}, 1 as {{{SINGLE-QUOTE}}}Boolean{{{SINGLE-QUOTE}}}; + endif; + endif; + if(newOrderUDDI.DataTypeCode = "Date")then + value := UDO_list[x].value as time; + void := CALL Order_obj.{{{SINGLE-QUOTE}}}SetFormFieldReadOnly{{{SINGLE-QUOTE}}} with newOrderUDDI.DataItemCode as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}, 0 as {{{SINGLE-QUOTE}}}Boolean{{{SINGLE-QUOTE}}}; + retval := call Order_Obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue>{{{SINGLE-QUOTE}}} with newOrderUDDI.DataItemCode , value; + endif; + if(newOrderUDDI.DataTypeCode = "Time")then + value := UDO_list[x].value;// as time; + valueS := value as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}; + sep := ":" AS {{{SINGLE-QUOTE}}}Char{{{SINGLE-QUOTE}}}; + netList := new NET_OBJECT {{{SINGLE-QUOTE}}}List{{{SINGLE-QUOTE}}}; + void := CALL netList.Add WITH sep; + array := CALL netList.ToArray; + parts := CALL valueS.Split WITH array; + myHours := parts[1] as number; + myMinutes := parts[2] as number; + valueT := NEW NET_OBJECT {{{SINGLE-QUOTE}}}ObjectsPlusXA.SunriseClinicalManager.Time{{{SINGLE-QUOTE}}} with (myHours as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}), (myMinutes as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}); + void := CALL Order_obj.{{{SINGLE-QUOTE}}}SetFormFieldReadOnly{{{SINGLE-QUOTE}}} with newOrderUDDI.DataItemCode as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}, 0 as {{{SINGLE-QUOTE}}}Boolean{{{SINGLE-QUOTE}}}; + retval := call Order_Obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue