Files
St.Clair/MLMStripper/bin/Debug/FORM/FORM_MEDICAL_IMAGING.mlm

607 lines
33 KiB
Plaintext

maintenance:
title: Ordering: Pregnancy field visable only for females between 9 and 55;;
mlmname: FORM_Medical_Imaging;;
arden: version 2;;
version: 4.50;;
institution: St Clair Pregnanacy and Isolation MLM;;
author: Don Warnick, Robert Spence Eclipsys Corp;;
specialist: ;;
date: 2007-07-31;;
validation: testing;;
library:
purpose: Hide the pregnancy field if the patient is not a female of child bearing age
Auto popultate the isolation field
Loosen the restrictions for Medical Imaging orders when the order is entered by a doctor
;;
explanation: This MLM is called from many Medical Imaging forms.
Upon form open the patient gender and age is interrogated and if the patient is a female between 9 and 55, the pregnancy box is visable.
Auto fill the isolation field per the patient{{{SINGLE-QUOTE}}}s current isolation status
If requesting doctor is non-staff physician, the type-in physician field becomes mandatory
If a doctor (orderroletype = %physician%) enters the order, this MLM will cause some fields to be optional.
Change history
05.29.2008 DW Change hidden fields to protected fields (control_visible := false --- control_read_only :=true)
06.03.2008 DW Removed the calling event = form open statement so the mlm logic can be invoked from a grid
07.07.2008 DW Removed the reverse childbearing female logic of 5/29 (pregnancy question was shown incorrectly as mandatory on ultrasound tests)
01.13.2009 DW Added session object code to recall the answer to the pregnancy and lms questions and populate them on other forms during the session
03.17.2009 DW Added code to fire an alert only if a Contrast is needed, the patient is allergic to Iodine and the order is a CT or MRI
06.20.2012 TMS CSR# 22904 - Added coding to retrieve idodine allergy and reaction, diabetic health issues and metformin given or history of metformin in
the past 48 hours to auto populate fields on diagnostic studies with contrast questions.
06.26.2012 TMS CSR# 22904 - Removed query for medication history per requestor.
02.25.2014 DW CSR# 32185 - CPOE Auto-populate pregnancy field on MI order forms
05.05.2014 DW CSR# 32185 - CPOE Auto-populate pregnancy field on MI order forms (disable the cpoe logic related to contrast)
10.29.2014 JML CSR# 32188 - Added call to FORM_ED_CT_ORDERS_TO_STAT to ensure all CT orders made in ED are set to STAT
09.23.2015 DW CSR# 23359 - ICD10
07.19.2018 TMS CSR# 36350 - Added FieldChange and MLM_From Order Set field in addition to FormOpen Logic to execute MLM from CT Order Sets.
;;
keywords: Called MLMs, Form fields, Pregnancy, Isolation
;;
knowledge:
type: data-driven;;
data:
// This MLM is passed three arguments, of types
// communication_type, form_type and client info object respectively.
(this_communication, // Communication object
this_form, // Form object
client_info_obj //Arden ClientInfo object
) := argument;
standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}};
include standard_libs;
using "ObjectsPlusXA.SCM.Forms";
using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms";
//JML - CSR 32188 Change
ed_ct_stat_orders := mlm {{{SINGLE-QUOTE}}}FORM_ED_CT_ORDERS_TO_STAT{{{SINGLE-QUOTE}}};
/*******************Make Changes To Spelling And Flags In This Section*******************/
/* Change the age limits with these variables */
lower_age_limit := 9;
upper_age_limit := 56;
non_staff_requester := "Non Staff, Physician";
/***************************************************************************************/
// Initialize error message
error_message:="";
// Assigns fields passed in the Form object to the Field object
field_list:= this_form.fields;
CallingEvent := this_communication.CallingEvent;
CallingField :=this_communication.CallingFieldName;
ClientVisitGuid := this_communication.ClientVisitGuid;
ClientGuid := this_communication.ClientGuid;
ChartGuid := this_communication.ChartGuid;
requesting_user_guid := this_communication.CareProviderGUID;
orderroletype:= this_communication.primaryobj.enterrole;
user_guid:= this_communication.userguid;
ordername:= this_communication.primaryobj.name;
//--------------------------------------------------------------------------
local_session := cds_session.local;
//--------------------------------------------------------------------------
if ( ordername matches pattern "%CT%" ) then
( this_communication, this_form_client_info_obj ) := call ed_ct_stat_orders with this_communication, this_form, client_info_obj;
endif;
//Mark by RS
// Display the MI_LV_MI Yes No Pregnancy field only if the patient is female
// Also display last menstraul period if patient is female.
Pregnancy_History := last of (field_list where field_list.DataItemName = "MI_LV_MI Yes No Pregnacy" );
LMP_Field := last of (field_list where field_list.DataItemName = "MI_LV_MI LMP" );
Order_md_field := last of (field_list where field_list.DataItemName = "MI_MR_VO_OBR16P2_MI Typein Order MD");
Iso_field :=last of (field_list where field_list.DataItemName = "MI Isolation" );
ctabdpelviscontrast := last of (field_list where field_list.DataItemName = "MI_VO_MI CT Abd Pelvis Contrast" );
ctothercontrast := last of (field_list where field_list.DataItemName = "MI_VO_MI CT Other Contrast" );
DiabeticPatient := last of (field_list where field_list.DataItemName = "MI Yes No" );
bpmeds := last of (field_list where field_list.DataItemName = "MI Yes No2" );
IodineAllergyCB := last of (field_list where field_list.DataItemName = "MI Yes No3" );
orderrole := orderroletype matches pattern "%Physician%";
OnMetformin := last of (field_list where field_list.DataItemName = "MI Metformin Med");
// IodineAllergyCB := last of (field_list where field_list.DataItemName = "MI Yes No3");
// DiabeticPatient := last of (field_list where field_list.DataItemName = "MI Yes No");
IodineReaction := last of (field_list where field_list.DataItemName = "MI Iodine Reaction");
DiabeticPatient_value := DiabeticPatient.value;
ReactionList := ("Unknown", "Anaphylaxis", "Rash", "Hives", "Itch", "Swelling", "Shortness of Breath");
OSMLM := last of (field_list where field_list.DataItemName = "MLM_From Order Set");
iodinealerthistory := last of (field_list where field_list.DataItemName = "MI_Iodine_Allergy_Alert_CPOE" );
useridcode := read last {" Select idcode from cv3user where guid = " || SQL(user_guid)};
fire_on_User := ("rspence","jmwright","tspicuzza", "tspicuzzatest","deiler","lhancher","gfino",
"dmiklavic", "dwarnick","dmiklavichis","chughes","mvennero","wbell","cdeluca",
"gconnolly","otraynor","jlaw");
// 06.03.2008 DW Removed the calling event = form open statement so the mlm logic can be invoked from a grid
// If CallingEvent="FormOpen"
// then
// Lab Priority Code Section.************************************************************************************
DisplayNewScheduled := first of (field_list.Value
where field_list.DataItemName = "LAB_CB_Alternate Priorities");
if (DisplayNewScheduled) then
Call_UserFriendly_Lab_Priorities := mlm {{{SINGLE-QUOTE}}}SCH_LAB_PRIORITY_OPTIONS_CALLED{{{SINGLE-QUOTE}}};
(this_communication,this_form) := call Call_UserFriendly_Lab_Priorities with (this_communication,this_form,client_info_obj);
endif;
/****************************************************************************************************************/
// DW 01.13.2009 code to carry forward the pregnancy and lmp values into other ordersets within a session
If (CallingEvent = "FormOpen" or (CallingEvent = "Fieldchange" and CallingField = "MLM_From Order Set"))
and local_session.has_received_order_worksheet_message <> FALSE then
Pregnancy_History.value := local_session.SessionPregnancyValue;
LMP_Field.value := local_session.SessionLMPValue;
endif;
requesting_user_name := read last { "Select displayname from CV3User where guid = " || SQL(requesting_user_guid) };
if requesting_user_name = non_staff_requester then
Order_md_field.control_visible := true;
Order_md_field.control_mandatory := true;
else
Order_md_field.control_visible := false;
Order_md_field.control_mandatory := false;
endif;
if exist client_info_obj
then
(birthdate, birth_year, patient_gender ):= read last
{ClientInfo: birthdate, BirthYearNum, GenderTypeIntlCode REFERENCING client_info_obj};
endif;
if exist birthdate and birth_year > 0 and birthdate is time
then
patient_age:= (NOW - birthdate) / (1 year);
if (patient_age <= lower_age_limit or patient_age >= upper_age_limit and patient_gender = "F") or (patient_gender = "M")
then
PatientAbleToBePreganant := False;
Pregnancy_History.control_read_only := True;
Pregnancy_History.control_mandatory := False;
LMP_Field.control_read_only := True;
LMP_Field.control_mandatory := False;
else
PatientAbleToBePreganant := True;
endif;
endif;
If CallingEvent= "FormOpen" or (CallingEvent = "Fieldchange" and CallingField = "MLM_From Order Set") then // Added TMS 5.15.2012
// Auto-Fill Pregnancy Section (CSR# 32185)
if PatientAbleToBePreganant = True
then
// Populate the Pregnancy field if the session object hasn{{{SINGLE-QUOTE}}}t already done so (the session object wins)
if Pregnancy_History.value is not null
then
PregData := " A response of {{{SINGLE-QUOTE}}}" || Pregnancy_History.value || "{{{SINGLE-QUOTE}}} was carried forward from another order for this patient.";
else
// Retrieve Pregnancy Test Results
(Result) := read last
{ " select ov.value "
|| " from CV3BasicObservationView ov with (nolock) "
|| " where ov.ResultItemCodingStandard = {{{SINGLE-QUOTE}}}lab{{{SINGLE-QUOTE}}} and ov.ItemName = {{{SINGLE-QUOTE}}}hCG Pregnancy{{{SINGLE-QUOTE}}} "
|| " and ov.clientguid = " || SQL (ClientGuid) || " and ov.chartguid = " || SQL (chartguid) || " and ov.clientvisitguid = " || SQL (clientvisitguid) || " "
|| " order by ov.value "
};
// Retrieve Pregnancy Charting on Patient Profile
(ProileCharting) := read last
{ " select fsl.value "
|| " from CV3ClientDocument cd (nolock) "
|| " join CV3ClientDocDetail cdd (nolock) on (cdd.ClientDocumentGUID = cd.GUID and cdd.ClientGUID = " || SQL (ClientGuid) || " and cdd.active = 1) "
|| " join CV3ObservationDocument od (nolock) ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 "
|| " join CV3ObsCatalogMasterItem ocmi (nolock) on od.ObsMasterItemGUID = ocmi.GUID "
|| " and ocmi.userdictionarycode = {{{SINGLE-QUOTE}}}SCH_PRO fem repro pg yn{{{SINGLE-QUOTE}}} "
|| " left join SCMObsFSListValues fsl(nolock) ON (fsl.ParentGUID = od.ObservationDocumentGUID AND fsl.ClientGUID = " || SQL (ClientGuid) || " ) and fsl.active = 1 "
|| " where cd.clientguid = " || SQL (ClientGuid) || " and cd.chartguid = " || SQL (chartguid) || " "
|| " and cd.documentname like {{{SINGLE-QUOTE}}}%patient profile%{{{SINGLE-QUOTE}}} and cd.iscanceled = 0 "
|| " order by fsl.createdwhen "
};
// Retrieve Pregnancy Charting Point of Care Pregnancy Test charted on the ED VS Flowsheet)
(POCCharting) := read last
{ " select fsl.value "
|| " from CV3ClientDocument cd (nolock) "
|| " join CV3ClientDocDetail cdd (nolock) on (cdd.ClientDocumentGUID = cd.GUID and cdd.ClientGUID = " || SQL (ClientGuid) || " and cdd.active = 1) "
|| " join CV3ObservationDocument od (nolock) ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 "
|| " join CV3ObsCatalogMasterItem ocmi (nolock) on od.ObsMasterItemGUID = ocmi.GUID "
|| " and ocmi.userdictionarycode = {{{SINGLE-QUOTE}}}sch_edvitalsign_bedsideHCG{{{SINGLE-QUOTE}}} "
|| " left join SCMObsFSListValues fsl(nolock) ON (fsl.ParentGUID = od.ObservationDocumentGUID AND fsl.ClientGUID = " || SQL (ClientGuid) || " ) and fsl.active = 1 "
|| " where cd.clientguid = " || SQL (ClientGuid) || " and cd.chartguid = " || SQL (chartguid) || " "
|| " and cd.DocumentName = {{{SINGLE-QUOTE}}}1. Vital Signs - ED{{{SINGLE-QUOTE}}} and cd.iscanceled = 0 "
|| " order by fsl.createdwhen "
};
// If at least one data element indicates not pregnant, file "no" in the "is pregant" question.
// For safety, override this with a "yes", if at least one element indicates pregnant.
// If no data is filed regarding pregnancy, search the past 9 months of visits.
if Result = "Neg" or ProileCharting = "No" or ProileCharting = "Not Applicable" or POCCharting is "Neg" then Pregnant := "No";
NoPregvisit := "Pregnancy Information was found in this visit. \n";
WhoDecicded := " was based on SCM information ";
endif;
if Result = "POS" or ProileCharting = "Yes" or POCCharting = "POSITIVE" then Pregnant := "Yes";
NoPregvisit := "Pregnancy Information was found in this visit. \n";
WhoDecicded:= " was based on SCM information ";
endif;
if Result is null and ProileCharting is null and POCCharting is null
then
Pregnant := "Unknown";
NoPregvisit := "No Pregnancy Information was found in this visit. \n";
// Retrieve 9 months of Pregnancy Test Results (all visits)
(Result_9months, Result_9monthsDate) := read last
{ " select ov.value, convert(char(11), ov.createdwhen,1) "
|| " from CV3BasicObservationView ov with (nolock) "
|| " where ov.ResultItemCodingStandard = {{{SINGLE-QUOTE}}}lab{{{SINGLE-QUOTE}}} and ov.ItemName = {{{SINGLE-QUOTE}}}hCG Pregnancy{{{SINGLE-QUOTE}}} "
|| " and ov.clientguid = " || SQL (ClientGuid) || " and ov.createdWhen > getdate () -270 "
|| " order by ov.createdwhen "
};
// Retrieve 9 months of Pregnancy Charting on Patient Profile
(ProileCharting_9months,ProileCharting_9monthsDate) := read last
{ " select fsl.value, convert(char(11), fsl.createdwhen,1) "
|| " from CV3ClientDocument cd (nolock) "
|| " join CV3ClientDocDetail cdd (nolock) on (cdd.ClientDocumentGUID = cd.GUID and cdd.ClientGUID = " || SQL (ClientGuid) || " and cdd.active = 1) "
|| " join CV3ObservationDocument od (nolock) ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 "
|| " join CV3ObsCatalogMasterItem ocmi (nolock) on od.ObsMasterItemGUID = ocmi.GUID "
|| " and ocmi.userdictionarycode = {{{SINGLE-QUOTE}}}SCH_PRO fem repro pg yn{{{SINGLE-QUOTE}}} "
|| " join SCMObsFSListValues fsl(nolock) ON (fsl.ParentGUID = od.ObservationDocumentGUID AND fsl.ClientGUID = " || SQL (ClientGuid) || " )"
|| " and fsl.active = 1 and fsl.createdWhen > getdate () -270 "
|| " where cd.clientguid = " || SQL (ClientGuid) || " "
|| " and cd.documentname like {{{SINGLE-QUOTE}}}%patient profile%{{{SINGLE-QUOTE}}} and cd.iscanceled = 0 "
|| " order by fsl.createdwhen "
};
// Retrieve 9 months of Pregnancy Charting Point of Care Pregnancy Test charted on the ED VS Flowsheet)
(POCCharting_9months,POCCharting_9monthsDate) := read last
{ " select fsl.value, convert(char(11), fsl.createdwhen,1) "
|| " from CV3ClientDocument cd (nolock) "
|| " join CV3ClientDocDetail cdd (nolock) on (cdd.ClientDocumentGUID = cd.GUID and cdd.ClientGUID = " || SQL (ClientGuid) || " and cdd.active = 1) "
|| " join CV3ObservationDocument od (nolock) ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 "
|| " join CV3ObsCatalogMasterItem ocmi (nolock) on od.ObsMasterItemGUID = ocmi.GUID "
|| " and ocmi.userdictionarycode = {{{SINGLE-QUOTE}}}sch_edvitalsign_bedsideHCG{{{SINGLE-QUOTE}}} "
|| " join SCMObsFSListValues fsl(nolock) ON (fsl.ParentGUID = od.ObservationDocumentGUID AND fsl.ClientGUID = " || SQL (ClientGuid) || " )"
|| " and fsl.active = 1 and fsl.createdWhen > getdate () -270 "
|| " where cd.clientguid = " || SQL (ClientGuid) || " "
|| " and cd.DocumentName = {{{SINGLE-QUOTE}}}1. Vital Signs - ED{{{SINGLE-QUOTE}}} and cd.iscanceled = 0 "
|| " order by fsl.createdwhen "
};
// If something is found in a past visit, display it in a dialog box. The will select current status.
if Result_9months = "POS" or ProileCharting_9months = "YES" or POCCharting_9months = "POSITIVE" then
Evidence := " ";
If Result_9months is not null then
Evidence := Evidence || " \n Positive HCG Pregnancy test results were filed on " || Result_9monthsDate ;
endif;
If ProileCharting_9months is not null then
Evidence := Evidence || " \n\n Pregnancy was documented in the Patient Profile on " || ProileCharting_9monthsDate;
endif;
If POCCharting_9months is not null then
Evidence := Evidence || " \n\n Positive ED Bedside HCG results were filed on " || POCCharting_9monthsDate;
endif;
dlg_result := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with
"\n Information was found in SCM indicating that the patient may have been pregnant in the past 9 months. "||
"\n\n\n Information Found " ||
" \n _________________________________ " ||
"\n" || Evidence ||
" \n\n\n\n Please verify the patient{{{SINGLE-QUOTE}}}s pregnacy status " ||
" \n _________________________________ " ||
"\n\n Select {{{SINGLE-QUOTE}}}Yes{{{SINGLE-QUOTE}}} if she is currently pregnant " ||
"\n\n Select {{{SINGLE-QUOTE}}}No{{{SINGLE-QUOTE}}} if she is not currently pregnant " ||
"\n\n Select {{{SINGLE-QUOTE}}}Cancel{{{SINGLE-QUOTE}}} if her status is unknown " || "\n "
,"Pregnancy Information Found on a Past Visit ", "YesNoCancel" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Question" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}};
If (dlg_result as string) = "Yes" then Pregnant := "Yes"; endif;
If (dlg_result as string) = "No" then Pregnant := "No"; endif;
If (dlg_result as string) = "Cancel" then Pregnant := "Unknown"; endif;
WhoDecicded:= " was decided by the user";
else;
Pregnant := "Unknown";
WhoDecicded:= " was decided because no SCM information was found indicating pregnancy";
endif; // Has something has been found in the past 9 months?
endif; // Has something been found in the current visit?
Pregnancy_History.value := Pregnant;
// Gather the decision data (Used for MLM testing)
PregData := " " || NOW || " \n\n";
if NoPregvisit is not null then PregData := PregData || NoPregvisit; endif;
PregData := PregData
|| " \n hCG Result this visit : {{{SINGLE-QUOTE}}}" || Result || "{{{SINGLE-QUOTE}}}. "
|| " \n Profile charting this visit : {{{SINGLE-QUOTE}}}" || ProileCharting || "{{{SINGLE-QUOTE}}}. "
|| " \n ED hCG POC charting this visit : {{{SINGLE-QUOTE}}}" || POCCharting || "{{{SINGLE-QUOTE}}}. \n"
|| " \n Past hCG Result was found : {{{SINGLE-QUOTE}}}" || Result_9months || "{{{SINGLE-QUOTE}}} on " || Result_9monthsDate || ". "
|| " \n Past Profile charting was found : {{{SINGLE-QUOTE}}}" || ProileCharting_9months || "{{{SINGLE-QUOTE}}} on " || ProileCharting_9monthsDate || ". "
|| " \n Past ED hCG POC charting was found : {{{SINGLE-QUOTE}}}" || POCCharting_9months || "{{{SINGLE-QUOTE}}} on " || POCCharting_9monthsDate || ". ";
PregData := PregData || " \n\n A pregnancy response of {{{SINGLE-QUOTE}}}" || Pregnant || "{{{SINGLE-QUOTE}}}" || WhoDecicded || ".";
endif; // Something was found in the session object
// Display the decision data in a message box (Used for MLM testing)
// dlg_result := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n" || PregData,"The Evidence", "OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Information" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}};
endif; // PatientAbleToBePreganant
// Obtain health issues pertaining to diabetes
/* 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}}}) "
|| "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}}}) "
|| "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;
// Obtain Coded Allergen Guids
(AllergenGuids) := read
{ " select guid from cv3allergen where Code like {{{SINGLE-QUOTE}}}%Iodine%{{{SINGLE-QUOTE}}} or Code like {{{SINGLE-QUOTE}}}%iodide%{{{SINGLE-QUOTE}}} or Code like {{{SINGLE-QUOTE}}}%iodinated%{{{SINGLE-QUOTE}}}"};
// Retrieve coded allergies to Iodine
(IodineAllergy, Reaction) := read last
{ " Select Status, SvrtyLevelDisplay from CV3AllergyDeclaration "
|| " where ((clientguid = " || SQL(clientguid) || ") and "
|| " (AllergenGUID in ( " ||SQL(allergenguids) || ") and Status = {{{SINGLE-QUOTE}}}active{{{SINGLE-QUOTE}}})) "
};
If IodineAllergy is not Null then IodineBox := "True"; else IodineBox := "False"; endif;
If IodineBox = "True"
then IodineAllergyCB.value := "Yes";
else IodineAllergyCB.value := "Unknown";
endif;
If Reaction is not Null then IodineReaction.value := Reaction; endif;
// If Reaction in ReactionList then IodineReaction.value := Reaction; endif;
// Retrieve Metformin Orders (as identified by class type) charted as given.
(Medgiven, Medname) := read last
{ " select oto.performedfromdtm, o.name "
|| " from cv3ordercatalogmasteritem as ocmi with (nolock) "
|| " join CV3CatalogClassTypevalue ctv on ctv.CatalogMasterGUID = ocmi.GUID "
|| " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid "
|| " join CV3ClassType ct on ct.GUID = ctv.ClassTypeGUID "
|| " 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 "
|| " where o.ClientGUID = " || SQL (ClientGuid)
|| " and oto.taskstatuscode ={{{SINGLE-QUOTE}}}Performed{{{SINGLE-QUOTE}}} "
|| " and ct.Code = {{{SINGLE-QUOTE}}}PRX_MetforminMed{{{SINGLE-QUOTE}}} "
|| " order by oto.PerformedFromDtm "
};
// If last given task within 48 hours then value emar flag to yes
if (Medgiven as time) is within the past 48 hours then GetEmar := "Yes"; else GetEmar := "No"; endif;
/* Retrieve admit date and time. If patient admitted less than 48 hours check medication history for metformin meds
(AdmitDate) := read last
{ " select admitdtm from CV3ClientVisit "
|| " where guid = " || SQL(clientvisitguid)
|| " and clientguid = " || SQL(clientguid)
};
If (AdmitDate as time) is within the past 48 hours then GetHx := "Yes"; else GetHx := "No"; endif;
If GetHx = "Yes" then
(MetforminHx) := read last
{ " select cp.drugname from SXAAMBClientPrescription cp "
|| " join CV3Client c on c.guid = " || SQL(clientguid)
|| " where cp.genericnameid in (2598, 2888, 2251, 2705, 2474, 1481, 2152, 2254)"
|| " and cp.statustype = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} "
|| " and cp.clientguid = " || SQL(clientguid)
};
endif;
*/
// Value Metformin drug name and diabetic meds flag. If both history and current metformin found use current.
If GetEmar = "No" then
DiabeticMeds := "False";
endif;
If GetEmar = "Yes" then
DiabeticMeds := "True";
OnMetformin.value := Medname;
endif;
// Set value of diabetic patient question if patient has health issue or diabetic meds are found.
If (DiabeticMeds = "True" or diabeteshealthissue_found >0)
then DiabeticPatient.value := "Yes";
else DiabeticPatient.value := "Unknown";
endif;
Endif; // If CallingEvent="FormOpen
// End Added TMS 5.15.2012
//Mark by RS
IsolationCol := read last
{ " Select top 1 Columnname"
|| " from cv3EnterpriseColumnData "
|| " where dataitemcode = " || SQL({{{SINGLE-QUOTE}}}Isolation{{{SINGLE-QUOTE}}})};
If exists(IsolationCol)
then
// now get the visit{{{SINGLE-QUOTE}}}s isolation status
Isolation := read last
{ " Select " || IsolationCol
|| " from CV3EnterpriseVisitData "
|| " where visitguid = " || SQL(ClientVisitGuid)};
If (Isolation Is Null)
then
Iso_field.Value :="";
else
Iso_field.Value := Isolation;
endif;
endif;
// endif;
// DW CSR# 32185 05.05.2014 disable this logic also....post activation change
/*
if orderrole = true
then
if (ctabdpelviscontrast.value in ("NO IV Contrast","PO Contrast Only")) or
(ctothercontrast.value in ("NO IV Contrast","PO Contrast Only"))
then DiabeticPatient.control_mandatory:= false;
DiabeticPatient.control_read_only:= true;
bpmeds.control_mandatory:= false;
bpmeds.control_read_only:= true;
IodineAllergyCB.control_mandatory:= false;
IodineAllergyCB.control_read_only:= true;
else DiabeticPatient.control_mandatory:= true;
DiabeticPatient.control_read_only:= false;
bpmeds.control_mandatory:= true;
bpmeds.control_read_only:= false;
IodineAllergyCB.control_mandatory:= true;
IodineAllergyCB.control_read_only:= false;
endif;
endif;
*/
// DW 01.13.2009 code to carry forward the pregnancy and lmp values into other ordersets within a session
If CallingEvent="FormClose"
then
local_session.SessionPregnancyValue := Pregnancy_History.value;
local_session.SessionLMPValue := LMP_Field.value;
if local_session.has_received_order_worksheet_message = FALSE then
local_session.has_received_order_worksheet_message := TRUE; else; endif;
endif;
// section for displaying a warning box when patient is allergic to iodine - radiopaque and contrast is selected
If CallingField in ("MI_VO_MI CT Other Contrast" , "MI_VO_MI CT Abd Pelvis Contrast" ) and useridcode in fire_on_user then
(allergen,severity,confidence) := read last
{ " Select a.code, ad.svrtyleveldisplay, ad.conflevelcode "
|| " from cv3allergydeclaration ad with (nolock) "
|| " join cv3allergen a with (nolock) on a.guid = ad.allergenguid "
|| " where a.code like {{{SINGLE-QUOTE}}}iodine - radiopaque{{{SINGLE-QUOTE}}} and ad.status = {{{SINGLE-QUOTE}}}active{{{SINGLE-QUOTE}}} and ad.clientguid = " || SQL(ClientGuid)};
if exist confidence then p_confidence:= confidence; else p_confidence:= ""; endif;
if exist severity then p_severity:= severity; else p_severity:= ""; endif;
if exists allergen and (ctothercontrast.value = "IV Contrast" or ctabdpelviscontrast.value in ("IV/PO Contrast" , "No IV Contrast / PO Contrast Only" , "No PO Contrast / IV Contrast Only"))
then
this_communication.Message := "\n\n ALLERGY ALERT "
|| "\n\n\nPatient is alergic to " || allergen || " which is contained in the " || ordername || " order."
|| "\n\n\nOrder/Additive Name : " || ordername
|| "\n\nReaction : " || p_severity
|| "\n\nConfidence Level : " || p_confidence || "\n\n "
; this_communication.MessageType := "Informational";
iodinealerthistory.value := "An allergy to " || allergen || " with a " || p_severity || " reaction was detected and reported at the time of order entry (confidence level : " || p_confidence || " )" ;
else
iodinealerthistory.value := " ";
endif; // if contrast solution is requested
endif; // if form close
;;
evoke: // No evoke statement
;;
logic:
conclude true;
;;
action:
// This MLM returns two parameters, of types communication_type and form_type respectively.
return this_communication, this_form;
;;
end: