ICDXCODE ;ISL/KER - ICD basic data API's ;04/21/2014
;;18.0;DRG Grouper;**57**;Oct 20, 2000;Build 7
;
; ICD wrapper APIs
;
EN ; Main Entry Point
HELP ; Developer Help for an API
D HLP^ICDEXH("SDD") Q
;
ICDDATA(CSYS,CODE,DATE,FRMT) ; ICD data for code
;
; Input:
;
; CSYS Coding system Required
; CODE Code/IEN/variable pointer Required
; DATE Code Set Date (default = TODAY)
; FRMT Code format "E" external (default)
; "I" internal (IEN)
;
; Output:
;
; Diagnosis returns an 22 piece string delimited by "^"
;
; 1 IEN of code in file 80
; 2 ICD-9 Dx Code (#.01)
; 3 Identifier (#1.2)
; 4 Versioned Dx (67 multiple)
; 5 Unacceptable as Principal Dx (#1.3)
; 6 Major Dx Cat (72 multiple)
; 7 MDC13 (#1.4)
; 8 Compl/Comorb (103 multiple)
; 9 ICD Expanded (#1.7)
; 10 Status (66 multiple)
; 11 Sex (10 multiple)
; 12 Inactive Date (66 multiple)
; 13 MDC24 (#1.5)
; 14 MDC25 (#1.6)
; 15 Age Low (11 multiple)
; 16 Age High (12 multiple)
; 17 Activation Date (66 multiple)
; 18 Message
; 19 Complication/Comorbidity (103 multiple)
; 20 Coding System (#1.1)
; 21 Primary CC Flag (103 multiple)
; 22 PDX Exclusion Code (#1.11)
;
; Procedures returns A 14 piece string delimited by "^"
;
; 1 IEN of code in file 80.1
; 2 ICD procedure code (#.01)
; 3 Identifier (#1.2)
; 4 MDC24 (#1.5)
; 5 Versioned Oper/Proc (67 multiple)
; 6 <null>
; 7 <null>
; 8 <null>
; 9 ICD Expanded (#1.7)
; 10 Status (66 multiple)
; 11 Use with Sex (10 multiple)
; 12 Inactive Date (66 multiple)
; 13 Activation Date (66 multiple)
; 14 Message
; 15 Coding System (#1.1)
;
; or
;
; -1^Error Description
;
N ROOT,SYS
S DATE=$P($G(DATE),".",1),SYS=$$SYS^ICDEX($G(CSYS),$G(DATE)) S:+SYS'>0 SYS=$$SYS^ICDEX($G(CODE))
Q:+SYS'>0 "-1^Invalid coding system specified"
S ROOT=$$ROOT^ICDEX(SYS) Q:'$L(ROOT) "-1^Invalid Global Root"
S:CODE[";"&($P(CODE,";",2)=$TR(ROOT,"^",""))&($L($P(CODE,";",1))) FRMT="I",CODE=$P(CODE,";",1)
S:'$L($G(FRMT)) FRMT=$$IE^ICDEX($G(CODE))
Q:ROOT["ICD9" $$ICDDX^ICDEX($G(CODE),$G(DATE),$G(SYS),$G(FRMT))
Q:ROOT["ICD0" $$ICDOP^ICDEX($G(CODE),$G(DATE),$G(SYS),$G(FRMT))
Q "-1^Not found"
;
ICDDESC(CSYS,CODE,DATE,OUTARR) ; ICD description
;
; Input:
;
; CSYS Coding system
; CODE ICD Code (required)
; DATE Date (default = TODAY)
; .OUTARR Array Name passed by reference
;
; Output:
;
; $$ICDDESC Number of lines in array
;
; @ARY(1) - Versioned Description (68 multiple)
; @ARY(2) - blank
; @ARY(3) - message: CODE TEXT MAY BE INACCURATE
;
Q $$ICDD^ICDEX($G(CODE),.OUTARR,$G(DATE),$G(CSYS))
;
STATCHK(CSYS,CODE,DATE) ; Check status for code
;
; Input:
;
; CSYS Coding system
; CODE Code (IEN not allowed)
; DATE Date (default = TODAY)
;
; Output:
;
; 2-Piece String containing the code's status
; and the IEN if the code exists, else -1.
; The following are possible outputs:
;
; 1^IEN^Effective Date Active Code
; 0^IEN^Effective Date Inactive Code
; 0^-1 Code not Found
;
Q $$STATCHK^ICDEX($G(CODE),$G(DATE),$G(CSYS))
;
PREV(CSYS,CODE) ; Previous ICD Code
;
; Input:
;
; CSYS Coding system Required
; CODE ICD-10 Code (IEN not allowed) Required
;
; Output:
;
; $$PREV The Previous ICD Code, Null if none
;
Q $$PREV^ICDEX($G(CODE),$G(CSYS))
;
NEXT(CSYS,CODE) ; Next ICD Code
;
; Input:
;
; CSYS Coding system Required
; CODE ICD-10 Code (IEN not allowed) Required
;
; Output:
;
; $$NEXT The Next ICD Code, Null if none
;
Q $$NEXT^ICDEX($G(CODE),$G(CSYS))
;
HIST(CSYS,CODE,ARRAY) ; Activation History
;
; Input:
;
; CSYS Coding system Required
; CODE ICD Code (IEN not allowed) Required
; .ARRAY Array, passed by Reference Required
;
; Output:
;
; $$HIST Mirrors ARRAY(0) or, -1 on error
; ARRAY(0) = Number of Activation History Entries
; ARRAY(<date>) = Status where: 1 is Active
; ARRAY("IEN") = <ien>
;
Q $$HIST^ICDEX($G(CODE),.ARRAY,$G(CSYS))
;
PERIOD(CSYS,CODE,ARY) ; Activation Periods
; Input:
;
; CSYS Coding system Required
; CODE ICD Code (IEN not allowed) Required
; .ARY Array, passed by Reference Required
;
; Output:
;
; ARY(0) = IEN ^ Selectable ^ Error Message
;
; Where IEN = -1 if error
; Selectable = 0 for unselectable
; Error Message if applicable
;
; ARY(Activation Date) = Inactivation Date^Short Name
;
; Where the Short Name is versioned as follows:
;
; Period is active - Text for TODAY's date
; Period is inactive - Text for inactivation date
;
Q $$PERIOD^ICDEX($G(CODE),.ARY,$G(CSYS))
ICDXCODE ;ISL/KER - ICD basic data API's ;04/21/2014
+1 ;;18.0;DRG Grouper;**57**;Oct 20, 2000;Build 7
+2 ;
+3 ; ICD wrapper APIs
+4 ;
EN ; Main Entry Point
HELP ; Developer Help for an API
+1 DO HLP^ICDEXH("SDD")
QUIT
+2 ;
ICDDATA(CSYS,CODE,DATE,FRMT) ; ICD data for code
+1 ;
+2 ; Input:
+3 ;
+4 ; CSYS Coding system Required
+5 ; CODE Code/IEN/variable pointer Required
+6 ; DATE Code Set Date (default = TODAY)
+7 ; FRMT Code format "E" external (default)
+8 ; "I" internal (IEN)
+9 ;
+10 ; Output:
+11 ;
+12 ; Diagnosis returns an 22 piece string delimited by "^"
+13 ;
+14 ; 1 IEN of code in file 80
+15 ; 2 ICD-9 Dx Code (#.01)
+16 ; 3 Identifier (#1.2)
+17 ; 4 Versioned Dx (67 multiple)
+18 ; 5 Unacceptable as Principal Dx (#1.3)
+19 ; 6 Major Dx Cat (72 multiple)
+20 ; 7 MDC13 (#1.4)
+21 ; 8 Compl/Comorb (103 multiple)
+22 ; 9 ICD Expanded (#1.7)
+23 ; 10 Status (66 multiple)
+24 ; 11 Sex (10 multiple)
+25 ; 12 Inactive Date (66 multiple)
+26 ; 13 MDC24 (#1.5)
+27 ; 14 MDC25 (#1.6)
+28 ; 15 Age Low (11 multiple)
+29 ; 16 Age High (12 multiple)
+30 ; 17 Activation Date (66 multiple)
+31 ; 18 Message
+32 ; 19 Complication/Comorbidity (103 multiple)
+33 ; 20 Coding System (#1.1)
+34 ; 21 Primary CC Flag (103 multiple)
+35 ; 22 PDX Exclusion Code (#1.11)
+36 ;
+37 ; Procedures returns A 14 piece string delimited by "^"
+38 ;
+39 ; 1 IEN of code in file 80.1
+40 ; 2 ICD procedure code (#.01)
+41 ; 3 Identifier (#1.2)
+42 ; 4 MDC24 (#1.5)
+43 ; 5 Versioned Oper/Proc (67 multiple)
+44 ; 6 <null>
+45 ; 7 <null>
+46 ; 8 <null>
+47 ; 9 ICD Expanded (#1.7)
+48 ; 10 Status (66 multiple)
+49 ; 11 Use with Sex (10 multiple)
+50 ; 12 Inactive Date (66 multiple)
+51 ; 13 Activation Date (66 multiple)
+52 ; 14 Message
+53 ; 15 Coding System (#1.1)
+54 ;
+55 ; or
+56 ;
+57 ; -1^Error Description
+58 ;
+59 NEW ROOT,SYS
+60 SET DATE=$PIECE($GET(DATE),".",1)
SET SYS=$$SYS^ICDEX($GET(CSYS),$GET(DATE))
IF +SYS'>0
SET SYS=$$SYS^ICDEX($GET(CODE))
+61 IF +SYS'>0
QUIT "-1^Invalid coding system specified"
+62 SET ROOT=$$ROOT^ICDEX(SYS)
IF '$LENGTH(ROOT)
QUIT "-1^Invalid Global Root"
+63 IF CODE[";"&($PIECE(CODE,";",2)=$TRANSLATE(ROOT,"^",""))&($LENGTH($PIECE(CODE,";",1)))
SET FRMT="I"
SET CODE=$PIECE(CODE,";",1)
+64 IF '$LENGTH($GET(FRMT))
SET FRMT=$$IE^ICDEX($GET(CODE))
+65 IF ROOT["ICD9"
QUIT $$ICDDX^ICDEX($GET(CODE),$GET(DATE),$GET(SYS),$GET(FRMT))
+66 IF ROOT["ICD0"
QUIT $$ICDOP^ICDEX($GET(CODE),$GET(DATE),$GET(SYS),$GET(FRMT))
+67 QUIT "-1^Not found"
+68 ;
ICDDESC(CSYS,CODE,DATE,OUTARR) ; ICD description
+1 ;
+2 ; Input:
+3 ;
+4 ; CSYS Coding system
+5 ; CODE ICD Code (required)
+6 ; DATE Date (default = TODAY)
+7 ; .OUTARR Array Name passed by reference
+8 ;
+9 ; Output:
+10 ;
+11 ; $$ICDDESC Number of lines in array
+12 ;
+13 ; @ARY(1) - Versioned Description (68 multiple)
+14 ; @ARY(2) - blank
+15 ; @ARY(3) - message: CODE TEXT MAY BE INACCURATE
+16 ;
+17 QUIT $$ICDD^ICDEX($GET(CODE),.OUTARR,$GET(DATE),$GET(CSYS))
+18 ;
STATCHK(CSYS,CODE,DATE) ; Check status for code
+1 ;
+2 ; Input:
+3 ;
+4 ; CSYS Coding system
+5 ; CODE Code (IEN not allowed)
+6 ; DATE Date (default = TODAY)
+7 ;
+8 ; Output:
+9 ;
+10 ; 2-Piece String containing the code's status
+11 ; and the IEN if the code exists, else -1.
+12 ; The following are possible outputs:
+13 ;
+14 ; 1^IEN^Effective Date Active Code
+15 ; 0^IEN^Effective Date Inactive Code
+16 ; 0^-1 Code not Found
+17 ;
+18 QUIT $$STATCHK^ICDEX($GET(CODE),$GET(DATE),$GET(CSYS))
+19 ;
PREV(CSYS,CODE) ; Previous ICD Code
+1 ;
+2 ; Input:
+3 ;
+4 ; CSYS Coding system Required
+5 ; CODE ICD-10 Code (IEN not allowed) Required
+6 ;
+7 ; Output:
+8 ;
+9 ; $$PREV The Previous ICD Code, Null if none
+10 ;
+11 QUIT $$PREV^ICDEX($GET(CODE),$GET(CSYS))
+12 ;
NEXT(CSYS,CODE) ; Next ICD Code
+1 ;
+2 ; Input:
+3 ;
+4 ; CSYS Coding system Required
+5 ; CODE ICD-10 Code (IEN not allowed) Required
+6 ;
+7 ; Output:
+8 ;
+9 ; $$NEXT The Next ICD Code, Null if none
+10 ;
+11 QUIT $$NEXT^ICDEX($GET(CODE),$GET(CSYS))
+12 ;
HIST(CSYS,CODE,ARRAY) ; Activation History
+1 ;
+2 ; Input:
+3 ;
+4 ; CSYS Coding system Required
+5 ; CODE ICD Code (IEN not allowed) Required
+6 ; .ARRAY Array, passed by Reference Required
+7 ;
+8 ; Output:
+9 ;
+10 ; $$HIST Mirrors ARRAY(0) or, -1 on error
+11 ; ARRAY(0) = Number of Activation History Entries
+12 ; ARRAY(<date>) = Status where: 1 is Active
+13 ; ARRAY("IEN") = <ien>
+14 ;
+15 QUIT $$HIST^ICDEX($GET(CODE),.ARRAY,$GET(CSYS))
+16 ;
PERIOD(CSYS,CODE,ARY) ; Activation Periods
+1 ; Input:
+2 ;
+3 ; CSYS Coding system Required
+4 ; CODE ICD Code (IEN not allowed) Required
+5 ; .ARY Array, passed by Reference Required
+6 ;
+7 ; Output:
+8 ;
+9 ; ARY(0) = IEN ^ Selectable ^ Error Message
+10 ;
+11 ; Where IEN = -1 if error
+12 ; Selectable = 0 for unselectable
+13 ; Error Message if applicable
+14 ;
+15 ; ARY(Activation Date) = Inactivation Date^Short Name
+16 ;
+17 ; Where the Short Name is versioned as follows:
+18 ;
+19 ; Period is active - Text for TODAY's date
+20 ; Period is inactive - Text for inactivation date
+21 ;
+22 QUIT $$PERIOD^ICDEX($GET(CODE),.ARY,$GET(CSYS))