SRSCHAP ;B'HAM ISC/MAM - CHAPLAIN'S LIST OF SCHEDULED CASES ; [ 02/19/98 12:29 PM ]
;;3.0; Surgery ;**77**;24 Jun 93
DT S SRSOUT=0,%DT="AEFX",%DT("A")="List Scheduled Operations for which date ? " D ^%DT G:Y<1 END S SRSDATE=Y
K IOP,%ZIS,POP,IO("Q") S %ZIS("A")="Print to device: ",%ZIS="Q" D ^%ZIS G:POP END I $D(IO("Q")) K IO("Q") S ZTSAVE("SRSDATE")=SRSDATE,ZTDESC="SCHEDULED OPERATIONS",ZTRTN="EN^SRSCHAP" D ^%ZTLOAD G END
EN ; entry when queued
U IO S (SROR,SRSOUT)=0 F S SROR=$O(^SRF("AOR",SROR)) Q:'SROR!(SRSOUT) S SRTN=0 F S SRTN=$O(^SRF("AOR",SROR,SRSDATE,SRTN)) Q:'SRTN!(SRSOUT) S SRST=$P($G(^SRF(SRTN,31)),"^",4) I SRST D UTIL
D PRINT W:$E(IOST)="P" @IOF I $D(ZTQUEUED) K ^TMP("SR",$J) Q:$G(ZTSTOP) S ZTREQ="@" Q
END ;
S SRPRINT=0 I $E(IOST)="P" S SRPRINT=1
I 'SRSOUT,'SRPRINT W !!,"Press RETURN to continue " R X:DTIME
K SRTN D ^%ZISC,^SRSKILL W @IOF
Q
LOOP ; break procedure if greater than 65 characters
S SROP(M)="" F LOOP=1:1 S MM=$P(SROPER," "),MMM=$P(SROPER," ",2,200) Q:MMM="" Q:$L(SROP(M))+$L(MM)'<65 S SROP(M)=SROP(M)_MM_" ",SROPER=MMM
Q
PAGE I SRHDR,$E(IOST,1)'="P" W !!,"Press RETURN to continue or '^' to quit. " R X:DTIME I '$T!(X="^") S SRSOUT=1 Q
HDR ; print heading
I $D(ZTQUEUED) D ^SROSTOP I SRHALT S SRSOUT=1 Q
W:$Y @IOF W !,?20,"* Scheduled Operations for "_SREL_" *",!,?30,SRDATE,!!,"Start Time",?13,"Patient",?43,"Surgical Specialty",?67,"Ward Location",! F LINE=1:1:80 W "="
Q
UTIL ; set ^TMP("SR")
S DFN=$P(^SRF(SRTN,0),"^") D DEM^VADPT S SREL=$P($G(VADM(9)),"^",2) S:SREL="" SREL="UNKNOWN/NO PREFERENCE"
S ^TMP("SR",$J,SREL,SRST,SRTN)=""
Q
PRINT ; loop through ^TMP and print cases
S (SREL,SRHDR)=0,Y=SRSDATE X ^DD("DD") S SRDATE=Y
F S SREL=$O(^TMP("SR",$J,SREL)) Q:SREL=""!(SRSOUT) D:SRHDR PAGE Q:SRSOUT S SRST=0 F S SRST=$O(^TMP("SR",$J,SREL,SRST)) Q:'SRST!(SRSOUT) S SRTN=0 F S SRTN=$O(^TMP("SR",$J,SREL,SRST,SRTN)) Q:'SRTN!(SRSOUT) D OUT
Q
OUT ; output data
I 'SRHDR D HDR Q:SRSOUT S SRHDR=1
I $Y+5>IOSL D PAGE I SRSOUT Q
S SRF(0)=^SRF(SRTN,0),DFN=$P(SRF(0),"^") D DEM^VADPT S SRNAME=VADM(1)
S SRSS=$P(SRF(0),"^",4) I SRSS S SRSS=$P(^SRO(137.45,SRSS,0),"^")
S:SRSS="" SRSS="NOT ENTERED" S SRSS=$P(SRSS,"(")
S SRWARD=$P($G(^DPT(DFN,.1)),"^") I SRWARD="" D WARD
S Y=SRST D D^DIQ S SRSST=$P(Y,"@",2)
S SROPER=$P(^SRF(SRTN,"OP"),"^") K SROP,MM,MMM S:$L(SROPER)<65 SROP(1)=SROPER I $L(SROPER)>64 S SROPER=SROPER_" " F M=1:1 D LOOP Q:MMM=""
W !,SRSST,?12,SRNAME,?43,SRSS,?67,SRWARD,!,?12,SROP(1) I $D(SROP(2)) W !,?12,SROP(2) I $D(SROP(3)) W !,?12,SROP(3)
W ! F LINE=1:1:80 W "-"
Q
WARD ; check for scheduled admission
S (X,PEND)=0 F S PEND=$O(^DGS(41.1,"B",DFN,PEND)) Q:'PEND S PDATE=$P(^DGS(41.1,PEND,0),"^",2) I PDATE>DT S SRWARD="ADM. PENDING",X=1
Q:X=1 S SRWARD="OUTPATIENT"
Q
SRSCHAP ;B'HAM ISC/MAM - CHAPLAIN'S LIST OF SCHEDULED CASES ; [ 02/19/98 12:29 PM ]
+1 ;;3.0; Surgery ;**77**;24 Jun 93
DT SET SRSOUT=0
SET %DT="AEFX"
SET %DT("A")="List Scheduled Operations for which date ? "
DO ^%DT
IF Y<1
GOTO END
SET SRSDATE=Y
+1 KILL IOP,%ZIS,POP,IO("Q")
SET %ZIS("A")="Print to device: "
SET %ZIS="Q"
DO ^%ZIS
IF POP
GOTO END
IF $DATA(IO("Q"))
KILL IO("Q")
SET ZTSAVE("SRSDATE")=SRSDATE
SET ZTDESC="SCHEDULED OPERATIONS"
SET ZTRTN="EN^SRSCHAP"
DO ^%ZTLOAD
GOTO END
EN ; entry when queued
+1 USE IO
SET (SROR,SRSOUT)=0
FOR
SET SROR=$ORDER(^SRF("AOR",SROR))
IF 'SROR!(SRSOUT)
QUIT
SET SRTN=0
FOR
SET SRTN=$ORDER(^SRF("AOR",SROR,SRSDATE,SRTN))
IF 'SRTN!(SRSOUT)
QUIT
SET SRST=$PIECE($GET(^SRF(SRTN,31)),"^",4)
IF SRST
DO UTIL
+2 DO PRINT
IF $EXTRACT(IOST)="P"
WRITE @IOF
IF $DATA(ZTQUEUED)
KILL ^TMP("SR",$JOB)
IF $GET(ZTSTOP)
QUIT
SET ZTREQ="@"
QUIT
END ;
+1 SET SRPRINT=0
IF $EXTRACT(IOST)="P"
SET SRPRINT=1
+2 IF 'SRSOUT
IF 'SRPRINT
WRITE !!,"Press RETURN to continue "
READ X:DTIME
+3 KILL SRTN
DO ^%ZISC
DO ^SRSKILL
WRITE @IOF
+4 QUIT
LOOP ; break procedure if greater than 65 characters
+1 SET SROP(M)=""
FOR LOOP=1:1
SET MM=$PIECE(SROPER," ")
SET MMM=$PIECE(SROPER," ",2,200)
IF MMM=""
QUIT
IF $LENGTH(SROP(M))+$LENGTH(MM)'<65
QUIT
SET SROP(M)=SROP(M)_MM_" "
SET SROPER=MMM
+2 QUIT
PAGE IF SRHDR
IF $EXTRACT(IOST,1)'="P"
WRITE !!,"Press RETURN to continue or '^' to quit. "
READ X:DTIME
IF '$TEST!(X="^")
SET SRSOUT=1
QUIT
HDR ; print heading
+1 IF $DATA(ZTQUEUED)
DO ^SROSTOP
IF SRHALT
SET SRSOUT=1
QUIT
+2 IF $Y
WRITE @IOF
WRITE !,?20,"* Scheduled Operations for "_SREL_" *",!,?30,SRDATE,!!,"Start Time",?13,"Patient",?43,"Surgical Specialty",?67,"Ward Location",!
FOR LINE=1:1:80
WRITE "="
+3 QUIT
UTIL ; set ^TMP("SR")
+1 SET DFN=$PIECE(^SRF(SRTN,0),"^")
DO DEM^VADPT
SET SREL=$PIECE($GET(VADM(9)),"^",2)
IF SREL=""
SET SREL="UNKNOWN/NO PREFERENCE"
+2 SET ^TMP("SR",$JOB,SREL,SRST,SRTN)=""
+3 QUIT
PRINT ; loop through ^TMP and print cases
+1 SET (SREL,SRHDR)=0
SET Y=SRSDATE
XECUTE ^DD("DD")
SET SRDATE=Y
+2 FOR
SET SREL=$ORDER(^TMP("SR",$JOB,SREL))
IF SREL=""!(SRSOUT)
QUIT
IF SRHDR
DO PAGE
IF SRSOUT
QUIT
SET SRST=0
FOR
SET SRST=$ORDER(^TMP("SR",$JOB,SREL,SRST))
IF 'SRST!(SRSOUT)
QUIT
SET SRTN=0
FOR
SET SRTN=$ORDER(^TMP("SR",$JOB,SREL,SRST,SRTN))
IF 'SRTN!(SRSOUT)
QUIT
DO OUT
+3 QUIT
OUT ; output data
+1 IF 'SRHDR
DO HDR
IF SRSOUT
QUIT
SET SRHDR=1
+2 IF $Y+5>IOSL
DO PAGE
IF SRSOUT
QUIT
+3 SET SRF(0)=^SRF(SRTN,0)
SET DFN=$PIECE(SRF(0),"^")
DO DEM^VADPT
SET SRNAME=VADM(1)
+4 SET SRSS=$PIECE(SRF(0),"^",4)
IF SRSS
SET SRSS=$PIECE(^SRO(137.45,SRSS,0),"^")
+5 IF SRSS=""
SET SRSS="NOT ENTERED"
SET SRSS=$PIECE(SRSS,"(")
+6 SET SRWARD=$PIECE($GET(^DPT(DFN,.1)),"^")
IF SRWARD=""
DO WARD
+7 SET Y=SRST
DO D^DIQ
SET SRSST=$PIECE(Y,"@",2)
+8 SET SROPER=$PIECE(^SRF(SRTN,"OP"),"^")
KILL SROP,MM,MMM
IF $LENGTH(SROPER)<65
SET SROP(1)=SROPER
IF $LENGTH(SROPER)>64
SET SROPER=SROPER_" "
FOR M=1:1
DO LOOP
IF MMM=""
QUIT
+9 WRITE !,SRSST,?12,SRNAME,?43,SRSS,?67,SRWARD,!,?12,SROP(1)
IF $DATA(SROP(2))
WRITE !,?12,SROP(2)
IF $DATA(SROP(3))
WRITE !,?12,SROP(3)
+10 WRITE !
FOR LINE=1:1:80
WRITE "-"
+11 QUIT
WARD ; check for scheduled admission
+1 SET (X,PEND)=0
FOR
SET PEND=$ORDER(^DGS(41.1,"B",DFN,PEND))
IF 'PEND
QUIT
SET PDATE=$PIECE(^DGS(41.1,PEND,0),"^",2)
IF PDATE>DT
SET SRWARD="ADM. PENDING"
SET X=1
+2 IF X=1
QUIT
SET SRWARD="OUTPATIENT"
+3 QUIT