Quickstart Code Example
Ask questions of a clinical document and read the answers back — in Python
This page submits one document with three questions, waits for the job to
finish, and prints each answer with its evidence. It uses only the requests
library.
Create an API key with the formfill:process scope on the
emtelligent platform, then set it in the environment:
Create a session
Authentication is a bearer token in the Authorization header: an API key, or an
OAuth 2.0 access token.
Submit a job
A question is a string, or an object that names its answer type. The
Idempotency-Key makes the submission safe to retry: sending the same key and
body again returns the original job instead of creating, and charging for, a
second one.
Wait for it to finish
A job usually finishes within 5 to 10 seconds.
To avoid polling, add a callback_url to the submission and receive a
webhook when the job finishes.
Read the answers
A result can be downloaded once: a second request returns
410 result_expired. Store the result before
you do anything else with it.
The question given as a plain string was numbered q1, by its position. Give
questions an id of your own when you need to match answers back to them.
Next steps
- Asking questions: question types,
multiple, and writing questions that answer well - Filling a Questionnaire: the same job with a FHIR R4 Questionnaire
- Results and evidence: statuses, confidence, and highlighting evidence in your document
Complete example
The steps above in one script. Save it as formfill_quickstart.py, set
FORMFILL_API_KEY as at the top of this page, and run python formfill_quickstart.py.
To fill a FHIR Questionnaire instead, send "type": "questionnaire" with your
Questionnaire in place of "questions", and read result["questionnaire_response"];
see Filling a Questionnaire.

