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()
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"
}
}
]