SDES2EDITPREREG ;ALB/JAS - SDES2 EDIT PATIENT'S PRE-REGISTRATION ;AUG 28, 2023
;;5.3;Scheduling;**861**;Aug 13, 1993;Build 17
;;Per VHA Directive 6402, this routine should not be modified
;
Q
;
; RPC: SDES2 GET PATIENT MED LIST
;
; SDCONTEXT("ACHERON AUDIT ID") = 36 character unique ID number. Ex: 11d9dcc6-c6a2-4785-8031-8261576fca37
; SDCONTEXT("USER DUZ") = The DUZ of the user taking action on the calling application.
; SDCONTEXT("USER SECID") = The Security ID of the user taking action on the calling application.
; SDCONTEXT("PATIENT DFN") = The DFN of the Veteran/user taking action on the calling application.
; SDCONTEXT("PATIENT ICN") = The ICN of the Veteran/user taking action on the calling application.
;
; PARAMS("STATUS CODE") = The code that represents the outcome of the pre-registration interview
; with the patient (Required)
; PARAMS("DFN") = The DFN of the pre-registration patient
;
EDITPREREG(JSONRETURN,SDCONTEXT,PARAMS) ; Edit Patient's Pre-Registration
;
N SDERRORS,SDRESULT,SDRETURN,VALCHK
;
; Validate SDCONTEXT
;
S VALCHK=$$VALCONTXT(.SDCONTEXT,.SDERRORS)
I 'VALCHK M SDRETURN=SDERRORS S SDRETURN("Pre-Registration",1)="" D BUILDJSON^SDES2JSON(.JSONRETURN,.SDRETURN) Q
;
; Validate PARAMS
;
S VALCHK=$$VALPARAMS(.PARAMS,.SDERRORS)
I 'VALCHK M SDRETURN=SDERRORS S SDRETURN("Pre-Registration",1)="" D BUILDJSON^SDES2JSON(.JSONRETURN,.SDRETURN) Q
;
; Call PREREG^VPSRPC3
;
D PREREG^VPSRPC3(.SDRESULT,PARAMS("DFN"),PARAMS("STATUS CODE"))
;
K Y ; Kill leaking variable from PREREG^VPSRPC3
;
I '+(SDRESULT) D
. D ERRLOG^SDES2JSON(.SDERRORS,52,"An unspecified filing error occurred in the PREREG^VPSRPC3 API")
. S SDRETURN("Pre-Registration",1)="" M SDRETURN=SDERRORS
I +(SDRESULT) S SDRETURN("Pre-Registration","Success")=$P(SDRESULT,",",2)
;
; Build JSON return
;
D BUILDJSON^SDES2JSON(.JSONRETURN,.SDRETURN)
Q
;
VALCONTXT(SDCONTEXT,SDERRORS) ; Validate SDCONTEXT array
D VALCONTEXT^SDES2VALCONTEXT(.SDERRORS,.SDCONTEXT)
I $D(SDERRORS) Q 0
Q 1
;
VALPARAMS(PARAMS,SDERRORS) ; Validate PARAMS array (DFN & Status Code)
;
; Validate DFN
;
N VALRET
D VALFILEIEN^SDES2VALUTIL(.VALRET,.SDERRORS,2,$G(PARAMS("DFN")),1,0,1,2)
I 'VALRET,$D(SDERRORS) Q 0
;
; Validate Status Code
;
I $G(PARAMS("STATUS CODE"))="" D Q 0
. D ERRLOG^SDES2JSON(.SDERRORS,514)
I $L(PARAMS("STATUS CODE"))>1 D Q 0
. D ERRLOG^SDES2JSON(.SDERRORS,515)
I "^B^C^D^K^M^N^P^T^U^V^W^X^"'[("^"_$G(PARAMS("STATUS CODE"))_"^") D Q 0
. D ERRLOG^SDES2JSON(.SDERRORS,515)
Q 1
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDES2EDITPREREG 2678 printed Sep 15, 2024@22:17:43 Page 2
SDES2EDITPREREG ;ALB/JAS - SDES2 EDIT PATIENT'S PRE-REGISTRATION ;AUG 28, 2023
+1 ;;5.3;Scheduling;**861**;Aug 13, 1993;Build 17
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 QUIT
+5 ;
+6 ; RPC: SDES2 GET PATIENT MED LIST
+7 ;
+8 ; SDCONTEXT("ACHERON AUDIT ID") = 36 character unique ID number. Ex: 11d9dcc6-c6a2-4785-8031-8261576fca37
+9 ; SDCONTEXT("USER DUZ") = The DUZ of the user taking action on the calling application.
+10 ; SDCONTEXT("USER SECID") = The Security ID of the user taking action on the calling application.
+11 ; SDCONTEXT("PATIENT DFN") = The DFN of the Veteran/user taking action on the calling application.
+12 ; SDCONTEXT("PATIENT ICN") = The ICN of the Veteran/user taking action on the calling application.
+13 ;
+14 ; PARAMS("STATUS CODE") = The code that represents the outcome of the pre-registration interview
+15 ; with the patient (Required)
+16 ; PARAMS("DFN") = The DFN of the pre-registration patient
+17 ;
EDITPREREG(JSONRETURN,SDCONTEXT,PARAMS) ; Edit Patient's Pre-Registration
+1 ;
+2 NEW SDERRORS,SDRESULT,SDRETURN,VALCHK
+3 ;
+4 ; Validate SDCONTEXT
+5 ;
+6 SET VALCHK=$$VALCONTXT(.SDCONTEXT,.SDERRORS)
+7 IF 'VALCHK
MERGE SDRETURN=SDERRORS
SET SDRETURN("Pre-Registration",1)=""
DO BUILDJSON^SDES2JSON(.JSONRETURN,.SDRETURN)
QUIT
+8 ;
+9 ; Validate PARAMS
+10 ;
+11 SET VALCHK=$$VALPARAMS(.PARAMS,.SDERRORS)
+12 IF 'VALCHK
MERGE SDRETURN=SDERRORS
SET SDRETURN("Pre-Registration",1)=""
DO BUILDJSON^SDES2JSON(.JSONRETURN,.SDRETURN)
QUIT
+13 ;
+14 ; Call PREREG^VPSRPC3
+15 ;
+16 DO PREREG^VPSRPC3(.SDRESULT,PARAMS("DFN"),PARAMS("STATUS CODE"))
+17 ;
+18 ; Kill leaking variable from PREREG^VPSRPC3
KILL Y
+19 ;
+20 IF '+(SDRESULT)
Begin DoDot:1
+21 DO ERRLOG^SDES2JSON(.SDERRORS,52,"An unspecified filing error occurred in the PREREG^VPSRPC3 API")
+22 SET SDRETURN("Pre-Registration",1)=""
MERGE SDRETURN=SDERRORS
End DoDot:1
+23 IF +(SDRESULT)
SET SDRETURN("Pre-Registration","Success")=$PIECE(SDRESULT,",",2)
+24 ;
+25 ; Build JSON return
+26 ;
+27 DO BUILDJSON^SDES2JSON(.JSONRETURN,.SDRETURN)
+28 QUIT
+29 ;
VALCONTXT(SDCONTEXT,SDERRORS) ; Validate SDCONTEXT array
+1 DO VALCONTEXT^SDES2VALCONTEXT(.SDERRORS,.SDCONTEXT)
+2 IF $DATA(SDERRORS)
QUIT 0
+3 QUIT 1
+4 ;
VALPARAMS(PARAMS,SDERRORS) ; Validate PARAMS array (DFN & Status Code)
+1 ;
+2 ; Validate DFN
+3 ;
+4 NEW VALRET
+5 DO VALFILEIEN^SDES2VALUTIL(.VALRET,.SDERRORS,2,$GET(PARAMS("DFN")),1,0,1,2)
+6 IF 'VALRET
IF $DATA(SDERRORS)
QUIT 0
+7 ;
+8 ; Validate Status Code
+9 ;
+10 IF $GET(PARAMS("STATUS CODE"))=""
Begin DoDot:1
+11 DO ERRLOG^SDES2JSON(.SDERRORS,514)
End DoDot:1
QUIT 0
+12 IF $LENGTH(PARAMS("STATUS CODE"))>1
Begin DoDot:1
+13 DO ERRLOG^SDES2JSON(.SDERRORS,515)
End DoDot:1
QUIT 0
+14 IF "^B^C^D^K^M^N^P^T^U^V^W^X^"'[("^"_$GET(PARAMS("STATUS CODE"))_"^")
Begin DoDot:1
+15 DO ERRLOG^SDES2JSON(.SDERRORS,515)
End DoDot:1
QUIT 0
+16 QUIT 1