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

SDES2GETRESIEN.m

Go to the documentation of this file.
SDES2GETRESIEN ;ALB/LAB - VISTA SCHEDULING RPCS GET RESOURCE ;FEB 2,2024
 ;;5.3;Scheduling;**867,871**;Aug 13, 1993;Build 13
 ;;Per VHA Directive 6402, this routine should not be modified
 Q
GETRESIEN(RESULT,SDCONTEXT,SEARCHCRITERIA) ;
 NEW ERRORS,IEN,RESOURCE
 S IEN=""
 D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
 I $D(ERRORS) S ERRORS("Resource",1)="" D BUILDJSON^SDES2JSON(.RESULT,.ERRORS) Q
 D VALIDATE(.ERRORS,.SEARCHCRITERIA) ;
 I $D(ERRORS) S ERRORS("Resource",1)="" D BUILDJSON^SDES2JSON(.RESULT,.ERRORS) Q
 D GETIEN(.IEN,.SEARCHCRITERIA)
 I $D(ERRORS) S ERRORS("Resource",1,"IEN")=IEN D BUILDJSON^SDES2JSON(.RESULT,.ERRORS) Q
 S RESOURCE("Resource",1,"IEN")=IEN
 D BUILDJSON^SDES2JSON(.RESULT,.RESOURCE)
 ;
 Q
 ;
VALIDATE(ERRORS,SEARCHCRITERIA) ;
 D VALIDATERESTYP(.ERRORS,$G(SEARCHCRITERIA("ResourceType")))
 Q:$D(ERRORS)
 D:'$D(ERRORS) VALIDATEIEN(.ERRORS,.SEARCHCRITERIA)
 Q
 ;
VALIDATERESTYP(ERRORS,RESTYP) ;
 I RESTYP="" D ERRLOG^SDES2JSON(.ERRORS,52,"Missing required value for Resource Type") Q
 I RESTYP'="C"&(RESTYP'="P") D ERRLOG^SDES2JSON(.ERRORS,52,"Invalid Resource Type")
 Q
 ;
VALIDATEIEN(ERRORS,SEARCHCRITERIA) ;
 I $G(SEARCHCRITERIA("IEN"))="" D ERRLOG^SDES2JSON(.ERRORS,52,"Missing required value for IEN") Q
 D:SEARCHCRITERIA("ResourceType")="P" VALFILEIEN^SDES2VALUTIL(,.ERRORS,200,SEARCHCRITERIA("IEN"),1,0,53,54)
 D:SEARCHCRITERIA("ResourceType")="C" VALFILEIEN^SDES2VALUTIL(,.ERRORS,44,SEARCHCRITERIA("IEN"),1,,18,19)
 Q
 ;
GETIEN(IEN,SEARCHCRITERIA) ;
 S IEN=$O(^SDEC(409.831,"AC",SEARCHCRITERIA("ResourceType"),SEARCHCRITERIA("IEN"),IEN))
 I $O(^SDEC(409.831,"AC",SEARCHCRITERIA("ResourceType"),SEARCHCRITERIA("IEN"),IEN))'="" D
 . D ERRLOG^SDES2JSON(.ERRORS,52,"More than one resource exists for passed in IEN. First Resource IEN returned.")
 Q
 ;