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

SDES2SEARCHCLNAT.m

Go to the documentation of this file.
SDES2SEARCHCLNAT ;ALB/BLB - SDES2 SEARCH CLINIC ATTRIBUTES;Nov 3, 2023@8:11
 ;;5.3;Scheduling;**866**;Aug 13, 1993;Build 22
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 ; Reference to INSTITUTION in ICR #10090
 Q
 ;
 N SEARCHRESULTS,ERRORS
 ;
 D VALIDATE(.ERRORS,.SDCONTEXT,$G(SEARCH("SEARCHSTRING")),$G(SEARCH("STATION")),$G(SEARCH("DATETIME")),$G(SEARCH("RETURNACTIVE")),$G(SEARCH("LENGTH OF APPOINTMENT")))
 I $D(ERRORS) S ERRORS("Clinic",1)="" D BUILDJSON^SDESBUILDJSON(.JSON,.ERRORS) Q
 ;
 D SEARCHCLINICS(.SEARCHRESULTS,$G(SEARCH("SEARCHSTRING")),$S($G(SEARCH("DATETIME")):$$ISOTFM^SDAMUTDT(SEARCH("DATETIME")),1:DT),$G(SEARCH("STATION")),$G(SEARCH("LENGTH OF APPOINTMENT")),$G(SEARCH("RETURNACTIVE")))
 D BUILDJSON^SDESBUILDJSON(.JSON,.SEARCHRESULTS)
 Q
 ;
SEARCHCLINICS(SEARCHRESULTS,SEARCHSTRING,DATE,STATIONNUMBER,APPTLENGTH,ACTIVE) ;
 N CLINICIEN,CLINICIEN,COUNT,STRING2SEARCH
 ;
 I ACTIVE="" S ACTIVE=0
 ;
 S COUNT=0
 S STRING2SEARCH=$S($L($$GETSUB^SDES2UTIL(SEARCHSTRING)):$$GETSUB^SDES2UTIL(SEARCHSTRING),1:0)
 F  S STRING2SEARCH=$O(^SC("B",STRING2SEARCH)) Q:STRING2SEARCH=""!(STRING2SEARCH'[SEARCHSTRING)  D
 .S CLINICIEN=0
 .F  S CLINICIEN=$O(^SC("B",STRING2SEARCH,CLINICIEN)) Q:'CLINICIEN  D
 ..;
 ..; filter by active status
 ..I ACTIVE=0,$$INACTIVE^SDESUTIL(CLINICIEN,DATE) Q
 ..;
 ..; filter by station number
 ..I STATIONNUMBER'="",$$GET1^DIQ(4,$$GET1^DIQ(40.8,$$GET1^DIQ(44,CLINICIEN,3.5,"I"),.07,"I"),99,"I")'[STATIONNUMBER Q
 ..;
 ..; filter by appointment length
 ..I APPTLENGTH,APPTLENGTH'=$$GET1^DIQ(44,CLINICIEN,1912,"I") Q
 ..;
 ..S COUNT=COUNT+1
 ..D POPULATE(.SEARCHRESULTS,CLINICIEN,.COUNT)
 I '$D(SEARCHRESULTS("Clinic")) S SEARCHRESULTS("Clinic")=""
 Q
 ;
POPULATE(SEARCHRESULTS,CLINICIEN,COUNT) ;
 N CLINICATTRIBUTES,PROVIDERCOUNT,PROVIDERIEN,RESOURCETYPE,PROVIDERSUBIEN
 ;
 D GETS^DIQ(44,CLINICIEN_",",".01;1;8;16;60;2502;2503","IE","CLINICATTRIBUTES")
 ;
 S SEARCHRESULTS("Clinic",COUNT,"Abbreviation")=$G(CLINICATTRIBUTES(44,CLINICIEN_",",1,"E"))
 S SEARCHRESULTS("Clinic",COUNT,"ClinicIEN")=CLINICIEN
 S SEARCHRESULTS("Clinic",COUNT,"ClinicAppointmentLength")=$$GET1^DIQ(44,CLINICIEN,1912,"I")
 S SEARCHRESULTS("Clinic",COUNT,"ClinicName")=$G(CLINICATTRIBUTES(44,CLINICIEN_",",.01,"E"))
 S SEARCHRESULTS("Clinic",COUNT,"ClinicStatus")=$S($$INACTIVE^SDESUTIL(CLINICIEN,DATE)=1:"Inactive",1:"Active")
 S SEARCHRESULTS("Clinic",COUNT,"CreditStopCodeIEN")=$G(CLINICATTRIBUTES(44,CLINICIEN_",",2503,"I"))
 S SEARCHRESULTS("Clinic",COUNT,"CreditStopCodeName")=$G(CLINICATTRIBUTES(44,CLINICIEN_",",2503,"E"))
 S SEARCHRESULTS("Clinic",COUNT,"CreditStopCodeAMIS")=$$GET1^DIQ(40.7,$G(CLINICATTRIBUTES(44,CLINICIEN_",",2503,"I")),1,"I")
 S SEARCHRESULTS("Clinic",COUNT,"PatientFriendlyName")=$G(CLINICATTRIBUTES(44,CLINICIEN_",",60,"E"))
 S SEARCHRESULTS("Clinic",COUNT,"StopCodeIEN")=$G(CLINICATTRIBUTES(44,CLINICIEN_",",8,"I"))
 S SEARCHRESULTS("Clinic",COUNT,"StopCodeName")=$G(CLINICATTRIBUTES(44,CLINICIEN_",",8,"E"))
 S SEARCHRESULTS("Clinic",COUNT,"StopCodeAMIS")=$$GET1^DIQ(40.7,$G(CLINICATTRIBUTES(44,CLINICIEN_",",8,"I")),1,"I")
 S SEARCHRESULTS("Clinic",COUNT,"NonCountClinic")=$G(CLINICATTRIBUTES(44,CLINICIEN_",",2502,"E"))
 S SEARCHRESULTS("Clinic",COUNT,"DefaultProviderIEN")=""
 S SEARCHRESULTS("Clinic",COUNT,"DefaultProviderName")=""
 S SEARCHRESULTS("Clinic",COUNT,"DefaultProviderSecID")=""
 ;
 S PROVIDERSUBIEN=0,PROVIDERCOUNT=0
 F  S PROVIDERSUBIEN=$O(^SC(CLINICIEN,"PR",PROVIDERSUBIEN)) Q:'PROVIDERSUBIEN  D
 .S PROVIDERIEN=$$GET1^DIQ(44.1,PROVIDERSUBIEN_","_CLINICIEN_",",.01,"I")
 .;
 .I $$GET1^DIQ(44.1,PROVIDERSUBIEN_","_CLINICIEN_",",.02,"I") D  Q
 ..S SEARCHRESULTS("Clinic",COUNT,"DefaultProviderIEN")=PROVIDERIEN
 ..S SEARCHRESULTS("Clinic",COUNT,"DefaultProviderName")=$$GET1^DIQ(200,PROVIDERIEN,.01,"E")
 ..S SEARCHRESULTS("Clinic",COUNT,"DefaultProviderSecID")=$$GET1^DIQ(200,PROVIDERIEN,205.1,"I")
 .;
 .S PROVIDERCOUNT=PROVIDERCOUNT+1
 .S SEARCHRESULTS("Clinic",COUNT,"Providers",PROVIDERCOUNT,"ID")=PROVIDERIEN
 .S SEARCHRESULTS("Clinic",COUNT,"Providers",PROVIDERCOUNT,"Name")=$$GET1^DIQ(200,PROVIDERIEN,.01,"E")
 .S SEARCHRESULTS("Clinic",COUNT,"Providers",PROVIDERCOUNT,"SecID")=$$GET1^DIQ(200,PROVIDERIEN,205.1,"I")
 ; set empty object if no records are found
 I '$D(SEARCHRESULTS("Clinic",COUNT,"Providers")) S SEARCHRESULTS("Clinic",COUNT,"Providers",1)=""
 Q
 ;
VALIDATE(ERRORS,SDCONTEXT,SEARCHSTRING,STATIONNUMBER,DATE,ACTIVE,APPTLENGTH) ;
 ;
 D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT) I $D(ERRORS) Q
 ;
 I APPTLENGTH D
 .I APPTLENGTH<10!(APPTLENGTH>240) D ERRLOG^SDESJSON(.ERRORS,116) Q
 .I APPTLENGTH#15'=0,(APPTLENGTH#10'=0) D ERRLOG^SDESJSON(.ERRORS,116) Q
 ;
 I ($L(SEARCHSTRING)<2)!($L(SEARCHSTRING)>30) D ERRLOG^SDESJSON(.ERRORS,473) Q
 ;
 I STATIONNUMBER'="",'$D(^DIC(4,"D",STATIONNUMBER)) D ERRLOG^SDESJSON(.ERRORS,197) Q
 ;
 I DATE'="" S DATE=$$ISOTFM^SDAMUTDT(DATE) I DATE=-1 D ERRLOG^SDESJSON(.ERRORS,244) Q
 ;
 I ACTIVE'="",ACTIVE'=0,ACTIVE'=1 D ERRLOG^SDESJSON(.ERRORS,518)
 Q
 ;