예제 #1
0
        private EnumerationInfo ReadHardEnum(Type enumValueClass, Table table)
        {
            Type enumType = _mapClassToEnum[enumValueClass];

            int displayOrder = 1;

            // note that we process the enum constants in order of the underlying value assigned
            // so that the initial displayOrder reflects the natural ordering
            // (see msdn docs for Enum.GetValues for details)
            return(new EnumerationInfo(enumValueClass.FullName, table.Name, true,
                                       CollectionUtils.Map <object, EnumerationMemberInfo>(Enum.GetValues(enumType),
                                                                                           delegate(object value)
            {
                string code = Enum.GetName(enumType, value);
                FieldInfo fi = enumType.GetField(code);

                EnumValueAttribute attr = AttributeUtils.GetAttribute <EnumValueAttribute>(fi);
                return new EnumerationMemberInfo(
                    code,
                    attr != null ? TerminologyTranslator.Translate(enumType, attr.Value) : null,
                    attr != null ? TerminologyTranslator.Translate(enumType, attr.Description) : null,
                    displayOrder++,
                    false);
            })));
        }
예제 #2
0
파일: Worklist.cs 프로젝트: hksonngan/Xian
        /// <summary>
        /// Gets the display name for the specified worklist class, obtained either from
        /// the <see cref="WorklistClassDisplayNameAttribute"/>, otherwise via the
        /// <see cref="TerminologyTranslator"/> class.
        /// </summary>
        /// <param name="worklistClass"></param>
        /// <returns></returns>
        public static string GetDisplayName(Type worklistClass)
        {
            var a = AttributeUtils.GetAttribute <WorklistClassDisplayNameAttribute>(worklistClass, true);

            if (a == null)
            {
                return(TerminologyTranslator.Translate(worklistClass));
            }

            var resolver = new ResourceResolver(worklistClass, true);

            return(resolver.LocalizeString(a.DisplayName));
        }
예제 #3
0
        /// <summary>
        /// Create worklist class summary.
        /// </summary>
        /// <param name="worklistClass"></param>
        /// <returns></returns>
        public WorklistClassSummary CreateClassSummary(Type worklistClass)
        {
            var ptgClass = Worklist.GetProcedureTypeGroupClass(worklistClass);

            return(new WorklistClassSummary(
                       Worklist.GetClassName(worklistClass),
                       Worklist.GetDisplayName(worklistClass),
                       Worklist.GetCategory(worklistClass),
                       Worklist.GetDescription(worklistClass),
                       ptgClass == null ? null : ptgClass.Name,
                       ptgClass == null ? null : TerminologyTranslator.Translate(ptgClass),
                       Worklist.GetSupportsReportingStaffRoleFilter(worklistClass)));
        }
        public DeleteProtocolCodeResponse DeleteProtocolCode(DeleteProtocolCodeRequest request)
        {
            try
            {
                var broker = this.PersistenceContext.GetBroker <IProtocolCodeBroker>();
                var item   = broker.Load(request.ProtocolCodeRef, EntityLoadFlags.Proxy);
                broker.Delete(item);

                this.PersistenceContext.SynchState();

                return(new DeleteProtocolCodeResponse());
            }
            catch (PersistenceException)
            {
                throw new RequestValidationException(string.Format(SR.ExceptionFailedToDelete,
                                                                   TerminologyTranslator.Translate(typeof(ProtocolCode))));
            }
        }
예제 #5
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))));
     }
 }
예제 #6
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))));
     }
 }
예제 #7
0
        public DeleteStaffResponse DeleteStaff(DeleteStaffRequest request)
        {
            try
            {
                var broker = PersistenceContext.GetBroker <IStaffBroker>();
                var item   = broker.Load(request.StaffRef, EntityLoadFlags.Proxy);

                //bug #3324: because StaffGroup owns the collection, need to iterate over each group
                //and manually remove this staff
                var groups = new List <StaffGroup>(item.Groups);
                foreach (var group in groups)
                {
                    group.RemoveMember(item);
                }

                broker.Delete(item);
                PersistenceContext.SynchState();
                return(new DeleteStaffResponse());
            }
            catch (PersistenceException)
            {
                throw new RequestValidationException(string.Format(SR.ExceptionFailedToDelete, TerminologyTranslator.Translate(typeof(Staff))));
            }
        }
예제 #8
0
 public DeleteDiagnosticServiceResponse DeleteDiagnosticService(DeleteDiagnosticServiceRequest request)
 {
     try
     {
         IDiagnosticServiceBroker broker = PersistenceContext.GetBroker <IDiagnosticServiceBroker>();
         DiagnosticService        item   = broker.Load(request.DiagnosticServiceRef, EntityLoadFlags.Proxy);
         broker.Delete(item);
         PersistenceContext.SynchState();
         return(new DeleteDiagnosticServiceResponse());
     }
     catch (PersistenceException)
     {
         throw new RequestValidationException(string.Format(SR.ExceptionFailedToDelete, TerminologyTranslator.Translate(typeof(DiagnosticService))));
     }
 }
예제 #9
0
 public EnumValueInfo GetCategoryEnumValueInfo(Type groupClass)
 {
     // this is a bit hokey but avoids having to modify the client code that is expecting an EnumValueInfo
     return(new EnumValueInfo(groupClass.AssemblyQualifiedName, TerminologyTranslator.Translate(groupClass)));
 }
예제 #10
0
        public RemoveValueResponse RemoveValue(RemoveValueRequest request)
        {
            Type enumClass = null;

            try
            {
                enumClass = GetEnumClass(request.AssemblyQualifiedClassName);

                // Client side should enforce this.  But just in case it does not.
                if (IsSoftEnum(enumClass) == false)
                {
                    throw new RequestValidationException(SR.ExceptionUnableToDeleteHardEnumeration);
                }

                var broker = PersistenceContext.GetBroker <IEnumBroker>();
                broker.RemoveValue(enumClass, request.Value.Code);
                PersistenceContext.SynchState();
                return(new RemoveValueResponse());
            }
            catch (PersistenceException)
            {
                throw new RequestValidationException(string.Format(SR.ExceptionFailedToDelete, TerminologyTranslator.Translate(enumClass)));
            }
        }
예제 #11
0
        public DeleteStaffGroupResponse DeleteStaffGroup(DeleteStaffGroupRequest request)
        {
            try
            {
                var broker = PersistenceContext.GetBroker <IStaffGroupBroker>();
                var item   = broker.Load(request.StaffGroupRef, EntityLoadFlags.Proxy);

                // Remove worklist association before deleting a staff group
                var worklists = PersistenceContext.GetBroker <IWorklistBroker>().Find(item);
                CollectionUtils.ForEach(worklists, worklist => worklist.GroupSubscribers.Remove(item));

                broker.Delete(item);
                PersistenceContext.SynchState();
                return(new DeleteStaffGroupResponse());
            }
            catch (PersistenceException)
            {
                throw new RequestValidationException(string.Format(SR.ExceptionFailedToDelete, TerminologyTranslator.Translate(typeof(StaffGroup))));
            }
        }
예제 #12
0
        public DeleteWorklistResponse DeleteWorklist(DeleteWorklistRequest request)
        {
            try
            {
                var broker = PersistenceContext.GetBroker <IWorklistBroker>();
                var item   = broker.Load(request.WorklistRef, EntityLoadFlags.Proxy);

                // check if user can delete
                CheckAccess(item.Owner);

                broker.Delete(item);
                PersistenceContext.SynchState();
                return(new DeleteWorklistResponse());
            }
            catch (PersistenceException)
            {
                throw new RequestValidationException(string.Format(SR.ExceptionFailedToDelete, TerminologyTranslator.Translate(typeof(Worklist))));
            }
        }