Пример #1
0
 public Response(Guid encounterId, Guid clientId, Question question, Obs obs)
 {
     EncounterId = encounterId;
     ClientId    = clientId;
     SetQuestion(question);
     SetObs(obs);
 }
Пример #2
0
 public void SetObs(Obs obs)
 {
     if (null != obs)
     {
         ObsId = obs.Id;
         Obs   = obs;
     }
 }
Пример #3
0
 public void UpdateFrom(Obs obs)
 {
     ObsDate         = obs.ObsDate;
     ValueText       = obs.ValueText;
     ValueNumeric    = obs.ValueNumeric;
     ValueCoded      = obs.ValueCoded;
     ValueMultiCoded = obs.ValueMultiCoded;
     ValueDateTime   = obs.ValueDateTime;
 }
Пример #4
0
        public void AddOrUpdate(Obs obs, bool saveNulls = true)
        {
            var obses = Obses.ToList();

            if (obses.Any(x => x.QuestionId == obs.QuestionId))
            {
                var obsForUpdate = obses.First(x => x.QuestionId == obs.QuestionId);
                obses.Remove(obsForUpdate);
                if (saveNulls)
                {
                    obsForUpdate.UpdateFrom(obs);
                    obses.Add(obsForUpdate);
                }
                else
                {
                    if (!obs.IsNull)
                    {
                        obsForUpdate.UpdateFrom(obs);
                        obses.Add(obsForUpdate);
                    }
                }
            }
            else
            {
                obs.EncounterId = Id;
                if (saveNulls)
                {
                    obses.Add(obs);
                }
                else
                {
                    if (!obs.IsNull)
                    {
                        obses.Add(obs);
                    }
                }
            }

            Obses = obses;
        }
Пример #5
0
        public static Obs Create(Guid questionId, Guid encounterId, Guid clientId, string type, object obsValue)
        {
            //  Single | Numeric | Multi | DateTime | Text

            var value = null == obsValue ? string.Empty : obsValue.ToString();

            var obs = new Obs(questionId, encounterId, clientId, value);

            obs.IsNull = true;

            if (type == "Single")
            {
                var val = string.IsNullOrWhiteSpace(value)?Guid.Empty:new Guid(value);
                obs = new Obs(questionId, encounterId, clientId, val); obs.IsNull = true;
            }
            if (type == "Numeric")
            {
                var val = string.IsNullOrWhiteSpace(value) ? -0.01m : Convert.ToDecimal(value);
                obs = new Obs(questionId, encounterId, clientId, val); obs.IsNull = true;
            }
            if (type == "DateTime")
            {
                var val = string.IsNullOrWhiteSpace(value) ? new DateTime(1899, 1, 1) : Convert.ToDateTime(value);
                obs = new Obs(questionId, encounterId, clientId, val); obs.IsNull = true;
            }
            if (type == "Multi")
            {
                obs = new Obs(questionId, encounterId, clientId, value, true); obs.IsNull = true;
            }

            if (obs.HasValue(type))
            {
                obs.IsNull = false;
            }

            return(obs);
        }