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

671 lines
34 KiB
Plaintext

maintenance:
title: Influenza Logic;;
mlmname: DOC_FUNC_DiabetesRisk;;
arden: version 5.0;;
version: 2.00;;
institution: St.Clair Hospital;;
author: Teresa Spicuzza;;
specialist: ;;
date: 2010-09-01;;
validation: testing;;
library:
purpose:
;;
explanation:
Change history
11.23.2010 TS Created - (copy of Doc_FuncPneumovax functionality) MLM checks health issues for diabetes
and checks to see if patient has a HGA1C in the past 3 months if not order placed via mlm.
10.11.2012 JML CSR 30961 - added code to automatically check an HIS defined "unhide" button that displays
additional questions regarding diabetes risk
06.05.2013 JML CSR 30961 - removed coded section that "un-selects" the "SCHCK_Diabetes retrieve info SCM"
observation after user selects it; not allowing the obs to remain selected
was causing an issue with making that obs mandatory for RNs
09.10.2015 DW CSR# 23359 - ICD10
;;
keywords:
;;
knowledge:
type: data-driven;;
data:
// RS ADD Message box
standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}};
include standard_libs;
using "ObjectsPlusXA.SCM.Forms";
using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms";
// Receive arguments from the structured note
(thisDocumentCommunication) := argument;
// Extract interesting parts of the object model
(thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj;
(thisParameters) := thisStructuredNoteDoc.ParametersList;
(thisObservations) := thisStructuredNoteDoc.ChartedObservationsList;
// Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate
ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj];
FreeTextValueType := OBJECT [Value];
DateValueType := OBJECT [Value];
ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue];
ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected];
// Get the client and visit GUIDs
clientGuid := thisDocumentCommunication.ClientGUID;
visitGuid := thisDocumentCommunication.ClientVisitGUID;
chartGuid := thisDocumentCommunication.ChartGUID;
todays_date := now;
// Chart Observation Section
IF thisdocumentCommunication.EventType = "ChartObservation" then
// Determine if the Retrieve Info From SCM button has been selected
// (if so, set SCM flag to yes and reset the button or set the SCM flag to no)
theParameterx := first of (thisparameters where thisparameters.Name = "SCHCK_Diabetes retrieve info SCM");
theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameterx.ParameterGUID);
if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameterx.ParameterGUID then
//CSR 30961 retrieve Info from scm button checked, automatically check the {{{SINGLE-QUOTE}}}unhide{{{SINGLE-QUOTE}}} button
unhide_parametername := first of (thisParameters WHERE thisParameters.Name = "SCHCK_Diabetes Unhide");
new_currentObj := NEW ObservationType;
new_currentObj.ClientDocumentGUID := thisStructuredNoteDoc.ClientDocumentGUID;
new_currentObj.ParameterGUID := unhide_parametername.ParameterGUID;
new_currentObj.DataType := "ListValue";
new_currentObj.ValueObj := NEW ListValueType;
new_currentObj.ValueObj.ListGUID := unhide_parametername.ConfigurationObj.ListGUID;
new_listItems := ();
for item IN unhide_parametername.ConfigurationObj.ListItemsList do
selectedItem := NEW ListValueListItemType;
selectedItem.ListItemGUID := item.ListItemGUID;
selectedItem.Value := item.Value;
selectedItem.IsSelected := true;
new_listItems := (new_listItems, selectedItem);
enddo;
new_currentObj.ValueObj.ListItemsList := new_listItems;
thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, new_currentObj);
//End CSR code change
SCMButton := "yes";
else SCMButton := "no";
endif;
// Determine if the "HgA1C Order - Yes" button has been selected
// (if so, set the SCMButton flag to neither and the "Place Order - Yes" button to yes)
theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Diabetes HgA1C order");
theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID);
if thisDocumentCommunication.CurrentObservationObj.parameterguid = theParameter.ParameterGUID then SCMButton := "neither"; endif;
if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes")
then PlaceOrderYesButton := "yes"; endif;
If SCMButton = "neither" and PlaceOrderYesButton = "yes" then
// The following code is done only if the Place Order YES button was selected
dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n You cannot place an order on this patient. " ,"Alert","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}};
this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Diabetes HgA1C order");
this_currentObj := NEW ObservationType;
this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID;
this_currentObj.ParameterGUID := this_parametername.ParameterGUID;
this_currentObj.DataType := "ListValue";
this_currentObj.ValueObj := New ListValueType;
this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID;
listItems := ();
FOR item IN this_parametername.ConfigurationObj.ListItemsList DO
selectedItem := NEW ListValueListItemType;
selectedItem.ListItemGUID := item.ListItemGUID;
selectedItem.Value := item.Value;
if selectedItem.Value = "yes" then selectedItem.IsSelected := false; endif;
if selectedItem.Value = "no" then selectedItem.IsSelected := true; endif;
listItems := (listItems, selectedItem);
ENDDO;
this_currentobj.ValueObj.ListItemsList := listItems;
thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj);
endif;
// The following code is done only if a the Retrieve from SCM button was selected
// (get data from SCM and populate fields)
If SCMButton = "yes" then
// Diabetes health issues
/*
"select distinct hid.shortname chi.code chi.typecode hid.typecode "
||"from cv3healthissuedeclaration hid with (nolock) "
||"join cv3codedhealthissue chi on chi.Guid = hid.codedhealthissueguid "
where clientvisitguid = {{{SINGLE-QUOTE}}}9000002831200270{{{SINGLE-QUOTE}}} and chi.typecode = {{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}}"
|| "where clientguid = " || ClientGuid || " and hid.active = 1 and hid.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} "
|| "and chi.typecode = {{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}} ( "
*/
/* Replaced with ICD10 project
(diabeteshealthissue) := read
{
"select distinct hid.shortname, chi.code, chi.typecode, hid.typecode "
||"from cv3healthissuedeclaration hid with (nolock) "
||"join cv3codedhealthissue chi on chi.Guid = hid.codedhealthissueguid "
|| "where hid.clientguid = " || ClientGuid || " and hid.active = 1 and hid.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} "
|| "and chi.typecode in ({{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Pt-Stated Hx{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Pt Stated HX{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}AMB Med History{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Problem-Visit{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Vaccine History{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Skin Tests{{{SINGLE-QUOTE}}}) "
|| "and (hid.text like {{{SINGLE-QUOTE}}}%Diabetes%{{{SINGLE-QUOTE}}} or hid.shortname like {{{SINGLE-QUOTE}}}%Diabetes%{{{SINGLE-QUOTE}}} )"|| " and chi.code not in ({{{SINGLE-QUOTE}}}250.50{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}253.2{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}253.5{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}352.3{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}354{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}362.29{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}588.1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.00{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.01{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.03{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.04{{{SINGLE-QUOTE}}}, "
|| " {{{SINGLE-QUOTE}}}648.80{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}648.81{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}648.82{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}648.83{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}648.84{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}648.90{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}775.00{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}775.10{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}V12.2{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}V18.0{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}V19.8{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}V49.89{{{SINGLE-QUOTE}}},"
|| " {{{SINGLE-QUOTE}}}V77.1{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}V84.89{{{SINGLE-QUOTE}}})"
|| " and (hid.description not like {{{SINGLE-QUOTE}}}Diabetes, Gestational%{{{SINGLE-QUOTE}}} or hid.shortname not like {{{SINGLE-QUOTE}}}Diabetes, Gestational%{{{SINGLE-QUOTE}}}) "
};
*/
ProblemList := "({{{SINGLE-QUOTE}}}250.50{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}253.2{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}253.5{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}352.3{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}354{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}362.29{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}588.1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.00{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.01{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.03{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.04{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.80{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.81{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.82{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.83{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.84{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}648.90{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}775.00{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}775.10{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}V12.2{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}V18.0{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}V19.8{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}V49.89{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}V77.1{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}V84.89{{{SINGLE-QUOTE}}})";
(diabeteshealthissue) := read
{
"select distinct hid.shortname, chi.code, chi.typecode, hid.typecode "
||"from cv3healthissuedeclaration hid with (nolock) "
||"join cv3codedhealthissue chi on chi.Guid = hid.codedhealthissueguid "
|| "where hid.clientguid = " || ClientGuid || " and hid.active = 1 and hid.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} "
|| "and chi.typecode in ({{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}ICD10{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Pt-Stated Hx{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Pt Stated HX{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}AMB Med History{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Problem-Visit{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Vaccine History{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Skin Tests{{{SINGLE-QUOTE}}}) "
|| "and (hid.text like {{{SINGLE-QUOTE}}}%Diabetes%{{{SINGLE-QUOTE}}} or hid.shortname like {{{SINGLE-QUOTE}}}%Diabetes%{{{SINGLE-QUOTE}}} )"
|| "and "
|| "( "
|| "(hid.ICD9Code is null and chi.code not in " || ProblemList || " ) "
|| "or "
|| "(hid.ICD9Code is not null and hid.ICD9Code not in " || ProblemList || " ) "
|| ") "
|| " and (hid.description not like {{{SINGLE-QUOTE}}}Diabetes, Gestational%{{{SINGLE-QUOTE}}} or hid.shortname not like {{{SINGLE-QUOTE}}}Diabetes, Gestational%{{{SINGLE-QUOTE}}}) "
};
diabeteshealthissue_found := count(diabeteshealthissue) As Number;
// A1C Test performed
(testperformed) := read last{
"select significantdtm "
|| "from cv3order with (nolock) "
|| "where clientguid = " || ClientGuid || " and name = {{{SINGLE-QUOTE}}}Hemoglobin A1C{{{SINGLE-QUOTE}}} and active = 1 and orderstatuscode = {{{SINGLE-QUOTE}}}RESF{{{SINGLE-QUOTE}}} "
|| "order by significantdtm"
};
testperformed_found := count(testperformed) As Number ;
testnote := "";
//if (testperformed as time)is within the past 3 months then within3months := "Has been "; else within3months := "Has not been "; endif;
if (testperformed as time)is within the past 3 months then within3months := "Has been ";
testnote := "Patient has been tested in the past 3 months: " || testperformed;
else within3months := "Has not been ";
testnote:= "Patient has not been tested in the past 3 months. ";
endif;
// Populate Fields and Boxes
// Select Health Issue radio button (or Health Issue unknown)
healthissue := " ";
this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Diabetes HI- unknown");
this_currentObj := NEW ObservationType;
this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID;
this_currentObj.ParameterGUID := this_parametername.ParameterGUID;
this_currentObj.DataType := "ListValue";
this_currentObj.ValueObj := New ListValueType;
this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID;
listItems := ();
FOR item IN this_parametername.ConfigurationObj.ListItemsList DO
selectedItem := NEW ListValueListItemType;
selectedItem.ListItemGUID := item.ListItemGUID;
selectedItem.Value := item.Value;
if diabeteshealthissue_found = 0 then selectedItem.IsSelected := true; healthissue := "Is unknown if "; endif;
listItems := (listItems, selectedItem);
ENDDO;
this_currentobj.ValueObj.ListItemsList := listItems;
thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj);
If healthissue <> "Is unknown if " then
this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Diabetes HI- y/n");
this_currentObj := NEW ObservationType;
this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID;
this_currentObj.ParameterGUID := this_parametername.ParameterGUID;
this_currentObj.DataType := "ListValue";
this_currentObj.ValueObj := New ListValueType;
this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID;
listItems := ();
FOR item IN this_parametername.ConfigurationObj.ListItemsList DO
selectedItem := NEW ListValueListItemType;
selectedItem.ListItemGUID := item.ListItemGUID;
selectedItem.Value := item.Value;
if selectedItem.Value = "yes" and diabeteshealthissue_found > 0 then selectedItem.IsSelected := true; healthissue := "Has a "; endif;
listItems := (listItems, selectedItem);
ENDDO;
this_currentobj.ValueObj.ListItemsList := listItems;
thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj);
endif;
// Select A1c done in past 3 months radio button (or test done unknown)
labtests := " ";
this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Diabetes HgA1C- unknown");
this_currentObj := NEW ObservationType;
this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID;
this_currentObj.ParameterGUID := this_parametername.ParameterGUID;
this_currentObj.DataType := "ListValue";
this_currentObj.ValueObj := New ListValueType;
this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID;
listItems := ();
FOR item IN this_parametername.ConfigurationObj.ListItemsList DO
selectedItem := NEW ListValueListItemType;
selectedItem.ListItemGUID := item.ListItemGUID;
selectedItem.Value := item.Value;
if within3months = "Has not been " then selectedItem.IsSelected := true; labtests := "Is unknown if "; endif;
listItems := (listItems, selectedItem);
ENDDO;
this_currentobj.ValueObj.ListItemsList := listItems;
thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj);
If within3months = "Has been " then
this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Diabetes HgA1C- y/n");
this_currentObj := NEW ObservationType;
this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID;
this_currentObj.ParameterGUID := this_parametername.ParameterGUID;
this_currentObj.DataType := "ListValue";
this_currentObj.ValueObj := New ListValueType;
this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID;
listItems := ();
FOR item IN this_parametername.ConfigurationObj.ListItemsList DO
selectedItem := NEW ListValueListItemType;
selectedItem.ListItemGUID := item.ListItemGUID;
selectedItem.Value := item.Value;
if selectedItem.Value = "yes" then selectedItem.IsSelected := true; labtests := "Is "; endif;
listItems := (listItems, selectedItem);
ENDDO;
this_currentobj.ValueObj.ListItemsList := listItems;
thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj);
endif;
// new for check lab as no
If within3months = "Has not been " then
this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Diabetes HgA1C- y/n");
this_currentObj := NEW ObservationType;
this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID;
this_currentObj.ParameterGUID := this_parametername.ParameterGUID;
this_currentObj.DataType := "ListValue";
this_currentObj.ValueObj := New ListValueType;
this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID;
listItems := ();
FOR item IN this_parametername.ConfigurationObj.ListItemsList DO
selectedItem := NEW ListValueListItemType;
selectedItem.ListItemGUID := item.ListItemGUID;
selectedItem.Value := item.Value;
if selectedItem.Value = "no" then selectedItem.IsSelected := true; labtests := "Is not "; endif;
listItems := (listItems, selectedItem);
ENDDO;
this_currentobj.ValueObj.ListItemsList := listItems;
thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj);
endif;
// Prepare the data for the Diabetes Health Issue and A1C performed boxes
holdHI:="";
if diabeteshealthissue_found > 0 then
for k in (1 seqto (diabeteshealthissue_found)) do
if diabeteshealthissue[k] is not null then
holdHI := holdHI || diabeteshealthissue[k] ;
if k <> diabeteshealthissue_found then // not the last in the list
holdHI := holdHI || ", ";
endif;
endif;
enddo;
endif;
if holdHI = "" then formattedTextHI := " Nothing found. Does the patient have diabetes? ";
else formattedtextHi := holdHI;
endif;
holdHI:="";
if testperformed_found > 0 then
for k in (1 seqto (testperformed_found )) do
if testperformed[k] is not null then
holdHI := holdHI || testperformed[k] ;
if k <> testperformed_found then // not the last in the list
holdHI := holdHI || ", ";
endif;
endif;
enddo;
endif;
if holdHI = "" then formattedTextTest := " Nothing found. Has the patient had a HgA1C performed? ";
else formattedTextTest := testnote;
endif;
// Populate the Health Issue text box
this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Diabetes HI-FT");
this_currentObj := NEW ObservationType;
this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID;
this_currentObj.ParameterGUID := this_parametername.ParameterGUID;
this_currentObj.DataType := "FreeTextValue";
this_currentObj.ValueObj := New FreeTextValueType;
this_currentObj.ValueObj.Value := formattedTextHI;
thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj);
// Populate the A1c performed text box
this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Diabetes Hga1c- FT");
this_currentObj := NEW ObservationType;
this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID;
this_currentObj.ParameterGUID := this_parametername.ParameterGUID;
this_currentObj.DataType := "FreeTextValue";
this_currentObj.ValueObj := New FreeTextValueType;
this_currentObj.ValueObj.Value := formattedTextTest;
thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj);
// The following code is performed only if a button other than the Retrieve from SCM button was selected
//
// Since it appears that the checking of buttons does not occur until the end,
// this section it to be done only when not SCM button
//
elseIf SCMButton = "no" then
// Determine which of the Health Issue buttons is selected
theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Diabetes HI- y/n");
theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID);
if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no")
then healthissue := "Does not have "; endif;
if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes")
then healthissue := "Has a "; endif;
if false in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes")
and
false in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no")
then
healthissue := "Is unknown if "; endif;
// Determine which of the A1C Perfomred buttons is selected
theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Diabetes HgA1C- y/n");
theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID);
if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no")
then labtests := "Is not "; endif;
if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes")
then labtests := "Is "; endif;
if false in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes")
and
false in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no")
then
labtests := "Is unknown if "; endif;
endif; // If not the SCM button
if SCMButton = "yes" or SCMButton = "no" then
// The following code is done regardless of whether the Retrieve from SCM button or other button was selected
// (this excludes the place order yes button)
// Determine if test was performed within the past 3 months
//testnote:= "";
if (testperformed as time)is within the past 3 months then within3months := "Has been ";
testnote := "Patient has been tested in the past 3 months: " || testperformed;
else within3months := "Has not been ";
testnote:= "Patient has not been tested in the past 3 months. ";
endif;
// Assess the risk
/*
// This secton as well as the FormattedText1 := below are for diagnostic purposes only
Factor1 := scmbutton || ": value of scmbutton. ";
Factor2 := diabeteshealthissue || ": diabetes health issue. ";
Factor3 := diabeteshealthissue_found || ": dhi found. ";
Factor4 := labtests || ": labtests. ";
Factor5 := healthissue || ": healthissue. ";
Factor6 := within3months || ": Within3months. ";
Factor7 := testperformed_found || ": tp found. ";
Factor8 := formattedtextHi || ": value of formattedtextHI. " ;
Factor9 := formattedtexttest|| ": value of formattedtexttest. " ;
formattedTextReason := " Risk was not determined. ";
orderlab := "no";
formattedText1 := Factor1 ||"\n " || Factor4 || "\n " || Factor5 || "\n " || Factor6 ;
// Populate (HIS only) Diagnostic box
this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Pneumo FT info");
this_currentObj := NEW ObservationType;
this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID;
this_currentObj.ParameterGUID := this_parametername.ParameterGUID;
this_currentObj.DataType := "FreeTextValue";
this_currentObj.ValueObj := New FreeTextValueType;
this_currentObj.ValueObj.Value := formattedText1;
thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj);
*/
//Scenarios that will cause an order to be placed
If healthissue = "Has a " and (within3months = "Has not been " and labtests = "Is not ") then orderlab := "yes";
formattedTextReason := "Order is to be placed since patient is a diabetic and has not been tested in the past 3 months." ; endif;
If healthissue = "Has a " and (within3months = "Has been " or labtests = "Is ") then orderlab := "no";
formattedTextReason := "Order is not to be placed since patient is a diabetic but has been tested in the past 3 months." ; endif;
If healthissue <> "Has a " then orderlab := "no";
formattedTextReason := "Order is not to be placed since patient is not diabetic." ; endif;
If healthissue = "Is unknown if " then orderlab := "no";
formattedTextReason := " Risk was not determined. " ; endif;
// Populate the Risk Details box /*
this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Diabetes Risk Assess Details");
this_currentObj := NEW ObservationType;
this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID;
this_currentObj.ParameterGUID := this_parametername.ParameterGUID;
this_currentObj.DataType := "FreeTextValue";
this_currentObj.ValueObj := New FreeTextValueType;
this_currentObj.ValueObj.Value := formattedTextReason;
thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj);
// Select Order A1C radio button
this_parametername := first of (thisParameters where thisParameters.Name = "SCHCK_Diabetes HgA1C order");
this_currentObj := NEW ObservationType;
this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID;
this_currentObj.ParameterGUID := this_parametername.ParameterGUID;
this_currentObj.DataType := "ListValue";
this_currentObj.ValueObj := New ListValueType;
this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID;
listItems := ();
FOR item IN this_parametername.ConfigurationObj.ListItemsList DO
selectedItem := NEW ListValueListItemType;
selectedItem.ListItemGUID := item.ListItemGUID;
selectedItem.Value := item.Value;
if selectedItem.Value = "yes" and orderlab = "yes" then selectedItem.IsSelected := true; endif;
if selectedItem.Value = "no" and orderlab = "no" then selectedItem.IsSelected := true; endif;
listItems := (listItems, selectedItem);
ENDDO;
this_currentobj.ValueObj.ListItemsList := listItems;
thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj);
endif; // end of section for assessing risk
// Display error message when Health Issue or A1C performed is unknown
If healthissue = "Is unknown if " and labtests = "Is unknown if " then
dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with
"\n\n There are no Health Issues in SCM indicating that the patient has diabetes or has had an HgA1C in the past 3 months."
|| "\n\n Please address these questions with the patient and select the appropriate button for each of these. \n\n "
,"Un-addressed information to be resolved ","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}};
endif;
If healthissue <> "Is unknown if " and labtests = "Is unknown if " then
dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with
"\n\n There are no indications in SCM that the patient has had an HgA1C in the past 3 months"
|| "\n\n Please address this question with the patient and select the appropriate button. \n\n"
,"Un-addressed information to be resolved ","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}};
endif;
If healthissue = "Is unknown if " and labtests <> "Is unknown if " then
dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with
"\n\n There are no Health Issues in SCM indicating that the patient has diabetes"
|| "\n\n Please address this question with the patient and select the appropriate button. \n\n"
,"Un-addressed information to be resolved ","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}};
endif;
endif; // Observation Event
// Document Closing Event
IF thisdocumentCommunication.EventType = "DocumentClosing" then
// Determine if an order is to be placed
theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Diabetes HgA1C order");
theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID);
if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "no")
then placeorder := "no"; endif;
if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes")
then placeorder := "yes"; endif;
// Order present
(orderpresent) := read
{
" select o.name "
|| " from cv3ordercatalogmasteritem as ocmi with (nolock) "
|| " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid "
|| " and o.ClientGUID = " || ClientGuid || " and o.ChartGUID = " || ChartGuid || " and o.ClientVisitGUID= " || VisitGuid || " "
|| " and (o.name = {{{SINGLE-QUOTE}}}Hemoglobin A1C{{{SINGLE-QUOTE}}}) "
|| " and o.OrderStatusLevelNum > 15 and o.OrderStatusLevelNum not in ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}}) "
};
orderpresent_found := count(orderpresent) As Number;
If placeorder = "yes" and orderpresent_found = 0 then
SessionType := "Standard";
SessionReason := "";
RequestingSource := "";
user_IDType := "Edstan Number (physician)";
order_Creation_Reason := "From Test MLM";
client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((thisdocumentCommunication.ClientVisitGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ;
user_IDCode := read last {"SELECT IDCode FROM CV3User " || " where GUID = " || thisdocumentCommunication.UserGUID};
RequestingCareProvider_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindById with ( user_IDType, (user_IDCode as STRING) );
location_guid := read last {"SELECT CurrentLocationGUID FROM CV3ClientVisit where ClientGUID = " || thisdocumentCommunication.ClientGUID};
location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((location_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}});
// Create a new MEDICATION order from a Pre-Filled item ***
try
Catalog_Item_Name := "Hemoglobin A1C";
Catalog_Item_Modifier := "Per Risk Assessment";
Catalog_Item_Version := "";
Laboratory_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with Catalog_Item_Name;
Parent_DiagnosticOrder_obj := call {{{SINGLE-QUOTE}}}DiagnosticOrder{{{SINGLE-QUOTE}}}.CreateDiagnosticOrder
// PreFilled_MedicationOrder_obj := call {{{SINGLE-QUOTE}}}MedicationOrder{{{SINGLE-QUOTE}}}.CreateMedicationOrder
with
client_visit_obj, // ClientVisit ObjectsPlus object
// Medication_catalog_item, // OrderCatalogMasterItem ObjectsPlus object
Laboratory_catalog_item, // OrderCatalogMasterItem ObjectsPlus object
Catalog_Item_Modifier, // string ItemNameModifier
Catalog_Item_Version, // string ItemNameModifierVersion
order_Creation_Reason, // string CreateReason
RequestingCareProvider_obj , // RequestedBy ObjectsPlus object
RequestingSource, // string RequestedBySource (must be in dictionary)
SessionType, // string SessionType
SessionReason, // string SessionReason
location_obj, // Location ReleaseLocGrpID
"Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; // AvailabilityOverride eAvailabilityOverride
if ( Laboratory_catalog_item is NOT NULL ) then
void := call Parent_DiagnosticOrder_obj.Save;
void := call Parent_DiagnosticOrder_obj.Dispose;
void:= call Laboratory_catalog_item.Dispose;
Laboratory_catalog_item:= null;
endif;
// Parent_DiagnositicOrder_dest.ObjectsPlus := Parent_DiagnositicOrder_obj;
endtry;
catch Exception ex error_occurred := true; error_message := "{{+R}}New Parent Diagnostic order:{{-R}}\n" || ex.Message || "\n\n";
if ( Laboratory_catalog_item is NOT NULL ) then void:= call Laboratory_catalog_item.Dispose; Laboratory_catalog_item:= null; endif;
if ( Parent_DiagnosticOrder_obj is NOT NULL ) then void:= call Parent_DiagnosticOrder_obj.Dispose; Parent_DiagnosticOrder_obj:= null; endif;
Parent_DiagnosticOrder_dest := null;
endcatch;
endif; // End of Place Order = Yes section
endif; // End of Close Document
;;
evoke:
;;
logic: conclude true;
;;
action: return thisDocumentCommunication;
;;
Urgency: 50;;
end: