Exemple #1
0
        public SetConfigurationDocumentResponse SetConfigurationDocument(SetConfigurationDocumentRequest request)
        {
            Platform.CheckForNullReference(request, "request");
            Platform.CheckMemberIsSet(request.DocumentKey, "DocumentKey");

            CheckWriteAccess(request.DocumentKey);

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

            var document = CollectionUtils.FirstElement(documents);

            if (document != null)
            {
                document.Body.DocumentText = request.Content;

                // update document modified time
                document.Body.ModifiedTime = Platform.Time;
            }
            else
            {
                // no saved document, create new
                document = NewDocument(request.DocumentKey);
                document.Body.DocumentText = request.Content;
                PersistenceContext.Lock(document, DirtyState.New);
            }

            return(new SetConfigurationDocumentResponse());
        }
        public AddWorklistResponse AddWorklist(AddWorklistRequest request)
        {
            if (string.IsNullOrEmpty(request.Detail.Name))
            {
                throw new RequestValidationException(SR.ExceptionWorklistNameRequired);
            }

            // create instance of worklist owner
            var owner = CreateOwner(request.Detail, request.IsUserWorklist);

            // ensure user has access to create this worklist
            CheckAccess(owner);

            CheckWorklistCountRestriction(owner);

            // create instance of appropriate class
            var worklist = WorklistFactory.Instance.CreateWorklist(request.Detail.WorklistClass.ClassName);

            // set owner
            worklist.Owner = owner;

            // update properties
            UpdateWorklistHelper(request.Detail, worklist);

            PersistenceContext.Lock(worklist, DirtyState.New);
            PersistenceContext.SynchState();

            var adminAssembler = new WorklistAdminAssembler();

            return(new AddWorklistResponse(adminAssembler.CreateWorklistSummary(worklist, this.PersistenceContext)));
        }
        public AddPatientResponse AddPatient(AddPatientRequest request)
        {
            var profile = new PatientProfile();

            // check if we should auto-generate the MRN
            var workflowConfig = new WorkflowConfigurationReader();

            if (workflowConfig.AutoGenerateMrn)
            {
                var authorities = PersistenceContext.GetBroker <IEnumBroker>().Load <InformationAuthorityEnum>(false);

                // just use the first Information Authority (there is typically only one in this case)
                profile.Mrn.AssigningAuthority = CollectionUtils.FirstElement(authorities);
                profile.Mrn.Id = PersistenceContext.GetBroker <IMrnBroker>().GetNext();
            }


            var patient = new Patient();

            patient.AddProfile(profile);

            UpdateHelper(profile, request.PatientDetail, true, true, !workflowConfig.AutoGenerateMrn);

            PersistenceContext.Lock(patient, DirtyState.New);

            LogicalHL7Event.PatientCreated.EnqueueEvents(profile);

            PersistenceContext.SynchState();

            var assembler = new PatientProfileAssembler();

            return(new AddPatientResponse(assembler.CreatePatientProfileSummary(profile, PersistenceContext)));
        }
Exemple #4
0
        public UploadResponse Upload(UploadRequest request)
        {
            var tempFile = Path.GetTempFileName();

            try
            {
                // write data to a temp file
                File.WriteAllBytes(tempFile, request.DataContent);

                // create the new document object, and put the remote file
                var args = new AttachedDocumentCreationArgs
                {
                    MimeType             = request.MimeType,
                    FileExtension        = request.FileExtension,
                    LocalContentFilePath = tempFile
                };

                var document = AttachedDocument.Create(args, AttachmentStore.GetClient());
                PersistenceContext.Lock(document, DirtyState.New);

                PersistenceContext.SynchState();

                var assembler = new AttachedDocumentAssembler();
                return(new UploadResponse(assembler.CreateAttachedDocumentSummary(document)));
            }
            finally
            {
                File.Delete(tempFile);
            }
        }
        public AddUserResponse AddUser(AddUserRequest request)
        {
            Platform.CheckForNullReference(request, "request");
            Platform.CheckMemberIsSet(request.UserDetail, "UserDetail");

            var userDetail = request.UserDetail;
            var settings   = new AuthenticationSettings();

            // create new user
            var userInfo =
                new UserInfo(userDetail.UserName, userDetail.DisplayName, userDetail.EmailAddress, userDetail.ValidFrom, userDetail.ValidUntil);

            var user = User.CreateNewUser(userInfo, settings.DefaultTemporaryPassword);

            // copy other info such as authority groups from request
            var assembler = new UserAssembler();

            assembler.UpdateUser(user, request.UserDetail, PersistenceContext);

            // save
            PersistenceContext.Lock(user, DirtyState.New);
            PersistenceContext.SynchState();

            return(new AddUserResponse(user.GetRef(), assembler.GetUserSummary(user)));
        }
        public AddModalityResponse AddModality(AddModalityRequest request)
        {
            var modality  = new Modality();
            var assembler = new ModalityAssembler();

            assembler.UpdateModality(request.ModalityDetail, modality, this.PersistenceContext);

            PersistenceContext.Lock(modality, DirtyState.New);

            // ensure the new modality is assigned an OID before using it in the return value
            PersistenceContext.SynchState();

            return(new AddModalityResponse(assembler.CreateModalitySummary(modality)));
        }
Exemple #7
0
        public WriteEntryResponse WriteEntry(WriteEntryRequest request)
        {
            Platform.CheckForNullReference(request, "request");
            Platform.CheckMemberIsSet(request.LogEntry, "LogEntry");

            AuditLogEntryAssembler assembler = new AuditLogEntryAssembler();
            AuditLogEntry          logEntry  = assembler.CreateAuditLogEntry(request.LogEntry);

            logEntry.ServerReceivedTimeStamp = Platform.Time;

            // save the log entry
            PersistenceContext.Lock(logEntry, DirtyState.New);

            return(new WriteEntryResponse());
        }
        public AddLocationResponse AddLocation(AddLocationRequest request)
        {
            Location location = new Location();

            LocationAssembler assembler = new LocationAssembler();

            assembler.UpdateLocation(request.LocationDetail, location, PersistenceContext);

            PersistenceContext.Lock(location, DirtyState.New);

            // ensure the new location is assigned an OID before using it in the return value
            PersistenceContext.SynchState();

            return(new AddLocationResponse(assembler.CreateLocationSummary(location)));
        }
Exemple #9
0
        public AddDepartmentResponse AddDepartment(AddDepartmentRequest request)
        {
            Platform.CheckForNullReference(request, "request");
            Platform.CheckMemberIsSet(request.Department, "request.Department");

            var item = new Department();

            var assembler = new DepartmentAssembler();

            assembler.UpdateDepartment(item, request.Department, PersistenceContext);

            PersistenceContext.Lock(item, DirtyState.New);
            PersistenceContext.SynchState();

            return(new AddDepartmentResponse(assembler.CreateSummary(item, PersistenceContext)));
        }
Exemple #10
0
        public AddDiagnosticServiceResponse AddDiagnosticService(AddDiagnosticServiceRequest request)
        {
            Platform.CheckForNullReference(request, "request");
            Platform.CheckMemberIsSet(request.DiagnosticService, "request.DiagnosticService");

            DiagnosticService item = new DiagnosticService();

            DiagnosticServiceAssembler assembler = new DiagnosticServiceAssembler();

            assembler.UpdateDiagnosticService(item, request.DiagnosticService, PersistenceContext);

            PersistenceContext.Lock(item, DirtyState.New);
            PersistenceContext.SynchState();

            return(new AddDiagnosticServiceResponse(assembler.CreateSummary(item)));
        }
        public AddFacilityResponse AddFacility(AddFacilityRequest request)
        {
            var facility  = new Facility();
            var assembler = new FacilityAssembler();

            assembler.UpdateFacility(request.FacilityDetail, facility, this.PersistenceContext);

            PersistenceContext.Lock(facility, DirtyState.New);

            CheckMultipleInformationAuthoritiesUsed();

            // ensure the new facility is assigned an OID before using it in the return value
            PersistenceContext.SynchState();

            return(new AddFacilityResponse(assembler.CreateFacilitySummary(facility)));
        }
        public AddAuthorityGroupResponse AddAuthorityGroup(AddAuthorityGroupRequest request)
        {
            // create new group
            var authorityGroup = new AuthorityGroup();

            // set properties from request
            var assembler = new AuthorityGroupAssembler();

            assembler.UpdateAuthorityGroup(authorityGroup, request.AuthorityGroupDetail, PersistenceContext);

            // save
            PersistenceContext.Lock(authorityGroup, DirtyState.New);
            PersistenceContext.SynchState();

            return(new AddAuthorityGroupResponse(assembler.CreateAuthorityGroupSummary(authorityGroup)));
        }
Exemple #13
0
        public AddStaffGroupResponse AddStaffGroup(AddStaffGroupRequest request)
        {
            Platform.CheckForNullReference(request, "request");
            Platform.CheckMemberIsSet(request.StaffGroup, "request.StaffGroup");

            var item = new StaffGroup();

            var assembler        = new StaffGroupAssembler();
            var worklistEditable = Thread.CurrentPrincipal.IsInRole(AuthorityTokens.Admin.Data.Worklist);

            assembler.UpdateStaffGroup(item, request.StaffGroup, worklistEditable, true, PersistenceContext);

            PersistenceContext.Lock(item, DirtyState.New);
            PersistenceContext.SynchState();

            return(new AddStaffGroupResponse(assembler.CreateSummary(item)));
        }
        public AddProcedureTypeGroupResponse AddProcedureTypeGroup(
            AddProcedureTypeGroupRequest request)
        {
            if (string.IsNullOrEmpty(request.Detail.Name))
            {
                throw new RequestValidationException(SR.ExceptionProcedureTypeGroupNameRequired);
            }

            // create appropriate class of group
            var group     = (ProcedureTypeGroup)Activator.CreateInstance(Type.GetType(request.Detail.Category.Code));
            var assembler = new ProcedureTypeGroupAssembler();

            assembler.UpdateProcedureTypeGroup(group, request.Detail, this.PersistenceContext);

            PersistenceContext.Lock(group, DirtyState.New);
            PersistenceContext.SynchState();

            return(new AddProcedureTypeGroupResponse(
                       assembler.GetProcedureTypeGroupSummary(group, this.PersistenceContext)));
        }
Exemple #15
0
        public AddUserResponse AddUser(AddUserRequest request)
        {
            Platform.CheckForNullReference(request, "request");
            Platform.CheckMemberIsSet(request.UserDetail, "UserDetail");

            var userDetail  = request.UserDetail;
            var accountType = (userDetail.AccountType != null)
                                ? EnumUtils.GetEnumValue <UserAccountType>(userDetail.AccountType)
                                : UserAccountType.U;    // default account type is U if not specified

            // is the current user authorized to create user accounts of this type?
            EnsureCurrentUserAuthorizedToManage(accountType);

            if (!UserName.IsLegalUserName(userDetail.UserName))
            {
                throw new RequestValidationException("Illegal account name.");
            }

            // create new user
            var userInfo = new UserInfo(
                accountType,
                userDetail.UserName,
                userDetail.DisplayName,
                userDetail.EmailAddress,
                userDetail.ValidFrom,
                userDetail.ValidUntil);

            var password = GetNewAccountPassword(accountType, request.Password);
            var user     = User.CreateNewUser(userInfo, password, new HashedSet <AuthorityGroup>());

            // copy other info such as authority groups from request
            var assembler = new UserAssembler();

            assembler.UpdateUser(user, request.UserDetail, PersistenceContext);

            // save
            PersistenceContext.Lock(user, DirtyState.New);
            PersistenceContext.SynchState();

            return(new AddUserResponse(user.GetRef(), assembler.GetUserSummary(user)));
        }
Exemple #16
0
        public WriteEntryResponse WriteEntry(WriteEntryRequest request)
        {
            if (request == null)
            {
                throw new FaultException(SR.ErrorNullAuditRequest);
            }
            if (request.LogEntry == null)
            {
                throw new FaultException(SR.ErrorEmptyAuditRequest);
            }

            AuditLogEntryAssembler assembler = new AuditLogEntryAssembler();
            AuditLogEntry          logEntry  = assembler.CreateAuditLogEntry(request.LogEntry);

            logEntry.ServerReceivedTimeStamp = Platform.Time;

            // save the log entry
            PersistenceContext.Lock(logEntry, DirtyState.New);

            return(new WriteEntryResponse());
        }
Exemple #17
0
        public ImportSettingsGroupResponse ImportSettingsGroup(ImportSettingsGroupRequest request)
        {
            Platform.CheckForNullReference(request, "request");
            Platform.CheckMemberIsSet(request.Group, "Group");

            var broker = PersistenceContext.GetBroker <IConfigurationSettingsGroupBroker>();

            var where = ConfigurationSettingsGroup.GetCriteria(request.Group);
            var group = CollectionUtils.FirstElement(broker.Find(where));

            if (group == null)
            {
                // group doesn't exist, need to create it
                group = new ConfigurationSettingsGroup();
                group.UpdateFromDescriptor(request.Group);
                PersistenceContext.Lock(group, DirtyState.New);
            }
            else
            {
                // update group from descriptor
                group.UpdateFromDescriptor(request.Group);
            }

            if (request.Properties != null)
            {
                // update properties
                group.SettingsProperties.Clear();
                foreach (var descriptor in request.Properties)
                {
                    var property = new ConfigurationSettingsProperty();
                    property.UpdateFromDescriptor(descriptor);
                    group.SettingsProperties.Add(property);
                }
            }

            PersistenceContext.SynchState();

            return(new ImportSettingsGroupResponse());
        }
Exemple #18
0
        public AddAuthorityGroupResponse AddAuthorityGroup(AddAuthorityGroupRequest request)
        {
            Platform.CheckForNullReference(request, "request");
            Platform.CheckMemberIsSet(request.AuthorityGroupDetail, "AuthorityGroupDetail");

            if (request.AuthorityGroupDetail.BuiltIn)
            {
                throw new RequestValidationException(SR.MessageCannotManageBuiltInAuthorityGroups);
            }

            // create new group
            var authorityGroup = new AuthorityGroup();

            // set properties from request
            var assembler = new AuthorityGroupAssembler();

            assembler.UpdateAuthorityGroup(authorityGroup, request.AuthorityGroupDetail, PersistenceContext);

            // save
            PersistenceContext.Lock(authorityGroup, DirtyState.New);
            PersistenceContext.SynchState();

            return(new AddAuthorityGroupResponse(assembler.CreateAuthorityGroupSummary(authorityGroup)));
        }