Lianja
Lianja
IntakeQ: Send a Questionnaire
See more IntakeQ Examples
Send an intake package using the API.Chilkat Lianja Downloads
llSuccess = .F.
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loHttp = createobject("CkHttp")
// Implements the following CURL command:
// curl -H "Content-Type: application/json" \
// -H 'X-Auth-Key: xxxxxxxxxxxxxxxxxxxxxxxxx' \
// -X POST \
// -d '{
// "QuestionnaireId": "00000000-0000-0000-0000-000000000000",
// "ClientId": 123,
// "ClientName": "Dexter Morgan",
// "ClientEmail": "dexter@email.com",
// "ClientPhone": "2222222222",
// "PractitionerId": "00000000-0000-0000-0000-000000000000",
// }' https://intakeq.com/api/v1/intakes/send
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
// Use this online tool to generate code from sample JSON:
// Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "QuestionnaireId": "00000000-0000-0000-0000-000000000000",
// "ClientId": 123,
// "ClientName": "Dexter Morgan",
// "ClientEmail": "dexter@email.com",
// "ClientPhone": "2222222222",
// "PractitionerId": "00000000-0000-0000-0000-000000000000"
// }
loJson = createobject("CkJsonObject")
loJson.UpdateString("QuestionnaireId","00000000-0000-0000-0000-000000000000")
loJson.UpdateInt("ClientId",123)
loJson.UpdateString("ClientName","Dexter Morgan")
loJson.UpdateString("ClientEmail","dexter@email.com")
loJson.UpdateString("ClientPhone","2222222222")
loJson.UpdateString("PractitionerId","00000000-0000-0000-0000-000000000000")
loHttp.SetRequestHeader("Content-Type","application/json")
loHttp.SetRequestHeader("X-Auth-Key","xxxxxxxxxxxxxxxxxxxxxxxxx")
loResp = createobject("CkHttpResponse")
llSuccess = loHttp.HttpJson("POST","https://intakeq.com/api/v1/intakes/send",loJson,"application/json",loResp)
if (llSuccess = .F.) then
? loHttp.LastErrorText
release loHttp
release loJson
release loResp
return
endif
loSbResponseBody = createobject("CkStringBuilder")
loResp.GetBodySb(loSbResponseBody)
loJResp = createobject("CkJsonObject")
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = .F.
? "Response Body:"
? loJResp.Emit()
lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + str(lnRespStatusCode)
if (lnRespStatusCode >= 400) then
? "Response Header:"
? loResp.Header
? "Failed."
release loHttp
release loJson
release loResp
release loSbResponseBody
release loJResp
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",
// "Practitioner": "test@email.com",
// "PractitionerName": "FirstName LastName",
// "Questions": [
// {
// "Id": "xxxx-1",
// "Text": "Full name",
// "Answer": "Dexter Morgan",
// "QuestionType": "OpenQuestion",
// "Rows": [
// ],
// "ColumnNames": [
// ],
// "OfficeUse": false,
// "OfficeNote": "aaa"
// },
// {
// "Id": "xxxx-2",
// "Text": "Full name",
// "Answer": "Dexter Morgan",
// "QuestionType": "OpenQuestion",
// "Rows": [
// ],
// "ColumnNames": [
// ],
// "OfficeUse": false,
// "OfficeNote": "aaa"
// }
// ],
// "AppointmentId": "xxxxxxxx",
// "ConsentForms": [
// {
// "Id": "00000000-0000-0000-0000-000000000000",
// "Name": "HIPAA Release Form",
// "DocumentType": "Html",
// "Signed": true,
// "DateSubmitted": 1458526532654
// }
// ]
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
lcId = loJResp.StringOf("Id")
lcClientName = loJResp.StringOf("ClientName")
lcClientEmail = loJResp.StringOf("ClientEmail")
lnClientId = loJResp.IntOf("ClientId")
lcStatus = loJResp.StringOf("Status")
lnDateCreated = loJResp.IntOf("DateCreated")
lnDateSubmitted = loJResp.IntOf("DateSubmitted")
lcQuestionnaireName = loJResp.StringOf("QuestionnaireName")
lcPractitioner = loJResp.StringOf("Practitioner")
lcPractitionerName = loJResp.StringOf("PractitionerName")
lcAppointmentId = loJResp.StringOf("AppointmentId")
i = 0
lnCount_i = loJResp.SizeOfArray("Questions")
do while i < lnCount_i
loJResp.I = i
lcId = loJResp.StringOf("Questions[i].Id")
lcText = loJResp.StringOf("Questions[i].Text")
lcAnswer = loJResp.StringOf("Questions[i].Answer")
lcQuestionType = loJResp.StringOf("Questions[i].QuestionType")
llOfficeUse = loJResp.BoolOf("Questions[i].OfficeUse")
lcOfficeNote = loJResp.StringOf("Questions[i].OfficeNote")
j = 0
lnCount_j = loJResp.SizeOfArray("Questions[i].Rows")
do while j < lnCount_j
loJResp.J = j
j = j + 1
enddo
j = 0
lnCount_j = loJResp.SizeOfArray("Questions[i].ColumnNames")
do while j < lnCount_j
loJResp.J = j
j = j + 1
enddo
i = i + 1
enddo
i = 0
lnCount_i = loJResp.SizeOfArray("ConsentForms")
do while i < lnCount_i
loJResp.I = i
lcId = loJResp.StringOf("ConsentForms[i].Id")
lcName = loJResp.StringOf("ConsentForms[i].Name")
lcDocumentType = loJResp.StringOf("ConsentForms[i].DocumentType")
llSigned = loJResp.BoolOf("ConsentForms[i].Signed")
lnDateSubmitted = loJResp.IntOf("ConsentForms[i].DateSubmitted")
i = i + 1
enddo
release loHttp
release loJson
release loResp
release loSbResponseBody
release loJResp