source: FOIAVistA/trunk/r/SURGERY-SR/SROQD0.m@ 1397

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

initial load of FOIAVistA 6/30/08 version

File size: 4.6 KB
Line 
1SROQD0 ;BIR/ADM-Cases with Deaths within 30 Days ; [ 02/05/99 9:38 AM ]
2 ;;3.0; Surgery ;**62,70,50,87**;24 Jun 9
3 ;
4 ;** NOTICE: This routine is part of an implementation of a nationally
5 ;** controlled procedure. Local modifications to this routine
6 ;** are prohibited.
7 ;
8AC F S SRSD=$O(^SRF("AC",SRSD)) Q:'SRSD!(SRSD>SRED)!SRSOUT S SRTN=0 F S SRTN=$O(^SRF("AC",SRSD,SRTN)) Q:'SRTN I $D(^SRF(SRTN,0)),$$MANDIV^SROUTL0(SRINSTP,SRTN) S SRDTH=0 D CASE I SRDTH S ^TMP("SRDTH",$J,DFN)=""
9 D MORT S DFN=0 F S DFN=$O(^TMP("SRDEATH",$J,DFN)) Q:'DFN D:SRSEL=1 TOT D:SRSEL=2 SPEC D:SRSEL=3 INDEX
10 D CLEAN
11 Q
12TOT S SRNM=^TMP("SRNM",$J,DFN) I $O(^TMP("SRREL",$J,DFN,0))="" S SRIOSTAT=^TMP("SRDEATH",$J,DFN),SRTN=^TMP("SRINOUT",$J,DFN,SRIOSTAT),^TMP("SRSEC",$J,SRIOSTAT,SRNM,DFN)=SRTN Q
13 S SRSD=$O(^TMP("SRREL",$J,DFN,0)) I SRSD S SRTN=$O(^TMP("SRREL",$J,DFN,SRSD,0)) I SRTN S SRIOSTAT=^TMP("SRREL",$J,DFN,SRSD,SRTN),^TMP("SRSEC",$J,SRIOSTAT,SRNM,DFN)=SRTN
14 Q
15SPEC S SRNM=^TMP("SRNM",$J,DFN) I $O(^TMP("SRREL",$J,DFN,0))="" S SRNAT=^TMP("SRDEATH",$J,DFN),SRTN=^TMP("SRNAT",$J,DFN,SRNAT),^TMP("SRSEC",$J,SRNAT,SRNM,DFN)=SRTN Q
16 S SRSD=$O(^TMP("SRREL",$J,DFN,0)) I SRSD S SRTN=$O(^TMP("SRREL",$J,DFN,SRSD,0)) I SRTN S SRNAT=^TMP("SRREL",$J,DFN,SRSD,SRTN),^TMP("SRSEC",$J,SRNAT,SRNM,DFN)=SRTN
17 Q
18INDEX S SRNM=^TMP("SRNM",$J,DFN) I $O(^TMP("SRREL",$J,DFN,0))="" S SRPROC=^TMP("SRDEATH",$J,DFN),SRTN=^TMP("SRNAT",$J,DFN,SRPROC),^TMP("SRSEC",$J,SRPROC,SRNM,DFN)=SRTN Q
19 S SRSD=$O(^TMP("SRREL",$J,DFN,0)) I SRSD S SRTN=$O(^TMP("SRREL",$J,DFN,SRSD,0)) I SRTN S SRPROC=^TMP("SRREL",$J,DFN,SRSD,SRTN),^TMP("SRSEC",$J,SRPROC,SRNM,DFN)=SRTN
20 Q
21CASE ; examine case
22 Q:'$P($G(^SRF(SRTN,.2)),"^",12)!($P($G(^SRF(SRTN,"NON")),"^")="Y")!$P($G(^SRF(SRTN,30)),"^")
23 S SR(0)=^SRF(SRTN,0),DFN=$P(SR(0),"^") D DEM^VADPT Q:'$P(VADM(6),"^")
24 S SRIOSTAT=$P(SR(0),"^",12) I SRIOSTAT'="I"&(SRIOSTAT'="O") S VAIP("D")=SRSD D IN5^VADPT S SRIOSTAT=$S(VAIP(13):"I",1:"O") K VAIP
25 S Y=$P(SR(0),"^",4),SRSS=$S(Y:Y,1:9999)
26 I SRSEL=2 S SRNAT=$S(SRSS=9999:9999,1:$P(^SRO(137.45,SRSS,0),"^",2))
27 I SRSD<$P(VADM(6),"^") S X1=SRSD,X2=30 D C^%DTC I $P(VADM(6),"^")'>X S SRDTH=1
28 I SRDTH S ^TMP("SRDTH",$J,DFN)=""
29 Q
30TMP ; update ^TMP
31 S SRREL=$P($G(^SRF(SRTN,.4)),"^",7) I '$D(^TMP("SR",$J,DFN)) S ^TMP("SRPAT",$J,VADM(1),DFN)=VA("PID")_"^"_$P(VADM(3),"^")_"^"_$P(VADM(6),"^"),^TMP("SRNM",$J,DFN)=VADM(1)
32 S ^TMP("SR",$J,DFN,SRSD,SRTN)=SRSS_"^"_SRIOSTAT_"^"_SRREL_"^"_$P($G(^SRF(SRTN,"CON")),"^")
33 I SRSEL=1 S ^TMP("SRDEATH",$J,DFN)=SRIOSTAT,^TMP("SRINOUT",$J,DFN,SRIOSTAT)=SRTN,^TMP("SRNAT",$J,DFN,SRSS)=SRTN I SRREL="R" S ^TMP("SRREL",$J,DFN,(9999999-SRSD),SRTN)=SRIOSTAT
34 I SRSEL=2 S ^TMP("SRDEATH",$J,DFN)=SRNAT,^TMP("SRNAT",$J,DFN,SRNAT)=SRTN I SRREL="R" S ^TMP("SRREL",$J,DFN,(9999999-SRSD),SRTN)=SRNAT
35 I SRSEL=3 D DRPT^SROQ0A
36 Q
37PAGE I $E(IOST)="P"!SRHDR G HDR
38 D PRESS^SROQD I SRSOUT Q
39HDR ; print heading
40 I $D(ZTQUEUED) D ^SROSTOP I SRHALT S SRSOUT=1 Q
41 W:$Y @IOF W:$E(IOST)="P" !,?(IOM-$L(SRINST)\2),SRINST W !,?(IOM-$L(SRRPT)\2),SRRPT,?(IOM-10),$J("PAGE "_SRPAGE,9),!,?(IOM-$L(SRFRTO)\2),SRFRTO
42 W !,?(IOM-$L(SRPRINT)\2),SRPRINT I SRIO'="A" S X=$S(SRIO="I":"INPATIENT",1:"OUTPATIENT")_" DEATHS" W !,?(IOM-$L(X)\2),X
43 Q:SRHDR2
44 W !,?124,"DEATH",!,"OP DATE",?10,"CASE #",?22,"IN/OUT",?31,"SURGICAL SPECIALTY",?69,"PROCEDURE(S)",?123,"RELATED"
45 S SRHDR=0,SRPAGE=SRPAGE+1 W ! F I=1:1:IOM W "="
46 I SRSNM W !,SRNAME_" * * Continued from previous page * *",!
47 Q
48SUM ; print category totals
49 D:$Y+6>IOSL PAGE Q:SRSOUT
50 W !,"TOTAL DEATHS: "_SRDTOT
51 Q
52MORT ; look for operations in next quarter
53 S X1=SDATE,X2=-30 D C^%DTC S SRSD1=9999999.999999-(X-.0001),X1=EDATE,X2=30 D C^%DTC S SRED1=9999999.999999-(X+.9999)
54 S DFN=0 F S DFN=$O(^TMP("SRDTH",$J,DFN)) Q:'DFN D DEM^VADPT D
55 .K ^TMP("SRTN",$J) S SRINV=SRED1 F S SRINV=$O(^SRF("ADT",DFN,SRINV)) Q:'SRINV!(SRINV>SRSD1) S SRTN=0 F S SRTN=$O(^SRF("ADT",DFN,SRINV,SRTN)) Q:'SRTN D
56 ..S ^TMP("SRTN",$J,$P(^SRF(SRTN,0),"^",9),SRTN)=""
57 .S SRSD=0 F S SRSD=$O(^TMP("SRTN",$J,SRSD)) Q:'SRSD S SRTN=0 F S SRTN=$O(^TMP("SRTN",$J,SRSD,SRTN)) Q:'SRTN S SRDTH=0 D CASE I SRDTH D TMP
58 Q
59CLEAN ; deselect deaths attributable to operations outside date range
60 S SRNAT="" F S SRNAT=$O(^TMP("SRSEC",$J,SRNAT)) Q:SRNAT="" S SRNM="" F S SRNM=$O(^TMP("SRSEC",$J,SRNAT,SRNM)) Q:SRNM="" S DFN=0 F S DFN=$O(^TMP("SRSEC",$J,SRNAT,SRNM,DFN)) Q:'DFN D
61 .S SRTN=^TMP("SRSEC",$J,SRNAT,SRNM,DFN),SRSDATE=$P(^SRF(SRTN,0),"^",9) I SRSDATE>(EDATE+.9999)!(SRSDATE<(SDATE-.0001)) D
62 ..K ^TMP("SRSEC",$J,SRNAT,SRNM,DFN),^TMP("SRDEATH",$J,DFN),^TMP("SRNM",$J,DFN),^TMP("SRPAT",$J,SRNM,DFN)
63 ..K ^TMP("SRINOUT",$J,DFN),^TMP("SRNAT",$J,DFN),^TMP("SRREL",$J,DFN),^TMP("SR",$J,DFN)
64 Q
Note: See TracBrowser for help on using the repository browser.