SDES2GETRESGROUP ;ALB/BLB,LAB - SDES2 GET RESOURCE GROUP - JUN 7,2024
;;5.3;Scheduling;**866,867,880**;Aug 13, 1993;Build 5
;;Per VHA Directive 6402, this routine should not be modified
;
Q
;
GETRESOURCEGROUP(JSON,SDCONTEXT,RESOURCEGROUP) ;
N GROUPDATA,VALRETURN,ERRORS
;
D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
D VALFILEIEN^SDES2VALUTIL(.VALRETURN,.ERRORS,409.832,$G(RESOURCEGROUP("RESOURCE GROUP IEN")),1,,312,276)
D VALIDINACTIVE^SDES2PRVCLINSRC(.ERRORS,$G(RESOURCEGROUP("INACTIVE CLINIC")))
I $D(ERRORS) S ERRORS("RSGroup",1)="" D BUILDJSON^SDES2JSON(.JSON,.ERRORS) Q
;
D BUILDGROUP(.GROUPDATA,RESOURCEGROUP("RESOURCE GROUP IEN"))
;
D BUILDJSON^SDESBUILDJSON(.JSON,.GROUPDATA)
Q
;
BUILDGROUP(GROUPDATA,GROUPIEN) ;
N SUBIEN,COUNT,TYPE,IENS,RESOURCEIEN,RESOURCETYPE,PROVCLINCOUNT,CLINICIEN,PROVIDERIEN,INACTIVE
;
; top level group
S GROUPDATA("RSGroup","IEN")=GROUPIEN
S GROUPDATA("RSGroup","Name")=$$GET1^DIQ(409.832,GROUPIEN,.01,"E")
S GROUPDATA("RSGroup","Inactivation Date")=$$FMTISO^SDAMUTDT($$GET1^DIQ(409.832,GROUPIEN,.02,"I"))
;
; sub level resources
S SUBIEN=0,COUNT=0
F S SUBIEN=$O(^SDEC(409.832,GROUPIEN,1,SUBIEN)) Q:'SUBIEN D
.S RESOURCEIEN=$$GET1^DIQ(409.8321,SUBIEN_","_GROUPIEN_",",.01,"I")
.I $$GET1^DIQ(409.831,RESOURCEIEN,.02)="YES" Q
.S RESOURCETYPE=$$GET1^DIQ(409.831,RESOURCEIEN,.012,"E")
.S COUNT=COUNT+1
.;
.S GROUPDATA("RSGroup","Resources",COUNT,"IEN")=$P($$GET1^DIQ(409.831,RESOURCEIEN,.012,"I"),";")
.S GROUPDATA("RSGroup","Resources",COUNT,"Name")=$$GET1^DIQ(409.831,RESOURCEIEN,.01,"E")
.S GROUPDATA("RSGroup","Resources",COUNT,"Type")=RESOURCETYPE
.;
.I RESOURCETYPE="PROVIDER" D
..S PROVIDERIEN=$P($$GET1^DIQ(409.831,RESOURCEIEN,.012,"I"),";")
..S CLINICIEN=0,PROVCLINCOUNT=0
..F S CLINICIEN=$O(^SC("AVADPR",PROVIDERIEN,CLINICIEN)) Q:'CLINICIEN D
...S INACTIVE=$$INACTIVE^SDES2UTIL(CLINICIEN)
...Q:(+$G(RESOURCEGROUP("INACTIVE CLINIC"))=0)&(INACTIVE)
...S PROVCLINCOUNT=PROVCLINCOUNT+1
...;
...S GROUPDATA("RSGroup","Resources",COUNT,"Provider",PROVCLINCOUNT,"AssociatedClinicIEN")=CLINICIEN
...S GROUPDATA("RSGroup","Resources",COUNT,"Provider",PROVCLINCOUNT,"AssociatedClinicName")=$$GET1^DIQ(44,CLINICIEN,.01,"E")
...S GROUPDATA("RSGroup","Resources",COUNT,"Provider",PROVCLINCOUNT,"AssociatedClinicStatus")=$S($$INACTIVE^SDES2UTIL(CLINICIEN)=0:"Active",1:"Inactive")
.. S:PROVCLINCOUNT=0 GROUPDATA("RSGroup","Resources",COUNT,"Provider",1)=""
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDES2GETRESGROUP 2500 printed Nov 22, 2024@18:04:07 Page 2
SDES2GETRESGROUP ;ALB/BLB,LAB - SDES2 GET RESOURCE GROUP - JUN 7,2024
+1 ;;5.3;Scheduling;**866,867,880**;Aug 13, 1993;Build 5
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 QUIT
+5 ;
GETRESOURCEGROUP(JSON,SDCONTEXT,RESOURCEGROUP) ;
+1 NEW GROUPDATA,VALRETURN,ERRORS
+2 ;
+3 DO VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
+4 DO VALFILEIEN^SDES2VALUTIL(.VALRETURN,.ERRORS,409.832,$GET(RESOURCEGROUP("RESOURCE GROUP IEN")),1,,312,276)
+5 DO VALIDINACTIVE^SDES2PRVCLINSRC(.ERRORS,$GET(RESOURCEGROUP("INACTIVE CLINIC")))
+6 IF $DATA(ERRORS)
SET ERRORS("RSGroup",1)=""
DO BUILDJSON^SDES2JSON(.JSON,.ERRORS)
QUIT
+7 ;
+8 DO BUILDGROUP(.GROUPDATA,RESOURCEGROUP("RESOURCE GROUP IEN"))
+9 ;
+10 DO BUILDJSON^SDESBUILDJSON(.JSON,.GROUPDATA)
+11 QUIT
+12 ;
BUILDGROUP(GROUPDATA,GROUPIEN) ;
+1 NEW SUBIEN,COUNT,TYPE,IENS,RESOURCEIEN,RESOURCETYPE,PROVCLINCOUNT,CLINICIEN,PROVIDERIEN,INACTIVE
+2 ;
+3 ; top level group
+4 SET GROUPDATA("RSGroup","IEN")=GROUPIEN
+5 SET GROUPDATA("RSGroup","Name")=$$GET1^DIQ(409.832,GROUPIEN,.01,"E")
+6 SET GROUPDATA("RSGroup","Inactivation Date")=$$FMTISO^SDAMUTDT($$GET1^DIQ(409.832,GROUPIEN,.02,"I"))
+7 ;
+8 ; sub level resources
+9 SET SUBIEN=0
SET COUNT=0
+10 FOR
SET SUBIEN=$ORDER(^SDEC(409.832,GROUPIEN,1,SUBIEN))
if 'SUBIEN
QUIT
Begin DoDot:1
+11 SET RESOURCEIEN=$$GET1^DIQ(409.8321,SUBIEN_","_GROUPIEN_",",.01,"I")
+12 IF $$GET1^DIQ(409.831,RESOURCEIEN,.02)="YES"
QUIT
+13 SET RESOURCETYPE=$$GET1^DIQ(409.831,RESOURCEIEN,.012,"E")
+14 SET COUNT=COUNT+1
+15 ;
+16 SET GROUPDATA("RSGroup","Resources",COUNT,"IEN")=$PIECE($$GET1^DIQ(409.831,RESOURCEIEN,.012,"I"),";")
+17 SET GROUPDATA("RSGroup","Resources",COUNT,"Name")=$$GET1^DIQ(409.831,RESOURCEIEN,.01,"E")
+18 SET GROUPDATA("RSGroup","Resources",COUNT,"Type")=RESOURCETYPE
+19 ;
+20 IF RESOURCETYPE="PROVIDER"
Begin DoDot:2
+21 SET PROVIDERIEN=$PIECE($$GET1^DIQ(409.831,RESOURCEIEN,.012,"I"),";")
+22 SET CLINICIEN=0
SET PROVCLINCOUNT=0
+23 FOR
SET CLINICIEN=$ORDER(^SC("AVADPR",PROVIDERIEN,CLINICIEN))
if 'CLINICIEN
QUIT
Begin DoDot:3
+24 SET INACTIVE=$$INACTIVE^SDES2UTIL(CLINICIEN)
+25 if (+$GET(RESOURCEGROUP("INACTIVE CLINIC"))=0)&(INACTIVE)
QUIT
+26 SET PROVCLINCOUNT=PROVCLINCOUNT+1
+27 ;
+28 SET GROUPDATA("RSGroup","Resources",COUNT,"Provider",PROVCLINCOUNT,"AssociatedClinicIEN")=CLINICIEN
+29 SET GROUPDATA("RSGroup","Resources",COUNT,"Provider",PROVCLINCOUNT,"AssociatedClinicName")=$$GET1^DIQ(44,CLINICIEN,.01,"E")
+30 SET GROUPDATA("RSGroup","Resources",COUNT,"Provider",PROVCLINCOUNT,"AssociatedClinicStatus")=$SELECT($$INACTIVE^SDES2UTIL(CLINICIEN)=0:"Active",1:"Inactive")
End DoDot:3
+31 if PROVCLINCOUNT=0
SET GROUPDATA("RSGroup","Resources",COUNT,"Provider",1)=""
End DoDot:2
End DoDot:1
+32 QUIT
+33 ;