maintenance: title: Ordering: Check for complete registration when entering a discharge or expire order;; mlmname: FORM_Nur_Discharge;; arden: version 2;; version: 4.50;; institution: St Clair Discharge Order MLM;; author: Don Warnick Eclipsys Corp;; specialist: ;; date: 2008-02-25;; validation: testing;; library: purpose: Prevent a discharge order from being entered if the patient visit is not complete or if the registration date is in the future ;; explanation: This MLM is called from the Discharge form. Upon form open the patient comments are interrogated for the presence of a print location comment and the registration date is compared to the present date Change history 05.20.2009 DW Added code for compare of registration date to the current date 10.27.2009 RS Changed the comment to look for from print location to reg initials 06.03.2014 DW CSR# 31688 Changes for MU2 08.26.2015 GOS CSR#23359 - Made change in MLM for ICD9-ICD10 HI Dynamic Creation with all details Like ICD10 Code, Snowmed Code etc. 10.01.2015 JML CSR # 23359 - Copied to Production 10.06.2015 JML WO #1895816: Modified code to dissect the Health Issue Name in the event it contains an apostrophe; replace apostrophe with 2 single quotes so SQL can handle search. 10.07.2015 JML WO #1895816: Moved to Production - CC #2699. 08.22.2017 DW CSR# 36214 - SCM AM Registration - Changed criteria for determining incomplete registration to "iscompleteregistration" flag ;; keywords: Called MLMs, Form fields, discharge, complete visit ;; knowledge: type: data-driven;; data: (this_communication, this_form, client_info_obj) := argument; str_parse := mlm {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; include standard_libs; print_location := "Reg Initials"; error_message:=""; field_list:= this_form.fields; CallingEvent := this_communication.CallingEvent; Visit_Guid := this_communication.ClientVisitGuid; Chart_Guid := this_communication.ChartGuid; Client_Guid := this_communication.ClientGuid; order_name := this_communication.primaryobj.name; if order_name matches pattern "discharge%" then order_name_message := "discharge"; endif; if order_name matches pattern "expire%" then order_name_message := "expire"; endif; // 08/22/17 DW changed criterai to utilize the "iscompleteregistration" flag /* reg_complete := read last {"select typecode from cv3commentdeclaration where typecode = " || SQL(print_location) || " and ClientGUID = " || SQL(client_guid) || " and ChartGUID = " || SQL(chart_guid) || " and ClientVisitGUID= " || SQL(visit_guid) || " and active = 1 " }; */ reg_complete := read last {" select vr.IsCompleteRegistration from SXAAMVisitRegistration vr with (nolock) where vr.IsCompleteRegistration = 1 and vr.ClientVisitGUID = " || visit_guid || " " }; futuredate := read last {"select convert(char(17),admitdtm) from cv3clientvisit where admitdtm > getdate() " || " and ClientGUID = " || SQL(client_guid) || " and ChartGUID = " || SQL(chart_guid) || " and Guid = " || SQL(visit_guid) || " and active = 1 " }; // Check for an incomplete registration (quick reg that has not been addressed) if not exist reg_complete then this_communication.DisplayForm := "Yes"; this_communication.Message := "The registration for this account is incomplete." ||"\n\nDo not enter the "|| order_name_message ||" order at this time." ||"\n\nPlease notify the registrar of the incomplete registration for this account. " ||"\n\nUpon notification by the registrar that the registration is complete," ||"\n\nyou may proceed with the "|| order_name_message ||" process in SCM.\n\n"; this_communication.MessageType := "Informational"; endif; // Check for future registration date(reg clerk mistake that will prevent the patient from being discharged) if exist futuredate then this_communication.Message := "This patient{{{SINGLE-QUOTE}}}s registration date, "|| futuredate || ", is in the future." ||"\n\nDo not enter the "|| order_name_message ||" order at this time." ||"\n\nPlease notify the registrar of the improper registration date for this account. " ||"\n\nUpon notification by the registrar that the date has been corrected," ||"\n\nyou may proceed with the "|| order_name_message ||" process in SCM.\n\n"; this_communication.MessageType := "Informational"; endif; (DischargeDiagnosisHIOnFile) := read { " select distinct hi.shortname " || " from cv3healthissuedeclaration hi with (nolock) " || " join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID " || " where hi.clientguid = " || client_guid || " and hi.chartguid = " || chart_guid || " and hi.clientvisitguid = " || visit_guid || " " || " and hi.active = 1 and hi.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} And hi.ICD10Code is not null " // Added By Shivprasad on 29 Sept 2015 for ICD9-10 Changes || " and hi.typecode = {{{SINGLE-QUOTE}}}Discharge Diag{{{SINGLE-QUOTE}}} " }; // Search for Admit or Discharge Problems ProblemListADM := last of (field_list where field_list.DataItemName = "Obj_Plus_Problem List Builder ADM"); ProblemListDIS := last of (field_list where field_list.DataItemName = "Obj_Plus_Problem List Builder DISC"); If ProblemListADM is not null then ProblemListValue := ProblemListADM.Value; NewHealthIssueHIType:= "Admit Diag"; Elseif ProblemListDIS is not null then ProblemListValue := ProblemListDIS.Value; NewHealthIssueHIType:= "Discharge Diag"; Endif; // Proceed with creating a Problem (HI), if information is found in one of the fields If ProblemListValue is not null then NewHealthIssueListBox := last of (field_list where field_list.DataItemName = "NUR_Comment 3"); NewHealthIssueList := " "; formlist := call str_parse with ProblemListValue, "|"; // Parse the value into a string of Name/Number pairs index_list := 1 seqto (count formlist) ; for J in index_list do singledate := formlist[J]; hinumberstart := find "..." in string singledate; NewHealthIssuName := Trim(SUBSTRING (hinumberstart -1) CHARACTERS STARTING AT (1) from singledate); NewHealthIssueHICode:= Trim(SUBSTRING (10) CHARACTERS STARTING AT (hinumberstart + 4) from singledate); //JML: WO# 1895816 Code change Start if ( NewHealthIssuName matches pattern "%{{{SINGLE-QUOTE}}}%" ) then hiFirstPart := SUBSTRING ((FIND "{{{SINGLE-QUOTE}}}" IN STRING NewHealthIssuName) - 1) CHARACTERS STARTING AT 1 FROM NewHealthIssuName; //Zenker hiSecondPart := SUBSTRING ( (LENGTH NewHealthIssuName) - (FIND "{{{SINGLE-QUOTE}}}" IN STRING NewHealthIssuName)) CHARACTERS STARTING AT ( (FIND "{{{SINGLE-QUOTE}}}" IN STRING NewHealthIssuName) + 1) FROM NewHealthIssuName; HealthIssueSearchName := hiFirstPart || "{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}" || hiSecondPart; else HealthIssueSearchName := NewHealthIssuName; endif; //JML Code change end If j = 1 then NewHealthIssueList := NewHealthIssuName; else NewHealthIssueList := NewHealthIssueList || ", " || NewHealthIssuName; endif; try client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((Visit_Guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; endtry; catch Exception ex error_occurred:= true; error_message := "{{+R}}Retrieve client:{{-R}}\n" ||ex.Message || "\n\n"; if ex.InnerException is not null net_object then error_message := error_message || "Inner Exception: " || ex.InnerException.Message || "\n\n"; endif; if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; endcatch; try NewHealthIssueHIScheme := "ICD10"; // Added By Shivprasad for [CSR#23359- ICD9-10 MLM change] for Duplicate HI identification HI_Present := read {" select distinct hi.shortname " || "from cv3healthissuedeclaration hi with (nolock) " || "join CV3CodedHealthIssue chi with (nolock) on chi.GUID = hi.CodedHealthIssueGUID " || "where hi.clientguid = " || SQL(Client_Guid) || " and hi.active = 1 and hi.status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} " //|| "and hi.typecode not in ({{{SINGLE-QUOTE}}}admitting dx{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}chronic dx{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}dx comments{{{SINGLE-QUOTE}}}) " || " And hi.ICD10Code is not null " // Added By Shivprasad on 29 Sept 2015 for ICD9-10 Changes || " and ( " || "hi.text like {{{SINGLE-QUOTE}}}%"|| HealthIssueSearchName || "%{{{SINGLE-QUOTE}}} or hi.shortname like {{{SINGLE-QUOTE}}}%"|| HealthIssueSearchName || "%{{{SINGLE-QUOTE}}} or " || " " || "(Case when chi.TypeCode = {{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}} then chi.code end) in ({{{SINGLE-QUOTE}}}"|| NewHealthIssueHICode ||"{{{SINGLE-QUOTE}}}) " || " ) " || " AND ({{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} AND ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}} OR ( hi.ScopeLevel = {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}} AND hi.ChartGUID = " || SQL(Chart_Guid) || " ) OR hi.ClientVisitGUID = " || SQL(Visit_Guid) || " ) ) " || " AND hi.TypeCode = {{{SINGLE-QUOTE}}}Discharge Diag{{{SINGLE-QUOTE}}}" }; If Not Exist HI_Present Then //--Start: CSR 23359-ICD9-ICD10 HI Change Added By shivprasad Terms := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.FindIMOTerms with (NewHealthIssueHIScheme,NewHealthIssueHICode); FOR i IN 1 SEQTO (Terms.Count as Number ) DO HI_obj := Terms[i]; HI_Name := HI_obj.TermName as string; If HI_Name = NewHealthIssuName then HI_NO := i ; Endif; ENDDO; If HI_NO is Null Then HI_NO :=1 ; Endif; New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with (client_visit_obj, NewHealthIssueHIType, Terms[HI_NO]); //--End Added by Shivprasad //New_HealthIssue_obj := call {{{SINGLE-QUOTE}}}HealthIssue{{{SINGLE-QUOTE}}}.CreateCodedHealthIssue with (client_visit_obj, NewHealthIssueHIType, NewHealthIssueHIScheme, NewHealthIssueHICode ); New_HealthIssue_obj.Text := "Created from Discharge Order . " ; New_HealthIssue_obj.Name := NewHealthIssuName; if ( New_HealthIssue_obj is NOT NULL ) then void := call New_HealthIssue_obj.Save; void := call New_HealthIssue_obj.Dispose; endif; if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; Endif; // End of HI_Present endtry; catch exception ex error_occurred := true; if ( New_HealthIssue_obj is NOT NULL ) then void:= call New_HealthIssue_obj.Dispose; New_HealthIssue_obj:= null; endif; endcatch; enddo; NewHealthIssueListBox.value := NewHealthIssueList; endif; // ProblemList Value is not null ;; 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: