NHA-ABDM / ABDM-wrapper

Apache License 2.0
22 stars 15 forks source link

ABDM Wrapper

The Ayushman Bharat Digital Mission (ABDM) is a government initiative that aims to develop a digital health infrastructure for India. An overview of ABDM can be found here. The ABDM aims to improve the efficiency and transparency of healthcare data transfer between patients, medical institutions, and healthcare service providers. It also allows patients to securely store their medical information and share with others as needed. The National Health Authority (NHA) is implementing Ayushman Bharat Digital Mission (ABDM) to create a digital health ecosystem for the country. ABDM intends to support different healthcare facilities like clinics, diagnostic centers, hospitals, laboratories and pharmacies in adopting the ABDM ecosystem to make available the benefits of digital health for all the citizens of India. In order to make any digital solution ABDM compliant, it has to go through 3 milestones and obtain AND certification.

ABDM Wrapper is created to solve the challenges and issues faced by integrators to bring their systems into ABDM ecosystem. Wrapper aims to abstract complex workflows and algorithms exposing clean and simple interfaces for integrators. Wrapper abstracts implementation of HIP and HIU workflows involved in Milestone 2 and Milestone 3.

Architecture

ABDM Wrapper Architecture

Wrapper is a springboot application packaged with mongodb database. Wrapper can be deployed on existing HMIS's / health facility's infrastructure.

There are sets of interfaces which wrapper exposes and the existing services need to invoke them to implement ABDM workflows.

At the same time if HMIS is an HIP, then existing services should expose a set of interfaces which wrapper needs to invoke to get information from health providers.

The callback apis which gateway would be making to wrapper should be behind facility's firewall.

Pre-requisites

1. Install ABHA SBX PHR App on your mobile.

https://sandbox.abdm.gov.in/docs/phr_app

2. Create ABHA Address

* Skip if ABHA Address already exists.

ABHA Address can be created using: 
- Mobile Number
- Aadhaar Number
- E-mail

After creating the ABHA Address, your id should look like "yourAbha@sbx"

3. System Requirements and Installations:

There are two ways to get wrapper and related applications running on your system:

1. Using docker (Preferred): This is an easy way to get wrapper up and running.

Install docker and docker-compose: You can install docker desktop from here to get both.

System Requirements:

Using default docker-compose.yaml, you can bring up wrapper and mongodb services. Using compose-wrapper-mockgateway.yaml, you can bring up wrapper, mongodb and mock gateway services.

This repository provides two other services:

If you need to bring these services up, then you need to install gradle from here

2. If you are facing issues with installing or running docker, then you can install individual components:

System Requirements:

Recommended RAM: Systems with more than 8 GB RAM

4. Register bridge (hostUrl) with ABDM for callbacks.

  1. Get Access Token.

    curl --location 'https://dev.abdm.gov.in/gateway/v0.5/sessions' \
    --header 'Content-Type: application/json' \
    --data '{
    "clientId": <client id provided>,
    "clientSecret": <client secret provided>
    }'
  2. Register bridge url

    curl --location --request PATCH 'https://dev.abdm.gov.in/gateway/v1/bridges' \
    --header 'Authorization: Bearer <your accessToken>' \
    --header 'Content-Type: application/json' \
    --data '{
    "url": <your bridge url>
    }'
  3. Check the BRIDGE URL and Facilities

    curl --location 'https://dev.abdm.gov.in/gateway/v1/bridges/getServices' \
    --header 'Authorization: Bearer your accessToken' \
    --header 'X-CM-ID: sbx' \
    --data ''

    Swagger UI

  4. Wrapper API's you can check here

  5. FHIR Module API's you can check here

    Bring the application up.

  6. If the actual ABDM Gateway is up and running and responding properly:

    • Provide clientId and clientSecret in application.properties
    • If you have installed docker and docker compose then you can bring the application using: docker-compose up --build
    • If you have chosen to install separate components, then here is how you can bring the services up:
      • Start mongodb (let the port be defaulted to 27017): Instructions on how to start can be found here The links like Install on Linux do have instructions on how to start the service as well.
      • Go to root of this repository and start wrapper by running gradle bootrun
  7. In case ABDM sandbox gateway is down or not responding properly, you can use this mock gateway to test out your workflows. The ways to bring up the application are:

    • If you have installed docker and docker compose then you can bring the application:
      • Make the following changes to application.properties:
        Uncomment this line gatewayBaseUrl=http://gateway:8090 and comment gatewayBaseUrl=https://dev.abdm.gov.in/gateway
      • Run docker-compose -f compose-wrapper-mockgateway.yaml up --build
    • If you have chosen to install separate components, then here is how you can bring the services up:
      • Start mongodb (let the port be defaulted to 27017): Instructions on how to start can be found here The links like Install on Linux do have instructions on how to start the service as well.
      • Make the following changes to application.properties:
        Uncomment this line gatewayBaseUrl=http://gateway:8090 and comment gatewayBaseUrl=https://dev.abdm.gov.in/gateway
      • Also, change gatewayBaseUrl=http://gateway:8090 to gatewayBaseUrl=http://localhost:8090
      • Make one more change in mock-gateway's wrapper.yaml:
        change - url: http://abdm-wrapper:8082 to - url: http://localhost:8082
      • Install maven form here
      • Go to mock-gateway directory: cd mock-gateway
      • Run mvn spring-boot:run
      • In a different terminal, come to root of the repository and start wrapper by running gradle bootrun
  8. Proxy Server Settings:

    • If wrapper needs to send requests using proxy server then please define the following properties in application.properties:
      • useProxySettings=true
      • proxyHost=your proxy server ip
      • proxyPort=your proxy server port

Step-by-Step Testing Instructions:

Testing can be done majorly in 3 parts:

  1. Linking of care contexts
    • Discovery and user-initiated linking
    • HIP initiated linking
  2. Creation of consents
  3. Health information exchange

Adding patient to wrapper's db

We need to first add patient's details into wrapper's database. There are different ways by which we can do that:

  1. Docker container mongosh
    • If the docker containers are running then you can check the status of containers by running docekr ps
    • Then we can get inside the mongo container by running docker exec -it abdm-wrapper_mongodb_1 bash
    • Start mongo shell by running mongosh
    • Run use abdm_wrapper
    • Create a collection named patients by running db.createCollection('patients')
    • Add an item by providing the values which you want for the patient by running:
      db.patients.insert({
      "name": "patient's name",
      "gender": "M",
      "dateOfBirth": "DOB in yyyy-mm-dd",
      "patientReference": "patient's reference",
      "patientDisplay": "patient's display name",
      "patientMobile": "patient's mobile number",
      "abhaAddress": "patientAbhaAddress@sbx"
      })
  2. By using Compass for Mongodb
    • Install MongoDB Compass from here
    • Launch MongoDB Compass
    • Connect using default settings which is localhost and 27017
    • On GUI, you would see mongosh control on bottom left. You can carry the same steps which are mentioned in Step 1 after mongosh.
    • Alternatively, you can use graphical interface to create a database, a patients collection and a patient entry with the folloing values:
      • name
      • gender
      • dateOfBirth
      • patientReference
      • patientDisplay
      • patientMobile
      • abhaAddress
  3. By using postman. You can create a request and fire it up to wrapper. The PUT request should look like this:
    curl --location --request PUT 'localhost:8082/v1/add-patients' \
    --header 'Content-Type: application/json' \
    --data-raw '[{
      "name":"Govada Venu Ajitesh",
      "abhaAddress":"govada2704@sbx",
      "patientReference":"govada2704",
      "gender":"M",
      "dateOfBirth":"YYYY-MM-DD",
      "patientDisplay": "Govada Venu Ajitesh",
      "patientMobile":"Patient mobile"
    }]'
  4. By using Sample HIP
    • Go to PatientController.java
    • Make changes in upsertPatients method for patient details which you want to add or update in wrapper's database (Create a new method in case of a different language)
    • Bring the sample hip application up: gradle bootRun
    • Open postman and post a request to http://localhost:8081/v1/test-wrapper/upsert-patients

Register Facility/HIP with ABDM:

Discovery and User Initiated Linking

Follow the steps to link care contexts:

HIP Initiated Linking

Follow the steps to link care contexts. The linking can be achieved by two modes:

Consent Creation

Expose Endpoint to share health information bundle

Health Information Exchange

Frequently Asked Questions

Check this page to see FAQs.

Frequently Faced Issues

Check this page to see frequently faced issues.

Developer Guide

Check this page to get more details on this.