Example #1
0
        /// <summary>
        /// Insert the specified observation into the database
        /// </summary>
        protected override TObservation InsertInternal(LocalDataContext context, TObservation data)
        {
            if (data.InterpretationConcept != null)
            {
                data.InterpretationConcept = data.InterpretationConcept?.EnsureExists(context);
            }
            data.InterpretationConceptKey = data.InterpretationConcept?.Key ?? data.InterpretationConceptKey;

            var inserted = base.InsertInternal(context, data);

            // Not pure observation
            if (data.GetType() != typeof(Observation))
            {
                var dbobservation = new DbObservation()
                {
                    InterpretationConceptUuid = data.InterpretationConceptKey?.ToByteArray(),
                    Uuid = inserted.Key?.ToByteArray()
                };
                // Value type
                if (data is QuantityObservation)
                {
                    dbobservation.ValueType = "PQ";
                }
                else if (data is TextObservation)
                {
                    dbobservation.ValueType = "ST";
                }
                else if (data is CodedObservation)
                {
                    dbobservation.ValueType = "CD";
                }

                // Persist
                context.Connection.Insert(dbobservation);
            }
            return(inserted);
        }
Example #2
0
        /// <summary>
        /// Convert a data act and observation instance to an observation
        /// </summary>
        public virtual TObservation ToModelInstance(TDbObservation dataInstance, DbAct actInstance, DbObservation obsInstance, LocalDataContext context)
        {
            var retVal = m_actPersister.ToModelInstance <TObservation>(actInstance, context);

            if (obsInstance.InterpretationConceptUuid != null)
            {
                retVal.InterpretationConceptKey = new Guid(obsInstance.InterpretationConceptUuid);
            }

            return(retVal);
        }
Example #3
0
        /// <summary>
        /// Convert the specified object to a model instance
        /// </summary>
        public override CodedObservation ToModelInstance(DbCodedObservation dataInstance, DbAct actInstance, DbObservation obsInstance, LocalDataContext context)
        {
            var retVal = base.ToModelInstance(dataInstance, actInstance, obsInstance, context);

            if (dataInstance.Value != null)
            {
                retVal.ValueKey = new Guid(dataInstance.Value);
            }
            return(retVal);
        }
Example #4
0
        /// <summary>
        /// Convert the specified object to a model instance
        /// </summary>
        public override QuantityObservation ToModelInstance(DbQuantityObservation dataInstance, DbAct actInstance, DbObservation obsInstance, LocalDataContext context)
        {
            var retVal = base.ToModelInstance(dataInstance, actInstance, obsInstance, context);

            if (dataInstance.UnitOfMeasureUuid != null)
            {
                retVal.UnitOfMeasureKey = new Guid(dataInstance.UnitOfMeasureUuid);
            }
            retVal.Value = dataInstance.Value;
            return(retVal);
        }
Example #5
0
        /// <summary>
        /// Convert the specified object to a model instance
        /// </summary>
        public override TextObservation ToModelInstance(DbTextObservation dataInstance, DbAct actInstance, DbObservation obsInstance, LocalDataContext context)
        {
            var retVal = base.ToModelInstance(dataInstance, actInstance, obsInstance, context);

            retVal.Value = dataInstance.Value;
            return(retVal);
        }