This repository is now archived. It was previously used to enable transferring health records from a GP practice to repository, however this functionality now lives within EHR Transfer Service.
This component is responsible for the deduction functionality. When the patient becomes deducted from their previous practice and their health record becomes Orphaned/Stranded, the repository receives and stores the digital copy of it.
Follow the links to download
- Node - version 14.x
- Docker
- kudulab/dojo
In order to run npm install locally on your host, you'll need to install postgresql:
brew install postgresql
This repository imports shared AWS helpers from prm-deductions-support-infra.
They can be found utils
directory after running any task from tasks
file.
Directory | Description |
---|---|
/docs | Contains documentation such as Plantuml diagrams |
/test/docker | Contains smoke test for docker |
/test/functional | Contains end-to-end tests |
/gocd | Contains the GoCD pipeline files |
/src | The source code |
/terraform | Terraform to deploy app as a Fargate task in AWS |
/scripts | Useful scripts (e.g. for sending canary messages) |
/utils | Contains aws-helpers |
- Run
npm install
to install all node dependencies. - Configure local environment variables:
- enter
dojo
- run
./tasks _setup_test_integration_local
- enter
- Run
npm run start:local
- If successful, you will be able to reach the Swagger docs: http://localhost:3000/swagger/
Note: npm run start:nodemon
can be used to build the app before launching the Express server on port 3000
using nodemon - it will watch and reload the server upon any file changes.
Below are the environment variables that are automatically set:
NHS_ENVIRONMENT
- is set to the current environment in which the container is deployed. It is populated by the pipeline.gocd.ymlSERVICE_URL
- This is pre-populated bytasks
and will configure it to service URL according to environment.REPOSITORY_URI
- This is pre-populated bytasks
(based onIMAGE_REPO_NAME
)AUTHORIZATION_KEYS
- a comma-separated list of Authorization keys. These are automatically taken from AWS Parameters Store in the 'dev' and 'test' environments.
A Docker image can be built locally with:
- Run
./tasks build
- Run
./tasks build_docker_local
. This builds the docker containersdeductions/<component-name>:<commit-no>
anddeductions/<component-name>:latest
with the app in - Run
./tasks test_docker_local
to ensure the image has been built correctly - If the above fails,
./tasks run_docker_local
to debug production build
The swagger documentation for the app can be found at http://localhost:3000/swagger. To update it, change the
src/swagger.json
file. You can use this editor which will validate your changes.
Make sure your IDE has all the required environment variables configured. Use the test Dojofile with the preconfigured dependencies:
- enter
dojo -c Dojofile-itest
- run
./tasks _test_unit
or_test_integration
or_test_functional
Note: you can also run your rest directly from your IDE provided you configure your local environment variables first:
- enter
dojo
- run
./tasks _setup_test_integration_local
Run the unit tests with npm run test:unit
(or npm test
to run it with lint)
Enter dojo -c Dojofile-itest
Run ./tasks test_integration
to run within Dojo.
Runs the coverage tests (unit test and integration test) and collects coverage metrics.
Enter dojo -c Dojofile-itest
Run ./tasks test_coverage
to run within Dojo.
Run ./tasks test_docker_local
. Make sure you have followed the steps to start the app in production mode beforehand.
Run ./tasks test_functional
. This will run the end to end tests within ./test/functional. (Note you may need to be connected to VPN).
Before committing, ensure you run the following tests:
- Unit tests
- Integration tests
- Coverage tests
- Local docker test
In order to get sufficient access to work with terraform or AWS CLI, please follow the instructions on this confluence pages and this how to?
As a note, this set-up is based on the README of assume-role tool
brew install remind101/formulae/assume-role
Run the following command with the profile configured in your ~/.aws/config
:
assume-role admin
Run the following command with the profile configured in your ~/.aws/config
:
eval $(dojo "echo <mfa-code> | assume-role admin"
Run the following command to confirm the role was assumed correctly:
aws sts get-caller-identity
When creating the new ssm keys, please follow the agreed convention as per the design specified below:
- all parts of the keys are lower case
- the words are separated by dashes (
kebab case
) env
is optional
Please follow this design to ensure the ssm keys are easy to maintain and navigate through:
Type | Design | Example |
---|---|---|
User-specified | /repo/<env>?/user-input/ |
/repo/${var.environment}/user-input/db-username |
Auto-generated | /repo/<env>?/output/<name-of-git-repo>/ |
/repo/output/prm-deductions-base-infra/root-zone-id |