ICDXCODE ;ISL/KER - ICD basic data API's ;12/19/2014
;;18.0;DRG Grouper;**57,67**;Oct 20, 2000;Build 1
;
; ICD wrapper APIs
;
EN ; Main Entry Point
HELP ; Developer Help for an API
D HLP^ICDEXH("SDD") Q
;
ICDDATA(CSYS,CODE,DATE,FRMT,LOC) ; 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)
; LOC Local codes 1 = Yes
; 0 = No (default)
;
; 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),$G(LOC))
Q:ROOT["ICD0" $$ICDOP^ICDEX($G(CODE),$G(DATE),$G(SYS),$G(FRMT),$G(LOC))
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))
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HICDXCODE 5997 printed Dec 13, 2024@01:52:47 Page 2
ICDXCODE ;ISL/KER - ICD basic data API's ;12/19/2014
+1 ;;18.0;DRG Grouper;**57,67**;Oct 20, 2000;Build 1
+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,LOC) ; 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 ; LOC Local codes 1 = Yes
+10 ; 0 = No (default)
+11 ;
+12 ; Output:
+13 ;
+14 ; Diagnosis returns an 22 piece string delimited by "^"
+15 ;
+16 ; 1 IEN of code in file 80
+17 ; 2 ICD-9 Dx Code (#.01)
+18 ; 3 Identifier (#1.2)
+19 ; 4 Versioned Dx (67 multiple)
+20 ; 5 Unacceptable as Principal Dx (#1.3)
+21 ; 6 Major Dx Cat (72 multiple)
+22 ; 7 MDC13 (#1.4)
+23 ; 8 Compl/Comorb (103 multiple)
+24 ; 9 ICD Expanded (#1.7)
+25 ; 10 Status (66 multiple)
+26 ; 11 Sex (10 multiple)
+27 ; 12 Inactive Date (66 multiple)
+28 ; 13 MDC24 (#1.5)
+29 ; 14 MDC25 (#1.6)
+30 ; 15 Age Low (11 multiple)
+31 ; 16 Age High (12 multiple)
+32 ; 17 Activation Date (66 multiple)
+33 ; 18 Message
+34 ; 19 Complication/Comorbidity (103 multiple)
+35 ; 20 Coding System (#1.1)
+36 ; 21 Primary CC Flag (103 multiple)
+37 ; 22 PDX Exclusion Code (#1.11)
+38 ;
+39 ; Procedures returns A 14 piece string delimited by "^"
+40 ;
+41 ; 1 IEN of code in file 80.1
+42 ; 2 ICD procedure code (#.01)
+43 ; 3 Identifier (#1.2)
+44 ; 4 MDC24 (#1.5)
+45 ; 5 Versioned Oper/Proc (67 multiple)
+46 ; 6 <null>
+47 ; 7 <null>
+48 ; 8 <null>
+49 ; 9 ICD Expanded (#1.7)
+50 ; 10 Status (66 multiple)
+51 ; 11 Use with Sex (10 multiple)
+52 ; 12 Inactive Date (66 multiple)
+53 ; 13 Activation Date (66 multiple)
+54 ; 14 Message
+55 ; 15 Coding System (#1.1)
+56 ;
+57 ; or
+58 ;
+59 ; -1^Error Description
+60 ;
+61 NEW ROOT,SYS
+62 SET DATE=$PIECE($GET(DATE),".",1)
SET SYS=$$SYS^ICDEX($GET(CSYS),$GET(DATE))
if +SYS'>0
SET SYS=$$SYS^ICDEX($GET(CODE))
+63 if +SYS'>0
QUIT "-1^Invalid coding system specified"
+64 SET ROOT=$$ROOT^ICDEX(SYS)
if '$LENGTH(ROOT)
QUIT "-1^Invalid Global Root"
+65 if CODE[";"&($PIECE(CODE,";",2)=$TRANSLATE(ROOT,"^",""))&($LENGTH($PIECE(CODE,";",1)))
SET FRMT="I"
SET CODE=$PIECE(CODE,";",1)
+66 if '$LENGTH($GET(FRMT))
SET FRMT=$$IE^ICDEX($GET(CODE))
+67 if ROOT["ICD9"
QUIT $$ICDDX^ICDEX($GET(CODE),$GET(DATE),$GET(SYS),$GET(FRMT),$GET(LOC))
+68 if ROOT["ICD0"
QUIT $$ICDOP^ICDEX($GET(CODE),$GET(DATE),$GET(SYS),$GET(FRMT),$GET(LOC))
+69 QUIT "-1^Not found"
+70 ;
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))