Patients
Patients are the core entity in MediLoop. Each patient is assigned a unique Uganda Health Identifier (UHID) that follows the national standard format. Patient data is stored in the national FHIR server as the single source of truth.
Endpoints
/api/v1/uhid/register/Register a new patient/api/v1/uhid/{uhid}/Retrieve a patient by UHID/api/v1/uhid/List patients/api/v1/uhid/search/Search patients/api/v1/uhid/{uhid}/Update a patient/api/v1/uhid/{uhid}/validate/Validate patient UHIDThe Patient Object
Attributes
uhidstringUganda Health Identifier. Auto-generated on registration.
ninstringnullableNational Identification Number (for Ugandan citizens).
passport_numberstringnullablePassport number (for foreigners).
first_namestringPatient's first name.
middle_namestringnullablePatient's middle name.
last_namestringPatient's last name.
date_of_birthstringDate of birth (YYYY-MM-DD).
genderstringPatient's gender: M (Male) or F (Female).
phone_numberstringnullablePhone number in E.164 format (+256...).
emailstringnullableEmail address.
districtstringnullableDistrict of residence.
physical_addressstringnullablePhysical address.
countrystringCountry code (default: UG).
nationalitystringnullableNationality.
emergency_contact_namestringnullableEmergency contact name.
emergency_contact_phonestringnullableEmergency contact phone.
fhir_patient_idstringReference to the FHIR Patient resource.
is_activebooleanWhether the patient record is active.
created_atstringTimestamp when the patient was created.
updated_atstringTimestamp when the patient was last updated.
{
"uhid": "UG123456789A",
"nin": "CM12345678ABCDE",
"first_name": "John",
"middle_name": "Mukasa",
"last_name": "Doe",
"date_of_birth": "1990-05-15",
"gender": "M",
"phone_number": "+256700123456",
"email": "john.doe@example.com",
"district": "Kampala",
"physical_address": "Plot 123, Kampala Road",
"country": "UG",
"nationality": "Ugandan",
"emergency_contact_name": "Jane Doe",
"emergency_contact_phone": "+256700654321",
"fhir_patient_id": "fhir-patient-123-456",
"is_active": true,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}Register a Patient
Registers a new patient and auto-generates a UHID. The patient is created in the national FHIR server first (source of truth), then cached locally. Duplicate detection prevents creating multiple records for the same person.
/api/v1/uhid/register/Request Body
first_namestringrequiredPatient's first name
last_namestringrequiredPatient's last name
date_of_birthstringrequiredDate of birth (YYYY-MM-DD)
genderstringrequiredM (Male) or F (Female)
ninstringoptionalNational ID (for Ugandan citizens)
passport_numberstringoptionalPassport number (for foreigners)
phone_numberstringoptionalPhone in E.164 format (+256...)
emailstringoptionalEmail address
districtstringoptionalDistrict of residence
physical_addressstringoptionalPhysical address
emergency_contact_namestringoptionalEmergency contact name
emergency_contact_phonestringoptionalEmergency contact phone
curl -X POST https://api.mediloop.co/api/v1/uhid/register/ \
-H "Authorization: Bearer sk_test_..." \
-H "Content-Type: application/json" \
-d '{
"first_name": "John",
"last_name": "Doe",
"date_of_birth": "1990-05-15",
"gender": "M",
"nin": "CM12345678ABCDE",
"phone_number": "+256700123456",
"district": "Kampala"
}'{
"uhid": "UG123456789A",
"nin": "CM12345678ABCDE",
"first_name": "John",
"last_name": "Doe",
"date_of_birth": "1990-05-15",
"gender": "M",
"phone_number": "+256700123456",
"district": "Kampala",
"fhir_patient_id": "fhir-patient-123-456",
"is_active": true,
"created_at": "2024-01-15T10:30:00Z"
}Duplicate Detection
MediLoop enforces zero-tolerance duplicate prevention. Registration will fail with a 409 Conflict if a patient with matching NIN, passport, phone number, or name + date of birth already exists.
Retrieve a Patient
Retrieves a patient by their UHID from the national FHIR server.
/api/v1/uhid/{uhid}/Path Parameters
uhidstringrequiredThe patient's UHID
curl https://api.mediloop.co/api/v1/uhid/UG123456789A/ \
-H "Authorization: Bearer sk_test_..."{
"uhid": "UG123456789A",
"first_name": "John",
"last_name": "Doe",
"date_of_birth": "1990-05-15",
"gender": "M",
"phone_number": "+256700123456",
"district": "Kampala",
"fhir_patient_id": "fhir-patient-123-456",
"is_active": true
}Search Patients
Search for patients by various criteria. All searches query the national FHIR server.
/api/v1/uhid/search/Query Parameters
uhidstringoptionalSearch by exact UHID
ninstringoptionalSearch by National ID
passport_numberstringoptionalSearch by passport number
phone_numberstringoptionalSearch by phone number
first_namestringoptionalSearch by first name
last_namestringoptionalSearch by last name
date_of_birthstringoptionalSearch by date of birth (YYYY-MM-DD)
curl "https://api.mediloop.co/api/v1/uhid/search/?first_name=John&last_name=Doe" \
-H "Authorization: Bearer sk_test_..."{
"results": [
{
"uhid": "UG123456789A",
"first_name": "John",
"last_name": "Doe",
"date_of_birth": "1990-05-15",
"gender": "M",
"phone_number": "+256700123456"
}
],
"count": 1,
"source": "fhir"
}List Patients
Returns a paginated list of patients from the national FHIR server.
/api/v1/uhid/Query Parameters
pageintegeroptionalPage number
Default: 1
page_sizeintegeroptionalResults per page (max 100)
Default: 20
curl "https://api.mediloop.co/api/v1/uhid/?page=1&page_size=20" \
-H "Authorization: Bearer sk_test_..."{
"results": [
{
"uhid": "UG123456789A",
"first_name": "John",
"last_name": "Doe",
"date_of_birth": "1990-05-15"
}
],
"count": 1,
"page": 1,
"page_size": 20,
"next": null,
"previous": null,
"source": "fhir"
}Update a Patient
Updates a patient's information. Changes are written to the FHIR server first, then cached locally.
/api/v1/uhid/{uhid}/curl -X PUT https://api.mediloop.co/api/v1/uhid/UG123456789A/ \
-H "Authorization: Bearer sk_test_..." \
-H "Content-Type: application/json" \
-d '{
"phone_number": "+256700999888",
"district": "Wakiso"
}'{
"uhid": "UG123456789A",
"first_name": "John",
"last_name": "Doe",
"phone_number": "+256700999888",
"district": "Wakiso",
"updated_at": "2024-01-16T14:30:00Z"
}Validate Patient UHID
Validates a UHID and returns basic patient information. Useful for service integrations that need to verify patient identity before proceeding.
/api/v1/uhid/{uhid}/validate/curl https://api.mediloop.co/api/v1/uhid/UG123456789A/validate/ \
-H "Authorization: Bearer sk_test_..."{
"valid": true,
"uhid": "UG123456789A",
"name": "John Mukasa Doe",
"first_name": "John",
"last_name": "Doe",
"phone": "+256700123456",
"email": "john.doe@example.com",
"fhir_patient_id": "fhir-patient-123-456",
"address": "Plot 123, Kampala Road, Kampala, UG",
"date_of_birth": "1990-05-15",
"gender": "M",
"active": true
}UHID Format
The Uganda Health Identifier (UHID) is auto-generated during patient registration:
UG[0-9]{9}[A-Z]- Prefix: UG (Uganda)
- Numeric: 9 random digits
- Check character: 1 uppercase letter