Immunization
Technical reference for the Immunization model in Care EMR. An Immunization records one vaccine dose for one patient in one encounter: a dose that the facility gave, a dose that the patient or another provider reports, or a dose that was not given. It maps to the FHIR Immunization resource.
The Django model stores the record. Several fields are JSONFields. The Pydantic resource specs bind them to value sets and give them a shape, so read the spec columns below for what a write must contain.
Source:
- Model:
care/emr/models/immunisation.py(classImmunization) - Specs:
care/emr/resources/immunisation/immunization.py - Viewset:
care/emr/api/viewsets/immunization/immunization.py - Permissions:
care/security/permissions/immunization.py·care/security/authorization/immunization.py
Models
care/emr/models/immunisation.py holds three models. This page documents Immunization. The other two have their own pages.
| Model | Purpose | Page |
|---|---|---|
Immunization | One vaccine dose given, reported or not given | This page |
ImmunizationRecommendation | One planned dose, or a group of planned doses, in a patient's schedule | Immunization recommendation |
ImmunizationPolicy | A reusable template of recommendations, for one facility or for the instance | Immunization policy |
All three extend EMRBaseModel, which gives external_id, the audit fields, soft delete through deleted, history and meta.
Immunization fields
Status and vaccine
| Field | Type | Spec type | Notes |
|---|---|---|---|
status | CharField(100) | ImmunizationStatus | Required on create. Optional on update. See ImmunizationStatus values |
reason | CharField(100), nullable | ImmunizationReason | Optional. Why the dose was not given. The backend does not tie it to not_done; the care_fe form asks for it only when status is not_done |
code | JSONField, default {} | Coding, bound to system-medication | Required on create. Optional on update. The vaccine |
primary_source | BooleanField | bool | Required on create. Optional on update. true when the facility gave the dose. The care_fe form sends false for a historical (reported) record |
occurrence | DateTimeField, nullable | datetime | Optional. When the dose was given |
Administration details
| Field | Type | Spec type | Notes |
|---|---|---|---|
site | JSONField, nullable | Coding, bound to system-body-site | Optional |
route | JSONField, nullable | Coding, bound to system-route | Optional |
dose_quantity | JSONField, nullable | Quantity | Optional. See Nested JSON shapes |
is_subpotent | BooleanField, nullable | bool | Optional |
subpotent_reason | TextField, nullable | str | Optional. Free text |
note | TextField, nullable | str | Optional. Free text |
Links
| Field | Type | Spec type | Notes |
|---|---|---|---|
encounter | FK → Encounter, CASCADE | UUID4 | Required on create. Write once: the update spec has no encounter field. See Encounter |
patient | FK → Patient, CASCADE | — | Server-set from the encounter. Not in any read spec |
facility | FK → Facility, PROTECT | — | Server-set from the encounter. Not in any read spec |
recommendation | FK → ImmunizationRecommendation, SET_NULL, nullable | UUID4 or null | Optional. Must belong to the same patient. null clears it |
product | FK → Product, SET_NULL, nullable | UUID4 or null | Optional. Must belong to the encounter's facility. See Product |
location | FK → FacilityLocation, SET_NULL, nullable | UUID4 or null | Optional. Must belong to the encounter's facility. See Location |
administered_by | FK → users.User, SET_NULL, nullable | str (username) or null | Optional. Written as a username, read back as a UserSpec object |
Optional value fields (reason, occurrence, site, route, dose_quantity, is_subpotent, subpotent_reason, note) accept a value or no key. They do not accept null. The writer uses exclude_defaults, so a key that an update leaves out keeps its stored value.
Enum values
ImmunizationStatus values
| Value | care_fe label |
|---|---|
draft | Draft |
completed | Completed |
entered_in_error | Entered in error |
not_done | Not given |
ImmunizationReason values
HL7 v3 ActReason codes. The labels come from care_fe.
| Value | care_fe label |
|---|---|
IMMUNE | Patient is immune |
MEDPREC | Medical precaution |
OSTOCK | Vaccine out of stock |
PATOBJ | Patient objection |
PHILISOP | Philosophical objection |
RELIG | Religious objection |
VACEFF | Vaccine efficacy concerns |
VACSAF | Vaccine safety concerns |
Nested JSON shapes
Coding (code, site, route)
Coding {
system: str | null
version: str | null
code: str # required
display: str | null
}
Extra keys are rejected. Care validates the code against the bound value set (system-medication, system-body-site or system-route).
Quantity (dose_quantity)
Quantity {
value: Decimal | null # max 20 digits, 6 decimal places
unit: Coding | null
code: Coding | null
meta: dict | null
}
Extra keys are rejected.
Resource specs (API schema)
| Spec | Role | Fields beyond BaseImmunizationSpec |
|---|---|---|
BaseImmunizationSpec | Shared base | id, status, reason, code, occurrence, primary_source, site, route, dose_quantity, note, is_subpotent, subpotent_reason |
ImmunizationWriteSpec | Shared write base | recommendation, product, location, administered_by. Resolves each link and checks its scope |
ImmunizationCreateSpec | write · create | encounter (required). Sets patient and facility from the encounter |
ImmunizationUpdateSpec | write · update | Makes status, code and primary_source optional. No encounter |
ImmunizationListSpec | read · list | encounter (UUID), recommendation (UUID or null), administered_by (UserSpec or null) |
ImmunizationRetrieveSpec | read · detail | List fields plus product, location (UUIDs or null), created_by, updated_by |
The read specs do not return patient or facility.
API integration notes
- Endpoints are nested under the patient:
/api/v1/patient/{patient_external_id}/immunization/record/. The viewset allows create, list, retrieve and update. It has no delete. To void a record, setstatustoentered_in_error. - Create checks that the encounter belongs to the patient in the URL.
- Filters:
encounter,recommendation,facility(UUIDs),statusandreason(comma-separated, several values),occurrence(occurrence_after/occurrence_before),primary_source. Ordering:created_date,modified_date. - Create and update need
can_write_immunizationin the encounter. Care refuses both when the encounter status iscompleted,cancelled,entered_in_errorordiscontinued. Update checks the record's own encounter. - Read needs
can_read_immunizationon the patient, or in the record's encounter. A list withoutcan_read_immunizationon the patient must pass anencounterfilter for an encounter that the user can read. - Default roles with
can_write_immunization: Facility Admin, Doctor, Nurse. Default roles withcan_read_immunization: Facility Admin, Administrator, Staff, Doctor, Nurse, Volunteer, Pharmacist. See Permission. - Saving a record does not change its recommendation. care_fe sets the recommendation's
forecast_statustocompletewith a separate update after it saves a completed dose. - A referral can link an immunization as a resource of type
immunization. Care renders it withImmunizationListSpecfor users who can view the patient's or the encounter's clinical data.
Related
- Reference: Immunization recommendation
- Reference: Immunization policy
- Reference: Encounter
- Reference: Patient
- Reference: Product
- Reference: Location
- Reference: Value set
- Source (model): immunisation.py on GitHub
- Source (specs): resources/immunisation on GitHub