public ApiPatient(IElementNavigator RelatedPerson)
     : base(RelatedPerson)
 {
     if (RelatedPerson.Select("extension.where(url='https://apinams.ehealthvendortest.health.gov.au/fhir/v1.0.0/StructureDefinition/indigenous-status').value.as(Coding).display").IsAny())
     {
         this.IndigenousStatusDescription = RelatedPerson.Select("extension.where(url='https://apinams.ehealthvendortest.health.gov.au/fhir/v1.0.0/StructureDefinition/indigenous-status').value.as(Coding).display").First().Value.ToString();
     }
 }
        public void TestResolve()
        {
            var statement = "Bundle.entry.where(fullUrl = 'http://example.org/fhir/Patient/e')" +
                            ".resource.managingOrganization.resolve().id";

            var result = _bundleNav.Select(statement);

            Assert.AreEqual(1, result.Count());
            Assert.AreEqual("orgY", result.First().Value);

            //var resultPoco = _parsed.Select(statement).SingleOrDefault() as Organization;
            //Assert.IsNotNull(resultPoco);
            //Assert.AreEqual("orgY", resultPoco.Id);
        }
Exemple #3
0
        public static IElementNavigator QuerySelect(this IElementNavigator nav, Query query)
        {
            var root = ElementNode.Node(query.From);

            foreach (var field in query.Fields)
            {
                var subtree = nav.Select(field.Expression);
                root.Apply(subtree, field.Name);
            }
            return(root.ToNavigator());
        }
Exemple #4
0
        public void ResolveQuery()
        {
            string statement = "Bundle.entry.where(fullUrl = 'http://example.org/fhir/Patient/e')"
                               + ".resource.id";
            var result = _bundleNavigator.Select(statement);

            Assert.AreEqual(1, result.Count());
            Assert.AreEqual("e", result.First().Value);

            statement = "Bundle.entry.where(fullUrl = 'http://example.org/fhir/Patient/e')"
                        + ".resource.managingOrganization.reference";
            result = _bundleNavigator.Select(statement);
            Assert.AreEqual(1, result.Count());
            Assert.AreEqual("#orgY", result.First().Value);

            statement = "Bundle.entry.where(fullUrl = 'http://example.org/fhir/Patient/e')"
                        + ".resource.managingOrganization.resolve().id";
            result = _bundleNavigator.Select(statement);
            Assert.AreEqual(1, result.Count());
            Assert.AreEqual("orgY", result.First().Value);
        }
Exemple #5
0
 public static IEnumerable <IElementNavigator> Select(this IElementNavigator input, string expression, IElementNavigator resource)
 {
     return(input.Select(expression, new EvaluationContext(resource)));
 }
Exemple #6
0
        public ApiRelatedPerson(IElementNavigator RelatedPerson)
        {
            if (RelatedPerson.Select("id").IsAny())
            {
                this.FhirId = RelatedPerson.Select("id").First().Value.ToString();
            }
            if (RelatedPerson.Select("identifier.where(system = 'http://ns.electronichealth.net.au/id/hi/ihi/1.0').value").IsAny())
            {
                this.Ihi = RelatedPerson.Select("identifier.where(system = 'http://ns.electronichealth.net.au/id/hi/ihi/1.0').value").First().Value.ToString();
            }

            if (RelatedPerson.Select("name").IsAny())
            {
                if (RelatedPerson.Select("name.family").IsAny())
                {
                    this.Family = RelatedPerson.Select("name.family").First().Value.ToString();
                }

                if (RelatedPerson.Select("name.given").IsAny())
                {
                    this.Given = RelatedPerson.Select("name.given").First().Value.ToString();
                }
            }
            if (RelatedPerson.Select("birthDate").IsAny())
            {
                FhirDateTime FhirDate = new FhirDateTime(RelatedPerson.Select("birthDate").First().Value.ToString());
                this.Dob = FhirDate.ToDateTime();
            }

            if (RelatedPerson.Select("birthDate").IsAny())
            {
                this.Sex = RelatedPerson.Select("gender").First().Value.ToString().ToLower();
                switch (this.Sex)
                {
                case "female":
                    this.Gender = AdministrativeGender.Female;
                    break;

                case "male":
                    this.Gender = AdministrativeGender.Male;
                    break;

                case "other":
                    this.Gender = AdministrativeGender.Other;
                    break;

                case "unknown":
                    this.Gender = AdministrativeGender.Unknown;
                    break;

                default:
                    break;
                }
            }

            if (RelatedPerson.Select("relationship.extension.where(url='https://apinams.ehealthvendortest.health.gov.au/fhir/v1.0.0/StructureDefinition/relationship-type').value.as(CodeableConcept).coding.code").IsAny())
            {
                string RelationshipCode = RelatedPerson.Select("relationship.extension.where(url='https://apinams.ehealthvendortest.health.gov.au/fhir/v1.0.0/StructureDefinition/relationship-type').value.as(CodeableConcept).coding.code").First().Value.ToString();
                switch (RelationshipCode)
                {
                case "RT001":
                    this.RelationshipType        = ApiEnum.RelationshipType.Self;
                    this.RelationshipDescription = "Self";
                    break;

                case "RT002":
                    this.RelationshipType        = ApiEnum.RelationshipType.Under18ParentalResponsibility;
                    this.RelationshipDescription = "Under 18 - Parental Responsibility";
                    break;

                case "RT003":
                    this.RelationshipType        = ApiEnum.RelationshipType.Under18LegalAuthority;
                    this.RelationshipDescription = "Under 18 - Legal Authority";
                    break;

                case "RT004":
                    this.RelationshipType        = ApiEnum.RelationshipType.UnderAge18OtherwiseAppropriatePerson;
                    this.RelationshipDescription = "Under 18 - Otherwise Appropriate Person";
                    break;

                case "RT005":
                    this.RelationshipType        = ApiEnum.RelationshipType.Under18LegalAuthority;
                    this.RelationshipDescription = "18 and Over - Legal Authority";
                    break;

                case "RT006":
                    this.RelationshipType        = ApiEnum.RelationshipType.Age18andOverOtherwiseAppropriatePerson;
                    this.RelationshipDescription = "18 and Over - Otherwise Appropriate Person";
                    break;

                case "RT007":
                    this.RelationshipType        = ApiEnum.RelationshipType.FullAccessNominatedRepresentative;
                    this.RelationshipDescription = "Full Access Nominated Representative";
                    break;

                case "RT008":
                    this.RelationshipType        = ApiEnum.RelationshipType.NominatedRepresentative;
                    this.RelationshipDescription = "Nominated Representative";
                    break;

                default:
                    throw new FormatException($"Unknown ApiRelatedPerson.RelationshipType of {this.RelationshipType.ToString()}");
                }
            }
        }