Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: SDESGETAREQINST

SDESGETAREQINST.m

Go to the documentation of this file.
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