SDESGETREGA2 ;ALB/ANU - SDES GET PATREG BY DFNICN ;JULY 15,2023
;;5.3;Scheduling;**853**;Aug 13, 1993;Build 9
;;Per VHA Directive 6402, this routine should not be modified
;
; Documented API's and Integration Agreements
; -------------------------------------------
; Reference to PATIENT in ICR #7030
; Reference to PATIENT in ICR #7029
; Reference to PATIENT in ICR #1476
; Reference to PATIENT in ICR #10035
; Reference to SCHEDULED ADMISSION in ICR #4425
;
; Cloned from SDESGETREGA for new version
;
; The SDCONTEXT array is controlled by the Acheron application and its fields are
; needed for the storage of the required auditing information.
;
; SDCONTEXT("ACHERON ID")
; SDCONTEXT("USER DUZ")
; SDCONTEXT("USER NAME")
Q
;
;
; RPC: SDES GET PATREG BY DFNICN
;
GETREGA(JSONRETURN,DFNS,ICNS,SDEAS) ; Get Patient(s) Registration Data
;
N SDERRORS,SDFDA,SDCOUNT,SDRETURN
S SDCOUNT=1
; Validate EAS
D VALEAS($G(SDEAS),.SDERRORS)
I $D(SDERRORS) M SDRETURN=SDERRORS D BUILDJSON(.JSONRETURN,.SDRETURN) Q
; Validate DFNs and ICNs
I '$G(DFNS(1)),'$G(ICNS(1)) D ERRLOG^SDESJSON(.SDERRORS,486)
I $D(SDERRORS) M SDRETURN=SDERRORS D BUILDJSON(.JSONRETURN,.SDRETURN) Q
;
D PROCDFNS(.DFNS,.SDRETURN,.SDCOUNT) ; Process DFNs
D PROCICNS(.ICNS,.SDRETURN,.SDCOUNT) ; Process ICNs
;
D BUILDJSON(.JSONRETURN,.SDRETURN)
Q
;
PROCDFNS(DFNS,SDRETURN,SDCOUNT) ; Validate and Process DFNs
;
N SDCOUNT1,DFN
S SDCOUNT1=0
F S SDCOUNT1=$O(DFNS(SDCOUNT1)) Q:'SDCOUNT1 D
.N SDINFO
.I SDCOUNT>50 D ERRLOG^SDESJSON(.SDERRORS,489) Q
.S DFN=DFNS(SDCOUNT1)
.D VALDFN($G(DFN),.SDERRORS) ;Validate DFN
.I $D(SDERRORS) M SDRETURN=SDERRORS Q
.D GETREG(DFN,.SDINFO)
.M SDRETURN("Patient",SDCOUNT)=SDINFO("Patient")
.S SDCOUNT=SDCOUNT+1
Q
;
PROCICNS(ICNS,SDRETURN,SDCOUNT) ; Validate and Process ICNs
N SDDFN,ICN
S SDCOUNT1=0
F S SDCOUNT1=$O(ICNS(SDCOUNT1)) Q:'SDCOUNT1 D
.N SDINFO
.I SDCOUNT>50 D ERRLOG^SDESJSON(.SDERRORS,489) Q
.S ICN=ICNS(SDCOUNT1)
.D VALICN($G(ICN),.SDERRORS) ;Validate ICN
.I $D(SDERRORS) M SDRETURN=SDERRORS Q
.D GETREG(SDDFN,.SDINFO)
.M SDRETURN("Patient",SDCOUNT)=SDINFO("Patient")
.S SDCOUNT=SDCOUNT+1
Q
;
VALDFN(DFN,ERRORS) ; Validate DFNS
I +DFN=0 D ERRLOG^SDESJSON(.ERRORS,1) Q
I '$D(^DPT(DFN,0)) D ERRLOG^SDESJSON(.ERRORS,2," DFN not found:"_$G(DFN))
Q
;
VALICN(ICN,ERRORS) ; Validate ICNS
;Convert ICN to DFN
S SDDFN=$$GETDFN^MPIF001(ICN)
S SDDFN=$S(+SDDFN>0:SDDFN,1:"")
I +ICN=0 D ERRLOG^SDESJSON(.ERRORS,2," ICN not found:"_$G(ICN))
Q
;
VALEAS(EAS,ERRORS) ; Validate EAS
I $L(EAS) S EAS=$$EASVALIDATE^SDESUTIL($G(EAS))
I $P($G(EAS),U)=-1 D ERRLOG^SDESJSON(.ERRORS,142)
Q
;
GETREG(DFN,SDINFO) ;
;
D GETREG^SDESGETREGA1
Q
;
BUILDJSON(JSONRETURN,SDRETURN) ;Convert data to JSON
I '$D(SDRETURN("Patient")) S SDRETURN("Patient",1)=""
D BUILDJSON^SDESBUILDJSON(.JSONRETURN,.SDRETURN) Q
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESGETREGA2 2968 printed Dec 13, 2024@02:57:05 Page 2
SDESGETREGA2 ;ALB/ANU - SDES GET PATREG BY DFNICN ;JULY 15,2023
+1 ;;5.3;Scheduling;**853**;Aug 13, 1993;Build 9
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 ; Documented API's and Integration Agreements
+5 ; -------------------------------------------
+6 ; Reference to PATIENT in ICR #7030
+7 ; Reference to PATIENT in ICR #7029
+8 ; Reference to PATIENT in ICR #1476
+9 ; Reference to PATIENT in ICR #10035
+10 ; Reference to SCHEDULED ADMISSION in ICR #4425
+11 ;
+12 ; Cloned from SDESGETREGA for new version
+13 ;
+14 ; The SDCONTEXT array is controlled by the Acheron application and its fields are
+15 ; needed for the storage of the required auditing information.
+16 ;
+17 ; SDCONTEXT("ACHERON ID")
+18 ; SDCONTEXT("USER DUZ")
+19 ; SDCONTEXT("USER NAME")
+20 QUIT
+21 ;
+22 ;
+23 ; RPC: SDES GET PATREG BY DFNICN
+24 ;
GETREGA(JSONRETURN,DFNS,ICNS,SDEAS) ; Get Patient(s) Registration Data
+1 ;
+2 NEW SDERRORS,SDFDA,SDCOUNT,SDRETURN
+3 SET SDCOUNT=1
+4 ; Validate EAS
+5 DO VALEAS($GET(SDEAS),.SDERRORS)
+6 IF $DATA(SDERRORS)
MERGE SDRETURN=SDERRORS
DO BUILDJSON(.JSONRETURN,.SDRETURN)
QUIT
+7 ; Validate DFNs and ICNs
+8 IF '$GET(DFNS(1))
IF '$GET(ICNS(1))
DO ERRLOG^SDESJSON(.SDERRORS,486)
+9 IF $DATA(SDERRORS)
MERGE SDRETURN=SDERRORS
DO BUILDJSON(.JSONRETURN,.SDRETURN)
QUIT
+10 ;
+11 ; Process DFNs
DO PROCDFNS(.DFNS,.SDRETURN,.SDCOUNT)
+12 ; Process ICNs
DO PROCICNS(.ICNS,.SDRETURN,.SDCOUNT)
+13 ;
+14 DO BUILDJSON(.JSONRETURN,.SDRETURN)
+15 QUIT
+16 ;
PROCDFNS(DFNS,SDRETURN,SDCOUNT) ; Validate and Process DFNs
+1 ;
+2 NEW SDCOUNT1,DFN
+3 SET SDCOUNT1=0
+4 FOR
SET SDCOUNT1=$ORDER(DFNS(SDCOUNT1))
if 'SDCOUNT1
QUIT
Begin DoDot:1
+5 NEW SDINFO
+6 IF SDCOUNT>50
DO ERRLOG^SDESJSON(.SDERRORS,489)
QUIT
+7 SET DFN=DFNS(SDCOUNT1)
+8 ;Validate DFN
DO VALDFN($GET(DFN),.SDERRORS)
+9 IF $DATA(SDERRORS)
MERGE SDRETURN=SDERRORS
QUIT
+10 DO GETREG(DFN,.SDINFO)
+11 MERGE SDRETURN("Patient",SDCOUNT)=SDINFO("Patient")
+12 SET SDCOUNT=SDCOUNT+1
End DoDot:1
+13 QUIT
+14 ;
PROCICNS(ICNS,SDRETURN,SDCOUNT) ; Validate and Process ICNs
+1 NEW SDDFN,ICN
+2 SET SDCOUNT1=0
+3 FOR
SET SDCOUNT1=$ORDER(ICNS(SDCOUNT1))
if 'SDCOUNT1
QUIT
Begin DoDot:1
+4 NEW SDINFO
+5 IF SDCOUNT>50
DO ERRLOG^SDESJSON(.SDERRORS,489)
QUIT
+6 SET ICN=ICNS(SDCOUNT1)
+7 ;Validate ICN
DO VALICN($GET(ICN),.SDERRORS)
+8 IF $DATA(SDERRORS)
MERGE SDRETURN=SDERRORS
QUIT
+9 DO GETREG(SDDFN,.SDINFO)
+10 MERGE SDRETURN("Patient",SDCOUNT)=SDINFO("Patient")
+11 SET SDCOUNT=SDCOUNT+1
End DoDot:1
+12 QUIT
+13 ;
VALDFN(DFN,ERRORS) ; Validate DFNS
+1 IF +DFN=0
DO ERRLOG^SDESJSON(.ERRORS,1)
QUIT
+2 IF '$DATA(^DPT(DFN,0))
DO ERRLOG^SDESJSON(.ERRORS,2," DFN not found:"_$GET(DFN))
+3 QUIT
+4 ;
VALICN(ICN,ERRORS) ; Validate ICNS
+1 ;Convert ICN to DFN
+2 SET SDDFN=$$GETDFN^MPIF001(ICN)
+3 SET SDDFN=$SELECT(+SDDFN>0:SDDFN,1:"")
+4 IF +ICN=0
DO ERRLOG^SDESJSON(.ERRORS,2," ICN not found:"_$GET(ICN))
+5 QUIT
+6 ;
VALEAS(EAS,ERRORS) ; Validate EAS
+1 IF $LENGTH(EAS)
SET EAS=$$EASVALIDATE^SDESUTIL($GET(EAS))
+2 IF $PIECE($GET(EAS),U)=-1
DO ERRLOG^SDESJSON(.ERRORS,142)
+3 QUIT
+4 ;
GETREG(DFN,SDINFO) ;
+1 ;
+2 DO GETREG^SDESGETREGA1
+3 QUIT
+4 ;
BUILDJSON(JSONRETURN,SDRETURN) ;Convert data to JSON
+1 IF '$DATA(SDRETURN("Patient"))
SET SDRETURN("Patient",1)=""
+2 DO BUILDJSON^SDESBUILDJSON(.JSONRETURN,.SDRETURN)
QUIT
+3 QUIT