SROICU1 ;B'HAM ISC/MAM - UNSCHEDULED ADMISSION TO ICU BY SPECIALTY ; 2 OCT 1990 12:17 PM
;;3.0; Surgery ;**48,106**;24 Jun 93
S SRSOUT=0,SRSDATE=SRSD-.0001,SREDT=SRED+.9999,SRSSP="SURGICAL SPECIALTY: "_$P(^SRO(137.45,SRSS,0),"^"),SRCT=0
D HDR
F S SRSDATE=$O(^SRF("AC",SRSDATE)) Q:'SRSDATE!(SRSDATE>SREDT)!SRSOUT S SRTN=0 F S SRTN=$O(^SRF("AC",SRSDATE,SRTN)) Q:'SRTN!SRSOUT I $D(^SRF(SRTN,0)),$$DIV^SROUTL0(SRTN) D SET
I SRCT=0 W !!,"No unscheduled admissions to ICU for selected date range."
Q
SET ; case information
S X=$P(^SRF(SRTN,0),"^",4) I X'=SRSS Q
I '$D(^SRF(SRTN,.2)) Q
I $P(^SRF(SRTN,.2),"^",12)="" Q
S SR(.4)=$G(^SRF(SRTN,.4)),SRDISP=$P(SR(.4),"^",3),SRDISP1=$P(SR(.4),"^",6),Y=SRDISP,C=$P(^DD(130,.43,0),"^",2) D:Y'="" Y^DIQ S SRDISP=Y I Y["ICU" Q
S Y=SRDISP1,C=$P(^DD(130,.46,0),"^",2) D:Y'="" Y^DIQ S SRDISP1=Y I Y=""!(Y'["ICU") Q
S SRDIS=SRDISP_"/"_SRDISP1
I $Y+7>IOSL D PAGE I SRSOUT Q
S DFN=$P(^SRF(SRTN,0),"^") D DEM^VADPT S SRODATE=$E(SRSDATE,4,5)_"/"_$E(SRSDATE,6,7)_"/"_$E(SRSDATE,2,3)
S SRDIAG=$S($D(^SRF(SRTN,34)):$P(^(34),"^"),1:"DIAGNOSIS NOT ENTERED"),SR(.1)=$S($D(^SRF(SRTN,.1)):^(.1),1:""),SRSUR=$P(SR(.1),"^",4),SRATT=$P(SR(.1),"^",13)
I SRSUR S SRSUR=$P(^VA(200,SRSUR,0),"^")
I SRATT S SRATT=$P(^VA(200,SRATT,0),"^") I $L(SRATT)>18 S SRATT=$P(SRATT,",")_","_$E($P(SRATT,",",2))
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 SROP,MM,MMM S:$L(SROPER)<50 SROP(1)=SROPER I $L(SROPER)>49 S SROPER=SROPER_" " S SROPER=SROPER_" " F M=1:1 D LOOP Q:MMM=""
W !,SRODATE,?17,VADM(1),?55,SRDIAG,?110,SRSUR,!,?17,VA("PID"),?55,SROP(1),?110,SRATT,!,?17,SRDIS I $D(SROP(2)) W ?55,SROP(2) I $D(SROP(3)) W !,?55,SROP(3) I $D(SROP(4)) W !,?55,SROP(4)
W ! S SRCT=SRCT+1
Q
PAGE I $E(IOST)="P" D HDR Q
W !!,"Press RETURN to continue, or '^' to quit: " R X:DTIME I '$T!(X="^") S SRSOUT=1 Q
I X["?" W !!,"Press RETURN to continue listing cases, or '^' to exit from this option." G PAGE
HDR ; print heading
I $D(ZTQUEUED) D ^SROSTOP I SRHALT S SRSOUT=1 Q
I $Y W @IOF
W !,?(132-$L(SRINST)\2),SRINST,!,?58,"SURGICAL SERVICE",?100,"REVIEWED BY: ",!,?52,"UNSCHEDULED ADMISSIONS TO ICU",?100,"DATE REVIEWED: "
W !,?(132-$L(SRSSP)\2),SRSSP,!,?53,"FROM ",$E(SRSD,4,5)_"/"_$E(SRSD,6,7)_"/"_$E(SRSD,2,3)," TO ",$E(SRED,4,5)_"/"_$E(SRED,6,7)_"/"_$E(SRED,2,3)
W !!,"DATE",?17,"PATIENT",?55,"POSTOPERATIVE DIAGNOSIS",?110,"SURGEON",!,?17,"PATIENT ID",?55,"OPERATIVE PROCEDURE(S)",?110,"ATTENDING SURGEON",!,?17,"REQ DISPOSITION/POSTOP DISPOSITION"
W ! F LINE=1:1:132 W "="
Q
OTHER ; other operations
S SRLONG=1 I $L(SROPER)+$L($P(^SRF(SRTN,13,OPER,0),"^"))>240 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 SROP(M)="" F LOOP=1:1 S MM=$P(SROPER," "),MMM=$P(SROPER," ",2,200) Q:MMM="" Q:$L(SROP(M))+$L(MM)'<50 S SROP(M)=SROP(M)_MM_" ",SROPER=MMM
Q
SROICU1 ;B'HAM ISC/MAM - UNSCHEDULED ADMISSION TO ICU BY SPECIALTY ; 2 OCT 1990 12:17 PM
+1 ;;3.0; Surgery ;**48,106**;24 Jun 93
+2 SET SRSOUT=0
SET SRSDATE=SRSD-.0001
SET SREDT=SRED+.9999
SET SRSSP="SURGICAL SPECIALTY: "_$PIECE(^SRO(137.45,SRSS,0),"^")
SET SRCT=0
+3 DO HDR
+4 FOR
SET SRSDATE=$ORDER(^SRF("AC",SRSDATE))
IF 'SRSDATE!(SRSDATE>SREDT)!SRSOUT
QUIT
SET SRTN=0
FOR
SET SRTN=$ORDER(^SRF("AC",SRSDATE,SRTN))
IF 'SRTN!SRSOUT
QUIT
IF $DATA(^SRF(SRTN,0))
IF $$DIV^SROUTL0(SRTN)
DO SET
+5 IF SRCT=0
WRITE !!,"No unscheduled admissions to ICU for selected date range."
+6 QUIT
SET ; case information
+1 SET X=$PIECE(^SRF(SRTN,0),"^",4)
IF X'=SRSS
QUIT
+2 IF '$DATA(^SRF(SRTN,.2))
QUIT
+3 IF $PIECE(^SRF(SRTN,.2),"^",12)=""
QUIT
+4 SET SR(.4)=$GET(^SRF(SRTN,.4))
SET SRDISP=$PIECE(SR(.4),"^",3)
SET SRDISP1=$PIECE(SR(.4),"^",6)
SET Y=SRDISP
SET C=$PIECE(^DD(130,.43,0),"^",2)
IF Y'=""
DO Y^DIQ
SET SRDISP=Y
IF Y["ICU"
QUIT
+5 SET Y=SRDISP1
SET C=$PIECE(^DD(130,.46,0),"^",2)
IF Y'=""
DO Y^DIQ
SET SRDISP1=Y
IF Y=""!(Y'["ICU")
QUIT
+6 SET SRDIS=SRDISP_"/"_SRDISP1
+7 IF $Y+7>IOSL
DO PAGE
IF SRSOUT
QUIT
+8 SET DFN=$PIECE(^SRF(SRTN,0),"^")
DO DEM^VADPT
SET SRODATE=$EXTRACT(SRSDATE,4,5)_"/"_$EXTRACT(SRSDATE,6,7)_"/"_$EXTRACT(SRSDATE,2,3)
+9 SET SRDIAG=$SELECT($DATA(^SRF(SRTN,34)):$PIECE(^(34),"^"),1:"DIAGNOSIS NOT ENTERED")
SET SR(.1)=$SELECT($DATA(^SRF(SRTN,.1)):^(.1),1:"")
SET SRSUR=$PIECE(SR(.1),"^",4)
SET SRATT=$PIECE(SR(.1),"^",13)
+10 IF SRSUR
SET SRSUR=$PIECE(^VA(200,SRSUR,0),"^")
+11 IF SRATT
SET SRATT=$PIECE(^VA(200,SRATT,0),"^")
IF $LENGTH(SRATT)>18
SET SRATT=$PIECE(SRATT,",")_","_$EXTRACT($PIECE(SRATT,",",2))
OPS SET SROPER=$PIECE(^SRF(SRTN,"OP"),"^")
SET OPER=0
FOR I=0:0
SET OPER=$ORDER(^SRF(SRTN,13,OPER))
IF OPER=""
QUIT
DO OTHER
+1 KILL SROP,MM,MMM
IF $LENGTH(SROPER)<50
SET SROP(1)=SROPER
IF $LENGTH(SROPER)>49
SET SROPER=SROPER_" "
SET SROPER=SROPER_" "
FOR M=1:1
DO LOOP
IF MMM=""
QUIT
+2 WRITE !,SRODATE,?17,VADM(1),?55,SRDIAG,?110,SRSUR,!,?17,VA("PID"),?55,SROP(1),?110,SRATT,!,?17,SRDIS
IF $DATA(SROP(2))
WRITE ?55,SROP(2)
IF $DATA(SROP(3))
WRITE !,?55,SROP(3)
IF $DATA(SROP(4))
WRITE !,?55,SROP(4)
+3 WRITE !
SET SRCT=SRCT+1
+4 QUIT
PAGE IF $EXTRACT(IOST)="P"
DO HDR
QUIT
+1 WRITE !!,"Press RETURN to continue, or '^' to quit: "
READ X:DTIME
IF '$TEST!(X="^")
SET SRSOUT=1
QUIT
+2 IF X["?"
WRITE !!,"Press RETURN to continue listing cases, or '^' to exit from this option."
GOTO PAGE
HDR ; print heading
+1 IF $DATA(ZTQUEUED)
DO ^SROSTOP
IF SRHALT
SET SRSOUT=1
QUIT
+2 IF $Y
WRITE @IOF
+3 WRITE !,?(132-$LENGTH(SRINST)\2),SRINST,!,?58,"SURGICAL SERVICE",?100,"REVIEWED BY: ",!,?52,"UNSCHEDULED ADMISSIONS TO ICU",?100,"DATE REVIEWED: "
+4 WRITE !,?(132-$LENGTH(SRSSP)\2),SRSSP,!,?53,"FROM ",$EXTRACT(SRSD,4,5)_"/"_$EXTRACT(SRSD,6,7)_"/"_$EXTRACT(SRSD,2,3)," TO ",$EXTRACT(SRED,4,5)_"/"_$EXTRACT(SRED,6,7)_"/"_$EXTRACT(SRED,2,3)
+5 WRITE !!,"DATE",?17,"PATIENT",?55,"POSTOPERATIVE DIAGNOSIS",?110,"SURGEON",!,?17,"PATIENT ID",?55,"OPERATIVE PROCEDURE(S)",?110,"ATTENDING SURGEON",!,?17,"REQ DISPOSITION/POSTOP DISPOSITION"
+6 WRITE !
FOR LINE=1:1:132
WRITE "="
+7 QUIT
OTHER ; other operations
+1 SET SRLONG=1
IF $LENGTH(SROPER)+$LENGTH($PIECE(^SRF(SRTN,13,OPER,0),"^"))>240
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 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)'<50
QUIT
SET SROP(M)=SROP(M)_MM_" "
SET SROPER=MMM
+2 QUIT