Example #1
0
        private Facility FindFacility(string facilityCode, IPersistenceContext context)
        {
            var facilityCriteria = new FacilitySearchCriteria();

            facilityCriteria.Code.EqualTo(facilityCode);
            return(context.GetBroker <IFacilityBroker>().FindOne(facilityCriteria));
        }
Example #2
0
        protected override void Import(DepartmentData data, IUpdateContext context)
        {
            var facilityCriteria = new FacilitySearchCriteria();

            facilityCriteria.Code.EqualTo(data.FacilityCode);
            var facility = context.GetBroker <IFacilityBroker>().FindOne(facilityCriteria);

            var d = LoadOrCreateDepartment(data.Id, data.Name, facility, context);

            d.Deactivated = data.Deactivated;
            d.Description = data.Description;
        }
Example #3
0
		public ListAllFacilitiesResponse ListAllFacilities(ListAllFacilitiesRequest request)
		{
			var criteria = new FacilitySearchCriteria();
			criteria.Code.SortAsc(0);
			if (!request.IncludeDeactivated)
				criteria.Deactivated.EqualTo(false);

			var assembler = new FacilityAssembler();
			return new ListAllFacilitiesResponse(
				CollectionUtils.Map<Facility, FacilitySummary, List<FacilitySummary>>(
					PersistenceContext.GetBroker<IFacilityBroker>().Find(criteria, request.Page),
					assembler.CreateFacilitySummary));
		}
Example #4
0
        protected static Facility FindFacility(string facilityName, IPersistenceContext context)
        {
            var searchCriteria = new FacilitySearchCriteria();

            searchCriteria.Code.EqualTo(facilityName);
            searchCriteria.Deactivated.EqualTo(false);
            try
            {
                return(context.GetBroker <IFacilityBroker>().FindOne(searchCriteria));
            }
            catch (EntityNotFoundException)
            {
                throw new Exception(string.Format("Could not find facility {0}", facilityName));
            }
        }
Example #5
0
        /// <summary>
        /// Applies this filter to the specified criteria object.
        /// </summary>
        /// <param name="criteria"></param>
        /// <param name="wqc"></param>
        public void Apply(FacilitySearchCriteria criteria, IWorklistQueryContext wqc)
        {
            if (!this.IsEnabled)
            {
                return;
            }

            var values = new List <Facility>(this.Values);

            if (this.IncludeWorkingFacility)
            {
                values.Add(wqc.WorkingFacility);
            }
            criteria.In(values);
        }
        protected override void Import(LocationData data, IUpdateContext context)
        {
            var facilityCriteria = new FacilitySearchCriteria();

            facilityCriteria.Code.EqualTo(data.FacilityCode);
            var facility = context.GetBroker <IFacilityBroker>().FindOne(facilityCriteria);

            var location = LoadOrCreateLocation(data.Id, data.Name, facility, context);

            location.Deactivated = data.Deactivated;
            location.Description = data.Description;
            location.Building    = data.Building;
            location.Floor       = data.Floor;
            location.PointOfCare = data.PointOfCare;
        }
Example #7
0
        public ListAllFacilitiesResponse ListAllFacilities(ListAllFacilitiesRequest request)
        {
            var criteria = new FacilitySearchCriteria();

            criteria.Code.SortAsc(0);
            if (!request.IncludeDeactivated)
            {
                criteria.Deactivated.EqualTo(false);
            }

            var assembler = new FacilityAssembler();

            return(new ListAllFacilitiesResponse(
                       CollectionUtils.Map <Facility, FacilitySummary, List <FacilitySummary> >(
                           PersistenceContext.GetBroker <IFacilityBroker>().Find(criteria, request.Page),
                           assembler.CreateFacilitySummary)));
        }
Example #8
0
        public GetOrderEntryFormDataResponse GetOrderEntryFormData(GetOrderEntryFormDataRequest request)
        {
            Platform.CheckForNullReference(request, "request");

            // Sorted list of facility summaries for active facilities
            var facilityAssembler      = new FacilityAssembler();
            var facilitySearchCriteria = new FacilitySearchCriteria();

            facilitySearchCriteria.Deactivated.EqualTo(false);
            facilitySearchCriteria.Name.SortAsc(0);
            var facilities = CollectionUtils.Map(
                this.PersistenceContext.GetBroker <IFacilityBroker>().Find(facilitySearchCriteria),
                (Facility f) => facilityAssembler.CreateFacilitySummary(f));

            // Sorted list of department summaries for active departments
            var departmentAssembler      = new DepartmentAssembler();
            var departmentSearchCriteria = new DepartmentSearchCriteria();

            departmentSearchCriteria.Deactivated.EqualTo(false);
            departmentSearchCriteria.Name.SortAsc(0);
            var departments = CollectionUtils.Map(
                this.PersistenceContext.GetBroker <IDepartmentBroker>().Find(departmentSearchCriteria),
                (Department d) => departmentAssembler.CreateSummary(d, this.PersistenceContext));

            // Sorted list of department summaries for active departments
            var modalityAssembler      = new ModalityAssembler();
            var modalitySearchCriteria = new ModalitySearchCriteria();

            modalitySearchCriteria.Deactivated.EqualTo(false);
            modalitySearchCriteria.Name.SortAsc(0);
            var modalities = CollectionUtils.Map(
                this.PersistenceContext.GetBroker <IModalityBroker>().Find(modalitySearchCriteria),
                (Modality d) => modalityAssembler.CreateModalitySummary(d));

            return(new GetOrderEntryFormDataResponse(
                       facilities,
                       departments,
                       modalities,
                       EnumUtils.GetEnumValueList <OrderPriorityEnum>(this.PersistenceContext),
                       EnumUtils.GetEnumValueList <OrderCancelReasonEnum>(this.PersistenceContext),
                       EnumUtils.GetEnumValueList <LateralityEnum>(this.PersistenceContext),
                       EnumUtils.GetEnumValueList <SchedulingCodeEnum>(this.PersistenceContext)
                       ));
        }
Example #9
0
        /// <summary>
        /// Import external practitioner from CSV format.
        /// </summary>
        /// <param name="rows">
        /// Each string in the list must contain 4 CSV fields, as follows:
        ///     0 - Facility ID
        ///     1 - Facility Name
        ///     2 - Information Authority ID
        ///     3 - Information Authoirty Name
        /// </param>
        /// <param name="context"></param>
        public override void Import(List <string> rows, IUpdateContext context)
        {
            _enumBroker  = context.GetBroker <IEnumBroker>();
            _authorities = new List <InformationAuthorityEnum>(_enumBroker.Load <InformationAuthorityEnum>(true));

            List <Facility> facilities = new List <Facility>();

            foreach (string line in rows)
            {
                // expect 4 fields in the row
                string[] fields = ParseCsv(line, 4);

                string facilityId               = fields[0];
                string facilityName             = fields[1];
                string facilityDescription      = fields[2];
                string informationAuthorityId   = fields[3];
                string informationAuthorityName = fields[4];

                // first check if we have it in memory
                Facility facility = CollectionUtils.SelectFirst(facilities,
                                                                delegate(Facility f) { return(f.Code == facilityId && f.Name == facilityName); });

                // if not, check the database
                if (facility == null)
                {
                    FacilitySearchCriteria where = new FacilitySearchCriteria();
                    where.Code.EqualTo(facilityId);
                    where.Name.EqualTo(facilityName);

                    IFacilityBroker broker = context.GetBroker <IFacilityBroker>();
                    facility = CollectionUtils.FirstElement(broker.Find(where));

                    // if not, create a new instance
                    if (facility == null)
                    {
                        facility = new Facility(facilityId, facilityName, facilityDescription, GetAuthority(informationAuthorityId, informationAuthorityName));
                        context.Lock(facility, DirtyState.New);
                    }

                    facilities.Add(facility);
                }
            }
        }
Example #10
0
        /// <summary>
        /// Import external practitioner from CSV format.
        /// </summary>
        /// <param name="rows">
        /// Each string in the list must contain 4 CSV fields, as follows:
        ///     0 - Facility ID
        ///     1 - Facility Name
        ///     2 - Information Authority ID
        ///     3 - Information Authoirty Name
        /// </param>
        /// <param name="context"></param>
        public override void Import(List<string> rows, IUpdateContext context)
        {
            _enumBroker = context.GetBroker<IEnumBroker>();
            _authorities = new List<InformationAuthorityEnum>(_enumBroker.Load<InformationAuthorityEnum>(true));

            List<Facility> facilities = new List<Facility>();

            foreach (string line in rows)
            {
                // expect 4 fields in the row
                string[] fields = ParseCsv(line, 4);

                string facilityId = fields[0];
                string facilityName = fields[1];
				string facilityDescription = fields[2];
				string informationAuthorityId = fields[3];
                string informationAuthorityName = fields[4];

                // first check if we have it in memory
                Facility facility = CollectionUtils.SelectFirst(facilities,
                    delegate(Facility f) { return f.Code == facilityId && f.Name == facilityName; });

                // if not, check the database
                if (facility == null)
                {
                    FacilitySearchCriteria where = new FacilitySearchCriteria();
                    where.Code.EqualTo(facilityId);
                    where.Name.EqualTo(facilityName);

                    IFacilityBroker broker = context.GetBroker<IFacilityBroker>();
                    facility = CollectionUtils.FirstElement(broker.Find(where));

                    // if not, create a new instance
                    if (facility == null)
                    {
						facility = new Facility(facilityId, facilityName, facilityDescription, GetAuthority(informationAuthorityId, informationAuthorityName));
                        context.Lock(facility, DirtyState.New);
                    }

                    facilities.Add(facility);
                }
            }
        }
Example #11
0
        private static Facility LoadOrCreateFacility(string code, string name, string description, InformationAuthorityEnum ia, IPersistenceContext context)
        {
            Facility pt;

            try
            {
                // see if already exists in db
                var where = new FacilitySearchCriteria();
                where.Code.EqualTo(code);
                pt = context.GetBroker <IFacilityBroker>().FindOne(where);
            }
            catch (EntityNotFoundException)
            {
                // create it
                pt = new Facility(code, name, description, ia);
                context.Lock(pt, DirtyState.New);
            }

            return(pt);
        }
		public GetOrderEntryFormDataResponse GetOrderEntryFormData(GetOrderEntryFormDataRequest request)
		{
			Platform.CheckForNullReference(request, "request");

			// Sorted list of facility summaries for active facilities
			var facilityAssembler = new FacilityAssembler();
			var facilitySearchCriteria = new FacilitySearchCriteria();
			facilitySearchCriteria.Deactivated.EqualTo(false);
			facilitySearchCriteria.Name.SortAsc(0);
			var facilities = CollectionUtils.Map(
				this.PersistenceContext.GetBroker<IFacilityBroker>().Find(facilitySearchCriteria),
				(Facility f) => facilityAssembler.CreateFacilitySummary(f));

			// Sorted list of department summaries for active departments
			var departmentAssembler = new DepartmentAssembler();
			var departmentSearchCriteria = new DepartmentSearchCriteria();
			departmentSearchCriteria.Deactivated.EqualTo(false);
			departmentSearchCriteria.Name.SortAsc(0);
			var departments = CollectionUtils.Map(
				this.PersistenceContext.GetBroker<IDepartmentBroker>().Find(departmentSearchCriteria),
				(Department d) => departmentAssembler.CreateSummary(d, this.PersistenceContext));

			// Sorted list of department summaries for active departments
			var modalityAssembler = new ModalityAssembler();
			var modalitySearchCriteria = new ModalitySearchCriteria();
			modalitySearchCriteria.Deactivated.EqualTo(false);
			modalitySearchCriteria.Name.SortAsc(0);
			var modalities = CollectionUtils.Map(
				this.PersistenceContext.GetBroker<IModalityBroker>().Find(modalitySearchCriteria),
				(Modality d) => modalityAssembler.CreateModalitySummary(d));

			return new GetOrderEntryFormDataResponse(
				facilities,
				departments,
				modalities,
				EnumUtils.GetEnumValueList<OrderPriorityEnum>(this.PersistenceContext),
				EnumUtils.GetEnumValueList<OrderCancelReasonEnum>(this.PersistenceContext),
				EnumUtils.GetEnumValueList<LateralityEnum>(this.PersistenceContext),
				EnumUtils.GetEnumValueList<SchedulingCodeEnum>(this.PersistenceContext)
				);
		}
Example #13
0
 protected override IList <Facility> GetItemsForExport(IReadContext context, int firstRow, int maxRows)
 {
     var where = new FacilitySearchCriteria();
     where.Code.SortAsc(0);
     return(context.GetBroker <IFacilityBroker>().Find(where, new SearchResultPage(firstRow, maxRows)));
 }
Example #14
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);
            }
        }