コード例 #1
0
        public void TestLongDecimalSerialization()
        {
            var dec = 3.1415926535897932384626433833m;
            var ext = new FhirDecimal(dec);
            var obs = new Observation();

            obs.AddExtension("http://example.org/DecimalPrecision", ext);

            var json = FhirJsonSerializer.SerializeToString(obs);
            var obs2 = FhirJsonParser.Parse <Observation>(json);

            Assert.AreEqual(dec.ToString(CultureInfo.InvariantCulture), ((FhirDecimal)obs2.GetExtension("http://example.org/DecimalPrecision").Value).Value.Value.ToString(CultureInfo.InvariantCulture));
        }
コード例 #2
0
        public void TestDecimalPrecisionSerializationInJson()
        {
            var dec6  = 6m;
            var dec60 = 6.0m;
            var ext   = new FhirDecimal(dec6);
            var obs   = new Observation();

            obs.AddExtension("http://example.org/DecimalPrecision", ext);

            var json = FhirJsonSerializer.SerializeToString(obs);
            var obs2 = FhirJsonParser.Parse <Observation>(json);

            Assert.AreEqual("6", ((FhirDecimal)obs2.GetExtension("http://example.org/DecimalPrecision").Value).Value.Value.ToString(CultureInfo.InvariantCulture));

            ext = new FhirDecimal(dec60);
            obs = new Observation();
            obs.AddExtension("http://example.org/DecimalPrecision", ext);

            json = FhirJsonSerializer.SerializeToString(obs);
            obs2 = FhirJsonParser.Parse <Observation>(json);

            Assert.AreEqual("6.0", ((FhirDecimal)obs2.GetExtension("http://example.org/DecimalPrecision").Value).Value.Value.ToString(CultureInfo.InvariantCulture));
        }
コード例 #3
0
        internal static Observation ToFhirInternal(BloodPressure bp, Observation observation)
        {
            if (bp.IrregularHeartbeatDetected.HasValue)
            {
                observation.AddExtension(HealthVaultVocabularies.IrregularHeartBeatExtensionName, new FhirBoolean(bp.IrregularHeartbeatDetected.Value));
            }

            var diastolicComponent = new Observation.ComponentComponent
            {
                Code  = HealthVaultVocabularies.GenerateCodeableConcept(HealthVaultVitalStatisticsCodes.BloodPressureDiastolic),
                Value = new Quantity((decimal)bp.Diastolic, UnitAbbreviations.MillimeterOfMecury)
            };

            var systolicComponent = new Observation.ComponentComponent
            {
                Code  = HealthVaultVocabularies.GenerateCodeableConcept(HealthVaultVitalStatisticsCodes.BloodPressureSystolic),
                Value = new Quantity((decimal)bp.Systolic, UnitAbbreviations.MillimeterOfMecury)
            };

            observation.Component = new List <Observation.ComponentComponent> {
                diastolicComponent, systolicComponent
            };

            if (bp.Pulse != null)
            {
                observation.Component.Add(new Observation.ComponentComponent
                {
                    Code  = HealthVaultVocabularies.GenerateCodeableConcept(HealthVaultVitalStatisticsCodes.HeartRate),
                    Value = new Quantity((decimal)bp.Pulse, UnitAbbreviations.PerMinute)
                });
            }

            observation.Effective = new FhirDateTime(bp.When.ToLocalDateTime().ToDateTimeUnspecified());
            observation.Code      = HealthVaultVocabularies.BloodPressure;

            return(observation);
        }