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

SDESCLNGRP.m

Go to the documentation of this file.
SDESCLNGRP ;ALB/ANU - VISTA SCHEDULING RPCS - ROUTINE CLINIC GROUP LOOKUP ;Sept 9, 2022@14:21
 ;;5.3;Scheduling;**825**;Aug 13, 1993;Build 2
 ;;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
 ;
 ;
CLGRPLK(RETURNJSON,SRCHAR) ;
 ;
 ; Input:
 ;    SRCHAR        [Required] = Search string
 ;
 ; Output:
 ;    RETURNJSON = Returns list of SDEC RESOURCE GROUP (#409.832) - Group IEN^Group Name.
 ;
 N RETURN,HASFIELDS,ELGFIELDSARRAY,ELGRETURN
 N ISSRCHARVALID,SRCHARLEN
 S (RETURN,HASFIELDS)=""
 ;
 S ISSRCHARVALID=$$VALIDATESRCH(.ERRORS,$G(SRCHAR))
 ;
 I $D(ERRORS) M RETURN=ERRORS
 I '$D(ERRORS) S HASFIELDS=$$SEARCH(.ELGFIELDSARRAY,SRCHAR)
 I HASFIELDS M RETURN=ELGFIELDSARRAY
 ;
 D BUILDJSON^SDESBUILDJSON(.RETURNJSON,.RETURN)
 D CLEANUP
 Q
 ;
VALIDATESRCH(ERRORS,SRCHAR) ; Validate SEARCH STRING
 N ERRORFLAG
 I $TR(SRCHAR," ")="" S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,231) Q $D(ERRORFLAG)
 Q $D(ERRORFLAG)
 ;
 N INACTDT,COUNT,GRPIEN,GRPNAME,HASDATA,SDCHARLEN
 S COUNT=0
 S SRCHAR=$$TRIM^XLFSTR(SRCHAR)
 S SDCHARLEN=$L(SRCHAR)
 D CHKNAME
 S GRPNAME=$S($P(SRCHAR,"|",1)'="":$E($P(SRCHAR,"|",1),1,SDCHARLEN),1:"")
 F  S GRPNAME=$O(^SDEC(409.832,"B",GRPNAME)) Q:(GRPNAME="")!(GRPNAME'[SRCHAR)!($E(GRPNAME,1,SDCHARLEN)'=SRCHAR)  D
 . S GRPIEN=$O(^SDEC(409.832,"B",GRPNAME,""))
 . S INACTDT=$$GET1^DIQ(409.832,",",.02,"I") ;inactive date
 . Q:(INACTDT'="")&(INACTDT<DT)  ;Quit if inactive
 . S COUNT=COUNT+1
 . S ELGARRAY("ClinicGroup",COUNT,"IEN")=$G(GRPIEN) ;Clinic Group IEN
 . S ELGARRAY("ClinicGroup",COUNT,"Name")=$G(GRPNAME) ;Clinic Group Name
 I '$D(ELGARRAY) D
 .S ELGARRAY("ClinicGroup",1,"IEN")=""
 .S ELGARRAY("ClinicGroup",1,"Name")=""
 S HASDATA=($D(ELGARRAY)>1)
 Q HASDATA
 ;
CHKNAME ;
 S GRPIEN=$O(^SDEC(409.832,"B",SRCHAR,""))
 Q:GRPIEN=""
 S INACTDT=$$GET1^DIQ(409.832,",",.02,"I") ;inactive date
 Q:(INACTDT'="")&(INACTDT<DT)  ;Quit if inactive
 S GRPNAME=SRCHAR
 S COUNT=COUNT+1
 S ELGARRAY("ClinicGroup",COUNT,"IEN")=$G(GRPIEN) ;Clinic Group IEN
 S ELGARRAY("ClinicGroup",COUNT,"Name")=$G(GRPNAME) ;Clinic Group Name
 Q
 ;
CLEANUP ;
 K RETURNERROR,ERRORFLAG,ERRORS,ISSRCHARVALID
 K INACTDT,COUNT,GRPIEN,GRPNAME
 Q
 ;