61 lines
4.0 KiB
Mathematica
61 lines
4.0 KiB
Mathematica
SRORUT0 ;B'HAM ISC/MAM - OR UTILIZATION ; [ 10/01/98 9:55 AM ]
|
|
;;3.0; Surgery ;**34,50**;24 Jun 93
|
|
EN ; entry when queued
|
|
K ^TMP("SR",$J) S SRSOUT=0,SRFLG=1,SRSDT=SRSD1,^TMP("SR",$J)="0^0^0^0"
|
|
I SROR="ALL" S SRFLG=0 D ALL^SROUTIN S SROR=0 F S SROR=$O(^SRF("AOR",SROR)) Q:'SROR I $$ORDIV^SROUTL0(SROR,SRDIV),'$P(^SRS(SROR,0),"^",6) S SRSDT=SRSD1 D AOR
|
|
I SRFLG S (X,SRSDATE)=SRSD D H^%DTC S SRD=%Y D ONE^SROUTIN,AOR
|
|
MM U IO N SRFRTO S Y=SRSD X ^DD("DD") S SRFRTO=" FROM: "_Y_" TO: ",Y=SRED X ^DD("DD") S SRFRTO=SRFRTO_Y,Y=DT X ^DD("DD") S SRPRINT="DATE PRINTED: "_Y
|
|
I SRFLG S SRORN=$P(^SRS(SROR,0),"^"),SRORN=$P(^SC(SRORN,0),"^")
|
|
S SRHDR="FOR "_$S($D(SRORN):SRORN,1:"ALL OPERATING ROOMS")_SRFRTO,PAGE=0
|
|
D ^SRORUT1
|
|
END W:$E(IOST)="P" @IOF I $D(ZTQUEUED) K ^TMP("SR",$J) Q:$G(ZTSTOP) S ZTREQ="@" Q
|
|
D ^SRSKILL K SRTN D ^%ZISC W @IOF
|
|
Q
|
|
AOR ;
|
|
F K ^TMP("SRPAT",$J) S SRSDT=$O(^SRF("AOR",SROR,SRSDT)) Q:'SRSDT!(SRSDT>SRED1) D DAY S SRTN=0 F S SRTN=$O(^SRF("AOR",SROR,SRSDT,SRTN)) Q:'SRTN D UTIL
|
|
Q
|
|
DAY ; get start times
|
|
S TIMES=$P(^TMP("SR",$J,SRSDT,SROR),"^",5,6),SRORST=$P(TIMES,"^"),SROREND=$P(TIMES,"^",2),SRTIME=1
|
|
S X=$P(SRORST,".",2) S:'X SRTIME="" S X=$P(SROREND,".",2) S:'X SRTIME=""
|
|
Q
|
|
UTIL ; set ^TMP("SR"
|
|
S SRCON=$P($G(^SRF(SRTN,"CON")),"^") I SRCON,$D(^TMP("SR",$J,"OR",SROR,SRCON)) D CON Q
|
|
S SR(.2)=$S($D(^SRF(SRTN,.2)):^(.2),1:"") Q:SR(.2)="" S SRPATIN=$P(SR(.2),"^",10),SRPATOUT=$P(SR(.2),"^",12),SRNURSE=$P(SR(.2),"^",7)
|
|
S DFN=$P(^SRF(SRTN,0),"^") I $D(^TMP("SRPAT",$J,SRSDT,DFN)) D OPCHK I SRCON D CON Q
|
|
I SRPATIN="",SRNURSE="" Q
|
|
Q:SRPATOUT="" S TIMEOUT=SRPATOUT S:SRPATIN="" SRPATIN=99999999 S:SRNURSE="" SRNURSE=99999999 S TIMEIN=$S(SRPATIN<SRNURSE:SRPATIN,1:SRNURSE) D ET
|
|
S X1=TIMEOUT,X=TIMEIN D MIN S SROPTIME=X D OT
|
|
S SRUTIL=^TMP("SR",$J,SRSDT,SROR),SRT=$P(SRUTIL,"^",5,6),SRCASE=$P(SRUTIL,"^")+1
|
|
S SROPDT=$P(SRUTIL,"^",2)+SROPTIME,SRTP=$P(SRUTIL,"^",3),SROT=$P(SRUTIL,"^",4)+SROVRT,^TMP("SR",$J,SRSDT,SROR)=SRCASE_"^"_SROPDT_"^"_SRTP_"^"_SROT_"^"_SRT
|
|
S SRUTIL=^TMP("SR",$J,SRSDT),SRCASE=$P(SRUTIL,"^")+1,SROPDT=$P(SRUTIL,"^",2)+SROPTIME,SROT=$P(SRUTIL,"^",4)+SROVRT,^TMP("SR",$J,SRSDT)=SRCASE_"^"_SROPDT_"^"_$P(SRUTIL,"^",3)_"^"_SROT_"^"_$P(SRUTIL,"^",5)
|
|
S SRUTIL=^TMP("SR",$J),SRCASE=$P(SRUTIL,"^")+1,SROPDT=$P(SRUTIL,"^",2)+SROPTIME,SRTP=$P(SRUTIL,"^",3),SROT=$P(SRUTIL,"^",4)+SROVRT,^TMP("SR",$J)=SRCASE_"^"_SROPDT_"^"_SRTP_"^"_SROT
|
|
S SRUTIL=^TMP("SR",$J,"OR",SROR),SRCASE=$P(SRUTIL,"^")+1,SROPDT=$P(SRUTIL,"^",2)+SROPTIME,SRTP=$P(SRUTIL,"^",3),SROT=$P(SRUTIL,"^",4)+SROVRT,^TMP("SR",$J,"OR",SROR)=SRCASE_"^"_SROPDT_"^"_SRTP_"^"_SROT
|
|
S ^TMP("SR",$J,"OR",SROR,SRTN)="",^TMP("SRPAT",$J,SRSDT,DFN)=SROR_"^"_SRPATIN_"^"_SRPATOUT
|
|
Q
|
|
OT ; calculate overtime
|
|
S SROVRT=0
|
|
I 'SRTIME S X=TIMEIN,X1=TIMEOUT D MIN S SROVRT=X
|
|
I TIMEOUT<SRORST S X=TIMEIN,X1=TIMEOUT D MIN S SROVRT=X Q
|
|
I TIMEIN>SROREND S X=TIMEIN,X1=TIMEOUT D MIN S SROVRT=X Q
|
|
I TIMEIN<SRORST S X=TIMEIN,X1=SRORST D MIN S SROVRT=X
|
|
I TIMEOUT>SROREND S X=SROREND,X1=TIMEOUT D MIN S SROVRT=SROVRT+X
|
|
Q
|
|
MIN ; minutes between two times
|
|
S Y=$E(X1_"000",9,10)-$E(X_"000",9,10)*60+$E(X1_"00000",11,12)-$E(X_"00000",11,12),X2=X,X=$P(X,".",1)'=$P(X1,".",1) D ^%DTC:X S X=X*1440+Y
|
|
Q
|
|
CON S $P(^TMP("SR",$J,SRSDT,SROR),"^")=$P(^TMP("SR",$J,SRSDT,SROR),"^")+1
|
|
S $P(^TMP("SR",$J,SRSDT),"^")=$P(^TMP("SR",$J,SRSDT),"^")+1
|
|
S $P(^TMP("SR",$J),"^")=$P(^TMP("SR",$J),"^")+1
|
|
S $P(^TMP("SR",$J,"OR",SROR),"^")=$P(^TMP("SR",$J,"OR",SROR),"^")+1
|
|
S ^TMP("SR",$J,"OR",SROR,SRTN)=""
|
|
Q
|
|
ET ; add cleanup time to time out of O.R.
|
|
S CLEAN=$S($D(^SRS(SROR,3)):+^(3),1:30),SRD=$E(TIMEOUT,1,7),SRT=$P(TIMEOUT,".",2)_"0000",SRMIN=$E(SRT,3,4),SRHR=$E(SRT,1,2)
|
|
S SRMIN=SRMIN+CLEAN I SRMIN>59 S SRHR=SRHR+(SRMIN\60) S SRMIN=SRMIN#60 I SRHR>23 S X1=SRD,X2=1 D C^%DTC S SRD=X,SRHR="00"
|
|
S:$L(SRHR)=1 SRHR="0"_SRHR S:$L(SRMIN)=1 SRMIN="0"_SRMIN S TIMEOUT=SRD_"."_SRHR_SRMIN
|
|
Q
|
|
OPCHK ; check for concurrent case not marked conurrent
|
|
S X=^TMP("SRPAT",$J,SRSDT,DFN),SRRM=$P(X,"^"),SRIN=$P(X,"^",2),SROUT=$P(X,"^",3) Q:SRRM'=SROR
|
|
I SRIN=SRPATIN,SROUT=SRPATOUT S SRCON=1
|
|
Q
|