Note This repository is unmaintained as of 2023-05-03 as I am no longer employed by Somerset NHS Foundation Trust.
Yeovil Hospital's FHIR API authentication service
This is Yeovil Hospital's FHIR API authentication service, a Node.js application using the Fastify web framework.
Yeovil Hospital uses Mirth Connect for its integration engines that, whilst a versatile system, does not provide the following:
- SSL/TLS support out of the box
- Easily configurable authentication on HTTP/FHIR listeners
- Easily configurable CORS
This service was created to provide that functionality, acting as a proxy and middleware between the firewall and the targeted FHIR/HTTP listener channel.
- Node.js >=18.12.1 (if running outside of Docker)
- Mirth Connect
Perform the following steps before deployment:
- Download and extract the latest release asset
- Navigate to the extracted directory
- Make a copy of
.env.template
in the root directory and rename it to.env
- Configure the application using the environment variables in
.env
Note Set the following environment variables in
.env
to meet NHS England's recommendation to retain six months' worth of logs:
LOG_ROTATION_DATE_FORMAT="YYYY-MM-DD"
LOG_ROTATION_FREQUENCY="daily"
LOG_ROTATION_MAX_LOGS="180d"
- Run
npm ci --ignore-scripts --omit=dev
to install dependencies - Run
npm start
The service should now be up and running on the port set in the config. Output similar to the following should appear in stdout or in the log file specified using the LOG_ROTATION_FILENAME
environment variable:
{
"level": "info",
"time": "2022-10-20T07:57:21.459Z",
"pid": 148,
"hostname": "MYCOMPUTER",
"msg": "Server listening at http://127.0.0.1:51173"
}
To test it, use a request builder (i.e. Insomnia) and import the example requests in ./test_resources/insomnia-test-requests.json
.
This requires Docker installed.
- Run
docker compose up
(ordocker compose up -d
to run in the background)
If this cannot be deployed into production using Docker, use a process manager such as PM2.
- Run
npm ci --ignore-scripts --omit=dev
to install dependencies - Run
npm install -g pm2
to install pm2 globally - Launch application with
pm2 start .pm2.config.js
- Check the application has been deployed using
pm2 list
orpm2 monit
If using a Microsoft Windows OS utilise pm2-installer to install PM2 as a Windows service.
Note PM2 will automatically restart the application if
.env
is modified.
API documentation can be found at /docs
:
The underlying OpenAPI definitions are found at /docs/openapi
.
Contributions are welcome, and any help is greatly appreciated!
See the contributing guide for details on how to get started. Please adhere to this project's Code of Conduct when contributing.
- Mark Hunt - JWT and JWKS integration and testing
- Will Jehring - Forwarding and JWT testing
yh-fhir-authentication-service
is licensed under the MIT license.