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); }
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)))); }
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)); }
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))); }
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)))); }
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))); }
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)))); }
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)); }
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) }); }
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()); }
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)); }
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()))); }
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); }))); }
/// <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); } }
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())); }
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)))); }
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)) )); }
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)); }
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); }
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); }))); }
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)); } }
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)))); } }
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()); }
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)))); } }
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)))); } }
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)); }
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)); }
/// <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)); }
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)) )); }
/// <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)); }