Exemple #1
0
        internal static BodyDimension ToBodyDimension(this Observation observation)
        {
            var bodyDimension = observation.ToThingBase <BodyDimension>();

            bodyDimension.Value = ObservationToHealthVault.GetThingValueFromQuantity <Length>(observation.Value as Quantity);
            bodyDimension.When  = ObservationToHealthVault.GetApproximateDateTimeFromEffectiveDate(observation.Effective);

            if (observation.Method != null)
            {
                bodyDimension.MeasurementName = observation.Method.ToCodableValue();
            }

            return(bodyDimension);
        }
Exemple #2
0
        internal static BodyComposition ToBodyComposition(this Observation observation)
        {
            var bodyComposition = observation.ToThingBase <ItemTypes.BodyComposition>();

            if (observation.Component != null)
            {
                var bodyCompositionValue = new BodyCompositionValue();

                foreach (var component in observation.Component)
                {
                    var componentValue = component.Value as Quantity;
                    if (componentValue?.Value == null)
                    {
                        if (component.Code != null)
                        {
                            bodyComposition.MeasurementName = component.Code.ToCodableValue();
                        }

                        continue;
                    }

                    switch (componentValue.Unit)
                    {
                    case UnitAbbreviations.Kilogram:
                        bodyCompositionValue.MassValue = new WeightValue((double)componentValue.Value.Value);
                        break;

                    case UnitAbbreviations.Percent:
                        bodyCompositionValue.PercentValue = (double?)componentValue.Value;
                        break;
                    }
                }

                bodyComposition.Value = bodyCompositionValue;
            }

            bodyComposition.When = ObservationToHealthVault.GetApproximateDateTimeFromEffectiveDate(observation.Effective);

            if (observation.BodySite != null)
            {
                bodyComposition.Site = observation.BodySite.ToCodableValue();
            }

            if (observation.Method != null)
            {
                bodyComposition.MeasurementMethod = observation.Method.ToCodableValue();
            }

            return(bodyComposition);
        }