Skip to main content

Storing 3rd Party Medical Questionnaire Responses

Welcome to the Semble GraphQL API how-to guide. In this guide, we'll walk you through how to use the Semble public API to store the responses of a 3rd party medical questionnaire into Semble.

The process involves two main steps:

  1. Authenticate
  2. Either get a patient or create a new patient.
  3. Insert the responses from your questionnaire.

Let's dive into the details.

Step 1: Authenticate

Before making any requests, make sure you have a valid token. Refer to the Authentication section for more details.

Step 2: Get or Create a Patient

To get an existing patient, use the patients query. Here is the code for three languages:

curl -X POST https://open.semble.io/graphql \
-H "Content-Type: application/json" \
-H "x-token: yourtoken" \
-d '{
"query": "query findPatients($search: String) { patients(search: $search) { data { id firstName lastName dob email } } }",
"variables": {"search": "John Doe"}
}'

If you want to create a new patient, use the createPatient mutation. Make sure to replace the $first, $last, and $email placeholders with the correct patient's first name, last name, and email respectively.

curl -X POST https://open.semble.io/graphql \
-H "Content-Type: application/json" \
-H "x-token: yourtoken" \
-d '{
"query": "mutation createPatient($first: String, $last: String, $email: String) { createPatient(firstName: $first, lastName: $last, email: $email) { id } }",
"variables": {"first": "John", "last": "Doe", "email": "john.doe@example.com"}
}'

Step 3:

Insert Questionnaire Responses

To insert the responses from your questionnaire, use the createFreeTextRecord mutation. Replace the placeholders in the CreateFreeTextRecordDataInput type with the correct patient ID and responses from your questionnaire.

curl -X POST https://open.semble.io/graphql \
-H "Content-Type: application/json" \
-H "x-token: yourtoken" \
-d '{
"query": "mutation createFreeTextRecord($recordData: CreateFreeTextRecordDataInput) { createFreeTextRecord(recordData: $recordData) { id } }",
"variables": {"recordData": {"patientId": "4", "consultationId": "abc123", "sectionTitle": "xyz789", "question": "abc123", "answer": "xyz789"}}
}'

Congratulations! You've now learned how to store the responses of a 3rd party medical questionnaire into Semble using the Semble public API.