ICDAPIU ;DLS/DEK/KER - ICD UTILITIES FOR APIS ;04/21/2014
 ;;18.0;DRG Grouper;**6,11,12,15,57**;Oct 20, 2000;Build 1
 ;               
 ; Global Variables
 ;    None
 ;               
 ; External References
 ;    None
 ;               
 Q
EN ; Main Entry Point
HELP ; Developer Help for an API
 D HLP^ICDEXH("LEG") Q
 ;
DTBR(CDT,CS) ; Date Business Rules
 ;
 ; Input:   
 ; 
 ;     CDT   Code Date to check default TODAY
 ;     CS    Code System (Default 0 = ICD)
 ;     
 ; Output:  
 ; 
 ;     If CDT < ICD-9 Date and CS=0, use ICD-9 Date
 ;     If CDT < 2890101 and CS=1, use 2890101
 ;     If CDT < 2821001 and CS=2, use 2821001
 ;     If CDT is year only, use first of the year
 ;     If CDT is year and month only, use first of the month
 ;     
 Q $$DTBR^ICDEX($G(CDT),$G(CS))
MSG(CDT,CS) ; Inform of code text inaccuracy
 ;
 ; Input:   
 ; 
 ;     CDT   Code Date to check (FileMan format, Default = today)
 ;     CS    Code System (0:ICD, 1:CPT/HCPCS, 2:DRG, 3:LEX, Default=0)
 ;          
 ; Output:  
 ; 
 ;     User Alert
 ;     
 Q $$MSG^ICDEX($G(CDT),$G(CS))
STATCHK(CODE,CDT) ; Check Status of ICD Code
 ;
 ; Input:
 ; 
 ;     CODE  ICD Code
 ;     CDT   Date to screen against
 ;     
 ; Output:
 ; 
 ;     3-Piece String containing Status, IEN and Effective Date
 ;     
 Q $$STATCHK^ICDEX($G(CODE),$G(CDT))
NEXT(CODE) ; Next ICD Code (active or inactive)
 ;
 ; Input:
 ; 
 ;     CODE  ICD Code   REQUIRED
 ;     
 ; Output:  
 ; 
 ;     The Next ICD Code, Null if none
 ;     
 Q $$NEXT^ICDEX($G(CODE))
PREV(CODE) ; Previous ICD Code (active or inactive)
 ;
 ; Input:
 ; 
 ;     CODE   ICD Code   REQUIRED
 ;     
 ; Output:
 ; 
 ;     The Previous ICD Code, Null if none
 ;     
 Q $$PREV^ICDEX($G(CODE))
 ;
HIST(CODE,ARY)  ; Activation History
 ;
 ; Input:
 ; 
 ;     CODE   ICD Code                     REQUIRED
 ;    .ARY    Array, passed by Reference   REQUIRED
 ;   
 ; Output:
 ; 
 ;     Mirrors ARY(0) (or, -1 on error)
 ;     ARY(0) = Number of Activation History Entries
 ;     ARY(<date>) = status    where: 1 is Active
 ;     ARY("IEN") = <ien>
 ;     
 Q $$HIST^ICDEX($G(CODE),.ARY)
PERIOD(CODE,ARY) ; Return Activation/Inactivation Period in ARY
 ;
 ; Input:
 ; 
 ;     CODE  ICD Code (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
 ;     
 N X S X=$$PERIOD^ICDEX($G(CODE),.ARY) Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HICDAPIU   2883     printed  Sep 23, 2025@19:26:01                                                                                                                                                                                                     Page 2
ICDAPIU   ;DLS/DEK/KER - ICD UTILITIES FOR APIS ;04/21/2014
 +1       ;;18.0;DRG Grouper;**6,11,12,15,57**;Oct 20, 2000;Build 1
 +2       ;               
 +3       ; Global Variables
 +4       ;    None
 +5       ;               
 +6       ; External References
 +7       ;    None
 +8       ;               
 +9        QUIT 
EN        ; Main Entry Point
HELP      ; Developer Help for an API
 +1        DO HLP^ICDEXH("LEG")
           QUIT 
 +2       ;
DTBR(CDT,CS) ; Date Business Rules
 +1       ;
 +2       ; Input:   
 +3       ; 
 +4       ;     CDT   Code Date to check default TODAY
 +5       ;     CS    Code System (Default 0 = ICD)
 +6       ;     
 +7       ; Output:  
 +8       ; 
 +9       ;     If CDT < ICD-9 Date and CS=0, use ICD-9 Date
 +10      ;     If CDT < 2890101 and CS=1, use 2890101
 +11      ;     If CDT < 2821001 and CS=2, use 2821001
 +12      ;     If CDT is year only, use first of the year
 +13      ;     If CDT is year and month only, use first of the month
 +14      ;     
 +15       QUIT $$DTBR^ICDEX($GET(CDT),$GET(CS))
MSG(CDT,CS) ; Inform of code text inaccuracy
 +1       ;
 +2       ; Input:   
 +3       ; 
 +4       ;     CDT   Code Date to check (FileMan format, Default = today)
 +5       ;     CS    Code System (0:ICD, 1:CPT/HCPCS, 2:DRG, 3:LEX, Default=0)
 +6       ;          
 +7       ; Output:  
 +8       ; 
 +9       ;     User Alert
 +10      ;     
 +11       QUIT $$MSG^ICDEX($GET(CDT),$GET(CS))
STATCHK(CODE,CDT) ; Check Status of ICD Code
 +1       ;
 +2       ; Input:
 +3       ; 
 +4       ;     CODE  ICD Code
 +5       ;     CDT   Date to screen against
 +6       ;     
 +7       ; Output:
 +8       ; 
 +9       ;     3-Piece String containing Status, IEN and Effective Date
 +10      ;     
 +11       QUIT $$STATCHK^ICDEX($GET(CODE),$GET(CDT))
NEXT(CODE) ; Next ICD Code (active or inactive)
 +1       ;
 +2       ; Input:
 +3       ; 
 +4       ;     CODE  ICD Code   REQUIRED
 +5       ;     
 +6       ; Output:  
 +7       ; 
 +8       ;     The Next ICD Code, Null if none
 +9       ;     
 +10       QUIT $$NEXT^ICDEX($GET(CODE))
PREV(CODE) ; Previous ICD Code (active or inactive)
 +1       ;
 +2       ; Input:
 +3       ; 
 +4       ;     CODE   ICD Code   REQUIRED
 +5       ;     
 +6       ; Output:
 +7       ; 
 +8       ;     The Previous ICD Code, Null if none
 +9       ;     
 +10       QUIT $$PREV^ICDEX($GET(CODE))
 +11      ;
HIST(CODE,ARY) ; Activation History
 +1       ;
 +2       ; Input:
 +3       ; 
 +4       ;     CODE   ICD Code                     REQUIRED
 +5       ;    .ARY    Array, passed by Reference   REQUIRED
 +6       ;   
 +7       ; Output:
 +8       ; 
 +9       ;     Mirrors ARY(0) (or, -1 on error)
 +10      ;     ARY(0) = Number of Activation History Entries
 +11      ;     ARY(<date>) = status    where: 1 is Active
 +12      ;     ARY("IEN") = <ien>
 +13      ;     
 +14       QUIT $$HIST^ICDEX($GET(CODE),.ARY)
PERIOD(CODE,ARY) ; Return Activation/Inactivation Period in ARY
 +1       ;
 +2       ; Input:
 +3       ; 
 +4       ;     CODE  ICD Code (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       NEW X
           SET X=$$PERIOD^ICDEX($GET(CODE),.ARY)
           QUIT