DGENUPA ;ALB/CJM - API FOR UPLOAD AUDIT ; 04-APR-94
;;5.3;REGISTRATION;**147**;08/13/93
;
STORE(AUDIT,ERROR) ;
;Description: Creates a new entry in the ENROLLMENT/ELIGIBILITY UPLOAD
;AUDIT file (#27.14).
;
;INPUT:
; AUDIT: an array containing the record to be stored. (pass by reference)
;Output:
; Function Value: the ien of the entry created, or 0 on failure
; ERROR: on failure, will return an error message (optional) (pass by reference)
;
N DATA,ADD
S ADD=$$CHECK(.AUDIT,.ERROR)
I 'ADD G STEXIT
S DATA(.01)=AUDIT("MSGID")
S DATA(.02)=AUDIT("DATETIME")
S DATA(.03)=AUDIT("DFN")
S DATA(1)="AUDIT(""CHANGES"")"
S ADD=$$ADD^DGENDBS(27.14,,.DATA,.ERROR)
;
STEXIT ;
Q +ADD
;
CREATE(DFN,WHEN,MSGID,AUDIT) ;
;Description: Creates an array containing the AUDIT object. There are
;no changes initially in the AUDIT object.
;
;Input:
; DFN - ien of record in the PATIENT file
; WHEN - date & time when the upload occurred (uses current date/time if not provided)
K AUDIT
S AUDIT("DFN")=$G(DFN)
I '$G(WHEN) S WHEN=$$NOW^XLFDT
S AUDIT("DATETIME")=$G(WHEN)
S AUDIT("MSGID")=$G(MSGID)
D ADDCHNG(.AUDIT,">>No Change <<")
S AUDIT("CHANGES")=0
Q
;
CHECK(AUDIT,ERROR) ;
;Description: checks the validity of the AUDIT object
;
;Input:
; AUDIT - an array containing the AUDIT object (pass by reference)
;
;Output:
; Function Value - 1 if valid, 0 otherwise
; ERROR - if not valid, returns an error message (optional) (pass by reference)
;
N OK
S OK=1
I '$G(AUDIT("DFN")) S OK=0,ERROR="NO PATIENT"
I OK,'$D(^DPT(AUDIT("DFN"))) S OK=0,ERROR="PATIENT NOT FOUND"
I OK,'$D(AUDIT("DATETIME")) S OK=0,ERROR="DATE/TIME OF UPLOAD NOT SPECIFIED"
I OK,'$D(AUDIT("MSGID")) S OK=0,ERROR="MESSAGE ID NOT SPECIFIED"
Q OK
;
ADDCHNG(AUDIT,LINE) ;
;Description: Adds one line to the record of changes from an upload.
;
;Input:
; AUDIT - an array containing the AUDIT object. (pass by reference)
; LINE - the line to be added
;
;Output:
; AUDIT - the updated array containing the AUDIT object (pass by reference)
;
S AUDIT("CHANGES")=1+$G(AUDIT("CHANGES"))
S AUDIT("CHANGES",AUDIT("CHANGES"))=$G(LINE)
Q
AUDITID(IEN) ;
W "DT/TM UPLOADED: "_$P(^DGENA(27.14,IEN,0),"^",2)
W " MSG ID: "_$P(^DGENA(27.14,IEN,0),"^",2)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDGENUPA 2338 printed Oct 16, 2024@18:43:52 Page 2
DGENUPA ;ALB/CJM - API FOR UPLOAD AUDIT ; 04-APR-94
+1 ;;5.3;REGISTRATION;**147**;08/13/93
+2 ;
STORE(AUDIT,ERROR) ;
+1 ;Description: Creates a new entry in the ENROLLMENT/ELIGIBILITY UPLOAD
+2 ;AUDIT file (#27.14).
+3 ;
+4 ;INPUT:
+5 ; AUDIT: an array containing the record to be stored. (pass by reference)
+6 ;Output:
+7 ; Function Value: the ien of the entry created, or 0 on failure
+8 ; ERROR: on failure, will return an error message (optional) (pass by reference)
+9 ;
+10 NEW DATA,ADD
+11 SET ADD=$$CHECK(.AUDIT,.ERROR)
+12 IF 'ADD
GOTO STEXIT
+13 SET DATA(.01)=AUDIT("MSGID")
+14 SET DATA(.02)=AUDIT("DATETIME")
+15 SET DATA(.03)=AUDIT("DFN")
+16 SET DATA(1)="AUDIT(""CHANGES"")"
+17 SET ADD=$$ADD^DGENDBS(27.14,,.DATA,.ERROR)
+18 ;
STEXIT ;
+1 QUIT +ADD
+2 ;
CREATE(DFN,WHEN,MSGID,AUDIT) ;
+1 ;Description: Creates an array containing the AUDIT object. There are
+2 ;no changes initially in the AUDIT object.
+3 ;
+4 ;Input:
+5 ; DFN - ien of record in the PATIENT file
+6 ; WHEN - date & time when the upload occurred (uses current date/time if not provided)
+7 KILL AUDIT
+8 SET AUDIT("DFN")=$GET(DFN)
+9 IF '$GET(WHEN)
SET WHEN=$$NOW^XLFDT
+10 SET AUDIT("DATETIME")=$GET(WHEN)
+11 SET AUDIT("MSGID")=$GET(MSGID)
+12 DO ADDCHNG(.AUDIT,">>No Change <<")
+13 SET AUDIT("CHANGES")=0
+14 QUIT
+15 ;
CHECK(AUDIT,ERROR) ;
+1 ;Description: checks the validity of the AUDIT object
+2 ;
+3 ;Input:
+4 ; AUDIT - an array containing the AUDIT object (pass by reference)
+5 ;
+6 ;Output:
+7 ; Function Value - 1 if valid, 0 otherwise
+8 ; ERROR - if not valid, returns an error message (optional) (pass by reference)
+9 ;
+10 NEW OK
+11 SET OK=1
+12 IF '$GET(AUDIT("DFN"))
SET OK=0
SET ERROR="NO PATIENT"
+13 IF OK
IF '$DATA(^DPT(AUDIT("DFN")))
SET OK=0
SET ERROR="PATIENT NOT FOUND"
+14 IF OK
IF '$DATA(AUDIT("DATETIME"))
SET OK=0
SET ERROR="DATE/TIME OF UPLOAD NOT SPECIFIED"
+15 IF OK
IF '$DATA(AUDIT("MSGID"))
SET OK=0
SET ERROR="MESSAGE ID NOT SPECIFIED"
+16 QUIT OK
+17 ;
ADDCHNG(AUDIT,LINE) ;
+1 ;Description: Adds one line to the record of changes from an upload.
+2 ;
+3 ;Input:
+4 ; AUDIT - an array containing the AUDIT object. (pass by reference)
+5 ; LINE - the line to be added
+6 ;
+7 ;Output:
+8 ; AUDIT - the updated array containing the AUDIT object (pass by reference)
+9 ;
+10 SET AUDIT("CHANGES")=1+$GET(AUDIT("CHANGES"))
+11 SET AUDIT("CHANGES",AUDIT("CHANGES"))=$GET(LINE)
+12 QUIT
AUDITID(IEN) ;
+1 WRITE "DT/TM UPLOADED: "_$PIECE(^DGENA(27.14,IEN,0),"^",2)
+2 WRITE " MSG ID: "_$PIECE(^DGENA(27.14,IEN,0),"^",2)
+3 QUIT