ICDCODE ;DLS/DEK/KER/FJF - ICD CODE APIS ;04/21/2014
;;18.0;DRG Grouper;**6,12,14,29,57**;Oct 20, 2000;Build 7
;
; Global Variables
; ^TMP("ICDD") SACC 2.3.2.5.1
;
; External References
; $$DT^XLFDT ICR 10103
;
EN ; Main Entry Point
HELP ; Developer Help for an API
D HLP^ICDEXH("LEG") Q
;
ICDDX(CODE,CDT,DFN,SRC) ; Return ICD Dx Code Info
;
; Input:
;
; CODE Code/IEN (required)
; CDT Date (default = TODAY)
; DFN Not in use
; SRC Source
; 0 = exclude local codes
; 1 = include local codes
;
; Output:
;
; Returns an 19 piece string delimited by ^
;
; 1 IEN of code in file 80
; 2 ICD-9 Dx Code (#.01)
; 3 Id (#2)
; 4 Versioned Dx (67 multiple)
; 5 Unacceptable as Principal Dx (#101)
; 6 Major Dx Cat (#5)
; 7 MDC13 (5.5)
; 8 Compl/Comorb (#70)
; 9 ICD Expanded (#8) 1:Yes 0:No
; 10 Status (66 multiple)
; 11 Sex (#9.5)
; 12 Inactive Date (66 multiple)
; 13 MDC24 (#5.7)
; 14 MDC25 (#5.9)
; 15 Age Low (#14)
; 16 Age High (#15)
; 17 Activation Date (.01 of 66 multiple)
; 18 Message
; 19 Versioned Complication/Comorbidity (#103)
;
; or
;
; -1^Error Description
;
N X S X=$$ICDDX^ICDEX($S($G(CODE)?1N.N:$$CODEC^ICDEX(80,$G(CODE)),1:$G(CODE)),$G(CDT),1,,$G(SRC))
S $P(X,"^",3)=$TR($P(X,"^",3),";","")
Q X
ICDOP(CODE,CDT,DFN,SRC) ; Return ICD Operation/Procedure Code Info
;
; Input:
;
; CODE ICD code or IEN format, (required)
; CDT Date (default = TODAY)
; DFN Not in use
; SRC Source
; 0 = exclude local codes
; 1 = include local codes
;
; Output:
;
; Returns an 14 piece string delimited by ^
;
; 1 IEN of code in file 80.1
; 2 ICD-9 code (#.01)
; 3 Id (#2)
; 4 MDC24 (#5)
; 5 Versioned Oper/Proc (67 multiple)
; 6 <null>
; 7 <null>
; 8 <null>
; 9 ICD Expanded (#8) 1:Yes 0:No
; 10 Status (66 multiple)
; 11 Use with Sex (#9.5)
; 12 Inactive Date (66 multiple)
; 13 Activation Date (66 multiple)
; 14 Message
;
; or
;
; -1^Error Description
;
N X S X=$$ICDOP^ICDEX($S($G(CODE)?1N.N:$$CODEC^ICDEX(80.1,$G(CODE)),1:$G(CODE)),$G(CDT),2,,$G(SRC))
S $P(X,"^",3)=$TR($P(X,"^",3),";","")
Q X
ICDD(CODE,OUTARR,CDT) ; returns ICD description in array
;
; Input:
;
; CODE ICD Code (required)
; ARY Array Name for description
; e.g. "ABC" or "ABC("TEST")"
; Default = ^TMP("ICDD",$J)
; CDT Date (default = TODAY)
;
; Output:
;
; # Number of lines in array
;
; @ARY(1:n) - Versioned Description (68 multiple)
; @ARY(n+1) - blank
; @ARY(n+1) - message: CODE TEXT MAY BE INACCURATE
;
; or
;
; -1^Error Description
;
; ** NOTE - USER MUST INITIALIZE ^TMP("ICDD",$J), IF USED **
;
N ICDDXOUT,ICDDXARY,END,ICDDXI,ICDDXC
S ICDDXOUT=$$ICDD^ICDEX($G(CODE),.ICDDXARY,$G(CDT))
Q:ICDDXOUT["-1^Invalid" "-1^Invalid code"
Q:ICDDXOUT["-1^" ICDDXOUT
I $G(OUTARR)="" S OUTARR="^TMP(""ICDD"",$J,"
I OUTARR'["(" S OUTARR=OUTARR_"("
I OUTARR[")" S OUTARR=$P(OUTARR,")")
S END=$E(OUTARR,$L(OUTARR)) I END'="("&(END'=",") S OUTARR=OUTARR_","
I OUTARR="^TMP(""ICDD"",$J," K ^TMP("ICDD",$J)
S (ICDDXI,ICDDXC)=0 F S ICDDXI=$O(ICDDXARY(ICDDXI)) Q:+ICDDXI'>0 D
. N ARR S ARR=OUTARR_ICDDXI_")",@ARR=$G(ICDDXARY(ICDDXI)),ICDDXC=ICDDXC+1
Q ICDDXC
CODEN(CODE,FILE) ; return ien of ICD code
;
; Input:
;
; CODE ICD code (required)
; FILE File Number to search for code
; 80 = ICD Dx file
; 80.1 = ICD Oper/Proc file
;
; Output:
;
; IEN~global root
; or
; -1~error message
;
N X S X=$$CODEN^ICDEX($G(CODE),$G(FILE))
Q:X["-1~Invalid" "-1~Invalid code"
Q X
CODEC(IEN,FILE) ;return the ICD code of an ien
;Input:
; IEN IEN of ICD code REQUIRED
; FILE File Number to search for code
; 80 = ICD Dx file
; 80.1 = ICD Oper/Proc file
;
;Output: ICD code, -1 if not found
;
S:+($G(FILE))'>0 FILE=80
Q $$CODEC^ICDEX($G(FILE),$G(IEN))
CODEZ(CODE,ROOT,FLG) ; Based on IEN/root:
N Y,ICDL ; if 'FLG return code existence, else zero node - piece 1
S Y=$P($G(@(ROOT_CODE_",0)")),U),ICDL=$L(Y) I ICDL,'$G(FLG) Q CODE
Q $S('ICDL:-1,1:Y)
CODEBA(CODE,ROOT) ; Return IEN based on code/root
;
; Input:
;
; CODE ICD Code, either ICD-9 or ICD-10 (required)
; ROOT File Root or Number (required)
;
; Output:
;
; IEN IEN for CODE in ROOT or -1 if not found
;
Q $$CODEBA^ICDEX($G(CODE),$G(ROOT))
COMCOM(IEN,VDT) ; Return versioned complication/comorbidity
Q $$VCC^ICDEX($G(IEN),$G(CDT))
VST(IEN,VDT,FILE) ; Versioned Short Text
Q $$VST^ICDEX($G(FILE),$G(IEN),$G(CDT))
VSTD(IEN,VDT) ; Versioned Short Text (Dx)
Q $$VSTD^ICDEX($G(IEN),$G(CDT))
VSTP(IEN,VDT) ; Versioned Short Text (Proc)
Q $$VSTP^ICDEX($G(IEN),$G(CDT))
VLT(IEN,VDT,FILE) ; Version Description - Long Text
Q $$VLT^ICDEX($G(FILE),$G(IEN),$G(CDT))
VLTD(IEN,VDT) ; Versioned Description - Long Text (Dx)
Q $$VLTD^ICDEX($G(IEN),$G(CDT))
VLTP(IEN,VDT) ; Versioned Description - Long Text (Proc)
Q $$VLTP^ICDEX($G(IEN),$G(CDT))
ICDCODE ;DLS/DEK/KER/FJF - ICD CODE APIS ;04/21/2014
+1 ;;18.0;DRG Grouper;**6,12,14,29,57**;Oct 20, 2000;Build 7
+2 ;
+3 ; Global Variables
+4 ; ^TMP("ICDD") SACC 2.3.2.5.1
+5 ;
+6 ; External References
+7 ; $$DT^XLFDT ICR 10103
+8 ;
EN ; Main Entry Point
HELP ; Developer Help for an API
+1 DO HLP^ICDEXH("LEG")
QUIT
+2 ;
ICDDX(CODE,CDT,DFN,SRC) ; Return ICD Dx Code Info
+1 ;
+2 ; Input:
+3 ;
+4 ; CODE Code/IEN (required)
+5 ; CDT Date (default = TODAY)
+6 ; DFN Not in use
+7 ; SRC Source
+8 ; 0 = exclude local codes
+9 ; 1 = include local codes
+10 ;
+11 ; Output:
+12 ;
+13 ; Returns an 19 piece string delimited by ^
+14 ;
+15 ; 1 IEN of code in file 80
+16 ; 2 ICD-9 Dx Code (#.01)
+17 ; 3 Id (#2)
+18 ; 4 Versioned Dx (67 multiple)
+19 ; 5 Unacceptable as Principal Dx (#101)
+20 ; 6 Major Dx Cat (#5)
+21 ; 7 MDC13 (5.5)
+22 ; 8 Compl/Comorb (#70)
+23 ; 9 ICD Expanded (#8) 1:Yes 0:No
+24 ; 10 Status (66 multiple)
+25 ; 11 Sex (#9.5)
+26 ; 12 Inactive Date (66 multiple)
+27 ; 13 MDC24 (#5.7)
+28 ; 14 MDC25 (#5.9)
+29 ; 15 Age Low (#14)
+30 ; 16 Age High (#15)
+31 ; 17 Activation Date (.01 of 66 multiple)
+32 ; 18 Message
+33 ; 19 Versioned Complication/Comorbidity (#103)
+34 ;
+35 ; or
+36 ;
+37 ; -1^Error Description
+38 ;
+39 NEW X
SET X=$$ICDDX^ICDEX($SELECT($GET(CODE)?1N.N:$$CODEC^ICDEX(80,$GET(CODE)),1:$GET(CODE)),$GET(CDT),1,,$GET(SRC))
+40 SET $PIECE(X,"^",3)=$TRANSLATE($PIECE(X,"^",3),";","")
+41 QUIT X
ICDOP(CODE,CDT,DFN,SRC) ; Return ICD Operation/Procedure Code Info
+1 ;
+2 ; Input:
+3 ;
+4 ; CODE ICD code or IEN format, (required)
+5 ; CDT Date (default = TODAY)
+6 ; DFN Not in use
+7 ; SRC Source
+8 ; 0 = exclude local codes
+9 ; 1 = include local codes
+10 ;
+11 ; Output:
+12 ;
+13 ; Returns an 14 piece string delimited by ^
+14 ;
+15 ; 1 IEN of code in file 80.1
+16 ; 2 ICD-9 code (#.01)
+17 ; 3 Id (#2)
+18 ; 4 MDC24 (#5)
+19 ; 5 Versioned Oper/Proc (67 multiple)
+20 ; 6 <null>
+21 ; 7 <null>
+22 ; 8 <null>
+23 ; 9 ICD Expanded (#8) 1:Yes 0:No
+24 ; 10 Status (66 multiple)
+25 ; 11 Use with Sex (#9.5)
+26 ; 12 Inactive Date (66 multiple)
+27 ; 13 Activation Date (66 multiple)
+28 ; 14 Message
+29 ;
+30 ; or
+31 ;
+32 ; -1^Error Description
+33 ;
+34 NEW X
SET X=$$ICDOP^ICDEX($SELECT($GET(CODE)?1N.N:$$CODEC^ICDEX(80.1,$GET(CODE)),1:$GET(CODE)),$GET(CDT),2,,$GET(SRC))
+35 SET $PIECE(X,"^",3)=$TRANSLATE($PIECE(X,"^",3),";","")
+36 QUIT X
ICDD(CODE,OUTARR,CDT) ; returns ICD description in array
+1 ;
+2 ; Input:
+3 ;
+4 ; CODE ICD Code (required)
+5 ; ARY Array Name for description
+6 ; e.g. "ABC" or "ABC("TEST")"
+7 ; Default = ^TMP("ICDD",$J)
+8 ; CDT Date (default = TODAY)
+9 ;
+10 ; Output:
+11 ;
+12 ; # Number of lines in array
+13 ;
+14 ; @ARY(1:n) - Versioned Description (68 multiple)
+15 ; @ARY(n+1) - blank
+16 ; @ARY(n+1) - message: CODE TEXT MAY BE INACCURATE
+17 ;
+18 ; or
+19 ;
+20 ; -1^Error Description
+21 ;
+22 ; ** NOTE - USER MUST INITIALIZE ^TMP("ICDD",$J), IF USED **
+23 ;
+24 NEW ICDDXOUT,ICDDXARY,END,ICDDXI,ICDDXC
+25 SET ICDDXOUT=$$ICDD^ICDEX($GET(CODE),.ICDDXARY,$GET(CDT))
+26 IF ICDDXOUT["-1^Invalid"
QUIT "-1^Invalid code"
+27 IF ICDDXOUT["-1^"
QUIT ICDDXOUT
+28 IF $GET(OUTARR)=""
SET OUTARR="^TMP(""ICDD"",$J,"
+29 IF OUTARR'["("
SET OUTARR=OUTARR_"("
+30 IF OUTARR[")"
SET OUTARR=$PIECE(OUTARR,")")
+31 SET END=$EXTRACT(OUTARR,$LENGTH(OUTARR))
IF END'="("&(END'=",")
SET OUTARR=OUTARR_","
+32 IF OUTARR="^TMP(""ICDD"",$J,"
KILL ^TMP("ICDD",$JOB)
+33 SET (ICDDXI,ICDDXC)=0
FOR
SET ICDDXI=$ORDER(ICDDXARY(ICDDXI))
IF +ICDDXI'>0
QUIT
Begin DoDot:1
+34 NEW ARR
SET ARR=OUTARR_ICDDXI_")"
SET @ARR=$GET(ICDDXARY(ICDDXI))
SET ICDDXC=ICDDXC+1
End DoDot:1
+35 QUIT ICDDXC
CODEN(CODE,FILE) ; return ien of ICD code
+1 ;
+2 ; Input:
+3 ;
+4 ; CODE ICD code (required)
+5 ; FILE File Number to search for code
+6 ; 80 = ICD Dx file
+7 ; 80.1 = ICD Oper/Proc file
+8 ;
+9 ; Output:
+10 ;
+11 ; IEN~global root
+12 ; or
+13 ; -1~error message
+14 ;
+15 NEW X
SET X=$$CODEN^ICDEX($GET(CODE),$GET(FILE))
+16 IF X["-1~Invalid"
QUIT "-1~Invalid code"
+17 QUIT X
CODEC(IEN,FILE) ;return the ICD code of an ien
+1 ;Input:
+2 ; IEN IEN of ICD code REQUIRED
+3 ; FILE File Number to search for code
+4 ; 80 = ICD Dx file
+5 ; 80.1 = ICD Oper/Proc file
+6 ;
+7 ;Output: ICD code, -1 if not found
+8 ;
+9 IF +($GET(FILE))'>0
SET FILE=80
+10 QUIT $$CODEC^ICDEX($GET(FILE),$GET(IEN))
CODEZ(CODE,ROOT,FLG) ; Based on IEN/root:
+1 ; if 'FLG return code existence, else zero node - piece 1
NEW Y,ICDL
+2 SET Y=$PIECE($GET(@(ROOT_CODE_",0)")),U)
SET ICDL=$LENGTH(Y)
IF ICDL
IF '$GET(FLG)
QUIT CODE
+3 QUIT $SELECT('ICDL:-1,1:Y)
CODEBA(CODE,ROOT) ; Return IEN based on code/root
+1 ;
+2 ; Input:
+3 ;
+4 ; CODE ICD Code, either ICD-9 or ICD-10 (required)
+5 ; ROOT File Root or Number (required)
+6 ;
+7 ; Output:
+8 ;
+9 ; IEN IEN for CODE in ROOT or -1 if not found
+10 ;
+11 QUIT $$CODEBA^ICDEX($GET(CODE),$GET(ROOT))
COMCOM(IEN,VDT) ; Return versioned complication/comorbidity
+1 QUIT $$VCC^ICDEX($GET(IEN),$GET(CDT))
VST(IEN,VDT,FILE) ; Versioned Short Text
+1 QUIT $$VST^ICDEX($GET(FILE),$GET(IEN),$GET(CDT))
VSTD(IEN,VDT) ; Versioned Short Text (Dx)
+1 QUIT $$VSTD^ICDEX($GET(IEN),$GET(CDT))
VSTP(IEN,VDT) ; Versioned Short Text (Proc)
+1 QUIT $$VSTP^ICDEX($GET(IEN),$GET(CDT))
VLT(IEN,VDT,FILE) ; Version Description - Long Text
+1 QUIT $$VLT^ICDEX($GET(FILE),$GET(IEN),$GET(CDT))
VLTD(IEN,VDT) ; Versioned Description - Long Text (Dx)
+1 QUIT $$VLTD^ICDEX($GET(IEN),$GET(CDT))
VLTP(IEN,VDT) ; Versioned Description - Long Text (Proc)
+1 QUIT $$VLTP^ICDEX($GET(IEN),$GET(CDT))