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
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESADDDELCGI 4107 printed Oct 16, 2024@18:55:58 Page 2
SDESADDDELCGI ;ALB/ANU - VISTA SCHEDULING RPCS ;sEP 19, 2022
+1 ;;5.3;Scheduling;**826**;Aug 13, 1993;Build 18
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 ;External References
+5 ;-------------------
+6 ; Reference to $$GETS^DIQ,$$GETS1^DIQ in ICR #2056
+7 ;
+8 QUIT
+9 ;
+10 ;
DELRGI(RETURNJSON,SDESRGIEN,SDESRSIEN) ;Deletes entry SDESIEN1 from entry SDESIEN in the SDEC RESOURCE GROUP file
+1 ;
+2 ; Input:
+3 ; SDESRGIEN [Required] - Resource Group Id - Pointer to SDEC RESOURCE GROUP file
+4 ; SDESRSIEN [Required] - Pointer to SDEC RESOURCE file
+5 ;
+6 ; Output:
+7 ; RETURNJSON - Returns Status (Success or Failure)
+8 ;
+9 ; Called by SDES DELETE RESGRP ITEM
+10 ;
+11 NEW RETURN,HASFIELDS,ELGFIELDSARRAY,ELGRETURN
+12 NEW ISRGIENVALID,ISRSIENVALID
+13 SET (RETURN,ELGFIELDSARRAY,HASFIELDS)=""
+14 ;
+15 SET ISRGIENVALID=$$VALIDATERGIEN(.ERRORS,$GET(SDESRGIEN))
+16 IF '$DATA(ERRORS)
SET ISRSIENVALID=$$VALIDATERSIEN(.ERRORS,1,$GET(SDESRSIEN))
+17 ;
+18 IF $DATA(ERRORS)
MERGE RETURN=ERRORS
+19 IF '$DATA(ERRORS)
SET HASFIELDS=$$RGIDEL(.ELGFIELDSARRAY,SDESRGIEN,SDESRSIEN)
+20 IF HASFIELDS
MERGE RETURN=ELGFIELDSARRAY
+21 ;
+22 DO BUILDJSON^SDESBUILDJSON(.RETURNJSON,.RETURN)
+23 DO CLEANUP
+24 QUIT
+25 ;
ADDRGI(RETURNJSON,SDESRGIEN,SDESRSIEN) ;Adds entry SDESRSIEN to SDESRGIEN in the SDEC RESOURCE GROUP file
+1 ;
+2 ; Input:
+3 ; SDESRGIEN [Required] - Resource Group Id - Pointer to SDEC RESOURCE GROUP file
+4 ; SDESRSIEN [Required] - Pointer to SDEC RESOURCE file
+5 ;
+6 ; Output:
+7 ; RETURNJSON - Returns Status (Success or Failure)
+8 ;
+9 ; Called by SDES ADD RESGRP ITEM
+10 ;
+11 NEW RETURN,HASFIELDS,ELGFIELDSARRAY,ELGRETURN
+12 NEW ISRGIENVALID,ISRSIENVALID
+13 SET (RETURN,ELGFIELDSARRAY,HASFIELDS)=""
+14 ;
+15 SET ISRGIENVALID=$$VALIDATERGIEN(.ERRORS,$GET(SDESRGIEN))
+16 IF '$DATA(ERRORS)
SET ISRSIENVALID=$$VALIDATERSIEN(.ERRORS,0,$GET(SDESRSIEN))
+17 ;
+18 IF $DATA(ERRORS)
MERGE RETURN=ERRORS
+19 IF '$DATA(ERRORS)
SET HASFIELDS=$$RGIADD(.ELGFIELDSARRAY,SDESRGIEN,SDESRSIEN)
+20 IF HASFIELDS
MERGE RETURN=ELGFIELDSARRAY
+21 ;
+22 DO BUILDJSON^SDESBUILDJSON(.RETURNJSON,.RETURN)
+23 DO CLEANUP
+24 QUIT
+25 ;
VALIDATERGIEN(ERRORS,SDESRGIEN) ; Validate Resource Group IEN
+1 NEW ERRORFLAG
+2 ; Missing Resource Gruop IEN
IF SDESRGIEN=""
SET ERRORFLAG=1
DO ERRLOG^SDESJSON(.ERRORS,312)
QUIT $DATA(ERRORFLAG)
+3 ; Invalid Resource Group
IF SDESRGIEN'=""
IF '$DATA(^SDEC(409.832,SDESRGIEN,0))
SET ERRORFLAG=1
DO ERRLOG^SDESJSON(.ERRORS,276)
QUIT $DATA(ERRORFLAG)
+4 QUIT $DATA(ERRORFLAG)
+5 ;
VALIDATERSIEN(ERRORS,SDDLTFLAG,SDESRSIEN) ; Validate Resource IEN
+1 NEW ERRORFLAG,SDDA
+2 ; Missing Resource Item IEN
IF SDESRSIEN=""
SET ERRORFLAG=1
DO ERRLOG^SDESJSON(.ERRORS,69)
QUIT $DATA(ERRORFLAG)
+3 ; Invalid Resource Item
IF SDESRSIEN'=""
IF '$DATA(^SDEC(409.831,SDESRSIEN,0))
SET ERRORFLAG=1
DO ERRLOG^SDESJSON(.ERRORS,70)
QUIT $DATA(ERRORFLAG)
+4 IF SDDLTFLAG
Begin DoDot:1
+5 SET SDDA=$ORDER(^SDEC(409.832,SDESRGIEN,1,"B",SDESRSIEN,0))
+6 IF $GET(SDDA)=""
SET ERRORFLAG=1
DO ERRLOG^SDESJSON(.ERRORS,313)
QUIT
+7 IF '$DATA(^SDEC(409.832,SDESRGIEN,1,SDDA,0))
SET ERRORFLAG=1
DO ERRLOG^SDESJSON(.ERRORS,313)
QUIT
End DoDot:1
+8 IF 'SDDLTFLAG
Begin DoDot:1
+9 IF $DATA(^SDEC(409.832,SDESRGIEN,1,"B",SDESRSIEN))
SET ERRORFLAG=1
DO ERRLOG^SDESJSON(.ERRORS,311)
QUIT
End DoDot:1
+10 QUIT $DATA(ERRORFLAG)
+11 ;
RGIDEL(ELGARRAY,SDESRGIEN,SDESRSIEN) ; Delete Resource ID from Resource Group File
+1 NEW HASDATA,SDFDA,SDDA,SDMSG
+2 SET SDDA=$ORDER(^SDEC(409.832,SDESRGIEN,1,"B",SDESRSIEN,0))
+3 ; Delete entry SDECIEN1
+4 SET SDFDA(409.8321,SDDA_","_SDESRGIEN_",",.01)="@"
+5 DO FILE^DIE(,"SDFDA","SDMSG")
+6 IF $DATA(SDMSG)
SET ELGARRAY("Status")="0^Error in deleting Resource Item."
+7 IF '$DATA(SDMSG)
SET ELGARRAY("Status")="1^Resource Item is successfully deleted."
+8 SET HASDATA=($DATA(ELGARRAY)>1)
+9 QUIT HASDATA
+10 ;
RGIADD(ELGARRAY,SDESRGIEN,SDESRSIEN) ; Add Resource ID to Resource Group File
+1 NEW HASDATA,SDFDA,SDMSG,SDESIENS
+2 ;
+3 SET SDESIENS="+1,"_SDESRGIEN_","
+4 ;RESOURCEID
SET SDFDA(409.8321,SDESIENS,.01)=SDESRSIEN
+5 KILL SDESRGIEN
+6 DO UPDATE^DIE("","SDFDA","SDESRGIEN","SDMSG")
+7 IF $DATA(SDMSG)
SET ELGARRAY("Status")="0^Error in adding Resource Item."
+8 IF '$DATA(SDMSG)
SET ELGARRAY("Status")="1^Resource Item is successfully added."
+9 SET HASDATA=($DATA(ELGARRAY)>1)
+10 QUIT HASDATA
+11 ;
CLEANUP ;
+1 KILL RETURNERROR,ERRORFLAG,ERRORS,ISRGIENVALID,ISRGNAMEVALID
+2 KILL RETURN,HASFIELDS,ELGFIELDSARRAY,ELGRETURN
+3 QUIT
+4 ;