XURNPAUD ;MVI/CKN - Master Veteran Index - Remote New Person Audit; 4 Apr 2021 2:48 pm ; 4/26/21 6:10pm
;;8.0;KERNEL;**743**;Jul 10, 1995;Build 1
Q
AUDIT(RETURN,PARAM) ;Entry point for RPC - XUS REMOTE NEW PERSON AUDIT
;This RPC returns remote audit data from the AUDIT (#1.1) at facility
;for specific New Person in the NEW PERSON (#200) file.
;Required Input:
;PARAM("SourceSystemID") = Facility Station Number
;PARAM("SourceID") = Source ID (DUZ)
;Optional:
;PARAM("BegDate") = Earliest recorded date of the audit records to return
;PARAM("EndDate") = Lastest recorded date of the audit records to return
;Returns:
; @RETURN@(0) = "1^SourceSystemID^SourceID^IDTYPE^ASSIGNAUTH^AuditBegDate^AuditEndDate^TotalAuditRecordsReturned
; or "-1^errorMessage"
; @RETURN@(n) = "DateTimeRecorded^FieldName^UserName^UserDUZ^OldValue^NewValue^MenuOptionUsed^ProtocolOrOptionUsed"
N XUDUZ,XUIENARR,BEGDT,CNT,EDITDT,ENDDT,ERR,IEN
;
S RETURN=$NA(^TMP("XURNPAUD",$J,"RET")) K @RETURN
K XUIENARR S XUIENARR=$NA(^TMP("XURNPAUD",$J,"AIEN")) K @XUIENARR
S XUDUZ=$G(PARAM("SourceID")),CNT=0
I +XUDUZ'>0 S @RETURN@(0)="-1^SourceID: Not a valid DUZ" Q
I '$D(^VA(200,+XUDUZ)) S @RETURN@(0)="-1^SourceID: New Person not found at selected facility" Q
S BEGDT=$$INTDATE($G(PARAM("BegDate"))) I BEGDT=-1 S @RETURN@(0)="-1^BegDate: Beginning Date is not a valid date" Q
S ENDDT=$$INTDATE($G(PARAM("EndDate"))) I ENDDT=-1 S @RETURN@(0)="-1^EndDate: Ending Date is not a valid date" Q
;Set the first line of return
S @RETURN@(0)=1_U_PARAM("SourceSystemID")_U_PARAM("SourceID")_U_$G(PARAM("IDTYPE"))_U_$G(PARAM("ASSIGNAUTH"))_U_$G(PARAM("BegDate"))_U_$G(PARAM("EndDate"))_U
;Get the IENs of audit records for this correlation that were recorded within the date range
D GETAUD(200,+XUDUZ,BEGDT,ENDDT,.XUIENARR)
;
;Loop through audit entries and put audit values into the return global
S (CNT,EDITDT)=0 F S EDITDT=$O(@XUIENARR@(EDITDT)) Q:'EDITDT D
. S IEN=0 F S IEN=$O(@XUIENARR@(EDITDT,IEN)) Q:'IEN D
.. ;Get the data for this audit record
.. N DIC,DIA,DA,DIQ,DR,FLDNM,MENUOPT,NEWVAL,OLDVAL,PROTOPT,RECDT,USERDUZ,USERNM,VAL
.. S DIC="^DIA(200,",DIA=200,DA=IEN,DIQ="VAL",DIQ(0)="EI",DR=".02;.03;.04;1.1;2;3;4.1;4.2"
.. D EN^DIQ1
.. ;
.. I $G(VAL(1.1,IEN,.03,"I"))=11 Q ;Do not include Verify code
.. S RECDT=$TR($$FMTE^XLFDT($G(VAL(1.1,IEN,.02,"I")),"5SZ"),"@"," ") ;DATE/TIME RECORDED
.. S FLDNM=$G(VAL(1.1,IEN,1.1,"E")) ;FIELD NAME
.. S USERNM=$G(VAL(1.1,IEN,.04,"E")) ;USER
.. S USERDUZ=$G(VAL(1.1,IEN,.04,"I")) ;DUZ
.. S OLDVAL=$G(VAL(1.1,IEN,2,"E")) ;OLD VALUE
.. S NEWVAL=$G(VAL(1.1,IEN,3,"E")) ;NEW VALUE
.. S MENUOPT=$G(VAL(1.1,IEN,4.1,"E")) ;MENU OPTION
.. S PROTOPT=$G(VAL(1.1,IEN,4.2,"E")) ;PROTOCOL or OPTION USED
.. ;
.. S CNT=CNT+1
.. S @RETURN@(CNT)=RECDT_U_FLDNM_U_USERNM_U_USERDUZ_U_OLDVAL_U_NEWVAL_U_MENUOPT_U_PROTOPT
;
S @RETURN@(0)=@RETURN@(0)_CNT
K @XUIENARR
Q
;
INTDATE(X) ;Get the internal form of the Date
N %DT,Y
Q:X="" ""
S %DT="PX" D ^%DT
Q Y
;
GETAUD(FILE,XUDUZ,BEGDT,ENDDT,RET) ;Build @RET@(auditDate,auditIEN) for audit records
; that pertain to the IEN in FILE and that were recorded between BEGDT and ENDDT, inclusive.
N AIEN,EDITDT
K @RET
S:$G(BEGDT)="" BEGDT=0
S:$G(ENDDT)="" ENDDT=9999999
;
S AIEN=0 F S AIEN=$O(^DIA(FILE,"B",XUDUZ,AIEN)) Q:'AIEN D
. Q:'$D(^DIA(FILE,AIEN,0)) S EDITDT=$P(^(0),U,2)
. I EDITDT'<BEGDT,EDITDT<(ENDDT+1) S @RET@(EDITDT,AIEN)=""
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HXURNPAUD 3526 printed Nov 22, 2024@17:52:22 Page 2
XURNPAUD ;MVI/CKN - Master Veteran Index - Remote New Person Audit; 4 Apr 2021 2:48 pm ; 4/26/21 6:10pm
+1 ;;8.0;KERNEL;**743**;Jul 10, 1995;Build 1
+2 QUIT
AUDIT(RETURN,PARAM) ;Entry point for RPC - XUS REMOTE NEW PERSON AUDIT
+1 ;This RPC returns remote audit data from the AUDIT (#1.1) at facility
+2 ;for specific New Person in the NEW PERSON (#200) file.
+3 ;Required Input:
+4 ;PARAM("SourceSystemID") = Facility Station Number
+5 ;PARAM("SourceID") = Source ID (DUZ)
+6 ;Optional:
+7 ;PARAM("BegDate") = Earliest recorded date of the audit records to return
+8 ;PARAM("EndDate") = Lastest recorded date of the audit records to return
+9 ;Returns:
+10 ; @RETURN@(0) = "1^SourceSystemID^SourceID^IDTYPE^ASSIGNAUTH^AuditBegDate^AuditEndDate^TotalAuditRecordsReturned
+11 ; or "-1^errorMessage"
+12 ; @RETURN@(n) = "DateTimeRecorded^FieldName^UserName^UserDUZ^OldValue^NewValue^MenuOptionUsed^ProtocolOrOptionUsed"
+13 NEW XUDUZ,XUIENARR,BEGDT,CNT,EDITDT,ENDDT,ERR,IEN
+14 ;
+15 SET RETURN=$NAME(^TMP("XURNPAUD",$JOB,"RET"))
KILL @RETURN
+16 KILL XUIENARR
SET XUIENARR=$NAME(^TMP("XURNPAUD",$JOB,"AIEN"))
KILL @XUIENARR
+17 SET XUDUZ=$GET(PARAM("SourceID"))
SET CNT=0
+18 IF +XUDUZ'>0
SET @RETURN@(0)="-1^SourceID: Not a valid DUZ"
QUIT
+19 IF '$DATA(^VA(200,+XUDUZ))
SET @RETURN@(0)="-1^SourceID: New Person not found at selected facility"
QUIT
+20 SET BEGDT=$$INTDATE($GET(PARAM("BegDate")))
IF BEGDT=-1
SET @RETURN@(0)="-1^BegDate: Beginning Date is not a valid date"
QUIT
+21 SET ENDDT=$$INTDATE($GET(PARAM("EndDate")))
IF ENDDT=-1
SET @RETURN@(0)="-1^EndDate: Ending Date is not a valid date"
QUIT
+22 ;Set the first line of return
+23 SET @RETURN@(0)=1_U_PARAM("SourceSystemID")_U_PARAM("SourceID")_U_$GET(PARAM("IDTYPE"))_U_$GET(PARAM("ASSIGNAUTH"))_U_$GET(PARAM("BegDate"))_U_$GET(PARAM("EndDate"))_U
+24 ;Get the IENs of audit records for this correlation that were recorded within the date range
+25 DO GETAUD(200,+XUDUZ,BEGDT,ENDDT,.XUIENARR)
+26 ;
+27 ;Loop through audit entries and put audit values into the return global
+28 SET (CNT,EDITDT)=0
FOR
SET EDITDT=$ORDER(@XUIENARR@(EDITDT))
if 'EDITDT
QUIT
Begin DoDot:1
+29 SET IEN=0
FOR
SET IEN=$ORDER(@XUIENARR@(EDITDT,IEN))
if 'IEN
QUIT
Begin DoDot:2
+30 ;Get the data for this audit record
+31 NEW DIC,DIA,DA,DIQ,DR,FLDNM,MENUOPT,NEWVAL,OLDVAL,PROTOPT,RECDT,USERDUZ,USERNM,VAL
+32 SET DIC="^DIA(200,"
SET DIA=200
SET DA=IEN
SET DIQ="VAL"
SET DIQ(0)="EI"
SET DR=".02;.03;.04;1.1;2;3;4.1;4.2"
+33 DO EN^DIQ1
+34 ;
+35 ;Do not include Verify code
IF $GET(VAL(1.1,IEN,.03,"I"))=11
QUIT
+36 ;DATE/TIME RECORDED
SET RECDT=$TRANSLATE($$FMTE^XLFDT($GET(VAL(1.1,IEN,.02,"I")),"5SZ"),"@"," ")
+37 ;FIELD NAME
SET FLDNM=$GET(VAL(1.1,IEN,1.1,"E"))
+38 ;USER
SET USERNM=$GET(VAL(1.1,IEN,.04,"E"))
+39 ;DUZ
SET USERDUZ=$GET(VAL(1.1,IEN,.04,"I"))
+40 ;OLD VALUE
SET OLDVAL=$GET(VAL(1.1,IEN,2,"E"))
+41 ;NEW VALUE
SET NEWVAL=$GET(VAL(1.1,IEN,3,"E"))
+42 ;MENU OPTION
SET MENUOPT=$GET(VAL(1.1,IEN,4.1,"E"))
+43 ;PROTOCOL or OPTION USED
SET PROTOPT=$GET(VAL(1.1,IEN,4.2,"E"))
+44 ;
+45 SET CNT=CNT+1
+46 SET @RETURN@(CNT)=RECDT_U_FLDNM_U_USERNM_U_USERDUZ_U_OLDVAL_U_NEWVAL_U_MENUOPT_U_PROTOPT
End DoDot:2
End DoDot:1
+47 ;
+48 SET @RETURN@(0)=@RETURN@(0)_CNT
+49 KILL @XUIENARR
+50 QUIT
+51 ;
INTDATE(X) ;Get the internal form of the Date
+1 NEW %DT,Y
+2 if X=""
QUIT ""
+3 SET %DT="PX"
DO ^%DT
+4 QUIT Y
+5 ;
GETAUD(FILE,XUDUZ,BEGDT,ENDDT,RET) ;Build @RET@(auditDate,auditIEN) for audit records
+1 ; that pertain to the IEN in FILE and that were recorded between BEGDT and ENDDT, inclusive.
+2 NEW AIEN,EDITDT
+3 KILL @RET
+4 if $GET(BEGDT)=""
SET BEGDT=0
+5 if $GET(ENDDT)=""
SET ENDDT=9999999
+6 ;
+7 SET AIEN=0
FOR
SET AIEN=$ORDER(^DIA(FILE,"B",XUDUZ,AIEN))
if 'AIEN
QUIT
Begin DoDot:1
+8 if '$DATA(^DIA(FILE,AIEN,0))
QUIT
SET EDITDT=$PIECE(^(0),U,2)
+9 IF EDITDT'<BEGDT
IF EDITDT<(ENDDT+1)
SET @RET@(EDITDT,AIEN)=""
End DoDot:1
+10 QUIT