You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This contains a cloud formation stack which contains a lambda which can be used to validate FHIR R4 messages against implementation guides on [Simplifier](https://simplifier.net/).
6
+
7
+
-`scripts/` Utilities helpful to developers of this specification.
8
+
-`SAMtemplates/` Contains the SAM templates used to define the stack.
9
+
-`.github` Contains github workflows that are used for building and deploying from pull requests and releases.
10
+
-`.devcontainer` Contains a dockerfile and vscode devcontainer definition.
11
+
-`src` Contains the java source code for the lambda
12
+
13
+
## Contributing
14
+
15
+
Contributions to this project are welcome from anyone, providing that they conform to the [guidelines for contribution](https://github.com/NHSDigital/eps-FHIR-validator-lambda/blob/main/CONTRIBUTING.md) and the [community code of conduct](https://github.com/NHSDigital/eps-FHIR-validator-lambda/blob/main/CODE_OF_CONDUCT.md).
16
+
17
+
### Licensing
18
+
19
+
This code is dual licensed under the MIT license and the OGL (Open Government License). Any new work added to this repository must conform to the conditions of these licenses. In particular this means that this project may not depend on GPL-licensed or AGPL-licensed libraries, as these would violate the terms of those libraries' licenses.
20
+
21
+
The contents of this repository are protected by Crown Copyright (C).
22
+
23
+
## Updates to implementation guide versions
24
+
25
+
The implementation guides and versions are defined in `src/resources/manifest.json`. When we need to update to a newer version, just update this file and run `make download-dependencies` to download them locally.
4
26
5
-
## Customising the validator
6
-
The Simplifier packages to be used for validation are declared in manifest.json. These are downloaded at build time and included in the jar.
7
27
8
28
## Known limitations
9
29
* Resources must use FHIR version R4
@@ -13,9 +33,173 @@ The Simplifier packages to be used for validation are declared in manifest.json.
13
33
* A capability statement in the packages specifies which profile to use for a given resource type
14
34
* The validator does not use a terminology server, so some code systems, including SNOMED, cannot be validated
15
35
16
-
## How to update validator in EPS
17
-
From repo root, run:
18
-
-`make install`
19
-
-`make build-latest`
20
36
21
-
Commit and push changes to a branch. Get merged into main and reference new commit from EPS repo
37
+
## Development
38
+
39
+
It is recommended that you use visual studio code and a devcontainer as this will install all necessary components and correct versions of tools and languages.
40
+
See https://code.visualstudio.com/docs/devcontainers/containers for details on how to set this up on your host machine.
41
+
There is also a workspace file in .vscode that should be opened once you have started the devcontainer. The workspace file can also be opened outside of a devcontainer if you wish.
42
+
The project uses [SAM](https://aws.amazon.com/serverless/sam/) to develop and deploy the APIs and associated resources.
43
+
44
+
All commits must be made using [signed commits](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits)
45
+
46
+
Once the steps at the link above have been completed. Add to your ~/.gnupg/gpg.conf as below:
47
+
48
+
```
49
+
use-agent
50
+
pinentry-mode loopback
51
+
```
52
+
53
+
and to your ~/.gnupg/gpg-agent.conf as below:
54
+
55
+
```
56
+
allow-loopback-pinentry
57
+
```
58
+
59
+
As described here:
60
+
https://stackoverflow.com/a/59170001
61
+
62
+
You will need to create the files, if they do not already exist.
63
+
This will ensure that your VSCode bash terminal prompts you for your GPG key password.
64
+
65
+
You can cache the gpg key passphrase by following instructions at https://superuser.com/questions/624343/keep-gnupg-credentials-cached-for-entire-user-session
66
+
67
+
### SAM setup and usage
68
+
69
+
[SAM](https://aws.amazon.com/serverless/sam/) allows rapid local development and deployment to AWS for development and testing.
70
+
71
+
### Setup
72
+
73
+
Ensure you have the following lines in the file .envrc
74
+
75
+
```
76
+
export AWS_DEFAULT_PROFILE=prescription-dev
77
+
export stack_name=<UNIQUE_NAME_FOR_YOU>
78
+
```
79
+
80
+
UNIQUE_NAME_FOR_YOU should be a unique name for you with no underscores in it - eg anthony-brown-1
81
+
82
+
Once you have saved .envrc, start a new terminal in vscode and run this command to authenticate against AWS
83
+
84
+
```
85
+
make aws-configure
86
+
```
87
+
88
+
Put the following values in:
89
+
90
+
```
91
+
SSO session name (Recommended): sso-session
92
+
SSO start URL [None]: <USE VALUE OF SSO START URL FROM AWS LOGIN COMMAND LINE ACCESS INSTRUCTIONS ACCESSED FROM https://myapps.microsoft.com>
93
+
SSO region [None]: eu-west-2
94
+
SSO registration scopes [sso:account:access]:
95
+
```
96
+
97
+
This will then open a browser window and you should authenticate with your hscic credentials
98
+
You should then select the development account and set default region to be eu-west-2.
99
+
100
+
You will now be able to use AWS and SAM CLI commands to access the dev account. You can also use the AWS extension to view resources.
101
+
102
+
When the token expires, you may need to reauthorise using `make aws-login`
103
+
104
+
### CI Setup
105
+
106
+
The GitHub Actions require a secret to exist on the repo called "SONAR_TOKEN".
107
+
This can be obtained from [SonarCloud](https://sonarcloud.io/)
108
+
as described [here](https://docs.sonarsource.com/sonarqube/latest/user-guide/user-account/generating-and-using-tokens/).
109
+
You will need the "Execute Analysis" permission for the project (NHSDigital_prescriptionsforpatients) in order for the token to work.
110
+
111
+
112
+
### Continuous deployment for testing
113
+
114
+
You can run the following command to deploy the code to AWS for testing
115
+
116
+
```
117
+
make sam-sync
118
+
```
119
+
120
+
This will take a few minutes to deploy - you will see something like this when deployment finishes
121
+
122
+
```
123
+
......
124
+
CloudFormation events from stack operations (refresh every 0.5 seconds)
Note - the command will keep running and should not be stopped.
140
+
141
+
142
+
### Make commands
143
+
144
+
There are `make` commands that are run as part of the CI pipeline and help alias some functionality during development.
145
+
146
+
#### install targets
147
+
148
+
-`install-python` installs python dependencies
149
+
-`install-hooks` installs git pre commit hooks
150
+
-`install` runs all install targets
151
+
152
+
#### SAM targets
153
+
154
+
These are used to do common commands
155
+
156
+
-`sam-build` prepares the lambdas and SAM definition file to be used in subsequent steps
157
+
-`sam-sync` sync the API and lambda to AWS. This keeps running and automatically uploads any changes to lambda code made locally. Needs AWS_DEFAULT_PROFILE and stack_name environment variables set.
158
+
-`sam-validate` validates the main SAM template and the splunk firehose template.
159
+
-`sam-deploy-package` deploys a package created by sam-build. Used in CI builds. Needs the following environment variables set
160
+
- artifact_bucket - bucket where uploaded packaged files are
161
+
- artifact_bucket_prefix - prefix in bucket of where uploaded packaged files ore
162
+
- stack_name - name of stack to deploy
163
+
- template_file - name of template file created by sam-package
164
+
- cloud_formation_execution_role - ARN of role that cloud formation assumes when applying the changeset
165
+
166
+
167
+
#### Clean and deep-clean targets
168
+
169
+
-`clean` clears up any files that have been generated by building or testing locally.
170
+
-`deep-clean` runs clean target and also removes any maven and python libraries installed locally.
171
+
172
+
#### Linting and testing
173
+
174
+
-`lint` runs lint for all code
175
+
-`lint-python` runs lint for python scripts
176
+
-`lint-samtemplates` runs lint for SAM templates
177
+
-`lint-githubactions` runs lint for github actions
178
+
-`lint-githubactions-scriptns` runs lint for github actions scripts
179
+
-`test` runs unit tests for all code
180
+
181
+
#### Compiling
182
+
183
+
-`compile` compiles all code
184
+
-`download-dependencies` downloads files from simplifier
185
+
186
+
#### Check licenses
187
+
188
+
-`check-licenses` checks licenses for all packages used - calls check-licenses-java, check-licenses-python, check-licenses-golang
189
+
-`check-licenses-java` checks licenses for all java code
190
+
-`check-licenses-python` checks licenses for all python code
191
+
192
+
#### CLI Login to AWS
193
+
194
+
-`aws-configure` configures a connection to AWS
195
+
-`aws-login` reconnects to AWS from a previously configured connection
196
+
197
+
198
+
### Pre-commit hooks
199
+
200
+
Some pre-commit hooks are installed as part of the install above, to run basic lint checks and ensure you can't accidentally commit invalid changes.
201
+
The pre-commit hook uses python package pre-commit and is configured in the file .pre-commit-config.yaml.
0 commit comments