PSGCT ;BIR/CML3-ADD OR SUBTRACT MINUTES FROM A DATE/TIME ;16 DEC 97 / 1:36 PM
;;5.0; INPATIENT MEDICATIONS ;;16 DEC 97
;
EN(ST,AM) ;
; ST=start date/time AM=minutes (+ or -) X=new date/time
N H,HRS,M,MN,T,X,X1,X2
S:'AM X=ST Q:'AM X S T=1 S:AM<0 T=-1,AM=-AM S X2=AM\1440,AM=AM-(X2*1440),H=AM\60,M=AM#60,HRS=+$E(ST_"0000",9,10),MN=+$E(ST_"0000",11,12),X=$P(ST,".")
I M S MN=MN+(M*T) S:MN>59 MN=MN-60,H=H+1 S:MN<0 MN=MN+60,H=H+1
S:H HRS=HRS+(H*T) S:HRS>24!(HRS=24&MN) HRS=HRS-24,X2=X2+1 S:HRS<0 HRS=HRS+24,X2=X2+1
I X2 S X1=X,X2=X2*T D C^%DTC
S X=+(X_"."_$E(0,HRS<10)_HRS_$E(0,MN<10)_MN) Q X
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSGCT 614 printed Oct 16, 2024@18:01:44 Page 2
PSGCT ;BIR/CML3-ADD OR SUBTRACT MINUTES FROM A DATE/TIME ;16 DEC 97 / 1:36 PM
+1 ;;5.0; INPATIENT MEDICATIONS ;;16 DEC 97
+2 ;
EN(ST,AM) ;
+1 ; ST=start date/time AM=minutes (+ or -) X=new date/time
+2 NEW H,HRS,M,MN,T,X,X1,X2
+3 if 'AM
SET X=ST
if 'AM
QUIT X
SET T=1
if AM<0
SET T=-1
SET AM=-AM
SET X2=AM\1440
SET AM=AM-(X2*1440)
SET H=AM\60
SET M=AM#60
SET HRS=+$EXTRACT(ST_"0000",9,10)
SET MN=+$EXTRACT(ST_"0000",11,12)
SET X=$PIECE(ST,".")
+4 IF M
SET MN=MN+(M*T)
if MN>59
SET MN=MN-60
SET H=H+1
if MN<0
SET MN=MN+60
SET H=H+1
+5 if H
SET HRS=HRS+(H*T)
if HRS>24!(HRS=24&MN)
SET HRS=HRS-24
SET X2=X2+1
if HRS<0
SET HRS=HRS+24
SET X2=X2+1
+6 IF X2
SET X1=X
SET X2=X2*T
DO C^%DTC
+7 SET X=+(X_"."_$EXTRACT(0,HRS<10)_HRS_$EXTRACT(0,MN<10)_MN)
QUIT X