public LoadAuthorityGroupForEditResponse LoadAuthorityGroupForEdit(LoadAuthorityGroupForEditRequest request) { var authorityGroup = PersistenceContext.Load <AuthorityGroup>(request.AuthorityGroupRef); var assembler = new AuthorityGroupAssembler(); return(new LoadAuthorityGroupForEditResponse(assembler.CreateAuthorityGroupDetail(authorityGroup))); }
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 DeleteAuthorityGroupResponse DeleteAuthorityGroup(DeleteAuthorityGroupRequest request) { var broker = PersistenceContext.GetBroker <IAuthorityGroupBroker>(); var authorityGroup = PersistenceContext.Load <AuthorityGroup>(request.AuthorityGroupRef, EntityLoadFlags.Proxy); if (request.DeleteOnlyWhenEmpty) { var count = broker.GetUserCountForGroup(authorityGroup); if (count > 0) { throw new AuthorityGroupIsNotEmptyException(authorityGroup.Name, count); } } // before we can delete an authority group, first need to remove all tokens and users authorityGroup.AuthorityTokens.Clear(); authorityGroup.RemoveAllUsers(); // delete group broker.Delete(authorityGroup); PersistenceContext.SynchState(); return(new DeleteAuthorityGroupResponse()); }
private GetWorklistEditValidationResponse GetWorklistEditValidation(GetWorklistEditValidationRequest request) { WorklistOwner owner; if (!request.IsUserWorklist) { // if not creating a user worklist, the owner is Admin owner = WorklistOwner.Admin; } else if (request.OwnerGroup != null) { // if an owner group is specified, assign ownership to the group var group = PersistenceContext.Load <StaffGroup>(request.OwnerGroup.StaffGroupRef, EntityLoadFlags.Proxy); owner = new WorklistOwner(group); } else { // otherwise assign ownership to current user, regardless of whether a different owner staff specified owner = new WorklistOwner(CurrentUserStaff); } try { CheckWorklistCountRestriction(owner); } catch (RequestValidationException e) { return(new GetWorklistEditValidationResponse(e.Message)); } return(new GetWorklistEditValidationResponse()); }
public DeleteAuthorityGroupResponse DeleteAuthorityGroup(DeleteAuthorityGroupRequest request) { Platform.CheckForNullReference(request, "request"); Platform.CheckMemberIsSet(request.AuthorityGroupRef, "AuthorityGroupRef"); var broker = PersistenceContext.GetBroker <IAuthorityGroupBroker>(); var authorityGroup = PersistenceContext.Load <AuthorityGroup>(request.AuthorityGroupRef, EntityLoadFlags.Proxy); if (authorityGroup.BuiltIn) { throw new RequestValidationException(SR.MessageCannotManageBuiltInAuthorityGroups); } if (request.DeleteOnlyWhenEmpty) { var count = broker.GetUserCountForGroup(authorityGroup); if (count > 0) { throw new AuthorityGroupIsNotEmptyException(authorityGroup.Name, count); } } // before we can delete an authority group, first need to remove all tokens and users authorityGroup.AuthorityTokens.Clear(); authorityGroup.RemoveAllUsers(); // delete group broker.Delete(authorityGroup); PersistenceContext.SynchState(); return(new DeleteAuthorityGroupResponse()); }
public UpdateAuthorityGroupResponse UpdateAuthorityGroup(UpdateAuthorityGroupRequest request) { Platform.CheckForNullReference(request, "request"); Platform.CheckMemberIsSet(request.AuthorityGroupDetail, "AuthorityGroupDetail"); var authorityGroup = PersistenceContext.Load <AuthorityGroup>(request.AuthorityGroupDetail.AuthorityGroupRef); if (authorityGroup.BuiltIn || request.AuthorityGroupDetail.BuiltIn) { throw new RequestValidationException(SR.MessageCannotManageBuiltInAuthorityGroups); } if (authorityGroup.DataGroup && !request.AuthorityGroupDetail.DataGroup) { var user = GetUser(Thread.CurrentPrincipal.Identity.Name, PersistenceContext); if (!user.Password.Verify(request.Password)) { // the error message is deliberately vague throw new UserAccessDeniedException(); } } // set properties from request var assembler = new AuthorityGroupAssembler(); assembler.UpdateAuthorityGroup(authorityGroup, request.AuthorityGroupDetail, PersistenceContext); PersistenceContext.SynchState(); return(new UpdateAuthorityGroupResponse(assembler.CreateAuthorityGroupSummary(authorityGroup))); }
public UpdateStaffResponse UpdateStaff(UpdateStaffRequest request) { Platform.CheckForNullReference(request, "request"); Platform.CheckMemberIsSet(request.StaffDetail, "StaffDetail"); var staff = PersistenceContext.Load <Staff>(request.StaffDetail.StaffRef); // ensure user has access to edit this staff CheckWriteAccess(staff); // if trying to associate with a new user account, check the account is free if (!string.IsNullOrEmpty(request.StaffDetail.UserName) && request.StaffDetail.UserName != staff.UserName) { ValidateUserNameFree(request.StaffDetail.UserName); } var assembler = new StaffAssembler(); assembler.UpdateStaff(request.StaffDetail, staff, request.UpdateElectiveGroups && (Thread.CurrentPrincipal.IsInRole(AuthorityTokens.Admin.Data.StaffGroup) || staff.UserName == this.CurrentUser), request.UpdateNonElectiveGroups && Thread.CurrentPrincipal.IsInRole(AuthorityTokens.Admin.Data.StaffGroup), PersistenceContext); return(new UpdateStaffResponse(assembler.CreateStaffSummary(staff, PersistenceContext))); }
public GetConversationResponse GetConversation(GetConversationRequest request) { Platform.CheckForNullReference(request, "request"); Platform.CheckMemberIsSet(request.OrderRef, "request.OrderRef"); var order = PersistenceContext.Load <Order>(request.OrderRef); // select only notes that are actually posted, and meet category filter var notes = CollectionUtils.Select(OrderNote.GetNotesForOrder(order), n => n.IsPosted && (request.CategoryFilters == null || request.CategoryFilters.Count == 0 || request.CategoryFilters.Contains(n.Category))); // put most recent notes first notes.Reverse(); var noteAssembler = new OrderNoteAssembler(); if (request.CountOnly) { return(new GetConversationResponse(order.GetRef(), null, notes.Count)); } return(new GetConversationResponse( order.GetRef(), CollectionUtils.Map(notes, (OrderNote n) => noteAssembler.CreateOrderNoteDetail(n, CurrentUserStaff, PersistenceContext)), notes.Count)); }
public LoadLocationForEditResponse LoadLocationForEdit(LoadLocationForEditRequest request) { // note that the version of the LocationRef is intentionally ignored here (default behaviour of ReadOperation) Location l = PersistenceContext.Load <Location>(request.LocationRef); LocationAssembler assembler = new LocationAssembler(); return(new LoadLocationForEditResponse(assembler.CreateLocationDetail(l))); }
public LoadNoteCategoryForEditResponse LoadNoteCategoryForEdit(LoadNoteCategoryForEditRequest request) { // note that the version of the NoteCategoryRef is intentionally ignored here (default behaviour of ReadOperation) PatientNoteCategory category = PersistenceContext.Load <PatientNoteCategory>(request.NoteCategoryRef); PatientNoteCategoryAssembler assembler = new PatientNoteCategoryAssembler(); return(new LoadNoteCategoryForEditResponse(category.GetRef(), assembler.CreateNoteCategoryDetail(category, this.PersistenceContext))); }
public LoadFacilityForEditResponse LoadFacilityForEdit(LoadFacilityForEditRequest request) { // note that the version of the FacilityRef is intentionally ignored here (default behaviour of ReadOperation) var f = PersistenceContext.Load <Facility>(request.FacilityRef); var assembler = new FacilityAssembler(); return(new LoadFacilityForEditResponse(assembler.CreateFacilityDetail(f))); }
public UpdateModalityResponse UpdateModality(UpdateModalityRequest request) { var modality = PersistenceContext.Load <Modality>(request.ModalityDetail.ModalityRef, EntityLoadFlags.CheckVersion); var assembler = new ModalityAssembler(); assembler.UpdateModality(request.ModalityDetail, modality, this.PersistenceContext); return(new UpdateModalityResponse(assembler.CreateModalitySummary(modality))); }
public LoadWorklistForEditResponse LoadWorklistForEdit(LoadWorklistForEditRequest request) { var worklist = PersistenceContext.Load <Worklist>(request.EntityRef); var adminAssembler = new WorklistAdminAssembler(); var adminDetail = adminAssembler.CreateWorklistDetail(worklist, this.PersistenceContext); return(new LoadWorklistForEditResponse(worklist.GetRef(), adminDetail)); }
public UpdateVisitResponse UpdateVisit(UpdateVisitRequest request) { Visit visit = PersistenceContext.Load <Visit>(request.VisitRef); VisitAssembler assembler = new VisitAssembler(); assembler.UpdateVisit(visit, request.VisitDetail, PersistenceContext); return(new UpdateVisitResponse(assembler.CreateVisitSummary(visit, PersistenceContext))); }
public UpdateNoteCategoryResponse UpdateNoteCategory(UpdateNoteCategoryRequest request) { PatientNoteCategory noteCategory = PersistenceContext.Load <PatientNoteCategory>(request.NoteCategoryDetail.NoteCategoryRef, EntityLoadFlags.CheckVersion); PatientNoteCategoryAssembler assembler = new PatientNoteCategoryAssembler(); assembler.UpdateNoteCategory(request.NoteCategoryDetail, noteCategory); return(new UpdateNoteCategoryResponse(assembler.CreateNoteCategorySummary(noteCategory, this.PersistenceContext))); }
public UpdateLocationResponse UpdateLocation(UpdateLocationRequest request) { Location location = PersistenceContext.Load <Location>(request.LocationDetail.LocationRef, EntityLoadFlags.CheckVersion); LocationAssembler assembler = new LocationAssembler(); assembler.UpdateLocation(request.LocationDetail, location, PersistenceContext); return(new UpdateLocationResponse(assembler.CreateLocationSummary(location))); }
public LoadDepartmentForEditResponse LoadDepartmentForEdit(LoadDepartmentForEditRequest request) { Platform.CheckForNullReference(request, "request"); Platform.CheckMemberIsSet(request.DepartmentRef, "request.DepartmentRef"); var item = PersistenceContext.Load <Department>(request.DepartmentRef); var assembler = new DepartmentAssembler(); return(new LoadDepartmentForEditResponse(assembler.CreateDetail(item, PersistenceContext))); }
public LoadDiagnosticServiceForEditResponse LoadDiagnosticServiceForEdit(LoadDiagnosticServiceForEditRequest request) { Platform.CheckForNullReference(request, "request"); Platform.CheckMemberIsSet(request.DiagnosticServiceRef, "request.DiagnosticServiceRef"); DiagnosticService item = PersistenceContext.Load <DiagnosticService>(request.DiagnosticServiceRef); DiagnosticServiceAssembler assembler = new DiagnosticServiceAssembler(); return(new LoadDiagnosticServiceForEditResponse(assembler.CreateDetail(item))); }
public LoadStaffGroupForEditResponse LoadStaffGroupForEdit(LoadStaffGroupForEditRequest request) { Platform.CheckForNullReference(request, "request"); Platform.CheckMemberIsSet(request.StaffGroupRef, "request.StaffGroupRef"); var item = PersistenceContext.Load <StaffGroup>(request.StaffGroupRef); var assembler = new StaffGroupAssembler(); return(new LoadStaffGroupForEditResponse(assembler.CreateDetail(item, PersistenceContext))); }
public UpdateProcedureTypeGroupResponse UpdateProcedureTypeGroup( UpdateProcedureTypeGroupRequest request) { var group = PersistenceContext.Load <ProcedureTypeGroup>(request.EntityRef, EntityLoadFlags.CheckVersion); var assembler = new ProcedureTypeGroupAssembler(); assembler.UpdateProcedureTypeGroup(group, request.Detail, this.PersistenceContext); return(new UpdateProcedureTypeGroupResponse( assembler.GetProcedureTypeGroupSummary(group, this.PersistenceContext))); }
public void LoadAll() { try { PersistenceContext.Load(this); } catch (Exception) { throw; } }
public LoadStaffForEditResponse LoadStaffForEdit(LoadStaffForEditRequest request) { var s = PersistenceContext.Load <Staff>(request.StaffRef); // ensure user has access to edit this staff CheckReadAccess(s); var assembler = new StaffAssembler(); return(new LoadStaffForEditResponse(assembler.CreateStaffDetail(s, this.PersistenceContext))); }
public LoadProcedureTypeForEditResponse LoadProcedureTypeForEdit(LoadProcedureTypeForEditRequest request) { Platform.CheckForNullReference(request, "request"); Platform.CheckMemberIsSet(request.ProcedureTypeRef, "request.ProcedureTypeRef"); var item = PersistenceContext.Load <ProcedureType>(request.ProcedureTypeRef); var assembler = new ProcedureTypeAssembler(); return(new LoadProcedureTypeForEditResponse(assembler.CreateDetail(item, PersistenceContext))); }
public UpdateFacilityResponse UpdateFacility(UpdateFacilityRequest request) { var facility = PersistenceContext.Load <Facility>(request.FacilityDetail.FacilityRef, EntityLoadFlags.CheckVersion); var assembler = new FacilityAssembler(); assembler.UpdateFacility(request.FacilityDetail, facility, this.PersistenceContext); CheckMultipleInformationAuthoritiesUsed(); return(new UpdateFacilityResponse(assembler.CreateFacilitySummary(facility))); }
public UpdateDiagnosticServiceResponse UpdateDiagnosticService(UpdateDiagnosticServiceRequest request) { Platform.CheckForNullReference(request, "request"); Platform.CheckMemberIsSet(request.DiagnosticService, "request.DiagnosticService"); Platform.CheckMemberIsSet(request.DiagnosticService.DiagnosticServiceRef, "request.DiagnosticService.DiagnosticServiceRef"); DiagnosticService item = PersistenceContext.Load <DiagnosticService>(request.DiagnosticService.DiagnosticServiceRef); DiagnosticServiceAssembler assembler = new DiagnosticServiceAssembler(); assembler.UpdateDiagnosticService(item, request.DiagnosticService, PersistenceContext); PersistenceContext.SynchState(); return(new UpdateDiagnosticServiceResponse(assembler.CreateSummary(item))); }
public UpdateProcedureTypeResponse UpdateProcedureType(UpdateProcedureTypeRequest request) { Platform.CheckForNullReference(request, "request"); Platform.CheckMemberIsSet(request.ProcedureType, "request.ProcedureType"); Platform.CheckMemberIsSet(request.ProcedureType.ProcedureTypeRef, "request.ProcedureType.ProcedureTypeRef"); var item = PersistenceContext.Load <ProcedureType>(request.ProcedureType.ProcedureTypeRef); var assembler = new ProcedureTypeAssembler(); assembler.UpdateProcedureType(item, request.ProcedureType, PersistenceContext); PersistenceContext.SynchState(); return(new UpdateProcedureTypeResponse(assembler.CreateSummary(item))); }
public UpdateDepartmentResponse UpdateDepartment(UpdateDepartmentRequest request) { Platform.CheckForNullReference(request, "request"); Platform.CheckMemberIsSet(request.Department, "request.Department"); Platform.CheckMemberIsSet(request.Department.DepartmentRef, "request.Department.DepartmentRef"); var item = PersistenceContext.Load <Department>(request.Department.DepartmentRef); var assembler = new DepartmentAssembler(); assembler.UpdateDepartment(item, request.Department, PersistenceContext); PersistenceContext.SynchState(); return(new UpdateDepartmentResponse(assembler.CreateSummary(item, PersistenceContext))); }
public AcknowledgeAndPostResponse AcknowledgeAndPost(AcknowledgeAndPostRequest request) { Platform.CheckForNullReference(request, "request"); Platform.CheckMemberIsSet(request.OrderRef, "request.OrderRef"); var order = PersistenceContext.Load <Order>(request.OrderRef); // process acknowledgements first if (request.OrderNotesToAcknowledge != null) { var notes = CollectionUtils.Map(request.OrderNotesToAcknowledge, (EntityRef noteRef) => PersistenceContext.Load <OrderNote>(noteRef)); foreach (var note in notes) { //validate that the note is actually associated with the correct order if (!Equals(note.Order, order)) { throw new ArgumentException("Attempt to acknowledge a note that is not associated with this order."); } note.Acknowledge(CurrentUserStaff); } } try { // process reply note OrderNote replyNote = null; var noteAssembler = new OrderNoteAssembler(); if (request.OrderNote != null) { replyNote = noteAssembler.CreateOrderNote( request.OrderNote, order, CurrentUserStaff, true, PersistenceContext); } PersistenceContext.SynchState(); return(replyNote != null ? new AcknowledgeAndPostResponse(noteAssembler.CreateOrderNoteDetail(replyNote, CurrentUserStaff, PersistenceContext)) : new AcknowledgeAndPostResponse(null)); } catch (NoteAcknowledgementException e) { // occurs when there are notes that this author must ack prior to posting a new note throw new RequestValidationException(e.Message); } }
public LoadMergeExternalPractitionerFormDataResponse LoadMergeExternalPractitionerFormData(LoadMergeExternalPractitionerFormDataRequest request) { var response = new LoadMergeExternalPractitionerFormDataResponse(); if (request.PractitionerRef != null) { var broker = PersistenceContext.GetBroker <IExternalPractitionerBroker>(); var practitioner = PersistenceContext.Load <ExternalPractitioner>(request.PractitionerRef); var duplicates = broker.GetMergeCandidates(practitioner); var assembler = new ExternalPractitionerAssembler(); response.Duplicates = CollectionUtils.Map <ExternalPractitioner, ExternalPractitionerSummary>(duplicates, item => assembler.CreateExternalPractitionerSummary(item, this.PersistenceContext)); } return(response); }
public PrintReportResponse PrintReport(PrintReportRequest request) { Platform.CheckForNullReference(request, "request"); Platform.CheckMemberIsSet(request.ReportRef, "ReportRef"); var report = PersistenceContext.Load <Report>(request.ReportRef); var printModel = request.RecipientContactPointRef != null ? new ReportPageModel(report, PersistenceContext.Load <ExternalPractitionerContactPoint>(request.RecipientContactPointRef)) : new ReportPageModel(report); using (var printResult = PrintJob.Run(printModel)) { var contents = File.ReadAllBytes(printResult.OutputFilePath); return(new PrintReportResponse(contents)); } }