public void WhenHealthVaultBodyDimensionTransformedToFhir_ThenCodeAndValuesEqual()
        {
            var testDateTime = new LocalDateTime(2017, 8, 2, 11, 13, 14);

            var bodyDimension = new BodyDimension(
                new ApproximateDateTime(testDateTime),
                new CodableValue("Left bicep size",
                                 new CodedValue("BicepCircumferenceLeft", "body-dimension-measurement-names", "wc", "1")), new Length(0.15)
                );

            var observation = bodyDimension.ToFhir();

            Assert.IsNotNull(observation);
            Assert.AreEqual(HealthVaultThingTypeNameCodes.BodyDimension, observation.Code.Coding[0]);
            Assert.AreEqual("BicepCircumferenceLeft", observation.Method.Coding[0].Code);

            var when = observation.Effective as FhirDateTime;

            Assert.IsNotNull(when);
            Assert.AreEqual(testDateTime.ToDateTimeUnspecified(), when.ToDateTime().Value);

            var value = observation.Value as Quantity;

            Assert.IsNotNull(value);
            Assert.AreEqual((decimal)0.15, value.Value);
            Assert.AreEqual(UnitAbbreviations.Meter, value.Unit);
        }
        internal static Observation ToFhirInternal(BodyDimension bodyDimension, Observation observation)
        {
            observation.Category = new List <CodeableConcept> {
                FhirCategories.VitalSigns
            };

            observation.Code = HealthVaultVocabularies.GenerateCodeableConcept(HealthVaultThingTypeNameCodes.BodyDimension);

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

            observation.Value = new Quantity((decimal)bodyDimension.Value.Meters, UnitAbbreviations.Meter);

            observation.Effective = bodyDimension.When.ToFhir();

            return(observation);
        }
 // Register the type on the generic ThingToFhir partial class
 public static Observation ToFhir(this BodyDimension bodyDimension)
 {
     return(BodyDimensionToFhir.ToFhirInternal(bodyDimension, ToFhirInternal <Observation>(bodyDimension)));
 }