source: WorldVistAEHR/trunk/r/SURGERY-SR/SRORUT0.m@ 1476

Last change on this file since 1476 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 4.0 KB
Line 
1SRORUT0 ;B'HAM ISC/MAM - OR UTILIZATION ; [ 10/01/98 9:55 AM ]
2 ;;3.0; Surgery ;**34,50**;24 Jun 93
3EN ; entry when queued
4 K ^TMP("SR",$J) S SRSOUT=0,SRFLG=1,SRSDT=SRSD1,^TMP("SR",$J)="0^0^0^0"
5 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
6 I SRFLG S (X,SRSDATE)=SRSD D H^%DTC S SRD=%Y D ONE^SROUTIN,AOR
7MM 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
8 I SRFLG S SRORN=$P(^SRS(SROR,0),"^"),SRORN=$P(^SC(SRORN,0),"^")
9 S SRHDR="FOR "_$S($D(SRORN):SRORN,1:"ALL OPERATING ROOMS")_SRFRTO,PAGE=0
10 D ^SRORUT1
11END W:$E(IOST)="P" @IOF I $D(ZTQUEUED) K ^TMP("SR",$J) Q:$G(ZTSTOP) S ZTREQ="@" Q
12 D ^SRSKILL K SRTN D ^%ZISC W @IOF
13 Q
14AOR ;
15 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
16 Q
17DAY ; get start times
18 S TIMES=$P(^TMP("SR",$J,SRSDT,SROR),"^",5,6),SRORST=$P(TIMES,"^"),SROREND=$P(TIMES,"^",2),SRTIME=1
19 S X=$P(SRORST,".",2) S:'X SRTIME="" S X=$P(SROREND,".",2) S:'X SRTIME=""
20 Q
21UTIL ; set ^TMP("SR"
22 S SRCON=$P($G(^SRF(SRTN,"CON")),"^") I SRCON,$D(^TMP("SR",$J,"OR",SROR,SRCON)) D CON Q
23 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)
24 S DFN=$P(^SRF(SRTN,0),"^") I $D(^TMP("SRPAT",$J,SRSDT,DFN)) D OPCHK I SRCON D CON Q
25 I SRPATIN="",SRNURSE="" Q
26 Q:SRPATOUT="" S TIMEOUT=SRPATOUT S:SRPATIN="" SRPATIN=99999999 S:SRNURSE="" SRNURSE=99999999 S TIMEIN=$S(SRPATIN<SRNURSE:SRPATIN,1:SRNURSE) D ET
27 S X1=TIMEOUT,X=TIMEIN D MIN S SROPTIME=X D OT
28 S SRUTIL=^TMP("SR",$J,SRSDT,SROR),SRT=$P(SRUTIL,"^",5,6),SRCASE=$P(SRUTIL,"^")+1
29 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
30 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)
31 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
32 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
33 S ^TMP("SR",$J,"OR",SROR,SRTN)="",^TMP("SRPAT",$J,SRSDT,DFN)=SROR_"^"_SRPATIN_"^"_SRPATOUT
34 Q
35OT ; calculate overtime
36 S SROVRT=0
37 I 'SRTIME S X=TIMEIN,X1=TIMEOUT D MIN S SROVRT=X
38 I TIMEOUT<SRORST S X=TIMEIN,X1=TIMEOUT D MIN S SROVRT=X Q
39 I TIMEIN>SROREND S X=TIMEIN,X1=TIMEOUT D MIN S SROVRT=X Q
40 I TIMEIN<SRORST S X=TIMEIN,X1=SRORST D MIN S SROVRT=X
41 I TIMEOUT>SROREND S X=SROREND,X1=TIMEOUT D MIN S SROVRT=SROVRT+X
42 Q
43MIN ; minutes between two times
44 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
45 Q
46CON S $P(^TMP("SR",$J,SRSDT,SROR),"^")=$P(^TMP("SR",$J,SRSDT,SROR),"^")+1
47 S $P(^TMP("SR",$J,SRSDT),"^")=$P(^TMP("SR",$J,SRSDT),"^")+1
48 S $P(^TMP("SR",$J),"^")=$P(^TMP("SR",$J),"^")+1
49 S $P(^TMP("SR",$J,"OR",SROR),"^")=$P(^TMP("SR",$J,"OR",SROR),"^")+1
50 S ^TMP("SR",$J,"OR",SROR,SRTN)=""
51 Q
52ET ; add cleanup time to time out of O.R.
53 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)
54 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"
55 S:$L(SRHR)=1 SRHR="0"_SRHR S:$L(SRMIN)=1 SRMIN="0"_SRMIN S TIMEOUT=SRD_"."_SRHR_SRMIN
56 Q
57OPCHK ; check for concurrent case not marked conurrent
58 S X=^TMP("SRPAT",$J,SRSDT,DFN),SRRM=$P(X,"^"),SRIN=$P(X,"^",2),SROUT=$P(X,"^",3) Q:SRRM'=SROR
59 I SRIN=SRPATIN,SROUT=SRPATOUT S SRCON=1
60 Q
Note: See TracBrowser for help on using the repository browser.