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

SDESRTNRG.m

Go to the documentation of this file.
SDESRTNRG ;ALB/ANU - VISTA SCHEDULING RPCS - ROUTINE SINGLE CLINIC GROUP RETURN ;Feb 20, 2023@14:21
 ;;5.3;Scheduling;**826,838**;Aug 13, 1993;Build 7
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 ;External References
 ;-------------------
 ; Reference to $$GETS^DIQ,$$GETS1^DIQ in ICR #2056
 ; Reference to $$TRIM^XLFSTR in ICR #10104
 ;
 Q
 ;
 ;
RTNRG(RETURNJSON,SDRGIEN) ;
 ;
 ; Input:
 ;    SDRGIEN    [Required] = SDEC RESOURCE GROUP IEN
 ;
 ; Output:
 ;    RETURNJSON = Returns SDEC RESOURCE GROUP (#409.832) - Group IEN^Inactivation Date^Group Name^Resources.
 ;
 N RETURN,HASFIELDS,ELGFIELDSARRAY,ELGRETURN
 N ISRGNAMEVALID
 S (RETURN,ELGFIELDSARRAY,HASFIELDS)=""
 ;
 S ISRGNAMEVALID=$$VALIDATERGIEN(.ERRORS,$G(SDRGIEN))
 ;
 I $D(ERRORS) M RETURN=ERRORS
 I '$D(ERRORS) S HASFIELDS=$$BLDRG(.ELGFIELDSARRAY,SDRGIEN)
 I HASFIELDS M RETURN=ELGFIELDSARRAY
 ;
 D BUILDJSON^SDESBUILDJSON(.RETURNJSON,.RETURN)
 D CLEANUP
 Q
 ;
VALIDATERGIEN(ERRORS,SDRGIEN) ; Validate Resource Group IEN
 N ERRORFLAG
 I SDRGIEN="" S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,312) Q $D(ERRORFLAG) ; Missing Resource Group IEN
 I SDRGIEN'="" I '$D(^SDEC(409.832,SDRGIEN,0)) S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,276) Q $D(ERRORFLAG) ; Invalid Resource Group ID
 Q $D(ERRORFLAG)
 ;
BLDRG(SDRGREC,SDRGIEN) ;Get SDEC Resource Group data
 ;
 N SDFIELDS,SDDATA,SDMSG,SDX,SDC,TIMEZONE,SDECI,HASDATA,SDESRES,SDRSTYPE,SDTYPR,SDRSPR,SDPRCLINS
 N CLINICIEN,COUNT
 S SDC=$G(SDC,0),SDX=""
 S SDFIELDS=".01;.02"
 D GETS^DIQ(409.832,SDRGIEN_",",SDFIELDS,"IE","SDDATA","SDMSG")
 ;S SDECI=SDECI+1
 S SDRGREC("RSGroup","IEN")=$G(SDRGIEN) ;Resource Group IEN
 S SDRGREC("RSGroup","Name")=$G(SDDATA(409.832,SDRGIEN_",",.01,"E")) ;Clinic Group Name
 S SDRGREC("RSGroup","Inactivation Date")=$$FMTISO^SDAMUTDT($G(SDDATA(409.832,SDRGIEN_",",.02,"I"))) ;Inactivate Date
 S SDFIELDS="1*"
 D GETS^DIQ(409.832,SDRGIEN_",",SDFIELDS,"IE","SDDATA","SDMSG")
 F  S SDX=$O(SDDATA(409.8321,SDX)) Q:$G(SDX)=""  D
 . S SDC=SDC+1
 . S SDESRES=$G(SDDATA(409.8321,SDX,.01,"I"))
 . I SDESRES="" Q
 . ; Do not include inactive entries
 . I $$GET1^DIQ(409.831,SDESRES_",",.02)="YES" Q
 . S SDTYPR=$$GET1^DIQ(409.831,SDESRES_",",.012,"I")
 . S SDRSTYPE=$S($P(SDTYPR,";",2)="SC(":"CLINIC",$P(SDTYPR,";",2)="VA(200,":"PROVIDER",$P(SDTYPR,";",2)="SDEC(409.834,":"ADDITIONAL RESOURCE",1:"")
 . S SDRGREC("RSGroup","Resources",SDC,"IEN")=$P(SDTYPR,";",1)
 . S SDRGREC("RSGroup","Resources",SDC,"Name")=$G(SDDATA(409.8321,SDX,.01,"E"))
 . S SDRGREC("RSGroup","Resources",SDC,"Type")=SDRSTYPE
 . I SDRSTYPE="PROVIDER" D
 . . S SDRSPR=$P(SDTYPR,";",1)
 . . S CLINICIEN=0,COUNT=0
 . . F  S CLINICIEN=$O(^SC("AVADPR",SDRSPR,CLINICIEN)) Q:'CLINICIEN  D
 . . . S COUNT=COUNT+1
 . . . S SDRGREC("RSGroup","Resources",SDC,"Provider",COUNT,"AssociatedClinicIEN")=CLINICIEN
 . . . S SDRGREC("RSGroup","Resources",SDC,"Provider",COUNT,"AssociatedClinicName")=$$GET1^DIQ(44,CLINICIEN,.01,"E")
 S HASDATA=($D(SDRGREC)>1)
 Q HASDATA
 ;
 Q 
 ;
CLEANUP ; kill vars
 K RETURN,HASFIELDS,ELGFIELDSARRAY,ELGRETURN,SDECI,ERRORS
 Q