Create new endpoints in rest with OpenEHR

Good morning to all,

I am a new user in OpenEHR and in EHRBase. I would really appreciate your help and I’m sure you can help me.
Nice to meet you all.

I apologize if I ask any basic or stupid questions.
I have done the following first step: Run EHRbase + DB with Docker-Compose

Afterwards, I have configured the following SDK project:

I have the 2 previous projects running and now I would like to do a very basic test. I want to do the following.
I would like to create 3 or 4 different endpoints:
1- EndPoint to save a patient in my Database
2- EndPoint to update an existing patient in my Database
3- EndPoint to get all existing patients in my database
4- Endpoint to delete a patient in my database.

This is a very simple example but I want to see how all these technologies work together.

Please can you help me with this simple example?

I will greatly appreciate all your help.

Many thanks.

Kind regards,
Rafael Gomez

Hi Rafael,

welcome to the forum! Just to make sure I understand your request: are you referring to the creation of an EHR object for a patient? In openEHR, we are not working directly with an equivalent to the FHIR Patient Resource but create an EHR object as the “bucket”/root object to put compositions (clinical entries) into.

Given this understanding:

Have you seen this part of the documentation? EHR Endpoint — EHRbase documentation

This covers (1) and (2)

To get all patients (3), you can use the AQL endpoints AQL Endpoint — EHRbase documentation and do a query like “SELECT e/ehr_status FROM EHR e” to get all EHR objects.

For some reason I cannot remember (maybe @thomas.beale, @sebastian.iancu oder @Seref can help, my guess it is for medico-legal reasons), there is no REST endpoint to “soft” delete an EHR. However, EHRbase provides a physical deletion of EHRs in test systems. However, this is not yet encapsulated in the SDK. 3.7.2. /admin/ehr — EHRbase documentation

That sounds likely @birger.haarbrandt .

@rafotis2 to slightly reword Birger’s helpful response: openEHR separates subject of an EHR (a patient in this case) from the EHR itself, so it is anonymized by design. There’s a pointer from the EHR, in the form of some identifier (decided by the users of platform/EhrBase; national health identifier etc) back to some sort of demographics server or master patient index.

So you’re supposed to create EHRs with some identifier associated to them, and it is your job to match say the name of a patient to this identifier so that you can get their EHR, and then use the EHR to access clinical data for that patient.
See the examples in these two API endpoints please:

Well there is a way to make an EHR non-modifiable and non-queryable (EHR_STATUS), which is close to the same thing. We possibly should add other flags in there, e.g. ‘is_deceased’ and ‘is_active’.

1 Like

I think this can be done by means of using access control to an ehr and setting the set of allowed parties to either an empty set or only to an audit role etc. Something in those lines :slight_smile:

It does as long as EHR_STATUS.subjectdoesn’t have PARTY_SELF.external_ref set, which it can have. The safe way is not to set this, and to use the EHR.ehr_id as the reliable EHR identifier, and to x-reference that to subject ids in another service (e.g. this one).

Exactly right.

I was thinking more the current REST call to update EHR_STATUS.is_modifiable and is_queryable.

1 Like

Not disputing this, but our REST API’s design and examples for EHR endpoint do not imply this. So something to bring to table for SEC then? It’s a pretty fundamental use case for the API, pretty much the entry point of every interaction with the EHR :slight_smile:

Yes, correct. We should do something about this soon. To date, it is implemented in a vendor-specific way by some vendors.

Hi all,

Thanks for your comments.

I have configured the following project with Docker Compose and PostgreSQL:

Please, can you send me an example project? explained step by step, where I have different AQL endpoints to obtain patients.
I would like to define different EHR objects like Patients, Doctors, etc.
I want to see a small demo and make it easy to configure. All with rest endpoints and that are stored in the database with Docker.
I am very interested in using your technologies.

Please, I hope you can help me.

Many thanks for your help.

Kind Regards,
Rafael Gomez

I’m not aware of such an example project I could share with you, so at least I cannot send you what you’re asking for. It’d be good to have a tutorial of sorts though.

Have you checked the documentation for the openEHR SDK you configured? Birger also gave some links. It has lots of useful snippets, and as it says, there are many examples you can look at in the tests on github:

I’d suggest you try implementing the most basic functionality following the above documentation and using existing tests in the source code as a guide. Create an Ehr, commit a composition etc. You can ask questions re specific tasks and we’d help you as much as we can.

Hi all,
Ok, I’ll try it now.

But I think it would be a good idea for you to make a video tutorial explaining an example project and how to run it step by step.
I think this would help a lot of beginners and novice users.

Many thanks.

Kind regards,
Rafael Gómez

1 Like

Hello all,

Hope you are well today.

I have read the documentation but I still have some doubts and questions.
How can I create Patient entities and Doctor entities to save in my PostgreSQL Database?
I have seen that I can only create an Ehr, compositions and templates.

Look forward your comments.

Many thanks for your help.

Kind Regards.

As I wrote before:

To put it in another way: EhrBase (your openEHR backend in this case) has no support to create patient, doctor etc entities. It is assumed that these exists somewhere else, and they have some unique identifiers. EhrBase allows you to create EHRs, then associate those with these identifiers.

If you’re planning to use EhrBase (and openEHR for that matter) to represent patients, doctors, hospitals etc, you cannot do that with EhrBase.

openEHR as a specification has a demographic model, which would help you to represent the concepts you listed in an openEHR way but few implementations support it, and EhrBase does not. For good reason as well, because these concepts are almost always in place and implemented by some other system.

It sound like your current goal is not focused on clinical data, but on demographic data. EhrBase won’t help you there. Do you know what kind of clinical data your application needs to process? Allergies? Medications? etc.

1 Like

Short answer: you can’t

openEHR defines a clinical repository component, which, by good medico-legal practices, shouldn’t store personal information (demographic).

The demographic data should go on other components. Patients are stored in master patient index (MPI), and clinicians, in general, are stored in a human-resource system in the hospital.

Then the clinical repository has references to the IDs of patients and clinicians stored on those external systems

This is how it works and it’s no way around, just to be clear. It’s an openEHR thing, not an EHRBASE thing.

In order to understand these requirements, you can check the openEHR’s architecture document or consult with an expert in case you have a project.

Hi all,

I hope you are well today.

Ok, understanding that with EHRBase you can’t do what I want to do with patients, doctors and hospitals.
But how the other tools and platforms could do it?
I am referring to the following tools and platforms: EHRServer or EtherCIS.
Is this possible with either of the above two tools and platforms?

Look forward your comments.

Many thanks for your help.

Kind Regards.

Hi Rafa,

you can basically use any technology that is appropriate. For example, you can use a an IHE MPI (PIX/PDQ) for the patients and Active Directory for the provider directory.

If you have a complete greenfield environment, you might also use a demographics service based on FHIR. Then, you can put the (FHIR) IDs inside the openEHR compositions to reference entries in the provider directory.

1 Like

EhrServer is @pablo 's baby I think, so I’ll let him comment. EtherCIS won’t do it either as far as I know. (EhrBase is a fork of EtherCIS btw, though it’s been getting so much love (work) from Vita I’m not sure if much is left in common between them)

You can always use something like i.e. use FHIR demographic to implement demographic and wire that into EhrBase.
Check out FhirBridge component of EhrBase project if you want to see it in action.

You beat me to it with a few seconds :smiley:

1 Like

Any system that implements openEHR will have patients, doctors and hospitals in a separate system.

Your requirements require you to get a platform together, not just one system that complies with all your requirements, that is why consulting with an openEHR expert if you have a project is the best option.

It’s not that what you try to do can’t be done, it’s that how you are trying to do it can’t be done. Is how the standard works.

As I said, you should read the architecture overview document first to understand the basic concepts.

About your demographic requirements, check