I am working on an API. I have been stuck for a long time, but I am getting a response in JSON.
I want to create a variable to parse the JSON. Here is the code that performs a GET.
////////////////////////////////////////////////////////////////////////////////////////////////
// GET with parameters
////////////////////////////////////////////////////////////////////////////////////////////////
api.GET('/chart/1/encounters', {
params: {
departmentid: 1,
}
}).on('done', function(response) {
var appt = response['appointments'][0]
Here is a bit of the JSON I get back.
'{“encounters”:[{“encountertype”:“VISIT”,“patientstatusid”:3,“stage”:“INTAKE”,“status”:“OPEN”,“appointmentstartdate”:“2021-01-20T10:00:00-05:00”,“appointmentid”:1174575,“patientlocationid”:21,“departmentid”:1,“providerid”:1,“encounterdate”:“01\/20\/2021”,“encountervisitname”:“physical exam”,“patientlocation”:“Waiting Room”,“providerlastname”:“Cartwright”,“encounterid”:40438,“lastupdated”:“09\/30\/2020”,“providerfirstname”:“Camille”,“providerphone”:"(555) 004-0271",“patientstatus”:“Ready For Provider”},{“encountertype”:“VISIT”,“patientstatusid”:4,
One field I need to put into another API is provider name, so I need to have a field that would be prvdrfullname.providerfirstname + prvdrfullname.providerlastname
That data I have from the first API I’m working with.
My JavaScript is moderate & I am also using NodeJS as the sample is in Node.js.
I don’t know if this is the proper forum but I’m really having a hardtime parsing the JSON.
Thank you.