Esempio n. 1
0
        public void UpdateProcedureType(ProcedureType procType, ProcedureTypeDetail detail, IPersistenceContext context)
        {
            procType.Id       = detail.Id;
            procType.Name     = detail.Name;
            procType.BaseType = detail.CustomProcedurePlan && detail.BaseType != null
                                                                        ? context.Load <ProcedureType>(detail.BaseType.ProcedureTypeRef, EntityLoadFlags.Proxy)
                                                                        : null;

            procType.DefaultDuration = detail.DefaultDuration;
            procType.Deactivated     = detail.Deactivated;

            try
            {
                if (detail.CustomProcedurePlan)
                {
                    procType.Plan = new ProcedurePlan(detail.PlanXml);
                }
                else
                {
                    var modality = context.Load <Modality>(detail.DefaultModality.ModalityRef);
                    procType.Plan = ProcedurePlan.CreateDefaultPlan(detail.Name, modality);
                }
            }
            catch (XmlException e)
            {
                throw new RequestValidationException(string.Format("Procedure plan XML is invalid: {0}", e.Message));
            }
        }
Esempio n. 2
0
        protected override void Import(ProcedureTypeData data, IUpdateContext context)
        {
            var pt = LoadOrCreateProcedureType(data.Id, data.Name, context);

            pt.Deactivated     = data.Deactivated;
            pt.DefaultDuration = data.DefaultDuration;
            if (!string.IsNullOrEmpty(data.DefaultModality))
            {
                pt.Plan = ProcedurePlan.CreateDefaultPlan(data.Name, GetModality(data.DefaultModality, context));
            }
            else
            {
                pt.Plan = new ProcedurePlan(data.PlanXml);
                if (!string.IsNullOrEmpty(data.BaseTypeId))
                {
                    pt.BaseType = LoadOrCreateProcedureType(data.BaseTypeId, data.BaseTypeId, context);
                }
            }
        }