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)
;
SEARCH(ELGARRAY,SRCHAR) ; Look up Clinic Gruop
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
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESCLNGRP 2419 printed Nov 22, 2024@18:06:08 Page 2
SDESCLNGRP ;ALB/ANU - VISTA SCHEDULING RPCS - ROUTINE CLINIC GROUP LOOKUP ;Sept 9, 2022@14:21
+1 ;;5.3;Scheduling;**825**;Aug 13, 1993;Build 2
+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 ; Reference to $$TRIM^XLFSTR in ICR #10104
+8 ;
+9 QUIT
+10 ;
+11 ;
CLGRPLK(RETURNJSON,SRCHAR) ;
+1 ;
+2 ; Input:
+3 ; SRCHAR [Required] = Search string
+4 ;
+5 ; Output:
+6 ; RETURNJSON = Returns list of SDEC RESOURCE GROUP (#409.832) - Group IEN^Group Name.
+7 ;
+8 NEW RETURN,HASFIELDS,ELGFIELDSARRAY,ELGRETURN
+9 NEW ISSRCHARVALID,SRCHARLEN
+10 SET (RETURN,HASFIELDS)=""
+11 ;
+12 SET ISSRCHARVALID=$$VALIDATESRCH(.ERRORS,$GET(SRCHAR))
+13 ;
+14 IF $DATA(ERRORS)
MERGE RETURN=ERRORS
+15 IF '$DATA(ERRORS)
SET HASFIELDS=$$SEARCH(.ELGFIELDSARRAY,SRCHAR)
+16 IF HASFIELDS
MERGE RETURN=ELGFIELDSARRAY
+17 ;
+18 DO BUILDJSON^SDESBUILDJSON(.RETURNJSON,.RETURN)
+19 DO CLEANUP
+20 QUIT
+21 ;
VALIDATESRCH(ERRORS,SRCHAR) ; Validate SEARCH STRING
+1 NEW ERRORFLAG
+2 IF $TRANSLATE(SRCHAR," ")=""
SET ERRORFLAG=1
DO ERRLOG^SDESJSON(.ERRORS,231)
QUIT $DATA(ERRORFLAG)
+3 QUIT $DATA(ERRORFLAG)
+4 ;
SEARCH(ELGARRAY,SRCHAR) ; Look up Clinic Gruop
+1 NEW INACTDT,COUNT,GRPIEN,GRPNAME,HASDATA,SDCHARLEN
+2 SET COUNT=0
+3 SET SRCHAR=$$TRIM^XLFSTR(SRCHAR)
+4 SET SDCHARLEN=$LENGTH(SRCHAR)
+5 DO CHKNAME
+6 SET GRPNAME=$SELECT($PIECE(SRCHAR,"|",1)'="":$EXTRACT($PIECE(SRCHAR,"|",1),1,SDCHARLEN),1:"")
+7 FOR
SET GRPNAME=$ORDER(^SDEC(409.832,"B",GRPNAME))
if (GRPNAME="")!(GRPNAME'[SRCHAR)!($EXTRACT(GRPNAME,1,SDCHARLEN)'=SRCHAR)
QUIT
Begin DoDot:1
+8 SET GRPIEN=$ORDER(^SDEC(409.832,"B",GRPNAME,""))
+9 ;inactive date
SET INACTDT=$$GET1^DIQ(409.832,",",.02,"I")
+10 ;Quit if inactive
if (INACTDT'="")&(INACTDT<DT)
QUIT
+11 SET COUNT=COUNT+1
+12 ;Clinic Group IEN
SET ELGARRAY("ClinicGroup",COUNT,"IEN")=$GET(GRPIEN)
+13 ;Clinic Group Name
SET ELGARRAY("ClinicGroup",COUNT,"Name")=$GET(GRPNAME)
End DoDot:1
+14 IF '$DATA(ELGARRAY)
Begin DoDot:1
+15 SET ELGARRAY("ClinicGroup",1,"IEN")=""
+16 SET ELGARRAY("ClinicGroup",1,"Name")=""
End DoDot:1
+17 SET HASDATA=($DATA(ELGARRAY)>1)
+18 QUIT HASDATA
+19 ;
CHKNAME ;
+1 SET GRPIEN=$ORDER(^SDEC(409.832,"B",SRCHAR,""))
+2 if GRPIEN=""
QUIT
+3 ;inactive date
SET INACTDT=$$GET1^DIQ(409.832,",",.02,"I")
+4 ;Quit if inactive
if (INACTDT'="")&(INACTDT<DT)
QUIT
+5 SET GRPNAME=SRCHAR
+6 SET COUNT=COUNT+1
+7 ;Clinic Group IEN
SET ELGARRAY("ClinicGroup",COUNT,"IEN")=$GET(GRPIEN)
+8 ;Clinic Group Name
SET ELGARRAY("ClinicGroup",COUNT,"Name")=$GET(GRPNAME)
+9 QUIT
+10 ;
CLEANUP ;
+1 KILL RETURNERROR,ERRORFLAG,ERRORS,ISSRCHARVALID
+2 KILL INACTDT,COUNT,GRPIEN,GRPNAME
+3 QUIT
+4 ;