Skip to content

hexila/interoperability-testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Technical Details

Working elements

  • Backend
  • Blockchain
  • SmartContract
  • HL7Convertor
  • Docker

Backend

The backend is written in Python, using the FastAPI framework. When getting run, the Python backend tries to access the local Ethereum blockchain network ad 127.0.0.1:9545.

Moreover, It has 5 endpoints:

HTTP Purpose
POST /record/set Create a new record on the blockchain
GET /record/get/:key Get records of the blockchain, based on the provided publickey
POST /thirdparty/add Create a thirdparty, for the provided publickey
GET /thirdparty/get/:key Get a public key’s thirdparties
GET /blockchain/publickey Get blockchain public key

A new record on the blockchain

Generate a based on the provided public key, and store the value for the generated key.
Given that the provided publickey is FOO, based on the provided publickey, the generated key will be:
FOO||||FOO
“||||” (four pipes) is the delimiter.

Pattern

[PATIENT PUBLIC KEY] + delimiter + [PATIENT PUBLIC KEY]
[BLOCKCHAIN PUBLIC KEY] + delimiter + [PATIENT PUBLIC KEY]

Each time a value gets created on the blockchain, an identical record with the same value will be created with a different key. This means a new record with a value X will have the following format:

{  
	  
	“FOO||||Foo”: [..., X],  
	“BLOCKCHAIN_PUBLICK_KEY||||Foo”: [..., X],  
	  
}

Reading a public key’s data from the blockchain

You will get a list of all the data the provided public key has on the blockchain.

Create a thirdparty

Each public key in the blockchain will have a list indicating who has been granted to see what data. By removing or adding thirdparties, we store a new copy of the current valid thirdparties. With having their state, we can tell, for example:
Mr. Brown(a thirdparty) has been on the list of Miss Blue*(the patient)*’s thirdparities for 2 years, however, Mr. Brown is no longer considered a thirdparty as Miss Blue removed him 2 months ago”

Get thirdparties list

Simply a list containing all thirdparties in a list of public keys.
This is the structure for the data we store on the blockchain for the access list (thirdparties):

[BLOCKCHAIN PUBLIC KEY] + delimiter + [PATIENT PUBLIC KEY] + delimiter + access_list + delimiter + index
BLOCKCHAIN_PUBLICK_KEY||||FOO||||acess_list|||0
BLOCKCHAIN_PUBLICK_KEY||||FOO||||acess_list|||1
BLOCKCHAIN_PUBLICK_KEY||||FOO||||acess_list|||2
BLOCKCHAIN_PUBLICK_KEY||||FOO||||acess_list|||3
BLOCKCHAIN_PUBLICK_KEY||||FOO||||acess_list|||4

By keeping old states, we have access to historical data of the changed states.

Blockchain

We use Truffle suit for the sake of the local Ethereum network.
The network will be available at 127.0.0.1:9545
Blockchain will take the responsibility of deploying the smart contract on the network and migrating it.

SmartContract

The solidity smart contract is the actual core of the functionality we do on the blockchain network.
The smart contract can be found at blockchain/contracts/SimpleStorage.sol
It has 5 methods on it:

  1. setData(string memory key, string memory encryptedString)
  2. getData(string memory key)
  3. increaseAccessListState(string memory key)
  4. getAccessListState(string memory key)
  5. addNewThirdparty(string memory newAccessKey, string memory oldAccessKey, string memory newPublicKey)

Also, it has 2 global variables:

  1. mapping(string => string[][]) public dataMap;
  2. mapping(string => int) public accessListStateMap;

HL7Convertor

This is a backend service written in Rust using the Axum framework. The main responsibility of the hl7convertor is to transform an XML with format A to an XML with format B.
It does its job using XSLT (Extensible Stylesheet Language Transformations) to convert two XMLs back and forth.
Wikipedia

Example

Given the following XML:

<Employee\>  
  <firstName\>John\</firstName\>  
  <lastName\>Doe\</lastName\>  
</Employee\>

When XLST is:

<xsl:stylesheet version=\\"1.0\\" xmlns:xsl=\\"[http://www.w3.org/1999/XSL/Transform\\](http://www.w3.org/1999/XSL/Transform\\)"\>  
  <xsl:template match=\\"/\\"\>  
    <Person\>  
      <fullName\>\<xsl:value-of select=\\"concat(//firstName, ' ', //lastName)\\"/\>\</fullName\>  
    </Person\>  
  </xsl:template\>  
</xsl:stylesheet\>

Then we have:

<Person\>  
  <fullName\>John Doe\</fullName\>  
</Person\>

**You can use the above input to test to hl7convertor functionality

Docker (Deployment)

Docker and DockerCompose are used together to make the deployment of this stack smooth. Here I define each app and its listened ports:

Process Port
Backend 8002
Etheruem 9545
HL7Convertor 2000

When deploying using docker-compose up, after installing are requirements a bash file will be fired to run each service. It’s called entrypoint.sh

Build Project

Install Just
Run just up

**For further info run just help

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published