Immunization recommendation
Technical reference for the ImmunizationRecommendation model in Care EMR. A recommendation is one planned vaccine dose in a patient's schedule, or a group that holds other recommendations. It maps to the FHIR ImmunizationRecommendation resource, with one Care row for each planned dose.
Recommendations usually come from an immunization policy: the apply_policy action copies the policy template into a tree of recommendations for one patient. An immunization record can point to the recommendation that it fulfils.
Source:
- Model:
care/emr/models/immunisation.py(classImmunizationRecommendation) - Specs:
care/emr/resources/immunisation/recommendation.py - Viewset:
care/emr/api/viewsets/immunization/recommendation.py - Permissions:
care/security/permissions/immunization.py·care/security/authorization/immunization.py
Models
| Model | Purpose |
|---|---|
ImmunizationRecommendation | One planned dose (is_group = false) or a group of recommendations (is_group = true) for one patient |
It extends EMRBaseModel. The same model file also holds Immunization (Immunization) and ImmunizationPolicy (Immunization policy).
ImmunizationRecommendation fields
Clinical details
These fields come from BaseImmunizationRecommendationSpec. The policy template uses the same base.
| Field | Type | Spec type | Notes |
|---|---|---|---|
codes | JSONField, default [] | list[Coding], each bound to system-medication | The vaccines. Required and not empty when is_group is false. Optional for a group |
diseases | JSONField, nullable | list[Coding], each bound to system-condition-code | Optional. Target diseases |
earliest_date | DateField, nullable | date | Optional |
due_date | DateField, nullable | date | Optional |
overdue_date | DateField, nullable | date | Optional |
description | TextField, nullable | str | Optional |
series | CharField(255), nullable | str | Optional. Free text |
dose_number | CharField(255), nullable | str | Optional. Free text, not a number |
series_number | CharField(255), nullable | str | Optional. Free text. care_fe shows it as the number of doses in the series |
The recommendation specs do not check the order of the three dates. Only the policy template checks the order of its day offsets.
Status and tree
| Field | Type | Spec type | Notes |
|---|---|---|---|
forecast_status | CharField(100) | ImmunizationRecommendationForecastStatus | Required on create. Optional on update. See forecast status values |
is_group | BooleanField | bool | Required on create. Write once |
parent | FK → self, CASCADE, nullable, related_name="children" | UUID4 or null | Optional. Write once. Must be a group (is_group = true) of the same patient. A root recommendation has no parent |
Links
| Field | Type | Spec type | Notes |
|---|---|---|---|
patient | FK → Patient, CASCADE | UUID4 | Required on create. Must match the patient in the URL. Write once |
encounter | FK → Encounter, CASCADE, nullable | UUID4 or null | Optional. Write once. Must belong to the patient. Decides which permission check applies (see below) |
Optional value fields accept a value or no key. They do not accept null. A key that an update leaves out keeps its stored value.
Enum values
ImmunizationRecommendationForecastStatus values
| Value | care_fe label |
|---|---|
due | Due |
immune | Immune |
contraindicated | Contraindicated |
complete | Complete |
Care does not store "overdue" or "upcoming". care_fe derives them from a due recommendation and its dates:
- Overdue: today is on or after
overdue_date. Withoutoverdue_date, today is afterdue_date. - Upcoming: not overdue, and today is before
earliest_date. - Due: every other
duerecommendation.
Nested JSON shapes
Coding (each item of codes and diseases)
Coding {
system: str | null
version: str | null
code: str # required
display: str | null
}
Care validates each code against the bound value set.
Resource specs (API schema)
| Spec | Role | Fields |
|---|---|---|
BaseImmunizationRecommendationSpec | Shared base, also used by the policy template | id, codes, diseases, due_date, earliest_date, overdue_date, description, series, dose_number, series_number |
ImmunizationRecommendationCreateSpec | write · create | Base fields plus parent, patient, encounter, is_group, forecast_status. Rejects a non-group with no codes |
ImmunizationRecommendationUpdateSpec | write · update | Base fields plus forecast_status. No parent, patient, encounter or is_group. Rejects an update that would leave a non-group with no codes |
ImmunizationRecommendationListSpec | read · list | Base fields plus forecast_status, is_group, parent (UUID or null) |
ImmunizationRecommendationRetrieveSpec | read · detail | List fields plus patient, encounter (UUID or null), created_by, updated_by |
Applying a policy
POST /api/v1/patient/{patient_external_id}/immunization/recommendation/apply_policy/ creates the recommendation tree of one policy for the patient.
Request (ImmunizationPolicyApplySpec):
{
policy: UUID4 # required
reference_date: date # required. Day offsets count from this date
encounter: UUID4 | null # optional. Must belong to the patient
parent: UUID4 | null # optional. An existing group of the patient
}
Behaviour:
- Care creates one recommendation for each node of the template, groups included, with the same tree structure. A
parentin the request attaches the new root under that group. - Each node copies its own clinical fields. A group's fields do not pass to its children.
earliest_date,due_dateandoverdue_datearereference_dateplus the node's day offset. A date outside the supported range returns a validation error.- Every new recommendation gets
forecast_status = due, the request'sencounterand the URL's patient. - Care creates the whole tree in one transaction. If one node fails, Care creates none.
- The response is
201with a list ofImmunizationRecommendationRetrieveSpecobjects, one for each created node. - For a facility policy, the user needs
can_read_immunization_policyin that facility. Ifencounteris set, it must be an encounter of the policy's facility. - If
parentbelongs to an encounter, the request'sencountermust be the same encounter.
care_fe does not apply a policy that has more than 20 non-group recommendations. The backend has no such limit.
API integration notes
- Endpoints are nested under the patient:
/api/v1/patient/{patient_external_id}/immunization/recommendation/. The viewset allows create, list, retrieve, update andapply_policy. It has no delete. - Filters:
encounter,parent(UUIDs),root(truefor recommendations with no parent),is_group,forecast_status(comma-separated, several values),due_date_after,due_date_before. Ordering:created_date,modified_date,due_date. - Write (create, update and
apply_policy): a recommendation with an encounter needscan_write_immunization_recommendationin that encounter, and Care refuses it when the encounter is closed (completed,cancelled,entered_in_errorordiscontinued). A recommendation without an encounter needs the permission on the patient. - Read:
can_read_immunization_recommendationon the patient, or in the recommendation's encounter. A list without the patient permission must pass anencounterfilter for an encounter that the user can read. - Default roles with
can_write_immunization_recommendation: Facility Admin, Doctor, Nurse. Default roles withcan_read_immunization_recommendation: Facility Admin, Administrator, Staff, Doctor, Nurse, Volunteer, Pharmacist. - Recording an immunization against a recommendation does not change
forecast_status. The client setscompletewith an update.
Related
- Reference: Immunization
- Reference: Immunization policy
- Reference: Encounter
- Reference: Patient
- Source (model): immunisation.py on GitHub
- Source (specs): resources/immunisation on GitHub