Files
St.Clair/MLMStripper/bin/Debug/DOC/DOC_FUNC_PNEUMOVAX.mlm

1188 lines
58 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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: