IPEHR project - bsn-si/IPEHR-gateway Wiki

What is IPEHR?

The IPEHR (InterPlanetary EHR) project is held to propose an alternative way of storing medical data registries. Patients’ data will be stored in the Filecoin network and will be accessed directly by stakeholders according to their personal access rights. Access rights and documents’ indexes will be stored on a blockchain in a smart contract. Every data subject will have full unalienable control over his data and manage access rights on a personal level.

The project is under active development and will gradually be supplemented.

Key features of the IPEHR solution:

  • all data is stored in provider-independent decentralized storage;
  • data encryption;
  • self-management of user’s access rights;
  • data integrity and authenticity is guaranteed by a smart contract.

According to the RFP application first stage of this project is developed with 7 milestones:

  • Development of MH-ORM and structure of storage of medical data - we are here
  • The functionality of encryption and saving/reading personal data to/from Filecoin
  • Access rights management on a blockchain
  • BsnGateway. Implementation of OpenEHR API, integration with MH-ORM
  • Public data publishing features using the Chainlink network
  • Application to manage your own medical data and access
  • Testing, documentation, and deployment

Workflow example

The following methods are based on the standard specification of OpenEHR

The following workflow is showing how to create, update and find EHR information using swagger

Precondition: go to Swagger

P.S. For creating a UUID you can use a generator (e.g uuidgenerator)

Create an EHR

Create an EHR

  1. Click POST /ehr Create EHR method
  2. Click Try it out
  3. Fill in AuthUserId (UUID format e.g 46f3df9f-817c-4910-825f-92d5ea595c73) and Prefer return=representation
  4. Click Execute

Result: in the response, you see a created EHR with structured data in JSON format. Also in the response, you see other important information (e.g fields like ehr_id, ehr_status, ehr_access, time_created that help you to work with EHR in the future requests)

Watch video instruction 📹

Create EHR with subject_id and subject_namespace params

  1. Click PUT ​/ehr​/{ehr_id} Create EHR method
  2. Click Try it out
  3. Fill in AuthUserId (UUID format e.g 46f3df9f-817c-4910-825f-92d5ea595c73) and specify ehr_id (also UUID format)
  4. Change params in Request field
    • "subject" -> "external_ref" -> "id" -> "value" -> put here id (e.g num123)
    • "subject" -> "external_ref" -> "id" -> "namespace" -> put here namespace (e.g testnamespace)
  5. Click Execute

Result: in the response, you see a created EHR with structured data in JSON format. Also in the response, you see other important information (e.g fields like ehr_id, ehr_status, ehr_access, time_created that help you to work with EHR in future requests). There are no subject_id and subject_space fields, they can be only requested with GET request

Watch video instruction 📹

Create EHR with id

  1. Click PUT /ehr​/{ehr_id} Create EHR with id method
  2. Click Try it out
  3. Fill in AuthUserId (UUID format e.g 46f3df9f-817c-4910-825f-92d5ea595c73), Prefer (return=representation) and specify ehr_id (also UUID format)
  4. Click Execute

Result: in the response, you see a created EHR with structured data in JSON format. Also in the response, you see other important information (e.g fields like ehr_id, ehr_status, ehr_access, time_created that help you to work with EHR in the future requests)

Watch video instruction 📹 (the same as Create EHR with subject_id and subject_namespace params, but do not put subject_id and subject_namespace)

Get EHR with different parameters

Getting info on created summary EHR by the subject id

Precondition: Create EHR with subject_id and subject_namespace. Copy params subject_id and subject_namespace to a buffer

  1. Click /GET ehr/{ehr_id} Get EHR summary by subject id
  2. Click Try it out
  3. Paste subject_id, subject_namespace and AuthUserId from previously created EHR
  4. Click Execute

Result: in the response, you see created before EHR with the requested subject_id and subject_namespace. Here you can find exact EHR without ehr_id.

Watch video instruction 📹

Getting info on created EHR summary by id

Precondition: EHR was created and ehr_id is copied to a buffer

  1. Click /GET her GET Get EHR summary by summary id
  2. Click Try it out
  3. Fill in (or paste) ehr_id field
  4. Click Execute

Result: in the response, you see created before EHR which was found with ehr_id

Watch video instruction 📹

Getting info on EHR status version by time

Precondition: EHR was created and ehr_id, AuthUserId, Prefer, and time_created(return=representation) are copied to a buffer

  1. Click /GET ehr/{ehr_id}/ehr_status Get EHR_STATUS version by time
  2. Click Try it out
  3. Fill in ehr_id, AuthUserId, Prefer, and time_created (or any other time between creation EHR and current time in format "2022-06-22T13:26:39.042+00:00") with copied information
  4. Click Execute

Result: in the response, you see the EHR status version by time

Watch video instruction 📹

Getting info on EHR_STATUS by version id

Precondition: EHR was created and ehr_id, AuthUserId, version_id (look at "ehr_status" -> "value") are copied to a buffer

  1. Click GET /ehr/{ehr_id}/ehr_status/{version_uid} Get EHR_STATUS by version id
  2. Click Try it out
  3. Fill in ehr_id, AuthUserId, version_id (e.g 8cf1779d-f050-4be3-a671-579bf277f294::openEHRSys.example.com::1 where ::1 is version of EHR) with copied information
  4. Click Execute

Result: in the response, you see the EHR status EHR_STATUS by version id (at the example it is ::1 at the end which means requested the first version)

Watch video instruction 📹

Update EHR

Update EHR status

Precondition: EHR was created and ehr_id, AuthUserId are copied to a buffer

  1. Click /PUT /ehr/{ehr_id}/ehr_status Update EHR_STATUS

  2. Click Try it out

  3. Fill in AuthUserId with copied information

  4. Fill in a new ehr_id according to the UUID format

  5. Fill in If-Match with current version_id (e.g the current version is 8cf1779d-f050-4be3-a671-579bf277f294::openEHRSys.example.com::1)

  6. Fill in Request with a body template (also can find it here):

    { "_type": "EHR_STATUS", "archetype_node_id": "openEHR-EHR-EHR_STATUS.generic.v1", "name": { "value": "EHR Status" }, "uid": { "_type": "OBJECT_VERSION_ID", "value": "8849182c-82ad-4088-a07f-48ead4180515::openEHRSys.example.com::2" }, "subject": { "external_ref": { "id": { "_type": "HIER_OBJECT_ID", "value": "324a4b23-623d-4213-cc1c-23f233b24234" }, "namespace": "DEMOGRAPHIC", "type": "PERSON" } }, "other_details": { "_type": "ITEM_TREE", "archetype_node_id": "at0001", "name": { "value": "Details" }, "items": [] }, "is_modifiable": true, "is_queryable": true }

  7. In the body change data (e.g. "is_queryable": false instead of "is_queryable": true)

  8. Click Execute

Result: in the response, you see an updated EHR. Now you can find EHR with a new version and in new version, you will see that the changed param has a new value

Watch video instruction 📹

Create a composition

Creates the first version of a new COMPOSITION in the EHR identified by ehr_id

Precondition: EHR was created and ehr_id, AuthUserId, and Prefer (return=representation) are copied to a buffer

  1. Click /POST /ehr/{ehr_id}/composition Create COMPOSITION
  2. Click Try it out
  3. Fill in ehr_id, AuthUserId, and Prefer` with copied information
  4. In the Request put information (body of JSON) from this file
  5. Click Execute

Result: in the response, you see a created composition with a lot of information inside (e.g archetype_node_id, composer, health_care_facility etc)

Watch video instruction 📹

Execute ad-hoc (non-stored) AQL query

Execute AQL query

  1. Click /POST query/aql Execute ad-hoc (non-stored) AQL query
  2. Click Try it out
  3. Fill in AuthUserId
  4. Fill in Request with AQL request

    { "q": "SELECT c/uid/value, obs/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/magnitude AS systolic FROM EHR e[ehr_id/value=$ehr_id] CONTAINS COMPOSITION c[openEHR-EHR-COMPOSITION.health_summary.v1] CONTAINS OBSERVATION obs[openEHR-EHR-OBSERVATION.blood_pressure.v2] WHERE obs/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/magnitude >= $systolic_bp", "offset": 0, "fetch": 10, "query_parameters": { "ehr_id": "07fa4e05-df30-4a2b-9612-6bf1d28ff80c", "systolic_bp": 140 } }

  5. Click Execute Result: In the response, you see a requested information

Watch video instruction 📹