maintenance: title: DOC_FUNC_ACUTE_CHF_CRITERIA ;; mlmname: DOC_FUNC_ACUTE_CHF_CRITERIA ;; arden: version 5.0;; version: 2.00;; institution: St.Clair Hospital;; author: Shivprasad Jadhav ;; specialist: Shivprasad Jadhav, GOS Allscripts;; date: 2015-08-12;; validation: testing;; library: purpose: On Document save MLM look for the [Acute CHF] or [CHF] Selection in structured note Or look for the HI Depend on HI type and its scope of [ Acute CHF or CHF]. Then it will look for Mail send history. As we are creating comment when mail sent earlier. If Mail not sent earlier then it send mail to [#patient Registration-Pharmacy@StClair.org ] ;; explanation: Change history 08.12.2015 SSJ CSR# 33338 - Created 07.20.2016 SSJ CSR#333338- Added filter for patient Typecode [Inpatient and Observation] only 08.16.2016 Shivprasad - CSR #333338- Made changes as per new specs to sent mail and added logic to create HI for CHF, COPD, Renal And Diabetes. ;; 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; DocGuid := thisStructuredNoteDoc.ClientDocumentGUID ; HI_MLM := MLM {{{SINGLE-QUOTE}}}SCH_Func_Create_Health_Issue{{{SINGLE-QUOTE}}}; VST_Code := Read last {"Select cv.Typecode from cv3ClientVisit cv (nolock) Where cv.Guid = " || visitGuid || " And cv.ClientGUID = " || clientGuid } ; (LocationLevelCode) := read last { " Select Top 1 case when cc.typecode = {{{SINGLE-QUOTE}}}unit{{{SINGLE-QUOTE}}} then cc.levelcode when b.typecode={{{SINGLE-QUOTE}}}unit{{{SINGLE-QUOTE}}} then b.levelcode when a.typecode={{{SINGLE-QUOTE}}}unit{{{SINGLE-QUOTE}}} then a.levelcode when cv3l.typecode={{{SINGLE-QUOTE}}}unit{{{SINGLE-QUOTE}}} then cv3l.levelcode else null end as Unit From CV3ClientVisit CV With (Nolock) Left Join CV3Location CV3L On CV3L.GUID=CV.CurrentLocationGUID Left Join CV3Location a With (Nolock) on CV3L.parentguid= a.guid Left Join CV3Location b With (Nolock) on a.parentguid = b.guid left join cv3location cc With (Nolock) on b.parentguid = cc.guid WHERE CV.GUID = "|| visitGuid }; // DOCUMENT CLOSING SECTION IF thisdocumentCommunication.EventType = "DocumentClosing" then errormessage := ""; // Determine if the Acute CHF button is selected theParameter := first of (thisparameters where thisparameters.Name = "SCHCK_Chronic_Conditions"); //SCH_CK_Diagnosis Risk theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); //------For Adult Patient Profile Observation Only--------------------------------------------------------------------------- theParameter1 := first of (thisparameters where thisparameters.Name = "SCH_CK_Diagnosis Risk"); //SCH_CK_Diagnosis Risk theObservation1 := first of (thisobservations where thisobservations.ParameterGUID = theParameter1.ParameterGUID); //-------------------------------------------------------------------------------------------------------------------------- // To get user selections for Observation if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "CHF") then HI_CHF :="CHF"; else HI_CHF :=""; endif; //------For Adult Patient Profile Observation Only--------------------------------------------------------------------------- if true in (theObservation1.ValueObj.ListItemsList.IsSelected where theObservation1.ValueObj.ListItemsList.Value = "Acute CHF") then HI_CHF :="CHF"; elseIf False in (theObservation1.ValueObj.ListItemsList.IsSelected where theObservation1.ValueObj.ListItemsList.Value = "Acute CHF") Then HI_CHF :=""; endif; //-------------------------------------------------------------------------------------------------------------- if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "COPD") then HI_COPD :="COPD"; else HI_COPD :=""; endif; if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Diabetes") then HI_Diabetes :="Diabetes"; else HI_Diabetes :=""; endif; if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Renal Failure") then HI_Renal :="Renal Failure"; else HI_Renal :=""; endif; //Health Issue Variable CHF_Created := "No"; COPD_Created := "No"; Diabetes_Created := "No"; Renal_Created := "No"; //To Create health Issue Filter Criteria based on user selection on St. Note. If (HI_CHF <> "" ) or (HI_COPD <> "" ) or (HI_Diabetes <> "") or ( HI_Renal <> "") Then //Message to User for Health Issue Creation dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "A Health Issue has been created for this Condition. ", "Important Alert","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; /*************************** Health Issue for CHF ******************************/ If HI_CHF <> "" Then // HI CHF Information HI_Name := "CHF (congestive heart failure)"; HI_9Code := "428.0"; HI_10Code := "I50.9"; CodingScheme:= "ICD10"; HI_TYPE := "Problem-Chronic"; IssueText := "Created from {{{SINGLE-QUOTE}}}Pharmacy Insurance Information MLM{{{SINGLE-QUOTE}}}. " ; (CurrentVisit_CHF) := read last { "select distinct hi.shortname , hi.ScopeLevel, hi.typecode " || " from Cv3ClientVisit cv With (Nolock) Join cv3healthissuedeclaration hi with (nolock) " || " on cv.guid= hi.ClientVisitGUID And cv.ClientGuid =Hi.ClientGUID " || " join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID" || " where cv.GUID = " || visitGuid || " And cv.clientguid = " || clientGuid || " and hi.active = 1 " || " and hi.typecode in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Visit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}}) " || " and ((Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}"|| HI_9Code ||"{{{SINGLE-QUOTE}}}) or (Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD10{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}"|| HI_10Code ||"{{{SINGLE-QUOTE}}}) ) " }; If Not exist CurrentVisit_CHF Then Void := Call HI_MLM With (visitGuid, HI_Name, HI_10Code, IssueText,HI_TYPE,CodingScheme); //(visitGuid,issuename,issuecode,issuetext,issuetype,issuescheme) CHF_Created := "Yes"; EndIf; Endif; /*************************** Health Issue for COPD ******************************/ If HI_COPD <> "" Then HI_Name := "Chronic Obstructive Pulmonary Desease"; HI_9Code := "496"; HI_10Code := "J44.9"; CodingScheme := "ICD10"; HI_TYPE := "Problem-Chronic"; IssueText := "Created from {{{SINGLE-QUOTE}}}Pharmacy Insurance Information MLM{{{SINGLE-QUOTE}}}. " ; (CurrentVisit_COPD) := read last { "select distinct hi.shortname , hi.ScopeLevel, hi.typecode " || " from Cv3ClientVisit cv With (Nolock) Join cv3healthissuedeclaration hi with (nolock) " || " on cv.guid= hi.ClientVisitGUID And cv.ClientGuid =Hi.ClientGUID " || " join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID" || " where cv.GUID = " || visitGuid || " And cv.clientguid = " || clientGuid || " and hi.active = 1 " || " and hi.typecode in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Visit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}}) " || " and ((Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}"|| HI_9Code ||"{{{SINGLE-QUOTE}}}) or (Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD10{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}"|| HI_10Code ||"{{{SINGLE-QUOTE}}}) ) " }; If Not exist CurrentVisit_COPD Then Void := Call HI_MLM With (visitGuid, HI_Name, HI_10Code, IssueText,HI_TYPE,CodingScheme); //(visitGuid,issuename,issuecode,issuetext,issuetype,issuescheme) COPD_Created := "Yes"; Endif; EndIf; /*************************** Health Issue for Diabetes ******************************/ If HI_Diabetes <> "" Then HI_Name := "Diabetes"; HI_9Code := "250.00"; HI_10Code := "E11.9"; CodingScheme := "ICD10"; HI_TYPE := "Problem-Chronic"; IssueText := "Created from {{{SINGLE-QUOTE}}}Pharmacy Insurance Information MLM{{{SINGLE-QUOTE}}}. " ; (CurrentVisit_Diabetes) := read last { "select distinct hi.shortname , hi.ScopeLevel, hi.typecode " || " from Cv3ClientVisit cv With (Nolock) Join cv3healthissuedeclaration hi with (nolock) " || " on cv.guid= hi.ClientVisitGUID And cv.ClientGuid =Hi.ClientGUID " || " join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID" || " where cv.GUID = " || visitGuid || " And cv.clientguid = " || clientGuid || " and hi.active = 1 " || " and hi.typecode in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Visit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}}) " || " and ((Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}"|| HI_9Code ||"{{{SINGLE-QUOTE}}}) or (Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD10{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}"|| HI_10Code ||"{{{SINGLE-QUOTE}}}) ) " }; If Not exist CurrentVisit_Diabetes Then Void := Call HI_MLM With (visitGuid, HI_Name, HI_10Code, IssueText,HI_TYPE,CodingScheme); //(visitGuid,issuename,issuecode,issuetext,issuetype,issuescheme) Diabetes_Created := "Yes"; Endif; EndIf; /*************************** Health Issue for renal Chronic ******************************/ If HI_Renal <> "" Then HI_Name := "Chronic renal failure"; HI_9Code := "585.9"; HI_10Code := "N18.9"; CodingScheme := "ICD10"; HI_TYPE := "Problem-Chronic"; IssueText := "Created from {{{SINGLE-QUOTE}}}Pharmacy Insurance Information MLM{{{SINGLE-QUOTE}}}. " ; (CurrentVisit_Renal) := read last { "select distinct hi.shortname , hi.ScopeLevel, hi.typecode " || " from Cv3ClientVisit cv With (Nolock) Join cv3healthissuedeclaration hi with (nolock) " || " on cv.guid= hi.ClientVisitGUID And cv.ClientGuid =Hi.ClientGUID " || " join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID" || " where cv.GUID = " || visitGuid || " And cv.clientguid = " || clientGuid || " and hi.active = 1 " || " and hi.typecode in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Visit{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Problem-Chronic{{{SINGLE-QUOTE}}}) " || " and ((Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}"|| HI_9Code ||"{{{SINGLE-QUOTE}}}) or (Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD10{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}"|| HI_10Code ||"{{{SINGLE-QUOTE}}}) ) " }; If Not exist CurrentVisit_Renal Then Void := Call HI_MLM With (visitGuid, HI_Name, HI_10Code, IssueText,HI_TYPE,CodingScheme); //(visitGuid,issuename,issuecode,issuetext,issuetype,issuescheme) Renal_Created := "Yes"; Endif; Endif; /*************************** Health Issue Creation Completed **************************************************** ******************************/ // To get Last observation value charted on patient or current Values for {{{SINGLE-QUOTE}}}SCHCK_Chronic_Conditions{{{SINGLE-QUOTE}}} Observation /* If DocGuid Is not Null Then LastObsVal := read First {"SELECT oflv.value " || " FROM CV3ClientDocument cd WITH (NOLOCK) INNER JOIN cv3ClientVisit cv WITH (NOLOCK) ON cv.GUID = cd.ClientVisitGUID And cv.clientguid = cd.ClientGUID " || " AND cv.chartguid = cd.ChartGUID AND cd.iscanceled = 0 And cd.Active = 1 AND cd.DocumentName in ( {{{SINGLE-QUOTE}}}Adult Patient Profile{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Adult Patient Profile - Observation{{{SINGLE-QUOTE}}}) " || " INNER JOIN SXACDObservationParameter OP WITH (NOLOCK) ON OP.ClientGUID = cd.ClientGUID AND OP.ChartGUID = cd.ChartGUID " || " AND OP.PatCareDocGUID = cd.PatCareDocGUID AND OP.RecordedDtm = cd.AuthoredDtm " || " INNER JOIN CV3ObsCatalogMasterItem omi WITH (NOLOCK) ON omi.GUID = op.ObsMasterItemGUID And omi.name in ({{{SINGLE-QUOTE}}}SCHCK_Chronic_Conditions{{{SINGLE-QUOTE}}}) " || " LEFT JOIN SCMObsFSListValues oflv WITH (NOLOCK) ON oflv.ParentGUID = op.ObservationDocumentGUID AND oflv.Active = 1 AND cd.ClientGUID = oflv.ClientGUID " || " AND oflv.ClientGUID = cd.ClientGUID " || " Where cv.guid = " || visitGuid || " And cd.guid = " || thisStructuredNoteDoc.ClientDocumentGUID || " And oflv.value in ({{{SINGLE-QUOTE}}}CHF{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}COPD{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Diabetes{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Renal Failure{{{SINGLE-QUOTE}}}) " }; Else LastObsVal := read First {"SELECT oflv.value " || " FROM CV3ClientDocument cd WITH (NOLOCK) INNER JOIN cv3ClientVisit cv WITH (NOLOCK) ON cv.GUID = cd.ClientVisitGUID And cv.clientguid = cd.ClientGUID " || " AND cv.chartguid = cd.ChartGUID AND cd.iscanceled = 0 And cd.Active = 1 AND cd.DocumentName in ( {{{SINGLE-QUOTE}}}Adult Patient Profile{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Adult Patient Profile - Observation{{{SINGLE-QUOTE}}}) " || " INNER JOIN SXACDObservationParameter OP WITH (NOLOCK) ON OP.ClientGUID = cd.ClientGUID AND OP.ChartGUID = cd.ChartGUID " || " AND OP.PatCareDocGUID = cd.PatCareDocGUID AND OP.RecordedDtm = cd.AuthoredDtm " || " INNER JOIN CV3ObsCatalogMasterItem omi WITH (NOLOCK) ON omi.GUID = op.ObsMasterItemGUID And omi.name in ({{{SINGLE-QUOTE}}}SCHCK_Chronic_Conditions{{{SINGLE-QUOTE}}}) " || " LEFT JOIN SCMObsFSListValues oflv WITH (NOLOCK) ON oflv.ParentGUID = op.ObservationDocumentGUID AND oflv.Active = 1 AND cd.ClientGUID = oflv.ClientGUID " || " AND oflv.ClientGUID = cd.ClientGUID " || " Where cv.guid = " || visitGuid //|| " And cd.guid = " || thisStructuredNoteDoc.ClientDocumentGUID || " And oflv.value in ({{{SINGLE-QUOTE}}}CHF{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}COPD{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Diabetes{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Renal Failure{{{SINGLE-QUOTE}}}) " }; Endif; */ // To identify the Existing Email Sent or Not LastMLMSent := read First {"Select cd.text from cv3ClientVisit cv With (Nolock) Join CV3CommentDeclaration cd With (Nolock) On cv.guid=cd.ClientVisitGUID And cd.ClientGUID=cv.ClientGUID and cd.ChartGUID= cv.ChartGUID And cd.Typecode= {{{SINGLE-QUOTE}}}Reg Notified of CHF{{{SINGLE-QUOTE}}} And cd.Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} And cd.ClientVisitGUID = " || visitGuid || ""}; //------------------------------------------------------------------------------------------------------- If LocationLevelCode In ("4B","5A","5B","5E","5F","5G","6E","6F","CCU1","CCU2","CVSU","ICU","ICU Pod 2","IMC") Then If ((HI_CHF <> "" ) or (HI_COPD <> "" ) or (HI_Diabetes <> "") or ( HI_Renal <> "") ) // And (CHF_Created = "Yes" or COPD_Created = "Yes" or Diabetes_Created = "Yes" or Renal_Created = "Yes" ) Then // To Value selection and HI Creation confirmation //If (LastObsVal is Null ) And (LastMLMSent is Null ) Then // To Restrict One Time to send this message If (LastMLMSent is Null ) Then // To Restrict One Time to send this message If (VST_Code Matches Pattern "%Inpatient%") or (VST_Code Matches Pattern "%Observation%") Then (PatientName , MRN, VisitIDCode, DOA) := Read First {" Select ClientDisplayName, IDCode, VisitIDCode, FORMAT( AdmitDtm ,{{{SINGLE-QUOTE}}}MM/dd/yyyy{{{SINGLE-QUOTE}}}) as DOA from cv3CLientVisit Where Guid = " || visitGuid || " "}; // Send a Text Message Section PhoneNumber := read last {" select p.PhoneNumber from CV3User u with (nolock) join Cv3Phone p with (nolock) on p.PersonGUID = u.GUID " || " where u.displayname = {{{SINGLE-QUOTE}}}SCM, Text Messaging{{{SINGLE-QUOTE}}} and p.PhoneNote = {{{SINGLE-QUOTE}}}Outpatient Pharmacy Prescription Request{{{SINGLE-QUOTE}}} And p.Active =1 "}; //PhoneNumber := "Shivprasad.Jadhav@stclair.org;" ; If PhoneNumber ="#Patient Registration-Pharmacy" Then PhoneNumber := " #PatientRegistrationPharmacy@stclair.org" ; EndIf; //PhoneNumber := PhoneNumber,"Shivprasad.jadhav@stclair.org;"; Page_MLM := mlm {{{SINGLE-QUOTE}}}SCH_FUNC_PAGE{{{SINGLE-QUOTE}}}; MessageSubject:= "Pharmacy Insurance Information"; MessageBody := " Please enter this patients Pharmacy Insurance information into the Registration system. \n " || "Patient Name: "|| PatientName || " \n " || "Medical Record Number: "|| MRN || " \n " || "Account Number: "|| VisitIDCode || " \n " || "Date of Admission: "|| DOA || " \n " ; PPMvoid := call Page_MLM with(PhoneNumber, MessageSubject, MessageBody); client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); CommentTypeCode := "Reg Notified of CHF"; PatientComment_Obj := call {{{SINGLE-QUOTE}}}PatientComment{{{SINGLE-QUOTE}}}.CreatePatientComment with client_visit_obj, CommentTypeCode; PatientComment_Obj.text := "Mail Sent"; Void := Call PatientComment_Obj.Save; EndIf; Endif; EndIf; Endif; endif; // End of Close Document Endif; ;; evoke: ;; logic: conclude true; ;; action: return thisDocumentCommunication; ;; Urgency: 50;; end: