PXRMHIST ; SLC/PKR - Routines for dealing with edit histories. ;12/23/2004
;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
;
;=====================================================
DISP(RIEN,MAX) ;Display edit history in reverse date order, newest to oldest.
N CNT,EDATA,EIEN,ETIME,IC,NIN,NOUT,RNAME
N TEXTIN,TEXTOUT,UIEN,USER
;Last N lines
S CNT=0,EIEN=":"
S RNAME=$P(^PXD(811.9,RIEN,0),U,1)
W !!,"Edit History for reminder "_RNAME_":"
F S EIEN=$O(^PXD(811.9,RIEN,110,EIEN),-1) Q:'EIEN Q:CNT=MAX D
.;Edit date and edit by fields
. S EDATA=$G(^PXD(811.9,RIEN,110,EIEN,0)) Q:EDATA=""
. S ETIME=$P(EDATA,U),UIEN=$P(EDATA,U,2) Q:'UIEN
. S USER=$$GET1^DIQ(200,UIEN,.01),CNT=CNT+1
. W !!,?2,"Edit date: ",$$FMTE^XLFDT(ETIME,"1")
. W ?38,"Edit by: ",USER
. S (IC,NIN)=0
. F S IC=$O(^PXD(811.9,RIEN,110,EIEN,1,IC)) Q:'IC D
.. S NIN=NIN+1
.. S TEXTIN(NIN)=$G(^PXD(811.9,RIEN,110,EIEN,1,IC,0))
. D FORMAT^PXRMTEXT(18,75,NIN,.TEXTIN,.NOUT,.TEXTOUT)
. I NOUT>0 D
.. W !,?2,"Edit Comments:",?1,$P(TEXTOUT(1)," ",17,99)
.. F IC=2:1:NOUT W !,TEXTOUT(IC)
Q
;
;=====================================================
MAX() ;Return the maximum number of occurrences to display.
N DIR,DIROUT,DIRUT,DTOUT,DUOUT,MAX,X,Y
S DIR(0)="N^2:99"
S DIR("A")="Maximum number of occurrences to display "
;Get the edit history count to use as a default value.
S MAX=$G(^PXRM(800,1,"EDIT HISTORY COUNT")) I MAX="" S MAX=2
S DIR("B")=MAX
D ^DIR
I $D(DIROUT)!$D(DIRUT) Q 0
I $D(DTOUT)!$D(DUOUT) Q 0
Q +Y
;
;=====================================================
REM ;Select reminder definition for displaying the history.
N IEN,IENN,MAX,PXRMROOT
S IENN=0
S PXRMROOT="^PXD(811.9,"
S MAX=$$MAX
I MAX=0 Q
F Q:IENN=-1 D
. W !
. S IENN=$$SELECT^PXRMINQ(PXRMROOT,"Select Reminder Definition: ","")
. I IENN=-1 Q
. S IEN=$P(IENN,U,1)
. D DISP(IEN,MAX)
Q
;=====================================================
RMEH ;Remove edit history. This is for items sent directly via KIDS that
;do not go through Exchange. Reminder computed findings are a good
;example.
I DUZ(0)'="@" Q
N CLASS,DIR,DIROUT,DIRUT,DTOUT,DUOUT,EH,ENTRY,IEN
N FIELD,FILENUM,GLOBAL,NAME,X,Y
W !,"Remove edit history from national reminder files.",!
S DIR(0)="NAOU^0::15"
S DIR("A")="Enter the file number: "
D ^DIR
I $D(DIROUT)!$D(DIRUT) Q
I (Y="")!($D(DTOUT))!($D(DUOUT)) Q
S FILENUM=+Y
S FIELD=$$GET1^DID(FILENUM,110,"","LABEL")
I FIELD'="EDIT HISTORY" D Q
. W !,"This is no Edit History in this file!"
S NAME=$$GET1^DID(FILENUM,"","","NAME")
W !,"Looking for edit histories in file ",NAME
S GLOBAL=$$GET1^DID(FILENUM,"","","GLOBAL NAME")
S ENTRY=GLOBAL_"IEN)"
S IEN=0
F S IEN=+$O(@ENTRY) Q:(IEN=0)!($G(DUOUT)) D
. S CLASS=GLOBAL_"IEN,100)"
. S CLASS=$P(@CLASS,U,1)
. I CLASS'="N" Q
. S NAME=GLOBAL_"IEN,0)"
. S NAME=$P(@NAME,U,1)
. K DIR
. S DIR(0)="YA"
. S DIR("A")="Delete Edit History from entry "_NAME_"? "
. S DIR("B")="N"
. D ^DIR
. I $D(DIROUT)!$D(DIRUT) Q
. I (Y="")!($D(DTOUT))!($D(DUOUT)) Q
. I 'Y Q
. S EH=GLOBAL_"IEN,110)"
. K @EH
. S EH=GLOBAL_"IEN,110,0)"
. S @EH="^811.9001D^^0"
Q
;
PXRMHIST ; SLC/PKR - Routines for dealing with edit histories. ;12/23/2004
+1 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
+2 ;
+3 ;=====================================================
DISP(RIEN,MAX) ;Display edit history in reverse date order, newest to oldest.
+1 NEW CNT,EDATA,EIEN,ETIME,IC,NIN,NOUT,RNAME
+2 NEW TEXTIN,TEXTOUT,UIEN,USER
+3 ;Last N lines
+4 SET CNT=0
SET EIEN=":"
+5 SET RNAME=$PIECE(^PXD(811.9,RIEN,0),U,1)
+6 WRITE !!,"Edit History for reminder "_RNAME_":"
+7 FOR
SET EIEN=$ORDER(^PXD(811.9,RIEN,110,EIEN),-1)
IF 'EIEN
QUIT
IF CNT=MAX
QUIT
Begin DoDot:1
+8 ;Edit date and edit by fields
+9 SET EDATA=$GET(^PXD(811.9,RIEN,110,EIEN,0))
IF EDATA=""
QUIT
+10 SET ETIME=$PIECE(EDATA,U)
SET UIEN=$PIECE(EDATA,U,2)
IF 'UIEN
QUIT
+11 SET USER=$$GET1^DIQ(200,UIEN,.01)
SET CNT=CNT+1
+12 WRITE !!,?2,"Edit date: ",$$FMTE^XLFDT(ETIME,"1")
+13 WRITE ?38,"Edit by: ",USER
+14 SET (IC,NIN)=0
+15 FOR
SET IC=$ORDER(^PXD(811.9,RIEN,110,EIEN,1,IC))
IF 'IC
QUIT
Begin DoDot:2
+16 SET NIN=NIN+1
+17 SET TEXTIN(NIN)=$GET(^PXD(811.9,RIEN,110,EIEN,1,IC,0))
End DoDot:2
+18 DO FORMAT^PXRMTEXT(18,75,NIN,.TEXTIN,.NOUT,.TEXTOUT)
+19 IF NOUT>0
Begin DoDot:2
+20 WRITE !,?2,"Edit Comments:",?1,$PIECE(TEXTOUT(1)," ",17,99)
+21 FOR IC=2:1:NOUT
WRITE !,TEXTOUT(IC)
End DoDot:2
End DoDot:1
+22 QUIT
+23 ;
+24 ;=====================================================
MAX() ;Return the maximum number of occurrences to display.
+1 NEW DIR,DIROUT,DIRUT,DTOUT,DUOUT,MAX,X,Y
+2 SET DIR(0)="N^2:99"
+3 SET DIR("A")="Maximum number of occurrences to display "
+4 ;Get the edit history count to use as a default value.
+5 SET MAX=$GET(^PXRM(800,1,"EDIT HISTORY COUNT"))
IF MAX=""
SET MAX=2
+6 SET DIR("B")=MAX
+7 DO ^DIR
+8 IF $DATA(DIROUT)!$DATA(DIRUT)
QUIT 0
+9 IF $DATA(DTOUT)!$DATA(DUOUT)
QUIT 0
+10 QUIT +Y
+11 ;
+12 ;=====================================================
REM ;Select reminder definition for displaying the history.
+1 NEW IEN,IENN,MAX,PXRMROOT
+2 SET IENN=0
+3 SET PXRMROOT="^PXD(811.9,"
+4 SET MAX=$$MAX
+5 IF MAX=0
QUIT
+6 FOR
IF IENN=-1
QUIT
Begin DoDot:1
+7 WRITE !
+8 SET IENN=$$SELECT^PXRMINQ(PXRMROOT,"Select Reminder Definition: ","")
+9 IF IENN=-1
QUIT
+10 SET IEN=$PIECE(IENN,U,1)
+11 DO DISP(IEN,MAX)
End DoDot:1
+12 QUIT
+13 ;=====================================================
RMEH ;Remove edit history. This is for items sent directly via KIDS that
+1 ;do not go through Exchange. Reminder computed findings are a good
+2 ;example.
+3 IF DUZ(0)'="@"
QUIT
+4 NEW CLASS,DIR,DIROUT,DIRUT,DTOUT,DUOUT,EH,ENTRY,IEN
+5 NEW FIELD,FILENUM,GLOBAL,NAME,X,Y
+6 WRITE !,"Remove edit history from national reminder files.",!
+7 SET DIR(0)="NAOU^0::15"
+8 SET DIR("A")="Enter the file number: "
+9 DO ^DIR
+10 IF $DATA(DIROUT)!$DATA(DIRUT)
QUIT
+11 IF (Y="")!($DATA(DTOUT))!($DATA(DUOUT))
QUIT
+12 SET FILENUM=+Y
+13 SET FIELD=$$GET1^DID(FILENUM,110,"","LABEL")
+14 IF FIELD'="EDIT HISTORY"
Begin DoDot:1
+15 WRITE !,"This is no Edit History in this file!"
End DoDot:1
QUIT
+16 SET NAME=$$GET1^DID(FILENUM,"","","NAME")
+17 WRITE !,"Looking for edit histories in file ",NAME
+18 SET GLOBAL=$$GET1^DID(FILENUM,"","","GLOBAL NAME")
+19 SET ENTRY=GLOBAL_"IEN)"
+20 SET IEN=0
+21 FOR
SET IEN=+$ORDER(@ENTRY)
IF (IEN=0)!($GET(DUOUT))
QUIT
Begin DoDot:1
+22 SET CLASS=GLOBAL_"IEN,100)"
+23 SET CLASS=$PIECE(@CLASS,U,1)
+24 IF CLASS'="N"
QUIT
+25 SET NAME=GLOBAL_"IEN,0)"
+26 SET NAME=$PIECE(@NAME,U,1)
+27 KILL DIR
+28 SET DIR(0)="YA"
+29 SET DIR("A")="Delete Edit History from entry "_NAME_"? "
+30 SET DIR("B")="N"
+31 DO ^DIR
+32 IF $DATA(DIROUT)!$DATA(DIRUT)
QUIT
+33 IF (Y="")!($DATA(DTOUT))!($DATA(DUOUT))
QUIT
+34 IF 'Y
QUIT
+35 SET EH=GLOBAL_"IEN,110)"
+36 KILL @EH
+37 SET EH=GLOBAL_"IEN,110,0)"
+38 SET @EH="^811.9001D^^0"
End DoDot:1
+39 QUIT
+40 ;