Sample code for 30+ languages & platforms
AutoIt

IntakeQ: Send a Questionnaire

See more IntakeQ Examples

Send an intake package using the API.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

;  This example assumes the Chilkat API to have been previously unlocked.
;  See Global Unlock Sample for sample code.

$oHttp = ObjCreate("Chilkat.Http")

;  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"
;  }

$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateString("QuestionnaireId","00000000-0000-0000-0000-000000000000")
$oJson.UpdateInt("ClientId",123)
$oJson.UpdateString("ClientName","Dexter Morgan")
$oJson.UpdateString("ClientEmail","dexter@email.com")
$oJson.UpdateString("ClientPhone","2222222222")
$oJson.UpdateString("PractitionerId","00000000-0000-0000-0000-000000000000")

$oHttp.SetRequestHeader "Content-Type","application/json"
$oHttp.SetRequestHeader "X-Auth-Key","xxxxxxxxxxxxxxxxxxxxxxxxx"

$oResp = ObjCreate("Chilkat.HttpResponse")
$bSuccess = $oHttp.HttpJson("POST","https://intakeq.com/api/v1/intakes/send",$oJson,"application/json",$oResp)
If ($bSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

$oSbResponseBody = ObjCreate("Chilkat.StringBuilder")
$oResp.GetBodySb($oSbResponseBody)
$oJResp = ObjCreate("Chilkat.JsonObject")
$oJResp.LoadSb($oSbResponseBody)
$oJResp.EmitCompact = False

ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJResp.Emit() & @CRLF)

Local $iRespStatusCode = $oResp.StatusCode
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oResp.Header & @CRLF)
    ConsoleWrite("Failed." & @CRLF)
    Exit
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

Local $sText
Local $sAnswer
Local $sQuestionType
Local $bOfficeUse
Local $sOfficeNote
Local $iJ
Local $iCount_j
Local $sName
Local $sDocumentType
Local $bSigned

Local $sId = $oJResp.StringOf("Id")
Local $sClientName = $oJResp.StringOf("ClientName")
Local $sClientEmail = $oJResp.StringOf("ClientEmail")
Local $iClientId = $oJResp.IntOf("ClientId")
Local $sStatus = $oJResp.StringOf("Status")
Local $iDateCreated = $oJResp.IntOf("DateCreated")
Local $iDateSubmitted = $oJResp.IntOf("DateSubmitted")
Local $sQuestionnaireName = $oJResp.StringOf("QuestionnaireName")
Local $sPractitioner = $oJResp.StringOf("Practitioner")
Local $sPractitionerName = $oJResp.StringOf("PractitionerName")
Local $sAppointmentId = $oJResp.StringOf("AppointmentId")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("Questions")
While $i < $iCount_i
    $oJResp.I = $i
    $sId = $oJResp.StringOf("Questions[i].Id")
    $sText = $oJResp.StringOf("Questions[i].Text")
    $sAnswer = $oJResp.StringOf("Questions[i].Answer")
    $sQuestionType = $oJResp.StringOf("Questions[i].QuestionType")
    $bOfficeUse = $oJResp.BoolOf("Questions[i].OfficeUse")
    $sOfficeNote = $oJResp.StringOf("Questions[i].OfficeNote")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("Questions[i].Rows")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("Questions[i].ColumnNames")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $iJ = $iJ + 1
    Wend
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("ConsentForms")
While $i < $iCount_i
    $oJResp.I = $i
    $sId = $oJResp.StringOf("ConsentForms[i].Id")
    $sName = $oJResp.StringOf("ConsentForms[i].Name")
    $sDocumentType = $oJResp.StringOf("ConsentForms[i].DocumentType")
    $bSigned = $oJResp.BoolOf("ConsentForms[i].Signed")
    $iDateSubmitted = $oJResp.IntOf("ConsentForms[i].DateSubmitted")
    $i = $i + 1
Wend