maintenance: title: FORM_TPA_INCLUSION_EXCLUSION;; mlmname: FORM_TPA_INCLUSION_EXCLUSION;; arden: version 2;; version: 4.50;; institution: St Clair Admissions;; author: Juliet M. Law, Allscripts, Inc ext 7461;; specialist: Maria Pest, Allscripts, Inc ext 7443;; date: 2012-09-24;; validation: testing;; library: purpose: Used for TPA Inclusion/Exclusion Criteria Order for Acute Ishemic Stroke ;; explanation: This MLM is called from the TPA Inclusion/Exclusion Order, form: CPOE_Inc/Exc Crit This MLM will collect the answers on the TPA Inclusion/Exclusion Order to determine if the inclusion/exclusion criteria is met before ordering a TPA for Acute Ishemic Stroke. Change History: 2012.09.24 JML CSR 30685: Created - copied from FORM_SET_TPA_ACUTE_ISHEMIC_STROKE MLM. 2014.09.10 JML CSR 32550: Modify existing TPA Inclusion/Exclusion form. ;; keywords: Called MLMs, TPA, Inclusion/Exclusion ;; knowledge: type: data-driven;; data: // 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; // RS ADD Message box 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 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; client_guid := this_communication.ClientGUID; visit_guid := this_communication.ClientVisitGUID; chart_guid := this_communication.ChartGuid; CallingEvent := this_communication.CallingEvent; CallingField := this_communication.CallingFieldName; //Formatting TAB := 9 FORMATTED WITH "%C"; CR := 13 formatted with "%c"; LF := 10 formatted with "%c"; NIHSS_Score_Fld := last of (field_list WHERE field_list.DataItemName = "CPOE_NIHSS score"); Stroke_Onset_Date_Fld := last of (field_list WHERE field_list.DataItemName = "CPOE_Symptom Onset Date"); Stroke_Onset_Time_Fld := last of (field_list WHERE field_list.DataItemName = "CPOE_Symptom Onset"); BP_Fld := last of (field_list WHERE field_list.DataItemName = "CPOE_BP"); Age_18_Response_Fld := last of (field_list WHERE field_list.DataItemName = "CPOE_Inc/Exc Response"); Age_80_Response_Fld := last of (field_list WHERE field_list.DataItemName = "CPOE_Inc/Exc Response23"); Clinical_Diagnosis_Stroke_Response_Fld := last of (field_list WHERE field_list.DataItemName = "CPOE_Inc/Exc Response2"); NIHSS_25_Score_Fld := last of (field_list WHERE field_list.DataItemName = "CPOE_Inc/Exc Response21"); Exclusion_Statement_Fld1 := last of (field_list WHERE field_list.DataItemName = "CPOE_Inc/Exc_Statement1"); Exclusion_Statement_Fld1.Value := ""; Exclusion_Statement_Fld2 := last of (field_list WHERE field_list.DataItemName = "CPOE_Inc/Exc_Statement2"); Exclusion_Statement_Fld2.Value := ""; Exclusion_Statement_Fld3 := last of (field_list WHERE field_list.DataItemName = "CPOE_Inc/Exc_Statement3"); Exclusion_Statement_Fld3.Value := ""; Exclusion_Statement_Fld4 := last of (field_list WHERE field_list.DataItemName = "CPOE_Inc/Exc_Statement4"); Exclusion_Statement_Fld4.Value := ""; if (CallingEvent = "FormOpen") then //Get NIHSS Score NIHSS_Score := read last {"SELECT o.ValueText" || " 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" || " 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 cd.DocumentName like {{{SINGLE-QUOTE}}}%Assessment/Intervention%{{{SINGLE-QUOTE}}}" || " AND cdd.Active = 1" || " AND od.Active = 1" || " AND cv.ClientGUID = " || Sql(client_guid) || " AND cv.GUID = " || Sql(visit_guid) || " AND cv.ChartGUID = " || Sql(chart_guid) || " AND oci.Name = {{{SINGLE-QUOTE}}}AS SC NIH SS TOTAL CAL{{{SINGLE-QUOTE}}}"}; if (exists NIHSS_Score) then NIHSS_Score_Fld.Value := NIHSS_Score; //Answer #2: NIHSS score >= 4 and NIHSS score <= 22 = YES // NIHSS score > 22 = NO //Answer #21: NIHSS score > 25 = YES; NIHSS score <= 25 = NO /* if (((NIHSS_Score as number) >= 4) AND ((NIHSS_Score as number) <= 22)) then Clinical_Diagnosis_Stroke_Response_Fld.Value := "Yes"; elseif ((NIHSS_Score as number) > 22) then Clinical_Diagnosis_Stroke_Response_Fld.Value := "No"; else //NIHSS_Score < 4 Clinical_Diagnosis_Stroke_Response_Fld.Value := "No"; endif; if ((NIHSS_Score as number) > 25) then NIHSS_25_Score_Fld.Value := "Yes"; else //NIHSS_Score <= 25 NIHSS_25_Score_Fld.Value := "No"; endif; */ endif; //Retrieve Stroke Last Known Well Date (Stroke_Onset_Date, Stroke_Onset_Time) := read last {"SELECT " || " CASE WHEN Len(DatePart(mm, o.ValueText)) = 1 THEN" || " {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} + Convert(varchar(2), DatePart(MM, o.ValueText))" || " ELSE" || " Convert(varchar(2), DatePart(MM, o.ValueText))" || " END" || " + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} +" || " CASE WHEN Len(DatePart(dd, o.ValueText)) = 1 THEN" || " {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} + Convert(varchar(2), DatePart(DD, o.ValueText))" || " ELSE" || " Convert(varchar(2), DatePart(DD, o.ValueText))" || " END" || " + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + Convert(varchar(4), DatePart(YY, o.ValueText))," || " CASE WHEN Len(DatePart(HOUR, o.ValueText)) = 1 THEN" || " {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} + Convert(varchar(2), DatePart(HOUR, o.ValueText))" || " ELSE" || " Convert(varchar(2), DatePart(HOUR, o.ValueText))" || " END" || " + {{{SINGLE-QUOTE}}}:{{{SINGLE-QUOTE}}} +" || " CASE WHEN Len(DatePart(MINUTE, o.ValueText)) = 1 THEN" || " {{{SINGLE-QUOTE}}}0{{{SINGLE-QUOTE}}} + Convert(varchar(2), DatePart(MINUTE, o.ValueText))" || " ELSE" || " Convert(varchar(2), DatePart(MINUTE, o.ValueText))" || " END" || " 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" || " 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 cd.DocumentName like {{{SINGLE-QUOTE}}}%triage%{{{SINGLE-QUOTE}}}" || " AND cdd.Active = 1" || " AND od.Active = 1" || " AND cv.ClientGUID = " || Sql(client_guid) || " AND cv.GUID = " || Sql(visit_guid) || " AND cv.ChartGUID = " || Sql(chart_guid) || " AND oci.Name = {{{SINGLE-QUOTE}}}sch_edtriage_stroke date and time{{{SINGLE-QUOTE}}}"}; if (exists Stroke_Onset_Date) then Stroke_Onset_Date_Fld.Value := Stroke_Onset_Date; Stroke_Onset_Time_Fld.Value := Stroke_Onset_Time; endif; //Retrieve BP (BP_Systolic, BP_Recorded_Dtm) := read {"SELECT o.ValueText, od.RecordedDtm" || " 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" || " 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 cd.DocumentName like {{{SINGLE-QUOTE}}}%vital%sign%{{{SINGLE-QUOTE}}}" || " AND cdd.Active = 1" || " AND od.Active = 1" || " AND cv.ClientGUID = " || Sql(client_guid) || " AND cv.GUID = " || Sql(visit_guid) || " AND cv.ChartGUID = " || Sql(chart_guid) || " AND (oci.Name = {{{SINGLE-QUOTE}}}sch_edtriage_noninvasive systolic bp{{{SINGLE-QUOTE}}}" || " OR oci.Name = {{{SINGLE-QUOTE}}}Noninvasive Systolic BP{{{SINGLE-QUOTE}}})" || " ORDER BY od.RecordedDtm DESC"}; BP_Diastolic := read {"SELECT o.ValueText, od.RecordedDtm" || " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3ClientDocument cd WITH (NOLOCK)" || " ON cv.GUID = cd.ClientVisitGUID" || " AND cv.ClientGUID = cd.ClientGUID" || " AND cv.ChartGUID = cv.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" || " 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 cd.DocumentName like {{{SINGLE-QUOTE}}}%vital%sign%{{{SINGLE-QUOTE}}} AND cdd.Active = 1 AND od.Active = 1" || " AND cv.ClientGUID = " || Sql(client_guid) || " AND cv.GUID = " || Sql(visit_guid) || " AND cv.ChartGUID = " || Sql(chart_guid) || " AND (oci.Name = {{{SINGLE-QUOTE}}}sch_edtriage_noninvasive diastolic bp{{{SINGLE-QUOTE}}}" || " OR oci.Name = {{{SINGLE-QUOTE}}}Noninvasive Diastolic BP{{{SINGLE-QUOTE}}})" || " ORDER BY od.RecordedDtm DESC"}; if (exists BP_Systolic) then BP_Fld.Value := first of (BP_Systolic); endif; if (exists BP_Diastolic) then bp_value := BP_Fld.Value || "/" || first of (BP_Diastolic) || CR || LF || first of (BP_Recorded_Dtm); BP_Fld.Value := bp_value; endif; //Patient{{{SINGLE-QUOTE}}}s Age Question //Question #1: Patient Age >= 18 = YES; Patient Age < 18 = NO //Question #18: Patient Age > 80 = YES; Patient Age <= 80 = NO if (exists client_info_obj) then (birthDate) := read last {ClientInfo: BirthDate REFERENCING client_info_obj}; patientAge := (NOW - birthDate) / (1 year); if (patientAge > 17.99) then Age_18_Response_Fld.Value := "Yes"; else Age_18_Response_Fld.Value := "No"; endif; if (patientAge > 80.99) then Age_80_Response_Fld.Value := "Yes"; else Age_80_Response_Fld.Value := "No"; endif; endif; elseif (CallingEvent = "FormClose") then responseIndex := 1; answeredCount := 0; exclusionCount := 0; exclusionStatement := ""; statementFld := 1; for i in 1 seqto (count field_list) do item := field_list.DataItemName[i]; responseField := "CPOE_Inc/Exc Response" || responseIndex; questionField := "CPOE_Inc/Exc Question" || responseIndex; if ((item = "CPOE_Inc/Exc Response") OR (item = responseField)) then responseValue := last of (field_list WHERE field_list.DataItemName = item); questionValue := last of (field_list WHERE field_list.DataItemName = questionField); // if ((responseIndex >= 1 AND responseIndex <= 3) AND responseValue.Value IS NOT NULL) then if ((( responseIndex >= 1 AND responseIndex <= 3 ) OR ( responseIndex >= 21 AND responseIndex <= 22 )) AND responseValue.Value IS NOT NULL ) then if (responseValue.Value = "No") then exclusionCount := exclusionCount + 1; //exclusionStatement := exclusionStatementList[responseIndex]; exclusionStatement := exclusionCount || ". " || questionValue.Value; if (Exclusion_Statement_Fld1.Value = "") then Exclusion_Statement_Fld1.Value := "Response to following question(s) indicates Exclusion:" || CR || LF; endif; Exclusion_Statement_Fld1.Value := Exclusion_Statement_Fld1.Value || CR || LF || exclusionStatement; if (length Exclusion_Statement_Fld1.Value >= 2000) then statementFld := statementFld + 1; endif; endif; answeredCount := answeredCount + 1; // elseif ((responseIndex > 3) AND (responseValue.Value IS NOT NULL)) then elseif ((( responseIndex >= 4 AND responseIndex <= 20 ) OR ( responseIndex >= 23 AND responseIndex <= 27 )) AND responseValue.Value IS NOT NULL ) then if (responseValue.Value = "Yes") then exclusionCount := exclusionCount + 1; //exclusionStatement := exclusionStatementList[responseIndex] || "\n"; exclusionStatement := exclusionCount || ". " || questionValue.Value; if (statementFld = 1) then if (Exclusion_Statement_Fld1.Value = "") then Exclusion_Statement_Fld1.Value := "Response to following question(s) indicates Exclusion:" || CR || LF; endif; totalFieldLength := ((length exclusionStatement) + (length Exclusion_Statement_Fld1.Value)); if (totalFieldLength <= 2000) then Exclusion_Statement_Fld1.Value := Exclusion_Statement_Fld1.Value || CR || LF || exclusionStatement; else statementFld := statemekntFld + 1; endif; endif; if (statementFld = 2) then totalFieldLength2 := ((length exclusionStatement) + (length Exclusion_Statement_Fld2.Value)); if (totalFieldLength2 <= 2000) then Exclusion_Statement_Fld2.Value := Exclusion_Statement_Fld2.Value || CR || LF || exclusionStatement; else statementFld := statementFld + 1; endif; endif; if (statementFld = 3) then totalFieldLength3 := ((length exclusionStatement) + (length Exclusion_Statement_Fld3.Value)); if(totalFieldLength3 <= 2000) then Exclusion_Statement_Fld3.Value := Exclusion_Statement_Fld3.Value || CR || LF || exclusionStatement; else statementFld := statementFld + 1; endif; endif; if (statementFld = 4) then totalFieldLength4 := ((length exclusionStatement) + (length Exclusion_Statement_Fld4.Value)); if (totalFieldLength4 <= 2000) then Exclusion_Statement_Fld4.Value := Exclusion_Statement_Fld4.Value || CR || LF || exclusionStatement; else statementFld := statementFld + 1; endif; endif; endif; answeredCount := answeredCount + 1; endif; responseIndex := responseIndex + 1; endif; enddo; percentageUnanswered := 27 - answeredCount; percentageUnanswered := percentageUnanswered / 27; percentageUnanswered := percentageUnanswered * 100; if (percentageUnanswered = 0 AND exclusionCount = 0) then Exclusion_Statement_Fld1.Value := "No Exclusions" || CR || LF || "Questions unanswered = " || percentageUnanswered formatted with "%.0f" || "%"; else Exclusion_Statement_Fld4.Value := Exclusion_Statement_Fld4.Value || CR || LF || "Questions unanswered = " || percentageUnanswered formatted with "%.0f" || "%"; endif; endif; //CallingEvent ;; 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: