Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: AUMSCBD

AUMSCBD.m

Go to the documentation of this file.
AUMSCBD ;IHS/OIT/NKD - SCB UPDATE - DRIVER 12/07/2012 ;
 ;;19.0;TABLE MAINTENANCE;**1**;SEP 04,2018;Build 1
 ; 03/12/14 - Modified processing/display for ADD/DEL tags
 ;          - Modified debug to include ADD changes
 ; 12/16/14 - Removed old/unused code
 ; 05/29/15 - Added Clinic report
 ; 06/03/16 - Enhancement to WP array processing
 Q
 ;Called at POST by KIDS for AUM updates
POST ; EP -- MAIN EP
 N AUMCNT,HDR,ONE,AT,AUMDT,AUMT,AUMA,CNT
 S AUMCNT=0,HDR="",ONE=1,AT="@",AUMDT=$P($$NOW^XLFDT(),".")
 F  S AUMCNT=$O(^AUMDATA(AUMCNT)) Q:'AUMCNT  D
 . N AUMT,AUMA,CNT
 . S AUMT=$P(^AUMDATA(AUMCNT,0),U,2),AUMA=""
 . F CNT="ADD","INA","DEL","ALL" Q:$L(AUMA)>0  S:$E(AUMT,$L(AUMT)-2,$L(AUMT))=CNT AUMA=$E(AUMT,$L(AUMT)-2,$L(AUMT)),AUMT=$E(AUMT,1,$L(AUMT)-3)
 . I AUMA="ALL" D  Q
 . . S:'$D(^TMP("AUM",$J,"ALL",AUMT,0)) ^TMP("AUM",$J,"ALL",AUMT,0)=0
 . . S ^TMP("AUM",$J,"ALL",AUMT,^TMP("AUM",$J,"ALL",AUMT,0)+1)=$P(^AUMDATA(AUMCNT,0),U,3,9),^TMP("AUM",$J,"ALL",AUMT,0)=^TMP("AUM",$J,"ALL",AUMT,0)+1
 . D ENTRY(AUMT,AUMA,$P(^AUMDATA(AUMCNT,0),U,3,9))
 I $D(^TMP("AUM",$J,"ALL")) D ALL^AUMSCBA
 D RSLT($$REPEAT^XLFSTR("-",20))
 I HDR["EDT" D PKLST^AUMSCBU
 I HDR["CLIN" D CLINIC^AUMSCBU  ; IHS/OIT/NKD AUM*15.0*3 - ADDED CLINIC REPORT
 Q
ENTRY(AUMT,AUMA,L,AUMAIEN,AUMQ) ; MAIN UPDATE DRIVER
 N P1,P2,P3,P4,P5,P6,P7,P1A,P2A,P3A,P4A,P5A,P6A,P7A,L1,F1,F2,F3
 N FDA,NEWIEN,ERR,CNT,CNT2,TEXT,INA,INAD
 ; D=DATA,E=ERROR,I=IEN,L=LIST,M=MODIFY,P=PRINT,R=RESULT,S=STRING
 N AUMD,AUME,AUMI,AUML,AUMM,AUMP,AUMR,AUMS
 S (AUMI,AUMM,AUML)="",AUMP=0,INA=$S(AUMA="INA":1,AUMA="DEL":1,1:0)
 F CNT=1:1:7 S @("P"_CNT)=$P(L,U,CNT),@("P"_CNT_"A")=""
 F CNT=1:1 S TEXT=$P($T(@(AUMT)+CNT^AUMSCBM),";;",2) Q:TEXT="END"  D
 . S AUMD(TEXT)=$P($T(@(AUMT)+CNT^AUMSCBM),";;",3)
 ; PRE-UPDATE
 I $D(AUMD("PRE")) D @(AUMD("PRE"))
 Q:$D(AUME)
 ; SEARCH
 S:$D(AUMAIEN) AUMI=AUMAIEN
 S:'AUMI&$D(AUMD("SEA")) AUMI=$$SEARCH(AUMD("SEA"))
 ; INACTIVATE
 I INA,$D(AUMD("INA")) D INACT
 ; NEW
 I 'INA,'AUMI,$D(AUMD("NEW")) D NEW
 Q:'AUMI
 ; UPDATE
 I 'INA,$D(AUMD("UPD")) D UPDATE
 ; WP
 I $D(AUMD("WP")) D WP
 ; POST-UPDATE
 I $D(AUMD("POS")) D @(AUMD("POS")) Q
 ; DISPLAY
 I $D(AUMD("DSP")) D DISP Q
 D RSLT(AUMT_": "_L)
 Q
 N F1,F2,F3,CNT,CNT2,AUMR,AUMI
 S F1=$P(AUMD,U,1),F2=$P(AUMD,U,2),AUMI=""
 F CNT=1:1:$L(F2,";") Q:AUMI]""  D
 . S F3=$P(F2,";",CNT)
 . I '$D(@$P(F3,"|",1)) D ERR("SYSTEM ERROR - Unassigned local variable: "_$P(F3,"|",1)) Q
 . D FIND^DIC(F1,"","@;.01","PX",@$P(F3,"|",1),,$P(F3,"|",2),,,"AUMR")
 . S CNT2=$P($G(AUMR("DILIST",0)),U,1)
 . S AUMI=$S(CNT2=1:$P($G(AUMR("DILIST",1,0)),U,1),CNT2>1:$P($G(AUMR("DILIST",$P($G(AUMR("DILIST",0)),U,1),0)),U,1),1:"")
 Q AUMI
INACT ; GENERIC INACTIVATE DRIVER
 N FDA,ERR,F1,F2,F3,CNT,AUMR
 I 'AUMI S AUMM=AUMA_" :" D ERR("Entry not found to INACTIVATE (ok)") Q
 ; CUSTOM INACTIVATE CHECK
 I AUMD("INA")'["|" D @(AUMD("INA")) Q
 S F1=$P(AUMD("INA"),U,1),F2=$P(AUMD("INA"),U,2),AUMR=""
 F CNT=1:1:$L(F2,";") D
 . S F3=$P(F2,";",CNT)
 . I '$D(@$P(F3,"|",2)) D ERR("SYSTEM ERROR - Unassigned local variable: "_$P(F3,"|",2)) Q
 . Q:(@$P(F3,"|",2))']""
 . Q:($$GET1^DID(F1,$P(F3,"|",1),"","LABEL")']"")
 . S FDA(F1,AUMI_",",$P(F3,"|",1))=@$P(F3,"|",2)
 . S AUMR=AUMR_$P(F3,"|",1)_"|"_$TR($$GET1^DIQ(F1,AUMI,$P(F3,"|",1),"I"),U,";;")_"|"_$P(F3,"|",2)_U
 D UPDATE^DIE($S($L($P(AUMD("INA"),U,3))<1:"E",1:""),"FDA",,"ERR")
 I $D(ERR) D ERR("SYSTEM ERROR - Inactivate failed") Q
 I AUMM']"" D
 . ;I AUMA="DEL" S AUMM=AUMA_" :" Q    ; IHS/OIT/NKD AUM*14.0*2 - MODIFIED PROCESSING FOR DEL TAG
 . F CNT=1:1:$L(AUMR,U) Q:$P(AUMR,U,CNT)']""  D
 . . Q:$$GET1^DIQ(F1,AUMI,$P($P(AUMR,U,CNT),"|",1),"I")=$TR($P($P(AUMR,U,CNT),"|",2),";;",U)
 . . Q:$P($P(AUMR,U,CNT),"|",1)=".28"
 . . S AUML=AUML_$$GET1^DID(F1,$P($P(AUMR,U,CNT),"|",1),"","LABEL")_"|"_$P($P(AUMR,U,CNT),"|",2)_"|"_@$P($P(AUMR,U,CNT),"|",3)_U
 . . S AUMM="INA :"
 . . S:AUMA="DEL" AUMM="DEL :"  ; IHS/OIT/NKD AUM*14.0*2 - MODIFIED PROCESSING FOR DEL TAG
 Q
NEW ; GENERIC NEW ENTRY DRIVER
 N FDA,NEWIEN,ERR,F1,F2,F3,CNT
 S AUMM="NEW :"
 ; CUSTOM NEW ENTRY CHECK
 I AUMD("NEW")'["|" D @(AUMD("NEW")) Q
 S F1=$P(AUMD("NEW"),U,1),F2=$P(AUMD("NEW"),U,2)
 F CNT=1:1:$L(F2,";") D
 . S F3=$P(F2,";",CNT)
 . I '$D(@$P(F3,"|",2)) D ERR("SYSTEM ERROR - Unassigned local variable: "_$P(F3,"|",2)) Q
 . Q:(@$P(F3,"|",2))']""
 . Q:($$GET1^DID(F1,$P(F3,"|",1),"","LABEL")']"")
 . S FDA(F1,"+1,",$P(F3,"|",1))=@$P(F3,"|",2)
 D UPDATE^DIE($S($L($P(AUMD("NEW"),U,3))<1:"E",1:""),"FDA","NEWIEN","ERR")
 I $D(ERR) D ERR("SYSTEM ERROR - New entry failed") Q
 S AUMI=NEWIEN(1)
 Q
UPDATE ; GENERIC UPDATE DRIVER
 N FDA,ERR,F1,F2,F3,CNT,AUMR
 S F1=$P(AUMD("UPD"),U,1),F2=$P(AUMD("UPD"),U,2),AUMR=""
 F CNT=1:1:$L(F2,";") D
 . S F3=$P(F2,";",CNT)
 . I '$D(@$P(F3,"|",2)) D ERR("SYSTEM ERROR - Unassigned local variable: "_$P(F3,"|",2)) Q
 . Q:(@$P(F3,"|",2))']""
 . Q:($$GET1^DID(F1,$P(F3,"|",1),"","LABEL")']"")
 . S FDA(F1,AUMI_",",$P(F3,"|",1))=@$P(F3,"|",2)
 . S AUMR=AUMR_$P(F3,"|",1)_"|"_$TR($$GET1^DIQ(F1,AUMI,$P(F3,"|",1),"I"),U,";;")_"|"_$P(F3,"|",2)_U
 D UPDATE^DIE($S($L($P(AUMD("UPD"),U,3))<1:"E",1:""),"FDA",,"ERR")
 I $D(ERR) D ERR("SYSTEM ERROR - Update failed") Q
 I AUMM']"" D
 . ;I AUMA=""ADD"" S AUMM=AUMA_"" :"" Q  ; IHS/OIT/NKD AUM*14.0*2 - MODIFIED PROCESSING FOR ADD TAG
 . F CNT=1:1:$L(AUMR,U) Q:$P(AUMR,U,CNT)']""  D
 . . Q:$$GET1^DIQ(F1,AUMI,$P($P(AUMR,U,CNT),"|",1),"I")=$TR($P($P(AUMR,U,CNT),"|",2),";;",U)
 . . Q:$P($P(AUMR,U,CNT),"|",1)=".28"
 . . S AUML=AUML_$$GET1^DID(F1,$P($P(AUMR,U,CNT),"|",1),"","LABEL")_"|"_$P($P(AUMR,U,CNT),"|",2)_"|"_@$P($P(AUMR,U,CNT),"|",3)_U
 . . S AUMM="MOD :"
 . . S:AUMA="ADD" AUMM="ADD :"  ; IHS/OIT/NKD AUM*14.0*2 - MODIFIED PROCESSING FOR ADD TAG
 Q
WP ; GENERIC WORD-PROCESSING DRIVER
 N FDA,ERR,F1,F2,F3,CNT
 N AUMWP1,AUMWP2
 S F1=$P(AUMD("WP"),U,1),F2=$P(AUMD("WP"),U,2)
 F CNT=1:1:$L(F2,";") D
 . S F3=$P(F2,";",CNT)
 . I '$D(@$P(F3,"|",2)) D ERR("SYSTEM ERROR - Unassigned local variable: "_$P(F3,"|",2)) Q
 . D TEXT(.@($P(F3,"|",2)))
 . S AUMWP1=$$GET1^DIQ(F1,AUMI_",",$P(F3,"|",1),,"AUMWP1")
 . D WP^DIE(F1,AUMI_",",$P(F3,"|",1),,$P(F3,"|",2))
 . S AUMWP2=$$GET1^DIQ(F1,AUMI_",",$P(F3,"|",1),,"AUMWP2")
 . I $$WPCHK(.AUMWP1,.AUMWP2) S AUML=AUML_$$GET1^DID(F1,$P(F3,"|",1),"","LABEL")_U,AUMM=$S(AUMM]"":AUMM,1:"MOD :")
 Q
DISP ; EP - GENERIC DISPLAY DRIVER
 N F1,F2,F3,CNT,AUMS,AUMH
 Q:AUMP
 I $D(AUMD("DSP")) D
 . S AUMS=""
 . S INAD=$S(INA:"I",1:"")
 . F CNT=1:1:$L(AUMD("DSP"),";") D
 . . S F1=$P($P(AUMD("DSP"),";",CNT),"|",1),F2=$P($P(AUMD("DSP"),";",CNT),"|",2),F3=$P($P(AUMD("DSP"),";",CNT),"|",3)
 . . S:F3]"" AUMS=AUMS_$J("",F3-$L(AUMS))
 . . S AUMS=AUMS_$E(@F1,1,F2)_$J("",F2+1-$L($E(@F1,1,F2)))
 . ; CHECK IF TABLE HEADER NEEDS TO BE DISPLAYED
 . I $D(AUMD("HDR")) D
 . . S F1=$P(AUMD("HDR"),U,1)
 . . Q:$P(HDR,U,$L(HDR,U)-1)=@$P(F1,";",1)
 . . D RSLT($$REPEAT^XLFSTR("-",20))
 . . S AUMH=""
 . . D RSLT(AUMH)
 . . S AUMH=$G(^TMP("AUM",$J,"COUNT",@$P(F1,";",1)))_" "_$P(F1,";",2)
 . . D RSLT(AUMH)
 . . S AUMH=""
 . . F CNT=1:1:$L($P(AUMD("HDR"),U,2),";") D
 . . . S F2=$P($P($P(AUMD("HDR"),U,2),";",CNT),"|",1),F3=$P($P($P(AUMD("HDR"),U,2),";",CNT),"|",2)
 . . . S AUMH=AUMH_$J("",F3-$L(AUMH))_F2
 . . D RSLT(AUMH)
 . . D RSLT($TR(AUMH,"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-",$$REPEAT^XLFSTR("=",37)))
 . . S HDR=HDR_@$P(F1,";",1)_U
 . I '$G(AUMQ) D RSLT(AUMS),TAGCNT
 . I AUMM]"",(($G(AUMQ)=1)!(AUMM["ERR")) D RSLT(AUMS)
 . I $G(AUMQ)=1 D TAGCNT
 . S AUMP=1
 . ;I $D(AUMDEBUG),AUMM'["ERR",AUMM'["NEW",AUMM'["ADD" D  ; IHS/OIT/NKD AUM*14.0*2 - DEBUG TO INCLUDE ADD
 . I $D(AUMDEBUG),AUMM'["ERR",AUMM'["NEW" D
 . . Q:AUML']""
 . . F CNT=1:1:$L(AUML,U) I $P(AUML,U,CNT)]"" D RSLT($J("",4)_$P(AUML,U,CNT))
 Q
ERR(%) ; EP - ERROR MESSAGES
 S:'INA AUME="",AUMM="ERR :"
 D DISP,RSLT($J("",2)_%)
 Q
RSLT(%) ; EP - ISSUE MESSAGES DURING INSTALL
 D MES^XPDUTL(%)
 Q
 ;
CLEAN(X) ; EP - STRING CLEANING UTILITY
 N CNT,AUMS
 S AUMS=X
 S CNT=0 F  S CNT=$F(X," -") Q:'CNT  S $E(X,CNT-2,CNT-1)="-"
 S CNT=0 F  S CNT=$F(X,"- ") Q:'CNT  S $E(X,CNT-2,CNT-1)="-"
 S CNT=0 F  S CNT=$F(X,"  ") Q:'CNT  S $E(X,CNT-2,CNT-1)=" "
 I $E(X,1)=" " S X=$E(X,2,$L(X))
 I $E(X,$L(X))=" " S X=$E(X,1,$L(X)-1)
 Q X
TEXT(X) ; EP - STRING TO WP ARRAY USING '|' AS A DELIMITER
 N AUMS,I,J
 S AUMS=X,I=1,J=1
 K X
 F I=1:1:$L(AUMS,"|")  D
 . Q:$L($P(AUMS,"|",I))=0
 . ; IHS/OIT/NKD AUM*16.0*3 - START NEW CODE - NICE BREAKING OTHERWISE 80 CHARS
 . I $L($P(AUMS,"|",I))>80 D  Q
 . . N STR S STR=$P(AUMS,"|",I) F  Q:'$L(STR)  D
 . . . N BRK,TRY S BRK=0,TRY=$L(STR) D
 . . . . I TRY<81 S BRK=TRY Q
 . . . . F TRY=80:-1:2 D  Q:BRK
 . . . . . I $E(STR,TRY+1)=" " S $E(STR,TRY+1)="",BRK=TRY Q
 . . . . . I "&_+-*/<=>}])|:;,.?!"[$E(STR,TRY),$E(STR,TRY+1)=" " S BRK=TRY Q
 . . . . S:'BRK BRK=80
 . . . S X(J)=$E(STR,1,BRK),J=J+1,$E(STR,1,BRK)=""
 . ; IHS/OIT/NKD AUM*16.0*3 - END NEW CODE
 . S X(J)=$P(AUMS,"|",I),J=J+1
 Q
WPCHK(AUMWP1,AUMWP2) ; COMPARE WP ARRAYS AND RETURN 1 IF NOT EQUAL
 N CNT,AUMFR,AUMTO,AUMRES
 S AUMRES=0
 S CNT=0,AUMFR=0 F  S CNT=$O(AUMWP1(CNT)) Q:'CNT  S AUMFR=AUMFR+1
 S CNT=0,AUMTO=0 F  S CNT=$O(AUMWP2(CNT)) Q:'CNT  S AUMTO=AUMTO+1
 I AUMFR'=AUMTO S AUMRES=1
 E  F CNT=1:1:AUMTO S:$$CLEAN($G(AUMWP1(CNT)))'=$$CLEAN($G(AUMWP2(CNT))) AUMRES=1
 Q AUMRES
TAGCNT ; UPDATE LOCAL MODIFICATION COUNT AND DISPLAY IF TOTAL REACHED
 N AUMLA,AUMCNT,AUMCNT2,AUMCNT3
 S AUMLA=$P(AUMM," ")
 S AUMLA=$S(AUMLA="MOD":"MODIFIED",AUMLA="INA":"INACTIVE",AUMLA="DEL":"DELETE",AUMLA="ERR":"ERROR",1:AUMLA)
 S AUMLA=$S(AUMLA]"":AUMLA,1:"UNMODIFIED")
 S ^TMP("AUM",$J,"COUNT",AUMT,AUMLA)=$G(^TMP("AUM",$J,"COUNT",AUMT,AUMLA))+1
 S AUMCNT=$G(^TMP("AUM",$J,"COUNT",AUMT)),AUMCNT2=0
 S AUMCNT3="" F  S AUMCNT3=$O(^TMP("AUM",$J,"COUNT",AUMT,AUMCNT3)) Q:AUMCNT3']""  S AUMCNT2=AUMCNT2+$G(^TMP("AUM",$J,"COUNT",AUMT,AUMCNT3))
 Q:AUMCNT'=AUMCNT2
 D RSLT("")
 F AUMCNT3="NEW","ADD","MODIFIED","INACTIVE","DELETE","ERROR","UNMODIFIED" D
 . Q:($G(^TMP("AUM",$J,"COUNT",AUMT,AUMCNT3))'>0)
 . D RSLT(AUMCNT3_$$REPEAT^XLFSTR(".",11-$L(AUMCNT3))_$G(^TMP("AUM",$J,"COUNT",AUMT,AUMCNT3)))
 D RSLT("TOTAL......"_AUMCNT2)
 Q