Medplum CRUD Operations with REST APIs: A Lazy Person’s Guide
Quick guide to effortlessly perform Medplum CRUD operations using REST APIs, including implementing FHIR for healthcare data exchange. Here I'll be talking about implementing CRUD (Create , Read ,
Quick guide to effortlessly perform Medplum CRUD operations using REST APIs, including implementing FHIR for healthcare data exchange.
Here I'll be talking about implementing CRUD (Create, Read, Update,Delete) operations on medplum server after successfully implementing it
Here, I've hosted my backend in my server, so I'll be explaining to you how I'm doing the CRUD operation on that hosted server, if you want to install Medplum on your local setup, please go through the Medplum documentation
To start with, first, we need to Register an account on Medplum.if you're using the application locally you can register it in localhost or go forward with the Medplum site.
You can use these credentials which are offered by Medplum itself
The default username is admin at example.com default password medplum_admin.
After that, create a project in Medplum, and create a Client Application, you can create a client application by going to the /admin/clients route your app.(if you're using localhost the route will look something like http://localhost:3000/admin/client)
If you want to check whether your backend is working, you can go to the route "yourbackendurl/healthcheck"(if your backend URL is api.medplum.com, go to api.medplum.com/healthcheck)
CRUD Operations
Create: POST
To create a new patient using the FHIR standards
http://localhost:8000/patient or your_hosted_backend_link/patient
Content-Type: application/fhir+json
Authorisation: Beared ACCESS_TOKEN
{
"resourceType": "Patient",
"identifier": [ { "system": "urn:oid:1.2.36.146.595.217.0.1", "value": "12345" } ],
"name": [ {
"family": "Miller",
"given": [ "John", "Doe" ]
} ],
"gender": "male",
"birthDate": "1964-12-15"
}
You can refer to this link to know how to get the ACCESS_TOKEN for the REST APIs
Read : GET
To read all the patients
http://localhost:8000/Patient
To read a single patient
http://localhost:8000/Patient/123
Update: UPDATE
To update a patient whose id is 123
http://localhost:8000/Patient/123
{
"resourceType": "Patient",
"id": "123",
"identifier": [ { "system": "urn:oid:1.2.36.146.595.217.0.1", "value": "12345" } ],
"name": [ {
"family": "Miller",
"given": [ "John", "Doe" ]
} ],
"gender": "male",
"birthDate": "1964-12-15"
"address": [ {
"line": [ "Address line" ],
"city": "any city",
"state": "Random state",
"postalCode": "5000"
} ]
}
Delete: DELETE
To Delete a patient with ID 123
http://localhost:8000/Patient/123
That's it! With these simple examples, you can perform CRUD operations in Medplum using REST APIs. Lazy, but effective!
Remember, this guide is a quick reference. For detailed information, consult the official documentation. Happy coding!
No comments yet. Login to start a new discussion Start a new discussion