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

AUMI10D.m

Go to the documentation of this file.
AUMI10D ;IHS/OIT/NKD - DRIVER FOR ICD10 - 09/04/2018 ;
 ;;19.0;ICD UPDATE;;SEP 04,2018;Build 1
 ;
 Q
POST ; EP - MAIN EP FR KIDS
 N HDR,ONE,AT,TAG,TMP,LOG,CNT,AUMDT
 S HDR="",ONE=1,AT="@",AUMDT=$G(^TMP("AUM",$J,"AUMDT"),$P($$NOW^XLFDT(),"."))
 ; BUILD MAP IN TMP
 F TAG="CM","PCS" S LOG=$NA(^TMP("AUM",$J,TAG)) D
 . S TMP=$O(^ICDS("B",$S(TAG="CM":"ICD-10-CM",TAG="PCS":"ICD-10-PCS",1:0),0)),TMP=$S(TMP:TMP,TAG="CM":30,TAG="PCS":31,1:0) Q:'TMP
 . S @LOG=TMP_U_$G(^ICDS(TMP,0))
 . F CNT=1:1 S TMP=$P($T(@(TAG)+CNT^AUMI10M),";;",2) Q:TMP="END"  S @LOG@("M",TMP)=$P($T(@(TAG)+CNT^AUMI10M),";;",3),@LOG@("M",TMP,$P($T(@(TAG)+CNT^AUMI10M),";;",4))=""
 . F CNT=1:1 S TMP=$P($T(@(TAG_"D")+CNT^AUMI10M),";;",2) Q:TMP="END"  S @LOG@($E(TMP))=$P($T(@(TAG_"D")+CNT^AUMI10M),";;",3)
 ; ITERATE THROUGH ENTRIES
 D RSLT($$REPEAT^XLFSTR("-",20))
 S CNT=0 F  S CNT=$O(^AUMDATA(CNT)) Q:'CNT  D
 . S TAG=$P($G(^AUMDATA(CNT,0)),U,2)
 . I $P($G(^AUMDATA(CNT-1,0)),U,2)'=TAG D HDR(TAG)
 . S ^TMP("AUM",$J,TAG,"C")=+$G(^TMP("AUM",$J,TAG,"C"))+1
 . D ENTRY(TAG,$P($G(^AUMDATA(CNT,0)),U,3,99),$NA(^TMP("AUM",$J,CNT)))
 . I $P($G(^AUMDATA(CNT+1,0)),U,2)'=TAG D FTR(TAG)
 ;
 Q
 ;
ENTRY(AUMT,AUMD,AUML) ; MAIN UPDATE DRIVER
 N P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P5A,INA,AUMC
 ; E=ERROR,I=IEN,M=MODIFY,P=PRINT
 N AUME,AUMI,AUMM,AUMP
 S (AUMI,AUMM)="",AUMP=0,INA=0,AUMT=$G(AUMT),AUMD=$G(AUMD),AUML=$G(AUML)
 F AUMC=1:1:12 S @("P"_AUMC)=$P(AUMD,U,AUMC)
 ; PRE-UPDATE
 D @(AUMT_"PRE^AUMI10U")
 ; SEARCH
 S:'AUMI AUMI=$$SEARCH(P1)
 ; INACTIVATE
 I INA D INACT
 ; NEW
 I 'INA,'AUMI D NEW
 Q:'AUMI
 ; UPDATE
 I 'INA D UPDATE
 ; DRG
 I 'INA D @(AUMT_"DRG^AUMI10U")
 ; DISPLAY
 D DISP
 ;
 Q
 ;
 N AUMI
 ; SEARCH BY CODE/SYS
 S AUMI=+$$CODEABA^ICDEX(AUMC,$$SYS(AUMT,4),$$SYS(AUMT,1))
 ; IF FOUND, STORE RESULTS OF API CALL (FOR COMPARISON)
 I AUMI>0,$$SYS(AUMT,4)=80 S @AUML=$$ICDDX^ICDEX(AUMI,AUMDT,$$SYS(AUMT,1),"I")_U_(+$P($G(^ICD9(AUMI,1)),U,9))
 I AUMI>0,$$SYS(AUMT,4)=80.1 S @AUML=$$ICDOP^ICDEX(AUMI,AUMDT,$$SYS(AUMT,1),"I")
 ;
 Q $S(AUMI>0:AUMI,1:0)
 ;
NEW ; GENERIC NEW ENTRY DRIVER
 N FDA,NEWIEN,ERR
 ;
 S FDA($$SYS(AUMT,4),"+1,",.01)=P1
 S FDA($$SYS(AUMT,4),"+1,",1.1)=$$SYS(AUMT,1)
 S NEWIEN(1)=$$IEN^AUMI10U($$SYS(AUMT,1))  ; GET NEXT AVAILABLE IEN BASED ON SYS
 ;
 D RLOG(AUML,"P1",,P1),UPDATE^DIE(,"FDA","NEWIEN","ERR")
 S AUMM="NEW :",AUMI=NEWIEN(1)
 I $D(ERR) D ERR("SYSTEM ERROR - New entry failed")
 ;
 Q
 ;
UPDATE ; GENERIC UPDATE DRIVER
 N AUMV,AUMFR,AUMTO,AUMCP,AUMNL,AUMFI,AUMFL,FDA,ERR
 ; ITERATE THROUGH MAPPED PIECES
 S AUMV="" F  S AUMV=$O(^TMP("AUM",$J,AUMT,"M",AUMV)) Q:AUMV']""  D
 . ; CP=COMPARE POINT, NL=NULL VALUE, FI=FILE #, FL=FIELD #
 . S AUMCP=$$MAP(AUMT,AUMV,1),AUMNL=$$MAP(AUMT,AUMV,2),AUMFI=$$MAP(AUMT,AUMV,3),AUMFL=$$MAP(AUMT,AUMV,4)
 . ; COMPARISON LOGIC
 . Q:'$D(@AUMV)  S AUMTO=$G(@AUMV)  ; TO VALUE
 . S AUMFR=$S(AUMCP?1N.N:$P($G(@AUML),U,AUMCP),AUMCP="VLT":$$VLT^ICDEX($$SYS(AUMT,4),AUMI,AUMDT),1:"")  ; FROM VALUE
 . S:'$L(AUMFR) AUMFR=AUMNL S:'$L(AUMTO) AUMTO=AUMNL  ; CONVERT ANY NULL VALUE
 . Q:AUMFR=AUMTO  ; QUIT IF NO CHANGE
 . ; BUILD FDA USING TO VALUES
 . D RLOG(AUML,AUMV,AUMFR,AUMTO)
 . I AUMFI=$$SYS(AUMT,4) S FDA(AUMFI,AUMI_",",AUMFL)=AUMTO Q  ; IF MAIN FILE, DON'T USE SUB-FILE LOGIC
 . I AUMV="P7",$D(FDA(AUMFI)) S FDA(AUMFI,"?+6,"_AUMI_",",AUMFL)=AUMTO Q  ; IF P6 CHANGED, USE THAT SUB-FILE PLACEHOLDER
 . S FDA(AUMFI,"?+"_+$TR(AUMV,"P")_","_AUMI_",",.01)=AUMDT
 . S FDA(AUMFI,"?+"_+$TR(AUMV,"P")_","_AUMI_",",AUMFL)=AUMTO
 . I AUMV="P7" S FDA(AUMFI,"?+7,"_AUMI_",",1)=$S($L($G(P6)):$G(P6),1:0)  ; IF P7 CHANGED BUT NOT P6, ADD P6 TO SUB-FILE CREATION
 ;
 I $D(FDA) D UPDATE^DIE(,"FDA",,"ERR") S:'$L(AUMM) AUMM="MOD :"
 I $D(ERR) D ERR("SYSTEM ERROR - Update failed")
 ;
 Q
 ;
INACT ; GENERIC INACTIVATE DRIVER
 N AUMV,AUMNL,AUMFI,AUMFL,FDA,ERR I 'AUMI D TAGCNT Q
 ; ITERATE THROUGH MAPPED PIECES
 S AUMV="" F  S AUMV=$O(^TMP("AUM",$J,AUMT,"M",AUMV)) Q:AUMV']""  D
 . ; NL=NULL VALUE, FI=FILE #, FL=FIELD #
 . S AUMNL=$$MAP(AUMT,AUMV,2),AUMFI=$$MAP(AUMT,AUMV,3),AUMFL=$$MAP(AUMT,AUMV,4)
 . ; ONLY NULL OUT STATUS FIELD
 . Q:'$D(@AUMV)  Q:+$TR(AUMV,"P")>2
 . ; BUILD FDA USING DEFINED NULL VALUES
 . I AUMFI=$$SYS(AUMT,4) S FDA(AUMFI,AUMI_",",AUMFL)=AUMNL Q  ; IF MAIN FILE, DON'T USE SUB-FILE LOGIC
 . I AUMV="P7",$D(FDA(AUMFI)) S FDA(AUMFI,"?+6,"_AUMI_",",AUMFL)=AUMNL Q  ; IF P6 CHANGED, USE THAT SUB-FILE PLACEHOLDER
 . S FDA(AUMFI,"?+"_+$TR(AUMV,"P")_","_AUMI_",",.01)=AUMDT
 . S FDA(AUMFI,"?+"_+$TR(AUMV,"P")_","_AUMI_",",AUMFL)=AUMNL
 ;
 I $D(FDA) D RLOG(AUML,"P2",1,0),UPDATE^DIE(,"FDA",,"ERR") S AUMM="INA :"
 I $D(ERR) D ERR("SYSTEM ERROR - Inactivate failed")
 ;
 Q
 ;
DISP ; GENERIC DISPLAY DRIVER
 N AUMF1,AUMF2,AUMF3,AUMF4,AUMC,INAD,AUMS,AUMH,AUMD0,AUMD1,AUMV Q:AUMP
 ;
 S AUMS="",AUMP=1,INAD=$S(INA:"I",1:"") I AUMM]"" D
 . S AUMD0=$G(^TMP("AUM",$J,AUMT,"D")) F AUMC=1:1:$L(AUMD0,";") S AUMD1=$P(AUMD0,";",AUMC) D
 . . S AUMF1=$P(AUMD1,"|",1),AUMF2=$P(AUMD1,"|",2),AUMF3=$P(AUMD1,"|",3),AUMF4=$P(AUMD1,"|",4),AUMV=""
 . . S AUMV=$E($S('AUMF3:$G(@AUMF1),AUMF3>1:$P($G(@AUML@("R",AUMF1)),U,AUMF3),1:""),1,AUMF2)
 . . I '$L(AUMV),AUMF3>1,$L($G(@AUML@("R",AUMF1))) S AUMV="@"
 . . I $L(AUMV),$L(AUMF4) S AUMV=AUMF4
 . . S AUMS=AUMS_AUMV_$J("",AUMF2+1-$L(AUMV))
 . D RSLT(AUMS)
 ;
 D TAGCNT
 ;
 Q
 ;
SYS(T,P)  ; EP - RETURN SYS DATA
 S T=$G(T,$G(AUMT)),P=$G(P,1) Q $S('$L(T):"",1:$P($G(^TMP("AUM",$J,T)),U,P))
 ;
MAP(T,V,P)  ; RETURN MAP DATA
 S T=$G(T,$G(AUMT)),V=$G(V),P=$G(P,1) Q $S('$L(T)!('$L(V)):"",1:$P($G(^TMP("AUM",$J,T,"M",V)),U,P))
 ;
RLOG(GL,VN,V1,V2)  ; EP - LOG RESULT TO TMP
 S GL=$G(GL),VN=$G(VN),V1=$G(V1),V2=$G(V2) Q:'$L(GL)  Q:'$L(VN)
 S @GL@("R",VN)=V1_U_V2
 Q
 ;
TAGCNT ; UPDATE LOCAL MODIFICATION COUNT AND DISPLAY IF TOTAL REACHED
 N AUMA,AUMV,AUMF
 ;
 S AUMA=$S($L($P(AUMM," ")):$P(AUMM," "),1:"UNM")
 S ^TMP("AUM",$J,AUMT,"C",AUMA)=+$G(^TMP("AUM",$J,AUMT,"C",AUMA))+1
 Q:AUMA'="MOD"
 ;
 S AUMF="" F  S AUMF=$O(@AUML@("R",AUMF)) Q:'$L(AUMF)  D
 . S AUMV=$S($E(AUMF)="P":$O(^TMP("AUM",$J,AUMT,"M",AUMF,"")),1:AUMF) S:'$L(AUMV) AUMV="UNKNOWN"
 . S ^TMP("AUM",$J,AUMT,"C","F",AUMV)=+$G(^TMP("AUM",$J,AUMT,"C","F",AUMV))+1
 ;
 Q
 ;
HDR(AUMT)  ; DISPLAY TABLE HEADER
 N AUMS,AUMF0,AUMF1,AUMF2,AUMF3,AUMC S AUMT=$G(AUMT) Q:'$L(AUMT)  Q:'$D(^TMP("AUM",$J,AUMT,"H"))
 ;
 S AUMF0=$G(^TMP("AUM",$J,AUMT,"H"))
 S AUMF1=$P(AUMF0,U),AUMS=$P(AUMF1,";",2) D RSLT(AUMS,1)
 S AUMF1=$P(AUMF0,U,2),AUMS="" F AUMC=1:1:$L(AUMF1,";") S AUMF2=$P($P(AUMF1,";",AUMC),"|"),AUMF3=$P($P(AUMF1,";",AUMC),"|",2),AUMS=AUMS_$J("",AUMF3-$L(AUMS))_AUMF2
 ;
 D RSLT(AUMS),RSLT($TR(AUMS,"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-",$$REPEAT^XLFSTR("=",37)))
 ;
 Q
 ;
FTR(AUMT)  ; DISPLAY TABLE FOOTER
 N AUMA,AUMC,TOT S TOT=+$G(^TMP("AUM",$J,AUMT,"C")) D RSLT("") I 'TOT D RSLT($$REPEAT^XLFSTR("-",20)) Q
 ;
 F AUMA="NEW","MODIFIED","INACTIVE","ERROR","UNMODIFIED" D
 . S AUMC=+$G(^TMP("AUM",$J,AUMT,"C",$E(AUMA,1,3))) Q:'AUMC
 . D RSLT(AUMA_$$REPEAT^XLFSTR(".",15-$L(AUMA))_AUMC)
 . Q:AUMA'="MODIFIED"
 . S AUMC="" F  S AUMC=$O(^TMP("AUM",$J,AUMT,"C","F",AUMC)) Q:'$L(AUMC)  D RSLT("  "_AUMC_$$REPEAT^XLFSTR(".",13-$L(AUMC))_(+$G(^TMP("AUM",$J,AUMT,"C","F",AUMC))))
 D RSLT("TOTAL.........."_TOT),RSLT($$REPEAT^XLFSTR("-",20))
 ;
 Q
 ;
RSLT(%,LINE) ; ISSUE MESSAGES DURING INSTALL
 I $D(LINE) D MES^XPDUTL("")
 D MES^XPDUTL(%)
 Q
 ;
ERR(%) ; ERROR MESSAGES
 S:'INA AUME="",AUMM="ERR :"
 D DISP,RSLT($J("",2)_%)
 K DIERR
 Q
 ;