Proposal: Date-Bounded and Multi-Level Service Alerts

To: Open Referral Technical Committee

Background

HSDS currently supports a single free-text alert on the service object via service.alert. In practice, our clients are now supplying service alerts that include a start date, and we expect end dates to follow soon. Alongside this, we’ve received a request to automatically show and hide alerts based on those dates.

Looking further ahead, we anticipate two additional needs:

  1. Multiple alerts per service. This is a rare but real edge case (for example, a temporary closure notice alongside a separate eligibility change).
  2. Alerts at the service_at_location level. Some alerts apply only to a service as delivered at a specific location, not to the service everywhere it’s offered.

The current single-string service.alert field can’t represent dates, multiple alerts, or location-specific alerts.

Proposal

We propose a two-phase approach: a minimal, backward-compatible short-term change, followed by a more complete long-term model.

Short-term: add date fields to service

Add two optional fields to the service object:

Field Type Description
service.alert_start_date date The date from which service.alert becomes relevant.
service.alert_end_date date The date after which service.alert is no longer relevant.

This is purely additive, requires no changes to existing data, and lets consumers automatically show or hide service.alert (or at least signal its relevancy) based on the current date.

Long-term: introduce an alert object

Create a new alert object that can be linked to either a service or a service_at_location:

Field Type Description
alert.id string (UUID) Unique identifier for the alert.
alert.service_id string The service this alert applies to, if any.
alert.service_at_location_id string The service_at_location this alert applies to, if any.
alert.message string The text of the alert.
alert.start_date date The date from which the alert is relevant.
alert.end_date date The date after which the alert is no longer relevant.

An alert would be linked to a service or a service_at_location (at least one of alert.service_id or alert.service_at_location_id should be present). A service or service_at_location could have zero or more alerts.

Benefits

  • Granularity: Alerts can be expressed at the service level or the service-at-location level.
  • Multiplicity: Multiple concurrent or sequential alerts are supported when needed.
  • Automation: Start and end dates allow consumers to automatically show and hide alerts, or at minimum indicate whether an alert is current, upcoming, or expired.
  • Incremental adoption: The short-term change delivers immediate value without blocking on the larger model change.

Documenting Open-ended dates

We suggest that both dates be optional, with a missing start_date meaning “effective immediately” and a missing end_date meaning “until further notice.”

Next Steps

I’d like to propose this at our next standing technical meeting. What do you think? Is this useful? Could it be improved? @mrshll @sasha @MikeThacker-iStandUK @oughnic @bloom

This seems worthwhile. I think we discussed it before, right? As per this comment thread, re this schema.org property as an example: SpecialAnnouncement - Schema.org Type

We haven’t had requests for service alerts, but I’d like to see examples of how this would be used and see no harm in adding to the full HSDS.

If there’s something similar in schema.org, I’m sure @oughnic will recommend we use that.

This is a great idea, thanks for this @skyleryoung! I think we should do this.

My initial thoughts:

  • Introducing an alert object would be possible with a MINOR upgrade, and could be revised later with a MAJOR upgrade if the object has limitations imposed by the current design of HSDS.
  • In the same MINOR upgrade, we can mark service.alert as deprecated in the schema, and add service.alerts. We have precedence for this in v3.3 where we deprecated service.schedules. We can also add service_at_location.alerts
  • Is there a reason that alert.start_date can’t be mandatory? The missing start date meaning “effective immediately” could just have today’s date applied by systems who receive the alert. There might be some context I’m missing from not working in the area.
  • Are there any taxonomies or codelists we could use to describe the type or category of alert in machine-readable form? This would complement the alert.message field. If so, we could maybe add alert.categories or alert.taxonomies to allow describing this.
  • Current HSDS practice is to add a metadata array to each object. To keep in with this, we could add in alert.metadata to the alert object.
  • We might want to provide a URL which links off to more information. It might be that we provide a link to the source of information. We have a url schema, and JSON Schema provides the uri string formatting rule. So we could think about adding in alert.source/alert.further_information (or something?).
  • Is there a case for updating the API spec to describe an optional /alerts endpoint, to complement this? This could be a separate proposal. While I’d advise us moving towards a future where the data/API model is oriented around service objects, this doesn’t preclude a medium-term where APIs provide functionality to directly query for alert objects in the same way that the API spec defines the /taxonomies endpoint.
  • Looking at the SpecialAnnouncement from Schema.org, I think I prefer Skyler’s lightweight model for use in HSDS. The schema.org one seems very oriented around describing things like disease control measures and school closures, which is a lot of detail that might not be relevant to every alert on a service. From what I can tell in this thread, the main use-cases for HSDS users are that they need to know whether a service is currently affected by a particular alert in some way. The details could be provided elsewhere, ideally linked off via a url, which in a dream world would resolve to an object using the Schema.org vocabulary to describe the details.