SDESRECCLINSRCH ;ALB/MGD - VISTA SCHEDULING RECALL CLINIC SEARCH RPC; Aug 24, 2022@15:04
;;5.3;Scheduling;**823**;Aug 13, 1993;Build 9
;;Per VHA Directive 6402, this routine should not be modified
;
Q
; RPC = SDES SEARCH RECALL CLINICS
SEARCHRECALLCLIN(JSONRETURN,SEARCHSTRING) ;Search for Recall clinics and provide return of matches in JSON STRING
; INPUT - SEARCHSTRING = free text string that represents the recall clinic name that will be searched
; OUTPUT - JSONRETURN
; List of Recall Clinics from the RECALL REMINDERS (#403.5) file with the following data.
; Field List:
; (1) Recall Clinic IEN
; (2) Recall Clinic Name
; (3) Recall Reminder IEN
;
N CLINICLIST,ERROREXISTS,ERRORLIST,CLINICRETURN,CLINICLIST
K JSONRETURN
S SEARCHSTRING=$G(SEARCHSTRING)
S ERROREXISTS=0
S ERROREXISTS=$$VALIDATEINPUT(.ERRORLIST,SEARCHSTRING)
I ERROREXISTS D BUILDJSON^SDESBUILDJSON(.JSONRETURN,.ERRORLIST) Q
D GETPROVLIST(SEARCHSTRING,.CLINICLIST)
D BUILDRETURN(.CLINICLIST,.CLINICRETURN)
D BUILDJSON^SDESBUILDJSON(.JSONRETURN,.CLINICRETURN)
Q
;
VALIDATEINPUT(ERRORLIST,SEARCHSTRING) ; validate incoming parameters
; input - ERRORLIST = passed in by reference, represents the errors that could be generated when validating the searchstring
; SEARCHSTRING = represents the name or partial name of the Recall Clinic
; returns 0 or 1
; 0 = no validation errors
; 1 = validation errors
S SEARCHSTRING=$TR(SEARCHSTRING,$C(13)_$C(10)_$C(9),"")
I ($L(SEARCHSTRING)<3)!($L(SEARCHSTRING)>35) D Q 1
. D ERRLOG^SDESJSON(.ERRORLIST,230)
. S ERRORLIST("Recall Clinic",1)=""
Q 0
;
GETPROVLIST(SEARCHSTRING,CLINICLIST) ; pull matching recall clinics using the first input parameter passed in by the RPC
; Input - SEARCHSTRING = string that represents the name of the recall clinic
; CLINICLIST = passed in by reference; represents the array that will be returned as output
; Output - CLINICLIST = list of recall clinic names, clinic IENs and the associated recall reminder IENs.
N RESULTS,SUB3
K CLINICLIST
S SUB3=0
D FIND^DIC(403.5,,"@;4.5",,SEARCHSTRING,,"E",,,"RESULTS")
F S SUB3=$O(RESULTS("DILIST",2,SUB3)) Q:SUB3="" D
. S CLINNAME=$G(RESULTS("DILIST","ID",SUB3,4.5))
. S CLINICLIST(CLINNAME,SUB3)=$G(RESULTS("DILIST",2,SUB3))
Q
;
BUILDRETURN(CLINICLIST,CLINICRETURN) ;Build return array with recall reminder clinic data
; input - CLINICLIST = array of recall clinics
; CLINICRETURN = passed by reference, represents the array of recall clinics and associated data that will be returned to the client
; output - CLINICRETURN = recall clinic array and their associated data to be sent back to the client
;
N CLINIEN,CLINNAME,RECIEN,RECCNT
S (CLINNAME,RECCNT)=0
F S CLINNAME=$O(CLINICLIST(CLINNAME)) Q:CLINNAME="" D
. S CLINIEN=$$FIND1^DIC(44,"","X",CLINNAME,"B","","ERROR")
. Q:'CLINIEN
. S RECIEN=0
. F S RECIEN=$O(CLINICLIST(CLINNAME,RECIEN)) Q:'RECIEN D
. . S CLINICRETURN("Recall Clinic",CLINNAME,RECIEN,"ClinicIEN")=CLINIEN
. . S CLINICRETURN("Recall Clinic",CLINNAME,RECIEN,"ClinicName")=CLINNAME
. . S CLINICRETURN("Recall Clinic",CLINNAME,RECIEN,"ClinicRecallIEN")=RECIEN
. . S RECCNT=RECCNT+1
I RECCNT=0 S CLINICRETURN("Recall Clinic",1)=""
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESRECCLINSRCH 3295 printed Dec 13, 2024@02:57:39 Page 2
SDESRECCLINSRCH ;ALB/MGD - VISTA SCHEDULING RECALL CLINIC SEARCH RPC; Aug 24, 2022@15:04
+1 ;;5.3;Scheduling;**823**;Aug 13, 1993;Build 9
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 QUIT
+5 ; RPC = SDES SEARCH RECALL CLINICS
SEARCHRECALLCLIN(JSONRETURN,SEARCHSTRING) ;Search for Recall clinics and provide return of matches in JSON STRING
+1 ; INPUT - SEARCHSTRING = free text string that represents the recall clinic name that will be searched
+2 ; OUTPUT - JSONRETURN
+3 ; List of Recall Clinics from the RECALL REMINDERS (#403.5) file with the following data.
+4 ; Field List:
+5 ; (1) Recall Clinic IEN
+6 ; (2) Recall Clinic Name
+7 ; (3) Recall Reminder IEN
+8 ;
+9 NEW CLINICLIST,ERROREXISTS,ERRORLIST,CLINICRETURN,CLINICLIST
+10 KILL JSONRETURN
+11 SET SEARCHSTRING=$GET(SEARCHSTRING)
+12 SET ERROREXISTS=0
+13 SET ERROREXISTS=$$VALIDATEINPUT(.ERRORLIST,SEARCHSTRING)
+14 IF ERROREXISTS
DO BUILDJSON^SDESBUILDJSON(.JSONRETURN,.ERRORLIST)
QUIT
+15 DO GETPROVLIST(SEARCHSTRING,.CLINICLIST)
+16 DO BUILDRETURN(.CLINICLIST,.CLINICRETURN)
+17 DO BUILDJSON^SDESBUILDJSON(.JSONRETURN,.CLINICRETURN)
+18 QUIT
+19 ;
VALIDATEINPUT(ERRORLIST,SEARCHSTRING) ; validate incoming parameters
+1 ; input - ERRORLIST = passed in by reference, represents the errors that could be generated when validating the searchstring
+2 ; SEARCHSTRING = represents the name or partial name of the Recall Clinic
+3 ; returns 0 or 1
+4 ; 0 = no validation errors
+5 ; 1 = validation errors
+6 SET SEARCHSTRING=$TRANSLATE(SEARCHSTRING,$CHAR(13)_$CHAR(10)_$CHAR(9),"")
+7 IF ($LENGTH(SEARCHSTRING)<3)!($LENGTH(SEARCHSTRING)>35)
Begin DoDot:1
+8 DO ERRLOG^SDESJSON(.ERRORLIST,230)
+9 SET ERRORLIST("Recall Clinic",1)=""
End DoDot:1
QUIT 1
+10 QUIT 0
+11 ;
GETPROVLIST(SEARCHSTRING,CLINICLIST) ; pull matching recall clinics using the first input parameter passed in by the RPC
+1 ; Input - SEARCHSTRING = string that represents the name of the recall clinic
+2 ; CLINICLIST = passed in by reference; represents the array that will be returned as output
+3 ; Output - CLINICLIST = list of recall clinic names, clinic IENs and the associated recall reminder IENs.
+4 NEW RESULTS,SUB3
+5 KILL CLINICLIST
+6 SET SUB3=0
+7 DO FIND^DIC(403.5,,"@;4.5",,SEARCHSTRING,,"E",,,"RESULTS")
+8 FOR
SET SUB3=$ORDER(RESULTS("DILIST",2,SUB3))
if SUB3=""
QUIT
Begin DoDot:1
+9 SET CLINNAME=$GET(RESULTS("DILIST","ID",SUB3,4.5))
+10 SET CLINICLIST(CLINNAME,SUB3)=$GET(RESULTS("DILIST",2,SUB3))
End DoDot:1
+11 QUIT
+12 ;
BUILDRETURN(CLINICLIST,CLINICRETURN) ;Build return array with recall reminder clinic data
+1 ; input - CLINICLIST = array of recall clinics
+2 ; CLINICRETURN = passed by reference, represents the array of recall clinics and associated data that will be returned to the client
+3 ; output - CLINICRETURN = recall clinic array and their associated data to be sent back to the client
+4 ;
+5 NEW CLINIEN,CLINNAME,RECIEN,RECCNT
+6 SET (CLINNAME,RECCNT)=0
+7 FOR
SET CLINNAME=$ORDER(CLINICLIST(CLINNAME))
if CLINNAME=""
QUIT
Begin DoDot:1
+8 SET CLINIEN=$$FIND1^DIC(44,"","X",CLINNAME,"B","","ERROR")
+9 if 'CLINIEN
QUIT
+10 SET RECIEN=0
+11 FOR
SET RECIEN=$ORDER(CLINICLIST(CLINNAME,RECIEN))
if 'RECIEN
QUIT
Begin DoDot:2
+12 SET CLINICRETURN("Recall Clinic",CLINNAME,RECIEN,"ClinicIEN")=CLINIEN
+13 SET CLINICRETURN("Recall Clinic",CLINNAME,RECIEN,"ClinicName")=CLINNAME
+14 SET CLINICRETURN("Recall Clinic",CLINNAME,RECIEN,"ClinicRecallIEN")=RECIEN
+15 SET RECCNT=RECCNT+1
End DoDot:2
End DoDot:1
+16 IF RECCNT=0
SET CLINICRETURN("Recall Clinic",1)=""
+17 QUIT