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

220 lines
9.5 KiB
Plaintext

maintenance:
title: DOC_FUNC_FBC_BILIMETER_SCREEN;;
mlmname: DOC_FUNC_FBC_BILIMETER_SCREEN;;
arden: version 5.0;;
version: 2.50;;
institution: St.Clair Hospital;;
author: Juliet M. Law, Allscripts, Inc. x7461 ;;
specialist: Dean Miklavic, Allscripts, Inc. x7466 ;;
date: 2012-11-02;;
validation: testing;;
library:
purpose: This MLM attaches to the Transcutaneous Bilimeter Screening document (SCH_FBC_Bilimeter Screen).
Retrieve gestational age from Newborn Patient Profile; calculate age in hours based on Bilimeter Screening date.
;;
explanation: This MLM will check if the Newborn Patient Profile document exists. If the document does not exist, the user
will receive an alert on document open that the gestational age could not be retrieved. The document will not allow
saving as a completed document.
If the document does exist, the gestational age will be retrieved and populated into the observation.
After the user enters the Bilimeter Screening date time, the age in hours will be calculated and populate
the observation.
Change history
11.02.2012 - JML Created
;;
keywords:
;;
knowledge:
type: data-driven;;
data:
// Receive arguments from the structured note
(this_documentCommunication) := argument;
//.Net Libraries
standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}};
include standard_libs;
// Called MLM declaration section
set_cds_vars := MLM {{{SINGLE-QUOTE}}}Called_RPM_DOM_Get_Definition_MLM{{{SINGLE-QUOTE}}};
read_obs_value := MLM {{{SINGLE-QUOTE}}}CALLED_DOC_FS_OBS_VALUE_MLM{{{SINGLE-QUOTE}}};
using "ObjectsPlusXA.SCM.Forms";
using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms";
/*********************************BEGIN EDIT SECTION*****************************************************/
//Define Document Type Constants
FLOWSHEET := "Flowsheet";
STRUCTUREDNOTE := "StructuredNote";
//Define Event Type Constants
DOCUMENTOPENING := "DocumentOpening";
DOCUMENTCLOSING := "DocumentClosing";
CHARTOBSERVATION := "ChartObservation";
// Setting the cancelProcessing to true will cause the charted observation not to be saved
cancelProcessing := false;
// Setting the debugFlag to true will cause popup dialogs containing debug information to display
debugFlag := false;
//Variable Declaration
displayAlert := false;
/*********************************END EDIT SECTION*****************************************************/
//Set CDS DocumentCommunication object model variables via Called MLM
(this_documentCommunication, client_guid, client_visit_guid, client_chart_guid,
user_guid, document_type, document_name, event_type,
configuration_guid, this_currentObj, CancelEventFlag, this_structuredNoteDoc,
authored_date_time, authored_by_guid, client_document_guid, document_date_time,
isNewFlag, isIncompleteFlag, isResultsPendingFlag, isPriorityFlag,
this_parameters, this_chartedObservationsList, this_parameters_display_name, current_parameter,
current_parameter_name, current_parameter_guid, current_parameter_DataType, selectedItems,
selectedItems_value, current_value, diagnosticMessage, displayMessageFlag,
CoSigner1, CoSigner2, DocumentTopic) := CALL set_cds_vars WITH (this_documentCommunication);
// Set up debugging information to be captured
messageText := "";
if (debugFlag = true) then
messageText := "Debug Information: \n\n";
messageText := messageText || " DOC_FUNC_FBC_BILIMETER_SCREEN mlm is called\n\n";
endif;
// Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate
ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj];
FreeTextValueType := OBJECT [Value];
NumericValueType := OBJECT [Value];
DateValueType := OBJECT [Value];
ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue];
ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected];
//Assign document name and parameter to variable
newbornDocument := "Newborn Patient Profile";
newbornGestAgeParam := "PRO gestational age infant NU";
pediatricDocument := "Pediatric Patient Profile";
pediatricGestAgeParam := "PRO gestational age peds NU";
//Check for existence of Newborn Patient Profile
(newbornDocName, newbornGestAge) := read {"SELECT cd.DocumentName, o.ValueText"
|| " FROM CV3ClientVisit cv JOIN CV3ClientDocumentCUR cd "
|| " on cv.GUID = cd.ClientVisitGUID"
|| " JOIN CV3ClientDocDetailCUR cdd "
|| " on cd.GUID = cdd.ClientDocumentGUID"
|| " JOIN CV3ObservationDocumentCUR od"
|| " on cdd.ClientDocumentGUID = od.OwnerGUID"
|| " JOIN CV3ObsCatalogMasterItem ocmi"
|| " on od.ObsMasterItemGUID = ocmi.GUID"
|| " JOIN CV3ObservationCUR o"
|| " on od.ObservationGUID = o.GUID"
|| " JOIN CV3ObsCatalogItem oci"
|| " on o.ObsItemGUID = oci.GUID"
|| " WHERE ((cd.DocumentName = {{{SINGLE-QUOTE}}}" || newbornDocument || "{{{SINGLE-QUOTE}}}"
|| " AND oci.Name = {{{SINGLE-QUOTE}}}" || newbornGestAgeParam || "{{{SINGLE-QUOTE}}})"
|| " OR "
|| " (cd.DocumentName = {{{SINGLE-QUOTE}}}" || pediatricDocument || "{{{SINGLE-QUOTE}}}"
|| " AND oci.Name = {{{SINGLE-QUOTE}}}" || pediatricGestAgeParam || "{{{SINGLE-QUOTE}}}))"
|| " AND cd.IsCanceled = 0"
|| " AND cdd.Active = 1"
|| " AND od.Active = 1"
|| " AND cv.ClientGUID = " || Sql(client_guid)
|| " AND cv.GUID = " || Sql(client_visit_guid)
|| " AND cv.ChartGUID = " || Sql(client_chart_guid)
|| " ORDER BY cd.AuthoredDtm DESC"};
//On Document Open, retrieve the gestational age from the Newborn Patient Profile; if not available display
//alert to user
if (document_type = STRUCTUREDNOTE AND (event_type = DOCUMENTOPENING OR event_type = DOCUMENTCLOSING)) then
if (not (exists newbornDocName)) then
//Newborn Patient Profile AND Pediatric Patient Profile don{{{SINGLE-QUOTE}}}t exist for this baby; alert user
displayAlert := true;
else
//Document does exist, but gestation age does not; alert user
if (last of (newbornGestAge) IS NULL) then
displayAlert := true;
else
//Document and gestational age exist; populate observation SCH_FBC_Bilimeter_gestational age
bilimeterGestAgeParam := "SCH_FBC_Bilimeter_gestational age";
//set variable to value
bilimeterGestAgeValue := last of (newbornGestAge);
bilimeterGestAge := first of (this_parameters WHERE this_parameters.Name = bilimeterGestAgeParam);
if (exists bilimeterGestAge) then
this_currentObs := NEW ObservationType;
this_currentObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID;
this_currentObs.ParameterGUID := bilimeterGestAge.ParameterGUID;
this_currentObs.DataType := "NumericValue";
this_currentObs.ValueObj := NEW NumericValueType;
this_currentObs.ValueObj.Value := bilimeterGestAgeValue as number;
this_structuredNoteDoc.ChartedObservationsList := (this_structuredNoteDoc.ChartedObservationsList, this_currentObs);
endif;
endif;
endif;
if (displayAlert) then
alertMsg := "Gestational Age has not been documented on the Newborn Patient Profile or the Pediatric Patient Profile."
|| " Please enter this information "
|| "before completing the Transcutaneous Bilimeter Screening.\n\n"
|| "Please NOTE that you will be unable to SAVE this document until a gestational age has been entered "
|| "on the Newborn Patient Profile or the Pediatric Patient Profile. Please cancel this document.";
this_documentCommunication.DisplayMessage := true;
this_documentCommunication.Message := alertMsg;
this_documentCommunication.CancelEvent := true;
endif;
elseif (document_type = STRUCTUREDNOTE AND event_type = CHARTOBSERVATION) then
//If charted observation is the bilimeter screen date time, retrieve value and calculate age in hours
if (current_parameter_name = "SCH_FBC_Bilimeter_Screen Date Time") then
//Retrieve admit date to calculate hours old
admitdttm := read last {"SELECT AdmitDtm "
|| " FROM CV3ClientVisit cv WITH (NOLOCK)"
|| " WHERE cv.GUID = " || SQL(client_visit_Guid)
|| " AND cv.ClientGUID = " || SQL(client_Guid)
|| " AND cv.ChartGUID = " || Sql(client_chart_guid) };
calcHours := (((current_value - admitdttm) / 60 seconds) / 60) formatted with "%.2f";
findDec := FIND "." IN STRING (calcHours as string);
calcHours := SUBSTRING findDec-1 CHARACTERS FROM calcHours;
//Populate observation
HoursAgeParameterName := "SCH_FBC_Bilimeter_Hourly Age";
HoursAgeParameter := first of (this_parameters WHERE this_parameters.Name = HoursAgeParameterName);
if (exists HoursAgeParameter) then
this_currentAgeObs := NEW ObservationType;
this_currentAgeObs.ClientDocumentGUID := this_structuredNoteDoc.ClientDocumentGUID;
this_currentAgeObs.ParameterGUID := HoursAgeParameter.ParameterGUID;
this_currentAgeObs.DataType := "NumericValue";
this_currentAgeObs.ValueObj := NEW NumericValueType;
this_currentAgeObs.ValueObj.Value := calcHours;
this_structuredNoteDoc.ChartedObservationsList := (this_structuredNoteDoc.ChartedObservationsList, this_currentAgeObs);
endif;
endif;
endif;
;;
evoke:
;;
logic: conclude true;
;;
action: return this_documentCommunication;
;;
Urgency: 50;;
end: