FHI has created example code showing how an integration with Legemiddelregisteret can be developed. The example code is available in both C# and PowerShell, and demonstrates the most important functions for secure data transfer to the registry.
You can find the example code here:
To gain access to the API for data transfer, the sender system’s IP address must be registered in LMR’s list of allowlisted addresses. Both individual addresses and address ranges can be allowlisted. Allowlisting is only available in the production environment.
Data transferred to the API must be encrypted and signed (see Signed and Encrypted Bundle).
The API is protected by Maskinporten and requires clients to authenticate with machine-to-machine authentication.
To gain access:
https://sjolvbetjening.test.samarbeid.digdir.no/)
fhi:lmr/fhirmottak.apihttps://github.com/Altinn/altinn-apiclient-maskinporten
Resource in the JWT assertion. This value must be fhi:lmr/fhirmottak.Scope claim must also be added. This value corresponds to the name of the scope in the self-service portal: fhi:lmr/fhirmottak.apiInstitutions that are to transfer data to Legemiddelregisteret must follow the defined protocol. The protocol describes requirements for transfer frequency, data structure, and security. You can find more information here: Protocol for data transfer.
To build a collection of data to be transferred, a LegemiddelregisterBundle must be created. This is a specialised FHIR Bundle profile developed for submitting data to Legemiddelregisteret. It is limited to transaction-type bundles and only permits POST operations, ensuring consistent data handling and traceability. The bundle may only contain specific resource types relevant to Legemiddelregisteret: Patient, Practitioner, Medication, MedicationAdministration, Condition, Encounter, MedicationRequest, Organization, Substance.
When transferring data, a SignertKryptertBundle must be created, which ensures both encryption and signing of the content. This process involves compressing, encrypting, and signing a FHIR-based LegemiddelregisterBundle before it is sent to the API. Read more about how to create a SignertKryptertBundle in this guide.
URLs for Legemiddelregisteret’s API:
For testing the integration, two dedicated validation endpoints are available. These store no data and are only available in the test environment.
Validation of FHIR bundle:
/fhirmottak/v1/validateLegemiddelregisterBundle – Validates the content of a FHIR bundle against the LMDI specification.
The endpoint expects to receive an unsigned and unencrypted FHIR bundle in JSON format. Does not require authentication, and the sender does not need to be registered.
Returns a validation result as OperationOutcome with status 200 (valid) or 400 (invalid).Validation of signed and encrypted bundle:
/fhirmottak/v1/validate – Validates that signing and encryption have been performed correctly, and that the content of the encrypted FHIR bundle is in accordance with the LMDI specification.
The endpoint expects to receive a signed and encrypted bundle. The sender must be registered and active. Data is validated but not stored.
Requires Maskinporten authentication with scope fhi:lmr/fhirmottak.api.
Returns status 200 (valid) or 400 (invalid).The test endpoints return the following HTTP status codes:
200 OK
/fhirmottak/v1/validate: The message has been validated but not stored/fhirmottak/v1/validateLegemiddelregisterBundle: Returns OperationOutcome confirming that the FHIR bundle is valid400 Bad Request
/fhirmottak/v1/validate:
401 Unauthorized
/fhirmottak/v1/validate)WWW-Authenticate header with an error description403 Forbidden
/fhirmottak/v1/validate)fhi:lmr/fhirmottak.api)WWW-Authenticate header with an error description500 Internal Server Error