Initial Checking with all 820 MLMs
This commit is contained in:
753
MLMStripper/bin/Debug/DOC/DOC_FUNC_TDAP.mlm
Normal file
753
MLMStripper/bin/Debug/DOC/DOC_FUNC_TDAP.mlm
Normal file
@@ -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:
|
||||
Reference in New Issue
Block a user