Using Fhir views with BigQuery and Extensions
- Dominant language
- Python
- Stars
- 106
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
Hello, I am using FHIR view and its bigquery runner to query fhir data from a bigquery table on GCP. Wondering how we can work with extensions in this case?
Specifically, the bq table is exported from a fhir-store, and bq automatically strips away extensions (it maps each extension onto its own column). For example the following extension in a resource will actually create a column named `retired` in the bq table for the resource, and the bq table will NOT have a column with the name extension.
```
"extension": [
{
"url": "https://my-definition/StructureDefinition/retired",
"valueString": "N"
},
]
```
For context, due to our usecase, we are using the SQL on FHIR to specify the query, i.e
```
simple_pats_config = {
'resource': 'Patient',
'select': [
{
'alias': 'extensions',
'path': 'extension',
},
...
]
}
```
The problem with this is that the SQL generated will attempt to `UNNEST(extension)`, which bigquery will error `google.api_core.exceptions.BadRequest: 400 Unrecognized name: extension` since such column does not exist in the bq table. So the question is how do we work with the bq table in this case? Or alternatively what settings/config do we need when exporting from fhir-store to bq to preserve the `extension` column so this works?
And a separate but related question is whether there will be support for `extension.url` matching. Currently, if the fhir-path used is `extension.where(url = 'some-url')`, `views.from_view_definition(query)` will throw an error (`ValueError: Identifier url not in dict_keys(['id', 'extension', 'value'])`). This is perhaps because (if i am correct) url is currently not part of `child_defs` of `extension` in `FhirPathDataType`. Maybe I am mistaken and if this is somehow supported it would be great!
Thanks in advance.
Contributor guide
Assessment
This issue has not been assessed yet.