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

SDES2GETRESGROUP.m

Go to the documentation of this file.
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
 ;