Document Index
Index storage
Using a smart contract as a document and data index repository provides high availability, fault tolerance, immutability.
User (patient)
user_id - unique identifier
user key pair - public key + private key, generated according to the Curve25519 elliptic curve-based cryptosystem
EHR (electronic health record)
Is a data structure described in the openEHR standard
ehr_id
includes the documents: EHR_STATUS, COMPOSITION, DIRECTORY, CONTRIBUTION
Each patient can have only one EHR.
EHR index
Sets the relationship between ehr_id from a specified user_id
Document index
mapping (bytes32 => mapping(IDocs.Type => IDocs.DocumentMeta[])) ehrDocs;Sets the relationship betweendoc_storage_id and ehr_id
DocumentMeta: {
Status uint8
Id []byte
Version []byte
Timestamp uint32
IsLast bool
Attrs []AttributesAttribute
}EHRsubject index
Sets the relationship between ehr_id and subject_id, subject_namespace
subjectKey = sha3(subject_id + subject_namespace)
subjectKey -> ehr_iddocAccess index
Allows to find an encrypted doc_key for the specified doc_storage_id and user_id
key = sha3(doc_storage_id+user_id)
value = user_pub_key.Encrypt(doc_key)
key -> valuedataSearch index
Allows to find the doc_storage_id of documents that contain data with the specified values
DataEntry: {
groupId [16]byte // UUID
value []byte // encrypted values
docStorIdEncr []byte // user_pub_key.Encrypt(doc_storage_id)
}
pathKey = sha3(path) // path Example: '/data/events[at0006]/data/items[at0004]/value/magnitude'
pathKey -> DataEntrydataAccess index
access_group - access group, within which encrypted data is searched
key = sha3(user_id+access_group_id)
value = user_pub_key.Encrypt(access_group_key)
key -> valueCreating EHR
An EHR document is created as a json file
Generation of a new
doc_keyThe document is encrypted using the
doc_keyDocument is saved in the document storage,
doc_storage_idis returnedAn entry is added to the EHR Index to link the patient and their EHR:
An entry is added to the Document Index to allow the document in the repository to be linked to the EHR
An entry is added to the EHRsubject Index to search for
ehr_idby its subjectAn entry is added to the AccessStore index to find the encrypted
doc_keyfrom the document
Getting EHR by ehr_id
Get
ehr_idusinguser_idin EHR IndexGet
doc_storage_idof a document with DocType = EHRGet the encrypted
doc_keyfrom the AccessStore indexDecrypt
doc_keywith user'spriv_keyDownload document with
doc_storage_idfrom storageDecrypt the document using the decrypted
doc_keyin step 5
Creating COMPOSITION
The document is created as a json file
The document is encrypted with the unique key
doc_keyThe document is saved in the document storage,
doc_storage_idis returnedAn entry is added to the document index, allowing you to link the document in the repository with the EHR
Path construction for all field values within the document
Determining the
access_groupfor searching the values in the dataSearch indexRecords containing paths, values encrypted with
access_group_keyandencrypted doc_storage_idto associate records with documents in the repository andaccess_group_idare added to the dataSearch Index for all values
Search for documents using queries
Paths to the values of interest and conditions are generated from the query
Search for records in dataSearch index, which satisfy the specified conditions, the encrypted
doc_storage_idof documents containing these values is returned, or the encrypted valuesSearch for an
access_group_keyin the dataAccess indexDecrypting
access_group_keywithuser_priv_keyDecrypting field values with
access_group_keyDecrypting
doc_storage_idwithuser_priv_keySearch for
doc_keysencrypted documents in the docAccess index bydoc_storage_idDecrypting
doc_keysDownloading found documents from the storage
Documents are decrypted using
doc_keys
Last updated