Skip to content

Mock Lighthouse Health API

Afsin Ustundag edited this page Mar 21, 2023 · 3 revisions

Mock Lighthouse Health API is mainly developed to validate LightHouse Health API related functionality in the automated end-to-end tests.

Implementation

Mock Lighthouse Health API is a Spring Boot based REST API.

It is implemented as a Gradle subproject named mocks:mock-lighthouse-api in abd-vro project.

Mock Fhir Bundles

The primary functionality of Mock Lighthouse Health API is to provide Mock Fhir Bundles. All Mock Bundles are in a resource directory called mock-bundles in patient specific directories that are named after the Mock ICN for the patient.

Each patient specific directory contains the actual Mock Bundles named after the resource types. Currently there are three types bundles all in json format

  • Observation.json
  • MedicationRequest.json
  • Condition.json

These Mock Bundles are modeled after the actual Fhir Bundles received either from Lighthouse Sandbox environment or from Lighthouse Production environment before and during end-to-end testing.

The Mock Fhir Bundles are stored in a MockBundles object which are themselves stored in a Java HashMap with the patient ICN's as the keys. Spring Boot Application configuration initializes the HashMap as part of initialization of the MockBundleStore bean.

End Points

All end-points are defined in an interface and implemented in a controller.

All end-points mock Lighthouse Health API functionality. One is for token retrieval and others are for mock Fhir Search End-points to retrieve resources:

  • POST /token
  • GET /Observation
  • GET /Condition
  • GET /MedicationRequest

The end-point /token retrieves jwt. This end-point is a pass-through; it simply calls to Lighthouse Health API Sandbox server for the token and returns the retrieved.

All other end-points identify the patient ICN from the patient query parameter. If the ICN is one of those for which Mock Fhir Bundles are available, the Mock Fhir Bundle is returned. Otherwise the Bundle is retrieved from Lighthouse Health API Sandbox server and returned.

Note that this Mock Server itself does not validate the token when returning the Mock Bundles. For Sandbox Bundles, Mock Server passes the token to the Lighthouse server.

Environment Variables

This Mock API uses the same Lighthouse Health API related environment variables that VRO application uses. You can find these environment variables in the application.yml mock-lh properties.

Clone this wiki locally