# 7-1-7 register

Keep the detection and notification dates of each alert in a DHIS2 event program for the 7-1-7 targets.

This page concludes the [Outbreak alerts](https://zato.io/docs/dev/healthcare/dhis2/outbreak-alerts/index.html) series. The 7-1-7 targets measure each outbreak against three intervals - seven days from emergence to detection, one day from detection to notification, and seven days from notification to the completion of the early response actions.

## The register {#the-register}

The register is a DHIS2 event program with one event per alert and one date data element per milestone. Two of the dates are known at the moment an alert is raised - the date it was detected and the date the district was notified - and the service below writes them. The date of emergence, the date the early response was completed and the account of any delay are entered by the people who investigate the outbreak, into the same event.

Program indicators in DHIS2 compute each interval with `d2:daysBetween` over two of the dates, and a chart of the indicators shows how many outbreaks met each target.

## The event {#the-event}

The event is left active so that the remaining dates can be added to it:

```python
# -*- coding: utf-8 -*-

# Zato
from zato.server.service import Service

class UpdateRegister(Service):
    name = 'dhis2.alerts.update-register'

    def build_event(self, alert:'dict') -> 'dict':

        register = self.config.alert_programs.register

        # The dates known when the alert is raised ..
        data_values = [
            {'dataElement': register.element_disease, 'value': alert['disease']},
            {'dataElement': register.element_detected, 'value': alert['detected']},
            {'dataElement': register.element_notified, 'value': alert['notified']},
        ]

        # .. go into a new event of the register, one per alert.
        event = {
            'program': register.id,
            'programStage': register.stage,
            'orgUnit': alert['district'],
            'occurredAt': alert['detected'],
            'status': 'ACTIVE',
            'dataValues': data_values,
        }

        return event
```

The register is written through the same tracker importer as the alert program:

```python
    def handle(self) -> 'None':

        alert = self.request.payload
        event = self.build_event(alert)

        payload = {'events': [event]}
        params = {'async': 'false'}

        conn = self.rest['DHIS2 Tracker']
        conn.post(payload, params)
```

The detection date is the date the threshold was crossed in Zato, and the notification date is the date `dhis2.alerts.notify-district` sent the email and the SMS, so neither depends on anyone copying dates from one system to another.

## See also {#see-also}

- [Thresholds](https://zato.io/docs/dev/healthcare/dhis2/outbreak-alerts/thresholds.html) - Where the detection date comes from
- [District notifications](https://zato.io/docs/dev/healthcare/dhis2/outbreak-alerts/notify.html) - Where the notification date comes from

## Learn more {#learn-more}

- [Healthcare interface engine](https://zato.io/docs/dev/healthcare/) - Clinical messages, FHIR, conversion and operations
- [HL7 v2 parsing](https://zato.io/docs/dev/healthcare/hl7/v2/parsing/) - Messages as typed objects, with field access and validation
- [MLLP channels](https://zato.io/docs/dev/healthcare/hl7v2/mllp/) - Receiving and sending HL7 v2 over MLLP sockets
- [FHIR integrations](https://zato.io/docs/dev/healthcare/hl7/fhir/) - Read and write FHIR resources, with paths, bundles and extensions
- [HL7 v2 to FHIR](https://zato.io/docs/dev/healthcare/hl7/to-fhir/) - Converting v2 messages into FHIR bundles, codes and references included
- [EDIFACT](https://zato.io/docs/dev/healthcare/edifact/) - Parsing interchanges, dialects and the transports they arrive on
- [Transformation](https://zato.io/docs/dev/healthcare/transformation/) - One message in, another standard out, in ordinary Python
- [Audit log](https://zato.io/docs/dev/healthcare/audit-log.html) - Every message with its acknowledgment, searchable by patient identifier
- [AI in clinical interfaces](https://zato.io/docs/dev/healthcare/ai/) - Services calling LLMs and AI agents calling clinical services as tools
