public long CountByVisitPractitioner(VisitSearchCriteria visitSearchCriteria, VisitPractitionerSearchCriteria practitionerSearchCriteria) { var query = GetBaseVisitPractitionerQuery(visitSearchCriteria, practitionerSearchCriteria); query.Selects.Add(new HqlSelect("count(*)")); return(ExecuteHqlUnique <long>(query)); }
/// <summary> /// All pertinent data other than the Profiles gets copied from otherPatient to thisPatient /// </summary> /// <param name="thisPatient"></param> /// <param name="otherPatient"></param> /// <param name="context"></param> static private void ReconnectRelatedPatientInformation(Patient thisPatient, Patient otherPatient, IPersistenceContext context) { foreach (PatientNote note in otherPatient.Notes) { thisPatient.AddNote(note); } OrderSearchCriteria orderCriteria = new OrderSearchCriteria(); orderCriteria.Patient.EqualTo(otherPatient); IList <Order> otherOrders = context.GetBroker <IOrderBroker>().Find(orderCriteria); foreach (Order order in otherOrders) { order.Patient = thisPatient; } VisitSearchCriteria visitCriteria = new VisitSearchCriteria(); visitCriteria.Patient.EqualTo(otherPatient); IList <Visit> otherVisits = context.GetBroker <IVisitBroker>().Find(visitCriteria); foreach (Visit visit in otherVisits) { visit.Patient = thisPatient; } // TODO: delete the otherPatient }
public IList <Visit> FindByVisitPractitioner(VisitSearchCriteria visitSearchCriteria, VisitPractitionerSearchCriteria practitionerSearchCriteria, SearchResultPage page) { var query = GetBaseVisitPractitionerQuery(visitSearchCriteria, practitionerSearchCriteria); query.Page = page; return(ExecuteHql <Visit>(query)); }
/// <summary> /// Applies this filter to the specified criteria object. /// </summary> /// <param name="criteria"></param> /// <param name="wqc"></param> public void Apply(VisitSearchCriteria criteria, IWorklistQueryContext wqc) { if (!this.IsEnabled) { return; } criteria.CurrentLocation.In(this.Values); }
private static HqlProjectionQuery GetBaseVisitPractitionerQuery(VisitSearchCriteria visitSearchCriteria, VisitPractitionerSearchCriteria practitionerSearchCriteria) { var hqlFrom = new HqlFrom(typeof(Visit).Name, "v"); hqlFrom.Joins.Add(new HqlJoin("v.Practitioners", "vp")); var query = new HqlProjectionQuery(hqlFrom); query.Conditions.AddRange(HqlCondition.FromSearchCriteria("vp", practitionerSearchCriteria)); query.Conditions.AddRange(HqlCondition.FromSearchCriteria("v", visitSearchCriteria)); return query; }
private static IList <Visit> GetVisitBatch(ExternalPractitioner practitioner, Action <VisitSearchCriteria> priorityFilter, int batchSize, IPersistenceContext context) { var visitsWhere = new VisitSearchCriteria(); priorityFilter(visitsWhere); var practitionersWhere = new VisitPractitionerSearchCriteria(); practitionersWhere.Practitioner.EqualTo(practitioner); return(context.GetBroker <IVisitBroker>().FindByVisitPractitioner(new VisitSearchCriteria(), practitionersWhere, new SearchResultPage(0, batchSize))); }
private static HqlProjectionQuery GetBaseVisitPractitionerQuery(VisitSearchCriteria visitSearchCriteria, VisitPractitionerSearchCriteria practitionerSearchCriteria) { var hqlFrom = new HqlFrom(typeof(Visit).Name, "v"); hqlFrom.Joins.Add(new HqlJoin("v.Practitioners", "vp")); var query = new HqlProjectionQuery(hqlFrom); query.Conditions.AddRange(HqlCondition.FromSearchCriteria("vp", practitionerSearchCriteria)); query.Conditions.AddRange(HqlCondition.FromSearchCriteria("v", visitSearchCriteria)); return(query); }
/// <summary> /// Reconciles the specified patient to this patient /// </summary> /// <param name="thisPatient"></param> /// <param name="otherPatient"></param> /// <param name="workflow"></param> private static void Reconcile(Patient thisPatient, Patient otherPatient, IWorkflow workflow) { if (PatientIdentifierConflictsFound(thisPatient, otherPatient)) throw new PatientReconciliationException("assigning authority conflict - cannot reconcile"); // copy the collection to iterate var otherProfiles = new List<PatientProfile>(otherPatient.Profiles); foreach (var profile in otherProfiles) { thisPatient.AddProfile(profile); } // copy the collection to iterate var otherNotes = new List<PatientNote>(otherPatient.Notes); foreach (var note in otherNotes) { thisPatient.AddNote(note); } // copy the collection to iterate var otherAttachments = new List<PatientAttachment>(otherPatient.Attachments); foreach (var attachment in otherAttachments) { otherPatient.Attachments.Remove(attachment); thisPatient.Attachments.Add(attachment); } // copy the collection to iterate var otherAllergies = new List<Allergy>(otherPatient.Allergies); foreach (var allergy in otherAllergies) { otherPatient.Allergies.Remove(allergy); thisPatient.Allergies.Add(allergy); } var visitCriteria = new VisitSearchCriteria(); visitCriteria.Patient.EqualTo(otherPatient); var otherVisits = workflow.GetBroker<IVisitBroker>().Find(visitCriteria); foreach (var visit in otherVisits) { visit.Patient = thisPatient; } var orderCriteria = new OrderSearchCriteria(); orderCriteria.Patient.EqualTo(otherPatient); var otherOrders = workflow.GetBroker<IOrderBroker>().Find(orderCriteria); foreach (var order in otherOrders) { order.Patient = thisPatient; } }
private void ValidateVisitsExist(Order order) { try { var visitSearchCriteria = new VisitSearchCriteria(); visitSearchCriteria.Patient.EqualTo(order.Patient); visitSearchCriteria.VisitNumber.AssigningAuthority.EqualTo(order.OrderingFacility.InformationAuthority); this.PersistenceContext.GetBroker <IVisitBroker>().FindOne(visitSearchCriteria); } catch (EntityNotFoundException) { throw new RequestValidationException( string.Format(SR.InvalidRequest_CannotEnterOrderWithoutVisits, order.OrderingFacility.InformationAuthority.Value)); } }
private void ValidateVisitsExist(Order order) { try { var visitSearchCriteria = new VisitSearchCriteria(); visitSearchCriteria.Patient.EqualTo(order.Patient); visitSearchCriteria.VisitNumber.AssigningAuthority.EqualTo(order.OrderingFacility.InformationAuthority); this.PersistenceContext.GetBroker <IVisitBroker>().FindOne(visitSearchCriteria); } catch (EntityNotFoundException) { throw new RequestValidationException( string.Format("The order cannot be entered because the patient does not have any visits at {0}.", order.OrderingFacility.InformationAuthority.Value)); } }
protected Visit GetVisit(PatientProfile patientProfile, Order order) { //if order originated from this authority, then just use visit in order if (_authority == order.OrderingFacility.InformationAuthority.Code) { return(order.Visit); } //otherwise, find appropriate visit var criteria = new VisitSearchCriteria(); criteria.Patient.EqualTo(order.Patient); criteria.AdmitTime.SortDesc(0); criteria.VisitNumber.AssigningAuthority.EqualTo(patientProfile.Mrn.AssigningAuthority); criteria.Status.In(new[] { VisitStatus.AA, VisitStatus.PD, VisitStatus.PA }); return(PersistenceScope.CurrentContext.GetBroker <IVisitBroker>().FindOne(criteria)); }
public ListVisitsForPatientResponse ListVisitsForPatient(ListVisitsForPatientRequest request) { Platform.CheckForNullReference(request, "request"); Platform.CheckMemberIsSet(request.PatientRef, "PatientRef"); var patient = this.PersistenceContext.GetBroker<IPatientBroker>().Load(request.PatientRef, EntityLoadFlags.Proxy); var criteria = new VisitSearchCriteria(); criteria.Patient.EqualTo(patient); criteria.AdmitTime.SortDesc(0); var assembler = new VisitAssembler(); return new ListVisitsForPatientResponse( CollectionUtils.Map<Visit, VisitSummary, List<VisitSummary>>( this.PersistenceContext.GetBroker<IVisitBroker>().Find(criteria), v => assembler.CreateVisitSummary(v, this.PersistenceContext))); }
public ListVisitsForPatientResponse ListVisitsForPatient(ListVisitsForPatientRequest request) { Patient patient = PersistenceContext.Load<Patient>(request.PatientRef); VisitSearchCriteria criteria = new VisitSearchCriteria(); criteria.Patient.EqualTo(patient); IList<Visit> visits = PersistenceContext.GetBroker<IVisitBroker>().Find(criteria); VisitAssembler assembler = new VisitAssembler(); ListVisitsForPatientResponse response = new ListVisitsForPatientResponse(); response.Visits = new List<VisitSummary>(); foreach (Visit v in visits) { response.Visits.Add(assembler.CreateVisitSummary(v, PersistenceContext)); } return response; }
public ListVisitsForPatientResponse ListVisitsForPatient(ListVisitsForPatientRequest request) { Platform.CheckForNullReference(request, "request"); Platform.CheckMemberIsSet(request.PatientRef, "PatientRef"); var patient = this.PersistenceContext.GetBroker <IPatientBroker>().Load(request.PatientRef, EntityLoadFlags.Proxy); var criteria = new VisitSearchCriteria(); criteria.Patient.EqualTo(patient); criteria.AdmitTime.SortDesc(0); var assembler = new VisitAssembler(); return(new ListVisitsForPatientResponse( CollectionUtils.Map <Visit, VisitSummary, List <VisitSummary> >( this.PersistenceContext.GetBroker <IVisitBroker>().Find(criteria), v => assembler.CreateVisitSummary(v, this.PersistenceContext)))); }
public ListVisitsForPatientResponse ListVisitsForPatient(ListVisitsForPatientRequest request) { Patient patient = PersistenceContext.Load <Patient>(request.PatientRef); VisitSearchCriteria criteria = new VisitSearchCriteria(); criteria.Patient.EqualTo(patient); IList <Visit> visits = PersistenceContext.GetBroker <IVisitBroker>().Find(criteria); VisitAssembler assembler = new VisitAssembler(); ListVisitsForPatientResponse response = new ListVisitsForPatientResponse(); response.Visits = new List <VisitSummary>(); foreach (Visit v in visits) { response.Visits.Add(assembler.CreateVisitSummary(v, PersistenceContext)); } return(response); }
public Visit GetVisit(string visitNumber, string assigningAuthority, bool createIfNotExist, out bool doneCreatedVisit) { doneCreatedVisit = false; Platform.CheckForEmptyString(visitNumber, "visitNumber"); Platform.CheckForEmptyString(assigningAuthority, "assigningAuthority"); var infoAuth = _persistenceContext.GetBroker <IEnumBroker>().TryFind <InformationAuthorityEnum>(assigningAuthority); Visit visit = null; var criteria = new VisitSearchCriteria(); criteria.VisitNumber.Id.EqualTo(visitNumber); criteria.VisitNumber.AssigningAuthority.EqualTo(infoAuth); try { visit = _persistenceContext.GetBroker <IVisitBroker>().FindOne(criteria); _visits.Add(new LockableEntity <Visit>(visit, DirtyState.Dirty)); //todo check that visit.Patient matches patient in _patients } catch (EntityNotFoundException) { if (createIfNotExist) { visit = new Visit(); _visits.Add(new LockableEntity <Visit>(visit, DirtyState.New)); visit.VisitNumber.Id = visitNumber; visit.VisitNumber.AssigningAuthority = infoAuth; // facility will be handled by location handler, and yet we can't leave facility null. //so, we simply pick any old facility for now visit.Facility = _persistenceContext.GetBroker <IFacilityBroker>().FindOne(new FacilitySearchCriteria()); doneCreatedVisit = true; } } return(visit); }
private ListVisitsResponse ListVisits(ListVisitsRequest request) { // hide visits if "visit workflow" is disabled var workflowConfig = new WorkflowConfigurationReader(); if (!workflowConfig.EnableVisitWorkflow) { return(null); } var browsePatientDataAssembler = new BrowsePatientDataAssembler(); var patient = this.PersistenceContext.Load <Patient>(request.PatientRef, EntityLoadFlags.Proxy); var where = new VisitSearchCriteria(); where.Patient.EqualTo(patient); var visits = this.PersistenceContext.GetBroker <IVisitBroker>().Find(where); return(new ListVisitsResponse( CollectionUtils.Map <Visit, VisitListItem>( visits, v => browsePatientDataAssembler.CreateVisitListItem(v, this.PersistenceContext)))); }
/// <summary> /// All pertinent data other than the Profiles gets copied from otherPatient to thisPatient /// </summary> /// <param name="thisPatient"></param> /// <param name="otherPatient"></param> /// <param name="context"></param> static private void ReconnectRelatedPatientInformation(Patient thisPatient, Patient otherPatient, IPersistenceContext context) { foreach (PatientNote note in otherPatient.Notes) { thisPatient.AddNote(note); } OrderSearchCriteria orderCriteria = new OrderSearchCriteria(); orderCriteria.Patient.EqualTo(otherPatient); IList<Order> otherOrders = context.GetBroker<IOrderBroker>().Find(orderCriteria); foreach (Order order in otherOrders) { order.Patient = thisPatient; } VisitSearchCriteria visitCriteria = new VisitSearchCriteria(); visitCriteria.Patient.EqualTo(otherPatient); IList<Visit> otherVisits = context.GetBroker<IVisitBroker>().Find(visitCriteria); foreach (Visit visit in otherVisits) { visit.Patient = thisPatient; } // TODO: delete the otherPatient }
private void ValidateVisitsExist(Order order) { try { var visitSearchCriteria = new VisitSearchCriteria(); visitSearchCriteria.Patient.EqualTo(order.Patient); visitSearchCriteria.VisitNumber.AssigningAuthority.EqualTo(order.OrderingFacility.InformationAuthority); this.PersistenceContext.GetBroker<IVisitBroker>().FindOne(visitSearchCriteria); } catch (EntityNotFoundException) { throw new RequestValidationException( string.Format(SR.InvalidRequest_CannotEnterOrderWithoutVisits, order.OrderingFacility.InformationAuthority.Value)); } }
private void ValidateVisitsExist(Order order) { try { var visitSearchCriteria = new VisitSearchCriteria(); visitSearchCriteria.Patient.EqualTo(order.Patient); visitSearchCriteria.VisitNumber.AssigningAuthority.EqualTo(order.OrderingFacility.InformationAuthority); this.PersistenceContext.GetBroker<IVisitBroker>().FindOne(visitSearchCriteria); } catch (EntityNotFoundException) { throw new RequestValidationException( string.Format("The order cannot be entered because the patient does not have any visits at {0}.", order.OrderingFacility.InformationAuthority.Value)); } }
private ListVisitsResponse ListVisits(ListVisitsRequest request) { // hide visits if "visit workflow" is disabled var workflowConfig = new WorkflowConfigurationReader(); if(!workflowConfig.EnableVisitWorkflow) return null; var browsePatientDataAssembler = new BrowsePatientDataAssembler(); var patient = this.PersistenceContext.Load<Patient>(request.PatientRef, EntityLoadFlags.Proxy); var where = new VisitSearchCriteria(); where.Patient.EqualTo(patient); var visits = this.PersistenceContext.GetBroker<IVisitBroker>().Find(where); return new ListVisitsResponse( CollectionUtils.Map<Visit, VisitListItem>( visits, v => browsePatientDataAssembler.CreateVisitListItem(v, this.PersistenceContext))); }
/// <summary> /// Reconciles the specified patient to this patient /// </summary> /// <param name="thisPatient"></param> /// <param name="otherPatient"></param> /// <param name="workflow"></param> private static void Reconcile(Patient thisPatient, Patient otherPatient, IWorkflow workflow) { if (PatientIdentifierConflictsFound(thisPatient, otherPatient)) { throw new PatientReconciliationException("assigning authority conflict - cannot reconcile"); } // copy the collection to iterate var otherProfiles = new List <PatientProfile>(otherPatient.Profiles); foreach (var profile in otherProfiles) { thisPatient.AddProfile(profile); } // copy the collection to iterate var otherNotes = new List <PatientNote>(otherPatient.Notes); foreach (var note in otherNotes) { thisPatient.AddNote(note); } // copy the collection to iterate var otherAttachments = new List <PatientAttachment>(otherPatient.Attachments); foreach (var attachment in otherAttachments) { otherPatient.Attachments.Remove(attachment); thisPatient.Attachments.Add(attachment); } // copy the collection to iterate var otherAllergies = new List <Allergy>(otherPatient.Allergies); foreach (var allergy in otherAllergies) { otherPatient.Allergies.Remove(allergy); thisPatient.Allergies.Add(allergy); } var visitCriteria = new VisitSearchCriteria(); visitCriteria.Patient.EqualTo(otherPatient); var otherVisits = workflow.GetBroker <IVisitBroker>().Find(visitCriteria); foreach (var visit in otherVisits) { visit.Patient = thisPatient; } var orderCriteria = new OrderSearchCriteria(); orderCriteria.Patient.EqualTo(otherPatient); var otherOrders = workflow.GetBroker <IOrderBroker>().Find(orderCriteria); foreach (var order in otherOrders) { order.Patient = thisPatient; } }
public static void All(VisitSearchCriteria visitsWhere) { // no filters }
public IList <Visit> FindByVisitPractitioner(VisitSearchCriteria visitSearchCriteria, VisitPractitionerSearchCriteria practitionerSearchCriteria) { return(FindByVisitPractitioner(visitSearchCriteria, practitionerSearchCriteria, new SearchResultPage())); }
public IList<Visit> FindByVisitPractitioner(VisitSearchCriteria visitSearchCriteria, VisitPractitionerSearchCriteria practitionerSearchCriteria) { return FindByVisitPractitioner(visitSearchCriteria, practitionerSearchCriteria, new SearchResultPage()); }
public IList<Visit> FindByVisitPractitioner(VisitSearchCriteria visitSearchCriteria, VisitPractitionerSearchCriteria practitionerSearchCriteria, SearchResultPage page) { var query = GetBaseVisitPractitionerQuery(visitSearchCriteria, practitionerSearchCriteria); query.Page = page; return ExecuteHql<Visit>(query); }
public long CountByVisitPractitioner(VisitSearchCriteria visitSearchCriteria, VisitPractitionerSearchCriteria practitionerSearchCriteria) { var query = GetBaseVisitPractitionerQuery(visitSearchCriteria, practitionerSearchCriteria); query.Selects.Add(new HqlSelect("count(*)")); return ExecuteHqlUnique<long>(query); }