I am facing an issue with my json file where I need to replace the value field with dynamic variables.
For example, if my app fetches "9.3", I want it to replace the existing value (2.3) in the json file.
I attempted using placeholders but encountered difficulties with this method:
JSON.stringify(jsonFile).split("{bloodGlucoseValue}").join(9.3)
This approach ended up corrupting my json file and prevented me from successfully POSTing it to my API due to a "Failed to parse request body as JSON resource...." error.
Is there another way for me to achieve this?
{
"resourceType" : "Bundle",
"type" : "transaction",
"entry" : [
{
"fullUrl": "urn:uuid:patient",
"resource" : {
"resourceType" : "Patient",
"name" : [
{
"given": ["ABC"],
"family": "Uni"
}
]
},
"request" : {
"method" : "POST",
"url" : "Patient"
}
},
{
"resource" : {
"resourceType" : "Observation",
"code" : {
"coding" : [
{
"system":"http://loinc.org",
"code":"15074-8",
"display":"Glucose [Moles/volume] in Blood"
}
]
},
"subject": {
"type" : "Patient",
"reference" : "urn:uuid:patient"
},
"valueQuantity": {
"value": 2.3,
"unit": "mmol/l",
"system": "http://unitofmeasure.org",
"code": "mmol/L"
}
},
"request" : {
"method" : "POST"
}
}
]
}