public static string ToDateTimeString(this FhirDateTime fhirDateTime, string format) { return(fhirDateTime?.ToDateTime().Value.ToString(format)); }
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()}"); } } }