Beispiel #1
0
        protected override IList <StaffGroup> GetItemsForExport(IReadContext context, int firstRow, int maxRows)
        {
            StaffGroupSearchCriteria where = new StaffGroupSearchCriteria();
            where.Name.SortAsc(0);

            return(context.GetBroker <IStaffGroupBroker>().Find(where, new SearchResultPage(firstRow, maxRows)));
        }
Beispiel #2
0
        public TextQueryResponse <StaffGroupSummary> TextQuery(StaffGroupTextQueryRequest request)
        {
            var broker    = PersistenceContext.GetBroker <IStaffGroupBroker>();
            var assembler = new StaffGroupAssembler();

            var helper = new TextQueryHelper <StaffGroup, StaffGroupSearchCriteria, StaffGroupSummary>(
                delegate
            {
                var rawQuery = request.TextQuery;

                // allow matching on name (assume entire query is a name which may contain spaces)
                var nameCriteria = new StaffGroupSearchCriteria();
                nameCriteria.Name.StartsWith(rawQuery);
                if (request.ElectiveGroupsOnly)
                {
                    nameCriteria.Elective.EqualTo(true);
                }

                return(new [] { nameCriteria });
            },
                assembler.CreateSummary,
                (criteria, threshold) => broker.Count(criteria) <= threshold,
                broker.Find);

            return(helper.Query(request));
        }
        public GetConversationEditorFormDataResponse GetConversationEditorFormData(
            GetConversationEditorFormDataRequest request)
        {
            var staffAssembler = new StaffAssembler();
            var groupAssembler = new StaffGroupAssembler();
            var response       = new GetConversationEditorFormDataResponse(
                CollectionUtils.Map(
                    this.CurrentUserStaff.ActiveGroups,                         // only active staff groups should be choices
                    (StaffGroup sg) => groupAssembler.CreateSummary(sg)));

            if (request.RecipientStaffIDs != null && request.RecipientStaffIDs.Count > 0)
            {
                var criteria = new StaffSearchCriteria();
                criteria.Id.In(request.RecipientStaffIDs);
                response.RecipientStaffs = CollectionUtils.Map(
                    PersistenceContext.GetBroker <IStaffBroker>().Find(criteria),
                    (Staff s) => staffAssembler.CreateStaffSummary(s, PersistenceContext));
            }

            if (request.RecipientStaffGroupNames != null && request.RecipientStaffGroupNames.Count > 0)
            {
                var criteria = new StaffGroupSearchCriteria();
                criteria.Name.In(request.RecipientStaffGroupNames);
                response.RecipientStaffGroups = CollectionUtils.Map(
                    PersistenceContext.GetBroker <IStaffGroupBroker>().Find(criteria),
                    (StaffGroup sg) => groupAssembler.CreateSummary(sg));
            }

            return(response);
        }
Beispiel #4
0
        public ListStaffGroupsResponse ListStaffGroups(ListStaffGroupsRequest request)
        {
            Platform.CheckForNullReference(request, "request");

        	var where = new StaffGroupSearchCriteria();
			where.Name.SortAsc(0);
			if (request.ElectiveGroupsOnly)
				where.Elective.EqualTo(true);
			if (!request.IncludeDeactivated)
				where.Deactivated.EqualTo(false);

            var broker = PersistenceContext.GetBroker<IStaffGroupBroker>();
			var items = broker.Find(where, request.Page);

            var assembler = new StaffGroupAssembler();
            return new ListStaffGroupsResponse(
                CollectionUtils.Map(items, (StaffGroup item) => assembler.CreateSummary(item))
                );
        }
Beispiel #5
0
        private StaffGroup LoadOrCreateGroup(string name, IPersistenceContext context)
        {
            StaffGroup group;

            try
            {
                StaffGroupSearchCriteria where = new StaffGroupSearchCriteria();
                where.Name.EqualTo(name);
                group = context.GetBroker <IStaffGroupBroker>().FindOne(where);
            }
            catch (EntityNotFoundException)
            {
                group      = new StaffGroup();
                group.Name = name;
                context.Lock(group, DirtyState.New);
            }

            return(group);
        }
        private static StaffGroup FindStaffGroup(string staffGroupName, IPersistenceContext context)
        {
            try
            {
                if (string.IsNullOrEmpty(staffGroupName))
                {
                    return(null);
                }

                StaffGroupSearchCriteria criteria = new StaffGroupSearchCriteria();
                criteria.Name.EqualTo(staffGroupName);

                IStaffGroupBroker broker = context.GetBroker <IStaffGroupBroker>();
                return(broker.FindOne(criteria));
            }
            catch (EntityNotFoundException)
            {
                return(null);
            }
        }
Beispiel #7
0
        public TextQueryResponse<StaffGroupSummary> TextQuery(StaffGroupTextQueryRequest request)
        {
            var broker = PersistenceContext.GetBroker<IStaffGroupBroker>();
            var assembler = new StaffGroupAssembler();

            var helper = new TextQueryHelper<StaffGroup, StaffGroupSearchCriteria, StaffGroupSummary>(
                    delegate
                    {
                        var rawQuery = request.TextQuery;

                        // allow matching on name (assume entire query is a name which may contain spaces)
                        var nameCriteria = new StaffGroupSearchCriteria();
                        nameCriteria.Name.StartsWith(rawQuery);
						if(request.ElectiveGroupsOnly)
							nameCriteria.Elective.EqualTo(true);

                        return new []{ nameCriteria };
                    },
                    assembler.CreateSummary,
                    (criteria, threshold) => broker.Count(criteria) <= threshold,
                    broker.Find);

            return helper.Query(request);
        }
Beispiel #8
0
        public ListStaffGroupsResponse ListStaffGroups(ListStaffGroupsRequest request)
        {
            Platform.CheckForNullReference(request, "request");

            var where = new StaffGroupSearchCriteria();
            where.Name.SortAsc(0);
            if (request.ElectiveGroupsOnly)
            {
                where.Elective.EqualTo(true);
            }
            if (!request.IncludeDeactivated)
            {
                where.Deactivated.EqualTo(false);
            }

            var broker = PersistenceContext.GetBroker <IStaffGroupBroker>();
            var items  = broker.Find(where, request.Page);

            var assembler = new StaffGroupAssembler();

            return(new ListStaffGroupsResponse(
                       CollectionUtils.Map(items, (StaffGroup item) => assembler.CreateSummary(item))
                       ));
        }
Beispiel #9
0
        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);
            }
        }