SDESGETAREQINST ;ALB/ANU - GET APPT REQ RPCS ;Oct 31, 2022@15:35
;;5.3;Scheduling;**835**;Aug 13, 1993;Build 4
;;Per VHA Directive 6402, this routine should not be modified
;
; Reference to ^VA(200 in ICR #10060
; Reference to $$GET1^DIQ in ICR #2056
Q
;
; For an example of the return object, see SDESGETREQWRAPPR due to its length.
; If you add new components to the JSON return object in this routine, document
; them in header of SDESGETREQWRAPPR and initialize them in APPTREQUEST.
;
GETREQSBYINTOPEN(JSONRETURN,INST,YEAR,EAS) ; SDES GET APPT REQ BY INST OPEN
N ISINSTVALID,ISEASVALID,RETURN,ERRORS,REQUESTIEN,REQUEST,REQUESTDT,COUNT,ISYRVALID
;
S ISINSTVALID=$$VALIDATEINST(.ERRORS,$G(INST))
S ISYRVALID=$$VALIDATEYEAR(.ERRORS,$G(YEAR))
S ISEASVALID=$$VALIDATEEAS(.ERRORS,$G(EAS))
I $D(ERRORS) M RETURN=ERRORS D BUILDJSON(.JSONRETURN,.RETURN) Q
;
S REQUESTIEN=0,COUNT=0,REQUESTDT=""
F S REQUESTIEN=$O(^SDEC(409.85,"C",INST,REQUESTIEN)) Q:'REQUESTIEN D
.I $$GET1^DIQ(409.85,REQUESTIEN,23,"I")="C" Q
.S REQUESTDT=$$GET1^DIQ(409.85,REQUESTIEN,9.5,"I")
.I REQUESTDT="" Q
.I YEAR'=$$FMTE^XLFDT($E(REQUESTDT,1,3)_"0000") Q
.D GETREQUEST^SDESGETAPPTREQ(.REQUEST,REQUESTIEN)
.S COUNT=COUNT+1
I '$D(REQUEST) S REQUEST("Request",1)=""
M RETURN=REQUEST
;
D BUILDJSON(.JSONRETURN,.RETURN)
Q
;
VALIDATEINST(ERRORS,INST) ;
I INST="" D ERRLOG^SDESJSON(.ERRORS,409) Q 0
I INST'="",'$D(^DIC(4,INST,0)) D ERRLOG^SDESJSON(.ERRORS,410) Q 0
Q 1
;
VALIDATEYEAR(ERRORS,YEAR) ;
I YEAR="" D ERRLOG^SDESJSON(.ERRORS,411) Q 0
I YEAR>$$FMTE^XLFDT($E($$NOW^XLFDT,1,3)_"0000") D ERRLOG^SDESJSON(.ERRORS,412) Q 0
I +YEAR<1900 D ERRLOG^SDESJSON(.ERRORS,412) Q 0
Q 1
;
VALIDATEEAS(ERRORS,EAS) ;
I $L(EAS) S EAS=$$EASVALIDATE^SDESUTIL($G(EAS))
I $P($G(EAS),U)=-1 D ERRLOG^SDESJSON(.ERRORS,142) Q 0
Q 1
;
BUILDJSON(JSONRETURN,RETURN) ;
N JSONERROR
D ENCODE^XLFJSON("RETURN","JSONRETURN","JSONERROR")
;
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESGETAREQINST 1982 printed Nov 22, 2024@18:06:38 Page 2
SDESGETAREQINST ;ALB/ANU - GET APPT REQ RPCS ;Oct 31, 2022@15:35
+1 ;;5.3;Scheduling;**835**;Aug 13, 1993;Build 4
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 ; Reference to ^VA(200 in ICR #10060
+5 ; Reference to $$GET1^DIQ in ICR #2056
+6 QUIT
+7 ;
+8 ; For an example of the return object, see SDESGETREQWRAPPR due to its length.
+9 ; If you add new components to the JSON return object in this routine, document
+10 ; them in header of SDESGETREQWRAPPR and initialize them in APPTREQUEST.
+11 ;
GETREQSBYINTOPEN(JSONRETURN,INST,YEAR,EAS) ; SDES GET APPT REQ BY INST OPEN
+1 NEW ISINSTVALID,ISEASVALID,RETURN,ERRORS,REQUESTIEN,REQUEST,REQUESTDT,COUNT,ISYRVALID
+2 ;
+3 SET ISINSTVALID=$$VALIDATEINST(.ERRORS,$GET(INST))
+4 SET ISYRVALID=$$VALIDATEYEAR(.ERRORS,$GET(YEAR))
+5 SET ISEASVALID=$$VALIDATEEAS(.ERRORS,$GET(EAS))
+6 IF $DATA(ERRORS)
MERGE RETURN=ERRORS
DO BUILDJSON(.JSONRETURN,.RETURN)
QUIT
+7 ;
+8 SET REQUESTIEN=0
SET COUNT=0
SET REQUESTDT=""
+9 FOR
SET REQUESTIEN=$ORDER(^SDEC(409.85,"C",INST,REQUESTIEN))
if 'REQUESTIEN
QUIT
Begin DoDot:1
+10 IF $$GET1^DIQ(409.85,REQUESTIEN,23,"I")="C"
QUIT
+11 SET REQUESTDT=$$GET1^DIQ(409.85,REQUESTIEN,9.5,"I")
+12 IF REQUESTDT=""
QUIT
+13 IF YEAR'=$$FMTE^XLFDT($EXTRACT(REQUESTDT,1,3)_"0000")
QUIT
+14 DO GETREQUEST^SDESGETAPPTREQ(.REQUEST,REQUESTIEN)
+15 SET COUNT=COUNT+1
End DoDot:1
+16 IF '$DATA(REQUEST)
SET REQUEST("Request",1)=""
+17 MERGE RETURN=REQUEST
+18 ;
+19 DO BUILDJSON(.JSONRETURN,.RETURN)
+20 QUIT
+21 ;
VALIDATEINST(ERRORS,INST) ;
+1 IF INST=""
DO ERRLOG^SDESJSON(.ERRORS,409)
QUIT 0
+2 IF INST'=""
IF '$DATA(^DIC(4,INST,0))
DO ERRLOG^SDESJSON(.ERRORS,410)
QUIT 0
+3 QUIT 1
+4 ;
VALIDATEYEAR(ERRORS,YEAR) ;
+1 IF YEAR=""
DO ERRLOG^SDESJSON(.ERRORS,411)
QUIT 0
+2 IF YEAR>$$FMTE^XLFDT($EXTRACT($$NOW^XLFDT,1,3)_"0000")
DO ERRLOG^SDESJSON(.ERRORS,412)
QUIT 0
+3 IF +YEAR<1900
DO ERRLOG^SDESJSON(.ERRORS,412)
QUIT 0
+4 QUIT 1
+5 ;
VALIDATEEAS(ERRORS,EAS) ;
+1 IF $LENGTH(EAS)
SET EAS=$$EASVALIDATE^SDESUTIL($GET(EAS))
+2 IF $PIECE($GET(EAS),U)=-1
DO ERRLOG^SDESJSON(.ERRORS,142)
QUIT 0
+3 QUIT 1
+4 ;
BUILDJSON(JSONRETURN,RETURN) ;
+1 NEW JSONERROR
+2 DO ENCODE^XLFJSON("RETURN","JSONRETURN","JSONERROR")
+3 ;
+4 QUIT