protected override IList <Location> GetItemsForExport(IReadContext context, int firstRow, int maxRows) { var where = new LocationSearchCriteria(); where.Id.SortAsc(0); return(context.GetBroker <ILocationBroker>().Find(where, new SearchResultPage(firstRow, maxRows))); }
public ListAllLocationsResponse ListAllLocations(ListAllLocationsRequest request) { LocationSearchCriteria criteria = new LocationSearchCriteria(); criteria.Id.SortAsc(0); if (request.Facility != null) { criteria.Facility.EqualTo(PersistenceContext.Load <Facility>(request.Facility.FacilityRef)); } if (!string.IsNullOrEmpty(request.Name)) { criteria.Name.StartsWith(request.Name); } if (!request.IncludeDeactivated) { criteria.Deactivated.EqualTo(false); } LocationAssembler assembler = new LocationAssembler(); return(new ListAllLocationsResponse( CollectionUtils.Map <Location, LocationSummary, List <LocationSummary> >( PersistenceContext.GetBroker <ILocationBroker>().Find(criteria, request.Page), delegate(Location l) { return assembler.CreateLocationSummary(l); }))); }
public string GetLocationsByCity(string cityName, string userid) { ILocationService service = null; try { // Create search criteria. LocationSearchCriteria criteria = new LocationSearchCriteria(); criteria.City = cityName; // Create the service. service = AppService.Create <ILocationService>(); // TODO: Need to change. UserAuthentication authentication = new UserAuthentication(); service.AppManager = authentication.AppManager; // Call service method. List <Location> locations = service.Search(criteria, Convert.ToInt32(userid)); string locationsJson = "[]"; if (locations != null) { var resultList = from item in locations where item.IsActive = true select new { Id = item.Id, City = item.City, Country = item.Country }; // Serialize. JavaScriptSerializer serializer = new JavaScriptSerializer(); locationsJson = serializer.Serialize(resultList); } // Return the value. return(locationsJson); } catch { throw; } finally { // Dispose. if (service != null) { service.Dispose(); } } }
private Location LoadOrCreateLocation(string id, string name, Facility facility, IPersistenceContext context) { Location l; try { // see if already exists in db var where = new LocationSearchCriteria(); where.Id.EqualTo(id); l = context.GetBroker <ILocationBroker>().FindOne(where); } catch (EntityNotFoundException) { // create it l = new Location(id, name, null, facility, null, null, null); context.Lock(l, DirtyState.New); } return(l); }
public ListAllLocationsResponse ListAllLocations(ListAllLocationsRequest request) { LocationSearchCriteria criteria = new LocationSearchCriteria(); criteria.Id.SortAsc(0); if (request.Facility != null) criteria.Facility.EqualTo(PersistenceContext.Load<Facility>(request.Facility.FacilityRef)); if (!string.IsNullOrEmpty(request.Name)) criteria.Name.StartsWith(request.Name); if (!request.IncludeDeactivated) criteria.Deactivated.EqualTo(false); LocationAssembler assembler = new LocationAssembler(); return new ListAllLocationsResponse( CollectionUtils.Map<Location, LocationSummary, List<LocationSummary>>( PersistenceContext.GetBroker<ILocationBroker>().Find(criteria, request.Page), delegate(Location l) { return assembler.CreateLocationSummary(l); })); }
private Location FindLocation(PL patientLocation) { Location location; var locationName = patientLocation.PointOfCare.Value; var locationCriteria = new LocationSearchCriteria(); if (!string.IsNullOrEmpty(locationName)) { locationCriteria.Id.EqualTo(locationName); } locationCriteria.Deactivated.EqualTo(false); try { location = PersistenceContext.GetBroker <ILocationBroker>().FindOne(locationCriteria); } catch (EntityNotFoundException e) { location = HandleLocationNotFound(patientLocation, e); } return(location); }
public void Init() { instance = new LocationSearchCriteria(); }
protected override void Import(WorklistData data, IUpdateContext context) { var worklist = LoadOrCreateWorklist(data.Name, data.Class, context); worklist.Description = data.Description; if (data.StaffSubscribers != null) { foreach (var s in data.StaffSubscribers) { var criteria = new StaffSearchCriteria(); criteria.Id.EqualTo(s.StaffId); var staff = context.GetBroker <IStaffBroker>().Find(criteria); if (staff.Count == 1) { worklist.StaffSubscribers.Add(CollectionUtils.FirstElement(staff)); } } } if (data.GroupSubscribers != null) { foreach (var s in data.GroupSubscribers) { var criteria = new StaffGroupSearchCriteria(); criteria.Name.EqualTo(s.StaffGroupName); var groups = context.GetBroker <IStaffGroupBroker>().Find(criteria); if (groups.Count == 1) { worklist.GroupSubscribers.Add(CollectionUtils.FirstElement(groups)); } } } // proc type filter ImportFilter( worklist.ProcedureTypeFilter, data.Filters.ProcedureTypes, delegate(WorklistData.ProcedureTypeData s) { var criteria = new ProcedureTypeSearchCriteria(); criteria.Id.EqualTo(s.Id); var broker = context.GetBroker <IProcedureTypeBroker>(); return(CollectionUtils.FirstElement(broker.Find(criteria))); }); // proc type group filter ImportFilter( worklist.ProcedureTypeGroupFilter, data.Filters.ProcedureTypeGroups, delegate(WorklistData.ProcedureTypeGroupData s) { var criteria = new ProcedureTypeGroupSearchCriteria(); criteria.Name.EqualTo(s.Name); var broker = context.GetBroker <IProcedureTypeGroupBroker>(); return(CollectionUtils.FirstElement(broker.Find(criteria, ProcedureTypeGroup.GetSubClass(s.Class, context)))); }); //Bug #2284: don't forget to set the IncludeWorkingFacility property // facility filter worklist.FacilityFilter.IncludeWorkingFacility = data.Filters.Facilities.IncludeWorkingFacility; ImportFilter( worklist.FacilityFilter, data.Filters.Facilities, delegate(WorklistData.EnumValueData s) { var criteria = new FacilitySearchCriteria(); criteria.Code.EqualTo(s.Code); var broker = context.GetBroker <IFacilityBroker>(); return(CollectionUtils.FirstElement(broker.Find(criteria))); }); // department filter ImportFilter( worklist.DepartmentFilter, data.Filters.Departments, delegate(WorklistData.DepartmentData s) { var criteria = new DepartmentSearchCriteria(); criteria.Id.EqualTo(s.Id); var broker = context.GetBroker <IDepartmentBroker>(); return(CollectionUtils.FirstElement(broker.Find(criteria))); }); // priority filter ImportFilter( worklist.OrderPriorityFilter, data.Filters.OrderPriorities, delegate(WorklistData.EnumValueData s) { var broker = context.GetBroker <IEnumBroker>(); return(broker.Find <OrderPriorityEnum>(s.Code)); }); // ordering prac filter ImportFilter( worklist.OrderingPractitionerFilter, data.Filters.OrderingPractitioners, delegate(WorklistData.PractitionerData s) { var criteria = new ExternalPractitionerSearchCriteria(); criteria.Name.FamilyName.EqualTo(s.FamilyName); criteria.Name.GivenName.EqualTo(s.GivenName); // these criteria may not be provided (the data may not existed when exported), // but if available, they help to ensure the correct practitioner is being mapped if (!string.IsNullOrEmpty(s.BillingNumber)) { criteria.BillingNumber.EqualTo(s.BillingNumber); } if (!string.IsNullOrEmpty(s.LicenseNumber)) { criteria.LicenseNumber.EqualTo(s.LicenseNumber); } var broker = context.GetBroker <IExternalPractitionerBroker>(); return(CollectionUtils.FirstElement(broker.Find(criteria))); }); // patient class filter ImportFilter( worklist.PatientClassFilter, data.Filters.PatientClasses, delegate(WorklistData.EnumValueData s) { var broker = context.GetBroker <IEnumBroker>(); return(broker.Find <PatientClassEnum>(s.Code)); }); // patient location filter ImportFilter( worklist.PatientLocationFilter, data.Filters.PatientLocations, delegate(WorklistData.LocationData s) { var criteria = new LocationSearchCriteria(); criteria.Id.EqualTo(s.Id); var broker = context.GetBroker <ILocationBroker>(); return(CollectionUtils.FirstElement(broker.Find(criteria))); }); // portable filter worklist.PortableFilter.IsEnabled = data.Filters.Portable.Enabled; worklist.PortableFilter.Value = data.Filters.Portable.Value; //Bug #2429: don't forget to include the time filter // time filter worklist.TimeFilter.IsEnabled = data.Filters.TimeWindow.Enabled; worklist.TimeFilter.Value = data.Filters.TimeWindow == null || data.Filters.TimeWindow.Value == null ? null : data.Filters.TimeWindow.Value.CreateTimeRange(); // reporting filters if (Worklist.GetSupportsReportingStaffRoleFilter(worklist.GetClass())) { ImportReportingWorklistFilters(data, worklist.As <ReportingWorklist>(), context); } }