maintenance: title: Pneumovax Logic for the Progress Note;; mlmname: DOC_FUNC_PNEUMOVAX_EPN;; arden: version 5.0;; version: 2.00;; institution: St.Clair Hospital;; author: Don Warnick;; specialist: ;; date: 2015-12-16;; validation: testing;; library: purpose: ;; explanation: Change history 12.16.2015 DW CSR# 33655 Previnar - Created ;; 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; // DOCUMENT OPENING SECTION IF thisdocumentCommunication.EventType = "DocumentOpening" then (OccCode, userName) := read last {" select OccupationCode, IDCode from CV3USER with (nolock) where guid = " || sql(userGuid) }; // if ( OccCode = "IT" AND userName = "jlaw" ) then // break; // endif; // Search for a pneumococcal recommendation on a patient profile recommendedvaccine := read last { " Select fsl.value " || " from CV3ObsCatalogMasterItem ocmi with (nolock) " || " join CV3ObservationDocument od with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " || " join CV3ClientDocDetailCUR cdd with (nolock) on cdd.CLientDocumentGUID = od.OwnerGUID and cdd.ClientGUID = " || ClientGuid || " " || " join CV3ClientDocumentCUR cd with (nolock) on cd.GUID = cdd.ClientDocumentGUID AND cd.clientguid = cdd.ClientGUID and cd.ChartGUID = " || ChartGuid || " and cd.ClientVisitGUID = " || VisitGuid || " " || " left join SCMObsFSListValues fsl with (nolock) on fsl.ParentGUID = od.ObservationDocumentGUID AND fsl.ClientGUID = " || ClientGuid || " " || " where ocmi.name = {{{SINGLE-QUOTE}}}SCHCK_Pneumo vac recommend{{{SINGLE-QUOTE}}} and cd.DocumentName like {{{SINGLE-QUOTE}}}%profile%{{{SINGLE-QUOTE}}} " || " and cd.iscanceled = 0 and cdd.active = 1 and od.Active = 1 " }; // Search for a pnumococcal vacccine resolution on an EPN. If one ia found the recommendation will not appear recommendationaddressed := read last { " Select o.ValueText " || " from CV3ObsCatalogMasterItem ocmi with (nolock) " || " join CV3ObservationDocument od with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " || " join CV3ClientDocDetailCUR cdd with (nolock) on cdd.CLientDocumentGUID = od.OwnerGUID and cdd.ClientGUID = " || ClientGuid || " " || " join CV3ClientDocumentCUR cd with (nolock) on cd.GUID = cdd.ClientDocumentGUID AND cd.clientguid = cdd.ClientGUID and cd.ChartGUID = " || ChartGuid || " and cd.ClientVisitGUID = " || VisitGuid || " " || " join CV3Observation o with (nolock) on o.GUID = od.ObservationGUID " || " where ocmi.name = {{{SINGLE-QUOTE}}}SCH_MDPN_Pneumo Ordered FT{{{SINGLE-QUOTE}}} and cd.DocumentName like {{{SINGLE-QUOTE}}}%progress%{{{SINGLE-QUOTE}}} and " || " cd.iscanceled = 0 and cdd.active = 1 and od.Active = 1 " }; // Select the "Pneumococcal Expand" radio button - When selected, vaccine ordering observations are displayed If exists recommendedvaccine and recommendedvaccine <> "no" and not exists recommendationaddressed then this_parametername := first of (thisParameters where thisParameters.Name = "SCH_Pneumo_Expand"); 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; // Display the recommended vaccine type (Pneumococcal or Prevnar) for the user this_parametername := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Pneumo Recommend 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 := recommendedvaccine; thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); endif; // Docuement Open Section // CHART OBSERVATION SECTION IF thisdocumentCommunication.EventType = "ChartObservation" then // Determine if the Order or Deferr button was selected response := ""; theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_Pneumo Vaccine Order"); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Order Vaccine") then response := "Approved administration of "; endif; if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Defer Vaccine") then response := "Deferred administration of pneumonia vaccine"; endif; if response = "Approved administration of " then // Determine which Vaccine is recommended theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_Pneumo Recommend FT"); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); vaccinerecommendation:= theObservation.ValueObj; response := response || vaccinerecommendation.Value; endif; // If the recommendation is addressed, store the response in a field to be saved to the note (to document the action and clear the recommendation) if response <> "" then // Populate the resonse field this_parametername := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Pneumo Ordered 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 := response; thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); endif; // Recommendation is addressed ? endif; // End of Observation Event section // DOCUMENT CLOSING SECTION IF thisdocumentCommunication.EventType = "DocumentClosing" then (OccCode, userName) := read last {" select OccupationCode, IDCode from CV3USER with (nolock) where guid = " || sql(userGuid) }; // if ( OccCode = "IT" AND userName = "jlaw" ) then // break; // endif; // Determine if Place Order button is set to "Yes" theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_Pneumo Vaccine Order"); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Order Vaccine") then placeorder := "yes"; endif; if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Defer Vaccine") then placeorder := "no"; endif; // Determine which Vaccine is recommended theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_Pneumo Recommend FT"); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); vaccinerecommendation:= theObservation.ValueObj; // Check for existing Pneumococcal Order on the account (orderpresent) := read { " select o.name " || " from cv3ordercatalogmasteritem as ocmi with (nolock) " || " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid " || " and o.ClientGUID = " || ClientGuid || " and o.ChartGUID = " || ChartGuid || " and o.ClientVisitGUID= " || VisitGuid || " " || " and o.name like {{{SINGLE-QUOTE}}}Pneumococcal%{{{SINGLE-QUOTE}}} and o.name like {{{SINGLE-QUOTE}}}%Vaccine Inj{{{SINGLE-QUOTE}}} " || " and o.OrderStatusLevelNum >= 15 and o.OrderStatusLevelNum not in (69, 70) " }; orderpresent_found := count(orderpresent) As Number; // If no existing order is found and Place Order button is "Yes" then create a new order If placeorder = "yes" and orderpresent_found = 0 then if vaccinerecommendation.value = "Pneumovax 23" then Catalog_Item_Name := "Pneumococcal Vaccine Inj"; Catalog_Item_Modifier := "0.5mL, IM, Once"; endif; if vaccinerecommendation.value = "Prevnar 13" then Catalog_Item_Name := "Pneumococcal 13-Valent Vaccine Inj"; Catalog_Item_Modifier := "-"; endif; SessionType := "Standard"; SessionReason := ""; RequestingSource := ""; user_IDType := "Edstan Number (physician)"; order_Creation_Reason := " "; client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((thisdocumentCommunication.ClientVisitGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; RequestingCareProvider_obj:= call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((thisdocumentCommunication.UserGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); 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_Version := ""; Medication_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with Catalog_Item_Name; PreFilled_MedicationOrder_obj := call {{{SINGLE-QUOTE}}}MedicationOrder{{{SINGLE-QUOTE}}}.CreateMedicationOrder with client_visit_obj, // ClientVisit ObjectsPlus object Medication_catalog_item, // OrderCatalogMasterItem ObjectsPlus object Catalog_Item_Modifier, // string ItemNameModifier Catalog_Item_Version, // string ItemNameModifierVersion order_Creation_Reason, // string CreateReason RequestingCareProvider_obj , // RequestedBy ObjectsPlus object RequestingSource, // string RequestedBySource (must be in dictionary) SessionType, // string SessionType SessionReason, // string SessionReason location_obj, // Location ReleaseLocGrpID "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; // AvailabilityOverride eAvailabilityOverride if ( Medication_catalog_item is NOT NULL ) then void := call PreFilled_MedicationOrder_obj.Save; void := call PreFilled_MedicationOrder_obj.Dispose; void:= call Medication_catalog_item.Dispose; Medication_catalog_item:= null; endif; endtry; catch Exception ex error_occurred := true; error_message := "{{+R}}New prefilled medication order:{{-R}}\n" || ex.Message || "\n\n"; if ( Medication_catalog_item is NOT NULL ) then void:= call Medication_catalog_item.Dispose; Medication_catalog_item:= null; endif; if ( PreFilled_MedicationOrder_obj is NOT NULL ) then void:= call PreFilled_MedicationOrder_obj.Dispose; PreFilled_MedicationOrder_obj:= null; endif; Prefilled_MedicationOrder_dest := null; endcatch; if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; if ( RequestingCareProvider_obj is NOT NULL ) then void:= call RequestingCareProvider_obj.Dispose; RequestingCareProvider_obj:= null; endif; if ( location_obj is NOT NULL ) then void:= call location_obj.Dispose; location_obj:= null; endif; endif; // End of Place Order = Yes section endif; // End of Close Document ;; evoke: ;; logic: conclude true; ;; action: return thisDocumentCommunication; ;; Urgency: 50;; end: