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
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDES2GETRESIEN 1831 printed Dec 13, 2024@02:54:11 Page 2
SDES2GETRESIEN ;ALB/LAB - VISTA SCHEDULING RPCS GET RESOURCE ;FEB 2,2024
+1 ;;5.3;Scheduling;**867,871**;Aug 13, 1993;Build 13
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 QUIT
GETRESIEN(RESULT,SDCONTEXT,SEARCHCRITERIA) ;
+1 NEW ERRORS,IEN,RESOURCE
+2 SET IEN=""
+3 DO VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
+4 IF $DATA(ERRORS)
SET ERRORS("Resource",1)=""
DO BUILDJSON^SDES2JSON(.RESULT,.ERRORS)
QUIT
+5 ;
DO VALIDATE(.ERRORS,.SEARCHCRITERIA)
+6 IF $DATA(ERRORS)
SET ERRORS("Resource",1)=""
DO BUILDJSON^SDES2JSON(.RESULT,.ERRORS)
QUIT
+7 DO GETIEN(.IEN,.SEARCHCRITERIA)
+8 IF $DATA(ERRORS)
SET ERRORS("Resource",1,"IEN")=IEN
DO BUILDJSON^SDES2JSON(.RESULT,.ERRORS)
QUIT
+9 SET RESOURCE("Resource",1,"IEN")=IEN
+10 DO BUILDJSON^SDES2JSON(.RESULT,.RESOURCE)
+11 ;
+12 QUIT
+13 ;
VALIDATE(ERRORS,SEARCHCRITERIA) ;
+1 DO VALIDATERESTYP(.ERRORS,$GET(SEARCHCRITERIA("ResourceType")))
+2 if $DATA(ERRORS)
QUIT
+3 if '$DATA(ERRORS)
DO VALIDATEIEN(.ERRORS,.SEARCHCRITERIA)
+4 QUIT
+5 ;
VALIDATERESTYP(ERRORS,RESTYP) ;
+1 IF RESTYP=""
DO ERRLOG^SDES2JSON(.ERRORS,52,"Missing required value for Resource Type")
QUIT
+2 IF RESTYP'="C"&(RESTYP'="P")
DO ERRLOG^SDES2JSON(.ERRORS,52,"Invalid Resource Type")
+3 QUIT
+4 ;
VALIDATEIEN(ERRORS,SEARCHCRITERIA) ;
+1 IF $GET(SEARCHCRITERIA("IEN"))=""
DO ERRLOG^SDES2JSON(.ERRORS,52,"Missing required value for IEN")
QUIT
+2 if SEARCHCRITERIA("ResourceType")="P"
DO VALFILEIEN^SDES2VALUTIL(,.ERRORS,200,SEARCHCRITERIA("IEN"),1,0,53,54)
+3 if SEARCHCRITERIA("ResourceType")="C"
DO VALFILEIEN^SDES2VALUTIL(,.ERRORS,44,SEARCHCRITERIA("IEN"),1,,18,19)
+4 QUIT
+5 ;
GETIEN(IEN,SEARCHCRITERIA) ;
+1 SET IEN=$ORDER(^SDEC(409.831,"AC",SEARCHCRITERIA("ResourceType"),SEARCHCRITERIA("IEN"),IEN))
+2 IF $ORDER(^SDEC(409.831,"AC",SEARCHCRITERIA("ResourceType"),SEARCHCRITERIA("IEN"),IEN))'=""
Begin DoDot:1
+3 DO ERRLOG^SDES2JSON(.ERRORS,52,"More than one resource exists for passed in IEN. First Resource IEN returned.")
End DoDot:1
+4 QUIT
+5 ;