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
I'm unclear what the square brackets (particularly the inner set, at "given") are trying to do in the generated JSON. Are you saying the API requires this somehow?
As a potential alternate approach to try, if you just create a dictionary and then wrap it in a!toJson, you should get the JSON text, without having to use such a cumbersome and error-prone concat statement (particularly given how hard it is to work with double-quotes given the need to escape each one, and the consequent confusion). This could at the very least provide you an easier method by which to test different potential generated inputs.