Open EMR FHIR API Integration from Non FHIR system

Hi I would like to seek your guidance on how to integrate the Open EMR to a Non FHIR system on where to start on this, and whats need to be done.

Our process is all Patient Information/Record is stored/save in the Open EMR system, then this will be integrated to a Non FHIR system, where this system will call to the Open EMR using PID and return/display back to the Non FHIR system with the corresponding Patient Information and Prescription for that specific PID.

Thanks
Casper

If I follow correctly then it is just a matter of calling the correct openemr API endpoints to fetch patient data and prescriptions by PID from your outside non-fhir requesting application.
You can test for the correct endpoints to use using openemr/swagger.

Hi @sjpadgett do i need to create a custom integration layer that translates the data from a REST API into FHIR format before sending it to Open EMR system? Or it a REST API will do.?

Check out these resources. You’ll need to create an app to login to openemrs authorization server then send your FHIR endpoints.

Swagger that allows testing endpoints:
Swagger UI

Here is a sample app I developed to help folks get started with API. This app will register both a public and private client for FHIR scopes. Hopefully it will give you an implementation start.
client_register.zip (2.1 KB)

1 Like

Thank you @sjpadgett i will check on this sample and resources.

Hi @sjpadgett i already try the sample app and i get a response “:white_check_mark: Clients Registered Successfully!”.

Also i check the API Client page and i see 2 client registration (public and confidential).

How could i connect the 3rd party application to open emr? This 3rd party application will search using pubpid then display the patient information including the prescription data, this 3rd party application can also update those information and save this in the open emr.

Thank you
Casper

Hi @sjpadgett i already manage to connect the API to the Application we created using Private Application → Multipurpose Application, I also manage to pull patient information using user/Patient.read scope and Prescription using user/MedicationRequest.read. I would like ask what scope do we need to used to update the Prescription in the 3rd party application we created. I already try the user/MedicationRequest.write, but this is not available in the SMART App Registration Form. I also try to add this in the sample app you created to register the API, but i get this error
“Client registration failed with HTTP Code: 400. Response: {“error”:“invalid_scope”,“error_description”:“The requested scope is invalid, unknown, or malformed”,“hint”:“Check the user\/MedicationRequest.write scope”,“message”:“The requested scope is invalid, unknown, or malformed”}”

I also check the ScopeRepository.php the user/MedicationRequest.write is on permitted scope.

Thanks
Casper

Try retyping the scope otherwise I don’t know.

I’ve been developing an API Explorer client to donate to community to help folks get started with API. I may give to you if you want to try it out.
It supports public and confidential clients and auto builds the resource endpoints based on the client scopes.
For write ops user will need to modify app. The explorer is a useful tool to learn grant flow and general oAuth2.
App can auto create three clients JWT, private and public. Every register run deletes previous client the creates and enables new clients.
The Client Credential grant doesn’t work out of the box because you will need to control your JWT but the pieces are there.

Hi @sjpadgett Yes :slight_smile: Can i try your API Explorer :-)., It would be a great help

"Try retyping the scope otherwise I don’t know., "
This is what i have for the user/MedicationRequest.read,
image

When i try to register the API i get this error :

user/MedicationRequest.read is Ok, But the user/MedicationRequest.write is not accepted.

I try to check the API documentation openemr/API_README.md at rel-701 · openemr/openemr · GitHub user/MedicationRequest.write is not included but the the ScopeRepository user/MedicationRequest.write is included in the permitted scope.

Thank you in advance :slight_smile:
Casper

I’ll try the scope in my client.

I won’t support this but the app has my good intensions. unzip in openemr root and will reside in modules/oe-module-api-explorer/oeApiExplorer.php and there is a readme in directory.

oeApiExplorer.zip (11.2 KB)

MedicationRequest write isn’t in swagger so it doesn’t appear write is supported. If I get time I’ll look at code and I know the scope in uncommented but I haven’t heard anyone develop the post endpoint.

Hi @sjpadgett Thank you very much the API Explorer, it is similar to the previous app you share (client register), But much more informative since it provide each api response in each scope.

Hope you could look on the MedicationRequest.write, or could point me on other way to update/write on the patient prescription.

Many Thanks
Casper

The only thing you have access to is the /api/patient/{pid}/medication endpoint which allows you to add a medication to the patient’s current medication list. The scope would be medication.write.

This isn’t really a full prescription (which is stored in the prescriptions) table, but it may accomplish your needs if you just need to store the medication the patient has been prescribed.

Otherwise, that endpoint would need to be written / created. I’m scoping out the work for building out the FHIR write api which would include the MedicationRequest.write capability, if you’re interesting in collaborating / helping to fund that initiative let me know.

Hi @adunsulag, Yes : -) It is a privilege to assist, as our objective is to utilize the MedicationRequest.write scope to retrieve and modify patient prescriptions via the third-party application.

Hi @adunsulag, I already created the FHIR write API for the MedicationRequest, can you guide me on how can i add this to Open EMR?.

Thanks
Casper

How did you create the api? You added it to the _rest_routes? Or you’re doing it as a custom module?

Yes, i added it in the_rest_routes.inc.php., there are also other files that i change that is related to MedicationRequest., Would you recommend doing this as a custom module?

If you do it as a custom module you can use it without having to modify core files.

Unless you’ve handled the unverified data situation (having a holding area for unverified data that can then be accepted/rejected into the clinical record) we can’t take FHIR write endpoints into core yet until that piece has been architected and built.