My name is Oluwakemi. I am currently learning software development and working on a digital health project focused on improving how healthcare referrals are tracked between facilities.The idea is to allow a referring healthcare facility to create a referral and allow the receiving facility to track and update that referral until the patient receives the required care.
The basic workflow is:
`Referring Facility → Referral Created → Receiving Facility → Referral Accepted → Care Provided → Referral Completed`
One of the challenges I am trying to solve is how to design the API and database so that healthcare workers can track the referral without unnecessarily exposing the patient's personal information.
For example, I was thinking of having a referral record like:
```json
{
"referral_id": "REF-2026-00125",
"patient_id": "PAT-10234",
"referring_facility_id": "FAC-001",
"receiving_facility_id": "FAC-014",
"status": "accepted",
"created_at": "2026-09-29T10:30:00Z"
}m
I am considering separating patient information from referral information:
```text
Patient
- patient_id
- name
- date_of_birth
- contact_information
Referral
- referral_id
- patient_id
- referring_facility_id
- receiving_facility_id
- status
- created_at
- updated_at
```
For example, a user at the receiving facility might need to see the referral ID, referral status and relevant information needed to provide care, but should not automatically have access to unrelated patient information.
I am therefore trying to understand the best way to approach the API design.
My questions are:
1. Is separating the Patient and Referral tables a good approach for this type of application?
2. Should the API return different fields depending on the user's role and facility?
3. How can I prevent one healthcare facility from accessing referrals belonging to another facility?
4. Is using an internal patient ID preferable to exposing the patient's name or other identifying information in API responses?
5. Should the referral ID be a random/opaque identifier rather than a sequential database ID?
6. What would a good API endpoint structure look like for creating, viewing and updating referrals?
7. What authorization approach would you recommend for this type of facility-to-facility access?
I am particularly interested in learning about good API and database design patterns for handling sensitive information. I am not looking for a complete healthcare system, but for guidance on how to structure the API correctly from the beginning.
I have removed real patient information from the examples above and am using fictional IDs.
Thank you.