Interface between Intake24 API and Clinical DB
- CRON-like node.js service
- CLI to execute tasks directly
Make sure you have latest Node.js LTS and pnpm installed.
MSSQL lib requires ODBC driver headers to be installed:
apt install unixodbc-dev
Install pnpm
pnpm install -g pnpm
Download local project dependencies
pnpm install
Copy .env-template
to .env
file.
cp .env-template .env
Edit .env
file and set up main configuration variables.
Any additional configuration variables (not extracted as ENV variables) can be found in src/config
folder.
Service executes specific tasks based on provided CRON entry and additional task-specific variables.
Task entries for execution are defined in tasks.json
file as an array of simple JSON objects.
Copy tasks-template.json
to tasks.json
file
cp tasks-template.json tasks.json
Edit tasks.json
file and set up task definitions as needed.
Currently implemented tasks are:
- Export Intake24 survey data and imports data into external database (MSSQL engine)
{
"name": "EXPORT_SURVEY_DATA",
"cron": "* * * * *",
"params": {
"apiVersion": "v3" | "v4",
"survey": "demo",
"exportOffset": 7,
"exportVersion": "v2"
},
"db": {
"database": "databaseName",
"tables": {
"data": "importDataTable",
"log": "importLogTable"
}
},
"notify": {
"success": [],
"error": []
}
},
- Export Intake24 survey stats
{
"name": "EXPORT_SURVEY_SETTINGS",
"cron": "* * * * *",
"params": {},
"notify": {
"success": [],
"error": []
}
},
- read contents of folder with files contains intake24 submission in JSON format
- output either to
csv
ordatabase
{
"name": "IMPORT_JSON_SUBMISSIONS",
"cron": false,
"params": {
"localeId": "en_GB",
"dir": "/path/to/submission/files",
"output": "csv" | "database"
},
"db": {
"database": "databaseName",
"tables": {
"data": "importDataTable",
"log": "importLogTable"
}
},
"notify": {
"success": [],
"error": []
}
},
- Run pg_dump for
system
orfoods
database and transfer to local / network location. - Make sure you got pg_dump binaries installed, e.g. for ubuntu:
apt-get install postgresql-client
.
{
"name": "DB_DUMP_TO_LOCAL",
"cron": "* * * * *",
"params": {
"instance": "instance-name",
"dialect": "mariadb" | "mysql" | "postgres",
"database": string | string[],
"basePath": "/destination/path",
"appendPath"?: "hourly",
"maxAge"?: "30d"
},
"notify": {
"success": [],
"error": []
}
}
- Run pg_dump for
system
orfoods
database and upload to sftp. - Make sure you got pg_dump binaries installed, e.g. for ubuntu:
apt-get install postgresql-client
.
{
"name": "DB_DUMP_TO_SFTP",
"cron": "* * * * *",
"params": {
"instance": "instance-name",
"dialect": "mariadb" | "mysql" | "postgres",
"database": string | string[],
"maxAge"?: "30d",
"sftp": {
"host": "sftp-server.example.com",
"port": 22,
"username": "sftp-username",
"password": "sftp-password",
"dir": "remote/dir/path"
}
},
"notify": {
"success": [],
"error": []
}
}
- First (display) name synchronization from external database (MSSQL) into Intake24 instance
{
"name": "UPLOAD_DISPLAY_NAMES",
"cron": "* * * * *",
"params": {
"dbVersion": "v3 | v4",
"survey": "demo"
},
"db": {
"database": "databaseName"
},
"notify": {
"success": [],
"error": []
}
},
- Upload external questionnaire URLs from external database (MSSQL) into the Intake24
{
"name": "UPLOAD_PAQ_LINKS",
"cron": "* * * * *",
"params": {
"dbVersion": "v3 | v4",
"survey": "demo"
},
"db": {
"database": "databaseName"
},
"notify": {
"success": [],
"error": []
}
}
Start server with hot-reloading
pnpm dev
Build application
pnpm build
Launch application
pnpm start
Optional
- install as service (systemd service example -
intake24-tasks.service
) - use node.js process manager like
pm2
- Execute specific task in
tasks.json
based on index.
pnpm cli --task-index <index>
- Execute specific task without build.
pnpm cli:dev --task-index <index>
Ansible role is provided as part of intake24 deployment repository