maintenance: title: Health Management Mark as Done;; mlmname: SCH_HM_MARK_AS_DONE;; arden: version 2.5;; version: 5.50;; //FP1 institution: AllScripts;; author: Allscripts Healthcare Solutions, Inc;; specialist: Shawn Head x7468;; date: 2014-06-20;; validation: testing;; library: purpose: Updates immunization and wellness events in the Health Management system when matching data is updated on the Patient{{{SINGLE-QUOTE}}}s record. ;; explanation: NOTE: This MLM has a dependent MLM that must be loaded for this functionality to work. STD_FUNC_HM_MARKASDONE.MLM This MLM is triggered when: (1) an order is completed (2) a task occurrence is marked as done (3) a flowsheet or structured note document is entered or modified (4) a final result item is received Ancillary Mapping ------------------------- When triggered, this MLM will look up the Evoking Object{{{SINGLE-QUOTE}}}s Ancillary Name using a specified site defined coding standard. This name matches an event name in the Health Management Event Catalog. If the client is on a schedule that contains this event a new client event occurrence will be created and marked as done using information extracted from the evoking object and any mapped user defined data item (UDDI) fields. The coding standard this MLM uses is "HM Event" but it can be changed to suit any needs. When looking up the event, the flags recordOnlyIfPatientAssignedEvent and recordOnlyIfEventActive are used to determine what actions are to be taken when the event is found. See the descriptions of the flags below for details. Exclude Patient Types ----------------------------- The MLM can be configured to exclude any patient types (i.e., Inpatient) from executing this MLM. The list patientVisitTypeList should contain a list of codes from the visit type dictionary that correspond to types that are to be excluded. This feature is then turned on by setting the flag limitPatientVisitTypes to be true. By default the flag is false so all visit types are allowed. Alert Output ------------------ When the MLM is executed it can be configured to attach an alert to the patient record on different conditions. The minimal setting is to never create an alert regardless of the final outcome; the Health Management event might still be marked as done but there will be no alert linked to that event. The next level is to only alert if at least one of the Mark as Done attempts generates an error condition. Note, if the evoking object is mapped to several events and only one generates an error, the alert will contain the successful messages as well. The third level is to alert on success and any failures. The final level will alert on all attempts as long as the evoking object has a mapped ancillary code. For example, this will generate alerts for order items that are mapped to an event but the patient doesn{{{SINGLE-QUOTE}}}t have a schedule with those events. Creating a Health Management Immunization/Wellness Event ----------------------------------------------------------------- In the Health Management system, Immunization and Wellness events have several properties that can be set based on the data extracted from the evoking trigger event. This MLM attempts to demonstrate how to extract a subset of this data from different sources. There are 5 arden objects defined in this MLM that can be filled in and then passed to the STD_FUNC_HM_MARKASDONE mlm; depending on the event type some of these objects are mandatory. EventOccurrenceDef This object defines the core details of an Immunization and Wellness event and is required. The fields, eventName, actionDate and actionProviderId are manditory. eventName The name of the event as defined in HM Catalogs/Event and mapped via the ancillary code. actionDate The date the event occurs. actionProviderId The ID of the person performing the event. This value depends on the evoking object. Order = CareProviderGUID OrderTaskOccurrence = PerformedProviderGUID ClientDocument = AuthoredProviderGUID BasicObservation = actionProviderGUID actionProviderDisplayName The display name of the above user. If not set the STD_FUNC_MARKASDONE mlm will retrieve it from the database based on the value of the ID. Comment The comment for the event occurrence. SiteGivenCode A code indicating where the event was given to the client. Only required for events where this is used. RouteCode The route the event was administered. Only required for events where this is used. IsPartialDose If true then the event occurrence was only partially completed. ConsentDocumentDef This object defines the consent document for both an immunization and wellness event. It is not required if there is no consent information. TypeCode The consent type. Not mandatory but mapped to the HM Dictionary "Consent Type". ConsentDate The date consent was given. ConsentTime The time consent was given. NOTE: Not supported at this time ConsentBy The name of the person giving consent. RelationshipCode The relationship of the person giving consent to the client. DocumentType The document type. 0 = consent, 1 = Exemption EducationalMaterialsDef This object defines the educational material for both an immunization and wellness event. It is not required, however if used then the TypeCode must be included. TypeCode The educational material type code, must contain a value from the HM Dictionary "Educational Material Type". IsVis Set to 1 if the document is a Vaccine Information Sheet. PublishedDate The date the document was published. PresentedDate The date the document was presented to the client. ImmunizationDef This object defines information only for an Immunization event. It must be include when the mapped event is an immunization (ie MMR). VaccineName CVXCode The name of the vaccine or CVX code. Only set one of these values, not both. VaccineProductCode The vaccine product code VaccineManufacturerMVXCode VaccineManufacturer Information about the vaccine{{{SINGLE-QUOTE}}}s manufacturer. If MVX code is used then it must contain a value from the HM Dictionary "Vaccine Manufacturer". If the MVX code is not known then a name can be entered into VaccineManufacturer. Only one of these two fields should be set. VaccineBrandName The brand name of the vaccine. VaccineEligibilityCode The vaccine eligibility code, if set then the value must come from the HM Dictionary "Vaccine Eligibility code". VaccineMedicationLotDef This object defines information only for an Immunization event. Must be used when dose and lot information is part of the vaccine. LotNumber The lot number of the vaccine LotSourceCode The source code for the vaccine. Must be mapped to values from the HM Dictionary "Vaccine Lot Source". LotExpirationDate The date the lot expires. LotDoseAmount The amount of vaccine given to the patient. LotDoseUom The unit of measure for the current dose. RemovedFromStorageDate The date the vaccine was removed from storage. LotWasteAmount LotWasteUom If any vaccine was wasted. Order Complete ------------------- This MLM will trigger on the event OrderComplete and will attempt to find and mark as done a mapped wellness event. The MLM extracts event data from the evoking object including the actionDate from either the SignificantDtm or StopDtm and the actionProviderId from the CareProviderGUID. It will then try and create an educational Material object from several UDDI field that were mapped when the order was first created. It then finds the ancillary code for the HM Event and when found calls the function MLM STD_FUNC_HM_MARKASDONE passing in all the information it was able to gather. Task Occurrence, Mark as Done ------------------------------------- The MLM will trigger on OrderTaskOccurrence Modify when the TaskStatusCode is changed from "Pending" to "Performed". It will attempt to find and mark as done a mapped immunization event. It extracts event data from the evoking object including the actionDate from the PerformedFromDtm or PeformedToDtm and the actionProviderId from the PeformedProviderGUID. Other event occurrence fields are extracted from the evoking object. To obtain vaccine information, UDDI fields extracted from the userDataList object are checked. These include the vaccine name or CVX code, lot number and expire date. Not all fields are mapped only a few to give an idea how it can be done. It then finds the ancillary code for the HM Event and when found calls the function MLM STD_FUNC_HM_MARKASDONE passing in all the information is was able to gather. Client Document, Enter or Modify ---------------------------------------- This MLM will trigger on ClientDocumentEnter or ClientDocumentModify and will attempt to find and mark as done a mapped Wellness event. This portion of the MLM runs in two stages. The first checks to see if the document itself has an ancillary mapping and extracts data from the evoking object for the actionDate and actionProviderId. The second stage does the same thing again but this time for any observation that is linked as would be the case for a flowsheet or structured note. Again information for the actionDate and providerId is extracted from these objects and if the event is found to be mapped via an ancillary code the Mark as done MLM is called. Basic Observation(Result) Enter -------------------------------------------- This MLM will trigger when a result item is received via the front end or interfaces. It will attempt to find and mark as done a mapped wellness event. The MLM extracts event data from the evoking object including the actionDate from either Entered date and the actionProviderId from either the parent orders{{{SINGLE-QUOTE}}}s careProviderGUID, UserGUID or if all else fails the current logged on user. It then finds the ancillary code for the HM Event and when found calls the function MLM STD_FUNC_HM_MARKASDONE passing in all the information it was able to gather. 053113 - ALlscripts - updated to work with CH task form configuration 062613 - Allscripts _added sql to get MVX code 071213 - Allscripts - moved from Test into PROD 062014 - Shawn Head - Modified and updated for use at St. Clair hospital for MU2. 07.21.2015 - Shawn Head - 15.1 upgrade required update to pass additional arguement to the standard MLM STD_FUNC_HM_MARK_AS_DONE 12.16.2015 - CSR #:33655 - Update for Prevnar 13 {Loaded 1.13.2016 ahead of the target go-live date of the product being available} 11.09.2016 - BBerkeybile Ticket#2429879 - Update manufacturer user data code to include new Vaccine Manucafturer Flu. ;; keywords: ;; knowledge: type: data-driven;; data: mlmStatus := 0; finalOutputMessage := ""; finalMlmStatus := 0; updateDatabase := true; MarkAsDone_MLM := MLM {{{SINGLE-QUOTE}}}STD_FUNC_HM_MARKASDONE{{{SINGLE-QUOTE}}}; eventOccurrenceFound := false; // ----------------------------------------------------------------- // Site defined fields // ----------------------------------------------------------------- log_execution_info := false; // The coding standard used by the item catalog to map an item to a // Health Management Event. [STH 6-20-2014] Added HM CVXCode to also be pulled from the // task coding standard. CodingStandard := "HM Event"; CodingCVXCode := "HM CVXCode"; // Display an alert depending on the status returned by the function MLM // 1 = Alert on all messages including not found on schedule, successful mark as done // and failure // 2 = Alert if either a failure or successful mark as done occurs // 3 = Alert if a failure occurs // 4 = Never show an alert AllowAlertOnStatusLevel := 3; // show alljust for testing - change back later // If set to true then when an alert is displayed it will contain a listing // of the objects passed to the Mark as Done function MLM. Should only be // set to true during the testing of the MLM. writeObjectDetails := false; //false; // If set to true then the MLM will be limited to only run for the visit types // NOT specified in patientVisitTypeList limitPatientVisitTypes := false; // The list of all possible visit types that will cause the MLM NOT to run. // The values are found in the Client Info/Visit Type dictionary. patientVisitTypeList := ( "Inpatient" ); // The following 2 flags determine when a record will get record to // the database based on the status of the client event and if it // must already be assigned first. // If set to true then the client event must be active. // Note: This flag can be reset based on business rules later in the MLM. recordOnlyIfEventActive := true; // If set to true then the mapped Event must be assigned to the patient; // Active or Inactive depending on the flag recordOnlyIfEventActive. // If false then the event will be added to the client regardless. The state of the // flag recordOnlyIfEventActive will not be considered. // Note: This flag can be reset based on business rules later in the MLM. recordOnlyIfPatientAssignedEvent := false; //true; // -------------------------------------------------------------------------- // The 5 object types that can be used to define a single wellness // or immunization event. // ** Do not make any changes to the object definitions. ** // -------------------------------------------------------------------------- EventOccurrenceDef := object [ eventName, actionDate, actionProviderId, actionProviderDisplayName, Comment, SiteGivenCode, RouteCode, IsPartialDose ]; ImmunizationDef := object [ VaccineName, CVXCode, VaccineProductCode, VaccineManufacturerMVXCode, VaccineManufacturer, VaccineBrandName, VaccineEligibilityCode ]; VaccineMedicationLotDef := object [ LotNumber, LotSourceCode, LotExpirationDate, LotDoseAmount, LotDoseUom, RemovedFromStorageDate, LotWasteAmount, LotWasteUom ]; ConsentDocumentDef := object [ TypeCode, ConsentDate, ConsentTime, ConsentBy, RelationshipCode, DocumentType // Consent=0, Exemption=1 ]; EducationalMaterialsDef := object [ TypeCode, IsVis, PublishedDate, PresentedDate ]; // Initialize to Null EventOccurrenceObj := null; ImmunizationObj := null; ConsentDocumentObj := null; EducationalMaterialsObj := null; VaccineMedicationLotObj := null; if called_by_editor then // Only set to true when testing the logic of the MLMs // from the editor. All logic is performed except the final // mark as done code is skipped. updateDatabase := false; // Choices are "order", "orderTaskOccurrence", "observation", and "clientDocument" // Specify which object you want to retrieve by customizing the WHERE clause of each // READ statement. objectChoice := "OrderTaskOccurrence"; if objectChoice = "Order" then EvokingObject := read last { order: this WHERE Name = "Blood Pressure" AND OrderStatusCode="COMP" }; elseif objectChoice = "OrderTaskOccurrence" then EvokingObject := read last { OrderTaskOccurrence: this WHERE TaskName MATCHES PATTERN "%influenza%" and TaskStatusCode="Performed" }; elseif objectChoice = "Observation" then EvokingObject := read last { Observation: this WHERE ItemName="BUN" AND Status="F" }; elseif objectChoice = "ClientDocument" then EvokingObject := read last { ClientDocument: this WHERE DocumentName="HM Notes Document" }; endif; endif; // ----------------------------------------------------------------- // Trigger Event Statements // ----------------------------------------------------------------- // Order Complete Trigger // To improve performance add a WHERE clause to filter on specific order name(s). // ie: // WHERE Name IN ("Blood Pressure Check", "Bone Density Test") /* //NOT USING CURRENTLY order_complete_event := EVENT { OrderComplete Any Order: where Backup.OrderStatusLevelNum < 100 }; */ // Order Task Occurrence Modify (Mark task as Done) // Do not change the check of the TaskStatusCodes. // To improve performance add to the where clause to filter on specific TaskNames // ie: // AND TaskName in ("Measles Immunization", "Mumps Immunization") taskOcc_modify_event := EVENT { OrderTaskOccurrenceModify Any OrderTaskOccurrence: WHERE (THIS.TaskStatusCode="Performed" AND Backup.TaskStatusCode <> "Performed") AND ( TaskName MATCHES PATTERN "Pneumococcal Vaccine Inj%" OR TaskName MATCHES PATTERN "Influenza Virus Vaccine%" OR TaskName MATCHES PATTERN "Influenza Virus Trivalent Vaccine%" OR TaskName MATCHES PATTERN "Pneumococcal 13-Valent Vaccine Inj%") }; // AND Backup.TaskStatusCode <> "Performed" // Result enter trigger // To improve performance add conditions to the WHERE clause to filter on // specific result item name(s) // ie: // AND ItemName in ("RBC", "HEMO") /* //NOT USING CURRENTLY observation_enter_event := EVENT { ObservationEnter ANY Observation: WHERE PerformedDtm is not null AND Status = "F" }; */ // Client Document enter and modify triggers // To improve performance add a where clause to filter on // specific document name(s). // ie: // AND DocumentName in ("Adult Wellness", "Child Wellness") /* //NOT USING CURRENTLY client_document_enter_event := EVENT { ClientDocumentEnter USER ClientDocument }; client_document_modify_event := EVENT { ClientDocumentModify USER ClientDocument }; */ // ----------------------------------------------------------------- // Alert destination // Make any necessary changes to the properties as needed for // your setup. // ----------------------------------------------------------------- alert_destination := destination { Alert } with [ display_alert := true, alert_type := "reminder", short_message := "Event Occurrence marked as done", priority := "low", Scope := "chart", Rule_number := 1001, Rule_group := "Mark as done" ]; clientVisitObj := read last { ClientVisit: this }; // -------------------------------------------------------------------------------- // First check to see if the current patient{{{SINGLE-QUOTE}}}s visit is of a type that is to // be excluded from this MLM. if limitPatientVisitTypes AND clientVisitObj.TypeCode in (patientVisitTypeList) then // Do nothing finalMlmStatus := 0; finalOutputMessage := "Patient type is excluded"; // ----------------------------------------------------------------- // Evoking Object is an order, linked to OrderComplete trigger event /* NOT CURRENTLY USING THE ORDER SECTION FOR CHARTING elseif ( EvokingObject is order ) then eventOccurrenceObj := new eventOccurrenceDef; clientGUID := EvokingObject.ClientGUID; catalogItemGUID := EvokingObject.OrderCatalogMasterItemGUID; linkedItemId := EvokingObject.GUID; // The Order{{{SINGLE-QUOTE}}}s GUID if evokingObject.StopDtm = "" OR EvokingObject.StopDtm is null then eventOccurrenceObj.actionDate := EvokingObject.SignificantDtm; else eventOccurrenceObj.actionDate := EvokingObject.StopDtm; endif; eventOccurrenceObj.actionProviderId := EvokingObject.CareProviderGUID; eventOccurrenceObj.Comment := "Order " || EvokingObject.Name || " marked as completed."; // The M.A.D. functionality requires the location group GUID from the // evoking object. This is attached to the client visit object. visitGuid := EvokingObject.ClientVisitGUID; locationGroupGuid := read last { "select CurrentLocationGUID from CV3ClientVisit " || " where GUID=" || SQL(visitGuid) }; // ------------------------------------------------------------------------ // Get the data necessary for the educational Materials object from // UDDI fields on the OrderUserData object orderUserDataObj := read first{ Order: OrderUserData referencing EvokingObject }; userDataList := read { OrderUserData: this referencing orderUserDataObj }; // Type field is required; is not on the form or empty do not create an educational // material object. userDataObj := first of ( userDataList where userDataList.UserDataCode = "HM Ed Material Type"); if ( userDataObj is not null AND userDataObj.Value <> "" ) then educationalMaterialsObj := new EducationalMaterialsDef; educationalMaterialsObj.TypeCode := userDataObj.Value; userDataObj := first of ( userDataList where userDataList.UserDataCode = "HM Ed Material IsVIS"); educationalMaterialsObj.IsVIS := userDataObj.Value; userDataObj := first of ( userDataList where userDataList.UserDataCode = "HM Ed Material Published"); educationalMaterialsObj.PublishedDate := userDataObj.Value; userDataObj := first of ( userDataList where userDataList.UserDataCode = "HM Ed Material Presented"); educationalMaterialsObj.PresentedDate := userDataObj.Value; endif; // Retrieve the EventNames from the Ancillary code using the catalog item GUID from // the evoking object. eventNameList := read {"Select an.Name from CV3AncillaryName an " || "Where an.MainCatItemGUID = " || SQL(catalogItemGUID) || " AND an.Active = 1 AND an.CodingStd = " || SQL(CodingStandard) }; for eventName in eventNameList do // Each Event that is marked as done will have the same occurrence // and educational Materials. eventOccurrenceObj.eventName := eventName; (mlmStatus, outputMessage) := call MarkAsDone_MLM with clientGUID, locationGroupGuid, linkedItemId, 0, // Only order is supported updateDatabase, recordOnlyIfPatientAssignedEvent, recordOnlyIfEventActive, eventOccurrenceObj, null, null, null, educationalMaterialsObj; if mlmStatus > finalMlmStatus then finalMlmStatus := mlmStatus; endif; finalOutputMessage := finalOutputMessage || outputMessage || "\n"; enddo; eventOccurrenceObj.eventName := eventName; */ // --------------------------------------------------------------------------- // Evoking object is an Order Task Occurrence. Linked to task modify (mark as done) elseif ( EvokingObject is OrderTaskOccurrence ) then // Create an object for each component that is needed by Mark As Done eventOccurrenceObj := new eventOccurrenceDef; immunizationObj := new ImmunizationDef; vaccineMedicationLotObj := new VaccineMedicationLotDef; // The M.A.D. functionality requires the location group GUID from the // evoking object. This is attached to the client visit object. visitGuid := clientVisitObj.GUID; locationGroupGuid := read last { "select CurrentLocationGUID from CV3ClientVisit with (nolock)" || " where GUID=" || SQL(visitGuid) }; clientGUID := clientVisitObj.clientGUID; chartGUID := clientVisitObj.ChartGUID; linkedItemId := EvokingObject.Order.GUID; // The parent Order{{{SINGLE-QUOTE}}}s GUID // Map properties from the EvokingObject and/or TaskUserData to the Event Occurrence // data objects if (EvokingObject.PerformedToDtm = "" OR EvokingObject.PerformedToDtm is null) then eventOccurrenceObj.actionDate := EvokingObject.PerformedFromDtm; else eventOccurrenceObj.actionDate := EvokingObject.PerformedToDtm; endif; eventOccurrenceObj.actionProviderId := EvokingObject.PerformedProviderGUID; eventOccurrenceObj.Comment := EvokingObject.TaskComment; eventOccurrenceObj.SiteGivenCode := EvokingObject.BodySite; eventOccurrenceObj.RouteCode := EvokingObject.TaskRouteCode; // Get the action provider from the order, first check care Provider, then userGUID then // finally current logged on user. (UserID) := read last { "Select u.IDCode FROM CV3User u with (nolock) " || "where u.GUID=" || eventOccurrenceObj.actionProviderId }; // The following fields are user defined and are found on the TaskUserData object taskUserDataObj := read first{ OrderTaskOccurrence: TaskUserData referencing EvokingObject }; userDataList := read { TaskUserData: this referencing taskUserDataObj }; // Vaccine name or CVX Code userDataObj := first of ( userDataList where userDataList.UserDataCode = "VaccineName"); if ( userDataObj.Value is not null ) then immunizationObj.VaccineName := userDataObj.Value; else userDataObj := first of ( userDataList where userDataList.UserDataCode = "VaccineCVXCode"); immunizationObj.CVXCode := userDataObj.Value; endif; /// manufacturer // task_lot_manufact:= first of ( userDataList where userDataList.UserDataCode = "Vaccine Manufacturer"); //BB Removed 11/9/16 task_lot_manufact:= first of ( userDataList where userDataList.UserDataCode in ("Vaccine Manufacturer","Vaccine Manufacturer Flu")); //BB Added 11/9/16 //get the MVXCode from the configured UDDD. The configuration should have the name displayed to the users //followed by (MVXCOde) in "(" & ")" findmvxstart := find "(" in string task_lot_manufact.value; if findmvxstart > 0 then task_lot_mfg_mvxcode := substring 3 characters starting at (findmvxstart + 1) from task_lot_manufact.value; a := length(task_lot_mfg_mvxcode); if task_lot_mfg_mvxcode is not null and ((length(task_lot_mfg_mvxcode)) = 3) then immunizationObj.VaccineManufacturerMVXCode := task_lot_mfg_mvxcode; DB_Manufacturer_Name := read last {"SELECT name FROM SXAHMVaccineManufacturer with (nolock) WHERE Active = 1 AND mvxcode = " || SQL(immunizationObj.VaccineManufacturerMVXCode)}; immunizationObj.VaccineManufacturer := DB_Manufacturer_Name as string; else DB_Manufacturer_Name := trim(substring (findmvxstart - 1) characters from task_lot_manufact.value); immunizationObj.VaccineManufacturer := DB_Manufacturer_Name as string; endif; else immunizationObj.VaccineManufacturer := task_lot_manufact.value as string; endif; if immunizationObj.VaccineManufacturerMVXCode is null then immunizationObj.VaccineManufacturerMVXCode := read last {"SELECT MVXCode FROM SXAHMVaccineManufacturer with (nolock) WHERE Active = 1 AND Name = " || SQL(immunizationObj.VaccineManufacturer)}; endif; if immunizationObj.VaccineManufacturer is null then immunizationObj.VaccineManufacturer := task_lot_manufact.value as string; endif; // Lot details vaccineMedicationLotObj.LotDoseAmount := EvokingObject.TaskDose; // "TaskDose" vaccineMedicationLotObj.LotDoseUOM := EvokingObject.TaskUOM; // "TaskUom" //lot number userDataObj := first of ( userDataList where userDataList.UserDataCode = "Vaccine Lot Number"); vaccineMedicationLotObj.LotNumber := userDataObj.Value; //expiration date PER Debbie Eiler request she DOES NOT want to pass expiration date //userDataObj := first of ( userDataList where userDataList.UserDataCode = "Vaccine Exp Date"); // vaccineMedicationLotObj.LotExpirationDate := userDataObj.Value AS TIME; //manufacture //userDataObj := first of ( userDataList where userDataList.UserDataCode = "Vaccine Manufacturer"); //immunizationObj.VaccineManufacturer := userDataObj.Value; //HARD CODING ACTIVE FOR NOW /// Immunization Registry Status //userDataObj := first of ( userDataList where userDataList.UserDataCode = "Immunization Registry Status"); //ImmRegStatus := userDataObj.Value; //userDataObj.Value := "Active"; // ------------------------------------------------------------------------ // Retrieve the mapped Event Name based on the Ancillary Coding standard // ------------------------------------------------------------------------ catalogItemGUID := EvokingObject.CatalogItemTaskGUID; //read last { OrderTaskOccurrence: CatalogItemTaskGUID referencing EvokingObject }; // Retrieve the EventName from the Ancillary code eventNameList := read {"Select an.Name from CV3AncillaryName an with (nolock) " || "Where an.MainCatItemGUID = " || SQL(catalogItemGUID) || " AND an.Active = 1 AND an.CodingStd = " || SQL(CodingStandard) }; ImmunizationCVXCode := read last {"Select an.Name from CV3AncillaryName an with (nolock) " || "Where an.MainCatItemGUID = " || SQL(catalogItemGUID) || " AND an.Active = 1 AND an.CodingStd = " || SQL(CodingCVXCode) }; immunizationObj.CVXCode := ImmunizationCVXCode; // Mark each Client Event mapped with the same Event, Immunization and Vaccine information for eventName in eventNameList do eventOccurrenceObj.eventName := eventName; (mlmStatus, outputMessage) := call MarkAsDone_MLM with clientGUID, locationGroupGuid, linkedItemId, 0, updateDatabase, recordOnlyIfPatientAssignedEvent, recordOnlyIfEventActive, eventOccurrenceObj, immunizationObj, vaccineMedicationLotObj, null, // ConsentDocumentObj, null, //EducationalMaterialsObj; false; //linkordertoeventoccurance; ImmRegStatus := "Active"; eventPhysNoteDeclIns := read { "EXEC SCMPhysicalNoteDeclInsPr " || sql(clientGUID) || ", " || sql(chartguid) || ", " || sql(visitguid)|| ", " || sql(UserID) || ", " || "{{{SINGLE-QUOTE}}}ImmRegStatus{{{SINGLE-QUOTE}}}, " || sql(ImmRegStatus) || ", " || NULL || ", " || "{{{SINGLE-QUOTE}}}" || NOW || "{{{SINGLE-QUOTE}}}" }; if mlmStatus > finalMlmStatus then finalMlmStatus := mlmStatus; endif; finalOutputMessage := finalOutputMessage || outputMessage || "\n"; enddo; /* //NOT CURRENTLY USING CLIENTDOCUMENT ACTIONS // --------------------------------------------------------------------------- // Evoking object is a document, flowhseet or structured note. Linked to the // new order or order modify events. elseif (EvokingObject is ClientDocument ) then clientGUID := EvokingObject.clientGUID; catalogItemGUID := EvokingObject.PatCareDocGUID; // The M.A.D. functionality requires the location group GUID from the // evoking object. This is attached to the client visit object. // The same location group guid is used for each of the client document // observations as well. visitGuid := EvokingObject.ClientVisitGUID; locationGroupGuid := read last { "select CurrentLocationGUID from CV3ClientVisit " || " where GUID=" || SQL(visitGuid) }; eventOccurrenceObj := new eventOccurrenceDef; eventOccurrenceObj.actionDate := EvokingObject.Entered; eventOccurrenceObj.actionProviderId := EvokingObject.AuthoredProviderGUID; eventOccurrenceObj.Comment := "Document " || EvokingObject.DocumentName || " entered/modified."; // ------------------------------------------------------------------------ // Retrieve the mapped Event Name based on the Ancillary Coding standard // ------------------------------------------------------------------------ catalogItemGUID := EvokingObject.PatCareDocGUID; eventNameDocList := read {"Select an.Name from CV3AncillaryName an " || "Where an.MainCatItemGUID = " || SQL(catalogItemGUID) || " AND an.Active = 1 AND an.CodingStd = " || SQL(CodingStandard) }; for eventName in eventNameDocList do // Document has an ancillary but it doesn{{{SINGLE-QUOTE}}}t mean that the // patient{{{SINGLE-QUOTE}}}s schedule has the ClientEvent. eventOccurrenceObj.EventName := eventName; (mlmStatus, outputMessage) := call MarkAsDone_MLM with clientGUID, locationGroupGuid, null, null, updateDatabase, recordOnlyIfPatientAssignedEvent, recordOnlyIfEventActive, eventOccurrenceObj, null, null, null, null; if mlmStatus > finalMlmStatus then finalMlmStatus := mlmStatus; endif; finalOutputMessage := finalOutputMessage || outputMessage || "\n"; enddo; // ---------------------------------------------------------------------------------------- // Now check each observation in the document // ---------------------------------------------------------------------------------------- (clientDocObj, observationDocObj) := read last { ClientDocument: THIS, ClientObservationDocument referencing EvokingObject }; observationDocsList := read { ClientObservationDocument: THIS referencing ObservationDocObj }; // For each observation linked to this document, see if it has a mapped Ancillary code // and if found mark that client event as done. for observationDocObj in ObservationDocsList do itemGUID := observationDocObj.ObsMasterItemGUID; eventOccurrenceObj.actionDate := observationDocObj.RecordedDTM; eventOccurrenceObj.Comment := "Observation " || observationDocObj.Name || " Entered/Modified."; // Find all the ClientEvents mapped via AncillaryCodes to this Observation. // Call Mark as Done for each one. eventNameObsList := read { "select cv.CodedValue from SCMObsCodedValue cv " || "where cv.ParentGUID = " || SQL(itemGUID) || " AND " || " cv.Active = 1 AND cv.CodingStandards = " || SQL(CodingStandard) }; for eventName in eventNameObsList do eventOccurrenceObj.EventName := eventName; (mlmStatus, outputMessage) := call MarkAsDone_MLM with clientGUID, locationGroupGuid, null, null, updateDatabase, recordOnlyIfPatientAssignedEvent, recordOnlyIfEventActive, eventOccurrenceObj, null, null, null, null; if mlmStatus > finalMlmStatus then finalMlmStatus := mlmStatus; endif; finalOutputMessage := finalOutputMessage || outputMessage || "\n"; enddo; enddo; // --------------------------------------------------------------------------- // Evoking object is a basic observation (Result) Linked to a basic observation // event. */ /* //NOT CURRENTLY USING THE BASIC OBASERVATION elseif (EvokingObject is BasicObservation) then eventOccurrenceObj := new eventOccurrenceDef; clientGUID := EvokingObject.ClientGUID; resultItemGUID := EvokingObject.ResultItemGUID; orderGUID := EvokingObject.OrderGUID; // The M.A.D. functionality requires the location group GUID from the // evoking object. This is attached to the client visit object. visitGuid := EvokingObject.ClientVisitGUID; locationGroupGuid := read last { "select CurrentLocationGUID from CV3ClientVisit " || " where GUID=" || SQL(visitGuid) }; eventOccurrenceObj.actionDate := EvokingObject.Entered; // Is this the correct time? // Get the action provider from the order, first check care Provider, then userGUID then // finally current logged on user. (careProviderGUID, UserGUID) := read last { "Select o.CareProviderGUID,UserGUID from CV3Order o " || "where o.GUID=" || SQL(orderGUID) }; if (careProviderGUID is null or careProviderGUID=0) then if (userGUID is null or userGUID=0) then actionProviderGUID := read last { User: GUID }; // use current user else actionProviderGUID := userGUID; endif; else actionProviderGUID := careProviderGUID; endif; eventOccurrenceObj.actionProviderId := actionProviderGUID; eventOccurrenceObj.Comment := "Final Result " || EvokingObject.ItemName || " received."; // ------------------------------------------------------------------------ // Retrieve the mapped Event Name based on the Ancillary Coding standard. // Check for Result Only (Type=3) or Order and Result (Type=2) // ------------------------------------------------------------------------ eventNameList := read { "Select an.Name,an.* from CV3AncillaryName an " || " inner join CV3ResultCatalogItem rci on rci.GUID=an.MainCatItemGUID " || "where rci.GUID=" || SQL(resultItemGUID) || " AND " || " an.Active=1 AND an.CatalogType=3 AND an.CodingStd = " || SQL(CodingStandard) || " union " || "Select an.Name,an.* from CV3AncillaryName an " || " inner join CV3ResultCatalogItem rci on rci.GUID=an.AuxCatItemGUID " || "where rci.GUID=" || SQL(resultItemGUID) || " AND " || " an.Active=1 AND an.CatalogType=2 AND an.CodingStd = " || SQL(CodingStandard) }; for eventName in eventNameList do eventOccurrenceObj.eventName := eventName; (mlmStatus, outputMessage) := call MarkAsDone_MLM with clientGUID, locationGroupGuid, orderGUID, 0, updateDatabase, recordOnlyIfPatientAssignedEvent, recordOnlyIfEventActive, eventOccurrenceObj, null, null, null, null; if mlmStatus > finalMlmStatus then finalMlmStatus := mlmStatus; endif; finalOutputMessage := finalOutputMessage || outputMessage || "\n"; enddo; */ endif; ;; priority: 50 ;; evoke: // Run the MLM in time delayed mode //0 minutes after time of order_complete_event; //0 minutes after time of 1 seconds after time of taskOcc_modify_event; //taskOcc_modify_event; //0 minutes after time of observation_enter_event; //0 minutes after time of client_document_enter_event; //0 minutes after time of client_document_modify_event; ;; logic: // Only conclude true if an alert needs to be displayed if ( finalMlmStatus >= AllowAlertOnStatusLevel ) then conclude true; else conclude false; endif; ;; action: if finalOutputMessage is not null then write finalOutputMessage at alert_destination; if not updateDatabase then write "{{+R}}Updates have not been made to the database. UpdateDatabase flag set to false.{{-R}}" at alert_destination; endif; endif; if writeObjectDetails then write "Object details:" at alert_destination; write eventOccurrenceObj at alert_destination; write ImmunizationObj at alert_destination; write vaccineMedicationLotObj at alert_destination; write ConsentDocumentObj at alert_destination; write EducationalMaterialsObj at alert_destination; write "task_lot_mfg_mvxcode =" || task_lot_mfg_mvxcode at alert_destination; write "findmvxstart =" || findmvxstart at alert_destination; write "task_lot_manufact =" || task_lot_manufact at alert_destination; write a at alert_destination; endif; ;; Urgency: 50;; end: