SRSCD ;B'HAM ISC/MAM - SCHEDULE OF OPERATIONS (SCREEN FORMAT) ; [ 10/13/98 10:19 AM ]
;;3.0; Surgery ;**77,50**;24 Jun 93
W @IOF,!,"List of Scheduled Operations:",!
DT S SRQ=0,%DT="AEFX",%DT("A")="List Scheduled Operations for which date ? " D ^%DT G:Y<1 END S SRSDATE=Y
BEG W !!,"Do you want to sort by OPERATING ROOM, SPECIALTY or WARD LOCATION ? " R Z:DTIME S:'$T Z="^" G:"^^"[Z END S Z=$E(Z)
I "OoSsWw"'[Z W !!,"Enter 'O' to sort the schedule by operating room, 'S' to sort by specialty",!,"or 'W' to sort by ward." G BEG
S Y=SRSDATE D D^DIQ S SRDATE=Y G:"Ss"[Z ^SRSCDS G:"Ww"[Z ^SRSCDW
ROOM ; sort by operating room
S (SROR,SROR("N"))="" K ^TMP("SR",$J) W !!,"Do you want a list of scheduled operations for all rooms ? YES// " R Z:DTIME S:'$T Z="^" G:Z["^" END S:Z="" Z="Y"
S Z=$E(Z) I "NnYy"'[Z W !!,"Enter 'NO' to list the scheduled operations for a specific operating room,",!,"or RETURN to list the scheduled cases for all rooms." G ROOM
I "Nn"[Z W !! S DIC("S")="I $$ORDIV^SROUTL0(+Y,$G(SRSITE(""DIV""))),('$P(^SRS(+Y,0),U,6))",DIC=131.7,DIC(0)="QEAMZ" D ^DIC G:Y<0 END S SROR=+Y,SROR("N")=$P(^SC($P(Y,"^",2),0),"^")
W ! K IOP,%ZIS,POP,IO("Q") S %ZIS("A")="Print the list on which device: ",%ZIS="Q" D ^%ZIS G:POP END I $D(IO("Q")) K IO("Q") S ZTDESC="SCHEDULED OPERATIONS",ZTRTN="ALL^SRSCD" D ZTSAVE,^%ZTLOAD G END
ALL ; entry when queued
U IO S (SRQ,SRZ)=0 G:"Nn"[Z ONE S SROR=0 F S SROR=$O(^SRF("AOR",SROR)) Q:'SROR!SRQ I $$ORDIV^SROUTL0(SROR,$G(SRSITE("DIV"))) S SROR("N")=$P(^SC($P(^SRS(SROR,0),"^"),0),"^") D OR
D PRINT I '$D(^TMP("SR",$J)) D HDR W $$NODATA^SROUTL0()
G END
ONE ; list scheduled cases for a specific room
D OR,PRINT I '$D(^TMP("SR",$J)) D HDR W $$NODATA^SROUTL0()
END W:$E(IOST)="P" @IOF I $D(ZTQUEUED) K ^TMP("SR",$J) Q:$G(ZTSTOP) S ZTREQ="@" Q
I 'SRQ,$E(IOST)'="P" W !!,"Press RETURN to continue " R X:DTIME
D ^SRSKILL K SRTN D ^%ZISC W @IOF
Q
LOOP ; break procedure if greater than 65 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)'<65 S SROPS(M)=SROPS(M)_MM_" ",SROPER=MMM
Q
HDR ; print heading
I $D(ZTQUEUED) D ^SROSTOP I SRHALT S SRQ=1 Q
S SRZ=1 W:$Y @IOF W !,?20,"* Scheduled Operations for "_SROR_" *",!,?30,SRDATE,!!,"Start Time",?13,"Patient",?43,"Surgical Specialty",?67,"Ward Location",!,?13,"ID #",! F LINE=1:1:80 W "="
Q
OR S SRTN=0 F S SRTN=$O(^SRF("AOR",SROR,SRSDATE,SRTN)) Q:'SRTN!SRQ I $P($G(^SRF(SRTN,31)),"^",4),$$DIV^SROUTL0(SRTN) S SRST=$P(^SRF(SRTN,31),"^",4) D UTL
Q
UTL ; set ^TMP("SR",$J)
I SRZ,$Y+5>IOSL D PAGE Q:SRQ D HDR Q:SRQ
S DFN=$P(^SRF(SRTN,0),"^") D DEM^VADPT S SRNM=VADM(1),SRSSN=VA("PID"),SRWARD=$S($D(^DPT(DFN,.1)):$P(^(.1),"^"),1:""),SRSOP=$P(^SRF(SRTN,"OP"),"^"),SRSS=$P(^SRF(SRTN,0),"^",4) I SRWARD="" D WARD
I SRSS S SRSS=$P(^SRO(137.45,SRSS,0),"^")
S Y=SRST D D^DIQ S SRFIND=$F(Y,":"),SRTIME=$S(SRFIND:$E(Y,SRFIND-3,SRFIND+1),1:"")
S:SRSS="" SRSS="NOT ENTERED" S SRSS=$P(SRSS,"(")
S ^TMP("SR",$J,SROR("N"),SRST)=SRNM_"^"_SRSOP_"^"_SRWARD_"^"_SRSS_"^"_SRTIME_"^"_SRSSN
Q
PRINT ; loop through ^TMP and print cases
S (SROR,SRST,SRZ)=0 F S SROR=$O(^TMP("SR",$J,SROR)) Q:SROR=""!SRQ D:SRZ PAGE Q:SRQ D HDR F S SRST=$O(^TMP("SR",$J,SROR,SRST)) Q:'SRST!SRQ D OUT
Q
OUT ; output data
I $Y+5>IOSL D PAGE Q:SRQ D HDR Q:SRQ
S SR=^TMP("SR",$J,SROR,SRST),SROPER=$P(SR,"^",2) K SROPS,MM,MMM S:$L(SROPER)<65 SROPS(1)=SROPER I $L(SROPER)>64 S SROPER=SROPER_" " F M=1:1 D LOOP Q:MMM=""
W !,$P(SR,"^",5),?12,$P(SR,"^"),?43,$P(SR,"^",4),?67,$P(SR,"^",3),!,?12,$P(SR,"^",6),!,?12,SROPS(1) I $D(SROPS(2)) W !,?12,SROPS(2) I $D(SROPS(3)) W !,?12,SROPS(3)
W ! F LINE=1:1:80 W "-"
Q
PAGE I $E(IOST,1)'="P" W !!,"Press RETURN to continue or '^' to quit. " R X:DTIME I '$T!(X="^") S SRQ=1
Q
ZTSAVE S (ZTSAVE("SRDATE"),ZTSAVE("SROR"),ZTSAVE("SROR(""N"")"),ZTSAVE("SRQ"),ZTSAVE("SRSDATE"),ZTSAVE("Z"),ZTSAVE("SRSITE*"))=""
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
SRSCD ;B'HAM ISC/MAM - SCHEDULE OF OPERATIONS (SCREEN FORMAT) ; [ 10/13/98 10:19 AM ]
+1 ;;3.0; Surgery ;**77,50**;24 Jun 93
+2 WRITE @IOF,!,"List of Scheduled Operations:",!
DT SET SRQ=0
SET %DT="AEFX"
SET %DT("A")="List Scheduled Operations for which date ? "
DO ^%DT
IF Y<1
GOTO END
SET SRSDATE=Y
BEG WRITE !!,"Do you want to sort by OPERATING ROOM, SPECIALTY or WARD LOCATION ? "
READ Z:DTIME
IF '$TEST
SET Z="^"
IF "^^"[Z
GOTO END
SET Z=$EXTRACT(Z)
+1 IF "OoSsWw"'[Z
WRITE !!,"Enter 'O' to sort the schedule by operating room, 'S' to sort by specialty",!,"or 'W' to sort by ward."
GOTO BEG
+2 SET Y=SRSDATE
DO D^DIQ
SET SRDATE=Y
IF "Ss"[Z
GOTO ^SRSCDS
IF "Ww"[Z
GOTO ^SRSCDW
ROOM ; sort by operating room
+1 SET (SROR,SROR("N"))=""
KILL ^TMP("SR",$JOB)
WRITE !!,"Do you want a list of scheduled operations for all rooms ? YES// "
READ Z:DTIME
IF '$TEST
SET Z="^"
IF Z["^"
GOTO END
IF Z=""
SET Z="Y"
+2 SET Z=$EXTRACT(Z)
IF "NnYy"'[Z
WRITE !!,"Enter 'NO' to list the scheduled operations for a specific operating room,",!,"or RETURN to list the scheduled cases for all rooms."
GOTO ROOM
+3 IF "Nn"[Z
WRITE !!
SET DIC("S")="I $$ORDIV^SROUTL0(+Y,$G(SRSITE(""DIV""))),('$P(^SRS(+Y,0),U,6))"
SET DIC=131.7
SET DIC(0)="QEAMZ"
DO ^DIC
IF Y<0
GOTO END
SET SROR=+Y
SET SROR("N")=$PIECE(^SC($PIECE(Y,"^",2),0),"^")
+4 WRITE !
KILL IOP,%ZIS,POP,IO("Q")
SET %ZIS("A")="Print the list on which device: "
SET %ZIS="Q"
DO ^%ZIS
IF POP
GOTO END
IF $DATA(IO("Q"))
KILL IO("Q")
SET ZTDESC="SCHEDULED OPERATIONS"
SET ZTRTN="ALL^SRSCD"
DO ZTSAVE
DO ^%ZTLOAD
GOTO END
ALL ; entry when queued
+1 USE IO
SET (SRQ,SRZ)=0
IF "Nn"[Z
GOTO ONE
SET SROR=0
FOR
SET SROR=$ORDER(^SRF("AOR",SROR))
IF 'SROR!SRQ
QUIT
IF $$ORDIV^SROUTL0(SROR,$GET(SRSITE("DIV")))
SET SROR("N")=$PIECE(^SC($PIECE(^SRS(SROR,0),"^"),0),"^")
DO OR
+2 DO PRINT
IF '$DATA(^TMP("SR",$JOB))
DO HDR
WRITE $$NODATA^SROUTL0()
+3 GOTO END
ONE ; list scheduled cases for a specific room
+1 DO OR
DO PRINT
IF '$DATA(^TMP("SR",$JOB))
DO HDR
WRITE $$NODATA^SROUTL0()
END IF $EXTRACT(IOST)="P"
WRITE @IOF
IF $DATA(ZTQUEUED)
KILL ^TMP("SR",$JOB)
IF $GET(ZTSTOP)
QUIT
SET ZTREQ="@"
QUIT
+1 IF 'SRQ
IF $EXTRACT(IOST)'="P"
WRITE !!,"Press RETURN to continue "
READ X:DTIME
+2 DO ^SRSKILL
KILL SRTN
DO ^%ZISC
WRITE @IOF
+3 QUIT
LOOP ; break procedure if greater than 65 characters
+1 SET SROPS(M)=""
FOR LOOP=1:1
SET MM=$PIECE(SROPER," ")
SET MMM=$PIECE(SROPER," ",2,200)
IF MMM=""
QUIT
IF $LENGTH(SROPS(M))+$LENGTH(MM)'<65
QUIT
SET SROPS(M)=SROPS(M)_MM_" "
SET SROPER=MMM
+2 QUIT
HDR ; print heading
+1 IF $DATA(ZTQUEUED)
DO ^SROSTOP
IF SRHALT
SET SRQ=1
QUIT
+2 SET SRZ=1
IF $Y
WRITE @IOF
WRITE !,?20,"* Scheduled Operations for "_SROR_" *",!,?30,SRDATE,!!,"Start Time",?13,"Patient",?43,"Surgical Specialty",?67,"Ward Location",!,?13,"ID #",!
FOR LINE=1:1:80
WRITE "="
+3 QUIT
OR SET SRTN=0
FOR
SET SRTN=$ORDER(^SRF("AOR",SROR,SRSDATE,SRTN))
IF 'SRTN!SRQ
QUIT
IF $PIECE($GET(^SRF(SRTN,31)),"^",4)
IF $$DIV^SROUTL0(SRTN)
SET SRST=$PIECE(^SRF(SRTN,31),"^",4)
DO UTL
+1 QUIT
UTL ; set ^TMP("SR",$J)
+1 IF SRZ
IF $Y+5>IOSL
DO PAGE
IF SRQ
QUIT
DO HDR
IF SRQ
QUIT
+2 SET DFN=$PIECE(^SRF(SRTN,0),"^")
DO DEM^VADPT
SET SRNM=VADM(1)
SET SRSSN=VA("PID")
SET SRWARD=$SELECT($DATA(^DPT(DFN,.1)):$PIECE(^(.1),"^"),1:"")
SET SRSOP=$PIECE(^SRF(SRTN,"OP"),"^")
SET SRSS=$PIECE(^SRF(SRTN,0),"^",4)
IF SRWARD=""
DO WARD
+3 IF SRSS
SET SRSS=$PIECE(^SRO(137.45,SRSS,0),"^")
+4 SET Y=SRST
DO D^DIQ
SET SRFIND=$FIND(Y,":")
SET SRTIME=$SELECT(SRFIND:$EXTRACT(Y,SRFIND-3,SRFIND+1),1:"")
+5 IF SRSS=""
SET SRSS="NOT ENTERED"
SET SRSS=$PIECE(SRSS,"(")
+6 SET ^TMP("SR",$JOB,SROR("N"),SRST)=SRNM_"^"_SRSOP_"^"_SRWARD_"^"_SRSS_"^"_SRTIME_"^"_SRSSN
+7 QUIT
PRINT ; loop through ^TMP and print cases
+1 SET (SROR,SRST,SRZ)=0
FOR
SET SROR=$ORDER(^TMP("SR",$JOB,SROR))
IF SROR=""!SRQ
QUIT
IF SRZ
DO PAGE
IF SRQ
QUIT
DO HDR
FOR
SET SRST=$ORDER(^TMP("SR",$JOB,SROR,SRST))
IF 'SRST!SRQ
QUIT
DO OUT
+2 QUIT
OUT ; output data
+1 IF $Y+5>IOSL
DO PAGE
IF SRQ
QUIT
DO HDR
IF SRQ
QUIT
+2 SET SR=^TMP("SR",$JOB,SROR,SRST)
SET SROPER=$PIECE(SR,"^",2)
KILL SROPS,MM,MMM
IF $LENGTH(SROPER)<65
SET SROPS(1)=SROPER
IF $LENGTH(SROPER)>64
SET SROPER=SROPER_" "
FOR M=1:1
DO LOOP
IF MMM=""
QUIT
+3 WRITE !,$PIECE(SR,"^",5),?12,$PIECE(SR,"^"),?43,$PIECE(SR,"^",4),?67,$PIECE(SR,"^",3),!,?12,$PIECE(SR,"^",6),!,?12,SROPS(1)
IF $DATA(SROPS(2))
WRITE !,?12,SROPS(2)
IF $DATA(SROPS(3))
WRITE !,?12,SROPS(3)
+4 WRITE !
FOR LINE=1:1:80
WRITE "-"
+5 QUIT
PAGE IF $EXTRACT(IOST,1)'="P"
WRITE !!,"Press RETURN to continue or '^' to quit. "
READ X:DTIME
IF '$TEST!(X="^")
SET SRQ=1
+1 QUIT
ZTSAVE SET (ZTSAVE("SRDATE"),ZTSAVE("SROR"),ZTSAVE("SROR(""N"")"),ZTSAVE("SRQ"),ZTSAVE("SRSDATE"),ZTSAVE("Z"),ZTSAVE("SRSITE*"))=""
+1 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