Immunization policy
Technical reference for the ImmunizationPolicy model in Care EMR. A policy is a reusable template of vaccine recommendations. A policy with a facility belongs to that facility. A policy without a facility is an instance policy, and every facility can use it.
A policy does not change a patient's record. The apply_policy action on immunization recommendations copies the template into recommendations for one patient.
Source:
- Model:
care/emr/models/immunisation.py(classImmunizationPolicy) - Specs:
care/emr/resources/immunisation/policy.py·recommendation.py(shared base) - Viewset:
care/emr/api/viewsets/immunization/policy.py - Permissions:
care/security/permissions/immunization.py·care/security/authorization/immunization.py
Models
| Model | Purpose |
|---|---|
ImmunizationPolicy | A named template of recommendations, for one facility or for the instance |
It extends EMRBaseModel. The same model file also holds Immunization (Immunization) and ImmunizationRecommendation (Immunization recommendation).
ImmunizationPolicy fields
| Field | Type | Spec type | Notes |
|---|---|---|---|
name | CharField(255) | str | Required |
description | TextField, nullable | str | Optional |
policy_template | JSONField, default {} | ImmunizationPolicyTemplateSpec | Required. The root node of the template tree. See Template shape |
facility | FK → Facility, PROTECT, nullable | UUID4 or null | Create only. null makes an instance policy. The update spec has no facility, so a policy cannot change scope. The read specs do not return it |
Template shape
policy_template holds one ImmunizationPolicyTemplateSpec node. A group node holds child nodes, to any depth.
ImmunizationPolicyTemplateSpec {
is_group: bool # required
children: list[ImmunizationPolicyTemplateSpec] # default []
codes: list[Coding] # bound to system-medication
diseases: list[Coding] # bound to system-condition-code
earliest_date: int # days from the reference date
due_date: int # days from the reference date
overdue_date: int # days from the reference date
description: str
series: str
dose_number: str
series_number: str
}
The clinical fields come from BaseImmunizationRecommendationSpec, the same base that recommendations use. In the template, the three date fields are whole numbers of days instead of dates. All fields except is_group and children are optional.
Template validation
Each node must pass these checks:
| Check | Error |
|---|---|
Only a group can have children | Only groups can contain children |
A node that is not a group has at least one codes entry | Codes are required for non-group recommendations |
The offsets that are set increase strictly, in the order earliest_date, due_date, overdue_date. Two offsets cannot be equal | <left> must be before <right>, for example earliest_date must be before due_date |
The specs do not restrict the sign of an offset.
Resource specs (API schema)
| Spec | Role | Fields |
|---|---|---|
ImmunizationPolicySpec | Shared base | id, policy_template, name, description |
ImmunizationPolicyCreateSpec | write · create | Base fields plus facility (UUID or null) |
ImmunizationPolicyUpdateSpec | write · update | Base fields. policy_template and name are required, so an update sends the whole template |
ImmunizationPolicyListSpec | read · list | Base fields |
ImmunizationPolicyRetrieveSpec | read · detail | Base fields |
ImmunizationPolicyTemplateSpec | Nested | One template node (see above) |
ImmunizationPolicyApplySpec | write · apply_policy request | policy, reference_date, encounter, parent. See Applying a policy |
ImmunizationPolicyApplyResponseSpec | read · apply_policy response | A list of ImmunizationRecommendationRetrieveSpec |
API integration notes
- Endpoint:
/api/v1/immunization/policy/. The viewset allows create, list, retrieve and update. It has no delete. - List without a
facilityquery parameter returns instance policies only. List withfacility={facility_external_id}returns that facility's policies and the instance policies, and needscan_read_immunization_policyin the facility. - Filters:
name(contains, case-insensitive) andfacility. Ordering:created_date,modified_date. - The viewset adds
FavoritesFilteras a filter backend, but it has noFAVORITE_RESOURCEand no favorites endpoints. Do not sendfavorite_list: the filter reads the missing attribute and the request fails. - Retrieve: a facility policy needs
can_read_immunization_policyin its facility. Any signed-in user can retrieve an instance policy. - Create and update: a facility policy needs
can_write_immunization_policyheld in the facility's root organization. Only a superuser can create or update an instance policy. - Default roles with
can_write_immunization_policy: Facility Admin. Default roles withcan_read_immunization_policy: Facility Admin, Administrator, Staff, Doctor, Nurse, Volunteer, Pharmacist. - The read specs do not return
facility. To tell instance policies from facility policies in a facility list, care_fe also fetches the list withoutfacility(instance policies only) and compares the IDs. apply_policylives on the recommendation endpoint, not here. See Immunization recommendation.
Related
- Reference: Immunization recommendation
- Reference: Immunization
- Reference: Facility
- Reference: Value set
- Source (model): immunisation.py on GitHub
- Source (specs): resources/immunisation on GitHub