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

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

initial load of WorldVistAEHR

File size: 7.8 KB
Line 
1DGMSTR3 ;ALB/GRR - GENERATE AND PRINT MST STATISTICAL REPORT ; 1/30/01 10:45am
2 ;;5.3;Registration;**195,319**; Aug 13, 1993
3 ;^TMP("DGMSTR3,JOB... - Array to hold ICD codes
4 ;DGPCDT - Current date in print format
5 ;DGSDAT - Start Date of selection range
6 ;DGEDAT - End Date of selection range
7 ;DGDX - ICD Code
8 ;DGDLOS - Length of Stay
9 ;DGPDAYS - Pass days
10 ;DGMST("N") - Number of new cases of MST
11 ;DGMST("O","R") - Number of outpatient visits related to MST
12 ;DGMST("O","NR") - Number of outpatient visits not related to MST
13 ;DGMST("O","U") - Number of unique outpatients treated for MST
14 ;DGMST("O","AR") - Average number of outpatient visits related to MST
15 ;DGMST("O","ANR") - Average number of outpatient visits not related to MST
16 ;DGMST("I", - Same totals as above except for inpatient
17 ;DGMST("LOS") - Total Length of Stay related to MST
18EN ;ENTRY POINT FOR ROUTINE
19 N TJOB
20 S TJOB=$J
21 K ^TMP("DGMSTR3",$J)
22 N DGMST,DGPCDT,DGSUB,DGSTAT,DGPSDT,DGPEDT,DTOUT,DUOUT,ZTSAVE,X,Y
23 N DTOUT,DUOUT,ZTSAVE
24 K DGMST
25 D DT^DICRW
26 S Y=DT D DD^%DT S DGPCDT=Y
27 F DGSTAT="O","I" F DGSUB="R","NR","U","AR","ANR","T" S DGMST(DGSTAT,DGSUB)=0
28 S DGMST("N")=0,DGMST("LOS")=0,DGMST("ALOS")=0
29 ;GET DATE RANGE
30SDAT S DIR(0)="D^:"_DT_":EX",DIR("A")="Start Date"
31 D ^DIR K DIR
32 Q:$D(DTOUT)!($D(DUOUT))
33 S DGSDAT=+Y,Y=+Y D DD^%DT S DGPSDT=Y
34TDAT S DIR(0)="D^"_DGSDAT_":"_DT_":EX",DIR("A")="End Date"
35 D ^DIR K DIR
36 Q:$D(DTOUT)!($D(DUOUT))
37 S DGEDAT=+Y_.9999,Y=+Y D DD^%DT S DGPEDT=Y
38DEVICE F X="DGMST(","DGSDAT","DGPSDT","DGEDAT","DGPEDT","DGPCDT" S ZTSAVE(X)=""
39 W !!,"This may take long to print, queue the report to free-up your terminal!",!
40 D EN^XUTMDEVQ("RPT^DGMSTR3","MST Statistical Summary",.ZTSAVE)
41 D HOME^%ZIS
42 Q
43RPT ;LOOP THROUGH AND CALCULATE NEW MST CASES
44 N DFN,SEX,DGSEDT,DGDATE,DGEIEN,DGAPST,DGCALC,DGTYP,DGGEN,DGIEN,DA,X,Y,DTOUT,DUOUT,VADM
45 N DGCSTAT,DGDA,DGCC,DGCLIEN,DGDX,DGMIEN,DGPTFIEN,DGLOS,DGPDAYS
46 N DGDXERR,DGLOS,DGOCIEN
47 S DGDATE=DGSDAT F S DGDATE=$O(^DGMS(29.11,"B",DGDATE)) Q:DGDATE'>0!(DGDATE>DGEDAT) S DGIEN=0 F S DGIEN=$O(^DGMS(29.11,"B",DGDATE,DGIEN)) Q:DGIEN'>0 S:$P($G(^DGMS(29.11,DGIEN,0)),"^",3)="Y" DGMST("N")=DGMST("N")+1
48 ;GET IEN FOR MST CLASSIFICATION TYPE
49 S DIC=409.41,DIC(0)="X",X="MILITARY SEXUAL TRAUMA"
50 D ^DIC K DIC
51 I Y'>0 W !!,"Military Sexual Trauma entry missing from Outpatient Classification Type (409.41) file" Q
52 S DGOCIEN=+Y K DFN S DFN=""
53 ;CALCULATE OUTPATIENT TOTALS
54 S DGDATE=DGSDAT F S DGDATE=$O(^SCE("B",DGDATE)) Q:DGDATE'>0!(DGDATE>DGEDAT) D
55 .S DGEIEN=0 F S DGEIEN=$O(^SCE("B",DGDATE,DGEIEN)) Q:DGEIEN'>0 D
56 ..S Y(0)=$G(^SCE(DGEIEN,0)) Q:Y(0)=""
57 ..S DFN=$P(Y(0),"^",2),DGAPST=$P(Y(0),"^",12) Q:DGAPST=8 ;DGAPST=8 MEANS INPATIENT, DONT COUNT
58 ..I DFN="" Q
59 ..S DGCSTAT=$$GETSTAT^DGMSTAPI(DFN,DGEDAT)
60 ..S DGCC=$P(DGCSTAT,"^",2)
61 ..I DGCC'="Y"&(DGCC'="N")&(DGCC'="D")&(DGCC'="U") Q
62 ..S DGCLIEN=$O(^SDD(409.42,"AO",DGEIEN,DGOCIEN,0)),DGMST("O","T")=DGMST("O","T")+1 I DGCLIEN]"" D
63 ...I $P($G(^SDD(409.42,DGCLIEN,0)),"^",3)'=1 S DGMST("O","NR")=DGMST("O","NR")+1
64 ...E S DGMST("O","R")=DGMST("O","R")+1 I '$D(DFN(DFN,"O")) S DFN(DFN,"O")="",DGMST("O","U")=DGMST("O","U")+1
65 ..D DEM^VADPT S SEX=$P(VADM(5),"^")
66 ..I SEX="M"!(SEX="F") D
67 ...S DGDX=$$GETPDX^SDOE(DGEIEN,.DGDXERR) ;; CHANGED 4.16.99 SCK CORRECT FOR API
68 ...I DGDX'="" S DGDX=$P($G(^ICD9(DGDX,0)),"^") I DGDX'="" D
69 ....I '$D(^TMP("DGMSTR3",$J,DGDX)) F DGGEN="M","F" F DGTYP="I","O" S ^TMP("DGMSTR3",$J,DGDX,DGGEN,DGTYP)=0
70 ....S ^TMP("DGMSTR3",$J,DGDX,SEX,"O")=^TMP("DGMSTR3",$J,DGDX,SEX,"O")+1
71 ;LOOP FOR INPATIENT CALCULATIONS
72 S DGDATE=DGSDAT F S DGDATE=$O(^DGPM("B",DGDATE)) Q:DGDATE'>0!(DGDATE>DGEDAT) S DGDA=0 F S DGDA=$O(^DGPM("B",DGDATE,DGDA)) Q:DGDA'>0 S DGPTFIEN=$P($G(^DGPM(DGDA,0)),"^",16) I DGPTFIEN'="" D
73 .S DGMIEN=0,DGPDAYS=0,DGCALC=0 F S DGMIEN=$O(^DGPT(DGPTFIEN,"M",DGMIEN)) Q:DGMIEN'>0 D
74 ..S Y(0)=$G(^(DGMIEN,0)),DGPDAYS=DGPDAYS+(+$P(Y(0),"^",4)),DGMST("I","T")=DGMST("I","T")+1
75 ..I $P(Y(0),"^",29)="Y" D
76 ...S DGMST("I","R")=DGMST("I","R")+1,DGCALC=1
77 ...S DFN=$P(^DGPT(DGPTFIEN,0),"^")
78 ...Q:DFN=""
79 ...I '$D(DFN(DFN,"I")) S DFN(DFN,"I")="",DGMST("I","U")=DGMST("I","U")+1
80 ...S DGDX=$P(Y(0),"^",5) D DEM^VADPT S SEX=$P(VADM(5),"^")
81 ...I DGDX'="",SEX="M"!(SEX="F") S DGDX=$P($G(^ICD9(DGDX,0)),"^") I DGDX'="" D
82 ....I '$D(^TMP("DGMSTR3",$J,DGDX)) F DGGEN="M","F" F DGTYP="I","O" S ^TMP("DGMSTR3",$J,DGDX,DGGEN,DGTYP)=0
83 ....S ^TMP("DGMSTR3",$J,DGDX,SEX,"I")=^TMP("DGMSTR3",$J,DGDX,SEX,"I")+1
84 ..E S DGMST("I","NR")=DGMST("I","NR")+1
85 .I +$G(DGCALC)>0,$P($G(^DGPT(DGPTFIEN,70)),"^")]"" D
86 ..S DGLOS=$$CALCLOS(DGPTFIEN,DGPDAYS),DGMST("LOS")=DGMST("LOS")+DGLOS
87PRT ;LAST CALCULATIONS AND PRINT
88 I DGMST("LOS")>0 S DGMST("ALOS")=DGMST("LOS")/DGMST("I","R")
89 I DGMST("O","T")>0 S DGMST("O","AR")=$J(DGMST("O","R")/DGMST("O","T"),7,2),DGMST("O","ANR")=$J(DGMST("O","NR")/DGMST("O","T"),7,2)
90 I DGMST("I","T")>0 S DGMST("I","AR")=$J(DGMST("I","R")/DGMST("I","T"),7,2),DGMST("I","ANR")=$J(DGMST("I","NR")/DGMST("I","T"),7,2)
91 D NOFF
92 W !!,"# OF NEW CASES IDENTIFIED FOR MST",?78-$L(DGMST("N")),DGMST("N")
93 W !!,"-------------OUTPATIENT STATISTICS-------------"
94 W !!,"# OF OUTPATIENT ENCOUNTERS RELATED TO MST",?78-$L(DGMST("O","R")),DGMST("O","R")
95 W !,"# OF OUTPATIENT ENCOUNTERS NOT RELATED TO MST",?78-$L(DGMST("O","NR")),DGMST("O","NR")
96 W !,"# OF UNIQUE OUTPATIENTS TREATED FOR MST",?78-$L(DGMST("O","U")),DGMST("O","U")
97 W !,"AVERAGE # OF ENCOUNTERS RELATED TO MST",?78-$L(DGMST("O","AR")),DGMST("O","AR")
98 W !,"AVERAGE # OF ENCOUNTERS NOT RELATED TO MST",?78-$L(DGMST("O","ANR")),DGMST("O","ANR")
99 W !!,"-------------INPATIENT STATISTICS---------------"
100 W !!,"# OF INPATIENT EPISODES RELATED TO MST",?78-$L(DGMST("I","R")),DGMST("I","R")
101 W !,"# OF INPATIENT EPISODES NOT RELATED TO MST",?78-$L(DGMST("I","NR")),DGMST("I","NR")
102 W !,"# OF UNIQUE INPATIENTS TREATED FOR MST",?78-$L(DGMST("I","U")),DGMST("I","U")
103 W !,"AVERAGE # OF INPATIENT EPISODES TREATED FOR MST",?78-$L(DGMST("I","AR")),DGMST("I","AR")
104 W !,"AVERAGE # OF INPATIENT EPISODES NOT TREATED FOR MST",?78-$L(DGMST("I","ANR")),DGMST("I","ANR")
105 W !,"TOTAL LENGTH OF STAY OF INPATIENTS TREATED FOR MST",?78-$L(DGMST("LOS")),DGMST("LOS")
106 W !,"AVERAGE LENGTH OF STAY OF INPATIENTS TREATED FOR MST",?78-$L(DGMST("ALOS")),DGMST("ALOS")
107 I $Y+3>$G(IOSL) D Q:$D(DTOUT)!($D(DUOUT))
108 .I $E(IOST,1,2)="C-" S DIR(0)="E" D ^DIR K DIR Q:$D(DTOUT)!($D(DUOUT))
109 .;I IO=IO(0) S DIR(0)="E" D ^DIR K DIR Q:$D(DTOUT)!($D(DUOUT))
110 .D HED
111 G:$O(^TMP("DGMSTR3",$J,0))="" END1 ;;CHANGED BY SCK 4.16.99 CHECK ON ERROR
112 W !!,"ICD-9 CODE",?24,"NUMBER OF MALE",?54,"NUMBER OF FEMALE"
113 W !,?22,"OUTPATIENT",?35,"INPATIENT",?52,"OUTPATIENT",?65,"INPATIENT"
114 S DGDX="" F S DGDX=$O(^TMP("DGMSTR3",$J,DGDX)) Q:DGDX="" D Q:$D(DTOUT)!($D(DUOUT))
115 .I $Y+3>IOSL D Q:$D(DTOUT)!($D(DUOUT))
116 ..I $E(IOST,1,2)="C-" S DIR(0)="E" D ^DIR K DIR Q:$D(DTOUT)!($D(DUOUT))
117 ..;I IO=IO(0) S DIR(0)="E" D ^DIR K DIR Q:$D(DTOUT)!($D(DUOUT))
118 ..D HED W !!,"ICD-9 CODE",?24,"NUMBER OF MALE",?54,"NUMBER OF FEMALE",!,?22,"OUTPATIENT",?35,"INPATIENT",?52,"OUTPATIENT",?65,"INPATIENT"
119 .W !,?2,DGDX,?28-$L(^TMP("DGMSTR3",$J,DGDX,"M","O"))
120 .W ^TMP("DGMSTR3",$J,DGDX,"M","O")
121 .W ?40-$L(^TMP("DGMSTR3",$J,DGDX,"M","I"))
122 .W ^TMP("DGMSTR3",$J,DGDX,"M","I")
123 .W ?58-$L(^TMP("DGMSTR3",$J,DGDX,"F","O")),^TMP("DGMSTR3",$J,DGDX,"F","O")
124 .W ?70-$L(^TMP("DGMSTR3",$J,DGDX,"F","I"))
125 .W ^TMP("DGMSTR3",$J,DGDX,"F","I")
126 I $E(IOST,1,2)="C-" S DIR="E" D ^DIR K DIR
127END1 K DA,DGSDAT,DGEDAT,DGMST,DGPCDT,DGPEDT,DGPSDT,X,Y
128 K ^TMP("DGMSTAPI",$J)
129 K TJOB
130 Q
131 ;
132CALCLOS(DGPTFIEN,DGPDAYS) ;CALCULATE LOS FOR EPISODE
133 N DGADT,DGDDT,DGLDAYS,DGDAYS,Y,X1,X2
134 S Y(70)=$G(^DGPT(DGPTFIEN,70)) Q:Y(70)="" 0
135 S DGDDT=$P(Y(70),"^")\1,DGADT=$P(^DGPT(DGPTFIEN,0),"^",2)\1,DGLDAYS=$P(Y(70),"^",8)
136 S X1=DGDDT,X2=DGADT D ^%DTC
137 S DGDAYS=X-(DGLDAYS+DGPDAYS)
138 Q DGDAYS
139 ;
140HED ;PRINT HEADER INFO
141 W @IOF
142NOFF W !,?20,"MST Statistical Report"
143 W !,?20,"Date Range: ",DGPSDT," - ",DGPEDT
144 W !,?20,"Date Report Printed: ",DGPCDT
145 Q
146 ;
Note: See TracBrowser for help on using the repository browser.