4. Demonstrator Back end - nhsconnect/nrls-reference-implementation GitHub Wiki
An API written in C# using Visual Studio 2017. Any IDE capable of developing with .NET Core v2.0 can be used.
In this section:
4.1 Framework
.NET Core
The framework in use is .NET Core v2.0.
Along with the more advanced features that this framework provides it also takes care of some boilerplate code that we previously had to write and re-write ourselves such as dependency injection.
FHIR
To help manage FHIR related resources and web request we are utilising the Hl7.Fhir.STU3 package from ewoutkramer.
4.2 Configuration
There are two areas to configuration, global and app settings.
AppSettings
The most important settings:
- NRLSMongoDB
This contains the datastore connection string config
Other settings include details of the external APIs and shared config values across the Demonstrator:
- Logging
- NRL Stub
- PDS
- ODS
- SPINE
- SSP
- DemonstratorAPI
Environments
It is possible to define environment specific configs which will override any settings defined in them.
The convention is [config file name].[environment].json
4.3 Structure
The structure is simple, the following make up the important areas:
- WebApp
- NRLSAdapter
- Services
- Database
The other projects provide a supporting role for these.
4.3.1 Entry Points
The entry point to the API is handled within:
- Demonstrator.WebApp
WebApp
This is the main web API interface used by the Front end app, and in this project the most important folder is the Controller. From these controllers we distribute our commands up to the Services.
Example endpoint:
http://[BaseUrl]/api/nrls/[nhsNumber]
4.3.2 Services
Services – Flows
These services are quite simple and basically relay commands to fetch data.
You will also find some ViewServices which do additional work to aggregate data from various sources into View Models.
Services – Epr
This service aids the Provider Generic Systems on the front end and also stored fake medical records.
Services – Nrls
This service relays get requests to the NRL Adapter.
Services – PDS and ODS
The NRL service also aggregates data into pointer view models from the various supporting services PDS and ODS.
4.3.3 NRLSAdapter
This projects purposes is to generate requests to the NRL Stub. The important features of the adapter are as follows:
- Generate NRL Pointers
- Generate JWT Tokens
- Build Web Requests and required NRL Headers
- Send and Receive Web Requests to the Stub
Security
When requests come via the front end the all-important ASID is sent from the Generic Screen (See the data section) and added to the Headers.There are both Consumer and Provider specific ASIDs.
These ASIDs are tide to ODS codes and can also be tided to a specific SSL Certificate, details of which are found in the AppSettings config.
Using the wrong ASID will result in an error.
Also using the wrong Custodian OrgCode against an ASID other than the one mapped to that OrgCode will result in an error.
Connector
Entry to the HTTP Stub request from the API Services is done through the Adapter services:
- DocumentReferences
- Organisations
- Patients
- Documents
4.3.5 NRL Adapter ODS & PDS
ODS and PDS searches are done via the NRL Adapter and are currently run against the Stub. As noted above it is theoretically possible to change the config settings to point to other sources.
4.3.6 Data Store
This is a standard installation of MongoDB and uses the official MongoDB driver for all interactions between the services and the data store.
The AppSettings configuration allows you to configure where the DB is located and what credentials and default database is used.
4.4 Build
The build procedure is as standard across a .NET application. Running your IDE build commands will suffice.
4.4.1 Deploy Pipeline
As a standard build this can be integrated into a standard deploy pipeline.
For this project we are using Docker and so is built as part of the Image build.
Details can be found in the Deployment section.