PXRMCLEH ;SLC/PKR - Utilities for managing Change Logs/Edit Histories. ;02/28/2024
;;2.0;CLINICAL REMINDERS;**88**;Feb 04, 2005;Build 13
;
;===============
CHANGELOG(CLOGSFN,IEN,CLOGTEXT) ;Add a CHANGE LOG/EDIT HISTORY entry.
N FDA,IENS,MSG
I IEN'>0 Q
S IENS="+1,"_IEN_","
S FDA(CLOGSFN,IENS,.01)=$$NOW^XLFDT
S FDA(CLOGSFN,IENS,1)=DUZ
S FDA(CLOGSFN,IENS,2)="CLOGTEXT"
D UPDATE^DIE("","FDA","","MSG")
I $D(MSG) D
. D BMES^XPDUTL("CHANGELOG^PXRMCLEH, Change Log/Edit History write failed.")
. D AWRITE^PXRMUTIL("MSG")
. D MES^XPDUTL("")
. D AWRITE^PXRMUTIL("FDA")
Q
;
;===============
GETCLOGSFN(FILENUM) ;Determine if this file has a CHANGE LOG or EDIT HISTORY field.
;If it does, return the subfile number.
N FIELDNUM,SPECIFIER,TARGET
S FIELDNUM=$$FLDNUM^DILFD(FILENUM,"CHANGE LOG")
I FIELDNUM=0 S FIELDNUM=$$FLDNUM^DILFD(FILENUM,"EDIT HISTORY")
I FIELDNUM=0 Q 0
D FIELD^DID(FILENUM,FIELDNUM,"","SPECIFIER","TARGET")
Q +$G(TARGET("SPECIFIER"))
;
;===============
LASTINSTALL(PXRMRIEN,FILENUM,IEN) ;
N CHANGELOG,CLTEXT,FIELDNUM,GLOBAL,LAST,TEMP,TESTTEXT
S FIELDNUM=$$FLDNUM^DILFD(FILENUM,"CHANGE LOG")
I FIELDNUM=0 S FIELDNUM=$$FLDNUM^DILFD(FILENUM,"EDIT HISTORY")
I FIELDNUM=0 Q 0
S GLOBAL=$$GET1^DID(FILENUM,"","","GLOBAL NAME")
S CHANGELOG=GLOBAL_IEN_","_FIELDNUM_")"
S LAST=+$O(@CHANGELOG@("A"),-1)
I LAST=0 Q 0
S CLTEXT(1)=$G(@CHANGELOG@(LAST,1,1,0))
;If there are no Comments quit.
I CLTEXT(1)="" Q 0
S TESTTEXT(1)="Exchange Install"
I CLTEXT(1)'=TESTTEXT(1) Q 0
S TEMP=$G(^PXD(811.8,PXRMRIEN,0))
S CLTEXT(2)=$g(@CHANGELOG@(LAST,1,2,0))
I CLTEXT(2)="" Q 0
S TESTTEXT(2)="Reminder Exchange entry: "_$P(TEMP,U,1)
S CLTEXT(3)=$G(@CHANGELOG@(LAST,1,3,0))
I CLTEXT(3)="" Q 0
S TESTTEXT(3)="Date Packed: "_$$EDATE^PXRMDATE($P(TEMP,U,3))
I (CLTEXT(2)'=TESTTEXT(2))!(CLTEXT(3)'=TESTTEXT(3)) D Q 0
. W !,"The last update was:"
. W !,CLTEXT(2)
. W !,CLTEXT(3)
. W !,"This is update:"
. W !,TESTTEXT(2)
. W !,TESTTEXT(3)
Q 1
;
;===============
RMEHIST(FILENUM,IEN) ;Remove the edit history for a reminder file.
N FIELDNUM
S FIELDNUM=$$FLDNUM^DILFD(FILENUM,"CHANGE LOG")
I FIELDNUM=0 S FIELDNUM=$$FLDNUM^DILFD(FILENUM,"EDIT HISTORY")
I FIELDNUM=0 Q
N DA,DIK,GLOBAL,ROOT
S GLOBAL=$$GET1^DID(FILENUM,"","","GLOBAL NAME")
;Edit History is stored in node 110 for all files.
S DA(1)=IEN
S DIK=GLOBAL_IEN_","_FIELDNUM_","
S ROOT=GLOBAL_IEN_","_FIELDNUM_",DA)"
S DA=0
F S DA=+$O(@ROOT) Q:DA=0 D ^DIK
Q
;
;===============
SEHIST(FILENUM,ROOT,IEN) ;Set the edit date and edit by and prompt the
;user for the edit comment.
N DIC,DIR,DWLW,DWPK,ENTRY,FDA,FDAIEN,IENS,IND,MSG,SFN,TARGET,X,Y
K ^TMP("PXRMWP",$J)
S SFN=$$GETCLOGSFN(FILENUM)
I SFN=0 Q
S ENTRY=ROOT_IEN_",110)"
S IND=$O(@ENTRY@("B"),-1)
S IND=IND+1
S IENS="+"_IND_","_IEN_","
S FDAIEN(IEN)=IEN
S FDA(SFN,IENS,.01)=$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
S FDA(SFN,IENS,1)="`"_DUZ
;Prompt the user for edit comments.
S DIC="^TMP(""PXRMWP"",$J,"
S DWLW=72
S DWPK=1
W !,"Input your edit comments."
S DIR(0)="Y"_U_"AO"
S DIR("A")="Edit"
S DIR("B")="NO"
D ^DIR
I Y D
. D EN^DIWE
. K ^TMP("PXRMWP",$J,0)
. I $D(^TMP("PXRMWP",$J)) S FDA(SFN,IENS,2)="^TMP(""PXRMWP"",$J)"
D UPDATE^DIE("E","FDA","FDAIEN","MSG")
I $D(MSG) D
. D BMES^XPDUTL("SEHIST^PXRMCLEH error setting Change Log.")
. D AWRITE^PXRMUTIL("MSG") W ! D AWRITE^PXRMUTIL("FDA")
K ^TMP("PXRMWP",$J)
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPXRMCLEH 3507 printed Dec 13, 2024@01:43:13 Page 2
PXRMCLEH ;SLC/PKR - Utilities for managing Change Logs/Edit Histories. ;02/28/2024
+1 ;;2.0;CLINICAL REMINDERS;**88**;Feb 04, 2005;Build 13
+2 ;
+3 ;===============
CHANGELOG(CLOGSFN,IEN,CLOGTEXT) ;Add a CHANGE LOG/EDIT HISTORY entry.
+1 NEW FDA,IENS,MSG
+2 IF IEN'>0
QUIT
+3 SET IENS="+1,"_IEN_","
+4 SET FDA(CLOGSFN,IENS,.01)=$$NOW^XLFDT
+5 SET FDA(CLOGSFN,IENS,1)=DUZ
+6 SET FDA(CLOGSFN,IENS,2)="CLOGTEXT"
+7 DO UPDATE^DIE("","FDA","","MSG")
+8 IF $DATA(MSG)
Begin DoDot:1
+9 DO BMES^XPDUTL("CHANGELOG^PXRMCLEH, Change Log/Edit History write failed.")
+10 DO AWRITE^PXRMUTIL("MSG")
+11 DO MES^XPDUTL("")
+12 DO AWRITE^PXRMUTIL("FDA")
End DoDot:1
+13 QUIT
+14 ;
+15 ;===============
GETCLOGSFN(FILENUM) ;Determine if this file has a CHANGE LOG or EDIT HISTORY field.
+1 ;If it does, return the subfile number.
+2 NEW FIELDNUM,SPECIFIER,TARGET
+3 SET FIELDNUM=$$FLDNUM^DILFD(FILENUM,"CHANGE LOG")
+4 IF FIELDNUM=0
SET FIELDNUM=$$FLDNUM^DILFD(FILENUM,"EDIT HISTORY")
+5 IF FIELDNUM=0
QUIT 0
+6 DO FIELD^DID(FILENUM,FIELDNUM,"","SPECIFIER","TARGET")
+7 QUIT +$GET(TARGET("SPECIFIER"))
+8 ;
+9 ;===============
LASTINSTALL(PXRMRIEN,FILENUM,IEN) ;
+1 NEW CHANGELOG,CLTEXT,FIELDNUM,GLOBAL,LAST,TEMP,TESTTEXT
+2 SET FIELDNUM=$$FLDNUM^DILFD(FILENUM,"CHANGE LOG")
+3 IF FIELDNUM=0
SET FIELDNUM=$$FLDNUM^DILFD(FILENUM,"EDIT HISTORY")
+4 IF FIELDNUM=0
QUIT 0
+5 SET GLOBAL=$$GET1^DID(FILENUM,"","","GLOBAL NAME")
+6 SET CHANGELOG=GLOBAL_IEN_","_FIELDNUM_")"
+7 SET LAST=+$ORDER(@CHANGELOG@("A"),-1)
+8 IF LAST=0
QUIT 0
+9 SET CLTEXT(1)=$GET(@CHANGELOG@(LAST,1,1,0))
+10 ;If there are no Comments quit.
+11 IF CLTEXT(1)=""
QUIT 0
+12 SET TESTTEXT(1)="Exchange Install"
+13 IF CLTEXT(1)'=TESTTEXT(1)
QUIT 0
+14 SET TEMP=$GET(^PXD(811.8,PXRMRIEN,0))
+15
*** ERROR ***
SET CLTEXT(2)=$g(@CHANGELOG@(LAST,1,2,0))
+16 IF CLTEXT(2)=""
QUIT 0
+17 SET TESTTEXT(2)="Reminder Exchange entry: "_$PIECE(TEMP,U,1)
+18 SET CLTEXT(3)=$GET(@CHANGELOG@(LAST,1,3,0))
+19 IF CLTEXT(3)=""
QUIT 0
+20 SET TESTTEXT(3)="Date Packed: "_$$EDATE^PXRMDATE($PIECE(TEMP,U,3))
+21 IF (CLTEXT(2)'=TESTTEXT(2))!(CLTEXT(3)'=TESTTEXT(3))
Begin DoDot:1
+22 WRITE !,"The last update was:"
+23 WRITE !,CLTEXT(2)
+24 WRITE !,CLTEXT(3)
+25 WRITE !,"This is update:"
+26 WRITE !,TESTTEXT(2)
+27 WRITE !,TESTTEXT(3)
End DoDot:1
QUIT 0
+28 QUIT 1
+29 ;
+30 ;===============
RMEHIST(FILENUM,IEN) ;Remove the edit history for a reminder file.
+1 NEW FIELDNUM
+2 SET FIELDNUM=$$FLDNUM^DILFD(FILENUM,"CHANGE LOG")
+3 IF FIELDNUM=0
SET FIELDNUM=$$FLDNUM^DILFD(FILENUM,"EDIT HISTORY")
+4 IF FIELDNUM=0
QUIT
+5 NEW DA,DIK,GLOBAL,ROOT
+6 SET GLOBAL=$$GET1^DID(FILENUM,"","","GLOBAL NAME")
+7 ;Edit History is stored in node 110 for all files.
+8 SET DA(1)=IEN
+9 SET DIK=GLOBAL_IEN_","_FIELDNUM_","
+10 SET ROOT=GLOBAL_IEN_","_FIELDNUM_",DA)"
+11 SET DA=0
+12 FOR
SET DA=+$ORDER(@ROOT)
if DA=0
QUIT
DO ^DIK
+13 QUIT
+14 ;
+15 ;===============
SEHIST(FILENUM,ROOT,IEN) ;Set the edit date and edit by and prompt the
+1 ;user for the edit comment.
+2 NEW DIC,DIR,DWLW,DWPK,ENTRY,FDA,FDAIEN,IENS,IND,MSG,SFN,TARGET,X,Y
+3 KILL ^TMP("PXRMWP",$JOB)
+4 SET SFN=$$GETCLOGSFN(FILENUM)
+5 IF SFN=0
QUIT
+6 SET ENTRY=ROOT_IEN_",110)"
+7 SET IND=$ORDER(@ENTRY@("B"),-1)
+8 SET IND=IND+1
+9 SET IENS="+"_IND_","_IEN_","
+10 SET FDAIEN(IEN)=IEN
+11 SET FDA(SFN,IENS,.01)=$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
+12 SET FDA(SFN,IENS,1)="`"_DUZ
+13 ;Prompt the user for edit comments.
+14 SET DIC="^TMP(""PXRMWP"",$J,"
+15 SET DWLW=72
+16 SET DWPK=1
+17 WRITE !,"Input your edit comments."
+18 SET DIR(0)="Y"_U_"AO"
+19 SET DIR("A")="Edit"
+20 SET DIR("B")="NO"
+21 DO ^DIR
+22 IF Y
Begin DoDot:1
+23 DO EN^DIWE
+24 KILL ^TMP("PXRMWP",$JOB,0)
+25 IF $DATA(^TMP("PXRMWP",$JOB))
SET FDA(SFN,IENS,2)="^TMP(""PXRMWP"",$J)"
End DoDot:1
+26 DO UPDATE^DIE("E","FDA","FDAIEN","MSG")
+27 IF $DATA(MSG)
Begin DoDot:1
+28 DO BMES^XPDUTL("SEHIST^PXRMCLEH error setting Change Log.")
+29 DO AWRITE^PXRMUTIL("MSG")
WRITE !
DO AWRITE^PXRMUTIL("FDA")
End DoDot:1
+30 KILL ^TMP("PXRMWP",$JOB)
+31 QUIT
+32 ;