Skip to main content
Version: 3.1

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:

Models​

ModelPurpose
ImmunizationPolicyA 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​

FieldTypeSpec typeNotes
nameCharField(255)strRequired
descriptionTextField, nullablestrOptional
policy_templateJSONField, default {}ImmunizationPolicyTemplateSpecRequired. The root node of the template tree. See Template shape
facilityFK → Facility, PROTECT, nullableUUID4 or nullCreate 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:

CheckError
Only a group can have childrenOnly groups can contain children
A node that is not a group has at least one codes entryCodes 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)​

SpecRoleFields
ImmunizationPolicySpecShared baseid, policy_template, name, description
ImmunizationPolicyCreateSpecwrite · createBase fields plus facility (UUID or null)
ImmunizationPolicyUpdateSpecwrite · updateBase fields. policy_template and name are required, so an update sends the whole template
ImmunizationPolicyListSpecread · listBase fields
ImmunizationPolicyRetrieveSpecread · detailBase fields
ImmunizationPolicyTemplateSpecNestedOne template node (see above)
ImmunizationPolicyApplySpecwrite · apply_policy requestpolicy, reference_date, encounter, parent. See Applying a policy
ImmunizationPolicyApplyResponseSpecread · apply_policy responseA 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 facility query parameter returns instance policies only. List with facility={facility_external_id} returns that facility's policies and the instance policies, and needs can_read_immunization_policy in the facility.
  • Filters: name (contains, case-insensitive) and facility. Ordering: created_date, modified_date.
  • The viewset adds FavoritesFilter as a filter backend, but it has no FAVORITE_RESOURCE and no favorites endpoints. Do not send favorite_list: the filter reads the missing attribute and the request fails.
  • Retrieve: a facility policy needs can_read_immunization_policy in its facility. Any signed-in user can retrieve an instance policy.
  • Create and update: a facility policy needs can_write_immunization_policy held 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 with can_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 without facility (instance policies only) and compares the IDs.
  • apply_policy lives on the recommendation endpoint, not here. See Immunization recommendation.