EhrIndexer

Provides work with EHR documents and groups of documents.

Functions

setEhrUser

function setEhrUser(
    bytes32 userIDHash,
    bytes32 ehrId,
    address signer,
    uint deadline,
    bytes calldata signature
) external onlyAllowed(msg.sender)

Sets the association between userID and ehrID.

Parameters

NameTypeDescription

userIDHash

bytes32

Hash of userID

ehrId

bytes32

EhrID

signer

address

Address of the signer of the request

deadline

uint

Expiration timestamp of the request

signature

bytes

Cryptographic signature of the request performed by the signer's key

getEhrUser

function getEhrUser(
    bytes32 userIDHash
) public view returns(bytes32)

Getting ehrID for userID

Parameters

NameTypeDescription

userIDHash

bytes32

Hash of userID

Return Values:

NameTypeDescription

ehrId

bytes32

EhrID

setEhrSubject

function setEhrSubject(
    bytes32 subjectKey,
    bytes32 ehrId,
    address signer,
    uint deadline,
    bytes calldata signature
) external onlyAllowed(msg.sender)

Sets the association between ehrID and subject.

Parameters

NameTypeDescription

subjectKey

bytes32

sha3(subjectID + subjectNamespace)

ehrId

bytes32

EhrID

signer

address

Address of the signer of the request

deadline

uint

Expiration timestamp of the request

signature

bytes

Cryptographic signature of the request performed by the signer's key

addEhrDoc

function addEhrDoc(IDocs.AddEhrDocParams calldata p)
    external onlyAllowed(msg.sender)

Adding a new EHR document

Parameters

NameTypeDescription

p

getEhrDocs

function getEhrDocs(
    bytes32 userIDHash, 
    IDocs.Type docType
) public view returns(IDocs.DocumentMeta[] memory)

Text

Parameters

NameTypeDescription

userIDHash

bytes32

Hash of userID

docType

Document type

Return Values:

NameTypeDescription

docs

List of documents of the specified type for the given userIDHash

getLastEhrDocByType

function getLastEhrDocByType(
    bytes32 ehrId,
    IDocs.Type docType
) public view returns(IDocs.DocumentMeta memory)

Retrieve the last document of the specified type.

Parameters

NameTypeDescription

ehrId

bytes

EhrID

docType

Document type

Return Values:

NameTypeDescription

doc

getDocByVersion

function getDocByVersion(
    bytes32 ehrId,
    IDocs.Type docType,
    bytes32 docBaseUIDHash,
    bytes32 version
) public view returns (IDocs.DocumentMeta memory)

Retrieve the specified version of the document

Parameters

NameTypeDescription

ehrId

bytes32

EhrID

docType

Document type

docBaseUIDHash

bytes32

Hash of document UID

version

bytes32

Document version

Return Values:

NameTypeDescription

doc

getDocByTime

function getDocByTime(
    bytes32 ehrID, 
    IDocs.Type docType, 
    uint32 timestamp
) public view returns (IDocs.DocumentMeta memory)

Retrieving a document that is up to date at the specified time

Parameters

NameTypeDescription

ehrID

bytes32

EhrID

docType

Document type

Return Values:

NameTypeDescription

doc

getDocLastByBaseID

function getDocLastByBaseID(
    bytes32    userIDHash,
    IDocs.Type docType,
    bytes32    UIDHash
) public view returns (IDocs.DocumentMeta memory)

Retrieving the latest version of the document specified by id

Parameters

NameTypeDescription

userIDHash

bytes32

Hash of userID

docType

Document type

Return Values:

NameTypeDescription

doc

deleteDoc

function deleteDoc(
    bytes32    ehrId,
    IDocs.Type docType,
    bytes32    docBaseUIDHash,
    bytes32    version,
    address    signer,
    uint deadline,
    bytes calldata  signature
) external onlyAllowed(msg.sender)

Deleting a document. The actual status of the document changes to Deleted.

Parameters

NameTypeDescription

ehrId

bytes32

EhrId

docType

Document type

docBaseUIDHash

bytes32

Hash of document UID

version

bytes32

Document version

signer

address

Address of the signer of the request

deadline

uint

Expiration timestamp of the request

signature

bytes

Cryptographic signature of the request performed by the signer's key

setAccess

function setAccess(
    bytes32 accessID,
    IAccessStore.Access memory a,
    address signer,
    uint deadline,
    bytes calldata signature
) external

Sets the access level to the object

Parameters

NameTypeDescription

accessID

bytes32

a

signer

address

Address of the signer of the request

deadline

uint

Expiration timestamp of the request

signature

bytes

Cryptographic signature of the request performed by the signer's key

docGroupCreate

function docGroupCreate(DocGroupCreateParams calldata p) external

Creating a document group

Parameters

NameTypeDescription

p

docGroupAddDoc

function docGroupAddDoc(
    bytes32 groupIDHash,
    bytes32 docCIDHash,
    bytes calldata docCIDEncr,
    address signer,
    uint deadline,
    bytes calldata signature
) external

Adding a document to a group of documents

Parameters

NameTypeDescription

groupIDHash

bytes32

Hash of groupID

docCIDHash

bytes32

docCIDEncr

bytes

Document CID encrypted by group key

signer

address

Address of the signer of the request

deadline

uint

Expiration timestamp of the request

signature

bytes

Cryptographic signature of the request performed by the signer's key

docGroupGetDocs

function docGroupGetDocs(bytes32 groupIdHash) external view returns (bytes[] memory)

Getting the list of documents included in the group

Parameters

NameTypeDescription

groupIDHash

bytes32

Return Values:

NameTypeDescription

docCIDEncrs

bytes[]

Array of CIDs of documents encrypted with the document group key

docGroupGetAttrs

function docGroupGetAttrs(
    bytes32 groupIdHash
) external view returns (Attribute[] memory)

Getting group attributes

Parameters

NameTypeDescription

groupIDHash

bytes32

Return Values:

NameTypeDescription

attrs

Array of group attributes

Models

Attribute

struct Attribute {
    Code  code;
    bytes value;
}

DocGroupCreateParams

struct DocGroupCreateParams {
    bytes32     groupIDHash;       
    Attributes.Attribute[] attrs;
    address     signer;
    uint        deadline;
    bytes       signature;
}

IDocs.Type

enum Type {
    Ehr,            // 0
    EhrAccess,      // 1
    EhrStatus ,     // 2
    Composition,    // 3
    Query,          // 4
    Template,       // 5
    Directory       // 6
}

IDocs.AddEhrDocParams

struct AddEhrDocParams {
    Type        docType;
    bytes       id;
    bytes       version;
    uint32      timestamp;
    Attributes.Attribute[] attrs;
    address     signer;
    uint        deadline;
    bytes       signature;
}

IDocs.DocumentMeta

struct DocumentMeta {
    Status   status;
    bytes    id;
    bytes    version;
    uint32   timestamp;
    bool     isLast;
    Attributes.Attribute[] attrs; 
}

IAccessStore.AccessLevel

enum AccessLevel { NoAccess, Owner, Admin, Read }

IAccessStore.Access

struct Access {
    AccessKind   kind;
    bytes32      idHash;
    bytes        idEncr;    // id encrypted by access key
    bytes        keyEncr;   // access key encrypted by user private key
    AccessLevel  level;
}

Last updated