###### Abstract  
Electronic health records (EHRs) play an important role in our life. However, most of the time, they are scattered and saved on different databases belonging to distinct institutions (hospitals, laboratories, clinics, etc.) geographically distributed across one or many countries. Due to this decentralization and the heterogeneity of the different involved systems, medical staff are facing difficulties in correctly collaborating by sharing, protecting, and tracking their patient's electronic health-record history to provide them with the best care. Additionally, patients have no control over their private EHRs. Blockchain has many promising future uses for the healthcare domain because it provides a better solution for sharing data while preserving the integrity, the interoperability, the availability of the classical client-server architectures used to manage EHRS. This paper proposes a framework called HealthBlock for collaboratively sharing EHRs and their privacy preservation. Different technologies have been combined to achieve this goal. The InterPlanetary File System (IPFS) technology stores and shares patients' EHRs in distributed off-chain storage and ensures the record's immutability; Hyperledger Indy gives patients full control over their EHRs, and Hyperledger Fabric stores the patient-access control policy and delegations.  
electronic health records (EHRs); blockchain; Hyperledger Fabric; Hyperledger Indy; smart contracts; InterPlanetary File System (IPFS) +
Footnote †: journal:  
files across multiple nodes to avoid a single point of failure or the need of trusted nodes. Hyperledger and blockchain use peer-to-peer networks, consensus algorithms, smart contracts, signature, hash functions, ZKP protocols, etc., to achieve interesting properties, such as availability, integrity, transparency, traceability and automation. Using smart contracts for instance, we can automatically trigger, under certain conditions, some processing without the intervention of any trusted authority. The contract is executed, even if the expected results are against the will of the stakeholders.  
These new emerging technologies, including blockchain, provide a better solution for patients' record protection, accessibility, delegation, anonymity and other useful features.  
The main goal of this paper is to address the problems of the existing EHR management systems by providing a solution with interesting features, such as the following:  
* The EHRs are appropriately protected (Integrity + Confidentiality) and available anytime from any country.
* The patients have full control of their EHRs, and they can temporarily delegate access to any person or organization at any time.
* The patients can obtain anonymous healthcare services, when needed, to better protect their privacy.
* The patients' attributes can be proved remotely, making telemedicine more efficient.
* The solution takes into consideration that in an emergency, the patients may not have their full capacity to grant access to their EHRs.  
Different technology, including Hyperledger Fabric, Hyperledger Indy, and the IPFS database, are combined to access these goals.  
The remaining part of this paper is organized as follows. Section 2 presents the related work. Section 3 recalls some preliminary notions useful to understand the proposed architecture. Section 4 gives the proposed framework architecture for sharing EHRs. Section 5 provides a prototype as a proof of concept. Section 6 discusses the proposed approach, and Section 7 provides some concluding remarks.