Set up uniqueness in Resource
Last updated
Was this helpful?
Last updated
Was this helpful?
Suppose we want to store the Patient resource only if a patient with such an email does not already exist in the database. Hence, we need to make Patient.telecom.value
unique where Patient.telecom.system = 'email'
.
To solve the problem, we can use PostgreSQL .
In this example PostgreSQL function will check the first email in Patient.telecom array. This works if the Patient resource can have only one email.
If it can have two or more emails, the only solution we see is to create a new patient_email
table, store emails into it via when inserting/updating in patient
table and make Unique index for patient_email
as in the example above.