ESPAJE ;ALB/ABR - ADD JOURNAL ENTRY ; 9/24/96
;;1.0;POLICE & SECURITY;**17,18,23,24,32,43**;Mar 31, 1994
;
; This will enable multiple journal entries to be added for the same
; time without overwriting one that is in use.
;
N DIC,DA,X,Y,FIRST,REC,TME
D DATE
S FIRST=1
I Y>0 F D ENTRY Q:$G(Y)<0!$D(DUOUT)!$D(DTOUT)
Q
DATE ; select date
S DIC="^ESP(916,",DIC(0)="AEQMZ"
D ^DIC
I Y S ESPDAT=+Y,DIC=DIC_ESPDAT_",4,",DIC("P")=$P(^DD(916,5,0),U,2)
Q
;
ENTRY ;add/edit entry in time multiple
S DA(1)=ESPDAT,DIC(0)="QAELMZ"
I FIRST D
.S DIC("B")=$$LAST(ESPDAT),FIRST=0
E K DIC("B")
D ^DIC Q:Y<1
S (REC,DA)=+Y
L +^ESP(916,ESPDAT,4,REC):2 I '$T D Q
. W !!,">>Entry for this time is in use.",!,"To create an additional entry for this time, enter time in quotes."
. W !," E.g. - ""1300"""
. W !,"Try later to edit same entry.",!
EDIT ; edit (add) info to new entry
S DIE=DIC,DA=+Y,DA(1)=ESPDAT,DR=".01;1;2;3" D ^DIE
L -^ESP(916,ESPDAT,4,REC)
Q
;
LAST(ESPDAT) ; get last time for journal entry
Q:'$G(ESPDAT) ""
N TIME1,TIME2,ESPT,ESPT1,FCX,FC
;
; Are start and end times for the journal defined? If so, use them.
;
S ESPT=$G(^ESP(916,ESPDAT,1)),ESPT1=$P($P(ESPT,"^"),"-",4)
I ESPT S ESPT=$P($P(^ESP(916,ESPDAT,1),"^",2),"-",4)
I ESPT,ESPT?4N,+ESPT>0&+ESPT<2401 D
.S ESPT=+$P($P(^ESP(916,ESPDAT,1),"^",2),"-",4)+1
.S TIME1="",TIME2=""
.F S TIME1=$O(^ESP(916,ESPDAT,4,"B",TIME1)) Q:TIME1="" D
..S X=$S(TIME1<ESPT1:DT+1,1:DT)_"."_TIME1
..S:X>TIME2 TIME2=X
.Q:$G(TIME2)=""
.S TIME2=$J($P(TIME2,".",2),4),TIME2=$TR(TIME2," ",0)
;
; If start/end times for journal not defined, assume 0001-2400
;
E D
.S TIME1=$O(^ESP(916,ESPDAT,4,"B",""),-1)
.S TIME2=$O(^ESP(916,ESPDAT,4,"B",9999),-1)
.I (+TIME1)>TIME2 S TIME2=TIME1
;
Q $G(TIME2)
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HESPAJE 1839 printed Dec 13, 2024@02:29:34 Page 2
ESPAJE ;ALB/ABR - ADD JOURNAL ENTRY ; 9/24/96
+1 ;;1.0;POLICE & SECURITY;**17,18,23,24,32,43**;Mar 31, 1994
+2 ;
+3 ; This will enable multiple journal entries to be added for the same
+4 ; time without overwriting one that is in use.
+5 ;
+6 NEW DIC,DA,X,Y,FIRST,REC,TME
+7 DO DATE
+8 SET FIRST=1
+9 IF Y>0
FOR
DO ENTRY
if $GET(Y)<0!$DATA(DUOUT)!$DATA(DTOUT)
QUIT
+10 QUIT
DATE ; select date
+1 SET DIC="^ESP(916,"
SET DIC(0)="AEQMZ"
+2 DO ^DIC
+3 IF Y
SET ESPDAT=+Y
SET DIC=DIC_ESPDAT_",4,"
SET DIC("P")=$PIECE(^DD(916,5,0),U,2)
+4 QUIT
+5 ;
ENTRY ;add/edit entry in time multiple
+1 SET DA(1)=ESPDAT
SET DIC(0)="QAELMZ"
+2 IF FIRST
Begin DoDot:1
+3 SET DIC("B")=$$LAST(ESPDAT)
SET FIRST=0
End DoDot:1
+4 IF '$TEST
KILL DIC("B")
+5 DO ^DIC
if Y<1
QUIT
+6 SET (REC,DA)=+Y
+7 LOCK +^ESP(916,ESPDAT,4,REC):2
IF '$TEST
Begin DoDot:1
+8 WRITE !!,">>Entry for this time is in use.",!,"To create an additional entry for this time, enter time in quotes."
+9 WRITE !," E.g. - ""1300"""
+10 WRITE !,"Try later to edit same entry.",!
End DoDot:1
QUIT
EDIT ; edit (add) info to new entry
+1 SET DIE=DIC
SET DA=+Y
SET DA(1)=ESPDAT
SET DR=".01;1;2;3"
DO ^DIE
+2 LOCK -^ESP(916,ESPDAT,4,REC)
+3 QUIT
+4 ;
LAST(ESPDAT) ; get last time for journal entry
+1 if '$GET(ESPDAT)
QUIT ""
+2 NEW TIME1,TIME2,ESPT,ESPT1,FCX,FC
+3 ;
+4 ; Are start and end times for the journal defined? If so, use them.
+5 ;
+6 SET ESPT=$GET(^ESP(916,ESPDAT,1))
SET ESPT1=$PIECE($PIECE(ESPT,"^"),"-",4)
+7 IF ESPT
SET ESPT=$PIECE($PIECE(^ESP(916,ESPDAT,1),"^",2),"-",4)
+8 IF ESPT
IF ESPT?4N
IF +ESPT>0&+ESPT<2401
Begin DoDot:1
+9 SET ESPT=+$PIECE($PIECE(^ESP(916,ESPDAT,1),"^",2),"-",4)+1
+10 SET TIME1=""
SET TIME2=""
+11 FOR
SET TIME1=$ORDER(^ESP(916,ESPDAT,4,"B",TIME1))
if TIME1=""
QUIT
Begin DoDot:2
+12 SET X=$SELECT(TIME1<ESPT1:DT+1,1:DT)_"."_TIME1
+13 if X>TIME2
SET TIME2=X
End DoDot:2
+14 if $GET(TIME2)=""
QUIT
+15 SET TIME2=$JUSTIFY($PIECE(TIME2,".",2),4)
SET TIME2=$TRANSLATE(TIME2," ",0)
End DoDot:1
+16 ;
+17 ; If start/end times for journal not defined, assume 0001-2400
+18 ;
+19 IF '$TEST
Begin DoDot:1
+20 SET TIME1=$ORDER(^ESP(916,ESPDAT,4,"B",""),-1)
+21 SET TIME2=$ORDER(^ESP(916,ESPDAT,4,"B",9999),-1)
+22 IF (+TIME1)>TIME2
SET TIME2=TIME1
End DoDot:1
+23 ;
+24 QUIT $GET(TIME2)