- ICDGTDRG ;ALB/ADL - COLLECTION OF DRG APIS ;07/19/2012
- ;;18.0;DRG Grouper;**7,12,14,17,57,64**;Oct 20, 2000;Build 103
- ; Collection of API's for accessing new "DRG" level
- ; of files #80, #80.1, and #80.2. These new levels
- ; were added for the Code Set Versioning Project
- ;
- ; Global Variables
- ; None
- ;
- ; External References
- ; ^ICDDRG0 ICR N/A
- ; $$CODEN^ICDEX ICR N/A
- ; $$DRG^ICDEX ICR N/A
- ; $$DRGD^ICDEX ICR N/A
- ; $$DRGDES^ICDEX ICR N/A
- ; $$DRGN^ICDEX ICR N/A
- ; $$GETDATE^ICDEX ICR N/A
- ; $$GETDRG^ICDEX ICR N/A
- ; $$ISVALID^ICDEX ICR N/A
- ;
- ; Local Variables NEWed or KILLed Elsewhere
- ; EFFD,ICDMDC
- ;
- GETDRG(CODE,DGNDT,FILE) ; Get DRG or DRG string associated with a Code
- ;
- ; Input:
- ; CODE - IEN number
- ; DRGDT - Effective date of the Code
- ; FILE - File to check : 9 - ICD9 (file #80)
- ; 0 - ICD0 (file 80.1)
- ; Output:
- ; DRGS - DRG or string of DRG's (delimited
- ; by "^") or -1 if not defined
- ;
- ; Effective date or error message;
- ; status flag (1=Active;0=Inactive)
- ; Delimited by ";" because DRG's can be
- ; multiple and are already delimited by "^"
- ;
- ; NOTE: For ICD Procedures, it uses the additional variable ICDMDC
- ;
- Q $$GETDRG^ICDEX($G(FILE),$G(CODE),$P($G(DGNDT),".",1),$G(ICDMDC))
- DRG(CODE,EDT) ; Returns a string of information from the DRG file (#80.2)
- ; Input: CODE DRG code, internal or external format (Required)
- ; CDT Date to check status for, FileMan format (default = TODAY)
- ; If CDT < 10/1/1978, use 10/1/1978
- ; If CDT > DT, validate with In/Activation Dates
- ; If CDT is year only, use first of the year
- ; If CDT is year and month, use first of the month
- ;
- ; Output: Returns an 22 piece string delimited by the up-arrow (^), where the
- ; pieces are:
- ; 1 DRG name (field #.01)
- ; 2 Weight (field #2)
- ; 3 Low Trim (days) (field #3)
- ; 4 High Trim (days) (field #4)
- ; 5 MDC (field #5)
- ; 6 Surgery Flag (field #.06)
- ; 7 <null>
- ; 8 Avg Length of Stay (days) (field 10)
- ; 9 Local Low Trim Days (field #11)
- ; 10 Local High Trim Days (field #12)
- ; 11 <null>
- ; 12 Local Breakeven (field #13)
- ; 13 Activation Date (.01 field of the 66 multiple)
- ; 14 Status (.03 field of the 66 multiple)
- ; 15 Inactivation Date (.01 field of the 66 multiple)
- ; 16 Effective date (.01 field of the 66 multiple)
- ; 17 Internal Entry Number (IEN)
- ; 18 Effective date of CSV (.01 field of the 66 multiple)
- ; 19 Reference (field #900)
- ; 20 Weight (Non Affil) (field #7)
- ; 21 Weight (Int Affil) (field #7.5)
- ; 22 Message
- ;
- ; or
- ;
- ; -1^Error Description
- ;
- Q $$DRG^ICDEX($G(CODE),$G(EDT))
- CODEI(CODE) ; Returns the IEN of an ICD code
- Q +($$CODEN^ICDEX($G(CODE),80))
- GETDATE(PATNUM) ; Find the correct "EFFECTIVE DATE" for locating the DRG/ICD/CPT codes
- ;
- ; Input: PATNUM - PTF Record Number
- ; Output: "effective date" to use
- ;
- Q $$GETDATE^ICDEX($G(PATNUM))
- ISVALID(CODE,EDATE,FILE) ; Is an ICD/CPT code Valid
- ; This is a function call to be used in DIC("S") FileMan
- ; calls to check the validation of a ICD/CPT code
- ; Input:
- ; CODE - ICD/CPT code (ien)
- ; EDATE - Effective date to be used
- ; FILE - File to use: 0 - ICD0; 9 - ICD9
- ;
- ; Output:
- ; OUT - 1 if valid; 0 if not
- ;
- Q $$ISVALID^ICDEX($G(FILE),$G(CODE),$G(EDATE))
- DRGD(CODE,OUTARR,DFN,CDT) ; returns DRG description in array
- ; Input: CODE ICD Code, Internal or External Format (required)
- ; ARY Output Array Name for description
- ; e.g. "ABC" or "ABC("TEST")"
- ; Default = ^TMP("DRGD",$J)
- ; DFN Not in use but included in anticipation of future need
- ; CDT Date to screen against (default = TODAY)
- ; If CDT < 10/1/1978, use 10/1/1978
- ; If CDT > DT, use DT
- ; If CDT is year only, use first of the year
- ; If CDT is year and month only, use first of the month
- ;
- ; Output: # Number of lines in description output array
- ; @ARY(1:n) - Versioned Description (lines 1-n) (from the 68 multiple)
- ; @ARY(n+1) - Blank
- ; @ARY(n+1) - A message stating: CODE TEXT MAY BE INACCURATE
- ;
- ; or
- ;
- ; -1^Error Description
- ;
- ; ** NOTE - USER MUST INITIALIZE ^TMP("DRGD",$J), IF USED **
- Q $$DRGD^ICDEX($G(CODE),$G(OUTARR),$G(CDT))
- VLTDR(IEN,VDATE,ARY) ; Versioned Description - Long Text
- ; Input:
- ; IEN - Internal Entry Number file 80.2
- ; VDATE - Effective/Versioning date to be used
- ; .ARY - Array for output, passed by reference
- ;
- ; Output:
- ; ARY() - Local array containing versioned description
- ;
- Q $$DRGDES^ICDEX($G(IEN),$G(VDATE),.ARY)
- CODEN(CODE) ; Return the IEN of DRG
- ;
- ; Input: DRG code
- ; Output: IEN of code
- ;
- Q $$DRGN^ICDEX($G(CODE))
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HICDGTDRG 5533 printed Jan 18, 2025@02:52:04 Page 2
- ICDGTDRG ;ALB/ADL - COLLECTION OF DRG APIS ;07/19/2012
- +1 ;;18.0;DRG Grouper;**7,12,14,17,57,64**;Oct 20, 2000;Build 103
- +2 ; Collection of API's for accessing new "DRG" level
- +3 ; of files #80, #80.1, and #80.2. These new levels
- +4 ; were added for the Code Set Versioning Project
- +5 ;
- +6 ; Global Variables
- +7 ; None
- +8 ;
- +9 ; External References
- +10 ; ^ICDDRG0 ICR N/A
- +11 ; $$CODEN^ICDEX ICR N/A
- +12 ; $$DRG^ICDEX ICR N/A
- +13 ; $$DRGD^ICDEX ICR N/A
- +14 ; $$DRGDES^ICDEX ICR N/A
- +15 ; $$DRGN^ICDEX ICR N/A
- +16 ; $$GETDATE^ICDEX ICR N/A
- +17 ; $$GETDRG^ICDEX ICR N/A
- +18 ; $$ISVALID^ICDEX ICR N/A
- +19 ;
- +20 ; Local Variables NEWed or KILLed Elsewhere
- +21 ; EFFD,ICDMDC
- +22 ;
- GETDRG(CODE,DGNDT,FILE) ; Get DRG or DRG string associated with a Code
- +1 ;
- +2 ; Input:
- +3 ; CODE - IEN number
- +4 ; DRGDT - Effective date of the Code
- +5 ; FILE - File to check : 9 - ICD9 (file #80)
- +6 ; 0 - ICD0 (file 80.1)
- +7 ; Output:
- +8 ; DRGS - DRG or string of DRG's (delimited
- +9 ; by "^") or -1 if not defined
- +10 ;
- +11 ; Effective date or error message;
- +12 ; status flag (1=Active;0=Inactive)
- +13 ; Delimited by ";" because DRG's can be
- +14 ; multiple and are already delimited by "^"
- +15 ;
- +16 ; NOTE: For ICD Procedures, it uses the additional variable ICDMDC
- +17 ;
- +18 QUIT $$GETDRG^ICDEX($GET(FILE),$GET(CODE),$PIECE($GET(DGNDT),".",1),$GET(ICDMDC))
- DRG(CODE,EDT) ; Returns a string of information from the DRG file (#80.2)
- +1 ; Input: CODE DRG code, internal or external format (Required)
- +2 ; CDT Date to check status for, FileMan format (default = TODAY)
- +3 ; If CDT < 10/1/1978, use 10/1/1978
- +4 ; If CDT > DT, validate with In/Activation Dates
- +5 ; If CDT is year only, use first of the year
- +6 ; If CDT is year and month, use first of the month
- +7 ;
- +8 ; Output: Returns an 22 piece string delimited by the up-arrow (^), where the
- +9 ; pieces are:
- +10 ; 1 DRG name (field #.01)
- +11 ; 2 Weight (field #2)
- +12 ; 3 Low Trim (days) (field #3)
- +13 ; 4 High Trim (days) (field #4)
- +14 ; 5 MDC (field #5)
- +15 ; 6 Surgery Flag (field #.06)
- +16 ; 7 <null>
- +17 ; 8 Avg Length of Stay (days) (field 10)
- +18 ; 9 Local Low Trim Days (field #11)
- +19 ; 10 Local High Trim Days (field #12)
- +20 ; 11 <null>
- +21 ; 12 Local Breakeven (field #13)
- +22 ; 13 Activation Date (.01 field of the 66 multiple)
- +23 ; 14 Status (.03 field of the 66 multiple)
- +24 ; 15 Inactivation Date (.01 field of the 66 multiple)
- +25 ; 16 Effective date (.01 field of the 66 multiple)
- +26 ; 17 Internal Entry Number (IEN)
- +27 ; 18 Effective date of CSV (.01 field of the 66 multiple)
- +28 ; 19 Reference (field #900)
- +29 ; 20 Weight (Non Affil) (field #7)
- +30 ; 21 Weight (Int Affil) (field #7.5)
- +31 ; 22 Message
- +32 ;
- +33 ; or
- +34 ;
- +35 ; -1^Error Description
- +36 ;
- +37 QUIT $$DRG^ICDEX($GET(CODE),$GET(EDT))
- CODEI(CODE) ; Returns the IEN of an ICD code
- +1 QUIT +($$CODEN^ICDEX($GET(CODE),80))
- GETDATE(PATNUM) ; Find the correct "EFFECTIVE DATE" for locating the DRG/ICD/CPT codes
- +1 ;
- +2 ; Input: PATNUM - PTF Record Number
- +3 ; Output: "effective date" to use
- +4 ;
- +5 QUIT $$GETDATE^ICDEX($GET(PATNUM))
- ISVALID(CODE,EDATE,FILE) ; Is an ICD/CPT code Valid
- +1 ; This is a function call to be used in DIC("S") FileMan
- +2 ; calls to check the validation of a ICD/CPT code
- +3 ; Input:
- +4 ; CODE - ICD/CPT code (ien)
- +5 ; EDATE - Effective date to be used
- +6 ; FILE - File to use: 0 - ICD0; 9 - ICD9
- +7 ;
- +8 ; Output:
- +9 ; OUT - 1 if valid; 0 if not
- +10 ;
- +11 QUIT $$ISVALID^ICDEX($GET(FILE),$GET(CODE),$GET(EDATE))
- DRGD(CODE,OUTARR,DFN,CDT) ; returns DRG description in array
- +1 ; Input: CODE ICD Code, Internal or External Format (required)
- +2 ; ARY Output Array Name for description
- +3 ; e.g. "ABC" or "ABC("TEST")"
- +4 ; Default = ^TMP("DRGD",$J)
- +5 ; DFN Not in use but included in anticipation of future need
- +6 ; CDT Date to screen against (default = TODAY)
- +7 ; If CDT < 10/1/1978, use 10/1/1978
- +8 ; If CDT > DT, use DT
- +9 ; If CDT is year only, use first of the year
- +10 ; If CDT is year and month only, use first of the month
- +11 ;
- +12 ; Output: # Number of lines in description output array
- +13 ; @ARY(1:n) - Versioned Description (lines 1-n) (from the 68 multiple)
- +14 ; @ARY(n+1) - Blank
- +15 ; @ARY(n+1) - A message stating: CODE TEXT MAY BE INACCURATE
- +16 ;
- +17 ; or
- +18 ;
- +19 ; -1^Error Description
- +20 ;
- +21 ; ** NOTE - USER MUST INITIALIZE ^TMP("DRGD",$J), IF USED **
- +22 QUIT $$DRGD^ICDEX($GET(CODE),$GET(OUTARR),$GET(CDT))
- VLTDR(IEN,VDATE,ARY) ; Versioned Description - Long Text
- +1 ; Input:
- +2 ; IEN - Internal Entry Number file 80.2
- +3 ; VDATE - Effective/Versioning date to be used
- +4 ; .ARY - Array for output, passed by reference
- +5 ;
- +6 ; Output:
- +7 ; ARY() - Local array containing versioned description
- +8 ;
- +9 QUIT $$DRGDES^ICDEX($GET(IEN),$GET(VDATE),.ARY)
- CODEN(CODE) ; Return the IEN of DRG
- +1 ;
- +2 ; Input: DRG code
- +3 ; Output: IEN of code
- +4 ;
- +5 QUIT $$DRGN^ICDEX($GET(CODE))