/// <summary> /// Deserialize JSON into a FHIR PractitionerRole /// </summary> public static void DeserializeJson(this PractitionerRole current, ref Utf8JsonReader reader, JsonSerializerOptions options) { string propertyName; while (reader.Read()) { if (reader.TokenType == JsonTokenType.EndObject) { return; } if (reader.TokenType == JsonTokenType.PropertyName) { propertyName = reader.GetString(); if (Hl7.Fhir.Serialization.FhirSerializerOptions.Debug) { Console.WriteLine($"PractitionerRole >>> PractitionerRole.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"PractitionerRole: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
public void Make(int b, List <string> rx) { practitioner = new Practitioner(); role = new PractitionerRole(); organisation = new Organization(); DoPractitioner(b, rx); DoOrg(b, rx); DoRole(b, rx); }
public bool Has(PractitionerRole r) { if (role == null) { return(false); } if (r == null) { return(false); } return(role.IsExactly(r)); }
public ClientPractionerRole SkapaTestPractionRole2() { PractitionerRole practionerRole = new PractitionerRole(); practionerRole.Identifier = new List <Identifier>(); practionerRole.Identifier.Add(new Identifier() { Value = "practionerRole 3", Use = Identifier.IdentifierUse.Old }); practionerRole.Identifier.Add(new Identifier() { Value = "practionerRole 4", Use = Identifier.IdentifierUse.Usual }); practionerRole.Active = true; return(new ClientPractionerRole(practionerRole)); }
public override Practitioner FromXml(XElement element) { if (element == null) { return(null); } var practitioner = new Practitioner { Id = Guid.NewGuid().ToString(), Meta = new Meta { Profile = new List <string> { "http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner" } } }; var role = new PractitionerRole() { Id = Guid.NewGuid().ToString(), Practitioner = new ResourceReference($"{practitioner.TypeName}/{practitioner.Id}") }; var location = new Location { Id = Guid.NewGuid().ToString() }; foreach (var child in element.Elements()) { switch (child.Name.LocalName) { case "id": var id = FromXml(new IdentifierParser(), child); if (id != null) { practitioner.Identifier.Add(id); } break; case "code": var code = FromXml(new CodeableConceptParser(), child); if (code != null) { role.Specialty.Add(code); } break; case "addr": location.Address = FromXml(new AddressParser(), child); break; case "telecom": var telecom = FromXml(new ContactPointParser(), child); if (telecom != null) { location.Telecom.Add(telecom); } break; case "assignedPerson": case "informationRecipient": var name = FromXml(new HumanNameParser(), child.CdaElement("name")); if (name != null) { practitioner.Name.Add(name); } break; case "receivedOrganization": break; } } if (!practitioner.Identifier.Any()) { Errors.Add(ParserError.CreateParseError(element, "does NOT have identifier", ParseErrorLevel.Error)); } if (!practitioner.Name.Any()) { Errors.Add(ParserError.CreateParseError(element, "does NOT have name", ParseErrorLevel.Warning)); } var existingPractitioner = Bundle?.FirstOrDefault <Practitioner>(p => p.Identifier.IsExactly(practitioner.Identifier)); if (existingPractitioner != null) { practitioner = existingPractitioner; } else { Bundle?.AddResourceEntry(practitioner); } role.Practitioner = practitioner.GetResourceReference(); if (location.Address != null || location.Telecom.Any()) { var existingLocation = Bundle?.FirstOrDefault <Location>(l => l.Address.IsExactly(location.Address) && l.Telecom.IsExactly(location.Telecom)); if (existingLocation != null) { location = existingLocation; } else { Bundle?.AddResourceEntry(location); } role.Location.Add(location.GetResourceReference()); } var existingRole = Bundle?.FirstOrDefault <PractitionerRole>(pr => pr.Location.IsExactly(role.Location) && pr.Specialty.IsExactly(role.Specialty) && pr.Practitioner.IsExactly(role.Practitioner)); if (existingRole == null && (role.Location.Any() || role.Specialty.Any())) { Bundle?.AddResourceEntry(role); } return(practitioner); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as Practitioner; if (dest != null) { base.CopyTo(dest); if (Identifier != null) { dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy()); } if (ActiveElement != null) { dest.ActiveElement = (Hl7.Fhir.Model.FhirBoolean)ActiveElement.DeepCopy(); } if (Name != null) { dest.Name = (Hl7.Fhir.Model.HumanName)Name.DeepCopy(); } if (Telecom != null) { dest.Telecom = new List <Hl7.Fhir.Model.ContactPoint>(Telecom.DeepCopy()); } if (Address != null) { dest.Address = new List <Hl7.Fhir.Model.Address>(Address.DeepCopy()); } if (GenderElement != null) { dest.GenderElement = (Code <Hl7.Fhir.Model.AdministrativeGender>)GenderElement.DeepCopy(); } if (BirthDateElement != null) { dest.BirthDateElement = (Hl7.Fhir.Model.Date)BirthDateElement.DeepCopy(); } if (Photo != null) { dest.Photo = new List <Hl7.Fhir.Model.Attachment>(Photo.DeepCopy()); } if (PractitionerRole != null) { dest.PractitionerRole = new List <Hl7.Fhir.Model.Practitioner.PractitionerRoleComponent>(PractitionerRole.DeepCopy()); } if (Qualification != null) { dest.Qualification = new List <Hl7.Fhir.Model.Practitioner.QualificationComponent>(Qualification.DeepCopy()); } if (Communication != null) { dest.Communication = new List <Hl7.Fhir.Model.CodeableConcept>(Communication.DeepCopy()); } return(dest); } else { throw new ArgumentException("Can only copy to an object of the same type", "other"); } }
public static Bundle getBundle(string basePath) { Bundle bdl = new Bundle(); bdl.Type = Bundle.BundleType.Document; // A document must have an identifier with a system and a value () type = 'document' implies (identifier.system.exists() and identifier.value.exists()) bdl.Identifier = new Identifier() { System = "urn:ietf:rfc:3986", Value = FhirUtil.createUUID() }; //Composition for Discharge Summary Composition c = new Composition(); //B.2 患者基本情報 // TODO 退院時サマリー V1.41 B.2 患者基本情報のproviderOrganizationの意図を確認 B.8 受診、入院時情報に入院した //医療機関の記述が書かれているならば、ここの医療機関はどういう位置づけのもの? とりあえず、managingOrganizationにいれておくが。 Patient patient = null; if (true) { //Patientリソースを自前で生成する場合 patient = PatientUtil.create(); } else { //Patientリソースをサーバから取ってくる場合 #pragma warning disable 0162 patient = PatientUtil.get(); } Practitioner practitioner = PractitionerUtil.create(); Organization organization = OrganizationUtil.create(); patient.ManagingOrganization = new ResourceReference() { Reference = organization.Id }; //Compositionの作成 c.Id = FhirUtil.createUUID(); //まだFHIRサーバにあげられていないから,一時的なUUIDを生成してリソースIDとしてセットする c.Status = CompositionStatus.Preliminary; //最終版は CompositionStatus.Final c.Type = new CodeableConcept() { Text = "Discharge Summary", //[疑問]Codable Concept内のTextと、Coding内のDisplayとの違いは。Lead Term的な表示? Coding = new List <Coding>() { new Coding() { Display = "Discharge Summary", System = "http://loinc.org", Code = "18842-5", } } }; c.Date = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzzz"); c.Author = new List <ResourceReference>() { new ResourceReference() { Reference = practitioner.Id } }; c.Subject = new ResourceReference() { Reference = patient.Id }; c.Title = "退院時サマリー"; //タイトルはこれでいいのかな。 //B.3 承認者 var attester = new Composition.AttesterComponent(); var code = new Code <Composition.CompositionAttestationMode>(); code.Value = Composition.CompositionAttestationMode.Legal; attester.ModeElement.Add(code); attester.Party = new ResourceReference() { Reference = practitioner.Id }; attester.Time = "20140620"; c.Attester.Add(attester); //B.4 退院時サマリー記載者 var author = new Practitioner(); author.Id = FhirUtil.createUUID(); var authorName = new HumanName().WithGiven("太郎").AndFamily("本日"); authorName.Use = HumanName.NameUse.Official; authorName.AddExtension("http://hl7.org/fhir/StructureDefinition/iso21090-EN-representation", new FhirString("IDE")); author.Name.Add(authorName); c.Author.Add(new ResourceReference() { Reference = author.Id }); //B.5 原本管理者 c.Custodian = new ResourceReference() { Reference = organization.Id }; //B.6 関係者 保険者 何故退院サマリーに保険者の情報を入れているのかな? //TODO 未実装 //sections //B.7 主治医 var section_careteam = new Composition.SectionComponent(); section_careteam.Title = "careteam"; var careteam = new CareTeam(); careteam.Id = FhirUtil.createUUID(); var attendingPhysician = new Practitioner(); attendingPhysician.Id = FhirUtil.createUUID(); var attendingPhysicianName = new HumanName().WithGiven("二郎").AndFamily("日本"); attendingPhysicianName.Use = HumanName.NameUse.Official; attendingPhysicianName.AddExtension("http://hl7.org/fhir/StructureDefinition/iso21090-EN-representation", new FhirString("IDE")); attendingPhysician.Name.Add(attendingPhysicianName); //医師の診療科はPracitionerRole/speciality + PracticeSettingCodeValueSetで表現する. //TODO: 膠原病内科は、Specilityのprefered ValueSetの中にはなかった。日本の診療科に関するValueSetを作る必要がある。 var attendingPractitionerRole = new PractitionerRole(); attendingPractitionerRole.Id = FhirUtil.createUUID(); attendingPractitionerRole.Practitioner = new ResourceReference() { Reference = attendingPhysician.Id }; attendingPractitionerRole.Code.Add(new CodeableConcept("http://hl7.org/fhir/ValueSet/participant-role", "394733009", "Attending physician")); attendingPractitionerRole.Specialty.Add(new CodeableConcept("http://hl7.org/fhir/ValueSet/c80-practice-codes", "405279007", "Medical specialty--OTHER--NOT LISTED")); var participant = new CareTeam.ParticipantComponent(); participant.Member = new ResourceReference() { Reference = attendingPractitionerRole.Id }; careteam.Participant.Add(participant); section_careteam.Entry.Add(new ResourceReference() { Reference = careteam.Id }); c.Section.Add(section_careteam); //B.8 受診、入院情報 //B.12 本文 (Entry部) 退院時サマリーV1.41の例では入院時診断を本文に書くような形に //なっているが、FHIRではadmissionDetailセクション中のEncounterで記載するのが自然だろう。 var section_admissionDetail = new Composition.SectionComponent(); section_admissionDetail.Title = "admissionDetail"; var encounter = new Encounter(); encounter.Id = FhirUtil.createUUID(); encounter.Period = new Period() { Start = "20140328", End = "20140404" }; var hospitalization = new Encounter.HospitalizationComponent(); hospitalization.DischargeDisposition = new CodeableConcept("\thttp://hl7.org/fhir/discharge-disposition", "01", "Discharged to home care or self care (routine discharge)"); encounter.Hospitalization = hospitalization; var locationComponent = new Encounter.LocationComponent(); var location = new Location() { Id = FhirUtil.createUUID(), Name = "○○クリニック", Type = new CodeableConcept("http://terminology.hl7.org/ValueSet/v3-ServiceDeliveryLocationRoleType", "COAG", "Coagulation clinic") }; locationComponent.Location = new ResourceReference() { Reference = location.Id }; section_admissionDetail.Entry.Add(new ResourceReference() { Reference = encounter.Id }); var diagnosisAtAdmission = new Condition() { Code = new CodeableConcept("http://hl7.org/fhir/ValueSet/icd-10", "N801", "右卵巣嚢腫") }; diagnosisAtAdmission.Id = FhirUtil.createUUID(); var diagnosisComponentAtAdmission = new Encounter.DiagnosisComponent() { Condition = new ResourceReference() { Reference = diagnosisAtAdmission.Id }, Role = new CodeableConcept("http://hl7.org/fhir/ValueSet/diagnosis-role", "AD", "Admission diagnosis") }; var encounterAtAdmission = new Encounter(); encounterAtAdmission.Id = FhirUtil.createUUID(); encounterAtAdmission.Diagnosis.Add(diagnosisComponentAtAdmission); section_admissionDetail.Entry.Add(new ResourceReference() { Reference = encounterAtAdmission.Id }); c.Section.Add(section_admissionDetail); //B.9情報提供者 var section_informant = new Composition.SectionComponent(); section_informant.Title = "informant"; var informant = new RelatedPerson(); informant.Id = FhirUtil.createUUID(); var informantName = new HumanName().WithGiven("藤三郎").AndFamily("東京"); informantName.Use = HumanName.NameUse.Official; informantName.AddExtension("http://hl7.org/fhir/StructureDefinition/iso21090-EN-representation", new FhirString("IDE")); informant.Name.Add(informantName); informant.Patient = new ResourceReference() { Reference = patient.Id }; informant.Relationship = new CodeableConcept("http://hl7.org/fhir/ValueSet/relatedperson-relationshiptype", "FTH", "father"); informant.Address.Add(new Address() { Line = new string[] { "新宿区神楽坂一丁目50番地" }, State = "東京都", PostalCode = "01803", Country = "日本" }); informant.Telecom.Add(new ContactPoint() { System = ContactPoint.ContactPointSystem.Phone, Use = ContactPoint.ContactPointUse.Work, Value = "tel:(03)3555-1212" }); section_informant.Entry.Add(new ResourceReference() { Reference = informant.Id }); c.Section.Add(section_informant); // B.10 本文 // B.10.1 本文記述 var section_clinicalSummary = new Composition.SectionComponent(); section_clinicalSummary.Title = "来院理由"; section_clinicalSummary.Code = new CodeableConcept("http://loinc.org", "29299-5", "Reason for visit Narrative"); var dischargeSummaryNarrative = new Narrative(); dischargeSummaryNarrative.Status = Narrative.NarrativeStatus.Additional; dischargeSummaryNarrative.Div = @" <div xmlns=""http://www.w3.org/1999/xhtml"">\n\n <p>平成19年喘息と診断を受けた。平成20年7月喘息の急性増悪にて当院呼吸器内科入院。退院後HL7医院にてFollowされていた</p> <p>平成21年10月20日頃より右足首にじんじん感が出現。左足首、両手指にも認めるようになった。同時に37℃台の熱発出現しWBC28000、Eosi58%と上昇していた</p> <p>このとき尿路感染症が疑われセフメタゾン投与されるも改善せず。WBC31500、Eosi64%と上昇、しびれ感の増悪認めた。またHb 7.3 Ht 20.0と貧血を認めた</p> <p>膠原病、特にChuge-stress-syndoromeが疑われ平成21年11月8日当院膠原病内科入院となった</p> </div> "; section_clinicalSummary.Text = dischargeSummaryNarrative; c.Section.Add(section_clinicalSummary); //B.10.3 観察・検査等 //section-observations var section_observations = new Composition.SectionComponent(); section_observations.Title = "observations"; var obs = new List <Observation>() { FhirUtil.createLOINCObservation(patient, "8302-2", "身長", new Quantity() { Value = (decimal)2.004, Unit = "m" }), FhirUtil.createLOINCObservation(patient, "8302-2", "身長", new Quantity() { Value = (decimal)2.004, Unit = "m" }), //Component Resultsの例 血圧- 拡張期血圧、収縮期血圧のコンポーネントを含む。 new Observation() { Id = FhirUtil.createUUID(), Subject = new ResourceReference() { Reference = patient.Id }, Status = ObservationStatus.Final, Code = new CodeableConcept() { Text = "血圧", Coding = new List <Coding>() { new Coding() { System = "http://loinc.org", Code = "18684-1", Display = "血圧" } } }, Component = new List <Observation.ComponentComponent>() { new Observation.ComponentComponent() { Code = new CodeableConcept() { Text = "収縮期血圧血圧", Coding = new List <Coding>() { new Coding() { System = "http://loinc.org", Code = "8480-6", Display = "収縮期血圧" } } }, Value = new Quantity() { Value = (decimal)120, Unit = "mm[Hg]" } }, new Observation.ComponentComponent() { Code = new CodeableConcept() { Text = "拡張期血圧", Coding = new List <Coding>() { new Coding() { System = "http://loinc.org", Code = "8462-4", Display = "拡張期血圧" } } }, Value = new Quantity() { Value = (decimal)100, Unit = "mm[Hg]" } }, } } }; foreach (var res in obs) { section_observations.Entry.Add(new ResourceReference() { Reference = res.Id }); } c.Section.Add(section_observations); //B.10.4 キー画像 //section-medicalImages var mediaPath = basePath + "/../../resource/Hydrocephalus_(cropped).jpg"; var media = new Media(); media.Id = FhirUtil.createUUID(); media.Type = Media.DigitalMediaType.Photo; media.Content = FhirUtil.CreateAttachmentFromFile(mediaPath); /* R3ではImagingStudyに入れられるのはDICOM画像だけみたい。 R4ではreasonReferenceでMediaも参照できる。 * とりあえずDSTU3ではMediaリソースをmedicalImagesセクションにセットする。 * var imagingStudy = new ImagingStudy(); * imagingStudy.Id = FhirUtil.getUUID(); //まだFHIRサーバにあげられていないから,一時的なUUIDを生成してリソースIDとしてセットする * imagingStudy.re */ var section_medicalImages = new Composition.SectionComponent(); section_medicalImages.Title = "medicalImages"; //TODO: sectionのcodeは? section_medicalImages.Entry.Add(new ResourceReference() { Reference = media.Id }); c.Section.Add(section_medicalImages); //Bundleの構築 //Bundleの構成要素 //Bunbdleの一番最初はCompostion Resourceであること。 List <Resource> bdl_entries = new List <Resource> { c, patient, organization, practitioner, author, careteam, encounter, encounterAtAdmission, diagnosisAtAdmission, location, informant, media, attendingPhysician, attendingPractitionerRole }; bdl_entries.AddRange(obs); foreach (Resource res in bdl_entries) { var entry = new Bundle.EntryComponent(); //entry.FullUrl = res.ResourceBase.ToString()+res.ResourceType.ToString() + res.Id; entry.FullUrl = res.Id; entry.Resource = res; bdl.Entry.Add(entry); } return(bdl); }
public ClientPractionerRole(PractitionerRole _PractitionerRole) { PractitionerRole = _PractitionerRole; }
public List <PractitionersNear> FHIR_SearchPractitioners(string city) { IList <Practitioner> practitioners = new List <Practitioner>(); IList <PractitionerRole> practitionerRoles = new List <PractitionerRole>(); IList <Organization> organizations = new List <Organization>(); var client = new Hl7.Fhir.Rest.FhirClient(FHIR_EndPoint_PatientInfo); client.PreferredFormat = ResourceFormat.Json; try { //Search for Practitioner in Patient's city and Reverse include all PractitionerRoles Practitioners have. Bundle bu3 = client.Search <Practitioner>(new string[] { "address-city=" + city, "_revinclude=PractitionerRole:practitioner", "_include=PractitionerRole:organization" }); foreach (Bundle.EntryComponent entry in bu3.Entry) { string fullUrl = entry.FullUrl; string ResourceType = entry.Resource.TypeName; if (ResourceType == "Practitioner") { Practitioner practitioner = (Practitioner)entry.Resource; practitioners.Add(practitioner); } else if (ResourceType == "PractitionerRole") { PractitionerRole practitionerRole = (PractitionerRole)entry.Resource; practitionerRoles.Add(practitionerRole); } else if (ResourceType == "Organization") { Organization organization = (Organization)entry.Resource; organizations.Add(organization); } } // Linq /*var practitionersNear = from practitioner in practitioners * join practitionerRole in practitionerRoles on "Practitioner/"+practitioner.Id equals practitionerRole.Practitioner.Url.ToString() * join organization in organizations on practitionerRole.Organization.Url.ToString() equals "Organization/" + organization.Id * * * select new PractitionersNear * { * Name = practitioner.Name.FirstOrDefault().Family + "," + practitioner.Name.FirstOrDefault().Given.FirstOrDefault(), * * Telecom = string.Join(Environment.NewLine, organization.Telecom.Select(t => t.Value + " (" + t.Use + ")")), * Address = string.Join(Environment.NewLine, organization.Address.FirstOrDefault().Line) + " " + * organization.Address.FirstOrDefault().City + " "+ * organization.Address.FirstOrDefault().PostalCode + " " + * organization.Address.FirstOrDefault().State, * Specialty = string.Join(Environment.NewLine, practitionerRole.Specialty.Select(s => s.Text)) * * };*/ //Switching to looping // 1. First fill in the details from Practitioner resource. // 2. Then check if the Practitioner is part of PractitionerRole // 3. Fetch the Address details from PractitionerRole.Organization and fill the Specialty List <PractitionersNear> practitionersNear = new List <PractitionersNear>(); foreach (var practitioner in practitioners) { var newPractitionerNear = new PractitionersNear() { Name = practitioner.Name.FirstOrDefault().Family + "," + practitioner.Name.FirstOrDefault().Given.FirstOrDefault(), Telecom = string.Join(Environment.NewLine, practitioner.Telecom.Select(t => t.Value + " (" + t.Use + ")")), Address = string.Join(Environment.NewLine, practitioner.Address.FirstOrDefault().Line) + " " + practitioner.Address.FirstOrDefault().City + " " + practitioner.Address.FirstOrDefault().PostalCode + " " + practitioner.Address.FirstOrDefault().State, Specialty = "Not Available", Qualification = string.Join(Environment.NewLine, practitioner.Qualification.Select(qual => qual.Code.Text)) }; bool foundPractitionerRole = false; foreach (var practitionerRole in practitionerRoles) { var practitionerRef = "Practitioner/" + practitioner.Id; if (practitionerRef.Equals(practitionerRole.Practitioner.Url.ToString())) { if (!foundPractitionerRole) { foundPractitionerRole = true; //Check for specialty newPractitionerNear.Specialty = string.Join(Environment.NewLine, practitionerRole.Specialty.Select(s => s.Text)); foreach (var organization in organizations) { var organizationRef = "Organization/" + organization.Id; if (organizationRef.Equals(practitionerRole.Organization.Url.ToString())) { newPractitionerNear.Telecom = string.Join(Environment.NewLine, organization.Telecom.Select(t => t.Value + " (" + t.Use + ")")); newPractitionerNear.Address = organization.Name + " " + string.Join(Environment.NewLine, organization.Address.FirstOrDefault().Line) + " " + organization.Address.FirstOrDefault().City + " " + organization.Address.FirstOrDefault().PostalCode + " " + organization.Address.FirstOrDefault().State; break; } } practitionersNear.Add(newPractitionerNear); } else { var newPractitionerNearInLoop = new PractitionersNear() { Name = practitioner.Name.FirstOrDefault().Family + "," + practitioner.Name.FirstOrDefault().Given.FirstOrDefault(), Telecom = string.Join(Environment.NewLine, practitioner.Telecom.Select(t => t.Value + " (" + t.Use + ")")), Address = string.Join(Environment.NewLine, practitioner.Address.FirstOrDefault().Line) + " " + practitioner.Address.FirstOrDefault().City + " " + practitioner.Address.FirstOrDefault().PostalCode + " " + practitioner.Address.FirstOrDefault().State, Specialty = string.Join(Environment.NewLine, practitionerRole.Specialty.Select(s => s.Text)), Qualification = string.Join(Environment.NewLine, practitioner.Qualification.Select(qual => qual.Code.Text)) }; foreach (var organization in organizations) { var organizationRef = "Organization/" + organization.Id; if (organizationRef.Equals(practitionerRole.Organization.Url.ToString())) { newPractitionerNearInLoop.Telecom = string.Join(Environment.NewLine, organization.Telecom.Select(t => t.Value + " (" + t.Use + ")")); newPractitionerNearInLoop.Address = organization.Name + " " + string.Join(Environment.NewLine, organization.Address.FirstOrDefault().Line) + " " + organization.Address.FirstOrDefault().City + " " + organization.Address.FirstOrDefault().PostalCode + " " + organization.Address.FirstOrDefault().State; break; } } practitionersNear.Add(newPractitionerNearInLoop); } } } if (!foundPractitionerRole) { practitionersNear.Add(newPractitionerNear); } } return(practitionersNear); } catch (FhirOperationException) { return(new List <PractitionersNear>()); } }
/// <summary> /// Serialize a FHIR PractitionerRole into JSON /// </summary> public static void SerializeJson(this PractitionerRole current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } writer.WriteString("resourceType", "PractitionerRole"); // Complex: PractitionerRole, Export: PractitionerRole, Base: DomainResource (DomainResource) ((Hl7.Fhir.Model.DomainResource)current).SerializeJson(writer, options, false); if ((current.Identifier != null) && (current.Identifier.Count != 0)) { writer.WritePropertyName("identifier"); writer.WriteStartArray(); foreach (Identifier val in current.Identifier) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (current.ActiveElement != null) { if (current.ActiveElement.Value != null) { writer.WriteBoolean("active", (bool)current.ActiveElement.Value); } if (current.ActiveElement.HasExtensions() || (!string.IsNullOrEmpty(current.ActiveElement.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_active", false, current.ActiveElement.Extension, current.ActiveElement.ElementId); } } if (current.Period != null) { writer.WritePropertyName("period"); current.Period.SerializeJson(writer, options); } if (current.Practitioner != null) { writer.WritePropertyName("practitioner"); current.Practitioner.SerializeJson(writer, options); } if (current.Organization != null) { writer.WritePropertyName("organization"); current.Organization.SerializeJson(writer, options); } if ((current.Code != null) && (current.Code.Count != 0)) { writer.WritePropertyName("code"); writer.WriteStartArray(); foreach (CodeableConcept val in current.Code) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if ((current.Specialty != null) && (current.Specialty.Count != 0)) { writer.WritePropertyName("specialty"); writer.WriteStartArray(); foreach (CodeableConcept val in current.Specialty) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if ((current.Location != null) && (current.Location.Count != 0)) { writer.WritePropertyName("location"); writer.WriteStartArray(); foreach (ResourceReference val in current.Location) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if ((current.HealthcareService != null) && (current.HealthcareService.Count != 0)) { writer.WritePropertyName("healthcareService"); writer.WriteStartArray(); foreach (ResourceReference val in current.HealthcareService) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if ((current.Telecom != null) && (current.Telecom.Count != 0)) { writer.WritePropertyName("telecom"); writer.WriteStartArray(); foreach (ContactPoint val in current.Telecom) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if ((current.AvailableTime != null) && (current.AvailableTime.Count != 0)) { writer.WritePropertyName("availableTime"); writer.WriteStartArray(); foreach (PractitionerRole.AvailableTimeComponent val in current.AvailableTime) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if ((current.NotAvailable != null) && (current.NotAvailable.Count != 0)) { writer.WritePropertyName("notAvailable"); writer.WriteStartArray(); foreach (PractitionerRole.NotAvailableComponent val in current.NotAvailable) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (current.AvailabilityExceptionsElement != null) { if (!string.IsNullOrEmpty(current.AvailabilityExceptionsElement.Value)) { writer.WriteString("availabilityExceptions", current.AvailabilityExceptionsElement.Value); } if (current.AvailabilityExceptionsElement.HasExtensions() || (!string.IsNullOrEmpty(current.AvailabilityExceptionsElement.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_availabilityExceptions", false, current.AvailabilityExceptionsElement.Extension, current.AvailabilityExceptionsElement.ElementId); } } if ((current.Endpoint != null) && (current.Endpoint.Count != 0)) { writer.WritePropertyName("endpoint"); writer.WriteStartArray(); foreach (ResourceReference val in current.Endpoint) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (includeStartObject) { writer.WriteEndObject(); } }
/// <summary> /// Deserialize JSON into a FHIR PractitionerRole /// </summary> public static void DeserializeJsonProperty(this PractitionerRole current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "identifier": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"PractitionerRole error reading 'identifier' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Identifier = new List <Identifier>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.Identifier v_Identifier = new Hl7.Fhir.Model.Identifier(); v_Identifier.DeserializeJson(ref reader, options); current.Identifier.Add(v_Identifier); if (!reader.Read()) { throw new JsonException($"PractitionerRole error reading 'identifier' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Identifier.Count == 0) { current.Identifier = null; } break; case "active": if (reader.TokenType == JsonTokenType.Null) { current.ActiveElement = new FhirBoolean(); reader.Skip(); } else { current.ActiveElement = new FhirBoolean(reader.GetBoolean()); } break; case "_active": if (current.ActiveElement == null) { current.ActiveElement = new FhirBoolean(); } ((Hl7.Fhir.Model.Element)current.ActiveElement).DeserializeJson(ref reader, options); break; case "period": current.Period = new Hl7.Fhir.Model.Period(); ((Hl7.Fhir.Model.Period)current.Period).DeserializeJson(ref reader, options); break; case "practitioner": current.Practitioner = new Hl7.Fhir.Model.ResourceReference(); ((Hl7.Fhir.Model.ResourceReference)current.Practitioner).DeserializeJson(ref reader, options); break; case "organization": current.Organization = new Hl7.Fhir.Model.ResourceReference(); ((Hl7.Fhir.Model.ResourceReference)current.Organization).DeserializeJson(ref reader, options); break; case "code": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"PractitionerRole error reading 'code' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Code = new List <CodeableConcept>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.CodeableConcept v_Code = new Hl7.Fhir.Model.CodeableConcept(); v_Code.DeserializeJson(ref reader, options); current.Code.Add(v_Code); if (!reader.Read()) { throw new JsonException($"PractitionerRole error reading 'code' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Code.Count == 0) { current.Code = null; } break; case "specialty": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"PractitionerRole error reading 'specialty' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Specialty = new List <CodeableConcept>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.CodeableConcept v_Specialty = new Hl7.Fhir.Model.CodeableConcept(); v_Specialty.DeserializeJson(ref reader, options); current.Specialty.Add(v_Specialty); if (!reader.Read()) { throw new JsonException($"PractitionerRole error reading 'specialty' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Specialty.Count == 0) { current.Specialty = null; } break; case "location": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"PractitionerRole error reading 'location' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Location = new List <ResourceReference>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.ResourceReference v_Location = new Hl7.Fhir.Model.ResourceReference(); v_Location.DeserializeJson(ref reader, options); current.Location.Add(v_Location); if (!reader.Read()) { throw new JsonException($"PractitionerRole error reading 'location' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Location.Count == 0) { current.Location = null; } break; case "healthcareService": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"PractitionerRole error reading 'healthcareService' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.HealthcareService = new List <ResourceReference>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.ResourceReference v_HealthcareService = new Hl7.Fhir.Model.ResourceReference(); v_HealthcareService.DeserializeJson(ref reader, options); current.HealthcareService.Add(v_HealthcareService); if (!reader.Read()) { throw new JsonException($"PractitionerRole error reading 'healthcareService' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.HealthcareService.Count == 0) { current.HealthcareService = null; } break; case "telecom": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"PractitionerRole error reading 'telecom' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Telecom = new List <ContactPoint>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.ContactPoint v_Telecom = new Hl7.Fhir.Model.ContactPoint(); v_Telecom.DeserializeJson(ref reader, options); current.Telecom.Add(v_Telecom); if (!reader.Read()) { throw new JsonException($"PractitionerRole error reading 'telecom' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Telecom.Count == 0) { current.Telecom = null; } break; case "availableTime": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"PractitionerRole error reading 'availableTime' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.AvailableTime = new List <PractitionerRole.AvailableTimeComponent>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.PractitionerRole.AvailableTimeComponent v_AvailableTime = new Hl7.Fhir.Model.PractitionerRole.AvailableTimeComponent(); v_AvailableTime.DeserializeJson(ref reader, options); current.AvailableTime.Add(v_AvailableTime); if (!reader.Read()) { throw new JsonException($"PractitionerRole error reading 'availableTime' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.AvailableTime.Count == 0) { current.AvailableTime = null; } break; case "notAvailable": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"PractitionerRole error reading 'notAvailable' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.NotAvailable = new List <PractitionerRole.NotAvailableComponent>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.PractitionerRole.NotAvailableComponent v_NotAvailable = new Hl7.Fhir.Model.PractitionerRole.NotAvailableComponent(); v_NotAvailable.DeserializeJson(ref reader, options); current.NotAvailable.Add(v_NotAvailable); if (!reader.Read()) { throw new JsonException($"PractitionerRole error reading 'notAvailable' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.NotAvailable.Count == 0) { current.NotAvailable = null; } break; case "availabilityExceptions": if (reader.TokenType == JsonTokenType.Null) { current.AvailabilityExceptionsElement = new FhirString(); reader.Skip(); } else { current.AvailabilityExceptionsElement = new FhirString(reader.GetString()); } break; case "_availabilityExceptions": if (current.AvailabilityExceptionsElement == null) { current.AvailabilityExceptionsElement = new FhirString(); } ((Hl7.Fhir.Model.Element)current.AvailabilityExceptionsElement).DeserializeJson(ref reader, options); break; case "endpoint": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"PractitionerRole error reading 'endpoint' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Endpoint = new List <ResourceReference>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.ResourceReference v_Endpoint = new Hl7.Fhir.Model.ResourceReference(); v_Endpoint.DeserializeJson(ref reader, options); current.Endpoint.Add(v_Endpoint); if (!reader.Read()) { throw new JsonException($"PractitionerRole error reading 'endpoint' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Endpoint.Count == 0) { current.Endpoint = null; } break; // Complex: PractitionerRole, Export: PractitionerRole, Base: DomainResource default: ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }