...
Flow/output: Next Question/ validation error current question.
Final output: QuestionnaireResponse JSON
Developer API Documentation
Questionnaire Processor is a server-side Node.js application designed to seamlessly process FHIR Questionnaires. This robust tool can be integrated with USSD or chatbot applications to prompt users with questionnaire items and gather their responses.
Objectives:
Parse the provided FHIR Questionnaire.
Prompt users with relevant questions.
Validate and process user responses based on question types.
Provide skip logic and conditional validations.
Save and resume sessions.
Detailed logging of user interactions.
Getting Started:
Environment Configuration:
Rename the
.env.example
file to.env
.Update the
.env
file based on your system configuration.
API Endpoint:
base_url/api/v1/questionnaire
API Documentation: Access detailed API documentation and test endpoints using swagger-ui at
base_url/api/v1/docs
.
Request Parameters:
Headers:
X-api-key
: Your API token set in the.env
file (required).Accept-Language
: Set the desired language for the response. Supported languages:English
,French
,Spanish
andBurundi
.
Body:
sessionId
: Unique session id for the interaction (required).userId
: Unique identifier related to the user.Input
: User response to the prompt (optional for first request).showQR
: Return Questionnaire response after each request (optional). The valid values are
orStatus colour Green title true Status colour Red title false questionnaire
: FHIR Questionnaire in JSON format (optional after the initial request).
Response Structure:
Status
: Reflects the state of the session (CON
orEND
).Message
: Question item, options, or validation message displayed to the user.QuestionnaireResponse
: Returned ifshowQR
is true or the session reaches the end.
Supported Question Types:
Boolean
Choice
Date
Decimal
Display
Integer
Phone
Quantity
Text
URL
Notes:
For Boolean questions, 1 is used for
True
and 2 forFalse
.Skip logic and validations like greater than, less than, or equals to are supported.
The application uses SQLite for session management and Winston for logging.
Use a simple token-based authentication mechanism for enhanced security.
The application doesn’t support nested FHIR questionnaire.
Example Request:
Code Block | ||
---|---|---|
| ||
{
"sessionId": "123456789",
"userId": "user123",
"Input": null,
"showQR": true,
"questionnaire": {...} // Your FHIR Questionnaire JSON
} |
Conclusion:
Questionnaire Processor offers a comprehensive solution to efficiently gather and manage user data via FHIR Questionnaires. This well-documented API ensures easy integration into diverse platforms, providing both developers and end-users with an enriching experience.
Issues and Support:
For any issues, feature requests, or support queries, feel free to raise an issue in our GitHub repository.
Flow Diagram:
...
Link: https://drive.google.com/file/d/1WM5nvoVbOon-X0yTX7t5Prz7mt_1DRVP/view?usp=sharing