public TextQueryResponse <ProcedureTypeSummary> TextQuery(TextQueryRequest request) { var broker = PersistenceContext.GetBroker <IProcedureTypeBroker>(); var assembler = new ProcedureTypeAssembler(); var helper = new TextQueryHelper <ProcedureType, ProcedureTypeSearchCriteria, ProcedureTypeSummary>( delegate { var rawQuery = request.TextQuery; IList <string> terms = TextQueryHelper.ParseTerms(rawQuery); var criteria = new List <ProcedureTypeSearchCriteria>(); // allow matching on name (assume entire query is a name which may contain spaces) var nameCriteria = new ProcedureTypeSearchCriteria(); nameCriteria.Name.StartsWith(rawQuery); criteria.Add(nameCriteria); // allow matching of any term against ID criteria.AddRange(CollectionUtils.Map(terms, delegate(string term) { var c = new ProcedureTypeSearchCriteria(); c.Id.StartsWith(term); return(c); })); return(criteria.ToArray()); }, assembler.CreateSummary, (criteria, threshold) => broker.Count(criteria) <= threshold, broker.Find); return(helper.Query(request)); }
public void Search() { try { _profileTable.Items.Clear(); TextQueryResponse <PatientProfileSummary> response = null; Platform.GetService( delegate(IRegistrationWorkflowService service) { var request = new TextQueryRequest(); request.TextQuery = _searchString; request.SpecificityThreshold = PatientSearchComponentSettings.Default.SearchCriteriaSpecificityThreshold; response = service.PatientProfileTextQuery(request); }); if (response.TooManyMatches) { throw new WeakSearchCriteriaException(); } _profileTable.Items.AddRange(response.Matches); this.SelectedProfile = new Selection(_profileTable.Items.Count > 0 ? _profileTable.Items[0] : null); if (_profileTable.Items.Count == 0) { this.Host.DesktopWindow.ShowMessageBox(SR.MessageResultsNotFound, MessageBoxActions.Ok); } } catch (Exception e) { ExceptionHandler.Report(e, this.Host.DesktopWindow); } }
protected override WorklistItemSearchCriteria[] BuildCriteria(TextQueryRequest request) { var req = (WorklistItemTextQueryRequest)request; var criteria = new List <WorklistItemSearchCriteria>(); if ((_options & WorklistItemTextQueryOptions.PatientOrder) == WorklistItemTextQueryOptions.PatientOrder) { criteria.AddRange(BuildProcedureSearchCriteria(req)); } if ((_options & WorklistItemTextQueryOptions.ProcedureStepStaff) == WorklistItemTextQueryOptions.ProcedureStepStaff) { criteria.AddRange(BuildStaffSearchCriteria(req)); } // add constraint for downtime vs live procedures var downtimeRecoveryMode = (_options & WorklistItemTextQueryOptions.DowntimeRecovery) == WorklistItemTextQueryOptions.DowntimeRecovery; criteria.ForEach(c => c.Procedure.DowntimeRecoveryMode.EqualTo(downtimeRecoveryMode)); // this is a silly hack to append additional information (degenerate flags) into the criteria so that we can // pass them on to the TestSpecificity and DoQuery methods (didn't want to refactor the superclass) var augmented = CollectionUtils.Map <WorklistItemSearchCriteria, WorklistItemSearchCriteria>( criteria, c => new TextQueryCriteria(c, ShouldIncludeDegeneratePatientItems(req), ShouldIncludeDegenerateProcedureItems(req))); return(augmented.ToArray()); }
protected override bool ValidateRequest(TextQueryRequest request) { // if the UseAdvancedSearch flag is set, check if the Search fields are empty var req = (WorklistItemTextQueryRequest)request; if (req.UseAdvancedSearch) { return(req.SearchFields != null && !req.SearchFields.IsEmpty()); } // otherwise, do base behaviour (check text query) return(base.ValidateRequest(request)); }
protected override PatientProfileSearchCriteria[] BuildCriteria(TextQueryRequest request) { string query = request.TextQuery; // this will hold all criteria var criteria = new List <PatientProfileSearchCriteria>(); // build criteria against names PersonName[] names = ParsePersonNames(query); criteria.AddRange(CollectionUtils.Map(names, delegate(PersonName n) { var sc = new PatientProfileSearchCriteria(); sc.Name.FamilyName.StartsWith(n.FamilyName); if (n.GivenName != null) { sc.Name.GivenName.StartsWith(n.GivenName); } return(sc); })); // build criteria against Mrn identifiers string[] ids = ParseIdentifiers(query); criteria.AddRange(CollectionUtils.Map(ids, delegate(string word) { var c = new PatientProfileSearchCriteria(); c.Mrn.Id.StartsWith(word); return(c); })); // build criteria against Healthcard identifiers criteria.AddRange(CollectionUtils.Map(ids, delegate(string word) { var c = new PatientProfileSearchCriteria(); c.Healthcard.Id.StartsWith(word); return(c); })); // sort results by patient last name (add sort directive to first instance only, otherwise we get exceptions) foreach (var criterion in criteria.Take(1)) { criterion.Name.FamilyName.SortAsc(0); } return(criteria.ToArray()); }
protected override TextQueryResponse <ExternalPractitionerSummary> DoQuery(ExternalPractitionerSearchParams query, int specificityThreshold) { TextQueryResponse <ExternalPractitionerSummary> response = null; Platform.GetService( delegate(IExternalPractitionerAdminService service) { var request = new TextQueryRequest { TextQuery = query.TextSearch, SpecificityThreshold = specificityThreshold }; response = service.TextQuery(request); }); return(response); }
public TextQueryResponse <DiagnosticServiceSummary> TextQuery(TextQueryRequest request) { IDiagnosticServiceBroker broker = PersistenceContext.GetBroker <IDiagnosticServiceBroker>(); DiagnosticServiceAssembler assembler = new DiagnosticServiceAssembler(); TextQueryHelper <DiagnosticService, DiagnosticServiceSearchCriteria, DiagnosticServiceSummary> helper = new TextQueryHelper <DiagnosticService, DiagnosticServiceSearchCriteria, DiagnosticServiceSummary>( delegate { string rawQuery = request.TextQuery; IList <string> terms = TextQueryHelper.ParseTerms(rawQuery); List <DiagnosticServiceSearchCriteria> criteria = new List <DiagnosticServiceSearchCriteria>(); // allow matching on name (assume entire query is a name which may contain spaces) DiagnosticServiceSearchCriteria nameCriteria = new DiagnosticServiceSearchCriteria(); nameCriteria.Name.StartsWith(rawQuery); criteria.Add(nameCriteria); // allow matching of any term against ID criteria.AddRange(CollectionUtils.Map <string, DiagnosticServiceSearchCriteria>(terms, delegate(string term) { DiagnosticServiceSearchCriteria c = new DiagnosticServiceSearchCriteria(); c.Id.StartsWith(term); return(c); })); return(criteria.ToArray()); }, delegate(DiagnosticService ds) { return(assembler.CreateSummary(ds)); }, delegate(DiagnosticServiceSearchCriteria[] criteria, int threshold) { return(broker.Count(criteria) <= threshold); }, delegate(DiagnosticServiceSearchCriteria[] criteria, SearchResultPage page) { return(broker.Find(criteria, page)); }); return(helper.Query(request)); }
public TextQueryResponse <ExternalPractitionerSummary> TextQuery(TextQueryRequest request) { var broker = PersistenceContext.GetBroker <IExternalPractitionerBroker>(); var assembler = new ExternalPractitionerAssembler(); var helper = new TextQueryHelper <ExternalPractitioner, ExternalPractitionerSearchCriteria, ExternalPractitionerSummary>( delegate { var rawQuery = request.TextQuery; var criteria = new List <ExternalPractitionerSearchCriteria>(); // build criteria against names var names = TextQueryHelper.ParsePersonNames(rawQuery); criteria.AddRange(CollectionUtils.Map(names, delegate(PersonName n) { var sc = new ExternalPractitionerSearchCriteria(); sc.Name.FamilyName.StartsWith(n.FamilyName); if (n.GivenName != null) { sc.Name.GivenName.StartsWith(n.GivenName); } return(sc); })); // build criteria against identifiers var ids = TextQueryHelper.ParseIdentifiers(rawQuery); criteria.AddRange(CollectionUtils.Map(ids, delegate(string word) { var c = new ExternalPractitionerSearchCriteria(); c.LicenseNumber.StartsWith(word); return(c); })); return(criteria.ToArray()); }, prac => assembler.CreateExternalPractitionerSummary(prac, PersistenceContext), (criteria, threshold) => broker.Count(criteria) <= threshold, broker.Find); return(helper.Query(request)); }
private static PatientProfileSummary GetRandomPatient() { var queryString = string.Format("{0}, {1}", RandomUtils.GetRandomAlphaChar(), RandomUtils.GetRandomAlphaChar()); PatientProfileSummary randomProfile = null; Platform.GetService( delegate(IRegistrationWorkflowService service) { // Get only 10 patients var request = new TextQueryRequest { TextQuery = queryString, Page = new SearchResultPage(0, 10) }; var response = service.PatientProfileTextQuery(request); randomProfile = RandomUtils.ChooseRandom(response.Matches); }); return(randomProfile); }
public TextQueryResponse <PatientProfileSummary> PatientProfileTextQuery(TextQueryRequest request) { var helper = new PatientProfileTextQueryHelper(this.PersistenceContext); return(helper.Query(request)); }