LRLOG ;SLC/STAFF - Edit Log ;10/15/03 09:08
;;5.2;LAB SERVICE;**295**;Sep 27, 1994
;
TIMESTMP(PAT,SUB,CDT,USER,TIMESTMP) ; set a timestamp entry in edit log
; from LRPX,LRPXRM
;N DATA,NUM
;S PAT=+$G(PAT)
;S SUB=$G(SUB)
;S CDT=$G(CDT)
;Q:'PAT Q:'$L(SUB) Q:'CDT
;I '$G(TIMESTMP) S TIMESTMP=$$NOW^XLFDT
;S USER=$G(USER)
;S NUM=+$P(^LRLOG(0),U,3)
;S DATA=TIMESTMP_U_PAT_U_SUB_U_CDT_U_USER
;L +^LRLOG(0):20 I '$T Q
;S NUM=1+$P(^LRLOG(0),U,3)
;F Q:'$D(^LRLOG(NUM)) S NUM=NUM+1
;S $P(^LRLOG(0),U,3)=NUM,$P(^(0),U,4)=$P(^(0),U,4)+1
;S ^LRLOG(NUM)=DATA
;L -^LRLOG(0)
;S ^LRLOG("B",TIMESTMP,NUM)=""
;S ^LRLOG("P",PAT,TIMESTMP,NUM)=""
Q
;
INIT ; initialize setup of edit log
; sets last edit as timestamp on old data
; does not set user
;N CDT,DATA,DFN,I,IDT,LRDFN,RELEASE,SUB,TIMESTMP
;S I=0 F S I=$O(^LRLOG(I)) Q:I="" K ^LRLOG(I)
;S $P(^LRLOG(0),U,3,4)="0^0"
;S LRDFN=.9
;F S LRDFN=$O(^LR(LRDFN)) Q:LRDFN<1 D
;. S DFN=$$DFN^LRPXAPIU(LRDFN)
;. I 'DFN Q
;. S SUB="CH"
;. S IDT=0
;. F S IDT=$O(^LR(LRDFN,SUB,IDT)) Q:IDT<1 D
;.. S DATA=$G(^LR(LRDFN,SUB,IDT,0))
;.. I '$L(DATA) Q
;.. S TIMESTMP=+$P(DATA,U,3)
;.. I 'TIMESTMP Q
;.. S CDT=+DATA
;.. I 'CDT Q
;.. D TIMESTMP(DFN,SUB,CDT,,TIMESTMP)
;. S SUB="MI"
;. S IDT=0
;. F S IDT=$O(^LR(LRDFN,SUB,IDT)) Q:IDT<1 D
;.. S DATA=$G(^LR(LRDFN,SUB,IDT,0))
;.. I '$L(DATA) Q
;.. S CDT=+DATA
;.. I 'CDT Q
;.. S TIMESTMP=+$P(DATA,U,3)
;.. F I=1,5,8,11,16 I $G(^LR(LRDFN,SUB,IDT,I))>TIMESTMP S TIMESTMP=+^(I)
;.. I 'TIMESTMP Q
;.. D TIMESTMP(DFN,SUB,CDT,,TIMESTMP)
;. F SUB="CY","EM","SP" D
;.. S IDT=0
;.. F S IDT=$O(^LR(LRDFN,SUB,IDT)) Q:IDT<1 D
;... S DATA=$G(^LR(LRDFN,SUB,IDT,0))
;... I '$L(DATA) Q
;... S TIMESTMP=+$P(DATA,U,3)
;... I 'TIMESTMP Q
;... S RELEASE=+$P(DATA,U,11)
;... I 'RELEASE Q
;... I RELEASE>TIMESTMP S TIMESTMP=RELEASE
;... S CDT=+DATA
;... I 'CDT Q
;... D TIMESTMP(DFN,SUB,CDT,,TIMESTMP)
;. S SUB="AU"
;. S DATA=$G(^LR(LRDFN,SUB))
;. I 'DATA Q
;. S TIMESTMP=+$P(DATA,U,3)
;. I 'TIMESTMP Q
;. S RELEASE=+$P(DATA,U,15)
;. I 'RELEASE Q
;. I RELEASE>TIMESTMP S TIMESTMP=RELEASE
;. S CDT=$$DOD^LRPXAPIU(DFN)
;. I 'CDT Q
;. D TIMESTMP(DFN,SUB,CDT,,TIMESTMP)
Q
;
DATEINTG(DATE1,DATE2,CNT) ; check integrity on patient's that were edited during a time range
; returns ^TMP("LRLOG",$J),^TMP("LRLOG PATS",$J) - must kill after use
;N DFN,NUMBER
;S DATE1=+$G(DATE1,1),DATE2=+$G(DATE2,9999999)
;D PATS(DATE1,DATE2,.CNT)
;I 'CNT S ^TMP("LRLOG",$J)="0^0" Q
;S (CNT,DFN,NUMBER)=0
;F S DFN=$O(^TMP("LRLOG PATS",$J,DFN)) Q:DFN<1 D
;. D PATINTEG(DFN,.CNT)
;. S NUMBER=NUMBER+1
;S ^TMP("LRLOG",$J)=CNT_U_NUMBER
Q
;
PATS(DATE1,DATE2,CNT) ; get patients that were edited during a time range
; returns ^TMP("LRLOG PATS",$J) - must kill after use
;N BEGCDT,CDT,DATA,DFN,ENDCDT,NUM,TSDT
;K ^TMP("LRLOG PATS",$J)
;S BEGCDT=9999999,(CNT,ENDCDT)=0
;S TSDT=$G(DATE1)-.00001
;F S TSDT=$O(^LRLOG("B",TSDT)) Q:TSDT<1 Q:TSDT>DATE2 D
;. S NUM=0
;. F S NUM=$O(^LRLOG("B",TSDT,NUM)) Q:NUM<1 D
;.. S DATA=$G(^LRLOG(NUM))
;.. S DFN=+$P(DATA,U,2)
;.. S CDT=+$P(DATA,U,4)
;.. I CDT<BEGCDT S BEGCDT=CDT
;.. I CDT>ENDCDT S ENDCDT=CDT
;.. Q:'DFN Q:'CDT
;.. I '$D(^TMP("LRLOG PATS",$J,DFN)) S CNT=CNT+1
;.. S ^TMP("LRLOG PATS",$J,DFN)=BEGCDT_U_ENDCDT
;.. S ^TMP("LRLOG PATS",$J,DFN,NUM)=""
;S ^TMP("LRLOG PATS",$J)=CNT
Q
;
PATINTEG(DFN,CNT) ; check integrity of a patient
; returns ^TMP("LRLOG",$J) - must kill after use
;K ^TMP("LRLOG",$J,DFN)
;S CNT=+$G(CNT)
;D CHKPAT^LRPXCHK(DFN)
;I $D(^TMP("LRLOG",$J,DFN)) S CNT=CNT+1
Q
;
TESTP ; test for patient integrity
;N DIC,X,Y K DIC
;S DIC=2,DIC(0)="AEMOQ"
;D ^DIC I Y<1 Q
;D PATINTEG(+Y)
;K ^TMP("LRLOG",$J)
Q
;
TESTD ; test for integrity of patients that were edited during a date range
;N CNT,DFN,ERR,FROM,TO
;D GETDATE^LRPXAPPU(.FROM,.TO,.ERR) I ERR Q
;S CNT=0
;D DATEINTG(FROM,TO,.CNT)
;S DFN=0
;F S DFN=$O(^TMP("LRLOG PATS",$J,DFN)) Q:DFN<.5 W !,DFN," ",$P(^DPT(DFN,0),U)," checked"
;K ^TMP("LRLOG",$J),^TMP("LRLOG PATS",$J)
Q
;
LTS() ; $$() -> last timestamp ien
;N TSDT
;S TSDT=+$O(^LRLOG("B",""),-1)
;Q +$O(^LRLOG("B",TSDT,0))
Q 0 ;remove after testing
;
LPTS(DFN) ; $$(dfn) -> patient's last timestamp ien
;N TSDT
;S DFN=+$G(DFN)
;S TSDT=+$O(^LRLOG("P",DFN,""),-1)
;Q +$O(^LRLOG("P",DFN,TSDT,0))
Q 0 ;remove after testing
;
TSDT(TSDT,TS) ; API - returns array of timestamps for a timestamp date/time
;N NUM K TS
;S TSDT=+$G(TSDT)
;S NUM=0
;F S NUM=$O(^LRLOG("B",TSDT,NUM)) Q:NUM<1 S TS(NUM)=""
Q
;
PTSDT(DFN,TSDT,TS) ; API - returns patient's array of timestamps for a timestamp date/time
;N NUM K TS
;S DFN=+$G(DFN),TSDT=+$G(TSDT)
;S NUM=0
;F S NUM=$O(^LRLOG("P",DFN,TSDT,NUM)) Q:NUM<1 S TS(NUM)=""
Q
;
NTSDT(TSDT) ; $$(timestamp date/time) -> next timestamp ien from a timestamp date/time
;S TSDT=+$G(TSDT)
;Q +$O(^LRLOG("B",TSDT),-1)
Q 0 ;remove after testing
;
NPTSDT(DFN,TSDT) ; $$(dfn,timestamp date/time) -> patient's next timestamp date/time
;S DFN=+$G(DFN),TSDT=+$G(TSDT)
;Q +$O(^LRLOG("P",DFN,TSDT),-1)
Q 0 ;remove after testing
;
LOG(TS) ; $$(timestamp ien) -> timestamp entry: timestamp^dfn^sub^cdt^user
;Q $G(^LRLOG(+$G(TS)))
Q 0 ;remove after testing
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HLRLOG 5410 printed Oct 16, 2024@18:17:31 Page 2
LRLOG ;SLC/STAFF - Edit Log ;10/15/03 09:08
+1 ;;5.2;LAB SERVICE;**295**;Sep 27, 1994
+2 ;
TIMESTMP(PAT,SUB,CDT,USER,TIMESTMP) ; set a timestamp entry in edit log
+1 ; from LRPX,LRPXRM
+2 ;N DATA,NUM
+3 ;S PAT=+$G(PAT)
+4 ;S SUB=$G(SUB)
+5 ;S CDT=$G(CDT)
+6 ;Q:'PAT Q:'$L(SUB) Q:'CDT
+7 ;I '$G(TIMESTMP) S TIMESTMP=$$NOW^XLFDT
+8 ;S USER=$G(USER)
+9 ;S NUM=+$P(^LRLOG(0),U,3)
+10 ;S DATA=TIMESTMP_U_PAT_U_SUB_U_CDT_U_USER
+11 ;L +^LRLOG(0):20 I '$T Q
+12 ;S NUM=1+$P(^LRLOG(0),U,3)
+13 ;F Q:'$D(^LRLOG(NUM)) S NUM=NUM+1
+14 ;S $P(^LRLOG(0),U,3)=NUM,$P(^(0),U,4)=$P(^(0),U,4)+1
+15 ;S ^LRLOG(NUM)=DATA
+16 ;L -^LRLOG(0)
+17 ;S ^LRLOG("B",TIMESTMP,NUM)=""
+18 ;S ^LRLOG("P",PAT,TIMESTMP,NUM)=""
+19 QUIT
+20 ;
INIT ; initialize setup of edit log
+1 ; sets last edit as timestamp on old data
+2 ; does not set user
+3 ;N CDT,DATA,DFN,I,IDT,LRDFN,RELEASE,SUB,TIMESTMP
+4 ;S I=0 F S I=$O(^LRLOG(I)) Q:I="" K ^LRLOG(I)
+5 ;S $P(^LRLOG(0),U,3,4)="0^0"
+6 ;S LRDFN=.9
+7 ;F S LRDFN=$O(^LR(LRDFN)) Q:LRDFN<1 D
+8 ;. S DFN=$$DFN^LRPXAPIU(LRDFN)
+9 ;. I 'DFN Q
+10 ;. S SUB="CH"
+11 ;. S IDT=0
+12 ;. F S IDT=$O(^LR(LRDFN,SUB,IDT)) Q:IDT<1 D
+13 ;.. S DATA=$G(^LR(LRDFN,SUB,IDT,0))
+14 ;.. I '$L(DATA) Q
+15 ;.. S TIMESTMP=+$P(DATA,U,3)
+16 ;.. I 'TIMESTMP Q
+17 ;.. S CDT=+DATA
+18 ;.. I 'CDT Q
+19 ;.. D TIMESTMP(DFN,SUB,CDT,,TIMESTMP)
+20 ;. S SUB="MI"
+21 ;. S IDT=0
+22 ;. F S IDT=$O(^LR(LRDFN,SUB,IDT)) Q:IDT<1 D
+23 ;.. S DATA=$G(^LR(LRDFN,SUB,IDT,0))
+24 ;.. I '$L(DATA) Q
+25 ;.. S CDT=+DATA
+26 ;.. I 'CDT Q
+27 ;.. S TIMESTMP=+$P(DATA,U,3)
+28 ;.. F I=1,5,8,11,16 I $G(^LR(LRDFN,SUB,IDT,I))>TIMESTMP S TIMESTMP=+^(I)
+29 ;.. I 'TIMESTMP Q
+30 ;.. D TIMESTMP(DFN,SUB,CDT,,TIMESTMP)
+31 ;. F SUB="CY","EM","SP" D
+32 ;.. S IDT=0
+33 ;.. F S IDT=$O(^LR(LRDFN,SUB,IDT)) Q:IDT<1 D
+34 ;... S DATA=$G(^LR(LRDFN,SUB,IDT,0))
+35 ;... I '$L(DATA) Q
+36 ;... S TIMESTMP=+$P(DATA,U,3)
+37 ;... I 'TIMESTMP Q
+38 ;... S RELEASE=+$P(DATA,U,11)
+39 ;... I 'RELEASE Q
+40 ;... I RELEASE>TIMESTMP S TIMESTMP=RELEASE
+41 ;... S CDT=+DATA
+42 ;... I 'CDT Q
+43 ;... D TIMESTMP(DFN,SUB,CDT,,TIMESTMP)
+44 ;. S SUB="AU"
+45 ;. S DATA=$G(^LR(LRDFN,SUB))
+46 ;. I 'DATA Q
+47 ;. S TIMESTMP=+$P(DATA,U,3)
+48 ;. I 'TIMESTMP Q
+49 ;. S RELEASE=+$P(DATA,U,15)
+50 ;. I 'RELEASE Q
+51 ;. I RELEASE>TIMESTMP S TIMESTMP=RELEASE
+52 ;. S CDT=$$DOD^LRPXAPIU(DFN)
+53 ;. I 'CDT Q
+54 ;. D TIMESTMP(DFN,SUB,CDT,,TIMESTMP)
+55 QUIT
+56 ;
DATEINTG(DATE1,DATE2,CNT) ; check integrity on patient's that were edited during a time range
+1 ; returns ^TMP("LRLOG",$J),^TMP("LRLOG PATS",$J) - must kill after use
+2 ;N DFN,NUMBER
+3 ;S DATE1=+$G(DATE1,1),DATE2=+$G(DATE2,9999999)
+4 ;D PATS(DATE1,DATE2,.CNT)
+5 ;I 'CNT S ^TMP("LRLOG",$J)="0^0" Q
+6 ;S (CNT,DFN,NUMBER)=0
+7 ;F S DFN=$O(^TMP("LRLOG PATS",$J,DFN)) Q:DFN<1 D
+8 ;. D PATINTEG(DFN,.CNT)
+9 ;. S NUMBER=NUMBER+1
+10 ;S ^TMP("LRLOG",$J)=CNT_U_NUMBER
+11 QUIT
+12 ;
PATS(DATE1,DATE2,CNT) ; get patients that were edited during a time range
+1 ; returns ^TMP("LRLOG PATS",$J) - must kill after use
+2 ;N BEGCDT,CDT,DATA,DFN,ENDCDT,NUM,TSDT
+3 ;K ^TMP("LRLOG PATS",$J)
+4 ;S BEGCDT=9999999,(CNT,ENDCDT)=0
+5 ;S TSDT=$G(DATE1)-.00001
+6 ;F S TSDT=$O(^LRLOG("B",TSDT)) Q:TSDT<1 Q:TSDT>DATE2 D
+7 ;. S NUM=0
+8 ;. F S NUM=$O(^LRLOG("B",TSDT,NUM)) Q:NUM<1 D
+9 ;.. S DATA=$G(^LRLOG(NUM))
+10 ;.. S DFN=+$P(DATA,U,2)
+11 ;.. S CDT=+$P(DATA,U,4)
+12 ;.. I CDT<BEGCDT S BEGCDT=CDT
+13 ;.. I CDT>ENDCDT S ENDCDT=CDT
+14 ;.. Q:'DFN Q:'CDT
+15 ;.. I '$D(^TMP("LRLOG PATS",$J,DFN)) S CNT=CNT+1
+16 ;.. S ^TMP("LRLOG PATS",$J,DFN)=BEGCDT_U_ENDCDT
+17 ;.. S ^TMP("LRLOG PATS",$J,DFN,NUM)=""
+18 ;S ^TMP("LRLOG PATS",$J)=CNT
+19 QUIT
+20 ;
PATINTEG(DFN,CNT) ; check integrity of a patient
+1 ; returns ^TMP("LRLOG",$J) - must kill after use
+2 ;K ^TMP("LRLOG",$J,DFN)
+3 ;S CNT=+$G(CNT)
+4 ;D CHKPAT^LRPXCHK(DFN)
+5 ;I $D(^TMP("LRLOG",$J,DFN)) S CNT=CNT+1
+6 QUIT
+7 ;
TESTP ; test for patient integrity
+1 ;N DIC,X,Y K DIC
+2 ;S DIC=2,DIC(0)="AEMOQ"
+3 ;D ^DIC I Y<1 Q
+4 ;D PATINTEG(+Y)
+5 ;K ^TMP("LRLOG",$J)
+6 QUIT
+7 ;
TESTD ; test for integrity of patients that were edited during a date range
+1 ;N CNT,DFN,ERR,FROM,TO
+2 ;D GETDATE^LRPXAPPU(.FROM,.TO,.ERR) I ERR Q
+3 ;S CNT=0
+4 ;D DATEINTG(FROM,TO,.CNT)
+5 ;S DFN=0
+6 ;F S DFN=$O(^TMP("LRLOG PATS",$J,DFN)) Q:DFN<.5 W !,DFN," ",$P(^DPT(DFN,0),U)," checked"
+7 ;K ^TMP("LRLOG",$J),^TMP("LRLOG PATS",$J)
+8 QUIT
+9 ;
LTS() ; $$() -> last timestamp ien
+1 ;N TSDT
+2 ;S TSDT=+$O(^LRLOG("B",""),-1)
+3 ;Q +$O(^LRLOG("B",TSDT,0))
+4 ;remove after testing
QUIT 0
+5 ;
LPTS(DFN) ; $$(dfn) -> patient's last timestamp ien
+1 ;N TSDT
+2 ;S DFN=+$G(DFN)
+3 ;S TSDT=+$O(^LRLOG("P",DFN,""),-1)
+4 ;Q +$O(^LRLOG("P",DFN,TSDT,0))
+5 ;remove after testing
QUIT 0
+6 ;
TSDT(TSDT,TS) ; API - returns array of timestamps for a timestamp date/time
+1 ;N NUM K TS
+2 ;S TSDT=+$G(TSDT)
+3 ;S NUM=0
+4 ;F S NUM=$O(^LRLOG("B",TSDT,NUM)) Q:NUM<1 S TS(NUM)=""
+5 QUIT
+6 ;
PTSDT(DFN,TSDT,TS) ; API - returns patient's array of timestamps for a timestamp date/time
+1 ;N NUM K TS
+2 ;S DFN=+$G(DFN),TSDT=+$G(TSDT)
+3 ;S NUM=0
+4 ;F S NUM=$O(^LRLOG("P",DFN,TSDT,NUM)) Q:NUM<1 S TS(NUM)=""
+5 QUIT
+6 ;
NTSDT(TSDT) ; $$(timestamp date/time) -> next timestamp ien from a timestamp date/time
+1 ;S TSDT=+$G(TSDT)
+2 ;Q +$O(^LRLOG("B",TSDT),-1)
+3 ;remove after testing
QUIT 0
+4 ;
NPTSDT(DFN,TSDT) ; $$(dfn,timestamp date/time) -> patient's next timestamp date/time
+1 ;S DFN=+$G(DFN),TSDT=+$G(TSDT)
+2 ;Q +$O(^LRLOG("P",DFN,TSDT),-1)
+3 ;remove after testing
QUIT 0
+4 ;
LOG(TS) ; $$(timestamp ien) -> timestamp entry: timestamp^dfn^sub^cdt^user
+1 ;Q $G(^LRLOG(+$G(TS)))
+2 ;remove after testing
QUIT 0
+3 ;