Using Daml to simplify electronic health records (EHR) management

Today, patient data is scattered across a variety of electronic health record (electronic health records) software systems. HIPAA consents are not trackable, and it takes significant time and energy to transfer patient records between doctors if they don’t use the same electronic health records system. Traditional healthcare technology is not suitable to effectively achieve the goals of access and interoperability of healthcare data, while maintaining privacy. The complexity of the industry, a myriad of regulations, and the sheer number of healthcare players involved makes it difficult. So we end up with error-prone and data duplication-intensive processes that require constant reconciliation. 

The promise of interoperability is now becoming a reality with enterprise blockchains in healthcare and Daml smart contracts. These emerging technologies allow:

  1. Providers and intermediaries to take advantage of enterprise-grade security and privacy 
  2. Flexibility of technology choice from enterprise databases and enterprise blockchains 
  3. A private yet “golden source” of data, without need to worry about data domicile issues 
  4. A simpler pathway to interoperability of electronic health records software systems

In this post, we’ll look at how blockchain and smart contracts technology can be used in healthcare, with the help of a practical use case and easy-to-understand smart contract code.

Use case overview

In our example, we’ll consider a real-life network of healthcare provider clinics. We’ll then build out a scenario in which a patient switches clinics. We’ll show how the patient’s electronic health records are automatically made accessible to the destination clinic, and the patient’s request to transfer is visible to both clinics while being invisible to every other clinic on the same blockchain network. We will also show how the first clinic is not able to access the records anymore once the transfer is complete unless a consent has been signed. Finally, we’ll demonstrate how end-to-end tracking can be achieved easily and without data duplication.

Thus, we will solve multiple problems at once:

  • Lower operational overhead by providers to transfer and track health records
  • Improved patient experiences and confidence
  • Compliance with HIPAA
  • electronic health records providers can tap into this underlying connectivity layer
  • Data domicile requirements are maintained
  • No data reconciliation is needed

Crucially, we will see that the use of blockchain technology in healthcare does not necessarily mean giving up privacy. The transactions do not have to be visible to everyone on the blockchain network. The open source Daml smart contract language is a major enabler of this granular privacy feature. The process flow and business rules outlined in this blog are of course configurable as needed.

Let’s start by modeling our electronic health records as a digital asset. This modeling concept by itself is a fundamental shift in how we treat our information. Information is no longer just rows in a database; similar to object-oriented programming, information is now a digital asset on which actions can be taken, and which can be made accessible to different parties depending on the business rules.

You will notice the use of the observer keyword. This implies that the patient automatically has access to this record, and this record only. Thus, using Daml smart contracts, you can easily control privacy and disclosure nightmares. Contrary to the commonly held notion that data on the blockchain is visible to everyone, Daml and certain Daml ledgers ensure privacy of data.

Since the electronic health record is now a digital asset, we can take actions on it. For example, the provider can add to the details of this record after a patient visit. We do that below by adding that capability to the template for PatientRecord above. This action simply creates a new smart contract and archives the old one, implying that we need not worry anymore about data inconsistencies due to incorrect database updates. It also means that once the new PatientRecord contract is created, the old one is no longer accessible for use.

In our example, you can see that the details are stored in a list. See more about Daml lists here in this video series by Steve Seow. Of course, this is a very simple data type used for illustrative purposes. In the real world, we’ll obviously create much more flexible data structures to suit the complexity that electronic health records software systems have to deal with.

Transferring electronic health records

Now, let's talk about the core of our use case: Transferring the record to another healthcare provider. Having the patient record as a digital asset with rights and obligations allows us to define a transfer action on the asset. This transfer asset creates a transfer request, which will be accepted by the new healthcare provider.

In this transfer, Daml ensures that the electronic health records are transferred to the new provider only upon consent. The AcceptTransfer function takes care of enforcing the consent without which the new provider is not set as the controller of the electronic health record. We also ensure that the old provider no longer has access to update the record.

Note that the patient has been made an observer, which means that they can see and track the transfer proposal. This itself is a huge challenge today.   


Patients will have access to not only the transfer request, but also to their patient electronic health records when they are transferred to the new provider.

Do providers have to be on the blockchain?

You may be wondering whether the healthcare providers in our example need to be on the same blockchain network. Indeed, that’s one of the biggest challenges in setting up any such network because the complexity is high.

That’s exactly where the crucial aspect of Daml interoperability comes in. The providers need not be on the same blockchain network. In fact, neither even need be on the blockchain itself at all. 

That’s possible because Daml runs on the Canton distributed ledger protocol. Canton in turn allows full privacy and consistency between the various providers who are participants on this network. This unique capability allows each participant to use an application of their choice (which could transparently run on a traditional database or a blockchain). 

As a result, by using Daml and Canton, healthcare providers don’t even need to be aware of the blockchain layer because their data is automatically kept in sync, while full data privacy and segregation is also maintained. So, all of the reconciliation and data transfer complexity is pushed under the hood to the Daml runtime. In our example, some providers may be running a system local to their clinics, while others may be on completely different electronic health records systems. All applications will now be able to connect to such a Daml network without significant software or infrastructure upgrades. 

Furthermore, this opens up potential for healthcare innovation, paving the way for applications that allow for these modern data management and analytics practices from the ground up. Existing electronic health records platforms, which already serve many different hospital systems, can now extend their networks without having to physically onboard providers. Interoperability and privacy of data, along with a seamless experience, are strong competitive advantages as well. 


In this example, we saw how Daml smart contracts and enterprise blockchain can help solve some of the thorniest challenges in healthcare. This is a step up from using traditional integration technology that relies on constant data reconciliations and audit challenges between electronic health records software systems. Check out this excellent webinar from Digital Asset and Change Healthcare on how they are using Daml to solve claims processing and payments in healthcare.

Pairing Daml with API-first software architecture and emerging innovations in enterprise blockchain and smart contracts offers an effective solution to healthcare technology challenges.

This is a tremendous boost in operational cost savings and compliance levels for healthcare providers, and a big increase in customer experience, privacy and convenience. Read more about how Daml creates an open network for business here.