Closed gdevanla closed 8 months ago
I think the solution is to change
https://github.com/GoogleCloudPlatform/openmrs-fhir-analytics/blob/master/dwh/query_lib.py#L150
to
type_code_str = 'array_contains(encTypeCode, {})'.format(temp_str)
FIxing this as part of https://github.com/GoogleCloudPlatform/openmrs-fhir-analytics/pull/256
Thanks for finding/flagging this bug @gdevanla. I finally managed to take a look and I think the proper fix for this is to do another explode_outer
on typeFlat.coding
before here. The idea for these flat views was that each output column would be a simple data type (i.e., not nested and not repeated). So for example for location, we remove the repeated element here and then create an alias for sub-elements of locationFlat
. We want to do the same for typeFlat
but as you pointed out typeFlat.coding
is still a repeated field which needs to be flattened as well.
Closing this issue as we are deprecating the old query library.
Using the provided notebook, I tried adding EncounterConstraints with typeCode.
But, looks like the flattenning is not sufficient, since
type.code.coding
is nested at an extra level. I get the following error.I think the problem is the type of
type
as show here. Notice, thattype.code
which gets flattened in_flatten_encounter
does not flatten.You can try this and notice that we need to use
array_contains
to make this query work: