FBICD9 ;AISC/JLG - ICD-9 DIAGNOSIS CODE UTILITIES ;3/14/2013
;;3.5;FEE BASIS;**139**;JAN 30, 1995;Build 127
;;Per VA Directive 6402, this routine should not be modified.
;
; References to API $$IMPDATE^LEXU supported by ICR #5679
; Reference to API $$FILE^ICDEX supported by ICR #5747
; Reference to API $$ROOT^ICDEX supported by ICR #5747
; Reference to API $$SYS^ICDEX supported by ICR #5747
; Reference to API $$ICDDX^ICDEX supported by ICR #5747
;
; Input - FBIDT= date of interest to check FBPRMT= user prompt FBALW= allow user to early exit if set to Y
; ALDEL= allow deletion of DX field? (optional) -if this is set to "Y", @ is an acceptable entry
; ALFREQ= allow forcing a field to be required (optional) -if this is set to "Y", the field will be forced to be required
; FBDFLT= default values for the search string (can be a code by default)
; Output- Y = IEN^ICD9 code OR -1^inactive code"
ENICD9(FBIDT,FBPRMT,FBALW,ALDEL,ALFREQ,FBDFLT) ; prompt user for ICD9 diagnosis code and test if code is inactive
N X,Y,DIC,DIR
S:'$D(FBALW) FBALW="N" ; early exit allow flag
S:'$D(ALDEL) ALDEL="N" ; delete allow flag
S:'$D(ALFREQ) ALFREQ="N" ; force required allow flag
SRCH1 ;
S Y=$$SEARCH(FBIDT)
I (Y>0)&('$$ICD9ACT(+Y,FBIDT)) D
. W !!,*7,"ICD Dx Code "_"("_$P(Y,U,2)_")"_" inactive on date of service ("_$$FMTE^XLFDT(FBIDT)_").",!
. S Y="-1^inactive code"
. Q
Q Y
;
; Input -FBINDT = ICD versioning date
; Output -Y = IEN^ICD9 code
SEARCH(FBINDT) ;
I $G(FBDFLT)>0 S DIR("A")=FBPRMT_": "_$P($$ICDDX^ICDEX(FBDFLT,FBIDT,1,"I"),"^",2)_"// "
E S DIR("A")=FBPRMT_": "
S DIR(0)="FAOr^0:245"
S DIR("?")="Answer with ICD DIAGNOSIS CODE NUMBER, or DESCRIPTION"
D ^DIR K DIR
I ((X="@")&(ALFREQ="Y")) W "?? REQUIRED" G SRCH1
I X="@",ALDEL="Y",$G(FBDFLT)="" S ALDEL="N"
I X="@",ALDEL="Y" N FBYN D Q:FBYN=1 "@" G SRCH1
. S FBYN=$$QUESTION^FBASF(2,"SURE YOU WANT TO DELETE")
. I FBYN'=1 W " <NOTHING DELETED>"
I X="@" W "??" G SRCH1
I X="^",FBALW="Y" Q -1
I X="^" W !,?4,"EXIT NOT ALLOWED ??" G SRCH1
N ROOT,FILE,SYS,ICDVDT,FILEID,SCREEN,DISFIL
S FILEID=80,SCREEN="I $$CHKVERS^FBICD9(+Y,FBINDT)",DISFIL="EIMQ"
S FILE=$$FILE^ICDEX($G(FILEID)) Q:+FILE'>0 -1
S (DIC,ROOT)=$$ROOT^ICDEX(FILE) Q:'$L(ROOT) -1
S DIC("S")=$S($L($G(SCREEN)):$G(SCREEN),1:"I 1")
S:$G(FBINDT) ICDVDT=$G(FBINDT)
S SYS=$$SYS^ICDEX(FILE,$G(ICDVDT)) S:+SYS>0 ICDSYS=+SYS
S DISFIL=$G(DISFIL,"EMQZ") S DISFIL=$TR(DISFIL,"L","") K DLAYGO
S DIC(0)=DISFIL D ^DIC K DIC,ICDSYS,ICDFMT
S:+($G(Y))'>0 Y=-1
G:((Y=-1)&($L(X)>0)) SRCH1
Q Y
;
;Input : Y (ien of file 80), (date of interest)
;Output: 1 (true) or 0 (false)
CHKVERS(FBDIRY,FBDT) ; return true (1) if diagnosis code is a current versioned ICD code, otherwise return false (0)
N FBICDSYS,FBINF,FBIC9SYS
S FBICDSYS=$S(FBDT<$$IMPDATE^LEXU(30):1,1:30) ; 1 = icd-9 version 30 = icd-10 version
S FBIC9SYS=$P($$ICDDX^ICDEX(FBDIRY,FBDT,"","I"),U,20) ; 1 = icd-9 version 30 = icd-10 version
Q:FBICDSYS=FBIC9SYS 1 ; returns true
Q 0 ; returns false
;
ICD9ACT(IEN,FBDT) ;Is the given code active for the date? (default-today)
N FBINF,FBRES
I '$G(FBDT) S FBDT=DT
S FBRES=0
S FBINF=$$ICDDX^ICDEX(IEN,FBDT,"","I")
I FBINF'<0,$P(FBINF,U,10) S FBRES=1
Q FBRES
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HFBICD9 3354 printed Oct 16, 2024@17:59:23 Page 2
FBICD9 ;AISC/JLG - ICD-9 DIAGNOSIS CODE UTILITIES ;3/14/2013
+1 ;;3.5;FEE BASIS;**139**;JAN 30, 1995;Build 127
+2 ;;Per VA Directive 6402, this routine should not be modified.
+3 ;
+4 ; References to API $$IMPDATE^LEXU supported by ICR #5679
+5 ; Reference to API $$FILE^ICDEX supported by ICR #5747
+6 ; Reference to API $$ROOT^ICDEX supported by ICR #5747
+7 ; Reference to API $$SYS^ICDEX supported by ICR #5747
+8 ; Reference to API $$ICDDX^ICDEX supported by ICR #5747
+9 ;
+10 ; Input - FBIDT= date of interest to check FBPRMT= user prompt FBALW= allow user to early exit if set to Y
+11 ; ALDEL= allow deletion of DX field? (optional) -if this is set to "Y", @ is an acceptable entry
+12 ; ALFREQ= allow forcing a field to be required (optional) -if this is set to "Y", the field will be forced to be required
+13 ; FBDFLT= default values for the search string (can be a code by default)
+14 ; Output- Y = IEN^ICD9 code OR -1^inactive code"
ENICD9(FBIDT,FBPRMT,FBALW,ALDEL,ALFREQ,FBDFLT) ; prompt user for ICD9 diagnosis code and test if code is inactive
+1 NEW X,Y,DIC,DIR
+2 ; early exit allow flag
if '$DATA(FBALW)
SET FBALW="N"
+3 ; delete allow flag
if '$DATA(ALDEL)
SET ALDEL="N"
+4 ; force required allow flag
if '$DATA(ALFREQ)
SET ALFREQ="N"
SRCH1 ;
+1 SET Y=$$SEARCH(FBIDT)
+2 IF (Y>0)&('$$ICD9ACT(+Y,FBIDT))
Begin DoDot:1
+3 WRITE !!,*7,"ICD Dx Code "_"("_$PIECE(Y,U,2)_")"_" inactive on date of service ("_$$FMTE^XLFDT(FBIDT)_").",!
+4 SET Y="-1^inactive code"
+5 QUIT
End DoDot:1
+6 QUIT Y
+7 ;
+8 ; Input -FBINDT = ICD versioning date
+9 ; Output -Y = IEN^ICD9 code
SEARCH(FBINDT) ;
+1 IF $GET(FBDFLT)>0
SET DIR("A")=FBPRMT_": "_$PIECE($$ICDDX^ICDEX(FBDFLT,FBIDT,1,"I"),"^",2)_"// "
+2 IF '$TEST
SET DIR("A")=FBPRMT_": "
+3 SET DIR(0)="FAOr^0:245"
+4 SET DIR("?")="Answer with ICD DIAGNOSIS CODE NUMBER, or DESCRIPTION"
+5 DO ^DIR
KILL DIR
+6 IF ((X="@")&(ALFREQ="Y"))
WRITE "?? REQUIRED"
GOTO SRCH1
+7 IF X="@"
IF ALDEL="Y"
IF $GET(FBDFLT)=""
SET ALDEL="N"
+8 IF X="@"
IF ALDEL="Y"
NEW FBYN
Begin DoDot:1
+9 SET FBYN=$$QUESTION^FBASF(2,"SURE YOU WANT TO DELETE")
+10 IF FBYN'=1
WRITE " <NOTHING DELETED>"
End DoDot:1
if FBYN=1
QUIT "@"
GOTO SRCH1
+11 IF X="@"
WRITE "??"
GOTO SRCH1
+12 IF X="^"
IF FBALW="Y"
QUIT -1
+13 IF X="^"
WRITE !,?4,"EXIT NOT ALLOWED ??"
GOTO SRCH1
+14 NEW ROOT,FILE,SYS,ICDVDT,FILEID,SCREEN,DISFIL
+15 SET FILEID=80
SET SCREEN="I $$CHKVERS^FBICD9(+Y,FBINDT)"
SET DISFIL="EIMQ"
+16 SET FILE=$$FILE^ICDEX($GET(FILEID))
if +FILE'>0
QUIT -1
+17 SET (DIC,ROOT)=$$ROOT^ICDEX(FILE)
if '$LENGTH(ROOT)
QUIT -1
+18 SET DIC("S")=$SELECT($LENGTH($GET(SCREEN)):$GET(SCREEN),1:"I 1")
+19 if $GET(FBINDT)
SET ICDVDT=$GET(FBINDT)
+20 SET SYS=$$SYS^ICDEX(FILE,$GET(ICDVDT))
if +SYS>0
SET ICDSYS=+SYS
+21 SET DISFIL=$GET(DISFIL,"EMQZ")
SET DISFIL=$TRANSLATE(DISFIL,"L","")
KILL DLAYGO
+22 SET DIC(0)=DISFIL
DO ^DIC
KILL DIC,ICDSYS,ICDFMT
+23 if +($GET(Y))'>0
SET Y=-1
+24 if ((Y=-1)&($LENGTH(X)>0))
GOTO SRCH1
+25 QUIT Y
+26 ;
+27 ;Input : Y (ien of file 80), (date of interest)
+28 ;Output: 1 (true) or 0 (false)
CHKVERS(FBDIRY,FBDT) ; return true (1) if diagnosis code is a current versioned ICD code, otherwise return false (0)
+1 NEW FBICDSYS,FBINF,FBIC9SYS
+2 ; 1 = icd-9 version 30 = icd-10 version
SET FBICDSYS=$SELECT(FBDT<$$IMPDATE^LEXU(30):1,1:30)
+3 ; 1 = icd-9 version 30 = icd-10 version
SET FBIC9SYS=$PIECE($$ICDDX^ICDEX(FBDIRY,FBDT,"","I"),U,20)
+4 ; returns true
if FBICDSYS=FBIC9SYS
QUIT 1
+5 ; returns false
QUIT 0
+6 ;
ICD9ACT(IEN,FBDT) ;Is the given code active for the date? (default-today)
+1 NEW FBINF,FBRES
+2 IF '$GET(FBDT)
SET FBDT=DT
+3 SET FBRES=0
+4 SET FBINF=$$ICDDX^ICDEX(IEN,FBDT,"","I")
+5 IF FBINF'<0
IF $PIECE(FBINF,U,10)
SET FBRES=1
+6 QUIT FBRES
+7 ;