예제 #1
0
        public bool CreateEntity()
        {
            CriticalResultsEntityManager manager = new CriticalResultsEntityManager();

            ResultEntity result = new ResultEntity();
            result.Message = _Message;
            if (_CreationTime == null)
                result.CreationTime = DateTime.Now;
            else
                result.CreationTime = _CreationTime.Value;
            result.Uuid = Guid.NewGuid();

            result.Sender = manager.GetUser(_Sender.UserName);
            result.Receiver = manager.GetUser(_Receiver.UserName);
            result.Level = manager.GetLevel(_Level.Name);

            result.EscalationTime = result.CreationTime + result.Level.EscalationTimespan;
            result.DueTime = result.CreationTime + result.Level.DueTimespan;

            if (result.SenderProxy != null)
            {
                result.SenderProxy = manager.GetUser(_SenderProxy.UserName);
            }

            _Entity = manager.CreateResultEntity(result);

            foreach (ResultContext context in _Context)
            {
                ContextTypeEntity contextTypeEntity = manager.GetContextType(context.ContextType.Name);
                ResultContextEntity resultEntity = manager.CreateResultContextEntity(_Entity, contextTypeEntity, context.JsonValue, context.XmlValue, context.PatientKey, context.ExamKey);
                _Entity.ResultContexts.Add(resultEntity);
            }

            ApplyEntity();

            return true;
        }