DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoHttp
Variant vSbResponseBody
Handle hoSbResponseBody
Handle hoJarrResp
Integer iRespStatusCode
Variant vJson
Handle hoJson
String sId
String sClientName
String sClientEmail
Integer iClientId
String sStatus
Integer iDateCreated
Integer iDateSubmitted
String sQuestionnaireName
String sQuestionnaireId
String sPractitioner
String sPractitionerName
Integer i
Integer iCount_i
String sTemp1
Move False To iSuccess
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
// 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
Send ComSetRequestHeader To hoHttp "X-Auth-Key" "xxxxxxxxxxxxxxxxxxxxxxxxx"
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComQuickGetSb Of hoHttp "https://intakeq.com/api/v1/intakes/summary?client=[searchString]&startDate=[yyyy-MM-dd]&endDate=[yyyy-MM-dd]&page=[pageNumber]&all=[bool]" vSbResponseBody To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatJsonArray)) To hoJarrResp
If (Not(IsComObjectCreated(hoJarrResp))) Begin
Send CreateComObject of hoJarrResp
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJarrResp vSbResponseBody To iSuccess
Set ComEmitCompact Of hoJarrResp To False
Showln "Response Body:"
Get ComEmit Of hoJarrResp To sTemp1
Showln sTemp1
Get ComLastStatus Of hoHttp To iRespStatusCode
Showln "Response Status Code = " iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Header:"
Get ComLastHeader Of hoHttp To sTemp1
Showln sTemp1
Showln "Failed."
Procedure_Return
End
// 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
Move 0 To i
Get ComSize Of hoJarrResp To iCount_i
While (i < iCount_i)
Get ComObjectAt Of hoJarrResp i To vJson
If (IsComObject(vJson)) Begin
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
Set pvComObject Of hoJson To vJson
End
Get ComStringOf Of hoJson "Id" To sId
Get ComStringOf Of hoJson "ClientName" To sClientName
Get ComStringOf Of hoJson "ClientEmail" To sClientEmail
Get ComIntOf Of hoJson "ClientId" To iClientId
Get ComStringOf Of hoJson "Status" To sStatus
Get ComIntOf Of hoJson "DateCreated" To iDateCreated
Get ComIntOf Of hoJson "DateSubmitted" To iDateSubmitted
Get ComStringOf Of hoJson "QuestionnaireName" To sQuestionnaireName
Get ComStringOf Of hoJson "QuestionnaireId" To sQuestionnaireId
Get ComStringOf Of hoJson "Practitioner" To sPractitioner
Get ComStringOf Of hoJson "PractitionerName" To sPractitionerName
Send Destroy of hoJson
Move (i + 1) To i
Loop
End_Procedure