コード例 #1
0
        private long EstimateAffectedRecords(ExternalPractitionerContactPoint right, ExternalPractitionerContactPoint left)
        {
            var rightOrderCount = QueryOrders <long>(new[] { right }, PersistenceContext.GetBroker <IOrderBroker>().CountByResultRecipient);
            var leftOrderCount  = QueryOrders <long>(new[] { left }, PersistenceContext.GetBroker <IOrderBroker>().CountByResultRecipient);

            // number of contact point referneces that must be updated
            return(rightOrderCount + leftOrderCount);
        }
コード例 #2
0
        public LoadDepartmentEditorFormDataResponse LoadDepartmentEditorFormData(LoadDepartmentEditorFormDataRequest request)
        {
            var facilityAssembler = new FacilityAssembler();
            var facilities        = PersistenceContext.GetBroker <IFacilityBroker>().FindAll(false);

            return(new LoadDepartmentEditorFormDataResponse(
                       CollectionUtils.Map(facilities, (Facility f) => facilityAssembler.CreateFacilitySummary(f))));
        }
コード例 #3
0
        public ListAuthorityTokensResponse ListAuthorityTokens(ListAuthorityTokensRequest request)
        {
            var assembler       = new AuthorityTokenAssembler();
            var authorityTokens = CollectionUtils.Map(
                PersistenceContext.GetBroker <IAuthorityTokenBroker>().FindAll(),
                (AuthorityToken authorityToken) => assembler.GetAuthorityTokenSummary(authorityToken));

            return(new ListAuthorityTokensResponse(authorityTokens));
        }
コード例 #4
0
ファイル: PatientAdminService.cs プロジェクト: hksonngan/Xian
        public LoadPatientProfileForEditResponse LoadPatientProfileForEdit(LoadPatientProfileForEditRequest request)
        {
            var broker = PersistenceContext.GetBroker <IPatientProfileBroker>();

            var profile   = broker.Load(request.PatientProfileRef);
            var assembler = new PatientProfileAssembler();

            return(new LoadPatientProfileForEditResponse(profile.Patient.GetRef(), profile.GetRef(), assembler.CreatePatientProfileDetail(profile, PersistenceContext)));
        }
コード例 #5
0
        public ListEnumerationValuesResponse ListEnumerationValues(ListEnumerationValuesRequest request)
        {
            var enumBroker = PersistenceContext.GetBroker <IEnumBroker>();
            var enumValues = enumBroker.Load(GetEnumClass(request.AssemblyQualifiedClassName), request.IncludeDeactivated);

            return(new ListEnumerationValuesResponse(
                       CollectionUtils.Map(enumValues,
                                           (EnumValue value) => new EnumValueAdminInfo(value.Code, value.Value, value.Description, value.Deactivated))));
        }
コード例 #6
0
        public LoadVisitForEditResponse LoadVisitForEdit(LoadVisitForEditRequest request)
        {
            IVisitBroker broker = PersistenceContext.GetBroker <IVisitBroker>();

            Visit          visit     = broker.Load(request.VisitRef);
            VisitAssembler assembler = new VisitAssembler();

            return(new LoadVisitForEditResponse(visit.GetRef(), assembler.CreateVisitDetail(visit, PersistenceContext)));
        }
コード例 #7
0
        public ListWorklistsForUserResponse ListWorklistsForUser(ListWorklistsForUserRequest request)
        {
            var assembler = new WorklistAssembler();

            return(new ListWorklistsForUserResponse(
                       CollectionUtils.Map <Worklist, WorklistSummary>(
                           PersistenceContext.GetBroker <IWorklistBroker>().Find(CurrentUserStaff, request.WorklistTokens),
                           worklist => assembler.GetWorklistSummary(worklist, PersistenceContext))));
        }
コード例 #8
0
        public LoadProcedureTypeGroupForEditResponse LoadProcedureTypeGroupForEdit(
            LoadProcedureTypeGroupForEditRequest request)
        {
            var rptGroup  = PersistenceContext.GetBroker <IProcedureTypeGroupBroker>().Load(request.EntityRef);
            var assembler = new ProcedureTypeGroupAssembler();
            var detail    = assembler.GetProcedureTypeGroupDetail(rptGroup, this.PersistenceContext);

            return(new LoadProcedureTypeGroupForEditResponse(rptGroup.GetRef(), detail));
        }
コード例 #9
0
        public LoadModalityEditorFormDataResponse LoadModalityEditorFormData(LoadModalityEditorFormDataRequest request)
        {
            var facilityAssembler = new FacilityAssembler();

            return(new LoadModalityEditorFormDataResponse
            {
                FacilityChoices = PersistenceContext.GetBroker <IFacilityBroker>().FindAll(false).Select(facilityAssembler.CreateFacilitySummary).ToList(),
                DicomModalityChoices = EnumUtils.GetEnumValueList <DicomModalityEnum>(this.PersistenceContext)
            });
        }
コード例 #10
0
        public DeleteCannedTextResponse DeleteCannedText(DeleteCannedTextRequest request)
        {
            var cannedText = this.PersistenceContext.Load <CannedText>(request.CannedTextRef, EntityLoadFlags.Proxy);

            CheckCannedTextWriteAccess(cannedText);

            PersistenceContext.GetBroker <ICannedTextBroker>().Delete(cannedText);

            return(new DeleteCannedTextResponse());
        }
コード例 #11
0
        public ListEnumerationsResponse ListEnumerations(ListEnumerationsRequest request)
        {
            var broker      = PersistenceContext.GetBroker <IMetadataBroker>();
            var enumClasses = broker.ListEnumValueClasses();

            var enumerations = CollectionUtils.Map <Type, EnumerationSummary, List <EnumerationSummary> >(enumClasses,
                                                                                                          enumClass => new EnumerationSummary(enumClass.AssemblyQualifiedName, enumClass.Name, IsSoftEnum(enumClass)));

            return(new ListEnumerationsResponse(enumerations));
        }
コード例 #12
0
        public ListSettingsPropertiesResponse ListSettingsProperties(ListSettingsPropertiesRequest request)
        {
            Platform.CheckForNullReference(request, "request");
            Platform.CheckMemberIsSet(request.Group, "Group");

            var where = ConfigurationSettingsGroup.GetCriteria(request.Group);
            var broker = PersistenceContext.GetBroker <IConfigurationSettingsGroupBroker>();
            var group  = broker.FindOne(where);

            return(new ListSettingsPropertiesResponse(
                       CollectionUtils.Map(group.SettingsProperties, (ConfigurationSettingsProperty p) => p.GetDescriptor())));
        }
コード例 #13
0
        public GetLocationEditFormDataResponse GetLocationEditFormData(GetLocationEditFormDataRequest request)
        {
            FacilityAssembler assembler = new FacilityAssembler();

            return(new GetLocationEditFormDataResponse(
                       CollectionUtils.Map <Facility, FacilitySummary, List <FacilitySummary> >(
                           PersistenceContext.GetBroker <IFacilityBroker>().FindAll(false),
                           delegate(Facility f)
            {
                return assembler.CreateFacilitySummary(f);
            })));
        }
コード例 #14
0
        /// <summary>
        /// Perform clean-up of any expired sessions that may be left over for the specified user.
        /// </summary>
        /// <param name="user"></param>
        private void CleanExpiredSessions(User user)
        {
            var expiredSessions = user.TerminateExpiredSessions();

            // delete the session objects
            var broker = PersistenceContext.GetBroker <IUserSessionBroker>();

            foreach (var session in expiredSessions)
            {
                broker.Delete(session);
            }
        }
コード例 #15
0
        public LoadProcedureTypeEditorFormDataResponse LoadProcedureTypeEditorFormData(LoadProcedureTypeEditorFormDataRequest request)
        {
            var where = new ModalitySearchCriteria();
            where.Name.SortAsc(0);
            where.Deactivated.EqualTo(false);

            var modalities = PersistenceContext.GetBroker <IModalityBroker>().Find(where);

            var assembler = new ModalityAssembler();

            return(new LoadProcedureTypeEditorFormDataResponse(modalities.Select(assembler.CreateModalitySummary).ToList()));
        }
コード例 #16
0
        public GetWorkingFacilityChoicesResponse GetWorkingFacilityChoices(GetWorkingFacilityChoicesRequest request)
        {
            // load all facilities and sort by code
            var facilities = PersistenceContext.GetBroker <IFacilityBroker>().FindAll(false);

            facilities = facilities.OrderBy(x => x.Code).ToList();

            var facilityAssembler = new FacilityAssembler();

            return(new GetWorkingFacilityChoicesResponse(
                       CollectionUtils.Map(facilities,
                                           (Facility input) => facilityAssembler.CreateFacilitySummary(input))));
        }
コード例 #17
0
ファイル: StaffAdminService.cs プロジェクト: hksonngan/Xian
        public LoadStaffEditorFormDataResponse LoadStaffEditorFormData(LoadStaffEditorFormDataRequest request)
        {
            var groupAssember = new StaffGroupAssembler();

            return(new LoadStaffEditorFormDataResponse(
                       EnumUtils.GetEnumValueList <StaffTypeEnum>(this.PersistenceContext),
                       EnumUtils.GetEnumValueList <SexEnum>(this.PersistenceContext),
                       (new SimplifiedPhoneTypeAssembler()).GetPatientPhoneTypeChoices(),
                       EnumUtils.GetEnumValueList <AddressTypeEnum>(PersistenceContext),
                       CollectionUtils.Map(PersistenceContext.GetBroker <IStaffGroupBroker>().FindAll(false),
                                           (StaffGroup group) => groupAssember.CreateSummary(group))
                       ));
        }
コード例 #18
0
        public GetAuthorizationsResponse GetAuthorizations(GetAuthorizationsRequest request)
        {
            Platform.CheckForNullReference(request, "request");
            Platform.CheckMemberIsSet(request.UserName, "UserName");

            //TODO: ideally we should validate the username and session token and check session expiry
            //this would ensure that only a user with a valid session could obtain his authorizations,
            //however, there is an issue in the RIS right now that prevents the session token from being passed
            // in the request... this is a WCF architecture question that needs to be resolved

            var tokens = PersistenceContext.GetBroker <IAuthorityTokenBroker>().FindTokensByUserName(request.UserName);

            return(new GetAuthorizationsResponse(tokens));
        }
コード例 #19
0
        private long EstimateAffectedRecords(ExternalPractitioner right, ExternalPractitioner left)
        {
            var rightOrderCount = QueryOrders <long>(right.ContactPoints, PersistenceContext.GetBroker <IOrderBroker>().CountByResultRecipient);
            var rightVisitCount = QueryVisits <long>(right, PersistenceContext.GetBroker <IVisitBroker>().CountByVisitPractitioner);
            var leftOrderCount  = QueryOrders <long>(left.ContactPoints, PersistenceContext.GetBroker <IOrderBroker>().CountByResultRecipient);
            var leftVisitCount  = QueryVisits <long>(left, PersistenceContext.GetBroker <IVisitBroker>().CountByVisitPractitioner);

            // total number of references
            var r = rightOrderCount + rightVisitCount;
            var l = leftOrderCount + leftVisitCount;

            // the cost is measured in terms of the total number of references that must be updated
            return(r + l);
        }
コード例 #20
0
        public LoadDiagnosticServiceEditorFormDataResponse LoadDiagnosticServiceEditorFormData(LoadDiagnosticServiceEditorFormDataRequest request)
        {
            ProcedureTypeSearchCriteria where = new ProcedureTypeSearchCriteria();
            where.Id.SortAsc(0);
            where.Deactivated.EqualTo(false);

            IList <ProcedureType> procTypes = PersistenceContext.GetBroker <IProcedureTypeBroker>().Find(where);

            ProcedureTypeAssembler assembler = new ProcedureTypeAssembler();

            return(new LoadDiagnosticServiceEditorFormDataResponse(
                       CollectionUtils.Map <ProcedureType, ProcedureTypeSummary>(procTypes,
                                                                                 delegate(ProcedureType pt) { return assembler.CreateSummary(pt); })));
        }
コード例 #21
0
        private User FindUserByName(string name)
        {
            try
            {
                var where = new UserSearchCriteria();
                where.UserName.EqualTo(name);

                return(PersistenceContext.GetBroker <IUserBroker>().FindOne(where));
            }
            catch (EntityNotFoundException)
            {
                throw new RequestValidationException(string.Format("{0} is not a valid user name.", name));
            }
        }
コード例 #22
0
 public DeleteNoteCategoryResponse DeleteNoteCategory(DeleteNoteCategoryRequest request)
 {
     try
     {
         IPatientNoteCategoryBroker broker = PersistenceContext.GetBroker <IPatientNoteCategoryBroker>();
         PatientNoteCategory        item   = broker.Load(request.NoteCategoryRef, EntityLoadFlags.Proxy);
         broker.Delete(item);
         PersistenceContext.SynchState();
         return(new DeleteNoteCategoryResponse());
     }
     catch (PersistenceException)
     {
         throw new RequestValidationException(string.Format(SR.ExceptionFailedToDelete, TerminologyTranslator.Translate(typeof(PatientNoteCategory))));
     }
 }
コード例 #23
0
        public CheckInProcedureResponse CheckInProcedure(CheckInProcedureRequest request)
        {
            var broker = PersistenceContext.GetBroker <IProcedureBroker>();
            var op     = new Operations.CheckIn();

            foreach (var procedureRef in request.Procedures)
            {
                var procedure = broker.Load(procedureRef, EntityLoadFlags.CheckVersion);
                op.Execute(procedure, this.CurrentUserStaff, request.CheckInTime, new PersistentWorkflow(this.PersistenceContext));

                LogicalHL7Event.ProcedureModified.EnqueueEvents(procedure);
            }

            return(new CheckInProcedureResponse());
        }
コード例 #24
0
 public DeleteExternalPractitionerResponse DeleteExternalPractitioner(DeleteExternalPractitionerRequest request)
 {
     try
     {
         var broker       = PersistenceContext.GetBroker <IExternalPractitionerBroker>();
         var practitioner = broker.Load(request.PractitionerRef, EntityLoadFlags.Proxy);
         broker.Delete(practitioner);
         PersistenceContext.SynchState();
         return(new DeleteExternalPractitionerResponse());
     }
     catch (PersistenceException)
     {
         throw new RequestValidationException(string.Format(SR.ExceptionFailedToDelete, TerminologyTranslator.Translate(typeof(ExternalPractitioner))));
     }
 }
コード例 #25
0
 public DeleteProcedureTypeResponse DeleteProcedureType(DeleteProcedureTypeRequest request)
 {
     try
     {
         var broker = PersistenceContext.GetBroker <IProcedureTypeBroker>();
         var item   = broker.Load(request.ProcedureTypeRef, EntityLoadFlags.Proxy);
         broker.Delete(item);
         PersistenceContext.SynchState();
         return(new DeleteProcedureTypeResponse());
     }
     catch (PersistenceException)
     {
         throw new RequestValidationException(string.Format(SR.ExceptionFailedToDelete, TerminologyTranslator.Translate(typeof(ProcedureType))));
     }
 }
コード例 #26
0
ファイル: StaffAdminService.cs プロジェクト: hksonngan/Xian
        public TextQueryResponse <StaffSummary> TextQuery(StaffTextQueryRequest request)
        {
            var broker    = PersistenceContext.GetBroker <IStaffBroker>();
            var assembler = new StaffAssembler();

            var helper = new TextQueryHelper <Staff, StaffSearchCriteria, StaffSummary>(
                delegate
            {
                var rawQuery = request.TextQuery;

                // this will hold all criteria
                var criteria = new List <StaffSearchCriteria>();

                // build criteria against names
                var names = TextQueryHelper.ParsePersonNames(rawQuery);
                criteria.AddRange(CollectionUtils.Map(names,
                                                      (PersonName n) =>
                {
                    var sc = new StaffSearchCriteria();
                    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,
                                                      (string word) =>
                {
                    var c = new StaffSearchCriteria();
                    c.Id.StartsWith(word);
                    return(c);
                }));


                ApplyStaffTypesFilter(request.StaffTypesFilter, criteria);

                return(criteria.ToArray());
            },
                staff => assembler.CreateStaffSummary(staff, PersistenceContext),
                (criteria, threshold) => broker.Count(criteria) <= threshold,
                broker.Find);

            return(helper.Query(request));
        }
コード例 #27
0
        public ListUsersResponse ListUsers(ListUsersRequest request)
        {
            // establish which account types this user is entitled to see
            var visibleAccountTypes = GetAccountTypesAuthorizedToManage(request.IncludeGroupAccounts, request.IncludeSystemAccounts).ToList();

            if (!visibleAccountTypes.Any())
            {
                throw new SecurityException(SR.MessageUserNotAuthorized);
            }

            var criteria = new UserSearchCriteria();

            criteria.AccountType.In(visibleAccountTypes);
            criteria.UserName.SortAsc(0);

            // create the criteria, depending on whether matches should be "exact" or "like"
            if (request.ExactMatchOnly)
            {
                if (!string.IsNullOrEmpty(request.UserName))
                {
                    criteria.UserName.EqualTo(request.UserName);
                }
                if (!string.IsNullOrEmpty(request.DisplayName))
                {
                    criteria.DisplayName.EqualTo(request.DisplayName);
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(request.UserName))
                {
                    criteria.UserName.StartsWith(request.UserName);
                }
                if (!string.IsNullOrEmpty(request.DisplayName))
                {
                    criteria.DisplayName.Like(string.Format("%{0}%", request.DisplayName));
                }
            }

            var broker        = PersistenceContext.GetBroker <IUserBroker>();
            var assembler     = new UserAssembler();
            var userSummaries = CollectionUtils.Map(
                broker.Find(criteria, request.Page),
                (User user) => assembler.GetUserSummary(user));
            var total = broker.Count(criteria);

            return(new ListUsersResponse(userSummaries, (int)total));
        }
コード例 #28
0
        /// <summary>
        /// Gets the specified configuration document.
        /// </summary>
        /// <param name="documentKey"></param>
        /// <returns></returns>
        protected GetConfigurationDocumentResponse GetConfigurationDocumentHelper(ConfigurationDocumentKey documentKey)
        {
            CheckReadAccess(documentKey);

            var broker    = PersistenceContext.GetBroker <IConfigurationDocumentBroker>();
            var criteria  = BuildDocumentKeyCriteria(documentKey);
            var documents = broker.Find(criteria, new SearchResultPage(0, 1), new EntityFindOptions {
                Cache = true
            });

            var document = CollectionUtils.FirstElement(documents);

            return(document == null
                                        ? new GetConfigurationDocumentResponse(documentKey, null, null, null)
                                        : new GetConfigurationDocumentResponse(documentKey, document.CreationTime, document.Body.ModifiedTime, document.Body.DocumentText));
        }
コード例 #29
0
        public ListDepartmentsResponse ListDepartments(ListDepartmentsRequest request)
        {
            Platform.CheckForNullReference(request, "request");

            var where = new DepartmentSearchCriteria();
            where.Id.SortAsc(0);

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

            var assembler = new DepartmentAssembler();

            return(new ListDepartmentsResponse(
                       CollectionUtils.Map(items, (Department item) => assembler.CreateSummary(item, PersistenceContext))
                       ));
        }
コード例 #30
0
        /// <summary>
        /// Gets the user specified by the user name, or null if no such user exists.
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        private User GetUser(string userName)
        {
            var criteria = new UserSearchCriteria();

            criteria.UserName.EqualTo(userName);

            // use query caching here to make this fast (assuming the user table is not often updated)
            var users = PersistenceContext.GetBroker <IUserBroker>().Find(
                criteria, new SearchResultPage(0, 1), new EntityFindOptions {
                Cache = true
            });

            // bug #3701: to ensure the username match is case-sensitive, we need to compare the stored name to the supplied name
            // returns null if no match
            return(CollectionUtils.SelectFirst(users, u => u.UserName == userName));
        }