Hello - I am trying to test creating a FHIR compliant JSON payload to send to hapi.fhir.org/Patient. Here is what I done so far.
created an expression to create the JSON payload:
concat( "{","""resourceType""",":","""Patient""",",","""name""",":[{","""use""",":","""official""",",","""text""",":","""Brian Doe""",",","""family""",":","""Doe""",",","""given""",":","[","""",tostring(ri!firstName),"""","]","}","]",",","""gender""",":","""male""",",","""birthDate""",":","""2000-04-30""","}")
This gives me:
"{"resourceType":"Patient","name":[{"use":"official","text":"Brian Doe","family":"Doe","given":[""]}],"gender":"male","birthDate":"2000-04-30"}"
When I put this in the integration's request body, it results in errors. First error is because of the " at the start and the end. I removed those manually and then it gives an 'open bracket' error. The open error seems to be because of [ brackets. If I remove all [ brackets, and the payload is now
{"resourceType": "Patient", "name": {"use": "official","text": "Brian Doe","family": "Doe","given": "Brian"},"gender":"male","birthDate": "2000-04-30"}
The API returns success. Any suggestion on how I can get the payload to be generated without the string so I can pass it to the integration as a parameter and keep the [ brackets?
Thank you!
John.
Discussion posts and replies are publicly visible
String concatenation, whilst it can work, is hard to implement and hard to maintain. You'd be better off creating an Appian data structure (e.g. using a CDT) and then casting that to JSON using a!toJson().
To do this you'll need to work backwards from the JSON message that you want to create and create an Appian data structure that will align to the target JSON structure.