VistA-WorldVistAEHR/r/SURGERY-SR/SROMORT.m

56 lines
3.3 KiB
Mathematica

SROMORT ;B'HAM ISC/MAM - MORTALITY REPORT ; [ 10/01/98 12:55 PM ]
;;3.0; Surgery ;**5,34,50**;24 Jun 93
BEG ; entry when queued
U IO N SRFRTO K ^TMP("SR",$J) S (SRHDR,SRSOUT)=0,PAGE=1
S Y=DT X ^DD("DD") S SRPRINT="DATE PRINTED: "_Y S Y=SRSD X ^DD("DD") S SRFRTO="FROM: "_Y_" TO: ",Y=SRED X ^DD("DD") S SRFRTO=SRFRTO_Y
S SRSD1=SRSD-.00001,SRSEDT=SRED+.9999 F S SRSD1=$O(^DPT("AEXP1",SRSD1)) Q:SRSD1>SRSEDT!'SRSD1 S DFN=0 F S DFN=$O(^DPT("AEXP1",SRSD1,DFN)) Q:'DFN D SEARCH
S SRSS=0 F S SRSS=$O(^TMP("SR",$J,SRSS)) Q:SRSS=""!(SRSOUT) D PAGE S SRSDATE=0 F S SRSDATE=$O(^TMP("SR",$J,SRSS,SRSDATE)) Q:'SRSDATE!(SRSOUT) D MORE
I '$D(^TMP("SR",$J)) K SRSS D HDR W !!,"No mortalities for the selected date range.",!
END ;
W:$E(IOST)="P" @IOF K ^TMP("SR",$J) I $D(ZTQUEUED) Q:$G(ZTSTOP) S ZTREQ="@" Q
I $E(IOST)'="P",'SRSOUT W !!,"Press RETURN to continue " R X:DTIME
D ^%ZISC K SRTN D ^SRSKILL W @IOF
Q
MORE S DFN=0 F S DFN=$O(^TMP("SR",$J,SRSS,SRSDATE,DFN)) Q:'DFN!(SRSOUT) S X=^(DFN),SRDEAD=$P(X,"^"),SRTN=$P(X,"^",2) D PRINT
Q
SEARCH ; search for procedures
S X1=SRSD1,X2=-30 D C^%DTC S SRCUTDT=X
S SRTN=0 F S SRTN=$O(^SRF("B",DFN,SRTN)) Q:'SRTN I $$MANDIV^SROUTL0(SRINSTP,SRTN) S SRSDATE=$P(^SRF(SRTN,0),"^",9) I SRSDATE<SRSEDT,SRSDATE>SRCUTDT D UTIL
Q
UTIL ; set ^TMP
I '$D(^SRF(SRTN,.2)) Q
I $P(^SRF(SRTN,.2),"^",12)="" Q
S Y=$P(^SRF(SRTN,0),"^",4) S SRSS=$S(Y:$P(^SRO(137.45,Y,0),"^"),1:"SURGICAL SPECIALTY NOT ENTERED")
S ^TMP("SR",$J,SRSS,SRSDATE,DFN)=SRSD1_"^"_SRTN
Q
HDR ; print heading
I $D(ZTQUEUED) D ^SROSTOP I SRHALT S SRSOUT=1 Q
W:$Y @IOF W !,?(132-$L(SRINST)\2),SRINST,?120,"PAGE ",PAGE,!,?58,"SURGICAL SERVICE",?100,"REVIEWED BY: ",!,?58,"MORTALITY REPORT",?100,"DATE REVIEWED: "
W !,?(132-$L(SRFRTO)\2),SRFRTO,?100,SRPRINT
W !!!,"OPERATION DATE",?17,"PATIENT",?50,"PRINCIPAL OPERATIVE PROCEDURE",?112,"DATE OF DEATH",!,?17,"ID#",?112,"AUTOPSY (Y/N)",! F LINE=1:1:IOM W "="
I $D(SRSS) W !,?(132-$L(SRSS)\2),SRSS,! F LINE=1:1:132 W "-"
S PAGE=PAGE+1,SRHDR=1
Q
OTHER ; other operations
S SRLONG=1 I $L(SROPER)+$L($P(^SRF(SRTN,13,OPER,0),"^"))>250 S SRLONG=0,OPER=999,SROPERS=" ..."
I SRLONG S SROPERS=$P(^SRF(SRTN,13,OPER,0),"^")
S SROPER=SROPER_$S(SROPERS=" ...":SROPERS,1:", "_SROPERS)
Q
PRINT ; print mortality information
I $Y+5>IOSL D PAGE Q:SRSOUT
S Y=SRSDATE D D^DIQ S SRSDT=$E(Y,1,12),(Y,SRAD)=SRDEAD D D^DIQ S SRSDEAD=$E(Y,1,12)
D DEM^VADPT S SRNAME=VADM(1),SSN=VA("PID")
OPS S SROPER=$P(^SRF(SRTN,"OP"),"^"),OPER=0 F I=0:0 S OPER=$O(^SRF(SRTN,13,OPER)) Q:OPER="" D OTHER
K SROPS,MM,MMM S:$L(SROPER)<55 SROPS(1)=SROPER,SROPS(2)="" I $L(SROPER)>54 S SROPER=SROPER_" " F M=1:1 D LOOP Q:MMM=""
S (SRAUT,SRPTF)=""
S VAINDT=SRAD-.0001 D INP^VADPT S SRPTF=VAIN(10) I SRPTF S SRAUT=$P($G(^DGPT(SRPTF,70)),"^",3),SRAUT=$S(SRAUT=6:"YES",SRAUT=7:"NO",1:"NOT AVAILABLE")
S:SRAUT="" SRAUT="NOT AVAILABLE"
W !!,SRSDT,?17,SRNAME,?50,SROPS(1),?112,SRSDEAD,!,?17,VA("PID"),?50,SROPS(2),?112,SRAUT I $D(SROPS(3)) W !,?50,SROPS(3) I $D(SROPS(4)) W !,?50,SROPS(4)
Q
LOOP ; break procedure if greater than 55 characters
S SROPS(M)="" F LOOP=1:1 S MM=$P(SROPER," "),MMM=$P(SROPER," ",2,200) Q:MMM="" Q:$L(SROPS(M))+$L(MM)'<55 S SROPS(M)=SROPS(M)_MM_" ",SROPER=MMM
Q
PAGE I $E(IOST)'="P",SRHDR W !!,"Press RETURN to continue, or '^' to quit: " R X:DTIME I '$T!(X["^") S SRSOUT=1 Q
D HDR
Q