Medications
MedicationAdministration Tracking
Recording when medications are actually administered
Set up the SDK server client to run the examples using esus. The REST examples use a session token. To run them with the SDK’s API key, send X-API-Key instead of Authorization.
Purpose of MedicationAdministration
MedicationAdministration documents that a medication was administered to a patient. This is crucial for:
- Hospital medication tracking
- Verifying order compliance
- Clinical documentation
Creating an Administration Record
curl -X POST https://api.esus.health/fhir/MedicationAdministration \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/fhir+json" \
-d '{
"status": "completed",
"medicationCodeableConcept": {
"coding": [{
"system": "http://www.nlm.nih.gov/research/umls/rxnorm",
"code": "308182",
"display": "Ibuprofen 400mg"
}]
},
"subjectId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"requestId": "c1a2e3d4-5b6f-7890-abcd-ef1234567890",
"effectiveDateTime": "2026-04-21T14:30:00Z",
"performer": [{
"actor": {
"reference": "Practitioner/a7b1c2d3-e4f5-6789-abcd-ef0123456789"
}
}],
"dosage": {
"text": "400mg by mouth once",
"dose": { "value": 400, "unit": "mg" }
}
}'
const created = await esus.fhir.create("MedicationAdministration", {
"status": "completed",
"medicationCodeableConcept": {
"coding": [
{
"system": "http://www.nlm.nih.gov/research/umls/rxnorm",
"code": "308182",
"display": "Ibuprofen 400mg"
}
]
},
"subjectId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"requestId": "c1a2e3d4-5b6f-7890-abcd-ef1234567890",
"effectiveDateTime": "2026-04-21T14:30:00Z",
"performer": [
{
"actor": {
"reference": "Practitioner/a7b1c2d3-e4f5-6789-abcd-ef0123456789"
}
}
],
"dosage": {
"text": "400mg by mouth once",
"dose": {
"value": 400,
"unit": "mg"
}
}
});
Notes:
subjectId(required) is the patient UUID;statusdefaults tocompleted.requestIdlinks the administration to the originating MedicationRequest (UUID); it comes back asrequest: { "reference": "MedicationRequest/<uuid>" }and is what therequestsearch parameter matches.- The medication goes in
medicationCodeableConceptormedicationReferenceand comes back in the same field it was sent in. Themedicationsearch matches either one. - Also accepted:
encounterId,identifier[],reasonCode[],note[]. Other MedicationAdministration fields (partOf,statusReason,category,supportingInformation,effectivePeriod,reasonReference,device,eventHistory) are not part of the contract and are not stored. performer[]uses the standard FHIR shape:{ "actor": { "reference": "Type/<uuid>" } }.- In FHIR R4,
dosagehere is a single object (not an array) and the amount goes indosage.dose. MedicationAdministrationhas nointentfield — it records an event, not an order.
Status Values
| Status | Meaning |
|---|---|
in-progress | Administration is under way |
completed | Administered (default) |
not-done | Not administered |
on-hold | Paused |
stopped | Stopped before completion |
entered-in-error | Recorded in error |
unknown | Status unknown |
Any other value (for example cancelled) is rejected with 422. When a dose was not given (patient refused, medication unavailable), record it as not-done and explain why in note[].
Searching Administrations
Find all administrations for a patient on a given date:
curl "https://api.esus.health/fhir/MedicationAdministration?patient=3fa85f64-5717-4562-b3fc-2c963f66afa6&effective-time=2026-04-21" \
-H "Authorization: Bearer YOUR_TOKEN"
const { resources, total } = await esus.fhir.search("MedicationAdministration", {
"patient": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"effective-time": "2026-04-21"
});
| Parameter | Matching |
|---|---|
patient, encounter | Exact id |
status | Exact code |
effective-time | Date (YYYY-MM-DD); without a prefix it matches the whole day. Supports gt, ge, lt, le and ne. Repeat it for a range (effective-time=ge2026-04-01&effective-time=lt2026-05-01) |
medication | Partial text match on medicationCodeableConcept or medicationReference (code or display) |
request | Partial match on the MedicationRequest reference (<uuid> or MedicationRequest/<uuid>) |