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

SDESSEARCHRCLN.m

Go to the documentation of this file.
SDESSEARCHRCLN ;ALB/LAB,BWF,JDJ - VISTA RPC SDES SEARCH RECALL CLINIC ;AUG 29,2024
 ;;5.3;Scheduling;**836,871,889**;Aug 13, 1993;Build 9
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 Q
 ;
CLINICSEARCH(CLINICLIST,SEARCHSTRING) ;Given a search string return a clinic list that matches.
 NEW ERRORS,RETURN,STRINGLENGTH,CLINICCOUNT,CLINICINFO,NUMSTR,CLINICFLIST,CLINICIEN
 D VALIDATESTR(.ERRORS,.SEARCHSTRING)
 I $D(ERRORS) M RETURN=ERRORS D BUILDJSON(.CLINICLIST,.RETURN) Q
 ;
 S CLINICIEN="",CLINICCOUNT=0
 S STRINGLENGTH=$L(SEARCHSTRING)
 S NUMSTR=(+SEARCHSTRING=SEARCHSTRING)
 D:NUMSTR NUMSEARCH(.CLINICINFO,SEARCHSTRING,STRINGLENGTH,.CLINICCOUNT,.CLINICFLIST)
 D:NUMSTR NUMABREVSEARCH(.CLINICINFO,SEARCHSTRING,STRINGLENGTH,.CLINICCOUNT,.CLINICFLIST)
 D:'NUMSTR ALPHASEARCH(.CLINICINFO,SEARCHSTRING,STRINGLENGTH,.CLINICCOUNT,.CLINICFLIST)
 D:'NUMSTR ABBREVSEARCH(.CLINICINFO,SEARCHSTRING,STRINGLENGTH,.CLINICCOUNT,.CLINICFLIST)
 I 'CLINICCOUNT S CLINICINFO("Clinic")=""
 D BUILDJSON(.CLINICLIST,.CLINICINFO)
 Q
 ;
ALPHASEARCH(CLINICINFO,SEARCHSTRING,STRINGLENGTH,CLINICCOUNT,CLINICFLIST) ;
 NEW CLINICIEN,CLINICNAME,INACTIVEDT,REACTIVEDT
 S CLINICNAME=$O(^SC("B",SEARCHSTRING),-1)
 I $E(CLINICNAME,1,STRINGLENGTH)=SEARCHSTRING D
 . S CLINICNAME=$O(^SC("B",CLINICNAME),-1)
 F  S CLINICNAME=$O(^SC("B",CLINICNAME)) Q:CLINICNAME=""!($E(CLINICNAME,1,STRINGLENGTH)'=SEARCHSTRING)  D
 . Q:(CLINICCOUNT>49)
 . S CLINICIEN=$O(^SC("B",CLINICNAME,""))
 . Q:('$O(^SD(403.52,"B",CLINICIEN,0)))
 . S INACTIVEDT=$$GET1^DIQ(44,CLINICIEN,2505,"I")
 . S REACTIVEDT=$$GET1^DIQ(44,CLINICIEN,2506,"I")
 . Q:((INACTIVEDT'="")&(INACTIVEDT<=DT))&(((REACTIVEDT'="")&(REACTIVEDT>DT))!(REACTIVEDT=""))  ;do not include inactive clinics
 . D BUILDCLININFO(.CLINICINFO,.CLINICIEN,.CLINICCOUNT,CLINICNAME,.CLINICFLIST)
 Q
 ;
ABBREVSEARCH(CLINICINFO,SEARCHSTRING,STRINGLENGTH,CLINICCOUNT,CLINICFLIST) ;
 NEW CLINICIEN,CLINICNAME,INACTIVEDT,REACTIVEDT,NEWSTRING
 I $L(SEARCHSTRING)=3,$E(SEARCHSTRING,3)=" " S NEWSTRING=$P(SEARCHSTRING," ",1),SEARCHSTRING=NEWSTRING
 S CLINICNAME=$O(^SC("C",SEARCHSTRING),-1)
 F  S CLINICNAME=$O(^SC("C",CLINICNAME)) Q:CLINICNAME=""!($E(CLINICNAME,1,STRINGLENGTH)'=SEARCHSTRING)  D
 . Q:(CLINICCOUNT>49)
 . S CLINICIEN=""
 . F  S CLINICIEN=$O(^SC("C",CLINICNAME,CLINICIEN)) Q:CLINICIEN=""  D
 . . Q:('$O(^SD(403.52,"B",CLINICIEN,0)))
 . . S INACTIVEDT=$$GET1^DIQ(44,CLINICIEN,2505,"I")
 . . S REACTIVEDT=$$GET1^DIQ(44,CLINICIEN,2506,"I")
 . . Q:((INACTIVEDT'="")&(INACTIVEDT<=DT))&(((REACTIVEDT'="")&(REACTIVEDT>DT))!(REACTIVEDT=""))  ;do not include inactive clinics
 . . D BUILDCLININFO(.CLINICINFO,.CLINICIEN,.CLINICCOUNT,CLINICNAME,.CLINICFLIST)
 Q
 ;
NUMSEARCH(CLINICINFO,SEARCHSTRING,STRINGLENGTH,CLINICCOUNT,CLINICFLIST) ;
 NEW CLINICIEN,CLINICNAME,INACTIVEDT,REACTIVEDT
 S CLINICNAME=SEARCHSTRING
 I $E(CLINICNAME,1,STRINGLENGTH)=SEARCHSTRING D
 . S CLINICNAME=$O(^SC("B",CLINICNAME),-1)
 F  S CLINICNAME=$O(^SC("B",CLINICNAME)) Q:CLINICNAME=""!($E(CLINICNAME,1,STRINGLENGTH)>SEARCHSTRING)  D
 . Q:$E(CLINICNAME,1,STRINGLENGTH)'=SEARCHSTRING
 . Q:(CLINICCOUNT>49)
 . S CLINICIEN=$O(^SC("B",CLINICNAME,""))
 . Q:('$O(^SD(403.52,"B",CLINICIEN,0)))
 . S INACTIVEDT=$$GET1^DIQ(44,CLINICIEN,2505,"I")
 . S REACTIVEDT=$$GET1^DIQ(44,CLINICIEN,2506,"I")
 . Q:((INACTIVEDT'="")&(INACTIVEDT<=DT))&(((REACTIVEDT'="")&(REACTIVEDT>DT))!(REACTIVEDT=""))  ;do not include inactive clinics
 . D BUILDCLININFO(.CLINICINFO,.CLINICIEN,.CLINICCOUNT,CLINICNAME,.CLINICFLIST)
 Q
 ;
NUMABREVSEARCH(CLINICINFO,SEARCHSTRING,STRINGLENGTH,CLINICCOUNT,CLINICFLIST) ;
 NEW CLINICIEN,CLINICNAME,INACTIVEDT,REACTIVEDT
 S CLINICNAME=SEARCHSTRING
 I $E(CLINICNAME,1,STRINGLENGTH)=SEARCHSTRING D
 . S CLINICNAME=$O(^SC("C",CLINICNAME),-1)
 F  S CLINICNAME=$O(^SC("C",CLINICNAME)) Q:CLINICNAME=""!($E(CLINICNAME,1,STRINGLENGTH)>SEARCHSTRING)  D
 . Q:$E(CLINICNAME,1,STRINGLENGTH)'=SEARCHSTRING
 . Q:(CLINICCOUNT>49)
 . S CLINICIEN=$O(^SC("C",CLINICNAME,""))
 . Q:('$O(^SD(403.52,"B",CLINICIEN,0)))
 . S INACTIVEDT=$$GET1^DIQ(44,CLINICIEN,2505,"I")
 . S REACTIVEDT=$$GET1^DIQ(44,CLINICIEN,2506,"I")
 . Q:((INACTIVEDT'="")&(INACTIVEDT<=DT))&(((REACTIVEDT'="")&(REACTIVEDT>DT))!(REACTIVEDT=""))  ;do not include inactive clinics
 . D BUILDCLININFO(.CLINICINFO,.CLINICIEN,.CLINICCOUNT,CLINICNAME,.CLINICFLIST)
 Q
 ;
BUILDCLININFO(CLINICINFO,CLINICIEN,CLINICCOUNT,CLINICNAME,CLINICFLIST) ;
 NEW STATUS,SDSTATUS,PRIMAMIS,SECONDAMIS,SDCLDATA
 Q:$D(CLINICFLIST(CLINICIEN))  ;only report on clinic once
 D GETS^DIQ(44,CLINICIEN,".01;1;8;200;2502;2503;60","IE","SDCLDATA")
 S STATUS=$$INACTIVE^SDESUTIL(CLINICIEN,DT)    ; Get status of clinic
 S SDSTATUS=$S(STATUS=0:"ACTIVE",1:"INACTIVE")
 S PRIMAMIS=$$STOPCODETOAMIS^SDESUTIL($G(SDCLDATA(44,CLINICIEN_",",8,"I")))        ; Get Primary AMIS Stop Code
 S SECONDAMIS=$$STOPCODETOAMIS^SDESUTIL($G(SDCLDATA(44,CLINICIEN_",",2503,"I")))   ; Get Secondary AMIS Stop Code
 S CLINICCOUNT=CLINICCOUNT+1
 S CLINICINFO("Clinic",CLINICCOUNT,"IEN")=CLINICIEN
 S CLINICINFO("Clinic",CLINICCOUNT,"Name")=$G(SDCLDATA(44,CLINICIEN_",",.01,"E"))
 S CLINICINFO("Clinic",CLINICCOUNT,"Abbreviation")=$G(SDCLDATA(44,CLINICIEN_",",1,"E"))
 S CLINICINFO("Clinic",CLINICCOUNT,"Status")=$G(SDSTATUS)
 S CLINICINFO("Clinic",CLINICCOUNT,"Non-CountClinic")=$G(SDCLDATA(44,CLINICIEN_",",2502,"E"))
 S CLINICINFO("Clinic",CLINICCOUNT,"PrimaryAMISStopCode")=PRIMAMIS
 S CLINICINFO("Clinic",CLINICCOUNT,"SecondaryAMISStopCode")=SECONDAMIS
 S CLINICINFO("Clinic",CLINICCOUNT,"PatientFriendlyName")=$G(SDCLDATA(44,CLINICIEN_",",60,"E"))
 S CLINICINFO("Clinic",CLINICCOUNT,"PbspID")=$G(SDCLDATA(44,CLINICIEN_",",200,"E"))
 S CLINICFLIST(CLINICIEN)=1
 Q
 ;
VALIDATESTR(ERRORS,SEARCHSTRING) ;
 I $G(SEARCHSTRING)="" D ERRLOG^SDESJSON(.ERRORS,231) Q
 I $L(SEARCHSTRING)<3!($L(SEARCHSTRING)>30) D ERRLOG^SDESJSON(.ERRORS,230) Q
 Q
 ;
BUILDJSON(JSONRETURN,RETURN) ;.
 N JSONERROR
 D ENCODE^XLFJSON("RETURN","JSONRETURN","JSONERR")
 Q
 ;