Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: ICDJC1

ICDJC1.m

Go to the documentation of this file.
  1. ICDJC1 ;ALB/ARH - DRG GROUPER CALCULATOR 2015 - ATTRIBUTES ;05/26/2016
  1. ;;18.0;DRG Grouper;**89,97**;Oct 20, 2000;Build 5
  1. ;
  1. ; DRG Calcuation for re-designed grouper ICD-10 2015, continuation
  1. ;
  1. PRATT(ICDPR,ICDDATE,PRARR) ; get all attributes of Procedures - determine if event is Surgical or Medical and MDCs
  1. ; returns array with the Procedure Attributes only, later updated to include Cluster Attributes
  1. ;
  1. ; Input: ICDPR(x) - array of Procedures into API, ICDDATE - event date
  1. ; Output: PRARR - 'O' if any procedure/cluster is an Operating Room procedure, 'N' if Non-OR only or blank
  1. ; - list of all MDC's associated with any of the Operating Room procedures, separated by ';'
  1. ; PRARR(x) - pr ifn (#80.1) ^ Procedure (OR/NOR) ^ (reserved Clstr) ^ (reserved Clstr Type) ^ ^ ^ OR/NOR applies
  1. ; w/ OR/NOR = O/N/blank for specific procedure and w/'x' corresponds to entry in ICDPR array
  1. N PRI,PR,PRIFN,ATTLN K PRARR S PRARR=""
  1. ;
  1. S PRI=0 F S PRI=$O(ICDPR(PRI)) Q:'PRI S PR=+$G(ICDPR(PRI)) S PRARR(PRI)=PR D
  1. . S PRIFN=$O(^ICDD(83.6,"B",PR,0)) Q:'PRIFN
  1. . S ATTLN=$$GETATT("PR",PRIFN,$G(ICDDATE))
  1. . S PRARR(PRI)=PR_U_$P(ATTLN,U,3)_U_U_U_U_U_$P(ATTLN,U,3) I PRARR'="O",$P(ATTLN,U,3)'="" S PRARR=$P(ATTLN,U,3)
  1. ;
  1. S PRARR=PRARR_U_$$GETMDC("PR",.ICDPR,$G(ICDDATE)) ; set event procedure attibutes - final OR/NonOR and MDC list
  1. Q
  1. ;
  1. ;
  1. DXATT(ICDDX,ICDDATE,ICDEXP,DXARR) ; get all attributes of Diagnosis - determine if MCC or CC apply to event and MDCs
  1. ; returns array with the Diagnosis Attributes only, later updated to include updates due to HAC
  1. ; the diagnosis event MDCs are determined by the primary Dx, based on the MDCs of its assigned code sets
  1. ; event MCC/CC is determined by secondary Dxs and the primary Dx if it is an MCC/CC of its Own
  1. ; the MCC/CC of a secondary Dx may be applied to the event DRG unless overridden by one of two cases:
  1. ; PDX is a member of the secondarys exclusion group or if patient has expired and MCC only if Alive
  1. ;
  1. ; Input: ICDDX(x) - array of Dx into API, ICDDATE - event date, ICDEXP - 1 if patient died before discharge
  1. ; Output: DXARR - 'MCC' or 'CC' for event if either result from the diagnosis or blank
  1. ; - list if all MDC's associated with the Primary Diagnosis, separated by ';'
  1. ; DXARR(x) - dx ifn (#80) ^ MCC/CC ^ exclude grp ^ alive exclude ^ (reserved HAC) ^ ^ MCC/CC applies
  1. N DXI,PDX,DX,DXIFN,ATTLN,DXCC,DXEXCL,DXALIVE,EXCLUDE,EXPIRED,CCMCC K DXARR S DXARR=""
  1. ;
  1. ; get primary diagnosis attributes to determine MCC/CC
  1. S DXI=+$O(ICDDX(0)),PDX=$G(ICDDX(DXI)) Q:'PDX S DXARR(DXI)=PDX
  1. ;
  1. S DXIFN=$O(^ICDD(83.5,"B",PDX,0)) Q:'DXIFN
  1. S ATTLN=$$GETATT("DX",DXIFN,$G(ICDDATE))
  1. S DXCC=$S(+$P(ATTLN,U,4):"MCC",+$P(ATTLN,U,5):"CC",1:"") ; MCC/CC of its own
  1. S DXARR(DXI)=PDX_U_DXCC_U_0_U_0_U_U_U_DXCC
  1. ;
  1. ; get secondary diagnosis attributes to determine MCC/CC
  1. F S DXI=$O(ICDDX(DXI)) Q:'DXI S DX=+$G(ICDDX(DXI)) S DXARR(DXI)=DX D
  1. . ;
  1. . S DXIFN=$O(^ICDD(83.5,"B",DX,0)) Q:'DXIFN
  1. . S ATTLN=$$GETATT("DX",DXIFN,$G(ICDDATE))
  1. . S DXCC=$S(+$P(ATTLN,U,7):"MCC",+$P(ATTLN,U,8):"CC",1:"") ; MCC/CC
  1. . ;
  1. . S (EXPIRED,EXCLUDE)=0
  1. . S DXALIVE=$P(ATTLN,U,6) I +DXALIVE,+$G(ICDEXP) S EXPIRED=1 ; mcc only if alive but patient expired
  1. . S DXEXCL=$P(ATTLN,U,3) I DXEXCL'="",+$$EXCLD(PDX,DXEXCL,$G(ICDDATE)) S EXCLUDE=DXEXCL ; pdx in exclusion grp
  1. . ;
  1. . S CCMCC="" I 'EXCLUDE,'EXPIRED S CCMCC=DXCC
  1. . S DXARR(DXI)=DX_U_DXCC_U_EXCLUDE_U_EXPIRED_U_U_U_CCMCC
  1. ;
  1. S DXARR=$$GETEVT(.DXARR)_U_$$GETMDC("DX",.ICDDX,$G(ICDDATE)) ; get event attributes - final MCC/CC and MDC list
  1. Q
  1. ;
  1. ;
  1. GETATT(TYP,CDIFN,DATE) ; get one codes Attributes for date, either diagnosis (83.5,10) or procedure (83.6,10) or cluster (83.61,10)
  1. ; only one set of attributes may be active on a given date, returns entire node
  1. ; input: TYP - type of codes 'DX' or 'PR' or 'CL', CDIFN - ptr to code in 83.5 or 83.6 or 83.61
  1. ; output: node of codes attributes active on date, if any, 83.5,10 or 83.6,10 or 86.61,10
  1. N IX,LINE,CDFILE,BEGIN,END,ATTLN S TYP=$G(TYP),CDIFN=+$G(CDIFN) S ATTLN="" I '$G(DATE) S DATE=DT
  1. S CDFILE=$S(TYP="DX":83.5,TYP="PR":83.6,TYP="CL":83.61,1:0)
  1. ;
  1. S BEGIN=DATE+.00001 S BEGIN=+$O(^ICDD(CDFILE,CDIFN,10,"B",BEGIN),-1)
  1. S IX=+$O(^ICDD(CDFILE,CDIFN,10,"B",BEGIN,0))
  1. S LINE=$G(^ICDD(CDFILE,CDIFN,10,IX,0))
  1. S BEGIN=$P(LINE,U,1),END=$P(LINE,U,2) I 'END S END=9999999
  1. I DATE'<BEGIN,DATE'>END S ATTLN=LINE
  1. Q ATTLN
  1. ;
  1. GETMDC(TYP,ICDARR,ICDDATE) ; get list of all MDC's the diagnosis/procedure codes are assigned to
  1. ; compile list of MDC's based on the codes assigned code sets (83.5,20&83.6,20), Primary Dx and OR Procedures only
  1. ; input: TYP - type of codes 'DX' or 'PR', ICDARR is either diagnoais ICDDX or procedures ICDPRC
  1. ; output: returns list of codes MDC ID's - 00;03... for Primary DX or all OR Procedures only
  1. N IX,CDFILE,CDIFN,CD,SETIFN,MDCIFN,MDC,MLIST,ARRCDS,ARRMDC S TYP=$G(TYP) S MLIST=""
  1. S CDFILE=$S(TYP="DX":83.5,TYP="PR":83.6,1:0)
  1. ;
  1. S IX=0 F S IX=$O(ICDARR(IX)) Q:'IX S CD=+$G(ICDARR(IX)) D I TYP="DX" Q
  1. . S CDIFN=$O(^ICDD(CDFILE,"B",CD,0)) Q:'CDIFN
  1. . ;
  1. . I TYP="PR",$P($$GETATT("PR",CDIFN,$G(ICDDATE)),U,3)'="O" Q
  1. . ;
  1. . D GETCDS^ICDJC2(TYP,CDIFN,$G(ICDDATE),.ARRCDS,.ICDARR) ; get code sets on date for individual code
  1. . ;
  1. . S SETIFN=0 F S SETIFN=$O(ARRCDS(SETIFN)) Q:'SETIFN D ; get MDC of all code sets the code is a member of
  1. .. S MDCIFN=$P($G(^ICDD(83.3,SETIFN,0)),U,2),MDC=$P($G(^ICDD(83,MDCIFN,0)),U,2) I MDC'="" S ARRMDC(MDC_";")=""
  1. ;
  1. ; list in order and no dups, separated by ';'
  1. S MDC="" F S MDC=$O(ARRMDC(MDC)) Q:MDC="" S MLIST=MLIST_MDC
  1. I MLIST'="" S MLIST=$E(MLIST,1,$L(MLIST)-1)
  1. Q MLIST
  1. ;
  1. GETEVT(DXARR) ; get the events MCC/CC attribute, compiled from all diagnosis attributes
  1. ; check each dx for an MCC/CC that was not overridden and still applies, MCC highest priority then CC
  1. ; input: DXARR list of each diagnosis attributes
  1. ; output: returns either MCC or CC or blank as the event attribute
  1. N DXEVT,DXI,CCMCC S DXEVT=""
  1. S DXI=0 F S DXI=$O(DXARR(DXI)) Q:'DXI S CCMCC=$P(DXARR(DXI),U,7) I CCMCC'="" S DXEVT=CCMCC I CCMCC="MCC" Q
  1. Q DXEVT
  1. ;
  1. EXCLD(DX,EXCLGRP,DATE) ; determine if the Diagnosis is in the Exclusion group
  1. ; if primary Dx is member of a secondary Dxs Exclusion group then that secondary Dx can not impart MCC/CC to event
  1. ; input: DX - ptr to 80, EXCLGRP - 4 character Exclusion Group ID (83.51, .01 and 83.5,10,.03)
  1. ; output: returns true if PDx is in SDx Exclusion group (83.51) on date and secondary Dxs MCC/CC should be ignored
  1. N LINE,EXIFN,BEGIN,END,EXCLUDE S EXCLUDE=0 S DX=+$G(DX) I '$G(DATE) S DATE=DT
  1. ;
  1. I $G(EXCLGRP)?4N S EXIFN=0 F S EXIFN=$O(^ICDD(83.51,"ADE",DX,EXCLGRP,EXIFN)) Q:'EXIFN D Q:EXCLUDE
  1. . S LINE=$G(^ICDD(83.51,EXIFN,0))
  1. . S BEGIN=$P(LINE,U,3),END=$P(LINE,U,4) I 'END S END=9999999
  1. . I DATE'<BEGIN,DATE'>END S EXCLUDE=1
  1. Q EXCLUDE
  1. ;
  1. ;
  1. ;
  1. DXHAC(ICDDX,ICDPR,ICDDATE,ICDPOA,DXARR) ; reset DXATT for HAC, determine HAC for each Dx not POA (N,U), if found then re-set event MCC/CC
  1. ; identify any diagnosis defined as a HAC, if a Dx is HAC then its MCC/CC should be ignored
  1. ; a HAC applies only to diagnosis Not Present on Admission (N or U)
  1. ; if a Dx is Not Present on Admission (N,U) and a member of a HAC group then it can not impart MCC/CC to the event
  1. ; if the HAC group requires multiple Dx codes then the MCC/CC of all are screened out
  1. ;
  1. ; Input: ICDDX(x) and ICDPR(x) - array of Dx/procedures input to API, ICDDATE - date of event
  1. ; ICDPOA(x) - array of Dx POA input to API
  1. ; DXARR(x) - dx ifn ^ MCC/CC ^ exclude grp ^ alive exclude ^ (reserved HAC) ^ ^ MCC/CC applies
  1. ; Output: DXARR - 'MCC' or 'CC' or blank, updated for any HAC Dx found
  1. ; DXARR(x) - (dx ifn) ^ (MCC/CC) ^ (exclude grp) ^ (alive exclude) ^ HAC Grp ^ ^ MCC/CC applies
  1. ; - if Dx is a member of a HAC group then 'HAC Grp' is set and 'MCC/CC applies' is updated
  1. ; to remove the Dxs MCC/CC from the event
  1. N FND,LINE,HCSIFN,HACCSE,HACIFN,HACID,DXI,ARRHCS,ARRHAC
  1. ;
  1. D HACSET(.ICDDX,.ICDPR,$G(ICDDATE),.ICDPOA,.ARRHCS) ; get all hac code sets defined by the event
  1. ;
  1. ; get HAC groups the identified hac code sets belong to, by case
  1. S HCSIFN=0 F S HCSIFN=$O(ARRHCS(HCSIFN)) Q:'HCSIFN D
  1. . S LINE=$G(^ICDD(83.71,HCSIFN,0)),HACCSE=$P(LINE,U,2)_U_+$P(LINE,U,5) S ARRHAC(HACCSE,HCSIFN)=""
  1. ;
  1. ; find the hac groups/cases with all code sets defined and update the diagnosis affected
  1. S HACCSE=0 F S HACCSE=$O(ARRHAC(HACCSE)) Q:'HACCSE S HACIFN=+HACCSE D
  1. . ;
  1. . ; for the hac group/case determine if all hac code sets are defined
  1. . S FND=1 S HCSIFN=0 F S HCSIFN=$O(^ICDD(83.71,"D",+HACIFN,HCSIFN)) Q:'HCSIFN D Q:'FND
  1. .. I +$P($G(^ICDD(83.71,+HCSIFN,0)),U,5)=+$P(HACCSE,U,2) I '$D(ARRHCS(HCSIFN)) S FND=0
  1. . ;
  1. . ; if hac group fully defined, update each diagnosis in the group to indicate MCC/CC removed by hac
  1. . I +FND S HCSIFN=0 F S HCSIFN=$O(ARRHAC(HACCSE,HCSIFN)) Q:'HCSIFN D
  1. .. S HACID=$P($G(^ICDD(83.7,+HACIFN,0)),U,1)
  1. .. ;
  1. .. S DXI=0 F S DXI=$O(ARRHCS(HCSIFN,"DX",DXI)) Q:'DXI I $D(DXARR(DXI)) S $P(DXARR(DXI),U,5)=HACID,$P(DXARR(DXI),U,7)=""
  1. ;
  1. S DXARR=$$GETEVT(.DXARR)_U_$$GETMDC("DX",.ICDDX,$G(ICDDATE)) ; get event attributes, final MCC/CC and MDC list
  1. ;
  1. Q
  1. ;
  1. HACSET(ICDDX,ICDPR,ICDDATE,ICDPOA,HCSARR) ; get all HAC Code Sets defined by event Diagnosis and Procedure codes
  1. ; a HAC only applies if Dx was not present on admission (N,U) and possibly only to secondary or primary Dx
  1. ; input: ICDDX(x) and ICDPR(x) - array of Dx/procedures input to API, ICDDATE - date of event
  1. ; ICDPOA(x) - array of Dx POA input to API
  1. ; output: returns array of all HAC code sets applicable to the specific event
  1. ; HCSARR( hac code set (83.71), "DX", x - code entry in ICDDX ) = ""
  1. ; HCSARR( hac code set (83.71), "PR", x - code entry in ICDPR ) = ""
  1. N DXI,DX,DXIFN,POA,HCSIFN,LINE,PRI,PR,PRIFN,ARRHSX K HCSARR
  1. ;
  1. ; get all HAC sets defined by event diagnosis that are not POA
  1. S DXI=0 F S DXI=$O(ICDDX(DXI)) Q:'DXI S POA=$G(ICDPOA(DXI)) I (POA="N")!(POA="U") D
  1. . ;
  1. . ; get all hac code sets the dx is assigned to on date
  1. . S DX=+$G(ICDDX(DXI)) S DXIFN=$O(^ICDD(83.5,"B",DX,0)) Q:'DXIFN D GETCDH("DX",DXIFN,$G(ICDDATE),.ARRHSX)
  1. . ;
  1. . ; for each hac set the dx is assigned, check if for this event the dx passes the hac set criteria (P/S)
  1. . S HCSIFN=0 F S HCSIFN=$O(ARRHSX(HCSIFN)) Q:'HCSIFN D
  1. .. S LINE=$G(^ICDD(83.71,HCSIFN,0)) Q:'HCSIFN
  1. .. ;
  1. .. I $P(LINE,U,4)="" S HCSARR(HCSIFN,"DX",DXI)="" Q ; set for any type of dx
  1. .. I $P(LINE,U,4)="P",$O(ICDDX(0))=DXI S HCSARR(HCSIFN,"DX",DXI)="" Q ; set for primary dx
  1. .. I $P(LINE,U,4)="S",$O(ICDDX(0))'=DXI S HCSARR(HCSIFN,"DX",DXI)="" Q ; set for secondary dx
  1. ;
  1. ; get all HAC sets defined by the event procedures
  1. S PRI=0 F S PRI=$O(ICDPR(PRI)) Q:'PRI D
  1. . S PR=+$G(ICDPR(PRI)) S PRIFN=$O(^ICDD(83.6,"B",PR,0)) Q:'PRIFN D GETCDH("PR",PRIFN,$G(ICDDATE),.ARRHSX)
  1. . ;
  1. . S HCSIFN=0 F S HCSIFN=$O(ARRHSX(HCSIFN)) Q:'HCSIFN S HCSARR(HCSIFN,"PR",PRI)=""
  1. ;
  1. Q
  1. ;
  1. GETCDH(TYP,CDIFN,DATE,ARRHSX) ; get HAC code sets for a single code on a date, either diagnosis (83.5,30) or procedure (83.6,30)
  1. ; input: TYP - type of codes 'DX' or 'PR', CDIFN - ptr to code in 83.5 or 83.6
  1. ; output: ARRHSX - array of HAC code sets the Code is a member of on the date
  1. ; ARRHSX(hac code set ifn (83.71)) = CDIFN
  1. N IX,LINE,CDFILE,BEGIN,END S TYP=$G(TYP),CDIFN=+$G(CDIFN) K ARRHSX I '$G(DATE) S DATE=DT
  1. S CDFILE=$S(TYP="DX":83.5,TYP="PR":83.6,1:0) I 'CDFILE Q
  1. ;
  1. S IX=0 F S IX=$O(^ICDD(CDFILE,CDIFN,30,IX)) Q:'IX D
  1. . S LINE=$G(^ICDD(CDFILE,CDIFN,30,IX,0)) Q:'LINE
  1. . S BEGIN=$P(LINE,U,1),END=$P(LINE,U,2) I 'END S END=9999999
  1. . I DATE'<BEGIN,DATE'>END S ARRHSX(+$P(LINE,U,3))=CDIFN
  1. Q
  1. ;
  1. ;
  1. PRCLS(ICDPR,ICDDATE,PRARR) ; reset PRATT for Clusters, determine Cluster OR/NOR attribute for each event Procedure, if found then re-set event OR/NOR
  1. ; identify all active clusters satified by the event procedures, set all cluster procedures OR/NOR to the Clusters OR/NOR
  1. ; the cluster identified is an indicator and not definitive, each procedure may be assigned to multiple clusters
  1. ; assumes that all clusters a procedure is a member of is the same type, either all OR clusters or all NOR clusters
  1. ;
  1. ; Input: ICDPR(x) - array of Procedures into API, ICDDATE - event date
  1. ; PRARR(x) - pr ifn (#80.1) ^ Procedure (OR/NOR) ^ (reserved Cltr) ^ (reserved Clst Type) ^ ^ ^ OR/NOR applies
  1. ; Output: PRARR - 'O' if any procedure/cluster is an Operating Room procedure, 'N' if Non-OR only or blank
  1. ; - list of all MDC's associated with any of the Operating Room procedures, separated by ';'
  1. ; PRARR(x) - pr ifn (#80.1) ^ Procedure (OR/NOR) ^ Cluster IFN ^ Cluster (OR/NOR) ^ ^ ^ OR/NOR applies
  1. ; w/ OR/NOR = O/N/blank for specific procedure/cluster and w/'x' corresponds to entry in ICDPR array
  1. ; - if Procedure is a member of an active cluster then 'Cluster IFN' and 'Cluster (OR/NOR)' are set and
  1. ; 'OR/NOR applies' is updated to the Clusters OR/NOR attribute
  1. N PRI,PR,CLSIFN,ATTLN,ARRCLS
  1. ;
  1. ; get list of all potential clusters, any cluster one of the event procedures belongs to
  1. S PRI=0 F S PRI=$O(ICDPR(PRI)) Q:'PRI S PR=+$G(ICDPR(PRI)) D
  1. . S CLSIFN=0 F S CLSIFN=$O(^ICDD(83.61,"ACL",PR,CLSIFN)) Q:'CLSIFN S ARRCLS(CLSIFN,PRI)=""
  1. ;
  1. ; find all active satisfied clusters and update the procedures affected
  1. S CLSIFN=0 F S CLSIFN=$O(ARRCLS(CLSIFN)) Q:'CLSIFN D
  1. . ;
  1. . I '$$CLSTR^ICDJC2(CLSIFN,.ICDPR) Q ; determine if cluster is satified by event procedures
  1. . ;
  1. . S ATTLN=$$GETATT("CL",CLSIFN,$G(ICDDATE)) I 'ATTLN Q ; determine if cluster is active, if active get its attribute
  1. . ;
  1. . S PRI=0 F S PRI=$O(ARRCLS(CLSIFN,PRI)) Q:'PRI I $D(PRARR(PRI)) D
  1. .. S $P(PRARR(PRI),U,3)=CLSIFN,$P(PRARR(PRI),U,4)=$P(ATTLN,U,3),$P(PRARR(PRI),U,7)=$P(ATTLN,U,3)
  1. ;
  1. S ATTLN="" S PRI=0 F S PRI=$O(PRARR(PRI)) Q:'PRI I ATTLN'="O",$P(PRARR(PRI),U,7)'="" S ATTLN=$P(PRARR(PRI),U,7)
  1. ;
  1. S PRARR=ATTLN_U_$$GETMDC("PR",.ICDPR,$G(ICDDATE)) ; set event procedure/cluster attibutes - final OR/NonOR and MDC list
  1. Q