Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: TIUAUD0

TIUAUD0.m

Go to the documentation of this file.
  1. TIUAUD0 ; SPFO/AJB - AUDIT SIGNED DOCUMENTS ;07/20/22 06:40
  1. ;;1.0;TEXT INTEGRATION UTILITIES;**343**;Jun 20, 1997;Build 17
  1. ;
  1. ; External reference to File ^DIA(8925 supported by IA 2602
  1. Q
  1. AUDIT(DA) ; audit signed documents
  1. Q:'+$G(TIUFPRIV) 0 ; do not audit if FILE SCREEN doesn't set TIUFPRIV
  1. Q:+$G(TIUDA) 0 ; do not audit if TIU is editing
  1. Q:$$BROKER^XWBLIB 0 ; do not audit if broker is active (CPRS)
  1. N AUDIT,FIELD
  1. ; see section: 21.18 Audit Condition in the FileMan Development Guide for detailed information
  1. ; DIIX is not present when editing WP fields (persists if editing another field and WP field consecutively)
  1. ; new WP field data is not stored/audited - saved in package global only
  1. ; DI*2.22*21 fixes audit condition not executing for WP fields but introduces hard crash post-edit
  1. ; DI*2.22*22 fixes hard crash but does not follow information in FM Dev Guide (DIIX not set, uses FLD)
  1. S FIELD=$S(+$G(FLD):FLD,+$P($G(DIIX),U,2):$P($G(DIIX),U,2),1:0) ; WP field sets FLD, DIIX set for everything else
  1. Q:'+FIELD 0 ; exit if field is not established
  1. S AUDIT=$$SIGNED(DA,FIELD,X) ; evaluate if document has ever been signed
  1. I +AUDIT!+$D(DIANUM) D
  1. . I +$D(DIANUM) S AUDIT=1 ; always audit new value if old value was audited (existence of DIANUM)
  1. . N IEN S IEN=$P($G(DIANUM(FIELD)),",",2) ; ^DIA IEN
  1. . S IEN=$S(+IEN:IEN,1:($O(^DIA(8925,"B"),-1)+1)) ; increment IEN from last ^DIA entry if needed
  1. . D GAD(IEN,FIELD,$G(DIIX)) ; get audit data for TIU
  1. Q AUDIT
  1. SIGNED(TIUDA,FIELD,VALUE) ; has the document ever been signed?
  1. I $G(FIELD)=.05,$G(VALUE)>5 Q 1 ; check current status of edit
  1. I $G(FIELD)'=.05,$P($G(^TIU(8925,TIUDA,0)),U,5)>5 Q 1 ; check document's status during edit
  1. N AUDIT,NODE,PIECE S NODE(15)=$G(^TIU(8925,TIUDA,15)),NODE(16)=$G(^TIU(8925,TIUDA,16))
  1. F PIECE=1,2,3,4,7,8,9,10,12,13 I $P(NODE(15),U,PIECE)'="" S AUDIT=1 Q ; check fields related to signature, if any have a value then entry should be audited
  1. Q:+$G(AUDIT) 1
  1. F PIECE=3,4,5,10,11 I $P(NODE(16),U,PIECE)'="" S AUDIT=1 Q ; check fields related to co-signature, if any have a value then entry should be audited
  1. Q $S(+$G(AUDIT):1,1:0)
  1. GAD(DA,FIELD,DIIX,DIANUM) ; get audit data for TIU
  1. ; FM saves audit data AFTER audit condition
  1. ; task will make a copy to the TIU namespace to avoid a data purge via the FM audit tools if audited, once per KILL/SET
  1. N ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK S ZTDESC="TIU Audit Capture",ZTDTH=+$H_","_($P($H,",",2)+1),ZTIO=""
  1. S ZTSAVE("DA")="",ZTSAVE("DIIX")="",ZTSAVE("FIELD")="",ZTRTN="TASK^TIUAUD0(DA,FIELD,DIIX)" D ^%ZTLOAD
  1. Q
  1. TASK(DA,FIELD,DIIX) ; copy audit data to ^TIU(8925,"AUD") namespace, non-published location
  1. N IEN S ZTREQ="@" ; remove task (successful completion)
  1. I '+DIIX!(+DIIX=2) S IEN=$S('$D(^TIU(8925,"AUD",DA)):DA,1:+$O(^TIU(8925,"AUD",""),-1)+1) ; for old value/WP, use DIA IEN if possible
  1. I +DIIX=3 S IEN=$S('$D(^DIA(8925,DA,2)):+$O(^TIU(8925,"AUD",""),-1)+1,1:+$O(^TIU(8925,"AUD",""),-1)) ; for new value, increment TIU IEN if old value wasn't audited
  1. S ^TIU(8925,"AUD",0)="TIU DOCUMENT AUDIT^1.1I^"_IEN_U_IEN ; i don't care about IEN accuracy here
  1. M ^TIU(8925,"AUD",IEN)=^DIA(8925,DA)
  1. I FIELD=2 D ; get the current REPORT TEXT
  1. . N TIUDA S TIUDA=+$G(^DIA(8925,DA,0))
  1. . M ^TIU(8925,"AUD",IEN,3.14)=^TIU(8925,TIUDA,"TEXT")
  1. Q