source: WorldVistAEHR/trunk/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/DGPTOD2.m@ 861

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

initial load of WorldVistAEHR

File size: 3.5 KB
RevLine 
[613]1DGPTOD2 ;ALB/BOK - PTF DRG REPORTS, BUILD UTILITY, CONT. ; 9/14/01 5:57pm
2 ;;5.3;Registration;**375,744**;Aug 13, 1993;Build 5
3 S DGCNT=0 D SET:DGB,DRG:'DGB Q
4SET F DGMV=0:0 S DGMV=$O(^DGPT(DGPTF,"M",DGMV)) Q:DGMV'>0 I $D(^DGPT(DGPTF,"M",DGMV,"P")) S DGPM=^("P"),DGTLOS=$P(DGPM,U,4),DGDRG=+DGPM,DGLBS=$P(^DGPT(DGPTF,"M",DGMV,0),U,2),DGSVC=$P(DGPM,U,2),DGPROV=$P(DGPM,U,5) I DGDRG D UTIL,COMP,CASEMIX
5 Q
6UTIL Q:'DGDRG D:'$D(^UTILITY($J,"DRG",DGDRG)) WWU^DGPTOD1 S DGDRGI=^(DGDRG)
7 I "DB"[DGS S $P(^(DGDRG),U)=$S($D(^UTILITY($J,"DGPTFR","D",DGDRG)):$P(^(DGDRG),U),1:0)+DGTLOS,$P(^(DGDRG),U,2)=$P(^(DGDRG),U,2)+1 I $P(^(DGDRG),U,2)=1 S ^(DGDRG)=^(DGDRG)_U_DGDRGI,$P(^(DGDRG),U,7)=$P(^(DGDRG),U,8)
8 I "SB"[DGS,DGSVC]"" D SET1 S $P(^(DGDRG),U,1)=$S($D(^UTILITY($J,"DGPTFR","SB",DGSVC,DGLBS,DGDRG)):$P(^(DGDRG),U,1),1:0)+DGTLOS,$P(^(DGDRG),U,2)=$P(^(DGDRG),U,2)+1 I $P(^(DGDRG),U,2)=1 S ^(DGDRG)=^(DGDRG)_U_DGDRGI
9 Q
10DRG Q:'$D(^DGPT(DGPTF,"M",1))
11 S DGLBS=$P(^DGPT(DGPTF,"M",1,0),U,2),DGSVC=$S(DGLBS:$P(^DIC(42.4,+DGLBS,0),U,3),1:"") Q:DGSVC']""
12 S DGLOS=$S($D(^DGPT(DGPTF,"M",1,"P")):$P(^("P"),U,6),1:""),PTF=DGPTF,DGTLOS=$S($D(^DGPT(DGPTF,"M",1,"P")):$P(^("P"),U,4),1:0),DGCPT="",DGPROV=$P($G(^DGPT(DGPTF,"M",1,"P")),U,5) D EN1^DGPTFD
13 I $D(DRG) S DGDRG=DRG D LOS:'DGLOS,UTIL,COMP,CASEMIX K DRG Q
14 Q
15COMP I DGTLOS,"DB"[DGS,DGDRG S Z=^UTILITY($J,"DGPTFR","D",DGDRG) D SETSUB,SETD
16 I DGTLOS,DGSVC]"","SB"[DGS,DGDRG,DGLBS S Z=^UTILITY($J,"DGPTFR","SB",DGSVC,DGLBS,DGDRG) D SETSUB,SETSB ;DG*5.3*375 changed the check on DGSVC
17 Q
18SETSUB S A=$S(DGTLOS>$P(Z,U,5):"AA",1:"BA"),T=$S(DGTLOS<$P(Z,U,3)!(DGTLOS=1):"BT",DGTLOS>$P(Z,U,4):"AT",1:"WT"),DGOUT=$S(T="AT"&($P(DGDRGI,U,2)):($S(DGTLOS<366:DGTLOS,1:365)-$P(DGDRGI,U,2)),1:0),DG1D=$S(T="BT"&(DGTLOS=1):1,1:0)
19 S B=$S($P(Z,U,7)']"":"",DGTLOS<$P(Z,U,7):"BBE",1:"ABE"),DGPR=$S(T="BT"&(DGTLOS>1):DGTLOS,1:0)
20 Q
21SETD F W=A,T,B I W]"" S $P(^(W),U,1)=$S($D(^UTILITY($J,"DGPTFR","D",DGDRG,W)):$P(^(W),U,1),1:0)+DGTLOS,$P(^(W),U,2)=$P(^(W),U,2)+1,$P(^(W),U,3)=$P(^(W),U,3)+DGOUT,$P(^(W),U,4)=$P(^(W),U,4)+DG1D,$P(^(W),U,5)=$P(^(W),U,5)+DGPR D:DGPR LOW
22 Q
23LOW S $P(^(W),U,6)=$P(^UTILITY($J,"DGPTFR","D",DGDRG,W),U,6)+1 Q
24SETSB F W=A,T,B I W]"" D SETSB1
25 Q
26SETSB1 S $P(^(W),U)=$S($D(^UTILITY($J,"DGPTFR","SB",DGSVC,DGLBS,DGDRG,W)):$P(^(W),U),1:0)+DGTLOS,$P(^(W),U,2)=$P(^(W),U,2)+1,$P(^(W),U,3)=$P(^(W),U,3)+DGOUT,$P(^(W),U,4)=$P(^(W),U,4)+DG1D,$P(^(W),U,5)=$P(^(W),U,5)+DGPR D:DGPR LOW1
27 Q
28LOW1 S $P(^(W),U,6)=$P(^UTILITY($J,"DGPTFR","SB",DGSVC,DGLBS,DGDRG,W),U,6)+1 Q
29SET1 S K=DGSVC,DGSNM=$S(K="M":"MEDICINE",K="S":"SURGERY",K="P":"PSYCHIATRY",K="NE":"NEUROLOGY",K="R":"REHAB MEDICINE",K="NH":"NHCU",K="I":"INTERMEDIATE MED",K="SCI":"SPINAL CORD INJURY",K="D":"DOMICILIARY",K="B":"BLIND REHAB",1:"RESPITE CARE")
30 I '$G(DGLBS) S DGLBS=83 ; use Respite Care
31 S ^UTILITY($J,"DGPTFR","SB",DGSVC)=DGSNM,^UTILITY($J,"DGPTFR","SB",DGSVC,DGLBS)=$P(^DIC(42.4,DGLBS,0),U,1) Q
32LOS S X2=$S('DGTLOS:$P(^DGPT(DGPTF,0),U,2),1:X2),X1=$S($P(^DGPT(DGPTF,"M",1,0),U,10)]"":$P(^(0),U,10),1:DT) D ^%DTC S DGTLOS=$S(X<1:1,1:X) Q
33 Q
34CASEMIX ;
35 S DGWGT=$P($G(^ICD(DGDRG,"FY",DGFY2K,0)),U,2)
36 I DGWGT="",DGFY2K="3070000" S DGWGT=$S($D(^ICD(DGDRG,"FY",DGFY2K,0)):(^(0)),1:"")
37 I DGWGT="",DGFY2K="3070000" N DGFY2KSV,DGFY2KYR S DGFY2KSV=DGFY2K,DGFY2KYR=$E(DGFY2K,1,3)-1,DGFY2K=DGFY2KYR_"0000" G CASEMIX
38 I $G(DGFY2KSV) S DGFY2K=DGFY2KSV
39 S DGCNT=DGCNT+1
40 ; next line is to avoid adding duplicates when the
41 ; "Batch Multiple DRG Reports" option is used
42 Q:$D(^UTILITY("DGPTOD1","CASEMIX",DGPTF,DGCNT))
43 S ^UTILITY("DGPTOD1","CASEMIX",DGPTF,DGCNT)=DGDRG_U_DGWGT_U_DGSVC_U_DGLBS_U_DGPROV
44 Q
Note: See TracBrowser for help on using the repository browser.