Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear how to filter same key-set on multiple levels of a tree #94

Open
bionicles opened this issue Nov 23, 2021 · 0 comments
Open

Unclear how to filter same key-set on multiple levels of a tree #94

bionicles opened this issue Nov 23, 2021 · 0 comments

Comments

@bionicles
Copy link

bionicles commented Nov 23, 2021

Hi, I'm trying to wrangle some health data and need to match on abstract path patterns, if that makes sense.

Could you expand the docs and docstrings a bit to demonstrate more advanced usage?

ex: how do you filter objects with a set of keys?
how do you apply that filter all over the whole tree?
how do you return the matches with the resourceType from the parent?

I want to walk a tree and save (resourceType, system, code, display) tuples for each code,
but the stuff with {system, code, display} mappings are usually nested inside the resource instances

do you know a nice way to filter on all subtrees with [system, code, display] as keys?

x = (
        {'resourceType': 'Patient', 'id': 'example', 'name': {'prefix': 'Dr.', 'given': ['Bob', 'B.'], 'family': 'Bobbins'}},
        {
            'resourceType': 'Observation',
            'id': 'example_code_and_valueQuantity',
            'subject': {'reference': 'Patient/example'},
            'code': {'coding': [{'system': 'http://loinc.org', 'code': '29463-7', 'display': 'Body weight'}]},
            'valueQuantity': {'value': '70', 'unit': 'kg', 'system': 'http://unitsofmeasure.org', 'code': 'kg'}
        },
        {
            'resourceType': 'Observation',
            'id': 'example_component',
            'subject': {'reference': 'Patient/example'},
            'code': {'coding': [{'system': 'http://loinc.org', 'code': '55284-4', 'display': 'Blood Pressure'}]},
            'component': (
                {
                    'code': {
                        'coding': {'system': 'http://loinc.org', 'code': '8462-4', 'display': 'Diastolic Blood Pressure'},
                        'text': 'Diastolic Blood Pressure'
                    },
                    'valueQuantity': {
                        'value': 84.51637275024623,
                        'unit': 'mm[Hg]',
                        'system': 'http://unitsofmeasure.org',
                        'code': 'mm[Hg]'
                    }
                },
                {
                    'code': {
                        'coding': {'system': 'http://loinc.org', 'code': '8480-6', 'display': 'Systolic Blood Pressure'},
                        'text': 'Systolic Blood Pressure'
                    },
                    'valueQuantity': {
                        'value': 119.11425717022348,
                        'unit': 'mm[Hg]',
                        'system': 'http://unitsofmeasure.org',
                        'code': 'mm[Hg]'
                    }
                }
            )
        }
    )
y = (("Observation", "https://loinc.org", "55284-4", "Blood Pressure"), ...)

BTW i think your project could help a lot of people because most medical data right now is nested json, thank you for your work and thank you for taking the time to read this

@bionicles bionicles changed the title Please add docstrings/doctests with more examples of advanced usage Unclear how to filter same key-set on multiple levels of a tree Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant