beda-software / FHIRPathMappingLanguage

MIT License
12 stars 1 forks source link

FSH based syntax #4

Open ir4y opened 1 year ago

ir4y commented 1 year ago

To simplify the mapper we can leverage FSH to describe a resource like this

Instance: undefined
InstanceOf: Patient
Usage: #example
* birthDate = "{{ QuestionnaireResponse.repeat(item).where(linkId='2').answer.value }}"
* name.given = "{{ QuestionnaireResponse.repeat(item).where(linkId='1').answer.value }}"
* telecom[0].value = "{{ QuestionnaireResponse.repeat(item).where(linkId='phone').answer.value }}"
* telecom[=].system = #phone
* telecom[+].value = "{{ QuestionnaireResponse.repeat(item).where(linkId='email').answer.value }}"
* telecom[=].system = #email

When we need to map a list we can use an extension:

Instance: undefined
InstanceOf: Bundle
Usage: #example
* type = #transaction
* entry.request.url = "{{ '/Patient/' + QuestionnaireResponse.repeat(item).where(linkId='patientId').answer.valueString }}"
* entry.request.method = #PATCH
* entry.resource = Inline-Instance-for-undefined-1

Instance: Inline-Instance-for-undefined-1
InstanceOf: Patient
Usage: #inline
* telecom.extension.url = "data-source"
* telecom.extension.valueExpression.language = #text/fhirpath
* telecom.extension.valueExpression.expression = "QuestionnaireResponse.repeat(item).where(linkId='phone-group')"
* telecom.system = #phone
* telecom.use = #"{{ item.where(linkId='phone-type').answer.valueString }}"
* telecom.value = "{{ item.where(linkId='phone-number').answer.valueString }}"
ir4y commented 6 months ago

Example that leverage assign #3 in FSH

Instance: undefined
InstanceOf: Bundle
Usage: #example
* type = #transaction
* entry.request.url = "{{ '/Patient/' + QuestionnaireResponse.repeat(item).where(linkId='patientId').answer.valueString }}"
* entry.request.method = #PATCH
* entry.resource = Inline-Instance-for-undefined-1

Instance: Inline-Instance-for-undefined-1
InstanceOf: Patient
Usage: #inline
* extension.url = "assign"
* extension.extension[+].url = "name"
* extension.extension[=].valueString = "qr"
* extension.extension[+].url = "value"
* extension.extension[=].valueExpression.language = #text/fhirpath
* extension.extension[=].valueExpression.expression = "QuestionnaireResponse.repeat(item)"
* telecom.extension.url = "data-source"
* telecom.extension.valueExpression.language = #text/fhirpath
* telecom.extension.valueExpression.expression = "%qr.where(linkId='phone-group')"
* telecom.system = #phone
* telecom.use = #"{{ item.where(linkId='phone-type').answer.valueString }}"
* telecom.value = "{{ item.where(linkId='phone-number').answer.valueString }}"
ir4y commented 6 months ago

Example that leverage assign #3 in FSH and RuleSet

Instance: undefined
InstanceOf: Bundle
Usage: #example
* type = #transaction
* entry.request.url = "{{ '/Patient/' + QuestionnaireResponse.repeat(item).where(linkId='patientId').answer.valueString }}"
* entry.request.method = #PATCH
* entry.resource = Inline-Instance-for-undefined-1

Instance: Inline-Instance-for-undefined-1
InstanceOf: Patient
Usage: #inline
* insert Assign("qr", "{{ QuestionnaireResponse.repeat(item) }}")
* telecom.extension.url = "data-source"
* telecom.extension.valueExpression.language = #text/fhirpath
* telecom.extension.valueExpression.expression = "%qr.where(linkId='phone-group')"
* telecom.system = #phone
* telecom.use = #"{{ item.where(linkId='phone-type').answer.valueString }}"
* telecom.value = "{{ item.where(linkId='phone-number').answer.valueString }}"