# Extension( ethnic-category) in Patient Resource Json Example [CC profile] **Category:** [FHIR](https://openhealthhub.org/c/fhir/31) **Created:** 2019-11-21 15:40 UTC **Views:** 2270 **Replies:** 4 **URL:** https://openhealthhub.org/t/extension-ethnic-category-in-patient-resource-json-example-cc-profile/2149 --- ## Post #1 by @Tharma Hi All, I am trying to read ethnic-category from extension from the patient fhir message (json) using HAPI Fhir STU3 library. I am unable to get the code from it. Following is the extension sample, "extension":[ { "url":"http://fhir.nhs.net/ValueSet/ethnic-category-1", "valueCodeableConcept":{ "coding":[ { "system":"http://fhir.nhs.net/ValueSet/ethnic-category-1", "code":"A", "display":"British, Mixed British" } ], "text":"British, Mixed British" } }, { "url":"careManager", "valueReference":{ "reference":"Practitioner/54w5wwwfasdfd", "display":"careManager" } } ], is it valid content if so please share how can I get the code 'A' from this ? I tried upto the followign patient.getExtensionsByUrl("http://fhir.nhs.net/ValueSet/ethnic-category-1").get(0).getValue() thanks in advance --- ## Post #2 by @mayfield.g.kev Your code is nearly there. for (Extension extension : patient.getExtensionsByUrl(“http://fhir.nhs.net/ValueSet/ethnic-category-1”)) { if (extension.getValue() instanceof CodeableConcept) { CodeableConcept concept = (CodeableConcept) extension.getValue(); // etc } } From a UK perspective the extension is wrong but not necessarily invalid though. You can chose to accept it but I'd recommend getting it corrected. { "extension": [ { // This is the correct Url "url": "https://fhir.hl7.org.uk/STU3/CodeSystem/CareConnect-EthnicCategory-1", "valueCodeableConcept": { "coding": [ { // The system was a ValueSet, it should be a CodeSystem "system": "https://fhir.hl7.org.uk/STU3/CodeSystem/CareConnect-EthnicCategory-1", "code": "A", "display": "British, Mixed British" } ], "text": "British, Mixed British" } } ] } --- ## Post #3 by @Tharma Thank you, where this url and system url (https://fhir.hl7.org.uk/STU3/CodeSystem/CareConnect-EthnicCategory-1) from? when I checked the Care Connect Profile the url has valueSet instead of CodeSystem ? please clarify ? https://fhir.hl7.org.uk/STU3/StructureDefinition/Extension-CareConnect-EthnicCategory-1 thanks --- ## Post #4 by @mayfield.g.kev Thats a common mistake. This is saying use a code which is defined in this ValueSet ![52|690x213](upload://1aAX1N37xyekIymyAmA7Yx4RYxO.png) When you look at the ValueSet, the CodeSystem is listed at the bottom. ![32|690x319](upload://jOkLHoaAiWbhlOvnKnOsxkbcx3w.png) I think the way the profile has been created is confusing, it's possibly been done that way because that is how it was done in DSTU2. --- ## Post #5 by @mayfield.g.kev After some comments. Based on the above, I believing the current spec led to the issue and was wondering if standard FHIR implementation guide would have been better. E.g. https://project-wildfyre.github.io/UK-STU3/CareConnect-EthnicCategory-1.html This has several issues at the mo (I'm experimenting) --- **Canonical:** https://openhealthhub.org/t/extension-ethnic-category-in-patient-resource-json-example-cc-profile/2149 **Original content:** https://openhealthhub.org/t/extension-ethnic-category-in-patient-resource-json-example-cc-profile/2149