SROSUR ;B'HAM ISC/MAM - SURGEON STAFFING REPORT ; [ 07/27/98 2:33 PM ]
;;3.0; Surgery ;**34,50**;24 Jun 93
SET ; set variables and print from ^SRF(
K CPT,ICD S S(0)=^SRF(M,0),DFN=$P(S(0),"^") D DEM^VADPT S PAT=VADM(1),SSN=VA("PID"),SRTN=M,Y=L D D^DIQ S DATE=Y
I $L(PAT)>18 S PAT=$P(PAT,",")_", "_$E($P(PAT,",",2))
OPS S SROPER=$P(^SRF(SRTN,"OP"),"^"),OPER=0 F S OPER=$O(^SRF(SRTN,13,OPER)) Q:OPER="" D OTHER
K SROPS,MM,MMM S:$L(SROPER)<50 SROPS(1)=SROPER I $L(SROPER)>49 S SROPER=SROPER_" " F MAM=1:1 D LOOP Q:MMM=""
I $D(^SRF(SRTN,.2)),$P(^(.2),"^",3)'="" S SRDG=34,SRDG1=15
I '$D(SRDG) S SRDG=33,SRDG1=14
S ICD("*")=$S($D(^SRF(SRTN,SRDG)):$P(^SRF(SRTN,SRDG),"^"),1:""),(CNT,ICD)=0 F I=0:0 S ICD=$O(^SRF(SRTN,SRDG1,ICD)) Q:ICD="" S CNT=CNT+1,ICD(CNT)=$P(^SRF(SRTN,SRDG1,ICD,0),"^")
I $Y+7>IOSL D ASK
Q:SRF W !,DATE,?23,PAT,?43,SROPS(1),?95,$E(ICD("*"),1,35) S (CPT,ICD)=0
W !,SRTN,?23,SSN S ICD=$O(ICD(ICD)) W:$D(SROPS(2)) ?43,SROPS(2) W:ICD ?95,$E(ICD(ICD),1,35) S:ICD ICD=$O(ICD(ICD)) I $D(SROPS(3)) W !,?43,SROPS(3) I ICD W ?95,$E(ICD(ICD),1,35)
I 'CPT W:ICD !,?95,$E(ICD(ICD),1,35)
W:$D(SROPS(4)) !,?43,SROPS(4) W:$D(SROPS(5)) !,?43,SROPS(5) W:$D(SROPS(6)) !,?43,SROPS(6) W ! Q
SETUP ; set up ^TMP(
I $D(^SRF(SRTN,31)),$P(^(31),"^",8)'="" Q
Q:'$D(^SRF(SRTN,.2)) I $P(^(.2),"^",12)="" Q
Q:'$D(^SRF(SRTN,.1)) S S(.1)=^(.1),DATE=$P(^SRF(SRTN,0),"^",9),SUR=$P(S(.1),"^",4),ATT=$P(S(.1),"^",13),FRST=$P(S(.1),"^",5),SCND=$P(S(.1),"^",6) S:SUR'="" ^TMP("SRO",$J,$P(^VA(200,SUR,0),"^"),"SUR",DATE,L)=""
I $O(^SRF(SRTN,28,0)) D OTHER^SROSUR1
S:ATT'="" ^TMP("SRO",$J,$P(^VA(200,ATT,0),"^"),"ATT",DATE,L)="" S:FRST'="" ^TMP("SRO",$J,$P(^VA(200,FRST,0),"^"),"1ST",DATE,L)="" S:SCND'="" ^TMP("SRO",$J,$P(^VA(200,SCND,0),"^"),"2ND",DATE,L)=""
Q
ASK S SRUL=0 I $E(IOST)'="P" W !!,"Press RETURN to continue, or '^' to quit:. " R X:DTIME I '$T!(X="^") S SRF=1 Q
D HDR Q
END D ^SRSKILL K SRTN D ^%ZISC W @IOF
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
LOOP ; break procedure if greater than 50 characters
S SROPS(MAM)="" F LOOP=1:1 S MM=$P(SROPER," "),MMM=$P(SROPER," ",2,200) Q:MMM="" Q:$L(SROPS(MAM))+$L(MM)'<50 S SROPS(MAM)=SROPS(MAM)_MM_" ",SROPER=MMM
Q
ASSTS ;
S SROTH=0 F S SROTH=$O(^SRF(SRTN,28,SROTH)) Q:'SROTH S SROTHER=^SRF(SRTN,28,SROTH,0) I SROTHER=SROSUR S SROTHER=$P(^VA(200,SROTHER,0),"^"),^TMP("SRO",$J,SROTHER,"OTH",DATE,SRTN)=""
Q
NAME I SRUL W ! F LINE=1:1:IOM W "-"
S SRUL=1 W !!,?50,"** "_J_" **" Q
ROLE I $Y+5>IOSL D ASK
Q:SRF W !!,?50,"ROLE: " W $S(K="1ST":"FIRST ASSISTANT",K="2ND":"SECOND ASSISTANT",K="ATT":"ATTENDING SURGEON",K="OTH":"OTHER ASSISTANT",1:"SURGEON"),!
Q
HDR ; print heading
I $D(ZTQUEUED) D ^SROSTOP I SRHALT S SRF=1 Q
W:$Y @IOF W !,?(132-$L(SRINST)\2),SRINST,?120,"PAGE: "_PAGE,!,?58,"SURGICAL SERVICE",?100,"REVIEWED BY: ",!,?54,"SURGEON STAFFING REPORT",?100,"DATE REVIEWED: "
W !,?(132-$L(SRFRTO)\2),SRFRTO,?100,SRPRINT
W !!,?1,"DATE/TIME",?23,"PATIENT",?43,"OPERATION(S)",?95,"DIAGNOSIS",!,?1,"CASE #",?23,"ID #",! F LINE=1:1:132 W "="
S PAGE=PAGE+1 I $D(J) D NAME,ROLE
Q
EN1 ;
U IO N SRFRTO 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
K J S (SRF,SRUL)=0,PAGE=1 D HDR S J=SRSD-.0001 K ^TMP("SRO",$J)
F S J=$O(^SRF("AC",J)) Q:J>(SRED+.9999)!(J="") S L=0 F S L=$O(^SRF("AC",J,L)) Q:L="" S SRTN=L I $D(^SRF(SRTN,0)),$$DIV^SROUTL0(SRTN) D SETUP
PRINT ; print from ^TMP(
S J=0 F S J=$O(^TMP("SRO",$J,J)) Q:J=""!(SRF) D NAME S K=0 F S K=$O(^TMP("SRO",$J,J,K)) Q:K=""!(SRF) D ROLE S L=0 F S L=$O(^TMP("SRO",$J,J,K,L)) Q:L=""!SRF D PRIN2
I '$D(^TMP("SRO",$J)) W $$NODATA^SROUTL0()
K ^TMP("SRO",$J) W:$E(IOST)="P" @IOF I $D(ZTQUEUED) Q:$G(ZTSTOP) S ZTREQ="@" Q
I $E(IOST)'="P",'SRF W !!,"Press RETURN to continue " R X:DTIME
G END
PRIN2 S M=0 F S M=$O(^TMP("SRO",$J,J,K,L,M)) Q:M=""!SRF S SRTN=M D SET
Q
SROSUR ;B'HAM ISC/MAM - SURGEON STAFFING REPORT ; [ 07/27/98 2:33 PM ]
+1 ;;3.0; Surgery ;**34,50**;24 Jun 93
SET ; set variables and print from ^SRF(
+1 KILL CPT,ICD
SET S(0)=^SRF(M,0)
SET DFN=$PIECE(S(0),"^")
DO DEM^VADPT
SET PAT=VADM(1)
SET SSN=VA("PID")
SET SRTN=M
SET Y=L
DO D^DIQ
SET DATE=Y
+2 IF $LENGTH(PAT)>18
SET PAT=$PIECE(PAT,",")_", "_$EXTRACT($PIECE(PAT,",",2))
OPS SET SROPER=$PIECE(^SRF(SRTN,"OP"),"^")
SET OPER=0
FOR
SET OPER=$ORDER(^SRF(SRTN,13,OPER))
IF OPER=""
QUIT
DO OTHER
+1 KILL SROPS,MM,MMM
IF $LENGTH(SROPER)<50
SET SROPS(1)=SROPER
IF $LENGTH(SROPER)>49
SET SROPER=SROPER_" "
FOR MAM=1:1
DO LOOP
IF MMM=""
QUIT
+2 IF $DATA(^SRF(SRTN,.2))
IF $PIECE(^(.2),"^",3)'=""
SET SRDG=34
SET SRDG1=15
+3 IF '$DATA(SRDG)
SET SRDG=33
SET SRDG1=14
+4 SET ICD("*")=$SELECT($DATA(^SRF(SRTN,SRDG)):$PIECE(^SRF(SRTN,SRDG),"^"),1:"")
SET (CNT,ICD)=0
FOR I=0:0
SET ICD=$ORDER(^SRF(SRTN,SRDG1,ICD))
IF ICD=""
QUIT
SET CNT=CNT+1
SET ICD(CNT)=$PIECE(^SRF(SRTN,SRDG1,ICD,0),"^")
+5 IF $Y+7>IOSL
DO ASK
+6 IF SRF
QUIT
WRITE !,DATE,?23,PAT,?43,SROPS(1),?95,$EXTRACT(ICD("*"),1,35)
SET (CPT,ICD)=0
+7 WRITE !,SRTN,?23,SSN
SET ICD=$ORDER(ICD(ICD))
IF $DATA(SROPS(2))
WRITE ?43,SROPS(2)
IF ICD
WRITE ?95,$EXTRACT(ICD(ICD),1,35)
IF ICD
SET ICD=$ORDER(ICD(ICD))
IF $DATA(SROPS(3))
WRITE !,?43,SROPS(3)
IF ICD
WRITE ?95,$EXTRACT(ICD(ICD),1,35)
+8 IF 'CPT
IF ICD
WRITE !,?95,$EXTRACT(ICD(ICD),1,35)
+9 IF $DATA(SROPS(4))
WRITE !,?43,SROPS(4)
IF $DATA(SROPS(5))
WRITE !,?43,SROPS(5)
IF $DATA(SROPS(6))
WRITE !,?43,SROPS(6)
WRITE !
QUIT
SETUP ; set up ^TMP(
+1 IF $DATA(^SRF(SRTN,31))
IF $PIECE(^(31),"^",8)'=""
QUIT
+2 IF '$DATA(^SRF(SRTN,.2))
QUIT
IF $PIECE(^(.2),"^",12)=""
QUIT
+3 IF '$DATA(^SRF(SRTN,.1))
QUIT
SET S(.1)=^(.1)
SET DATE=$PIECE(^SRF(SRTN,0),"^",9)
SET SUR=$PIECE(S(.1),"^",4)
SET ATT=$PIECE(S(.1),"^",13)
SET FRST=$PIECE(S(.1),"^",5)
SET SCND=$PIECE(S(.1),"^",6)
IF SUR'=""
SET ^TMP("SRO",$JOB,$PIECE(^VA(200,SUR,0),"^"),"SUR",DATE,L)=""
+4 IF $ORDER(^SRF(SRTN,28,0))
DO OTHER^SROSUR1
+5 IF ATT'=""
SET ^TMP("SRO",$JOB,$PIECE(^VA(200,ATT,0),"^"),"ATT",DATE,L)=""
IF FRST'=""
SET ^TMP("SRO",$JOB,$PIECE(^VA(200,FRST,0),"^"),"1ST",DATE,L)=""
IF SCND'=""
SET ^TMP("SRO",$JOB,$PIECE(^VA(200,SCND,0),"^"),"2ND",DATE,L)=""
+6 QUIT
ASK SET SRUL=0
IF $EXTRACT(IOST)'="P"
WRITE !!,"Press RETURN to continue, or '^' to quit:. "
READ X:DTIME
IF '$TEST!(X="^")
SET SRF=1
QUIT
+1 DO HDR
QUIT
END DO ^SRSKILL
KILL SRTN
DO ^%ZISC
WRITE @IOF
+1 QUIT
OTHER ; other operations
+1 SET SRLONG=1
IF $LENGTH(SROPER)+$LENGTH($PIECE(^SRF(SRTN,13,OPER,0),"^"))>250
SET SRLONG=0
SET OPER=999
SET SROPERS=" ..."
+2 IF SRLONG
SET SROPERS=$PIECE(^SRF(SRTN,13,OPER,0),"^")
+3 SET SROPER=SROPER_$SELECT(SROPERS=" ...":SROPERS,1:", "_SROPERS)
+4 QUIT
LOOP ; break procedure if greater than 50 characters
+1 SET SROPS(MAM)=""
FOR LOOP=1:1
SET MM=$PIECE(SROPER," ")
SET MMM=$PIECE(SROPER," ",2,200)
IF MMM=""
QUIT
IF $LENGTH(SROPS(MAM))+$LENGTH(MM)'<50
QUIT
SET SROPS(MAM)=SROPS(MAM)_MM_" "
SET SROPER=MMM
+2 QUIT
ASSTS ;
+1 SET SROTH=0
FOR
SET SROTH=$ORDER(^SRF(SRTN,28,SROTH))
IF 'SROTH
QUIT
SET SROTHER=^SRF(SRTN,28,SROTH,0)
IF SROTHER=SROSUR
SET SROTHER=$PIECE(^VA(200,SROTHER,0),"^")
SET ^TMP("SRO",$JOB,SROTHER,"OTH",DATE,SRTN)=""
+2 QUIT
NAME IF SRUL
WRITE !
FOR LINE=1:1:IOM
WRITE "-"
+1 SET SRUL=1
WRITE !!,?50,"** "_J_" **"
QUIT
ROLE IF $Y+5>IOSL
DO ASK
+1 IF SRF
QUIT
WRITE !!,?50,"ROLE: "
WRITE $SELECT(K="1ST":"FIRST ASSISTANT",K="2ND":"SECOND ASSISTANT",K="ATT":"ATTENDING SURGEON",K="OTH":"OTHER ASSISTANT",1:"SURGEON"),!
+2 QUIT
HDR ; print heading
+1 IF $DATA(ZTQUEUED)
DO ^SROSTOP
IF SRHALT
SET SRF=1
QUIT
+2 IF $Y
WRITE @IOF
WRITE !,?(132-$LENGTH(SRINST)\2),SRINST,?120,"PAGE: "_PAGE,!,?58,"SURGICAL SERVICE",?100,"REVIEWED BY: ",!,?54,"SURGEON STAFFING REPORT",?100,"DATE REVIEWED: "
+3 WRITE !,?(132-$LENGTH(SRFRTO)\2),SRFRTO,?100,SRPRINT
+4 WRITE !!,?1,"DATE/TIME",?23,"PATIENT",?43,"OPERATION(S)",?95,"DIAGNOSIS",!,?1,"CASE #",?23,"ID #",!
FOR LINE=1:1:132
WRITE "="
+5 SET PAGE=PAGE+1
IF $DATA(J)
DO NAME
DO ROLE
+6 QUIT
EN1 ;
+1 USE IO
NEW SRFRTO
SET Y=DT
XECUTE ^DD("DD")
SET SRPRINT="DATE PRINTED: "_Y
SET Y=SRSD
XECUTE ^DD("DD")
SET SRFRTO="FROM: "_Y_" TO: "
SET Y=SRED
XECUTE ^DD("DD")
SET SRFRTO=SRFRTO_Y
+2 KILL J
SET (SRF,SRUL)=0
SET PAGE=1
DO HDR
SET J=SRSD-.0001
KILL ^TMP("SRO",$JOB)
+3 FOR
SET J=$ORDER(^SRF("AC",J))
IF J>(SRED+.9999)!(J="")
QUIT
SET L=0
FOR
SET L=$ORDER(^SRF("AC",J,L))
IF L=""
QUIT
SET SRTN=L
IF $DATA(^SRF(SRTN,0))
IF $$DIV^SROUTL0(SRTN)
DO SETUP
PRINT ; print from ^TMP(
+1 SET J=0
FOR
SET J=$ORDER(^TMP("SRO",$JOB,J))
IF J=""!(SRF)
QUIT
DO NAME
SET K=0
FOR
SET K=$ORDER(^TMP("SRO",$JOB,J,K))
IF K=""!(SRF)
QUIT
DO ROLE
SET L=0
FOR
SET L=$ORDER(^TMP("SRO",$JOB,J,K,L))
IF L=""!SRF
QUIT
DO PRIN2
+2 IF '$DATA(^TMP("SRO",$JOB))
WRITE $$NODATA^SROUTL0()
+3 KILL ^TMP("SRO",$JOB)
IF $EXTRACT(IOST)="P"
WRITE @IOF
IF $DATA(ZTQUEUED)
IF $GET(ZTSTOP)
QUIT
SET ZTREQ="@"
QUIT
+4 IF $EXTRACT(IOST)'="P"
IF 'SRF
WRITE !!,"Press RETURN to continue "
READ X:DTIME
+5 GOTO END
PRIN2 SET M=0
FOR
SET M=$ORDER(^TMP("SRO",$JOB,J,K,L,M))
IF M=""!SRF
QUIT
SET SRTN=M
DO SET
+1 QUIT