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

SDESADDDELCGI.m

Go to the documentation of this file.
SDESADDDELCGI ;ALB/ANU - VISTA SCHEDULING RPCS ;sEP 19, 2022
 ;;5.3;Scheduling;**826**;Aug 13, 1993;Build 18
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 ;External References
 ;-------------------
 ; Reference to $$GETS^DIQ,$$GETS1^DIQ in ICR #2056
 ;
 Q
 ;
 ;
DELRGI(RETURNJSON,SDESRGIEN,SDESRSIEN) ;Deletes entry SDESIEN1 from entry SDESIEN in the SDEC RESOURCE GROUP file
 ;
 ; Input:
 ; SDESRGIEN    [Required] - Resource Group Id - Pointer to SDEC RESOURCE GROUP file
 ; SDESRSIEN    [Required] - Pointer to SDEC RESOURCE file
 ;
 ; Output:
 ;    RETURNJSON - Returns Status (Success or Failure)
 ;
 ; Called by SDES DELETE RESGRP ITEM
 ;
 N RETURN,HASFIELDS,ELGFIELDSARRAY,ELGRETURN
 N ISRGIENVALID,ISRSIENVALID
 S (RETURN,ELGFIELDSARRAY,HASFIELDS)=""
 ;
 S ISRGIENVALID=$$VALIDATERGIEN(.ERRORS,$G(SDESRGIEN))
 I '$D(ERRORS) S ISRSIENVALID=$$VALIDATERSIEN(.ERRORS,1,$G(SDESRSIEN))
 ;
 I $D(ERRORS) M RETURN=ERRORS
 I '$D(ERRORS) S HASFIELDS=$$RGIDEL(.ELGFIELDSARRAY,SDESRGIEN,SDESRSIEN)
 I HASFIELDS M RETURN=ELGFIELDSARRAY
 ;
 D BUILDJSON^SDESBUILDJSON(.RETURNJSON,.RETURN)
 D CLEANUP
 Q
 ;
ADDRGI(RETURNJSON,SDESRGIEN,SDESRSIEN) ;Adds entry SDESRSIEN to SDESRGIEN in the SDEC RESOURCE GROUP file
 ;
 ; Input:
 ;    SDESRGIEN     [Required] - Resource Group Id - Pointer to SDEC RESOURCE GROUP file
 ;    SDESRSIEN     [Required] - Pointer to SDEC RESOURCE file
 ;
 ; Output:
 ;    RETURNJSON - Returns Status (Success or Failure)
 ;
 ; Called by SDES ADD RESGRP ITEM
 ;
 N RETURN,HASFIELDS,ELGFIELDSARRAY,ELGRETURN
 N ISRGIENVALID,ISRSIENVALID
 S (RETURN,ELGFIELDSARRAY,HASFIELDS)=""
 ;
 S ISRGIENVALID=$$VALIDATERGIEN(.ERRORS,$G(SDESRGIEN))
 I '$D(ERRORS) S ISRSIENVALID=$$VALIDATERSIEN(.ERRORS,0,$G(SDESRSIEN))
 ;
 I $D(ERRORS) M RETURN=ERRORS
 I '$D(ERRORS) S HASFIELDS=$$RGIADD(.ELGFIELDSARRAY,SDESRGIEN,SDESRSIEN)
 I HASFIELDS M RETURN=ELGFIELDSARRAY
 ;
 D BUILDJSON^SDESBUILDJSON(.RETURNJSON,.RETURN)
 D CLEANUP
 Q
 ;
VALIDATERGIEN(ERRORS,SDESRGIEN) ; Validate Resource Group IEN
 N ERRORFLAG
 I SDESRGIEN="" S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,312) Q $D(ERRORFLAG) ; Missing Resource Gruop IEN
 I SDESRGIEN'="" I '$D(^SDEC(409.832,SDESRGIEN,0)) S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,276) Q $D(ERRORFLAG) ; Invalid Resource Group
 Q $D(ERRORFLAG)
 ;
VALIDATERSIEN(ERRORS,SDDLTFLAG,SDESRSIEN) ; Validate Resource IEN
 N ERRORFLAG,SDDA
 I SDESRSIEN="" S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,69) Q $D(ERRORFLAG) ; Missing Resource Item IEN
 I SDESRSIEN'="" I '$D(^SDEC(409.831,SDESRSIEN,0)) S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,70) Q $D(ERRORFLAG) ; Invalid Resource Item
 I SDDLTFLAG D
 .S SDDA=$O(^SDEC(409.832,SDESRGIEN,1,"B",SDESRSIEN,0))
 .I $G(SDDA)="" S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,313) Q
 .I '$D(^SDEC(409.832,SDESRGIEN,1,SDDA,0)) S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,313) Q
 I 'SDDLTFLAG D
 .I $D(^SDEC(409.832,SDESRGIEN,1,"B",SDESRSIEN)) S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,311) Q
 Q $D(ERRORFLAG)
 ;
RGIDEL(ELGARRAY,SDESRGIEN,SDESRSIEN) ; Delete Resource ID from Resource Group File
 N HASDATA,SDFDA,SDDA,SDMSG
 S SDDA=$O(^SDEC(409.832,SDESRGIEN,1,"B",SDESRSIEN,0))
 ; Delete entry SDECIEN1
 S SDFDA(409.8321,SDDA_","_SDESRGIEN_",",.01)="@"
 D FILE^DIE(,"SDFDA","SDMSG")
 I $D(SDMSG) S ELGARRAY("Status")="0^Error in deleting Resource Item."
 I '$D(SDMSG) S ELGARRAY("Status")="1^Resource Item is successfully deleted."
 S HASDATA=($D(ELGARRAY)>1)
 Q HASDATA
 ;
RGIADD(ELGARRAY,SDESRGIEN,SDESRSIEN) ; Add Resource ID to Resource Group File
 N HASDATA,SDFDA,SDMSG,SDESIENS
 ;
 S SDESIENS="+1,"_SDESRGIEN_","
 S SDFDA(409.8321,SDESIENS,.01)=SDESRSIEN ;RESOURCEID
 K SDESRGIEN
 D UPDATE^DIE("","SDFDA","SDESRGIEN","SDMSG")
 I $D(SDMSG) S ELGARRAY("Status")="0^Error in adding Resource Item."
 I '$D(SDMSG) S ELGARRAY("Status")="1^Resource Item is successfully added."
 S HASDATA=($D(ELGARRAY)>1)
 Q HASDATA
 ;
CLEANUP ;
 K RETURNERROR,ERRORFLAG,ERRORS,ISRGIENVALID,ISRGNAMEVALID
 K RETURN,HASFIELDS,ELGFIELDSARRAY,ELGRETURN
 Q
 ;