Xbase++
Xbase++
IntakeQ: Query Intake Forms
See more IntakeQ Examples
Use this method to query client intake form summaries. The result set does not contain all the contents of the intake forms, but only their basic information (id, status, client info).Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oHttp
LOCAL oSbResponseBody
LOCAL oJarrResp
LOCAL nRespStatusCode
LOCAL oJson
LOCAL cId
LOCAL cClientName
LOCAL cClientEmail
LOCAL nClientId
LOCAL cStatus
LOCAL nDateCreated
LOCAL nDateSubmitted
LOCAL cQuestionnaireName
LOCAL cQuestionnaireId
LOCAL cPractitioner
LOCAL cPractitionerName
LOCAL i
LOCAL nCount_i
nSuccess := 0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oHttp := CreateObject("Chilkat.Http")
// Implements the following CURL command:
// curl -X GET \
// https://intakeq.com/api/v1/intakes/summary?client=[searchString]&startDate=[yyyy-MM-dd]&endDate=[yyyy-MM-dd]&page=[pageNumber]&all=[bool] \
// -H 'X-Auth-Key: xxxxxxxxxxxxxxxxxxxxxxxxx'
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
oHttp:SetRequestHeader("X-Auth-Key", "xxxxxxxxxxxxxxxxxxxxxxxxx")
oSbResponseBody := CreateObject("Chilkat.StringBuilder")
nSuccess := oHttp:QuickGetSb("https://intakeq.com/api/v1/intakes/summary?client=[searchString]&startDate=[yyyy-MM-dd]&endDate=[yyyy-MM-dd]&page=[pageNumber]&all=[bool]", oSbResponseBody)
IF (nSuccess == 0)
? oHttp:LastErrorText
oHttp:destroy()
oSbResponseBody:destroy()
RETURN
ENDIF
oJarrResp := CreateObject("Chilkat.JsonArray")
oJarrResp:LoadSb(oSbResponseBody)
oJarrResp:EmitCompact := 0
? "Response Body:"
? oJarrResp:Emit()
nRespStatusCode := oHttp:LastStatus
? "Response Status Code = " + Str(nRespStatusCode)
IF (nRespStatusCode >= 400)
? "Response Header:"
? oHttp:LastHeader
? "Failed."
oHttp:destroy()
oSbResponseBody:destroy()
oJarrResp:destroy()
RETURN
ENDIF
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// [
// {
// "Id": "00000000-0000-0000-0000-000000000000",
// "ClientName": "test",
// "ClientEmail": "test@email.com",
// "ClientId": 9999,
// "Status": "Completed",
// "DateCreated": 1458526480368,
// "DateSubmitted": 1458526532654,
// "QuestionnaireName": "test",
// "QuestionnaireId": "1234acbd",
// "Practitioner": "test@email.com",
// "PractitionerName": "FirstName LastName"
// },
// {
// "Id": "00000000-0000-0000-0000-000000000000",
// "ClientName": "test",
// "ClientEmail": "test@email.com",
// "ClientId": 9999,
// "Status": "Completed",
// "DateCreated": 1458526480368,
// "DateSubmitted": 1458526532654,
// "QuestionnaireName": "test",
// "QuestionnaireId": "1234acbd",
// "Practitioner": "test@email.com",
// "PractitionerName": "FirstName LastName"
// }
// ]
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
i := 0
nCount_i := oJarrResp:Size
DO WHILE i < nCount_i
oJson := oJarrResp:ObjectAt(i)
cId := oJson:StringOf("Id")
cClientName := oJson:StringOf("ClientName")
cClientEmail := oJson:StringOf("ClientEmail")
nClientId := oJson:IntOf("ClientId")
cStatus := oJson:StringOf("Status")
nDateCreated := oJson:IntOf("DateCreated")
nDateSubmitted := oJson:IntOf("DateSubmitted")
cQuestionnaireName := oJson:StringOf("QuestionnaireName")
cQuestionnaireId := oJson:StringOf("QuestionnaireId")
cPractitioner := oJson:StringOf("Practitioner")
cPractitionerName := oJson:StringOf("PractitionerName")
oJson:destroy()
i := i + 1
ENDDO
oHttp:destroy()
oSbResponseBody:destroy()
oJarrResp:destroy()