source: FOIAVistA/trunk/r/DSS_EXTRACTS-ECX/ECXSASUR.m@ 1801

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

initial load of FOIAVistA 6/30/08 version

File size: 4.8 KB
Line 
1ECXSASUR ;BIR/DMA-SAS Report from Surgery Extract; 19 Jul 95 / 11:13 AM
2 ;;3.0;DSS EXTRACTS;**8**;Dec 22, 1997
3EN ;entry point from menu option
4 W @IOF,!!,"Surgery Extract SAS Report",!!
5 ;ecxaud=1 for 'sas' audit
6 S ECXHEAD="SUR",ECXAUD=1
7 ;select extract
8 D AUDIT^ECXUTLA(ECXHEAD,.ECXERR,.ECXARRAY,ECXAUD)
9 I ECXERR D AUDIT^ECXKILL Q
10 ;select all surgery sites/divisions
11 S ECXALL=1 D SUR^ECXDVSN2(.ECXDIV,ECXALL,.ECXERR)
12 I ECXERR D AUDIT^ECXKILL Q
13 W !!
14 S ECXPGM="PROCESS^ECXSASUR",ECXDESC="Surgery Extract SAS Report"
15 S ECXSAVE("ECXHEAD")="",ECXSAVE("ECXDIV(")="",ECXSAVE("ECXARRAY(")=""
16 W !
17 D DEVICE^ECXUTLA(ECXPGM,ECXDESC,.ECXSAVE)
18 I ECXSAVE("POP")=1 D Q
19 .W !!,?5,"Try agian later... exiting.",!
20 .D AUDIT^ECXKILL
21 I ECXSAVE("ZTSK")=0 D
22 .K ECXSAVE,ECXPGM,ECXDESC
23 .D PROCESS
24 I IO'=IO(0) D ^%ZISC
25 D HOME^%ZIS
26 D AUDIT^ECXKILL
27 Q
28 ;
29PROCESS ;queued entry
30 N J,JJ,X,Y,SS,LN,PG,DIV,EC,EC16,EC31,ECF1,ECFK,ECFL,ECFLNM,ECFLX,ECFX,QFLG,TOT,F1,F1SUB,F1NM,F2,F2SUB,F2NM,FL,DIQ,DR,DA,DIR,DIRUT,DTOUT,DUOUT
31 K ^TMP($J,"ECXAUD")
32 S ECXEXT=ECXARRAY("EXTRACT"),ECXDEF=ECXARRAY("DEF")
33 S (QFLG,PG)=0,$P(LN,"-",80)=""
34 ;get run date in external format
35 D NOW^%DTC S Y=$E(%,1,12) D DD^%DT S ECXRUN=Y
36 ;setup array of feeder location names
37 F F1=1:1:14 S X=$P($T(FEED1+F1),";",3),F1SUB=$P(X,U,1),F1NM=$P(X,U,2) S ^TMP($J,"ECXFL","OR"_F1SUB)=F1NM D
38 .F F2=1:1:7 S X=$P($T(FEED2+F2),";",3),F2SUB=$P(X,U,1),F2NM=$P(X,U,2) S ^TMP($J,"ECXFL","OR"_F1SUB_F2SUB)=F1NM_" - "_F2NM,FL(F2SUB)=F2NM
39 ;process extract records
40 ;type='p'rimary or 's'econdary or 'i'mplant
41 ;ignore type=secondary
42 S J="" F S J=$O(^ECX(727.811,"AC",ECXEXT,J)) Q:'J I $D(^ECX(727.811,J,0)) S EC=^(0),DIV=$P(EC,U,4) I $P(EC,U,17)'="S",$P(EC,U,28)'="C" D
43 .;determine feeder location
44 .S ECF1=$E($P(EC,U,32),1,4)
45 .I ECF1="" D
46 ..S ECF1=$P(EC,U,30),ECF1="OR"_$E("GEORCANECNAMINENCYWACLDEOT",ECF1*2-1,ECF1*2)
47 ..S:ECF1="OR" ECF1="ORNO"
48 ..I $P(EC,U,30)="",$P(EC,U,12)="",$P(EC,U,11)="059" S ECF1="ORCY"
49 .S ECFL=DIV_ECF1
50 .;determine surgical specialty
51 .S ECSS=$P(EC,U,11) S:ECSS="" ECSS=999 I $P(EC,U,32)'="" S ECSS="NON"
52 .;type=implant generates one product record; volume is always at least 1
53 .I $P(EC,U,17)="I" D Q
54 ..S ECFLX=ECFL_"I",ECFK=ECSS_"-"_$$RJ^XLFSTR($P(EC,U,23),5,0)
55 ..S ECQ=$P(EC,U,24) S:'ECQ ECQ=1
56 ..S ^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFLX,ECFK))+ECQ
57 .;type=primary generates four or five product records, but only two are of interest here
58 .;anesthesia time product
59 .S ECQ=+$P(EC,U,22) I ECQ>0 D
60 ..S ECFLX=ECFL_"A",EC16=$P(EC,U,16)
61 ..S ECD=$S(EC16="G":1,EC16="L":3,EC16="S":4,EC16="E":4,EC16="M":7,EC16="":6,1:5)
62 ..S ECFK=ECSS_"-"_"2"_ECD
63 ..S ^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFLX,ECFK))+ECQ
64 .;surgeon time product
65 .S ECQ=+$P(EC,U,21) I ECQ>0 D
66 ..S EC31=+$P(EC,U,31),ECFX=$S(EC31=10:"D",EC31=24:"M",EC31=32:"P",EC31=43:"C",1:"S")
67 ..S ECFLX=ECFL_ECFX
68 ..S ECFK=ECSS_"-40"
69 ..S ^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFLX,ECFK))+ECQ
70 .;patient time product
71 .S ECQ=+$P(EC,U,20) I ECQ>0 D
72 ..S ECFK=ECSS_"-10"
73 ..S ^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
74 .;recovery room time product only if not cystoscopy and not non-or
75 .I ECFL'="ORCY",$P(EC,U,32)="" D
76 ..S ECQ=+$P(EC,U,33) I ECQ>0 D
77 ...S ECFK=ECSS_"-60"
78 ...S ^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
79 .;technician time product, only for cystoscopy
80 .I ECFL="ORCY" D
81 ..S ECQ=+$P(EC,U,20) S:($P(EC,U,22)>$P(EC,U,20)) ECQ=+$P(EC,U,22) I ECQ>0 D
82 ...S ECFK=ECSS_"-70"
83 ...S ^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
84 .;cleanup time product
85 .S ECQ=2 D
86 ..S ECFK=ECSS_"-30"
87 ..S ^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
88 ;print the report
89 U IO
90 S DIV="" F S DIV=$O(^TMP($J,"ECXAUD",DIV)) Q:DIV="" D Q:QFLG
91 .D HEADER
92 .S ECFL="" F S ECFL=$O(^TMP($J,"ECXAUD",DIV,ECFL)) Q:ECFL="" D Q:QFLG
93 ..S DIVL=$L(DIV),ECFLX=$E(ECFL,DIVL+1,99),ECFLNM=$G(^TMP($J,"ECXFL",ECFLX)) S:ECFLNM="" ECFLNM="NON-OR"
94 ..I ECFLNM="NON-OR" D
95 ...S F2SUB=$E(ECFLX,5),F2NM=""
96 ...S:F2SUB]"" F2NM=$G(FL(F2SUB)) S:F2NM]"" ECFLNM=ECFLNM_" - "_F2NM
97 ..D:($Y+3>IOSL) HEADER Q:QFLG W !,ECFL,?12,ECFLNM
98 ..S ECFK="" F S ECFK=$O(^TMP($J,"ECXAUD",DIV,ECFL,ECFK)) Q:ECFK="" S TOT=^(ECFK) D Q:QFLG
99 ...D:($Y+3>IOSL) HEADER Q:QFLG W ?48,ECFK,?68,$$RJ^XLFSTR(TOT,6," "),!
100 ;close
101 I $E(IOST)'="C" W @IOF
102 I $E(IOST)="C",'QFLG D
103 .S SS=22-$Y F JJ=1:1:SS W !
104 .S DIR(0)="E" W ! D ^DIR K DIR
105 D AUDIT^ECXKILL
106 Q
107HEADER ;print the header
108 N ECXTAB
109 S ECXTAB=48
110 D SASHEAD^ECXUTLA(DIV,ECXHEAD,.ECXDIV,.ECXARRAY,.PG,ECXTAB)
111 Q
112 ;
113FEED1 ;or location names
114 ;;AM^AMBULATORY OR
115 ;;CA^CARDIAC OR
116 ;;CL^CLINIC
117 ;;CN^CARDIAC/NEURO OR
118 ;;CY^CYSTOSCOPY RM.
119 ;;DE^DEDICATED RM.
120 ;;EN^ENDOSCOPY RM.
121 ;;GE^GENERAL OR
122 ;;IN^ICU
123 ;;NE^NEUROSURGERY OR
124 ;;NO^UNKNOWN
125 ;;OR^ORTHOPEDIC OR
126 ;;OT^OTHER LOCATION
127 ;;WA^WARD
128 ;
129FEED2 ;service location names
130 ;;A^ANESTHESIA
131 ;;I^IMPLANTS
132 ;;C^SPINAL CORD
133 ;;D^DENTAL
134 ;;M^MEDICINE
135 ;;P^PSYCH
136 ;;S^SURGERY
Note: See TracBrowser for help on using the repository browser.