source: FOIAVistA/trunk/r/DRG_GROUPER-ICD--ICPT/ICDDRG0.m@ 767

Last change on this file since 767 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 9.3 KB
Line 
1ICDDRG0 ;ALB/GRR/EG/ADL - DRG GROUPER PROCESSING BEGINS ; 11/13/07 4:06pm
2 ;;18.0;DRG Grouper;**1,2,7,10,14,17,20,24,27,30,31,32**;Oct 20, 2000;Build 9
3 ;GROUPING PROCESS BEGINS
4 ;
5GROUP ;
6 I $D(ICDSEX(1))&($D(ICDSEX(2))) S ICDRTC=4,ICDDRG=$S(ICDDATE>3070930.9:999,1:470) G KILL^ICDDRG
7 I ICDMDC'=14,ICDMDC'=17,ICDMDC'=18,ICDMDC'=19,ICDMDC'=20,ICDMDC'=23,ICDMDC'=15 D:ICDOPCT<2 I ((ICDDATE'>3070930.9)&("468^476^477"[ICDRG))!((ICDDATE>3070930.9)&("983^986^989"[ICDRG)) G END
8 . I $D(ICDF) Q
9 . I ICDPD["M",ICDOR'["y" S ICDOPCT=0 Q
10 . I ICDDATE>3070930.9 D
11 . . I ICDORNI["O",ICDNOR=ICDONR,ICDNOR>0,'$D(ICDPDRG(769)),ICDORNI'["p" S ICDRG=$S($D(ICDORNI("O")):983,ICDORNI["y":986,ICDORNI["z":989,1:983) Q
12 . . I ICDOPNR S ICDRG=$S(ICDORNI["y":986,1:983),ICDOPNR=0 Q
13 . E D
14 . . I ICDORNI["O",ICDNOR=ICDONR,ICDNOR>0,'$D(ICDPDRG(377)),ICDORNI'["p" S ICDRG=$S($D(ICDORNI("O")):468,ICDORNI["y":476,ICDORNI["z":477,1:468) Q
15 . . I ICDOPNR S ICDRG=$S(ICDORNI["y":476,1:468),ICDOPNR=0 Q
16 ;
17 ;if number of non-extensive ORs eqs # OR, 477
18 ;
19 I ICDMDC'=14,ICDMDC'=17,ICDMDC'=18,ICDMDC'=19,ICDMDC'=20,ICDMDC'=23,ICDMDC'=15,ICDORNI'["y"&(ICDORNI'="")&(ICDORNI["z") D I ((ICDDATE'>3070930.9)&(ICDRG=477))!((ICDDATE>3070930.9)&(ICDRG=989)) G END
20 . I $D(ICDF) Q
21 . NEW K S K=$$ORNI(ICDORNI) I K=ICDOPCT S ICDRG=$S(ICDDATE>3070930.9:989,1:477) Q
22 ;
23 ;if number of non-extensive ORs+prostatics eqs # OR, 476
24 ;
25 I ICDMDC'=14,ICDMDC'=17,ICDMDC'=18,ICDMDC'=19,ICDMDC'=20,ICDMDC'=23,ICDMDC'=15,ICDORNI["y"&(ICDORNI'="") D I ((ICDDATE'>3070930.9)&(ICDRG=476))!((ICDDATE>3070930.9)&(ICDRG=986)) G END
26 .N K S K=$$ORNI(ICDORNI) I K=ICDOPCT&(ICDNOR=ICDONR) S ICDRG=$S(ICDDATE>3070930.9:986,1:476) Q
27 I ICDMDC'=14,ICDMDC'=17,ICDMDC'=18,ICDMDC'=19,ICDMDC'=20,ICDMDC'=23,ICDMDC'=15,ICDNOR=ICDONR&(ICDOPCT>0) S ICDRG=$S(ICDDATE>3070930.9:983,1:468) G END
28 I ICDMDC=5,ICDOR'["O" S ICDRTC=$S(ICDEXP="":5,1:"") S:ICDRTC'="" ICDRG=$S(ICDDATE>3070930.9:999,1:470) D:ICDRTC="" MI G END
29 ;I ICDMDC=18,ICDOR["O"!(ICDORNI["O") S ICDRG=415 G END ;;disabled by ICD*18*24 and new DRGs 578/579 - see ICDTLB6C
30 I ICDMDC=19,ICDOCNT>0,ICDOR["O" S (ICDRG,HICDRG)=$S(ICDDATE>3070930.9:876,1:424) D CKDRG
31 I ICDMDC=23,ICDOR["O"!(ICDORNI["O") S ICDRG=$S(ICDDATE>3070930.9:941,1:461) G END
32 I ICDMDC=14 D ^ICDDRG14 I ICDRG]"" G END
33 I ICDMDC=20 S ICDRTC=$S(ICDDMS="":7,1:"") I ICDDMS'=0 D G END
34 . I ICDDATE>3070930.9 S ICDRG=$S(ICDDMS="":999,1:894) Q
35 . S ICDRG=$S(ICDDMS="":470,1:433)
36 I ICDMDC=22 S ICDRTC=$S(ICDTRS="":6,1:"") S:ICDRTC'="" ICDRG=$S(ICDDATE>3070930.9:999,1:470) D:ICDRTC="" CKBURN G END
37 I ICDMDC=15 S ICDRTC=$S(ICDEXP="":5,ICDTRS="":6,1:"") I ICDTRS'=0 D G END
38 . I ICDDATE>3070930.9 S ICDRG=$S(ICDRTC'="":999,1:789) Q
39 . S ICDRG=$S(ICDRTC'="":470,1:385)
40NEONATE I 'ICDNOR!('$D(ICDODRG)) S ICDRG=$O(ICDPDRG(0)) X "I ICDMDC=15,$D(ICDSDRG),$O(ICDSDRG(0))<ICDRG D NEONATF^ICDDRG0" D D DODRG G GETMOR:ICDRG="",END
41 . N X,X1,X2,%
42 . S X1=$S($G(DGADM):$G(DGADM),1:DT),X2=$G(DOB) I X1,X2 D ^%DTC I X<29 D NBCOMP Q
43 . I ICDDATE'>3070930.9 I ICDRG<385!(ICDRG>391) Q
44 . I ICDDATE>3070930.9 I ICDRG<789!(ICDRG>795) Q
45 .; I "^11917^11918^11921^"[("^"_ICDDX(1)_"^") S ICDRG=395 Q
46 . I ICDDATE'>3070930.9 I $O(ICDRG(391)) S ICDRG=$O(ICDRG(391)) Q
47 . I ICDDATE>3070930.9 I $O(ICDRG(795)) S ICDRG=$O(ICDRG(795)) Q
48 . I 'ICDRG S ICDRG=$S(ICDDATE>3070930.9:999,1:470),ICDRTC=8
49 I AGE="",ICDMDC=3 S ICDRTC=3 S ICDRG=$S(ICDDATE>3070930.9:999,1:470) G END
50 D ^ICDDRG1:ICDMDC=1,^ICDDRG2:ICDMDC=2,^ICDDRG3:ICDMDC=3,^ICDDRG5:ICDMDC=5,^ICDDRG6:ICDMDC=6,^ICDDRG7:ICDMDC=7,^ICDDRG8:ICDMDC=8,^ICDDRG9:ICDMDC=9,^ICDDRG10:ICDMDC=10,^ICDDRG11:ICDMDC=11,^ICDDRG12:ICDMDC=12,^ICDDRG13:ICDMDC=13
51 D ^ICDDRG17:ICDMDC=17
52CONT G:ICDMDC=15 GETMOR S (ICDRG,HICDRG)=$O(ICDODRG(0)) G:ICDRG'>0 ENTER
53 D DODRG
54 G:ICDRG'>0 LOOK8:ICDMDC=8,AGAIN G END
55ENTER I 'ICDNOR,ICDORNR'=0,ICDMDC'=20,ICDMDC'=15 S ICDRG=$S(ICDDATE>3070930.9:983,1:468) G END
56GETMOR S (ICDRG,HICDRG)=$O(ICDPDRG(0)) S:ICDRG'>0 (ICDRG,HICDRG)=$S(ICDDATE>3070930.9:998,1:469)
57CKDRG D DODRG
58 I ICDRG="" K ICDPDRG(HICDRG) G GETMOR
59DODRG ;Go to DRG file and retrieve table entry to use if defined
60 N ICDMCV,ICDMCV1,ICDMCV2
61 N DRGFY,ICDREF S (DRGFY,ICDREF)=""
62 I ICDRG S DRGFY=$O(^ICD(ICDRG,2,"B",$P(+$G(ICDDATE),".")_.01),-1)
63 I 'DRGFY S DRGFY=3071001 ;default to current fiscal year
64 S ICDREF=$O(^ICD(+ICDRG,2,"B",+DRGFY,ICDREF))
65 I ICDREF'="" D
66 . S ICDREF=$P($G(^ICD(+ICDRG,2,ICDREF,0)),U,3)
67 . S ICDREF="DRG"_ICDRG_"^"_ICDREF D @ICDREF K ICDREF
68 I ICDOR["4" D DRG232^ICDTLB3
69 Q
70ORNI(X) ;
71 N I,K
72 S K=0 F I=1:1:$L(ICDORNI) I $E(ICDORNI,I,I)="z"!($E(ICDORNI,I,I)="y") S K=K+1
73 Q K
74END ;
75 D:ICDP24'=""!($D(ICDS24)) CKMST^ICDDRGX S ICDDRG=ICDRG
76 ;ICD*18*24 check for higher numbered DRG (such as new DRG 561) before checking for 489 in CKHIV^ICDDRGX
77 I ICDDATE<3071001 I ICDRG=489!(ICDRG=490)!(ICDRG=543&($G(ICDOR)="")) S ICDRG=$P($G(ICDPDRG),U,2) I ICDRG=543 S ICDRG=561
78 I ICDDATE'<3071001 I ICDRG=976!(ICDRG=977)!(ICDRG=24&($G(ICDOR)="")) S ICDRG=$P($G(ICDPDRG),U,2) I ICDRG=24 S ICDRG=99
79 D:$G(ICDP25)=1!(($G(ICDP25)>1)&($D(ICDS25(1)))) CKHIV^ICDDRGX S ICDDRG=ICDRG
80 ; this will effectively make DRG 103 into a pre-MDC (ICD*18*1)
81 I $D(ICDOP(" 33.6"))!$D(ICDOP(" 37.5"))!(ICDDATE>3030930.9&($D(ICDOP(" 37.51"))!$D(ICDOP(" 37.66")))) S ICDRG=$S(ICDDATE>3070930.9:2,1:103),ICDNMDC(1)="" D DODRG
82 I (ICDDATE>3050930.9)&($D(ICDOP(" 37.64")))&($D(ICDOP(" 37.65"))) S ICDRG=$S(ICDDATE>3070930.9:2,1:103),ICDNMDC(1)="" D DODRG
83 I (ICDDATE>3060930.9)&($D(ICDOP(" 37.63")))&($D(ICDOP(" 37.64"))) S ICDRG=$S(ICDDATE>3070930.9:2,1:103),ICDNMDC(1)="" D DODRG
84 I $D(ICDOP(" 39.65")) S ICDRG=$S(ICDDATE>3070930.9:3,1:541),ICDNMDC(1)=""
85 I (ICDDATE>3070930.9)&($D(ICDOP(" 46.97"))) S ICDRG=5,ICDNMDC(1)=""
86 ; this will create DRGs 512/513 as pre-MDC
87 I $D(ICDOP(" 52.80"))!$D(ICDOP(" 52.82")) S ICDRG=$S(ICDDATE>3070930.9:10,1:513),ICDNMDC(1)=""
88 I (ICDDATE>3070930.9) D
89 . I ICDRG=10 I $D(ICDOP(" 55.69")) S ICDRG=8
90 E I ICDRG=513 I $D(ICDOP(" 55.69")) S ICDRG=512
91 ; this will create DRG 481 as pre-MDC - loops thru 41.00 thru .09
92 N X S X=0 F S X=$O(ICDOP(X)) Q:X="" I X["41.0" S ICDRG=$S(ICDDATE>3070930.9:9,1:481),ICDNMDC(1)=""
93 I $D(ICDNMDC(1)) I ICDNMDC(1)="" D CKNMDC^ICDDRGX S ICDDRG=ICDRG K ICDNMDC
94 I ICDDATE>3070930.9 D
95 . I ICDRG=983 D CHKMDC4^ICDDRGX
96 . D DODRG S ICDDRG=ICDRG ;check for MCC/CC
97 E I ICDRG=468 D CHKMDC4^ICDDRGX D DODRG S ICDDRG=ICDRG
98 S:ICDRTC="" ICDRTC=0
99 S ICDTMP=$$DRG^ICDGTDRG(ICDDRG,ICDDATE) I '$P(ICDTMP,U,14) S ICDDRG=$S(ICDDATE>3070930.9:999,1:470)
100 G KILL^ICDDRG
101MI ;
102 ; if PTCA and not a bypass
103 I ICDOR["1"!($D(ICDOP(" 37.90"))) I ICDOR'["b"&(ICDOR'["6") D Q
104 . I ICDDATE>3070930.9 D CMS516^ICDTBL2 Q
105 . E D DRG516^ICDTLB6B
106 I ICDPD["A" D EN1^ICDDRG5 I ICDCC3 S ICDRG=$O(ICDODRG(0)) D DODRG Q
107 I ICDPD["AI"!(ICDSD["AI") D Q
108 . I ICDDATE>3070930.9 D
109 . . S ICDRG=$S($S($D(ICDEXP):ICDEXP,1:0):285,ICDPD["V"!(ICDSD["V"):280,1:282)
110 . E D
111 . . I $D(ICDOP(" 36.07")) I $D(ICDOP(" 37.26"))!($D(ICDOP(" 37.27"))) S ICDRG=526 Q
112 . . S ICDRG=$S($S($D(ICDEXP):ICDEXP,1:0):123,ICDPD["V"!(ICDSD["V"):121,1:122)
113 I $D(ICDOP(" 37.26"))&($D(ICDOP(" 39.61"))) S ICDRG=$S(ICDDATE>3070930.9:230,1:108) Q
114 ;I $D(ICDOP(" 37.26")) S ICDRG=112 Q
115 I ICDDATE<3071001 I $D(ICDOP(" 36.07")) I $D(ICDOP(" 37.26"))!($D(ICDOP(" 37.27"))) S ICDRG=527 Q
116 I ICDDATE<3071001 I $D(ICDOP(" 36.06")) I $D(ICDOP(" 37.26"))!$D(ICDOP(" 37.27")) S ICDRG=517 Q
117 I $D(ICDOP(" 37.26"))!$D(ICDOP(" 37.27")) S ICDRG=$S(ICDDATE>3070930.9:251,1:518) Q
118 I ICDOR["H" D Q
119 . I ICDDATE>3070930.9 S ICDRG=$S(ICDPD["X"!(ICDSD["X"):286,1:287) Q
120 . E S ICDRG=$S(ICDPD["X"!(ICDSD["X"):124,1:125) Q
121 I ICDDATE>3070930.9 K ICDPDRG(286),ICDPDRG(287)
122 E K ICDPDRG(124)
123 I ICDOR["p" S ICDRG=$O(ICDODRG(0)) D DODRG Q
124 I ICDOR["F" S ICDRG=$O(ICDODRG(0)) D DODRG Q
125 E D Q
126 . I ICDDATE>3070930.9 K ICDPDRG(280),ICDPDRG(281),ICDPDRG(282) S ICDRG=$O(ICDPDRG(0)) D DODRG Q
127 . E K ICDPDRG(121) S ICDRG=$O(ICDPDRG(0)) D DODRG Q
128 ;
129CKBURN ; MDC22 - Burns (extensive, full thickness, or non-extensive)
130 D
131 . I ICDPD["*"!(ICDSD["*") D Q
132 . . I ICDDATE>3070930.9 S ICDRG=$S(ICDOR["k":927,1:933) Q
133 . . E S ICDRG=$S(ICDOR["k":504,1:505) Q
134 . I ICDPD["b"!(ICDSD["b") D FTBURN Q
135 . I ICDDATE>3070930.9 S ICDRG=$S(ICDCC!(ICDPD["T")!(ICDSD["T"):935,1:935)
136 . E S ICDRG=$S(ICDCC!(ICDPD["T")!(ICDSD["T"):510,1:511)
137 Q
138 ;
139AGAIN G:'$D(ICDODRG) ENTER
140 K ICDODRG(HICDRG) I $O(ICDODRG(HICDRG))'>0 K ICDODRG G GROUP
141 S ICDRG=$O(ICDODRG(HICDRG)) G GROUP
142 ;
143 ;
144LOOK8 G:'$D(ICDJ) GETMOR
145 S ICDJ=$O(ICDJ(0)) G:ICDJ'>0 GETMOR
146 K ICDJ(ICDJ),ICDODRG D END^ICDDRG8 G GETMOR:'$D(ICDODRG),CONT
147 Q
148 ;
149NBCOMP ; check for complication related to NB
150 I ICDSD'["J"!'$D(ICDSDRG) Q
151 N ICDSDXCK
152 S ICDSDXCK=$O(ICDSDRG(0))
153 I ICDDATE>3070930.9 D
154 . I ICDSDXCK<ICDRG,ICDSDXCK>788,ICDSDXCK<796 D
155 .. S ICDRG=$S($D(ICDPDRG(795)):795,$D(ICDPDRG(791)):791,1:$O(ICDSDRG(0)))
156 E D
157 . I ICDSDXCK<ICDRG,ICDSDXCK>384,ICDSDXCK<392 D
158 .. S ICDRG=$S($D(ICDPDRG(391)):391,$D(ICDPDRG(387)):387,1:$O(ICDSDRG(0)))
159 Q
160 ;
161FTBURN ; full thickness burn check
162 I ICDSD["j"!(ICDOR["k") D
163 . I ICDCC!(ICDPD["T")!(ICDSD["T") S ICDRG=$S(ICDDATE>3070930.9:928,1:506)
164 . E S ICDRG=$S(ICDDATE>3070930.9:929,1:507)
165 E D
166 . I ICDCC!(ICDPD["T")!(ICDSD["T") S ICDRG=$S(ICDDATE>3070930.9:934,1:508)
167 . E S ICDRG=$S(ICDDATE>3070930.9:934,1:509)
168 Q
169 ;
170NEONATF ;NEONATE - Continuation of xecute line
171 I ICDDATE>3070930.9 S ICDRG=$S($D(ICDPDRG(795)):795,$D(ICDPDRG(791)):791,1:$O(ICDSDRG(0))) Q
172 S ICDRG=$S($D(ICDPDRG(391)):391,$D(ICDPDRG(387)):387,1:$O(ICDSDRG(0)))
173 Q
Note: See TracBrowser for help on using the repository browser.