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

SDES2CRTPRVRES.m

Go to the documentation of this file.
SDES2CRTPRVRES ;ALB/LAB - VISTA SCHEDULING SDES2 CREATE PROVIDER RESOURCE ;JAN 30,2024
 ;;5.3;Scheduling;**869,871**;Aug 13, 1993;Build 13
 ;;Per VHA Directive 6402, this routine should not be modified
 Q
 ;
CREATEPRVRES(RESULT,SDCONTEXT,SDPARAM) ; create provider resource record 409.831
 N ERRORS,RETURN,RESOURCE,SDDUZ
 ;validate context array for accuracy
 D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
 I $D(ERRORS) S ERRORS("ResourceIEN",1)="" D BUILDJSON^SDES2JSON(.RESULT,.ERRORS) Q
 D VALIDATE(.ERRORS,.SDPARAM)
 I $D(ERRORS) S ERRORS("ResourceIEN",1)="" D BUILDJSON^SDES2JSON(.RESULT,.ERRORS) Q
 D ASSIGNVARS(SDCONTEXT("USER DUZ"),SDPARAM("ProviderIEN"),.RESOURCE,.SDDUZ)
 D CREATERESOURCE(.RETURN,.ERRORS,.SDCONTEXT,.SDPARAM,RESOURCE,SDDUZ)
 I $D(ERRORS) S ERRORS("ResourceIEN",1)="" D BUILDJSON^SDES2JSON(.RESULT,.ERRORS) Q
 D BUILDJSON^SDES2JSON(.RESULT,.RETURN)
 Q
 ;
VALIDATE(ERRORS,SDPARAM) ; validate input array variables
 S SDPARAM("ClinicIEN")=$G(SDPARAM("ClinicIEN"))
 D VALFILEIEN^SDES2VALUTIL(,.ERRORS,44,SDPARAM("ClinicIEN"),0,"","",19)
 D VALFILEIEN^SDES2VALUTIL(,.ERRORS,200,$G(SDPARAM("ProviderIEN")),1,"",53,54)
 Q:$D(ERRORS)
 ;validate if resource already exists for provider
 D:$O(^SDEC(409.831,"AC","P",SDPARAM("ProviderIEN"),""))'="" ERRLOG^SDES2JSON(.ERRORS,52,"Provider Resource already exists")
 Q
 ;
ASSIGNVARS(USERID,PROVIDERIEN,RESOURCE,SDDUZ) ;assign variables to use
 S RESOURCE=$$GET1^DIQ(200,PROVIDERIEN,.01,"E")
 S SDDUZ=$S(USERID:USERID,1:DUZ)
 Q
 ;
CREATERESOURCE(RETURN,ERRORS,SDCONTEXT,SDPARAM,RESOURCE,SDSDUZ) ;create the provider resource
 N FILEDATA,NEWIEN
 S FILEDATA(409.831,"+1,",.01)=RESOURCE
 S FILEDATA(409.831,"+1,",.012)=SDPARAM("ProviderIEN")_";VA(200,"
 S FILEDATA(409.831,"+1,",.015)=$$NOW^XLFDT
 S FILEDATA(409.831,"+1,",.016)=SDDUZ
 S FILEDATA(409.831,"+1,",.04)=SDPARAM("ClinicIEN")
 D UPDATE^DIE("","FILEDATA","NEWIEN","ERRORS") K FILEDATA
 S RETURN("ResourceIEN")=$G(NEWIEN(1))
 ;