Exemplo n.º 1
0
        private Observation.ComponentComponent buildValue(string serviceid, fhir.model.TestResultParameter p)
        {
            var ret = new Observation.ComponentComponent()
            {
                Code = new CodeableConcept(string.Format(Constants.SERVICE_PARAMETERS_CODING_SYSTEM, serviceid), p.Id, $"[{p.Code}] {p.Name}"),
                //Value = buildValue(p),
                Interpretation = p.Flags?.Select(f => new CodeableConcept(Constants.RESULT_FLAGS_SYSTEM, f.Code, f.Name)).ToList(),
                ReferenceRange = buildReferenceRanges(p.ReferenceRange)
            };


            if (p.Value.NumericValue.HasValue)
            {
                ret.Value = new Quantity(p.Value.NumericValue.Value, p.Unit);
            }
            else if (p.Value.TextValue.StartsWith("<") || p.Value.TextValue.StartsWith(">"))
            {
                try
                {
                    var nv = decimal.Parse(p.Value.TextValue.Substring(1), System.Globalization.CultureInfo.InvariantCulture);
                    ret.Value = new Quantity(nv, p.Unit)
                    {
                        Comparator =
                            p.Value.TextValue.StartsWith("<") ? Quantity.QuantityComparator.LessThan : Quantity.QuantityComparator.GreaterThan
                    };
                }
                catch (Exception) { }
            }
            if (ret.Value == null)
            {
                ret.Value = new FhirString(p.Value.TextValue);
            }

            return(ret);
        }
Exemplo n.º 2
0
        private static void SetSystolic(BloodPressure bloodPressure, Observation.ComponentComponent component)
        {
            var systolic = ObservationToHealthVault.GetValueFromQuantity(component.Value as Quantity);

            if (systolic.HasValue)
            {
                bloodPressure.Systolic = (int)systolic.Value;
            }
        }
Exemplo n.º 3
0
        private static void SetPulse(BloodPressure bloodPressure, Observation.ComponentComponent component)
        {
            var pulse = ObservationToHealthVault.GetValueFromQuantity(component.Value as Quantity);

            if (pulse.HasValue)
            {
                bloodPressure.Pulse = (int)pulse.Value;
            }
        }
        internal static Observation ToFhirInternal(BodyComposition bodyComposition, Observation observation)
        {
            observation.Category = new List <CodeableConcept> {
                FhirCategories.VitalSigns
            };

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

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

            if (bodyComposition.MeasurementName != null)
            {
                observation.Component.Add(new Observation.ComponentComponent {
                    Code = bodyComposition.MeasurementName.ToFhir()
                });
            }

            if (bodyComposition.Value.MassValue != null)
            {
                var massValue = new Observation.ComponentComponent
                {
                    Code  = bodyComposition.MeasurementName.ToFhir(),
                    Value = new Quantity((decimal)bodyComposition.Value.MassValue.Kilograms, UnitAbbreviations.Kilogram)
                };
                observation.Component.Add(massValue);
            }

            if (bodyComposition.Value.PercentValue.HasValue)
            {
                var percentageValue = new Observation.ComponentComponent
                {
                    Code  = bodyComposition.MeasurementName.ToFhir(),
                    Value = new Quantity((decimal)bodyComposition.Value.PercentValue.Value, UnitAbbreviations.Percent)
                };
                observation.Component.Add(percentageValue);
            }

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

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

            return(observation);
        }
Exemplo n.º 5
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);
        }
            }                                                                                                                                      // BuildMemberBase.cs:117

            // BuildMemberBase.cs:119
            // BuildMemberBase.cs:120
            /// <summary>
            /// Read item.
            /// </summary>
            public void ReadItem(BreastRadiologyDocument doc, Observation.ComponentComponent item)                                                 // BuildMemberBase.cs:123
            {                                                                                                                                      // BuildMemberBase.cs:124
                this.Value = (CodeableConcept)item.Value;                                                                                          // BuildMemberComponents.cs:53
            }                                                                                                                                      // BuildMemberBase.cs:127
Exemplo n.º 7
0
        internal static Observation ToFhirInternal(Exercise exercise, Observation observation)
        {
            observation.Code = HealthVaultVocabularies.GenerateCodeableConcept(HealthVaultThingTypeNameCodes.Exercise);

            if (exercise.Distance != null)
            {
                var distanceValue = new Observation.ComponentComponent
                {
                    Code = new CodeableConcept {
                        Text = HealthVaultVocabularies.ExerciseDistance
                    },
                    Value = new Quantity((decimal)exercise.Distance.Value, UnitAbbreviations.Meter)
                };
                observation.Component.Add(distanceValue);
            }

            if (exercise.Duration != null)
            {
                var durationValue = new Observation.ComponentComponent
                {
                    Code = new CodeableConcept {
                        Text = HealthVaultVocabularies.ExerciseDuration
                    },
                    Value = new Quantity((decimal)exercise.Duration.Value, UnitAbbreviations.Minute)
                };
                observation.Component.Add(durationValue);
            }

            observation.Text = new Narrative
            {
                Div = exercise.Title
            };

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

            var activityValue = new Observation.ComponentComponent
            {
                Code = new CodeableConcept {
                    Text = HealthVaultVocabularies.ExerciseActivity
                },
                Value = exercise.Activity.ToFhir()
            };

            observation.Component.Add(activityValue);

            if (exercise.Details != null)
            {
                foreach (var detail in exercise.Details)
                {
                    observation.Extension.Add(CreateDetailExtension(detail.Key, detail.Value));
                }
            }

            if (!exercise.Segments.IsNullOrEmpty())
            {
                foreach (var segment in exercise.Segments)
                {
                    observation.Extension.Add(CreateSegmentExtension(segment));
                }
            }

            return(observation);
        }
Exemplo n.º 8
0
        private Observation makeABPMObservation(BPMCompleteSequence seqtomake)
        {
            // Link https://stackoverflow.com/questions/311165/how-do-you-convert-a-byte-array-to-a-hexadecimal-string-and-vice-versa

            string rawdata = new string("");

            foreach (var sample in seqtomake.SequenceOfBPMSamples)
            {
                rawdata += ByteArrayToString(sample.BPMSamples);
            }

            var eob = new Observation();

            eob.Id     = seqtomake.NameOfObject; //"EKG-odjvbhofdjghodfgofg"; //JRT Be careful when
            eob.Status = ObservationStatus.Final;
            eob.Category.Add(new CodeableConcept()
            {
                Coding = new List <Coding>()
            });
            eob.Category[0].Coding.Add(new Coding()
            {
                Code = "BPM Measurement", System = "http://terminology.hl7.org/CodeSystem/observation-category", Display = "Procedure"
            });
            eob.Code = new CodeableConcept();
            eob.Code.Coding.Add(new Coding()
            {
                System = "urn:oid:1.2.3.4.5.6", Code = "AUH131328", Display = "MDC_BPM_Phys_Sequence"
            });
            eob.Subject           = new ResourceReference();
            eob.Subject.Reference = "AU-ECE-ST-E20";
            eob.Subject.Display   = "E20ST3PRJ3-NVK";

            //eob.Effective = new FhirDateTime("2015-02-19T09:30:35+01:00");
            //eob.Effective = new FhirDateTime(DateTime.Now);
            //For DateTime and DataTimeOffset se link https://docs.microsoft.com/en-us/dotnet/standard/datetime/converting-between-datetime-and-offset
            DateTimeOffset dtoff = DateTime.SpecifyKind(seqtomake.StartTime, DateTimeKind.Utc);

            eob.Effective = new FhirDateTime(dtoff); //JRT
            eob.Performer.Add(new ResourceReference()
            {
                Reference = "Student/E20", Display = "Students from E20STS3NVK"
            });
            eob.Device         = new ResourceReference();
            eob.Device.Display = "1 Transducer Device mmHG Metric";
            var m = new Observation.ComponentComponent();

            m.Code = new CodeableConcept();
            m.Code.Coding.Add(new Coding()
            {
                System = "urn:oid:1.2.3.4.5.6", Code = "AUH131328", Display = "MDC_BPM_Phys_Sequence_1"
            });
            m.Value = new SampledData()
            {
                Origin = new SimpleQuantity {
                    Value = 2048
                },                           //??
                Period     = 3600,           //??
                Factor     = (decimal)1.612, //??
                LowerLimit = -3300,          //??
                UpperLimit = 3300,           //??
                Dimensions = 1,
                Data       = rawdata,
            };
            eob.Component.Add(m);//Add the new data block to Observation

            //But then how to access the justed  in line 89  added SampleData Object again??
            //Well remark that Observation.ComponentComponent.Value attribute is an Element class Just place cursor over m.Value
            //Then important to notice is that SampleData class inherits the Element class! Why do you think this is the case?
            //Now a type cast is needed to acces Value as a SampleData Class just as showen in next line
            var    x = (SampledData)eob.Component[0].Value;
            string d = x.Data;

            //Lesson learned: As JSON does not cares about specific object types, class definitions does not exist in JSON. In C# we do
            //need to make polymorph classes shaping more than one class. Element class shapes all needed HL7 FHIR classes in Component,
            //SampleData shapes only one specific class but can be carried in an Element class


            return(eob);
        }
Exemplo n.º 9
0
        private Observation makeAObservation()
        {
            List <int> rawdata = new List <int> {
                2041, 2043, 2037, 2047, 2060, 2062, 2051, 2023, 2014, 2027, 2034, 2033, 2040, 2047, 2047, 2053, 2058, 2064, 2059, 2063, 2061, 2052, 2053, 2038, 1966, 1885, 1884, 2009, 2129, 2166, 2137, 2102, 2086, 2077, 2067, 2067, 2060, 2059, 2062, 2062, 2060, 2057, 2045, 2047, 2057, 2054, 2042, 2029, 2027, 2018, 2007, 1995, 2001, 2012, 2024, 2039, 2068, 2092, 2111, 2125, 2131, 2148, 2137, 2138, 2128, 2128, 2115, 2099, 2097, 2096, 2101, 2101, 2091, 2073, 2076, 2077, 2084, 2081, 2088, 2092, 2070, 2069, 2074, 2077, 2075, 2068, 2064, 2060, 2062, 2074, 2075, 2074, 2075, 2063, 2058, 2058, 2064, 2064, 2070, 2074, 2067, 2060, 2062, 2063, 2061, 2059, 2048, 2052, 2049, 2048, 2051, 2059, 2059, 2066, 2077, 2073,
            };
            var eob = new Observation();

            eob.Id     = "EKG-odjvbhofdjghodfgofg";
            eob.Status = ObservationStatus.Final;
            //eob.Text = new Narrative();
            //eob.Text.Status = Narrative.NarrativeStatus.Generated;
            //eob.Text.Div = "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: ekg</p><p><b>status</b>: final</p><p><b>category</b>: Procedure <span>(Details : {http://terminology.hl7.org/CodeSystem/observation-category code 'procedure' = 'Procedure', given as 'Procedure'})</span></p><p><b>code</b>: MDC_ECG_ELEC_POTL <span>(Details : {urn:oid:2.16.840.1.113883.6.24 code '131328' = '131328', given as 'MDC_ECG_ELEC_POTL'})</span></p><p><b>subject</b>: <a>P. van de Heuvel</a></p><p><b>effective</b>: 19/02/2015 9:30:35 AM</p><p><b>performer</b>: <a>A. Langeveld</a></p><p><b>device</b>: 12 lead EKG Device Metric</p><blockquote><p><b>component</b></p><p><b>code</b>: MDC_ECG_ELEC_POTL_I <span>(Details : {urn:oid:2.16.840.1.113883.6.24 code '131329' = '131329', given as 'MDC_ECG_ELEC_POTL_I'})</span></p><p><b>value</b>: Origin: (system = '[not stated]' code null = 'null'), Period: 10, Factor: 1.612, Lower: -3300, Upper: 3300, Dimensions: 1, Data: 2041 2043 2037 2047 2060 2062 2051 2023 2014 2027 2034 2033 2040 2047 2047 2053 2058 2064 2059 2063 2061 2052 2053 2038 1966 1885 1884 2009 2129 2166 2137 2102 2086 2077 2067 2067 2060 2059 2062 2062 2060 2057 2045 2047 2057 2054 2042 2029 2027 2018 2007 1995 2001 2012 2024 2039 2068 2092 2111 2125 2131 2148 2137 2138 2128 2128 2115 2099 2097 2096 2101 2101 2091 2073 2076 2077 2084 2081 2088 2092 2070 2069 2074 2077 2075 2068 2064 2060 2062 2074 2075 2074 2075 2063 2058 2058 2064 2064 2070 2074 2067 2060 2062 2063 2061 2059 2048 2052 2049 2048 2051 2059 2059 2066 2077 2073</p></blockquote><blockquote><p><b>component</b></p><p><b>code</b>: MDC_ECG_ELEC_POTL_II <span>(Details : {urn:oid:2.16.840.1.113883.6.24 code '131330' = '131330', given as 'MDC_ECG_ELEC_POTL_II'})</span></p><p><b>value</b>: Origin: (system = '[not stated]' code null = 'null'), Period: 10, Factor: 1.612, Lower: -3300, Upper: 3300, Dimensions: 1, Data: 2041 2043 2037 2047 2060 2062 2051 2023 2014 2027 2034 2033 2040 2047 2047 2053 2058 2064 2059 2063 2061 2052 2053 2038 1966 1885 1884 2009 2129 2166 2137 2102 2086 2077 2067 2067 2060 2059 2062 2062 2060 2057 2045 2047 2057 2054 2042 2029 2027 2018 2007 1995 2001 2012 2024 2039 2068 2092 2111 2125 2131 2148 2137 2138 2128 2128 2115 2099 2097 2096 2101 2101 2091 2073 2076 2077 2084 2081 2088 2092 2070 2069 2074 2077 2075 2068 2064 2060 2062 2074 2075 2074 2075 2063 2058 2058 2064 2064 2070 2074 2067 2060 2062 2063 2061 2059 2048 2052 2049 2048 2051 2059 2059 2066 2077 2073</p></blockquote><blockquote><p><b>component</b></p><p><b>code</b>: MDC_ECG_ELEC_POTL_III <span>(Details : {urn:oid:2.16.840.1.113883.6.24 code '131389' = '131389', given as 'MDC_ECG_ELEC_POTL_III'})</span></p><p><b>value</b>: Origin: (system = '[not stated]' code null = 'null'), Period: 10, Factor: 1.612, Lower: -3300, Upper: 3300, Dimensions: 1, Data: 2041 2043 2037 2047 2060 2062 2051 2023 2014 2027 2034 2033 2040 2047 2047 2053 2058 2064 2059 2063 2061 2052 2053 2038 1966 1885 1884 2009 2129 2166 2137 2102 2086 2077 2067 2067 2060 2059 2062 2062 2060 2057 2045 2047 2057 2054 2042 2029 2027 2018 2007 1995 2001 2012 2024 2039 2068 2092 2111 2125 2131 2148 2137 2138 2128 2128 2115 2099 2097 2096 2101 2101 2091 2073 2076 2077 2084 2081 2088 2092 2070 2069 2074 2077 2075 2068 2064 2060 2062 2074 2075 2074 2075 2063 2058 2058 2064 2064 2070 2074 2067 2060 2062 2063 2061 2059 2048 2052 2049 2048 2051 2059 2059 2066 2077 2073</p></blockquote></div>";
            eob.Category.Add(new CodeableConcept()
            {
                Coding = new List <Coding>()
            });
            eob.Category[0].Coding.Add(new Coding()
            {
                Code = "procedure", System = "http://terminology.hl7.org/CodeSystem/observation-category", Display = "Procedure"
            });
            eob.Code = new CodeableConcept();
            eob.Code.Coding.Add(new Coding()
            {
                System = "urn:oid:2.16.840.1.113883.6.24", Code = "131328", Display = "MDC_ECG_ELEC_POTL"
            });
            eob.Subject           = new ResourceReference();
            eob.Subject.Reference = "reference";
            eob.Subject.Display   = "P. van de Heuvel";
            eob.Effective         = new FhirDateTime("2015-02-19T09:30:35+01:00");
            eob.Performer.Add(new ResourceReference()
            {
                Reference = "Practitioner/f005", Display = "A. Langeveld"
            });
            eob.Device         = new ResourceReference();
            eob.Device.Display = "12 lead EKG Device Metric";
            var m = new Observation.ComponentComponent();

            m.Code = new CodeableConcept();
            m.Code.Coding.Add(new Coding()
            {
                System = "urn:oid:2.16.840.1.113883.6.24", Code = "131389", Display = "MDC_ECG_ELEC_POTL_I"
            });
            m.Value = new Hl7.Fhir.Model.SampledData()
            {
                Origin = new SimpleQuantity {
                    Value = 2048
                },
                Period     = 10,
                Factor     = (decimal)1.612,
                LowerLimit = -3300,
                UpperLimit = 3300,
                Dimensions = 1,
                Data       = "2041 2043 2037 2047 2060 2062 2051 2023 2014 2027 2034 2033 2040 2047 2047 2053 2058 2064 2059 2063 2061 2052 2053 2038 1966 1885 1884 2009 2129 2166 2137 2102 2086 2077 2067 2067 2060 2059 2062 2062 2060 2057 2045 2047 2057 2054 2042 2029 2027 2018 2007 1995 2001 2012 2024 2039 2068 2092 2111 2125 2131 2148 2137 2138 2128 2128 2115 2099 2097 2096 2101 2101 2091 2073 2076 2077 2084 2081 2088 2092 2070 2069 2074 2077 2075 2068 2064 2060 2062 2074 2075 2074 2075 2063 2058 2058 2064 2064 2070 2074 2067 2060 2062 2063 2061 2059 2048 2052 2049 2048 2051 2059 2059 2066 2077 2073"
            };
            eob.Component.Add(m);
            var m1 = new Observation.ComponentComponent();

            m1.Code = new CodeableConcept();
            m1.Code.Coding.Add(new Coding()
            {
                System = "urn:oid:2.16.840.1.113883.6.24", Code = "131329", Display = "MDC_ECG_ELEC_POTL_I"
            });
            m1.Value = new Hl7.Fhir.Model.SampledData()
            {
                Origin = new SimpleQuantity()
                {
                    Value = 2048
                },
                Period     = 10,
                Factor     = (decimal)1.612,
                LowerLimit = -3300,
                UpperLimit = 3300,
                Dimensions = 1,
                Data       = rawdata.ToString()
                             //Data = "2041 2043 2037 2047 2060 2062 2051 2023 2014 2027 2034 2033 2040 2047 2047 2053 2058 2064 2059 2063 2061 2052 2053 2038 1966 1885 1884 2009 2129 2166 2137 2102 2086 2077 2067 2067 2060 2059 2062 2062 2060 2057 2045 2047 2057 2054 2042 2029 2027 2018 2007 1995 2001 2012 2024 2039 2068 2092 2111 2125 2131 2148 2137 2138 2128 2128 2115 2099 2097 2096 2101 2101 2091 2073 2076 2077 2084 2081 2088 2092 2070 2069 2074 2077 2075 2068 2064 2060 2062 2074 2075 2074 2075 2063 2058 2058 2064 2064 2070 2074 2067 2060 2062 2063 2061 2059 2048 2052 2049 2048 2051 2059 2059 2066 2077 2073"
            };
            eob.Component.Add(m1);
            var m2 = new Observation.ComponentComponent();

            m2.Code = new CodeableConcept();
            m2.Code.Coding.Add(new Coding()
            {
                System = "urn:oid:2.16.840.1.113883.6.24", Code = "131330", Display = "MDC_ECG_ELEC_POTL_I"
            });
            m2.Value = new Hl7.Fhir.Model.SampledData()
            {
                Origin = new SimpleQuantity()
                {
                    Value = 2048
                },
                Period     = 10,
                Factor     = (decimal)1.612,
                LowerLimit = -3300,
                UpperLimit = 3300,
                Dimensions = 1,
                Data       = "2041 2043 2037 2047 2060 2062 2051 2023 2014 2027 2034 2033 2040 2047 2047 2053 2058 2064 2059 2063 2061 2052 2053 2038 1966 1885 1884 2009 2129 2166 2137 2102 2086 2077 2067 2067 2060 2059 2062 2062 2060 2057 2045 2047 2057 2054 2042 2029 2027 2018 2007 1995 2001 2012 2024 2039 2068 2092 2111 2125 2131 2148 2137 2138 2128 2128 2115 2099 2097 2096 2101 2101 2091 2073 2076 2077 2084 2081 2088 2092 2070 2069 2074 2077 2075 2068 2064 2060 2062 2074 2075 2074 2075 2063 2058 2058 2064 2064 2070 2074 2067 2060 2062 2063 2061 2059 2048 2052 2049 2048 2051 2059 2059 2066 2077 2073"
            };
            eob.Component.Add(m2);

            return(eob);
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            var observation = new Observation
            {
                Meta = new Meta
                {
                    Profile = new string[] { "http://hl7.org/fhir/StructureDefinition/vitalsigns" }
                }
            };

            observation.Identifier = new List <Identifier> {
                new Identifier("urn:ietf:rfc:3986", "urn:uuid:" + System.Guid.NewGuid())
            };
            observation.Status   = ObservationStatus.Final;
            observation.Category = new List <CodeableConcept> {
                new CodeableConcept("http://terminology.hl7.org/CodeSystem/observation-category", "vital-signs", "Vital Signs")
            };
            observation.Code      = new CodeableConcept("http://loinc.org", "85354-9", "Blood pressure panel with all children optional", "Blood pressure systolic & diastolic");
            observation.Subject   = new ResourceReference("Patient/example");
            observation.Effective = new FhirDateTime();
            observation.Performer = new List <ResourceReference> {
                new ResourceReference("Practitioner/example")
            };
            observation.Interpretation = new List <CodeableConcept> {
                new CodeableConcept("http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", "L", "low", "Below low normal")
            };
            observation.BodySite = new CodeableConcept("http://snomed.info/sct", "368209003", "Right arm", "Right arm");


            var systolicCodings = new List <Coding>()
            {
                new Coding("http://loinc.org", "8480-6", "Systolic blood pressure"), new Coding("http://loinc.org", "271649006", "Systolic blood pressure")
            };
            var systolicComponent = new Observation.ComponentComponent();

            systolicComponent.Code = new CodeableConcept {
                Coding = systolicCodings
            };
            systolicComponent.Value          = new Quantity(107, "mmHg");
            systolicComponent.Interpretation = new List <CodeableConcept> {
                new CodeableConcept("http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", "N", "display", "Normal")
            };

            var diastolicCodings = new List <Coding>()
            {
                new Coding("http://loinc.org", "8462-4", "Diastolic blood pressure")
            };
            var diastolicComponent = new Observation.ComponentComponent();

            diastolicComponent.Code = new CodeableConcept {
                Coding = diastolicCodings
            };
            diastolicComponent.DataAbsentReason = new CodeableConcept("http://terminology.hl7.org/CodeSystem/data-absent-reason", "not-performed", "Not Performed");

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

            new FhirClient("http://localhost:8080/hapi-fhir-jpaserver/fhir/")
            .Create <Observation>(observation);
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            const string kDeviceId       = "device-0001";
            const string kObservationId  = "bp-0001";
            const string kPatientId      = "patient-0001";
            const string kPractitionerId = "practitioner-0001";

            Patient patient = new Patient()
            {
                Id = kPatientId
            };

            patient.Name.Add(HumanName.ForFamily("Miranda").WithGiven("Jorge"));

            Practitioner practitioner = new Practitioner()
            {
                Id = kPractitionerId
            };

            practitioner.Name.Add(HumanName.ForFamily("Banerjee").WithGiven("Suprateek"));

            Device device = new Device()
            {
                Id           = kDeviceId,
                Manufacturer = "A&D",
                Model        = "UA-651BLE"
            };

            Observation observation = new Observation()
            {
                Id      = kObservationId,
                Device  = new ResourceReference("Device/" + kDeviceId),
                Subject = new ResourceReference("Patient" + kPatientId)
            };

            observation.Performer.Add(new ResourceReference("Practitioner" + kPractitionerId));

            /* Systolic component */
            Observation.ComponentComponent systolic = new Observation.ComponentComponent();
            systolic.Code = new CodeableConcept();
            systolic.Code.Coding.Add(new Coding("http://loinc.org", "8480 - 6"));
            systolic.Code.Coding.Add(new Coding("http://snomed.info/sct", "271649006"));
            systolic.Value = new Quantity()
            {
                Value = 107,
                Unit  = "mmHg",
                Code  = "mm[Hg]"
            };
            systolic.Interpretation = new CodeableConcept("http://hl7.org/fhir/v2/0078", "N", "normal");

            /* Diastolic component */
            Observation.ComponentComponent diastolic = new Observation.ComponentComponent();
            diastolic.Code  = new CodeableConcept("http://loinc.org", "8462-4");
            diastolic.Code  = new CodeableConcept("http://snomed.info/sct", "271650006");
            diastolic.Value = new Quantity()
            {
                Value = 60,
                Unit  = "mmHg",
                Code  = "mm[Hg]"
            };
            diastolic.Interpretation = new CodeableConcept("http://hl7.org/fhir/v2/0078", "L", "low");

            observation.Component.Add(systolic);
            observation.Component.Add(diastolic);

            string json = FhirSerializer.SerializeToJson(observation);
        }
Exemplo n.º 12
0
        internal static Observation ToFhirInternal(SleepJournalAM sleepJournalAM, Observation observation)
        {
            observation.Code = HealthVaultVocabularies.GenerateCodeableConcept(HealthVaultThingTypeNameCodes.SleepJournalAM);

            observation.Effective = new FhirDateTime(sleepJournalAM.When.ToLocalDateTime().ToDateTimeUnspecified());

            observation.Component = new List <Observation.ComponentComponent>();

            var bedtimeComponent = new Observation.ComponentComponent
            {
                Code = new CodeableConcept {
                    Text = HealthVaultVocabularies.SleepJournalAMBedtime
                },
                Value = sleepJournalAM.Bedtime.ToFhir()
            };

            observation.Component.Add(bedtimeComponent);

            var waketimeComponent = new Observation.ComponentComponent
            {
                Code = new CodeableConcept {
                    Text = HealthVaultVocabularies.SleepJournalAMWaketime
                },
                Value = sleepJournalAM.WakeTime.ToFhir()
            };

            observation.Component.Add(waketimeComponent);

            var sleepMinutesComponent = new Observation.ComponentComponent
            {
                Code = new CodeableConcept {
                    Text = HealthVaultVocabularies.SleepJournalAMSleepMinutes
                },
                Value = new Quantity(sleepJournalAM.SleepMinutes, UnitAbbreviations.Minute)
            };

            observation.Component.Add(sleepMinutesComponent);

            var settlingMinutesComponent = new Observation.ComponentComponent
            {
                Code = new CodeableConcept {
                    Text = HealthVaultVocabularies.SleepJournalAMSettlingMinutes
                },
                Value = new Quantity(sleepJournalAM.SettlingMinutes, UnitAbbreviations.Minute)
            };

            observation.Component.Add(settlingMinutesComponent);

            if (sleepJournalAM.Awakenings != null)
            {
                foreach (var awakening in sleepJournalAM.Awakenings)
                {
                    var dummyDateTimeStart = new DateTime(sleepJournalAM.When.Date.Year, sleepJournalAM.When.Date.Month, sleepJournalAM.When.Date.Day);
                    dummyDateTimeStart = dummyDateTimeStart.AddHours(awakening.When.Hour);
                    dummyDateTimeStart = dummyDateTimeStart.AddMinutes(awakening.When.Minute);
                    if (awakening.When.Second.HasValue)
                    {
                        dummyDateTimeStart = dummyDateTimeStart.AddSeconds(awakening.When.Second.Value);
                    }

                    if (awakening.When.Millisecond.HasValue)
                    {
                        dummyDateTimeStart = dummyDateTimeStart.AddSeconds(awakening.When.Millisecond.Value);
                    }

                    var dummyDateTimeEnd = dummyDateTimeStart;
                    dummyDateTimeEnd = dummyDateTimeEnd.AddMinutes(awakening.Minutes);

                    var awakeningComponent = new Observation.ComponentComponent
                    {
                        Code = new CodeableConcept {
                            Text = HealthVaultVocabularies.SleepJournalAMAwakening
                        },
                        Value = new Period(new FhirDateTime(dummyDateTimeStart), new FhirDateTime(dummyDateTimeEnd)),
                    };
                    observation.Component.Add(awakeningComponent);
                }
            }

            var wakeStateComponent = new Observation.ComponentComponent
            {
                Code = new CodeableConcept {
                    Text = HealthVaultVocabularies.SleepJournalAMWakeState
                },
                Value = new FhirString(sleepJournalAM.WakeState.ToString()),
            };

            observation.Component.Add(wakeStateComponent);

            if (sleepJournalAM.Medications != null)
            {
                var medicationComponenet = new Observation.ComponentComponent
                {
                    Code = new CodeableConcept {
                        Text = HealthVaultVocabularies.SleepJournalAMMedication
                    },
                    Value = sleepJournalAM.Medications.ToFhir(),
                };
                observation.Component.Add(medicationComponenet);
            }

            return(observation);
        }