Beispiel #1
0
        internal static AllergyIntolerance ToFhirInternal(Allergy allergy, AllergyIntolerance allergyIntolerance)
        {
            var allergyExtension = new Extension
            {
                Url = HealthVaultExtensions.Allergy
            };

            allergyIntolerance.Code = allergy.Name.ToFhir();

            if (allergy.FirstObserved != null)
            {
                allergyIntolerance.Onset = allergy.FirstObserved.ToFhir();
            }

            if (allergy.AllergenType != null)
            {
                allergyIntolerance.SetAllergyIntoleranceCategory(allergy.AllergenType, allergyExtension);
            }

            if (allergy.Reaction != null)
            {
                allergyIntolerance.Reaction = new List <AllergyIntolerance.ReactionComponent>
                {
                    new AllergyIntolerance.ReactionComponent {
                        Manifestation = new List <CodeableConcept> {
                            allergy.Reaction.ToFhir()
                        },
                        Description = allergy.Reaction.Text
                    }
                };
            }

            if (allergy.TreatmentProvider != null)
            {
                allergyIntolerance.AddAsserter(allergy.TreatmentProvider.ToFhir());
            }

            if (allergy.Treatment != null)
            {
                allergyExtension.AddExtension(HealthVaultExtensions.AllergyTreatement, allergy.Treatment.ToFhir());
            }

            if (allergy.AllergenCode != null)
            {
                allergyExtension.AddExtension(HealthVaultExtensions.AllergenCode, allergy.AllergenCode.ToFhir());
            }

            if (allergy.IsNegated != null)
            {
                if (allergy.IsNegated.Value)
                {
                    allergyIntolerance.ClinicalStatus = AllergyIntoleranceClinicalStatus.Resolved;
                }
                else
                {
                    allergyIntolerance.ClinicalStatus = AllergyIntoleranceClinicalStatus.Active;
                }
            }

            if (allergy.CommonData != null && allergy.CommonData.Note != null)
            {
                var note = new Hl7.Fhir.Model.Annotation();
                note.Text = allergy.CommonData.Note;
                allergyIntolerance.Note = new List <Hl7.Fhir.Model.Annotation> {
                    note
                };
            }

            allergyIntolerance.Type = AllergyIntoleranceType.Allergy;
            allergyIntolerance.Extension.Add(allergyExtension);
            return(allergyIntolerance);
        }