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

Alternative to JUTE $let derective proposal #3

Closed
ir4y opened this issue Sep 6, 2023 · 5 comments
Closed

Alternative to JUTE $let derective proposal #3

ir4y opened this issue Sep 6, 2023 · 5 comments
Assignees

Comments

@ir4y
Copy link
Member

ir4y commented Sep 6, 2023

{
   "{% assign idQuestion %}": "patientId"
   "{% assign id %}": "{{ QuestionnaireResponse.repeat(item).where(linkId=%idQuestion).answer.valueString }}",
    "resourceType": "Bundle",
    "type": "transaction",
    "entry": [{
        "request": {
            "URL": "/Patient/{{ %id }}",
            "method": "PATCH"
        },
        "resource": {
            "{% assign phoneGroup %}": "{{ QuestionnaireResponse.repeat(item).where(linkId='phone-group') }}",
            "telecom": [
                {
                    "system": "phone",
                    "use": "{{ %phoneGroup.where(linkId='phone-type').answer.valueString }}",
                    "value": "{{ %phoneGroup.where(linkId='phone-number').answer.valueString }}"
                },
            ]
        }
    }]
}
@ir4y
Copy link
Member Author

ir4y commented Sep 6, 2023

The order is not granted, so we have to build a dependency graph and evaluate it consequentially.

@ir4y
Copy link
Member Author

ir4y commented Nov 1, 2023

As an alternative approach we can use an extension, please check #4 for more details.

@ir4y
Copy link
Member Author

ir4y commented May 22, 2024

An alternative approach that fixes issues with ordering.
In this case {% let %} directive SHALL present only once on each level

With this approach, we can simplify this mapper even more

{
   "{% let %}": [
       {"idQuestion": "patientId"}, // Example of simple string
       {"qr": "{{ QuestionnaireResponse.repeat(item) }}"},
       {"id": "%qr.where(linkId=%idQuestion).answer.valueString }}"},
   ],                    
    "resourceType": "Bundle",
    "type": "transaction",
    "entry": [{
        "request": {
            "URL": "/Patient/{{ %id }}",
            "method": "PATCH"
        },
        "resource": {
            "{% let %}": [{"phoneGroup": "{{ $qr.where(linkId='phone-group') }}"}],
            "telecom": [
                {
                    "system": "phone",
                    "use": "{{ %phoneGroup.where(linkId='phone-type').answer.valueString }}",
                    "value": "{{ %phoneGroup.where(linkId='phone-number').answer.valueString }}"
                },
            ]
        }
    }]
}

@ruscoder
Copy link
Member

The name {% assign %} is better than {% let %} to match the liquid naming.

Examples are available as tests here

describe('Assign usage', () => {

@ruscoder
Copy link
Member

The assign block might be defined in any other blocks including for (#1), merge (#7), if (#2) and it overrides local context for the block.

ruscoder added a commit that referenced this issue May 28, 2024
feat: add support for if, for, assign and merge

Closes #1 #2 #3 #7 #8
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

2 participants