# 06 — Medical Records

← [Back to index](README.md)

The patient's non-visit clinical history — **six** independently-editable sections. Kept
separate from [Patient](05-patients.md) demographics so each section PATCHes on its own.
The **allergies** feed the [drug-allergy check](09-prescriptions.md).

---

## `GET /patients/{patientId}/medical-record`
**Response `200` — `MedicalRecord`** (return all-empty arrays if none yet):
```json
{
  "patientId": "p1",
  "allergies": [
    { "id": "al1", "substance": "Penicillin", "severity": "severe",
      "reaction": "طفح جلدي", "notes": null, "notedAt": "2024-02-01T00:00:00Z" }
  ],
  "chronicConditions": [
    { "id": "cc1", "name": "السكري", "sinceYear": 2018, "notes": null }
  ],
  "currentMedications": [
    { "id": "cm1", "drugName": "ميتفورمين", "dose": "500mg",
      "frequency": "مرتين يومياً", "startedAt": "2020-01-01T00:00:00Z", "notes": null }
  ],
  "surgicalHistory": [
    { "id": "sr1", "procedure": "استئصال الزائدة", "date": "2015-06-10T00:00:00Z",
      "hospital": "مستشفى ...", "surgeon": "د. ...", "notes": null }
  ],
  "familyHistory": [
    { "id": "fh1", "condition": "ضغط الدم", "relation": "الأب", "notes": null }
  ],
  "vaccinations": [
    { "id": "vac1", "name": "كوفيد-19", "dateGiven": "2021-08-01T00:00:00Z", "notes": null }
  ]
}
```

---

## Per-section upsert / delete

Each section has an **upsert** (create when `id` is empty/new, else update by `id`) and a
**delete**. Upsert body = the entry object. Upsert returns the saved entry (`200`/`201`);
delete returns `200`/`204`.

| Section | Upsert | Delete |
|---|---|---|
| Allergies | `PUT /patients/{patientId}/medical-record/allergies` | `DELETE .../allergies/{entryId}` |
| Chronic conditions | `PUT /patients/{patientId}/medical-record/chronic-conditions` | `DELETE .../chronic-conditions/{entryId}` |
| Current medications | `PUT /patients/{patientId}/medical-record/medications` | `DELETE .../medications/{entryId}` |
| Surgical history | `PUT /patients/{patientId}/medical-record/surgical` | `DELETE .../surgical/{entryId}` |
| Family history | `PUT /patients/{patientId}/medical-record/family` | `DELETE .../family/{entryId}` |
| Vaccinations | `PUT /patients/{patientId}/medical-record/vaccinations` | `DELETE .../vaccinations/{entryId}` |

---

## Section field contracts
All `id`s are server-assigned; nullable fields may be omitted.

| Entity | Fields |
|---|---|
| **AllergyEntry** | `id`, `substance` (req), `severity` ([AllergySeverity](11-enums.md): `mild`/`moderate`/`severe`, req), `reaction?`, `notes?`, `notedAt?` (datetime). Store `substance` lowercase for matching. |
| **ChronicCondition** | `id`, `name` (req), `sinceYear?` (int), `notes?` |
| **CurrentMedication** | `id`, `drugName` (req), `dose?`, `frequency?`, `startedAt?` (datetime), `notes?` |
| **SurgicalRecord** | `id`, `procedure` (req), `date?` (datetime), `hospital?`, `surgeon?`, `notes?` |
| **FamilyHistoryEntry** | `id`, `condition` (req), `relation` (req, free text), `notes?` |
| **Vaccination** | `id`, `name` (req), `dateGiven?` (datetime), `notes?` |

> The `patientAllergies` passed to
> [`POST /prescriptions/check-allergy-conflicts`](09-prescriptions.md) come from this
> section's `allergies` (each `{ substance, severity }`).
