Trasovač¶
Caution
Tracker has been re-implemented in DHIS2 2.36. This document describes the new tracker endpoints
POST /api/trackerGET /api/tracker/trackedEntitiesGET /api/tracker/enrollmentsGET /api/tracker/eventsGET /api/tracker/relationshipsTracker (deprecated) describes the deprecated endpoints
GET/POST/PUT/DELETE /api/trackedEntityInstanceGET/POST/PUT/DELETE /api/enrollmentsGET/POST/PUT/DELETE /api/eventsGET/POST/PUT/DELETE /api/relationshipsThe deprecated endpoints will be removed in version 42!
Migrating to new tracker endpoints should help you get started with your migration. Reach out on the community of practice if you need further assistance.
Objekty Trasovače¶
Tracker consists of a few different types of objects that are nested together to represent the data. In this section, we will show and describe each of the objects used in the Tracker API.
Tracked Entities¶
Trasované entity jsou kořenovým objektem pro model trasování.
| Vlastnictví | Popis | Požadované | Neměnný | Typ | Příklad |
|---|---|---|---|---|---|
| trackedEntity | Identifikátor trasované entity. Vygenerováno, pokud není dodáno | Ne | Ano | String:Uid | ABCDEF12345 |
| trackedEntityType | Typ trasované entity. | Ano | Ano | String:Uid | ABCDEF12345 |
| createdAt | Časové razítko, kdy uživatel vytvořil trasovanou entitu. Nastavit na serveru. | Ne | Ne | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| createdAtClient | Časové razítko, kdy uživatel vytvořil trasovanou entitu na klientovi. | Ne | Ano | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| updatedAt | Timestamp when the object or any enrollment, event, attribute or originating relationship, was last updated. Set on the server. | Ne | Ne | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| updatedAtClient | Časové razítko, kdy byl objekt naposledy aktualizován na klientovi. | Ne | Ano | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| orgUnit | Organizační jednotka, kde uživatel vytvořil trasovanou entitu. | Ano | Ano | String:Uid | ABCDEF12345 |
| neaktivní | Udává, zda je trasovaná entita neaktivní nebo ne. | Ne | Ano | Boolean | Default: false, true |
| smazáno | Označuje, zda byla trasovaná entita odstraněna. Může se změnit pouze při mazání. | Ne | Ne | Boolean | false until deleted |
| potentialDuplicate | Indicates whether the tracked entity is a potential duplicate. | Ne | Ne | Boolean | Default: false |
| geometrie | A geographical representation of the tracked entity. Based on the "featureType" of the TrackedEntityType. | Ne | Ano | GeoJson | { "type": "POINT", "coordinates": [123.0, 123.0] } |
| storedBy | Client reference for who stored/created the tracked entity. Set on the server. | Ne | Ano | String:Any | John Doe |
| createdBy | Pouze pro čtení dat. Uživatel, který objekt vytvořil. Nastaveno na serveru | Ne | Ano | Uživatel | { "uid": "ABCDEF12345", "username": "username", "firstName": "John", "surname": "Doe" } |
| updatedBy | Pouze pro čtení dat. Uživatel, který naposledy aktualizoval objekt. Nastavit na serveru | Ne | Ano | Uživatel | { "uid": "ABCDEF12345", "username": "username", "firstName": "John", "surname": "Doe" } |
| atributy | Seznam hodnot atributů trasované entity vlastněných trasovanou entitou. | Ne | Ano | Seznam TrackedEntityAttributeValue | Viz Atribut |
| zápisy | Seznam zápisů vlastněných trasovanou entitou. | Ne | Ano | Seznam zápisů | Viz Zápis |
| vztahy | Seznam vztahů spojených s trasovanou entitou. | Ne | Ano | Seznam vztahů | Viz Vztah |
| programOwners | Seznam organizačních jednotek, které mají prostřednictvím konkrétních programů přístup k této sledované entitě. Více viz "Vlastnictví programu". | Ne | Ano | Seznam ProgramOwner | Viz část "Vlastnictví programu" |
Note
Tracked Entities"owns" allTracked Entity Attribute Values(Or "attributes" as described in the previous table). However,Tracked Entity Attributesare either connected to aTracked Entitythrough itsTracked Entity Typeor aProgram. We often refer to this separation asTracked Entity Type AttributesandTracked Entity Program Attributes. The importance of this separation is related to access control and limiting what information the user can see.The "attributes" referred to in the
Tracked EntityareTracked Entity Type Attributes.
Enrollments¶
Tracked Entities can enroll into Programs for which they are eligible. Tracked entities are eligible as long as the program is configured with the same Tracked Entity Type as the tracked entity. We represent the enrollment with the Enrollment object, which we describe in this section.
| Vlastnictví | Popis | Požadované | Neměnný | Typ | Příklad |
|---|---|---|---|---|---|
| zápis | Identifikátor zápisu. Vygenerováno, pokud není dodáno | Ne | Ano | String:Uid | ABCDEF12345 |
| program | Program, který zápis představuje. | Ano | Ne | String:Uid | ABCDEF12345 |
| trackedEntity | Odkaz na zaregistrovanou trasovanou entitu. | Ano | Ano | String:Uid | ABCDEF12345 |
| status | Stav zápisu. AKTIVNÍ, pokud není součástí dodávky. | Ne | Ne | Výčet | AKTIVNÍ, DOKONČENO, ZRUŠENO |
| orgUnit | Organizační jednotka, do které uživatel zapsal trasovanou entitu. | Ano | Ne | String:Uid | ABCDEF12345 |
| createdAt | Časové razítko, kdy uživatel vytvořil objekt. Nastavit na serveru. | Ne | Ano | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| createdAtClient | Časové razítko, kdy uživatel vytvořil objekt na klientovi | Ne | Ne | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| updatedAt | Časové razítko, kdy byl objekt naposledy aktualizován. Nastavit na serveru. | Ne | Ano | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| updatedAtClient | Časové razítko, kdy byl objekt naposledy aktualizován na klientovi | Ne | Ne | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| enrolledAt | Časové razítko, kdy uživatel zaregistroval trasovanou entitu. | Ano | Ano | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| occurredAt | Časové razítko, kdy došlo k registraci. | Ne | Ano | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| completedAt | Časové razítko, kdy uživatel dokončil registraci. Nastaveno na serveru. | Ne | Ano | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| completedBy | Odkaz na to, kdo dokončil registraci | Ne | Ne | String:any | John Doe |
| followUp | Označuje, zda zápis vyžaduje následnou kontrolu. Nesprávné, pokud není dodáno | Ne | Ne | Booelan | Výchozí: False, True |
| smazáno | Označuje, zda byla registrace smazána. Může se změnit pouze při mazání. | Ne | Ano | Boolean | Nepravda, dokud nebude smazán |
| geometrie | A geographical representation of the enrollment. Based on the "featureType" of the Program | Ne | Ne | GeoJson | { "type": "POINT", "coordinates": [123.0, 123.0] } |
| storedBy | Client reference for who stored/created the enrollment. Set on the server. | Ne | Ano | String:Any | John Doe |
| createdBy | Pouze pro čtení dat. Uživatel, který objekt vytvořil. Nastaveno na serveru | Ne | Ano | Uživatel | { "uid": "ABCDEF12345", "username": "username", "firstName": "John", "surname": "Doe" } |
| updatedBy | Pouze pro čtení dat. Uživatel, který naposledy aktualizoval objekt. Nastavit na serveru | Ne | Ano | Uživatel | { "uid": "ABCDEF12345", "username": "username", "firstName": "John", "surname": "Doe" } |
| atributy | Seznam hodnot atributů trasovaných entit spojených s registrací. | Ne | Ne | Seznam TrackedEntityAttributeValue | Viz Atribut |
| Události | Seznam událostí vlastněných registrací. | Ne | Ne | Seznam událostí | Viz Událost |
| vztahy | Seznam vztahů spojených s registrací. | Ne | Ne | Seznam vztahů | Viz Vztah |
| poznámky | Poznámky spojené s registrací. Lze jej pouze vytvořit. | Ne | Ano | Seznam poznámek | Viz poznámka |
Note
Tracked Entities"owns" allTracked Entity Attribute Values(Or "attributes" as described in the previous table). However,Tracked Entity Attributesare either connected to aTracked Entitythrough itsTracked Entity Typeor aProgram. We often refer to this separation asTracked Entity Type AttributesandTracked Entity Program Attributes. The importance of this separation is related to access control and limiting what information the user can see.The "attributes" referred to in the
EnrollmentareTracked Entity Program Attributes.
Události¶
Events are either part of an EVENT PROGRAM or TRACKER PROGRAM. For TRACKER PROGRAM, events belong to an Enrollment, which again belongs to a Tracked Entity. On the other hand, EVENT PROGRAM is Events not connected to a specific Enrollment or Tracked Entity. The difference is related to whether we track a specific Tracked Entity or not. We sometimes refer to EVENT PROGRAM events as "anonymous events" or "single events" since they only represent themselves and not another Tracked Entity.
In the API, the significant difference is that all events are either connected to the same enrollment (EVENT PROGRAM) or different enrollments (TRACKER PROGRAM). The table below will point out any exceptional cases between these two.
| Vlastnictví | Popis | Požadované | Neměnný | Typ | Příklad |
|---|---|---|---|---|---|
| událost | Identifikátor události. Vygenerováno, pokud není dodáno | Ne | Ano | String:Uid | ABCDEF12345 |
| programStage | Fáze programu, kterou akce představuje. | Ano | Ne | String:Uid | ABCDEF12345 |
| zápis | A reference to the enrollment which owns the event. Not applicable for EVENT PROGRAM | Ano | Ano | String:Uid | ABCDEF12345 |
| program | Pouze pro čtení dat. Typ programu, který má registrace, která událost vlastní. | Ne | Ano | String:Uid | ABCDEF12345 |
| trackedEntity | Pouze pro čtení dat. Trasovaná entita, která událost vlastní. Neplatí pro PROGRAM AKCE | Ne | Ne | String:Uid | ABCDEF12345 |
| status | Stav události. AKTIVNÍ, pokud není součástí dodávky. | Ne | Ne | Výčet | AKTIVNÍ, DOKONČENÉ, NAVŠTÍVENÉ, PLÁNOVANÉ, PO TERMÍNU, PŘESKOČENO |
| enrollmentStatus | Only for reading data. The status of the enrollment which owns the event. Not applicable for EVENT PROGRAM | Ne | Ne | Výčet | AKTIVNÍ, DOKONČENO, ZRUŠENO |
| orgUnit | Organizační jednotka, kde uživatel zaregistroval událost. | Ano | Ne | String:Uid | ABCDEF12345 |
| createdAt | Only for reading data. Timestamp when the user created the event. Set on the server. | Ne | Ano | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| createdAtClient | Časové razítko, kdy uživatel vytvořil událost na klientovi | Ne | Ne | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| updatedAt | Only for reading data. Timestamp when the event was last updated. Set on the server. | Ne | Ano | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| updatedAtClient | Časové razítko, kdy byla událost naposledy aktualizována na klientovi | Ne | Ne | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| scheduledAt | Časové razítko, kdy byla událost naplánována. | Ne | Ano | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| occurredAt | Časové razítko, když se něco stalo. | Ano | Ano | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| completedAt | Časové razítko, kdy uživatel dokončil událost. Nastaveno na serveru. | Ne | Ano | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| completedBy | Odkaz na toho, kdo akci dokončil | Ne | Ne | String:Any | John Doe |
| followUp | Only for reading data. Indicates whether the event has been flagged for follow-up. | Ne | Ne | Boolean | False, True |
| smazáno | Only for reading data. Indicates whether the event has been deleted. It can only change when deleting. | Ne | Ano | Boolean | Nepravda, dokud nebude smazán |
| geometrie | A geographical representation of the event. Based on the "featureType" of the Program Stage | Ne | Ne | GeoJson | { "type": "POINT", "coordinates": [123.0, 123.0] } |
| storedBy | Client reference for who stored/created the event. Set on the server. | Ne | Ano | String:Any | John Doe |
| createdBy | Pouze pro čtení dat. Uživatel, který objekt vytvořil. Nastaveno na serveru | Ne | Ano | Uživatel | { "uid": "ABCDEF12345", "username": "username", "firstName": "John", "surname": "Doe" } |
| updatedBy | Pouze pro čtení dat. Uživatel, který naposledy aktualizoval objekt. Nastavit na serveru | Ne | Ano | Uživatel | { "uid": "ABCDEF12345", "username": "username", "firstName": "John", "surname": "Doe" } |
| attributeOptionCombo | Kombinace možností atributu pro událost. Výchozí, pokud není dodáno nebo nakonfigurováno. | Ne | Ne | String:Uid | ABCDEF12345 |
| attributeCategoryOptions | Možnost kategorie atributu pro událost. Výchozí, pokud není dodáno nebo nakonfigurováno. | Ne | Ne | String:Uid | ABCDEF12345 |
| assignedUser | Odkaz na uživatele, který byl přiřazen k události. | Ne | Ne | Uživatel | { "uid": "ABCDEF12345", "username": "username", "firstName": "John", "surname": "Doe" } |
| dataValues | Seznam datových hodnot spojených s událostí. | Ne | Ne | Seznam TrackedEntityAttributeValue | Viz Atribut |
| vztahy | Seznam vztahů spojených s událostí. | Ne | Ne | Seznam vztahů | Viz Vztah |
| poznámky | Poznámky spojené s událostí. Lze jej pouze vytvořit. | Ne | Ano | Seznam poznámek | Viz poznámka |
Vztahy¶
Relationships are objects that link together two other tracker objects. The constraints each side of the relationship must conform to are based on the Relationship Type of the Relationship.
| Vlastnictví | Popis | Požadované | Neměnný | Typ | Příklad |
|---|---|---|---|---|---|
| vztah | Identifikátor vztahu. Vygenerováno, pokud není dodáno. | Ne | Ano | String:Uid | ABCDEF12345 |
| relationshipType | Typ vztahu. Rozhoduje, jaké objekty mohou být spojeny ve vztahu. | Ano | Ano | String:Uid | ABCDEF12345 |
| relationshipName | Pouze pro čtení dat. Název typu vztahu tohoto vztahu | Ne | Ne | String:Any | Sourozenec |
| createdAt | Časové razítko, kdy uživatel vytvořil vztah. Nastaveno na serveru. | Ne | Ano | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| updatedAt | Časové razítko, kdy byl vztah naposledy aktualizován. Nastavuje se na serveru. | Ne | Ano | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| createdAtClient | Timestamp when the user created the relationship on the client. | Ne | Ano | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| obousměrný | Pouze pro čtení dat. Označuje, zda je typ vztahu obousměrný nebo ne. | Ne | Ne | Boolean | True nebo False |
| od, do | Odkaz na každou stranu vztahu. Musí odpovídat omezením nastaveným v typu vztahu | Ano | Ano | RelationshipItem | {"trackedEntity": {"trackedEntity": "ABCEF12345"}}, {"enrollment": {"enrollment": "ABCDEF12345"}} or {"event": {"event": "ABCDEF12345" }} |
Note
Relationship itemrepresents a link to an object. Since arelationshipcan be between any tracker object liketracked entity,enrollment, andevent, the value depends on therelationship type. For example, if arelationship typeconnects from aneventto atracked entity, the format is strict:
{ "from": { "event": { "event": "ABCDEF12345" } }, "to": { "trackedEntity": { "trackedEntity": "FEDCBA12345" } } }
Atributy¶
Attributes are the actual values describing the tracked entities. They can either be connected through a tracked entity type or a program. Implicitly this means attributes can be part of both a tracked entity and an enrollment.
| Vlastnictví | Popis | Požadované | Neměnný | Typ | Příklad |
|---|---|---|---|---|---|
| attribute | Odkaz na zastoupený atribut trasované entity. | Ano | Ano | String:Uid | ABCDEF12345 |
| code | Pouze pro čtení dat. Kód atributu trasované entity. | Ne | Ne | String:Any | ABC |
| displayName | Pouze pro čtení dat. DisplayName atributu trasované entity. | Ne | Ne | String:Any | Název |
| createdAt | Časové razítko, kdy byla hodnota přidána. Nastavit na serveru. | Ne | Ano | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| updatedAt | Časové razítko, kdy byla hodnota naposledy aktualizována. Nastavit na serveru. | Ne | Ano | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| storedBy | Client reference for who stored/created the value. Set on the server. | Ne | Ano | String:Any | John Doe |
| valueType | Pouze pro čtení dat. Typ hodnoty, kterou atribut představuje. | Ne | Ne | Výčet | TEXT, INTEGER a další |
| value | Hodnota atributu trasované entity. | Ne | Ne | String:Any | John Doe |
Note
For
attributesonly the "attribute" and "value" properties are required when adding data. "value" can be null, which implies the user should remove the value.In the context of tracker objects, we refer to
Tracked Entity AttributesandTracked Entity Attribute Valuesas "attributes". However, attributes are also their own thing, related to metadata. Therefore, it's vital to separate Tracker attributes and metadata attributes. In the tracker API, it is possible to reference the metadata attributes when specifyingidScheme(See request parameters for more information).
Data Values¶
Zatímco Attributes popisuje trasovanou entitu nebo zápis, datové hodnoty popisují událost. Hlavní rozdíl spočívá v tom, že atributy mohou mít pro danou trasovanou entitu pouze jednu hodnotu. Naproti tomu datové hodnoty mohou mít mnoho různých hodnot pro různé události - i když všechny události patří ke stejnému zápisu nebo trasované entitě.
| Vlastnictví | Popis | Požadované | Neměnný | Typ | Příklad |
|---|---|---|---|---|---|
| dataElement | Datový prvek, který tato hodnota představuje. | Ano | Ano | String:Uid | ABCDEF12345 |
| value | Hodnota datové hodnoty. | Ne | Ne | String:Any | 123 |
| providedElsewhere | Označuje, zda uživatel zadal hodnotu jinde nebo ne. Nesprávné, pokud není dodáno. | Ne | Ne | Boolean | False nebo True |
| createdAt | Časové razítko, kdy uživatel přidal hodnotu. Nastavit na serveru. | Ne | Ano | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| updatedAt | Časové razítko, kdy byla hodnota naposledy aktualizována. Nastavit na serveru. | Ne | Ano | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| storedBy | Client reference for who stored/created the value. Set on the server. | Ne | Ano | String:Any | John Doe |
| createdBy | Pouze pro čtení dat. Uživatel, který objekt vytvořil. Nastaveno na serveru | Ne | Ano | Uživatel | { "uid": "ABCDEF12345", "username": "username", "firstName": "John", "surname": "Doe" } |
| updatedBy | Pouze pro čtení dat. Uživatel, který naposledy aktualizoval objekt. Nastavit na serveru | Ne | Ano | Uživatel | { "uid": "ABCDEF12345", "username": "username", "firstName": "John", "surname": "Doe" } |
Note
For
data elementsonly the "dataElement" and "value" properties are required when adding data. "value" can be null, which implies the user should remove the value.
Poznámky¶
DHIS2 tracker allows for capturing of data using data elements and tracked entity attributes. However, sometimes there could be a situation where it is necessary to record additional information or comment about the issue at hand. Such additional information can be captured using notes. Notes are equivalent to data value comments from the Aggregate DHIS2 side.
There are two types of notes - notes recorded at the event level and those recorded at the enrollment level. An enrollment can have one or more events. Comments about each of the events - for example, why an event was missed, rescheduled, or why only a few data elements were filled and the like - can be documented using event notes. Each of the events within an enrollment can have its own story/notes. One can then record, for example, an overall observation of these events using the parent enrollment note. Enrollment notes are also helpful to document, for example, why an enrollment is canceled. It is the user's imagination and use-case when and how to use notes.
Both enrollment and event can have as many notes as needed - there is no limit. However, it is not possible to delete or update neither of these notes. They are like a logbook. If one wants to amend a note, one can do so by creating another note. The only way to delete a note is by deleting the parent object - either event or enrollment.
Notes do not have their dedicated endpoint; they are exchanged as part of the parent event and/or enrollment payload. Below is a sample payload.
{
"trackedEntity": "oi3PMIGYJH8",
"enrollments": [
{
"enrollment": "EbRsJr8LSSO",
"notes": [
{
"note": "vxmCvYcPdaW",
"value": "Enrollment note 2."
},
{
"value": "Enrollment note 1"
}
],
"events": [
{
"event": "zfzS9WeO0uM",
"notes": [
{
"note": "MAQFb7fAggS",
"value": "Event Note 1."
},
{
"value": "Event Note 2."
}
]
}
]
}
]
}
| Vlastnictví | Popis | Požadované | Neměnný | Typ | Příklad |
|---|---|---|---|---|---|
| Poznámka | Odkaz na poznámku. Vygenerováno, pokud je prázdné | Ne | Ano | String:Uid | ABCDEF12345 |
| value | Obsah poznámky. | Ano | Ano | String:Any | Toto je poznámka |
| storedAt | Časové razítko, kdy uživatel přidal poznámku. Nastavit na serveru. | Ne | Ano | Date:ISO 8601 | RRRR-MM-DDThh:mm:ss |
| storedBy | Client reference for who stored/created the note. Set on the server. | Ne | Ano | String:Any | John Doe |
| createdBy | Pouze pro čtení dat. Uživatel, který objekt vytvořil. Nastaveno na serveru | Ne | Ano | Uživatel | { "uid": "ABCDEF12345", "username": "username", "firstName": "John", "surname": "Doe" } |
Uživatelé¶
| Vlastnictví | Popis | Požadované | Neměnný | Typ | Příklad |
|---|---|---|---|---|---|
| uid | Identifikátor uživatele. | Yes* | Ano | String:Uid | ABCDEF12345 |
| uživatelské jméno | Uživatelské jméno používané uživatelem. | Yes* | Ano | String:Any | 123 |
| firstName | Pouze pro čtení dat. Křestní jméno uživatele. | Ne | Ano | String:Any | John |
| surname | Pouze pro čtení dat. Příjmení uživatele. | Ne | Ano | String:Any | Doe |
One between
uidorusernamefield must be provided. If both are provided, only username is considered.
Program stage working lists¶
The program stage working lists feature within the Capture app is designed to display pre-established working lists relevant to a particular program stage. This functionality enables users to save filters and sorting preferences that are related to program stages, facilitating the organisation and management of their workflow. To interact with them, you'll need to use the /api/programStageWorkingLists resource. These lists can be shared and follow the same sharing pattern as any other metadata. When using the /api/sharing the type parameter will be programStageWorkingLists.
/api/40/programStageWorkingLists
Payload on CRUD operations to program stage working lists¶
The endpoint above can be used to get all program stage working lists. To get a single one, just add at the end the id of the one you are interested in. This is the same in case you want to delete it. On the other hand, if you are looking to create or update a program stage working list, besides the endpoint mentioned above, you'll need to provide a payload in the following format:
Tabulka: Datový obsah
| Hodnoty datového obsahu | Popis | Příklad |
|---|---|---|
| název | Name of the working list. Required. | |
| popis | A description of the working list. | |
| program | Objekt obsahující id programu. Požadované. | {"id" : "uy2gU8kTjF"} |
| programStage | Object containing the id of the program stage. Required. | {"id" : "oRySG82BKE6"} |
| programStageQueryCriteria | An object representing various possible filtering values. See Program Stage Query Criteria definition table below. |
| Criteria values | Popis | Příklad |
|---|---|---|
| status | The event status. Possible values are ACTIVE, COMPLETED, VISITED, SCHEDULE, OVERDUE, SKIPPED and VISITED | "status":"VISITED" |
| eventCreatedAt | DateFilterPeriod object filtering based on the event creation date. | {"type":"ABSOLUTE","startDate":"2020-03-01","endDate":"2022-12-30"} |
| scheduledAt | DateFilterPeriod object filtering based on the event scheduled date. | {"type":"RELATIVE","period":"TODAY"} |
| enrollmentStatus | Any valid ProgramStatus. Possible values are ACTIVE, COMPLETED and CANCELLED. | "enrollmentStatus": "COMPLETED" |
| followUp | Indicates whether to filter enrollments marked for follow up or not | "followUp":true |
| enrolledAt | DateFilterPeriod object filtering based on the event enrollment date. | "enrolledAt": {"type":"RELATIVE","period":"THIS_MONTH"} |
| enrollmentOccurredAt | DateFilterPeriod object filtering based on the event occurred date. | {"type":"RELATIVE","period":"THIS_MONTH"} |
| orgUnit | A valid organisation unit UID | "orgUnit": "Rp268JB6Ne4" |
| ouMode | A valid OU selection mode | "ouMode": "SELECTED" |
| assignedUserMode | A valid user selection mode for events. Possible values are CURRENT, PROVIDED, NONE, ANY and ALL. If PROVIDED (or null), non-empty assignedUsers in the payload will be expected. | "assignedUserMode":"PROVIDED" |
| assignedUsers | A list of assigned users for events. To be used along with PROVIDED assignedUserMode above. | "assignedUsers":["DXyJmlo9rge"] |
| řazení | List of fields and its directions in comma separated values, the results will be sorted according to it. A single item in order is of the form "orderDimension:direction". | "order": "w75KJ2mc4zz:asc" |
| displayColumnOrder | Output ordering of columns | "displayColumnOrder":["w75KJ2mc4zz","zDhUuAYrxNC"] |
| dataFilters | A list of items that contains the filters to be used when querying events | "dataFilters":[{"dataItem": "GXNUsigphqK","ge": "10","le": "20"}] |
| attributeValueFilters | A list of attribute value filters. This is used to specify filters for attribute values when listing tracked entities | "attributeValueFilters":[{"attribute": "ruQQnf6rswq","eq": "15"}] |
See an example payload below:
{
"name":"Test WL",
"program":{"id":"uy2gU8kT1jF"},
"programStage":{"id":"oRySG82BKE6"},
"description": "Test WL definition",
"programStageQueryCriteria":
{
"status":"VISITED",
"eventCreatedAt":{"type":"ABSOLUTE","startDate":"2020-03-01","endDate":"2022-12-30"},
"scheduledAt": {"type":"RELATIVE","period":"TODAY"},
"enrollmentStatus": "COMPLETED",
"followUp" : true,
"enrolledAt": {"type":"RELATIVE","period":"THIS_MONTH"},
"enrollmentOccurredAt": {"type":"RELATIVE","period":"THIS_MONTH"},
"orgUnit": "Rp268JB6Ne4",
"ouMode": "SELECTED",
"assignedUserMode":"PROVIDED",
"assignedUsers":["DXyJmlo9rge"],
"order": "w75KJ2mc4zz:asc",
"displayColumnOrder":["w75KJ2mc4zz","zDhUuAYrxNC"],
"dataFilters":[{
"dataItem": "GXNUsigphqK",
"ge": "10",
"le": "20"
}],
"attributeValueFilters":[{
"attribute": "ruQQnf6rswq",
"eq": "15"
}]
}
}
Import trackeru (POST /api/tracker)¶
The POST /api/tracker endpoint allows clients to import the following tracker objects
- Trasované entity
- Zápisy
- Události
- Relationships
- Data vložená do jiných trasovacích objektů
Request parameters¶
V současné době koncový bod importu trackeru podporuje následující parametry:
| Název parametru | Popis | Typ | Povolené hodnoty |
|---|---|---|---|
| async | Označuje, zda má import probíhat asynchronně nebo synchronně. | Boolean | true, false |
| reportMode | Pouze při provádění synchronního importu. Další informace najdete v importSummary. | Výčet | FULL, ERRORS, WARNINGS |
| importMode | Can either be VALIDATE which will report errors in the payload without making changes to the database or COMMIT (default) which will validate the payload and make changes to the database. | Výčet | VALIDATE, COMMIT |
| idScheme | Označuje celkové idScheme, které se má použít pro odkazy na metadata při importu. Výchozí je UID. Lze přepsat pro konkrétní metadata (uvedeno níže) | Výčet | UID, CODE, NAME, ATTRIBUTE |
| dataElementIdScheme | Označuje idScheme, které se má použít pro datové prvky při importu. | Výčet | UID, CODE, NAME, ATTRIBUTE |
| orgUnitIdScheme | Označuje idScheme, které se má použít pro organizační jednotky při importu. | Výčet | UID, CODE, NAME, ATTRIBUTE |
| programIdScheme | Označuje idScheme, které se má použít pro programy při importu. | Výčet | UID, CODE, NAME, ATTRIBUTE |
| programStageIdScheme | Označuje idScheme, které se má použít pro fáze programu při importu. | Výčet | UID, CODE, NAME, ATTRIBUTE |
| categoryOptionComboIdScheme | Označuje idScheme, které se má použít pro kombinace možností kategorií při importu. | Výčet | UID, CODE, NAME, ATTRIBUTE |
| categoryOptionIdScheme | Označuje idScheme, které se má použít pro možnosti kategorií při importu. | Výčet | UID, CODE, NAME, ATTRIBUTE |
| importStrategy | Označuje účinek, který by měl import mít. Může být CREATE, UPDATE, CREATE_AND_UPDATE a DELETE, což umožňuje pouze import nových dat, import změn existujících dat, import jakýchkoli nových nebo aktualizací existujících dat a nakonec smazání dat. | Výčet | CREATE, UPDATE, CREATE_AND_UPDATE, DELETE |
| atomicMode | Indicates how the import responds to validation errors. If ALL, all data imported must be valid for any data to be committed. For OBJECT, only the data committed needs to be valid, while other data can be invalid. | Výčet | ALL, OBJECT |
| flushMode | Udává frekvenci pročištění. To souvisí s tím, jak často jsou data vkládána do databáze během importu. Primárně se používá z důvodů ladění a nemělo by se měnit v produkčním nastavení | Výčet | AUTO, OBJECT |
| validationMode | Označuje úplnost kroku ověření. Lze jej přeskočit, nastavit na rychlé selhání (Návrat při první chybě) nebo úplné (Výchozí), které vrátí všechny nalezené chyby | Výčet | FULL, FAIL_FAST, SKIP |
| skipPatternValidation | Pokud je true, přeskočí ověřování vzoru generovaných atributů. | Boolean | true, false |
| skipSideEffects | Pokud je true, přeskočí se spuštění jakýchkoli vedlejších efektů importu | Boolean | true, false |
| skipRuleEngine | Pokud je true, přeskočí spuštění jakýchkoli programových pravidel pro import | Boolean | true, false |
NOTE: idScheme and its metadata specific idScheme parameters like orgUnitIdScheme, programIdScheme, ... used to allow and use the default AUTO. AUTO has been removed. The default idScheme has already been UID. Any requests sent with idScheme AUTO will see the same behavior as before, namely matching done using UID.
Flat and nested payloads¶
The importer support both flat and nested payloads.
- Flat
- The flat payload can contain collections for each of the core tracker objects we have at the
- top level. This works seamlessly with existing data, which already have UIDs assigned. However,
- for new data, the client will have to provide new UIDs for any references between objects. For
- example, if you import a new tracked entity with a new enrollment, the tracked entity requires
- the client to provide a UID so that the enrollment can be linked to that UID.
- Nested
- Nested payloads are the most commonly used structure. Here, tracker objects are embedded within
- their parent object. For example, an enrollment within a tracked entity. The advantage of this
- structure is that the client does not need to provide UIDs for these references as this is done
- automatically.
NOTE
While nested payloads might prove simpler for clients to deal with, the payload will always be flattened before the import. This means that for large imports, providing a flat structured payload will provide both more control and lower overhead for the import process itself.
Examples for the FLAT and the NESTED versions of the payload are listed below.
FLAT payload¶
{
"trackedEntities": [
{
"orgUnit": "y77LiPqLMoq",
"trackedEntity": "Kj6vYde4LHh",
"trackedEntityType": "nEenWmSyUEp"
},
{
"orgUnit": "y77LiPqLMoq",
"trackedEntity": "Gjaiu3ea38E",
"trackedEntityType": "nEenWmSyUEp"
}
],
"enrollments": [
{
"enrolledAt": "2019-08-19T00:00:00.000",
"enrollment": "MNWZ6hnuhSw",
"occurredAt": "2019-08-19T00:00:00.000",
"orgUnit": "y77LiPqLMoq",
"program": "IpHINAT79UW",
"status": "ACTIVE",
"trackedEntity": "Kj6vYde4LHh",
"trackedEntityType": "nEenWmSyUEp"
}
],
"events": [
{
"attributeCategoryOptions": "xYerKDKCefk",
"attributeOptionCombo": "HllvX50cXC0",
"dataValues": [
{
"dataElement": "bx6fsa0t90x",
"value": "true"
},
{
"dataElement": "UXz7xuGCEhU",
"value": "5.7"
}
],
"enrollment": "MNWZ6hnuhSw",
"enrollmentStatus": "ACTIVE",
"event": "ZwwuwNp6gVd",
"occurredAt": "2019-08-01T00:00:00.000",
"orgUnit": "y77LiPqLMoq",
"program": "IpHINAT79UW",
"programStage": "A03MvHHogjR",
"scheduledAt": "2019-08-19T13:59:13.688",
"status": "ACTIVE",
"trackedEntity": "Kj6vYde4LHh"
},
{
"attributeCategoryOptions": "xYerKDKCefk",
"attributeOptionCombo": "HllvX50cXC0",
"enrollment": "MNWZ6hnuhSw",
"enrollmentStatus": "ACTIVE",
"event": "XwwuwNp6gVE",
"occurredAt": "2019-08-01T00:00:00.000",
"orgUnit": "y77LiPqLMoq",
"program": "IpHINAT79UW",
"programStage": "ZzYYXq4fJie",
"scheduledAt": "2019-08-19T13:59:13.688",
"status": "ACTIVE",
"trackedEntity": "Kj6vYde4LHh"
}
],
"relationships": [
{
"from": {
"trackedEntity": {
"trackedEntity": "Kj6vYde4LHh"
}
},
"relationshipType": "dDrh5UyCyvQ",
"to": {
"trackedEntity": {
"trackedEntity": "Gjaiu3ea38E"
}
}
}
]
}
NESTED payload¶
{
"trackedEntities": [
{
"enrollments": [
{
"attributes": [
{
"attribute": "zDhUuAYrxNC",
"displayName": "Last name",
"value": "Kelly"
},
{
"attribute": "w75KJ2mc4zz",
"displayName": "First name",
"value": "John"
}
],
"enrolledAt": "2019-08-19T00:00:00.000",
"events": [
{
"attributeCategoryOptions": "xYerKDKCefk",
"attributeOptionCombo": "HllvX50cXC0",
"dataValues": [
{
"dataElement": "bx6fsa0t90x",
"value": "true"
},
{
"dataElement": "UXz7xuGCEhU",
"value": "5.7"
}
],
"enrollmentStatus": "ACTIVE",
"notes": [
{
"value": "need to follow up"
}
],
"occurredAt": "2019-08-01T00:00:00.000",
"orgUnit": "y77LiPqLMoq",
"program": "IpHINAT79UW",
"programStage": "A03MvHHogjR",
"scheduledAt": "2019-08-19T13:59:13.688",
"status": "ACTIVE"
}
],
"occurredAt": "2019-08-19T00:00:00.000",
"orgUnit": "y77LiPqLMoq",
"program": "IpHINAT79UW",
"status": "ACTIVE",
"trackedEntityType": "nEenWmSyUEp"
}
],
"orgUnit": "y77LiPqLMoq",
"trackedEntityType": "nEenWmSyUEp"
}
]
}
SYNC and ASYNC¶
For the user, the main difference between importing synchronously rather than asynchronously is the immediate response from the API. For the synchronous import, the response will be returned as soon as the import finishes with the importSummary. However, for asynchronous imports, the response will be immediate and contain a reference where the client can poll for updates to the import.
For significant imports, it might be beneficial for the client to use the asynchronous import to avoid waiting too long for a response.
Examples of the ASYNC response is shown below. For SYNC response, look at the importSummary section.
{
"httpStatus": "OK",
"httpStatusCode": 200,
"status": "OK",
"message": "Tracker job added",
"response": {
"id": "cHh2OCTJvRw",
"location": "https://play.im.dhis2.org/dev/api/tracker/jobs/cHh2OCTJvRw"
}
}
CSV import¶
To import events using CSV make a POST request with CSV body file and the Content-Type set to application/csv or text/csv.
Události¶
Every row of the CSV payload represents an event and a data value. So, for events with multiple data values, the CSV file will have x rows per event, where x is the number of data values in that event.
CSV PAYLOAD example¶
Your CSV file can look like:
event,status,program,programStage,enrollment,orgUnit,occurredAt,scheduledAt,geometry,latitude,longitude,followUp,deleted,createdAt,createdAtClient,updatedAt,updatedAtClient,completedBy,completedAt,updatedBy,attributeOptionCombo,attributeCategoryOptions,assignedUser,dataElement,value,storedByDataValue,updatedAtDataValue,createdAtDataValue
A7rzcnZTe2T,ACTIVE,eBAyeGv0exc,Zj7UnCAulEk,RiLEKhWHlxZ,DwpbWkiqjMy,2023-02-12T23:00:00Z,2023-02-12T23:00:00Z,"POINT (-11.468912037323042 7.515913998868316)",7.515913998868316,-11.468912037323042,false,false,2017-09-08T19:40:22Z,,2017-09-08T19:40:22Z,,,,,HllvX50cXC0,xYerKDKCefk,,F3ogKBuviRA,"[-11.4880220438585,7.50978830548003]",false,,2016-12-06T17:22:34.438Z,2016-12-06T17:22:34.438Z
See Events CSV in the export section for a more detailed definition of the CSV fields.
Souhrn importu¶
The Tracker API has two primary endpoints for consumers to acquire feedback from their imports. These endpoints are most relevant for async import jobs but are available for sync jobs as well. These endpoints will return either the log related to the import or the import summary itself.
Note
These endpoints rely on information stored in the application memory. This means the information will be unavailable after certain cases, as an application restart or after a large number of import requests have started after this one.
After submitting a tracker import request, we can access the following endpoints in order to monitor the job progress based on logs:
GET /tracker/jobs/{uid}
| Parametr | Popis | Příklad |
|---|---|---|
{uid} | UID existující úlohy importu trackeru | ABCDEF12345 |
REQUEST example¶
GET /tracker/jobs/PQK63sMwjQp
RESPONSE example¶
[
{
"uid": "PQK63sMwjQp",
"level": "INFO",
"category": "TRACKER_IMPORT_JOB",
"time": "2024-03-19T13:18:16.370",
"message": "Import complete with status OK, 0 created, 0 updated, 0 deleted, 0 ignored",
"completed": true,
"id": "PQK63sMwjQp"
},
{
"uid": "XIfTJ1UUNcd",
"level": "INFO",
"category": "TRACKER_IMPORT_JOB",
"time": "2024-03-19T13:18:16.369",
"message": "PostCommit",
"completed": false,
"id": "XIfTJ1UUNcd"
},
{
"uid": "uCG4FNJLLBJ",
"level": "INFO",
"category": "TRACKER_IMPORT_JOB",
"time": "2024-03-19T13:18:16.364",
"message": "Commit Transaction",
"completed": false,
"id": "uCG4FNJLLBJ"
},
{
"uid": "xfOUv2Lk2MC",
"level": "INFO",
"category": "TRACKER_IMPORT_JOB",
"time": "2024-03-19T13:18:16.361",
"message": "Running Rule Engine Validation",
"completed": false,
"id": "xfOUv2Lk2MC"
},
{
"uid": "cSPfA776obb",
"level": "INFO",
"category": "TRACKER_IMPORT_JOB",
"time": "2024-03-19T13:18:16.325",
"message": "Running Rule Engine",
"completed": false,
"id": "cSPfA776obb"
},
{
"uid": "mru3HJrFGKA",
"level": "INFO",
"category": "TRACKER_IMPORT_JOB",
"time": "2024-03-19T13:18:16.313",
"message": "Running Validation",
"completed": false,
"id": "mru3HJrFGKA"
},
{
"uid": "oTbCUJ2RnA6",
"level": "INFO",
"category": "TRACKER_IMPORT_JOB",
"time": "2024-03-19T13:18:16.312",
"message": "Running PreProcess",
"completed": false,
"id": "oTbCUJ2RnA6"
},
{
"uid": "lcUNbWTn6uh",
"level": "INFO",
"category": "TRACKER_IMPORT_JOB",
"time": "2024-03-19T13:18:16.312",
"message": "Calculating Payload Size",
"completed": false,
"id": "lcUNbWTn6uh"
},
{
"uid": "l4jQiSS9qdK",
"level": "INFO",
"category": "TRACKER_IMPORT_JOB",
"time": "2024-03-19T13:18:15.903",
"message": "Running PreHeat",
"completed": false,
"id": "l4jQiSS9qdK"
},
{
"uid": "qGbiuqgwPX5",
"level": "INFO",
"category": "TRACKER_IMPORT_JOB",
"time": "2024-03-19T13:18:15.850",
"message": "Loading file content",
"completed": false,
"id": "qGbiuqgwPX5"
},
{
"uid": "eWNHzVf7iAj",
"level": "INFO",
"category": "TRACKER_IMPORT_JOB",
"time": "2024-03-19T13:18:15.838",
"message": "Loading file resource",
"completed": false,
"id": "eWNHzVf7iAj"
},
{
"uid": "t9gOjotekQt",
"level": "INFO",
"category": "TRACKER_IMPORT_JOB",
"time": "2024-03-19T13:18:15.837",
"message": "Tracker import started",
"completed": false,
"dataType": "PARAMETERS",
"data": {
"userId": "xE7jOejl9FI",
"importMode": "VALIDATE",
"idSchemes": {
"dataElementIdScheme": {
"idScheme": "UID",
"attributeUid": null
},
"orgUnitIdScheme": {
"idScheme": "UID",
"attributeUid": null
},
"programIdScheme": {
"idScheme": "UID",
"attributeUid": null
},
"programStageIdScheme": {
"idScheme": "UID",
"attributeUid": null
},
"idScheme": {
"idScheme": "UID",
"attributeUid": null
},
"categoryOptionComboIdScheme": {
"idScheme": "UID",
"attributeUid": null
},
"categoryOptionIdScheme": {
"idScheme": "UID",
"attributeUid": null
}
},
"importStrategy": "CREATE_AND_UPDATE",
"atomicMode": "ALL",
"flushMode": "AUTO",
"validationMode": "FULL",
"skipPatternValidation": false,
"skipSideEffects": false,
"skipRuleEngine": false,
"filename": null,
"reportMode": "ERRORS"
},
"id": "t9gOjotekQt"
}
]
Additionally, the following endpoint will return the import summary of the import job. This import summary will only be available after the import has completed:
GET /tracker/jobs/{uid}/report
| Parametr | Popis | Příklad |
|---|---|---|
path /{uid} | The UID of an existing tracker import job. | ABCDEF12345 |
reportMode | The level of detail the report should have. | FULL|ERRORS|WARNINGS |
REQUEST example¶
GET /tracker/jobs/mEfEaFSCKCC/report
RESPONSE example¶
The response payload is the same as the one returned after a sync import request.
Note
Both endpoints are used primarily for async import; however,
GET /tracker/jobs/{uid}would also work for sync requests as it eventually uses the same import process and logging as async requests.
Import Summary Structure¶
Souhrny importu mají v závislosti na požadovaném reportMode následující celkovou strukturu:
{
"status": "OK",
"validationReport": {
"errorReports": [],
"warningReports": []
},
"stats": {
"created": 3,
"updated": 0,
"deleted": 0,
"ignored": 0,
"total": 3
},
"bundleReport": {
"typeReportMap": {
"EVENT": {
"trackerType": "EVENT",
"stats": {
"created": 1,
"updated": 0,
"deleted": 0,
"ignored": 0,
"total": 1
},
"objectReports": [
{
"trackerType": "EVENT",
"uid": "gTZBPT3Jq39",
"errorReports": []
}
]
},
"ENROLLMENT": {
"trackerType": "ENROLLMENT",
"stats": {
"created": 1,
"updated": 0,
"deleted": 0,
"ignored": 0,
"total": 1
},
"objectReports": [
{
"trackerType": "ENROLLMENT",
"uid": "ffcvJvWjiNZ",
"errorReports": []
}
]
},
"RELATIONSHIP": {
"trackerType": "RELATIONSHIP",
"stats": {
"created": 0,
"updated": 0,
"deleted": 0,
"ignored": 0,
"total": 0
},
"objectReports": []
},
"TRACKED_ENTITY": {
"trackerType": "TRACKED_ENTITY",
"stats": {
"created": 1,
"updated": 0,
"deleted": 0,
"ignored": 0,
"total": 1
},
"objectReports": [
{
"trackerType": "TRACKED_ENTITY",
"uid": "aVcGf9iO8Xp",
"errorReports": []
}
]
}
}
}
}
status
The property, status, of the import summary indicates the overall status of the import. If no errors or warnings were raised during the import, the status is reported as OK. The presence of any error or warnings in the import will result in a status of type ERROR or WARNING.
status is based on the presence of the most significant validationReport. ERROR has the highest significance, followed by WARNING and finally OK. This implies that ERROR is reported as long as a single error was found during the import, regardless of how many warnings occurred.
Note
If the import is performed using the AtomicMode "OBJECT", where the import will import any data without validation errors, the overall status will still be
ERRORif any errors were found.
validationReport
The validationReport might include errorReports and warningReports if any errors or warnings were present during the import. When present, they provide a detailed list of any errors or warnings encountered.
Například chyba ověření při importu TRACKED_ENTITY:
{
"validationReport": {
"errorReports": [
{
"message": "Could not find TrackedEntityType: `Q9GufDoplCL`.",
"errorCode": "E1005",
"trackerType": "TRACKED_ENTITY",
"uid": "Kj6vYde4LHh"
},
...
],
"warningReports" : [ ... ]
}
}
The report contains a message and a code describing the actual error (See the error codes section for more information about errors). Additionally, the report includes the trackerType and uid, which aims to describe where in the data the error was found. In this case, there was a TRACKED_ENTITY with the uid Kj6vYde4LHh, which had a reference to a tracked entity type that was not found.
Note
When referring to the
uidof tracker objects, they are labeled as their object names in the payload. For example, theuidof a tracked entity would in the payload have the name "trackedEntity". The same goes for "enrollment", "event" and "relationship" for enrollments, events, and relationships, respectively.If no uid is provided in the payload, the import process will generate new uids. This means the error report might refer to a uid that does not exist in your payload.
Errors represent issues with the payload which the importer can not circumvent. Any errors will block that data from being imported. Warnings, on the other hand, are issues where it's safe to circumvent them, but the user should be made aware that it happened. Warnings will not block data from being imported.
stats
The stats provide a quick overview of the import. After an import is completed, these will be the actual counts representing how much data was created, updated, deleted, or ignored.
Příklad:
{
"stats": {
"created": 2,
"updated": 2,
"deleted": 1,
"ignored": 5,
"total": 10
}
}
created refers to how many new objects were created. In general, objects without an existing uid in the payload will be treated as new objects.
updated refers to the number of objects updated. If an object has a uid set in the payload, it will be treated as an update as long as that same uid exists in the database.
deleted refers to the number of objects deleted during the import. Deletion only happens when the import is configured to delete data and only then when the objects in the payload have existing uids set.
ignored refers to objects that were not persisted. Objects can be ignored for several reasons, for example trying to create something that already exists. Ignores should always be safe, so if something was ignored, it was not necessary, or it was due to the configuration of the import.
bundleReport
When the import is completed, the bundleReport contains all the tracker objects imported.
Například TRACKED_ENTITY:
{
"bundleReport": {
"typeReportMap": {
"TRACKED_ENTITY": {
"trackerType": "TRACKED_ENTITY",
"stats": {
"created": 1,
"updated": 0,
"deleted": 0,
"ignored": 0,
"total": 1
},
"objectReports": [
{
"trackerType": "TRACKED_ENTITY",
"uid": "aVcGf9iO8Xp",
"errorReports": []
}
]
}
}
}
}
As seen, each type of tracker object will be reported, and each has its own stats and objectReports. These objectReports will provide details about each imported object, like their type, their uid, and any error or warning reports is applicable.
message
If the import ended abruptly, the message would contain further information in relation to what happened.
Import Summary Report Level¶
As previously stated, GET /tracker/jobs/{uid}/report can be retrieved using a specific reportMode parameter. By default the endpoint will return an importSummary with reportMode ERROR.
| Parametr | Popis |
|---|---|
FULL | Vrátí vše z WARNINGS plus timingsStats |
WARNINGS | Vrátí vše z ERRORS plus warningReports v validationReports |
ERRORS (výchozí) | Vrací pouze errorReports v validationReports |
In addition, all reportModes will return status, stats, bundleReport and message when applicable.
Kódy chyb¶
There are various error codes for different error scenarios. The following table has the list of error codes thrown from the new Tracker API, along with the error messages and some additional descriptions. The placeholders in the error messages ({0},{1},{2}..) are usually uids unless otherwise specified.
| Chybový kód | Chybové hlášení | Popis |
|---|---|---|
| E1000 | Uživatel: {0}, nemá přístup k zápisu do OrganisationUnit: {1}. | Obvykle to znamená, že organizační jednotka {1} není v rozsahu zachycení uživatele {0}, aby byla operace zápisu autorizována. |
| E1001 | Uživatel: {0}, nemá přístup k zápisu dat do TrackedEntityType: {1}. | The error occurs when the user is not authorized to create or modify data of the TrackedEntityType {1} |
| E1002 | TrackedEntity: {0}, already exists. | Tato chyba je vyvolána při pokusu o vytvoření nové TrackedEntity s již existujícím uid. Ujistěte se, že se při přidávání nové TrackedEntity používá nové uid. |
| E1003 | User: {0}, has no write access to TrackedEntity: {1}. | |
| E1005 | Nelze najít TrackedEntityType: {0}. | Error thrown when trying to fetch a non existing TrackedEntityType with uid {0} . This might also mean that the user does not have read access to the TrackedEntityType. |
| E1006 | Atribut: {0}, neexistuje. | Error thrown when the system was not able to find a matching TrackedEntityAttribute with uid {0}. This might also mean that the user does not have access to the TrackedEntityAttribute. |
| E1007 | Chyba při ověřování typu hodnoty atributu: {0}; Chyba: {1}. | Mismatch between value type of a TrackedEntityAttribute and its provided attribute value. The actual validation error will be displayed in {1}. |
| E1008 | Program stage {0} has no reference to a program. Check the program stage configuration | |
| E1009 | Zdroj souboru: {0}, již byl přiřazen k jinému objektu. | Uid prostředku souboru {0} je již přiřazen k jinému objektu v systému. |
| E1010 | Nelze najít program: {0}, propojený s událostí. | Systém nemohl najít program s uid {0} zadaným uvnitř datové části události. To může také znamenat, že konkrétní Program není přihlášenému uživateli přístupný. |
| E1011 | Could not find OrganisationUnit: {0}, linked to Event. | Systém nemohl najít Organizační jednotku s uid {0} zadaným uvnitř datové části události. |
| E1012 | Geometrie neodpovídá FeatureType: {0}. | Zadaný FeatureType je buď NONE, nebo je pro zadanou hodnotu geometrie nekompatibilní. |
| E1013 | Could not find ProgramStage: {0}, linked to Event. | The system was unable to find a ProgramStage with uid {0} specified inside the Event payload. This might also mean that the ProgramStage is not accessible to the logged in user. |
| E1014 | Provided Program: {0}, is a Program without registration. An Enrollment cannot be created into Program without registration. | Enrollments can only be created for Programs with registration. |
| E1015 | TrackedEntity: {0}, already has an active Enrollment in Program {1}. | Cannot enroll into a Program if another active enrollment already exists for the Program. The active enrollment will have to be completed first at least. |
| E1016 | TrackedEntity: {0}, already has an active enrollment in Program: {1}, and this program only allows enrolling one time. | As per the Program {1} configuration, a TrackedEntity can only be enrolled into that Program once. It looks like the TrackedEntity {0} already has either an ACTIVE or COMPLETED enrollment in that Program. Hence another enrollment cannot be added. |
| E1018 | Attribute: {0}, is mandatory in program {1} but not declared in enrollment {2}. | Attribute value is missing in payload, for an attribute that is defined as mandatory for a Program. Make sure that attribute values for mandatory attributes are provided in the payload. |
| E1019 | Only Program attributes is allowed for enrollment; Non valid attribute: {0}. | Attribute uid {0} specified in the enrollment payload is not associated with the Program. |
| E1020 | Enrollment date: {0}, can`t be future date. | Cannot enroll into a future date unless the Program allows for it in its configuration. |
| E1021 | Incident date: {0}, can`t be future date. | Incident date cannot be a future date unless the Program allows for it in its configuration. |
| E1022 | TrackedEntity: {0}, must have same TrackedEntityType as Program {1}. | The Program is configured to accept TrackedEntityType uid that is different from what is provided in the enrollment payload. |
| E1023 | DisplayIncidentDate is true but property occurredAt is null or has an invalid format: {0}. | Program is configured with DisplayIncidentDate but its either null or an invalid date in the payload. |
| E1025 | Property enrolledAt is null or has an invalid format: {0}. | EnrolledAt Date is mandatory for an Enrollment. Make sure it is not null and has a valid date format. |
| E1029 | Event OrganisationUnit: {0}, and Program: {1}, don't match. | The Event payload uses a Program {1} which is not configured to be accessible by OrganisationUnit {0}. |
| E1030 | Událost: {0}, již existuje. | Tato chyba je vyvolána při pokusu o přidání nové události s již existujícím uid. Ujistěte se, že je při přidávání nové události použito nové uid. |
| E1031 | Event occurredAt date is missing. | OccurredAt property is either null or has an invalidate date format in the payload. |
| E1032 | Událost: {0}, neexistuje. | |
| E1033 | Událost: {0}, hodnota zápisu je NULL. | |
| E1035 | Událost: {0}, hodnota ProgramStage je NULL. | |
| E1039 | ProgramStage: {0}, nelze opakovat a událost již existuje. | Událost pro ProgramStage pro konkrétní registraci již existuje. Protože je ProgramStage nakonfigurován jako neopakovatelný, nelze přidat další událost pro stejnou ProgramStage. |
| E1041 | Zápis OrganisationUnit: {0} a Program: {1}, nesouhlasí. | The Enrollment payload contains a Program {1} which is not configured to be accessible by the OrganisationUnit {0}. |
| E1042 | Událost: {0}, musí mít datum dokončení. | Pokud je program nakonfigurován tak, aby měl completeExpiryDays, je CompletedDate povinné pro datový obsah události COMPLETED. Událost se stavem COMPLETED by měla mít vlastnost CompleteDate jinou než nulovou a platný formát data. |
| E1043 | Event: {0}, completeness date has expired. Not possible to make changes to this event. | A user without 'F_EDIT_EXPIRED' authority cannot update an Event that has passed its expiry days as configured in its Program. |
| E1046 | Event: {0}, needs to have at least one (event or schedule) date. | Either of occuredAt or scheduledAt property should be present in the Event payload. |
| E1047 | Event: {0}, date belongs to an expired period. It is not possible to create such event. | Event occuredAt or scheduledAt has a value that is earlier than the PeriodType start date. |
| E1048 | Objekt: {0}, uid: {1}, má neplatný formát uid. | A valid uid has 11 characters. The first character has to be an alphabet (a-z or A-Z) and the remaining 10 characters can be alphanumeric (a-z or A-Z or 0-9). |
| E1049 | Could not find OrganisationUnit: {0}, linked to Tracked Entity. | Systém nemohl najít Organizační jednotku s uid {0}. |
| E1050 | Event ScheduledAt date is missing. | ScheduledAt property in the Event payload is either missing or an invalid date format. |
| E1054 | AttributeOptionCombo {0} is not in the event programs category combo {1}. | |
| E1055 | Default AttributeOptionCombo is not allowed since program has non-default CategoryCombo. | The Program is configured to contain non-default CategoryCombo but the request uses the Default AttributeOptionCombo. |
| E1056 | Event date: {0}, is before start date: {1}, for AttributeOption: {2}. | The CategoryOption has a start date configured , the Event date in the payload cannot be earlier than this start date. |
| E1057 | Event date: {0}, is after end date: {1}, for AttributeOption; {2}. | The CategoryOption has an end date configured, the Event date in the payload cannot be later than this end date. |
| E1063 | TrackedEntity: {0}, does not exist. | Error thrown when trying to fetch a non existing TrackedEntity with uid {0} . This might also mean that the user does not have read access to the TrackedEntity. |
| E1064 | Non-unique attribute value {0} for attribute {1} | The attribute value has to be unique within the defined scope. The error indicates that the attribute value already exists for another TrackedEntity. |
| E1068 | Could not find TrackedEntity: {0}, linked to Enrollment. | The system could not find the TrackedEntity specified in the Enrollment payload. This might also mean that the user does not have read access to the TrackedEntity. |
| E1069 | Could not find Program: {0}, linked to Enrollment. | The system could not find the Program specified in the Enrollment payload. This might also mean that the user does not have read access to the Program. |
| E1070 | Could not find OrganisationUnit: {0}, linked to Enrollment. | The system could not find the OrganisationUnit specified in the Enrollment payload. |
| E1074 | FeatureType is missing. | |
| E1075 | Atribut: {0}, chybí uid. | |
| E1076 | {0} {1} is mandatory and can't be null | |
| E1077 | Attribute: {0}, text value exceed the maximum allowed length: {0}. | |
| E1079 | Event: {0}, program: {1} is different from program defined in enrollment {2}. | |
| E1080 | Enrollment: {0}, already exists. | Tato chyba je vyvolána při pokusu o vytvoření nového Zápisu s již existujícím uid. Při přidávání nového Zápisu se ujistěte, že je použito nové uid. |
| E1081 | Zápis: {0}, neexistuje. | Error thrown when trying to fetch a non existing Enrollment with uid {0} . This might also mean that the user does not have read access to the Enrollment. |
| E1082 | Event: {0}, is already deleted and can't be modified. | If the event is soft deleted, no modifications on it are allowed. |
| E1083 | User: {0}, is not authorized to modify completed events. | Only a super user or a user with the authority "F_UNCOMPLETE_EVENT" can modify completed events. Completed Events are those Events with status as COMPLETED. |
| E1084 | File resource: {0}, reference could not be found. | |
| E1085 | Attribute: {0}, value does not match value type: {1}. | Mismatch between value type of an attribute and its provided attribute value. |
| E1089 | Event: {0}, references a Program Stage {1} that does not belong to Program {2}. | The ProgramStage uid and Program uid in the Event payload is incompatible. |
| E1090 | Atribut: {0}, je povinný v typu trasované entity {1}, ale není deklarován ve trasované entitě {2}. | The payload has missing values for mandatory TrackedEntityTypeAttributes. |
| E1091 | User: {0}, has no data write access to Program: {1}. | The Program sharing configuration is such that, the user does not have write access for this Program. |
| E1095 | User: {0}, has no data write access to ProgramStage: {1}. | The ProgramStage sharing configuration is such that, the user does not have write access for this ProgramStage. |
| E1096 | User: {0}, has no data read access to Program: {1}. | The Program sharing configuration is such that, the user does not have read access for this Program. |
| E1099 | User: {0}, has no write access to CategoryOption: {1}. | The CategoryOption sharing configuration is such that, the user does not have write access for this CategoryOption |
| E1100 | User: {0}, is lacking 'F_TEI_CASCADE_DELETE' authority to delete TrackedEntity: {1}. | There exists undeleted Enrollments for this TrackedEntity. If the user does not have 'F_TEI_CASCADE_DELETE' authority, then these Enrollments has to be deleted first explicitly to be able to delete the TrackedEntity. |
| E1102 | User: {0}, does not have access to the tracked entity: {1}, Program: {2}, combination. | This error is thrown when the user's OrganisationUnit does not have the ownership of this TrackedEntity for this specific Program. The owning OrganisationUnit of the TrackedEntity-Program combination should fall into the capture scope (in some cases the search scope) of the user. |
| E1103 | User: {0}, is lacking 'F_ENROLLMENT_CASCADE_DELETE' authority to delete Enrollment : {1}. | Pro tento zápis existují nesmazané události. Pokud uživatel nemá oprávnění 'F_ENROLLMENT_CASCADE_DELETE', musí být tyto události nejprve explicitně vymazány, aby bylo možné vymazat zápis. |
| E1104 | User: {0}, has no data read access to program: {1}, TrackedEntityType: {2}. | The sharing configuration of the TrackedEntityType associated with the Program is such that, the user does not have data read access to it. |
| E1112 | Attribute value: {0}, is set to confidential but system is not properly configured to encrypt data. | Either JCE files is missing or the configuration property encryption.password might be missing in dhis.conf. |
| E1113 | Enrollment: {0}, is already deleted and can't be modified. | If the Enrollment is soft deleted, no modifications on it are allowed. |
| E1114 | TrackedEntity: {0}, is already deleted and can't be modified. | If the TrackedEntity is soft deleted, no modifications on it are allowed. |
| E1115 | Could not find CategoryOptionCombo: {0}. | |
| E1116 | Could not find CategoryOption: {0}. | This might also mean the CategoryOption is not accessible to the user. |
| E1117 | CategoryOptionCombo does not exist for given category combo and category options: {0}. | |
| E1118 | Assigned user {0} is not a valid uid. | |
| E1119 | A Tracker Note with uid {0} already exists. | |
| E1120 | ProgramStage {0} does not allow user assignment | Datový obsah události má assignedUserId, ale ProgramStage není nakonfigurován tak, aby umožňoval přiřazení uživatele. |
| E1121 | Missing required tracked entity property: {0}. | |
| E1122 | Missing required enrollment property: {0}. | |
| E1123 | Missing required event property: {0}. | |
| E1124 | Missing required relationship property: {0}. | |
| E1125 | Value {0} is not a valid option code in option set {1} | |
| E1126 | Not allowed to update Tracked Entity property: {0}. | |
| E1127 | Not allowed to update Enrollment property: {0}. | |
| E1128 | Not allowed to update Event property: {0}. | |
| E1300 | Generated by program rule ({0}) - {1} | |
| E1301 | Generated by program rule ({0}) - Mandatory DataElement {1} is not present | |
| E1302 | DataElement {0} is not valid: {1} | |
| E1303 | Mandatory DataElement {0} is not present | |
| E1304 | DataElement {0} is not a valid data element | |
| E1305 | DataElement {0} is not part of {1} program stage | |
| E1306 | Vygenerováno programovým pravidlem ({0}) – povinný atribut {1} není přítomen | |
| E1307 | Generováno programovým pravidlem ({0}) – Nelze přiřadit hodnotu datovému prvku {1}. Zadaná hodnota musí být prázdná nebo odpovídat vypočítané hodnotě {2} | |
| E1308 | Generováno programovým pravidlem ({0}) – DataElement {1} je nahrazen v události {2} | |
| E1309 | Generováno programovým pravidlem ({0}) – Nelze přiřadit hodnotu atributu {1}. Zadaná hodnota musí být prázdná nebo odpovídat vypočítané hodnotě {2} | |
| E1310 | Generated by program rule ({0}) - Attribute {1} is being replaced in te {2} | |
| E1313 | Event {0} of an enrollment does not point to an existing tracked entity. The data in your system might be corrupted | Indicates an anomaly in the existing data whereby enrollments might not reference a tracked entity |
| E1314 | Generated by program rule ({0}) - DataElement {1} is mandatory and cannot be deleted. | |
| E1315 | Status {0} does not allow defining data values. Statuses that do allow defining data values are: {1} | |
| E1316 | No event can transition from status {0} to status {1}. | |
| E1317 | Generated by program rule ({0}) - Attribute {1} is mandatory and cannot be deleted. | |
| E4000 | Vztah: {0} nemůže odkazovat sám na sebe | |
| E4001 | Položka vztahu {0} pro vztah {1} je neplatná: Položka může propojit pouze jednu entitu sledování. | |
| E4006 | Nelze najít vztah Typ: {0}. | |
| E4010 | Omezení typu vztahu {0} vyžaduje {1}, ale bylo nalezeno {2}. | |
| E4012 | Nelze najít {0}: {1}, propojený s Relationship. | |
| E4014 | Relationship type {0} constraint requires a tracked entity having type {1} but {2} was found. | |
| E4015 | Relationship: {0}, already exists. | |
| E4016 | Relationship: {0}, do not exist. | |
| E4017 | Relationship: {0}, is already deleted and cannot be modified. | |
| E4018 | Relationship: {0}, linking {1}: {2} to {3}: {4} already exists. | |
| E4019 | User: {0}, has no data write access to relationship type: {1}. | |
| E4020 | User: {0}, has no write access to relationship: {1}. | |
| E5000 | "{0}" {1} cannot be persisted because "{2}" {3} referenced by it cannot be persisted. | The importer can't persist a tracker object because a reference cannot be persisted. |
| E9999 | Nedostupné | Nedefinovaná chybová zpráva. |
Ověření¶
While importing data using the tracker importer, a series of validations are performed to ensure the validity of the data. This section will describe some of the different types of validation performed to provide a better understanding if validation fails for your import.
Required properties¶
Each of the tracker objects has a few required properties that need to be present when importing data. For an exhaustive list of required properties, have a look at the Tracker Object section.
When validating required properties, we are usually talking about references to other data or metadata. In these cases, there are three main criteria:
- Reference je přítomna a není nulová v užitečném zatížení.
- Odkaz ukazuje na správný typ dat a existuje v databázi
- Uživatel má přístup k zobrazení reference
If the first condition fails, the import will fail with a message about a missing reference. However, suppose the reference points to something that doesn't exist or which the user cannot access. In that case, both cases will result in a message about the reference not being found.
Formats¶
Some of the properties of tracker objects require a specific format. When importing data, each of these properties is validated against the expected format and will return different errors depending on which property has a wrong format. Some examples of properties that are validated this way:
- UID (Pokrývají všechny odkazy na jiná data nebo metadata v DHIS2.)
- Termíny
- Geometrie (souřadnice musí odpovídat formátu určenému jeho typem)
User access¶
All data imported will be validated based on the metadata (Sharing) and the organisation units (Organisation Unit Scopes) referenced in the data. You can find more information about sharing and organisation unit scopes in the following sections.
Sharing is validated at the same time as references are looked up in the database. Metadata outside of the user's access will be treated as if it doesn't exist. The import will validate any metadata referenced in the data.
Organisation units, on the other hand, serve a dual purpose. It will primarily make sure that data can only be imported when imported for an organisation unit the user has within their "capture scope". Secondly, organisation units are also used to restrict what programs are available. That means if you are trying to import data for an organisation unit that does not have access to the Program you are importing, the import will be invalid.
Users with the ALL authority will ignore the limits of sharing and organisation unit scopes when they import data. However, they can not import enrollments in organisation units that do not have access to the enrollment program.
Attribute and Data values¶
Attributes and data values are part of a tracked entity and an event, respectively. However, attributes can be linked to a tracked entity either through its type (TrackedEntityType) or its Program (Program). Additionally, attributes can also be unique.
The initial validation done in the import is to make sure the value provided for an attribute or data element conforms to the type of value expected. For example, suppose you import a value for a data element with a numeric type. In that case, the value is expected to be numeric. Any errors related to a mismatch between a type and a value will result in the same error code but with a specific message related to the type of violation.
Mandatory attributes and data values are also checked. Currently, removing mandatory attributes is not allowed. Some use-cases require values to be sent separately, while others require all values to be sent as one. Programs can be configured to either validate mandatory attributes ON_COMPLETE or ON_UPDATE_AND_INSERT to accommodate these use-cases.
The import will validate unique attributes at the time of import. That means as long as the provided value is unique for the attribute in the whole system, it will pass. However, if the unique value is fpound used by any other tracked entity other than the one being imported, it will fail.
Konfigurace¶
The last part of validations in the importer are validations based on the user's configuration of relevant metadata. For more information about each configuration, check out the relevant sections. Some examples of configurable validations:
- Typ prvku (pro geometrii)
- Uživatelsky přiřaditelné události
- Povolit budoucí data
- Zapsat se jednou
- A více.
Tyto konfigurace dále změní způsob provádění ověřování během importu.
Pravidla programu¶
Users can configure Program Rules, which adds conditional behavior to tracker forms. In addition to running these rules in the tracker apps, the tracker importer will also run a selection of these rules. Since the importer is also running these rules, we can ensure an additional level of validation.
Not all program rule actions are supported since they are only suitable for a frontend presentation. A complete list of the supported program rule actions is presented below.
| Akce programového pravidla | Podporováno |
|---|---|
| DISPLAYTEXT | |
| DISPLAYKEYVALUEPAIR | |
| HIDEFIELD | |
| HIDESECTION | |
| ASSIGN | X |
| SHOWWARNING | X |
| SHOWERROR | X |
| WARNINGONCOMPLETION | X |
| ERRORONCOMPLETION | X |
| CREATEEVENT | |
| SETMANDATORYFIELD | X |
| SENDMESSAGE | X |
| SCHEDULEMESSAGE | X |
Program rules are evaluated in the importer in the same way they are evaluated in the Tracker apps. To summarize, the following conditions are considered when enforcing the program rules:
- The program rule must be linked to the data being imported. For example, a program stage or a data element.
- Podmínka programového pravidla musí být vyhodnocena jako true
Výsledky pravidel programu závisí na akcích definovaných v těchto pravidlech:
- Akce programových pravidel mohou skončit se 2 různými výsledky: Varování nebo Chyby.
- Errors will make the validation fail, while the warnings will be reported as a message in the import summary.
- Akce SHOWWARNING a WARNINGONCOMPLETION mohou generovat pouze varování.
- SHOWERROR, ERRORONCOMPLETION, and SETMANDATORYFIELD actions can generate only Errors.
- ASSIGN action can generate both Warnings and Errors.
- When the action is assigning a value to an empty attribute/data element, a warning is generated.
- When the action is assigning a value to an attribute/data element that already has the same value to be assigned, a warning is generated.
- When the action is assigning a value to an attribute/data element that already has a value and the value to be assigned is different, an error is generated unless the
RULE_ENGINE_ASSIGN_OVERWRITEsystem setting is set to true.
Additionally, program rules can also result in side-effects, like send and schedule messages. More information about side effects can be found in the following section.
POZNÁMKA
Programová pravidla lze během importu přeskočit pomocí parametru
skipProgramRules.
Vedlejší účinky¶
After an import has been completed, specific tasks might be triggered as a result of the import. These tasks are what we refer to as "Side effects". These tasks perform operations that do not affect the import itself.
Side effects are tasks running detached from the import but are always triggered by an import. Since side effects are detached from the import, they can fail even when the import is successful. Additionally, side effects are only run when the import is successful, so they cannot fail the other way around.
V současné době jsou podporovány následující vedlejší účinky:
| Vedlejší efekty | Podporováno | Popis |
|---|---|---|
| Oznámení trackeru | X | Updates can trigger notifications. Updates which trigger notifications are enrollment, event update, event or enrollment completion. |
| Oznámení ProgramRule | X | Pravidla programu mohou spouštět upozornění. Všimněte si, že tato upozornění jsou součástí efektů programových pravidel, které jsou generovány prostřednictvím modulu pravidel DHIS2. |
POZNÁMKA
Určité konfigurace mohou řídit provádění vedlejších účinků. Během importu lze nastavit příznak
skipSideEffects, aby se vedlejší efekty zcela vynechaly. Tento parametr může být užitečný, pokud například importujete něco, na co nechcete spouštět upozornění.
Přiřadit uživatele k událostem¶
Specific workflows benefit from treating events like tasks, and for this reason, you can assign a user to an event.
Assigning a user to an event will not change the access or permissions for users but will create a link between the Event and the user. When an event has a user assigned, you can query events from the API using the assignedUser field as a parameter.
When you want to assign a user to an event, you simply provide the UID of the user you want to assign in the assignedUser field. See the following example:
{
...
"events": [
{
"event": "ZwwuwNp6gVd",
"programStage": "nlXNK4b7LVr",
"orgUnit": "O6uvpzGd5pu",
"enrollment": "MNWZ6hnuhSw",
"assignedUser" : "M0fCOxtkURr"
}
],
...
}
In this example, the user with uid M0fCOxtkURr will be assigned to the Event with uid ZwwuwNp6gVd. Only one user can be assigned to a single event.
To use this feature, the relevant program stage needs to have user assignment enabled, and the uid provided for the user must refer to a valid, existing user.
Tracker Export¶
Tracker export endpoints allow you to retrieve the previously imported objects which are:
- tracked entities
- events
- enrollments
- relationships
NOTE
- All tracker export endpoints default to a
JSONresponse content.CSVis only supported by tracked entities and events.- You can export a CSV file by adding the
Acceptheader text/csv or application/csv to the request.- You can download in zip and gzip formats:
- CSV for Tracked entities
- JSON and CSV for Events
- You can export a Gzip file by adding the
Acceptheader application/csv+gzip for CSV or application/json+gzip for JSON.- You can export a Zip file by adding the
Acceptheader application/csv+zip for CSV or application/json+zip for JSON.
Common request parameters¶
The following endpoint supports standard parameters for pagination.
- Tracked entities
GET /api/tracker/trackedEntities - Události
GET /api/tracker/events - Enrollments
GET /api/tracker/enrollments - Relationships
GET /api/tracker/relationships
Request parameters for pagination¶
| Parametr požadavku | Typ | Povolené hodnoty | Popis |
|---|---|---|---|
page | Integer | Any positive integer | Page number to return. Defaults to 1. |
pageSize | Integer | Any positive integer | Page size. Defaults to 50. |
totalPages | Boolean | true|false | Indicates whether to return the total number of elements and pages. Defaults to false as getting the totals is an expensive operation. |
paging | Boolean | true|false | Indicates whether paging should be ignored and all rows should be returned. Defaults to true, meaning that by default all requests are paginated, unless paging=false. |
skipPaging deprecated for removal in version 42 use paging | Boolean | true|false | Indicates whether paging should be ignored and all rows should be returned. Defaults to false, meaning that by default all requests are paginated, unless skipPaging=true. |
order | String | Comma-separated list of property name and sort direction pairs in format propName:sortDirection.Example: createdAt:descNote: propName is case sensitive. Valid sortDirections are asc and desc. sortDirection is case-insensitive. sortDirection defaults to asc for properties or UIDs without explicit sortDirection. |
Caution
Be aware that the performance is directly related to the amount of data requested. Larger pages will take more time to return.
Request parameters for Organisational Unit selection mode¶
The available organisation unit selection modes are SELECTED, CHILDREN, DESCENDANTS, ACCESSIBLE, CAPTURE and ALL. Each mode is explained in detail in this section.
Request parameter to filter responses¶
All export endpoints accept a fields parameter which controls which fields will be returned in the JSON response. fields parameter accepts a comma separated list of field names or patterns. A few possible fields filters are shown below. Refer to Metadata field filter for a more complete guide on how to use fields.
Příklady¶
| Příklad parametru | Význam |
|---|---|
fields=* | returns all fields |
fields=createdAt,uid | only returns fields createdAt and uid |
fields=enrollments[*,!uid] | returns all fields of enrollments except uid |
fields=enrollments[uid] | only returns enrollments field uid |
fields=enrollments[uid,enrolledAt] | only returns enrollments fields uid and enrolledAt |
Tracked Entities (GET /api/tracker/trackedEntities)¶
Dva koncové body jsou vyhrazeny trasovaným entitám:
GET /api/tracker/trackedEntities- načte trasované entity odpovídající daným kritériím
GET /api/tracker/trackedEntities/{id}- načte trasovanou entitu podle poskytnutého ID
If not otherwise specified, JSON is the default response for the GET method. The API also supports CSV export for single and collection endpoints. Furthermore, compressed CSV types is an option for the collection endpoint.
CSV¶
In the case of CSV, the fields request parameter has no effect, and the response will always contain the following fields:
- trackedEntity (UID)
- trackedEntityType (UID)
- createdAt (Datetime)
- createdAtClient (Datetime)
- updatedAt (Datetime)
- updatedAtClient (Datetime)
- orgUnit (UID)
- inactive (boolean)
- deleted (boolean)
- potentialDuplicate (boolean)
- geometry (WKT, https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry. You can omit it in case of a
Pointtype and withlatitudeandlongitudeprovided) - latitude (Latitude of a
Pointtype of Geometry) - longitude (Longitude of a
Pointtype of Geometry) - attribute (UID)
- displayName (String)
- attrCreatedAt (Attribute creation Datetime)
- attrUpdatedAt (Attribute last update Datetime)
- valueType (String)
- value (String)
- storedBy (String)
- createdBy (Username of user)
- updatedBy (Username of user)
See Tracked Entities and Attributes for more field descriptions.
GZIP¶
The response is file trackedEntities.csv.gz containing the trackedEntities.csv file.
ZIP¶
The response is file trackedEntities.csv.zip containing the trackedEntities.csv file.
Tracked Entities Collection endpoint GET /api/tracker/trackedEntities¶
Účelem tohoto koncového bodu je načíst trasované entity odpovídající kritériím zadaným klientem.
Koncový bod vrátí seznam trasovaných entit, které odpovídají parametrům požadavku.
| Parametr požadavku | Typ | Povolené hodnoty | Popis |
|---|---|---|---|
filter | String | Comma-separated values of attribute filters. | Narrows response to TEIs matching given filters. A filter is a colon separated property or attribute UID with optional operator and value pairs. Example: filter=H9IlTX2X6SL:sw:A with operator starts with sw followed by a value. Special characters like + need to be percent-encoded so %2B instead of +. Characters such as : (colon) or , (comma), as part of the filter value, need to be escaped by / (slash). Likewise, / needs to be escaped. Multiple operator/value pairs for the same property/attribute like filter=AuPLng5hLbE:gt:438901703:lt:448901704 are allowed. Repeating the same attribute UID is not allowed. User needs access to the attribute to filter on it. |
orgUnits | String | Comma-separated list of organisation unit UIDs. | Only return tracked entities belonging to provided organisation units |
orgUnit deprecated for removal in version 42 use orgUnits | String | Semicolon-separated list of organisation units UIDs. | Only return tracked entities belonging to provided organisation units. |
orgUnitMode see orgUnitModes | String | SELECTED|CHILDREN|DESCENDANTS|ACCESSIBLE|CAPTURE|ALL | Způsob výběru organizačních jednotek může být. Výchozí hodnota je SELECTED, což se týká pouze vybraných organizačních jednotek. |
ouMode deprecated for removal in version 42 use orgUnitMode see orgUnitModes | String | SELECTED|CHILDREN|DESCENDANTS|ACCESSIBLE|CAPTURE|ALL | Způsob výběru organizačních jednotek může být. Výchozí hodnota je SELECTED, což se týká pouze vybraných organizačních jednotek. |
program | String | Program UID | A program UID for which tracked entities in the response must be enrolled into. |
programStatus | String | ACTIVE|COMPLETED|CANCELLED | The program status of the tracked entity in the given program. |
programStage | String | UID | A program stage UID for which tracked entities in the response must have events for. |
followUp | Boolean | true|false | Indicates whether the tracked entity is marked for follow up for the specified program. |
updatedAfter | DateTime | ISO-8601 | Start date and time for last updated |
updatedBefore | DateTime | ISO-8601 | End date and time for last updated |
updatedWithin | Duration | ISO-8601 | Vrátí TEI ne starší než zadaná doba trvání |
enrollmentEnrolledAfter | DateTime | ISO-8601 | Start date and time for enrollment in the given program |
enrollmentEnrolledBefore | DateTime | ISO-8601 | End date and time for enrollment in the given program |
enrollmentOccurredAfter | DateTime | ISO-8601 | Start date and time and time and time for occurred in the given program |
enrollmentOccurredBefore | DateTime | ISO-8601 | End date and time and time for occurred in the given program |
trackedEntityType | String | UID typu trasované entity | Only returns tracked entities of given type. |
trackedEntities | String | Comma-separated list of tracked entity UIDs. | Filter the result down to a limited set of tracked entities using explicit uids of the tracked entities by using trackedEntity=id1,id2. This parameter will, at the very least, create the outer boundary of the results, forming the list of all tracked entities using the uids provided. If other parameters/filters from this table are used, they will further limit the results from the explicit outer boundary. |
trackedEntity deprecated for removal in version 42 use trackedEntities | String | Semicolon-separated list of tracked entity UIDs. | Filter the result down to a limited set of tracked entities using explicit uids of the tracked entities by using trackedEntity=id1;id2. This parameter will, at the very least, create the outer boundary of the results, forming the list of all tracked entities using the uids provided. If other parameters/filters from this table are used, they will further limit the results from the explicit outer boundary. |
assignedUserMode | String | CURRENT|PROVIDED|NONE|ANY | Restricts result to tracked entities with events assigned based on the assigned user selection mode. See table below "Assigned user modes" for explanations. |
assignedUsers | String | Comma-separated list of user UIDs to filter based on events assigned to the users. | Filter the result down to a limited set of tracked entities with events that are assigned to the given user IDs by using assignedUser=id1,id2. This parameter will only be considered if assignedUserMode is either PROVIDED or null. The API will error out, if for example, assignedUserMode=CURRENT and assignedUser=someId. |
assignedUser deprecated for removal in version 42 use assignedUsers | String | Semicolon-separated list of user UIDs to filter based on events assigned to the users. | Filter the result down to a limited set of tracked entities with events that are assigned to the given user IDs by using assignedUser=id1;id2.This parameter will only be considered if assignedUserMode is either PROVIDED or null. The API will error out, if for example, assignedUserMode=CURRENT and assignedUser=someId |
order | String | Comma-separated list of property name or attribute or UID and sort direction pairs in format propName:sortDirection. | Supported values are createdAt, createdAtClient, enrolledAt, inactive, trackedEntity, updatedAt, updatedAtClient. |
eventStatus | String | ACTIVE|COMPLETED|VISITED|SCHEDULE|OVERDUE|SKIPPED | Status of any events in the specified program |
eventOccurredAfter | DateTime | ISO-8601 | Start date and time for Event for the given Program |
eventOccurredBefore | DateTime | ISO-8601 | End date and time for Event for the given Program |
includeDeleted | Boolean | true|false | Indicates whether to include soft-deleted elements |
potentialDuplicate | Boolean | true|false | Filter the result based on the fact that a TEI is a Potential Duplicate. true: return TEIs flagged as Potential Duplicates. false: return TEIs NOT flagged as Potential Duplicates. If omitted, we don't check whether a TEI is a Potential Duplicate or not. |
The available assigned user modes are explained in the following table.
Tabulka: Přiřazené uživatelské režimy
| Režim | Popis |
|---|---|
| CURRENT | Zahrnuje události přiřazené aktuálně přihlášenému uživateli. |
| PROVIDED | Includes events assigned to the user provided in the request. |
| NONE | Includes unassigned events only. |
| ANY | Includes all assigned events, doesn't matter who are they assigned to as long as they assigned to someone. |
V dotazu se nerozlišují velká a malá písmena. Pro parametry dotazu platí následující pravidla.
-
At least one organisation unit must be specified using the
orgUnitparameter (one or many), ororgUnitMode=ALLmust be specified. -
Only one of the
programandtrackedEntityparameters can be specifikováno (nula nebo jedna). -
If
programStatusis specified, thenprogrammust also be specifikováno. -
If
followUpis specified, thenprogrammust also be specified. -
If
enrollmentEnrolledAfterorenrollmentEnrolledBeforeis specified thenprogrammust also be specified. -
Položky filtru lze zadat pouze jednou.
Example requests¶
A query for all tracked entities associated with a specific organisation unit and program can look like this:
GET /api/tracker/trackedEntities?program=IpHINAT79UW&orgUnits=DiszpKrYNg8
To query for tracked entities using one attribute with a filter and one attribute without a filter, with one organisation unit using the descendant organisation unit query mode:
GET /api/tracker/trackedEntities?program=IpHINAT79UW&orgUnits=DiszpKrYNg8&filter=w75KJ2mc4zz:EQ:John
Dotaz, kde je pro položku filtru zadáno více operandů a filtrů:
GET /api/tracker/trackedEntities?orgUnits=DiszpKrYNg8&program=ur1Edk5Oe2n&filter=lw1SqmMlnfh:GT:150&filter=lw1SqmMlnfh:LT:190
A query filter with a value that needs escaping and will be interpreted as :,/:
GET /api/tracker/trackedEntities?orgUnits=DiszpKrYNg8&program=ur1Edk5Oe2n&filter=lw1SqmMlnfh:EQ:/:/,//
Chcete-li zadat data zápisu programu jako součást dotazu:
GET /api/tracker/trackedEntities?orgUnits=DiszpKrYNg8&program=IpHINAT79UW&fields=trackedEntity,enrollments[enrolledAt]&enrollmentEnrolledAfter=2024-01-01
To query on an attribute using multiple values in an IN filter:
GET /api/tracker/trackedEntities?trackedEntityType=nEenWmSyUEp&orgUnits=DiszpKrYNg8&filter=w75KJ2mc4zz:IN:Scott;Jimmy;Santiago
K filtrování můžete použít řadu operátorů:
| Operátor | Popis |
|---|---|
EQ | Rovno |
GE | Větší než nebo rovno |
GT | Větší než |
IN | Rovná se jedné z více hodnot oddělených ";" |
LE | Menší nebo rovno |
LIKE | Jako (shoda volného textu) |
LT | Menší než |
NE | Nerovná se |
Tracked Entities response example¶
The API supports CSV and JSON response for GET /api/tracker/trackedEntities.
JSON¶
Responses can be filtered on desired fields, see Request parameter to filter responses
A JSON response can look like the following:
{
"pager": {
"page": 1,
"pageSize": 1
},
"trackedEntities": [
{
"trackedEntity": "F8yKM85NbxW",
"trackedEntityType": "Zy2SEgA61ys",
"createdAt": "2019-08-21T13:25:38.022",
"createdAtClient": "2019-03-19T01:12:16.624",
"updatedAt": "2019-08-21T13:31:33.410",
"updatedAtClient": "2019-03-19T01:12:16.624",
"orgUnit": "DiszpKrYNg8",
"inactive": false,
"deleted": false,
"potentialDuplicate": false,
"geometry": {
"type": "Point",
"coordinates": [
-11.7896,
8.2593
]
},
"attributes": [
{
"attribute": "B6TnnFMgmCk",
"displayName": "Age (years)",
"createdAt": "2019-08-21T13:25:38.477",
"updatedAt": "2019-08-21T13:25:38.477",
"storedBy": "braimbault",
"valueType": "INTEGER_ZERO_OR_POSITIVE",
"value": "30"
},
{
"attribute": "TfdH5KvFmMy",
"displayName": "First Name",
"createdAt": "2019-08-21T13:25:38.066",
"updatedAt": "2019-08-21T13:25:38.067",
"storedBy": "josemp10",
"valueType": "TEXT",
"value": "Sarah"
},
{
"attribute": "aW66s2QSosT",
"displayName": "Last Name",
"createdAt": "2019-08-21T13:25:38.388",
"updatedAt": "2019-08-21T13:25:38.388",
"storedBy": "karoline",
"valueType": "TEXT",
"value": "Johnson"
}
]
}
]
}
CSV¶
A CSV response can look like the following:
trackedEntity,trackedEntityType,createdAt,createdAtClient,updatedAt,updatedAtClient,orgUnit,inactive,deleted,potentialDuplicate,geometry,latitude,longitude,storedBy,createdBy,updatedBy,attrCreatedAt,attrUpdatedAt,attribute,displayName,value,valueType
F8yKM85NbxW,Zy2SEgA61ys,2019-08-21T11:25:38.022Z,2019-03-19T00:12:16.624Z,2019-08-21T11:31:33.410Z,2019-03-19T00:12:16.624Z,DiszpKrYNg8,false,false,false,"POINT (-11.7896 8.2593)",8.2593,-11.7896,,,,2019-08-21T11:25:38.477Z,2019-08-21T11:25:38.477Z,B6TnnFMgmCk,"Age (years)",30,INTEGER_ZERO_OR_POSITIVE
F8yKM85NbxW,Zy2SEgA61ys,2019-08-21T11:25:38.022Z,2019-03-19T00:12:16.624Z,2019-08-21T11:31:33.410Z,2019-03-19T00:12:16.624Z,DiszpKrYNg8,false,false,false,"POINT (-11.7896 8.2593)",8.2593,-11.7896,,,,2019-08-21T11:25:38.066Z,2019-08-21T11:25:38.067Z,TfdH5KvFmMy,"First Name",Sarah,TEXT
F8yKM85NbxW,Zy2SEgA61ys,2019-08-21T11:25:38.022Z,2019-03-19T00:12:16.624Z,2019-08-21T11:31:33.410Z,2019-03-19T00:12:16.624Z,DiszpKrYNg8,false,false,false,"POINT (-11.7896 8.2593)",8.2593,-11.7896,,,,2019-08-21T11:25:38.388Z,2019-08-21T11:25:38.388Z,aW66s2QSosT,"Last Name",Johnson,TEXT
Tracked Entities Collection limits¶
The collection endpoint limits results in three ways:
-
KeyTrackedEntityMaxLimit in System settings:
KeyTrackedEntityMaxLimitdefines the maximum tracked entities in an API response, protecting database and server resources. No limit applies when set to 0. Configure it via/api/systemSettingsas described in the documentation. -
Max number of TEs to return in Program or tracked entity type: it limits results when searching outside the capture scope with a specified program or tracked entity type. The API returns an error if matches exceed this limit. No limit applies when searching within the capture scope or when set to 0. This limit is configurable in the maintenance app.
-
Pagination: As explained here.
For paginated requests with non-zero KeyTrackedEntityMaxLimit:
-
If pageSize ≤ KeyTrackedEntityMaxLimit:
pageSizeis enforced -
If pageSize > KeyTrackedEntityMaxLimit: The API returns an error
Tracked Entities single object endpoint GET /api/tracker/trackedEntities/{uid}¶
Účelem tohoto koncového bodu je načíst jednu trasovanou entitu s jejím uid.
Požádat o syntaxi¶
GET /api/tracker/trackedEntities/{uid}?program={programUid}&fields={fields}
| Parametr požadavku | Typ | Povolené hodnoty | Popis |
|---|---|---|---|
uid | String | uid | Return the tracked entity with specified uid |
program | String | uid | Zahrnout atributy programu do odpovědi (pouze ty, ke kterým má uživatel přístup) |
fields | String | Libovolný platný filtr polí (výchozí *,!relationships,!enrollments,!events,!programOwners) | Zahrnout do odpovědi zadané dílčí objekty |
Example requests¶
A query for a tracked entity:
GET /api/tracker/trackedEntities/PQfMcpmXeFE
Tracked Entity response example¶
The API supports CSV and JSON response for GET /api/tracker/trackedEntities/{uid}
JSON¶
Příklad odpovědi json:
{
"trackedEntity": "PQfMcpmXeFE",
"trackedEntityType": "nEenWmSyUEp",
"createdAt": "2014-03-06T05:49:28.256",
"createdAtClient": "2014-03-06T05:49:28.256",
"updatedAt": "2016-08-03T23:49:43.309",
"orgUnit": "DiszpKrYNg8",
"inactive": false,
"deleted": false,
"potentialDuplicate": false,
"attributes": [
{
"attribute": "w75KJ2mc4zz",
"code": "MMD_PER_NAM",
"displayName": "First name",
"createdAt": "2016-08-03T23:49:43.308",
"updatedAt": "2016-08-03T23:49:43.308",
"valueType": "TEXT",
"value": "John"
},
{
"attribute": "zDhUuAYrxNC",
"displayName": "Last name",
"createdAt": "2016-08-03T23:49:43.309",
"updatedAt": "2016-08-03T23:49:43.309",
"valueType": "TEXT",
"value": "Kelly"
}
],
"enrollments": [
{
"enrollment": "JMgRZyeLWOo",
"createdAt": "2017-03-06T05:49:28.340",
"createdAtClient": "2016-03-06T05:49:28.340",
"updatedAt": "2017-03-06T05:49:28.357",
"trackedEntity": "PQfMcpmXeFE",
"program": "IpHINAT79UW",
"status": "ACTIVE",
"orgUnit": "DiszpKrYNg8",
"enrolledAt": "2024-03-06T00:00:00.000",
"occurredAt": "2024-03-04T00:00:00.000",
"followUp": false,
"deleted": false,
"events": [
{
"event": "Zq2dg6pTNoj",
"status": "ACTIVE",
"program": "IpHINAT79UW",
"programStage": "ZzYYXq4fJie",
"enrollment": "JMgRZyeLWOo",
"trackedEntity": "PQfMcpmXeFE",
"relationships": [],
"scheduledAt": "2023-03-10T00:00:00.000",
"followUp": false,
"deleted": false,
"createdAt": "2017-03-06T05:49:28.353",
"createdAtClient": "2016-03-06T05:49:28.353",
"updatedAt": "2017-03-06T05:49:28.353",
"attributeOptionCombo": "HllvX50cXC0",
"attributeCategoryOptions": "xYerKDKCefk",
"dataValues": [],
"notes": [],
"followup": false
}
],
"relationships": [],
"attributes": [
{
"attribute": "w75KJ2mc4zz",
"code": "MMD_PER_NAM",
"displayName": "First name",
"createdAt": "2016-08-03T23:49:43.308",
"updatedAt": "2016-08-03T23:49:43.308",
"valueType": "TEXT",
"value": "John"
},
{
"attribute": "zDhUuAYrxNC",
"displayName": "Last name",
"createdAt": "2016-08-03T23:49:43.309",
"updatedAt": "2016-08-03T23:49:43.309",
"valueType": "TEXT",
"value": "Kelly"
},
{
"attribute": "AuPLng5hLbE",
"code": "National identifier",
"displayName": "National identifier",
"createdAt": "2016-08-03T23:49:43.301",
"updatedAt": "2016-08-03T23:49:43.301",
"valueType": "TEXT",
"value": "245435245"
},
{
"attribute": "ruQQnf6rswq",
"displayName": "TB number",
"createdAt": "2016-08-03T23:49:43.308",
"updatedAt": "2016-08-03T23:49:43.308",
"valueType": "TEXT",
"value": "1Z 1F2 A84 59 4464 173 6"
},
{
"attribute": "cejWyOfXge6",
"displayName": "Gender",
"createdAt": "2016-08-03T23:49:43.307",
"updatedAt": "2016-08-03T23:49:43.307",
"valueType": "TEXT",
"value": "Male"
},
{
"attribute": "VqEFza8wbwA",
"code": "MMD_PER_ADR1",
"displayName": "Address",
"createdAt": "2016-08-03T23:49:43.307",
"updatedAt": "2016-08-03T23:49:43.307",
"valueType": "TEXT",
"value": "Main street 2"
}
],
"notes": []
}
],
"programOwners": [
{
"orgUnit": "DiszpKrYNg8",
"trackedEntity": "PQfMcpmXeFE",
"program": "ur1Edk5Oe2n"
},
{
"orgUnit": "DiszpKrYNg8",
"trackedEntity": "PQfMcpmXeFE",
"program": "IpHINAT79UW"
}
]
}
CSV¶
The response will be the same as the collection endpoint but referring to a single tracked entity, although it might have multiple rows for each attribute.
Tracked entity attribute value change logs¶
GET /api/tracker/trackedEntities/{uid}/changeLogs
This endpoint retrieves change logs for the attributes of a specific tracked entity. It returns a list of all tracked entity attributes that have changed over time for that entity.
| Parametr | Typ | Povolené hodnoty |
|---|---|---|
path /{uid} | String | Tracked entity UID. |
program | String | Program UID (optional). |
Tracked entity attribute value change logs response example¶
Příklad odpovědi json:
{
"pager":{
"page":1,
"pageSize":10
},
"changeLogs":[
{
"createdBy":{
"uid":"AIK2aQOJIbj",
"username":"tracker",
"firstName":"Tracker demo",
"surname":"User"
},
"createdAt":"2024-06-20T14:51:16.433",
"type":"UPDATE",
"change":{
"dataValue":{
"dataElement":"bx6fsa0t90x",
"previousValue":"true",
"currentValue":"false"
}
}
},
{
"createdBy":{
"uid":"AIK2aQOJIbj",
"username":"tracker",
"firstName":"Tracker demo",
"surname":"User"
},
"createdAt":"2024-06-20T14:50:32.966",
"type":"CREATE",
"change":{
"dataValue":{
"dataElement":"ebaJjqltK5N",
"currentValue":"0"
}
}
}
]
}
The change log type can be CREATE, UPDATE, or DELETE. CREATE and DELETE will always hold a single value: the former shows the current value, and the latter shows the value that was deleted. UPDATE will hold two values: the previous and the current.
Enrollments (GET /api/tracker/enrollments)¶
Pro zápisy jsou vyhrazeny dva koncové body:
GET /api/tracker/enrollments- načte zápisy odpovídající zadaným kritériím
GET /api/tracker/enrollments/{id}- načte zápis podle poskytnutého ID
Enrollment Collection endpoint GET /api/tracker/enrollments¶
Vrátí seznam událostí na základě filtrů.
| Parametr požadavku | Typ | Povolené hodnoty | Popis |
|---|---|---|---|
orgUnits | String | Comma-separated list of organisation unit UIDs. | Only return enrollments belonging to provided organisation units. |
orgUnit deprecated for removal in version 42 use orgUnits | String | Semicolon-separated list of organisation units UIDs. | Only return enrollments belonging to provided organisation units. |
orgUnitMode see orgUnitModes | String | SELECTED|CHILDREN|DESCENDANTS|ACCESSIBLE|CAPTURE|ALL | Způsob výběru organizačních jednotek může být. Výchozí hodnota je SELECTED, což se týká pouze vybraných organizačních jednotek. |
ouMode deprecated for removal in version 42 use orgUnitMode see orgUnitModes | String | SELECTED|CHILDREN|DESCENDANTS|ACCESSIBLE|CAPTURE|ALL | Způsob výběru organizačních jednotek může být. Výchozí hodnota je SELECTED, což se týká pouze vybraných organizačních jednotek. |
program | String | uid | Identifikátor programu |
programStatus | enum | ACTIVE|COMPLETED|CANCELLED | Stav programu |
followUp | boolean | true|false | Follow up status of the tracked entity for the given program. Can be true|false or omitted. |
updatedAfter | DateTime | ISO-8601 | Pouze zápisy aktualizované po tomto datu |
updatedWithin | Duration | ISO-8601 | Pouze zápisy aktualizované od daného data |
enrolledAfter | DateTime | ISO-8601 | Pouze zápisy novější než toto datum |
enrolledBefore | DateTime | ISO-8601 | Pouze přihlášky starší než toto datum |
trackedEntityType | String | uid | Identifikátor typu trasované entity |
trackedEntity | String | uid | Identifier of tracked entity |
order | String | Comma-separated list of property name or attribute or UID and sort direction pairs in format propName:sortDirection. | Supported fields: completedAt, createdAt, createdAtClient, enrolledAt, updatedAt, updatedAtClient. |
enrollments | String | Comma-separated list of enrollment UIDs. | Filter the result down to a limited set of IDs by using enrollments=id1,id2. |
enrollment deprecated for removal in version 42 use enrollments | String | Semicolon-separated list of uid | Filter the result down to a limited set of IDs by using enrollment=id1;id2. |
includeDeleted | Boolean | Když je true, budou do výsledku dotazu zahrnuty měkké odstraněné události. |
V dotazu se nerozlišují velká a malá písmena. Následující pravidla platí pro parametry dotazu.
-
At least one organisation unit must be specified using the
orgUnitparameter (one or many), or orgUnitMode=ALL must be specified. -
Only one of the program and trackedEntity parameters can be specified (zero or one).
-
If programStatus is specified, then program must also be specified.
-
If followUp is specified, then program must also be specified.
-
If enrolledAfter or enrolledBefore is specified, then program must also be specified.
Example requests¶
Dotaz na všechny zápisy přidružené ke konkrétní organizační jednotce může vypadat takto:
GET /api/tracker/enrollments?orgUnits=DiszpKrYNg8
To constrain the response to enrollments which are part of a specific program you can include a program query parameter:
GET /api/tracker/enrollments?orgUnits=O6uvpzGd5pu&orgUnitMode=DESCENDANTS&program=ur1Edk5Oe2n
Chcete-li zadat data zápisu programu jako součást dotazu:
GET /api/tracker/enrollments?orgUnits=DiszpKrYNg8&program=M3xtLkYBlKI&enrolledAfter=2023-11-14&enrolledBefore=2024-02-07
To constrain the response to enrollments of a specific tracked entity you can include a tracked entity query parameter:
GET /api/tracker/enrollments?trackedEntity=ClJ3fn47c4s
To constrain the response to enrollments of a specific tracked entity you can include a tracked entity query parameter, in In this case, we have restricted it to available enrollments viewable for current user:
GET /api/tracker/enrollments?orgUnitMode=ACCESSIBLE&trackedEntity=tphfdyIiVL6
Formát odpovědi¶
Odpověď JSON může vypadat následovně.
{
"pager": {
"page": 1,
"pageSize": 1
},
"enrollments": [
{
"enrollment": "TRE0GT7eh7Q",
"createdAt": "2019-08-21T13:28:00.056",
"createdAtClient": "2018-11-13T15:06:49.009",
"updatedAt": "2019-08-21T13:29:44.942",
"updatedAtClient": "2019-08-21T13:29:44.942",
"trackedEntity": "s4NfKOuayqG",
"program": "M3xtLkYBlKI",
"status": "COMPLETED",
"orgUnit": "DiszpKrYNg8",
"enrolledAt": "2023-11-13T00:00:00.000",
"occurredAt": "2023-11-13T00:00:00.000",
"followUp": false,
"deleted": false,
"storedBy": "healthworker1",
"notes": []
}
]
}
Koncový bod registrace jednoho objektu GET /api/tracker/enrollments/{uid}¶
Účelem tohoto koncového bodu je načíst jednu prohlášku s jejím uid.
Požádat o syntaxi¶
GET /api/tracker/enrollment/{uid}
| Parametr požadavku | Typ | Povolené hodnoty | Popis |
|---|---|---|---|
uid | String | uid | Vraťte registraci se zadaným uid |
fields | String | Libovolný platný filtr polí (výchozí *,!relationships,!events,!attributes) | Include |
| specified sub-objects in the response |
Example requests¶
A query for an enrollment:
GET /api/tracker/enrollments/JMgRZyeLWOo
Formát odpovědi¶
{
"enrollment": "JMgRZyeLWOo",
"createdAt": "2017-03-06T05:49:28.340",
"createdAtClient": "2016-03-06T05:49:28.340",
"updatedAt": "2017-03-06T05:49:28.357",
"trackedEntity": "PQfMcpmXeFE",
"program": "IpHINAT79UW",
"status": "ACTIVE",
"orgUnit": "DiszpKrYNg8",
"enrolledAt": "2024-03-06T00:00:00.000",
"occurredAt": "2024-03-04T00:00:00.000",
"followUp": false,
"deleted": false,
"notes": []
}
Events (GET /api/tracker/events)¶
Two endpoints are dedicated to events:
GET /api/tracker/events- načte události odpovídající zadaným kritériím
GET /api/tracker/events/{id}- načte událost se zadaným ID
If not otherwise specified, JSON is the default response for the GET method. The API also supports CSV export for single and collection endpoints. Furthermore, it supports compressed JSON and CSV for the collection endpoint.
Events CSV¶
In the case of CSV, the fields request parameter has no effect, and the response will always contain the following fields:
- event (UID)
- status (String)
- program (UID)
- programStage (UID)
- enrollment (UID)
- orgUnit (UID)
- occurredAt (DateTime)
- scheduledAt (DateTime)
- geometry (WKT, https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry. You can omit it in case of a
Pointtype and withlatitudeandlongitudeprovided) - latitude (Latitude of a
Pointtype of Geometry) - longitude (Longitude of a
Pointtype of Geometry) - followUp (boolean)
- deleted (boolean)
- createdAt (DateTime)
- createdAtClient (DateTime)
- updatedAt (DateTime)
- updatedAtClient (DateTime)
- completedBy (String)
- completedAt (DateTime)
- updatedBy (UserName of user)
- attributeOptionCombo (UID)
- attributeCategoryOptions (UID)
- assignedUser (UserName of user)
- dataElement (UID)
- value (String)
- storedBy (String)
- providedElsewhere (boolean)
- storedByDataValue (String)
- createAtDataValue (DateTime)
- updatedAtDataValue (DateTime)
See Events and Data Values for more field descriptions.
Events GZIP¶
The response is file events.json.gz or events.csv.gzip containing the events.json or events.csv file.
Events ZIP¶
The response is fileevents.json.gz or events.json.zip containing the events.json or events.csv file.
Events Collection endpoint GET /api/tracker/events¶
Vrátí seznam událostí na základě poskytnutých filtrů.
| Parametr požadavku | Typ | Povolené hodnoty | Popis |
|---|---|---|---|
program | String | uid | Identifikátor programu |
programStage | String | uid | Identifikátor fáze programu |
programStatus | enum | ACTIVE|COMPLETED|CANCELLED | Stav události v programu |
filter | String | Čárkami oddělené hodnoty filtrů datových prvků | Narrows response to events matching given filters. A filter is a colon separated property or data element UID with optional operator and value pairs. Example: filter=fazCI2ygYkq:eq:PASSIVE with operator starts with eq followed by a value. A filter like filter=fazCI2ygYkq returns all events where the given data element has a value. Characters such as : (colon) or , (comma), as part of the filter value, need to be escaped by / (slash). Likewise, / needs to be escaped. Multiple operator/value pairs for the same property/data element like filter=qrur9Dvnyt5:gt:70:lt:80 are allowed. Repeating the same data element UID is not allowed. User needs access to the data element to filter on it. |
filterAttributes | String | Hodnoty filtrů atributů oddělené čárkami | Narrows response to TEIs matching given filters. A filter is a colon separated property or attribute UID with optional operator and value pairs. Example: filterAttributes=H9IlTX2X6SL:sw:A with operator starts with sw followed by a value. A filter like filterAttributes=H9IlTX2X6SL returns all events where the given attribute has a value. Special characters like + need to be percent-encoded so %2B instead of +. Characters such as : (colon) or , (comma), as part of the filter value, need to be escaped by / (slash). Likewise, / needs to be escaped. Multiple operator/value pairs for the same property/attribute like filterAttributes=AuPLng5hLbE:gt:438901703:lt:448901704 are allowed. Repeating the same attribute UID is not allowed. User needs access to the attribute to filter on it. |
followUp | boolean | true|false | Zda je událost zvažována pro pokračování v programu. Výchozí hodnota je true |
trackedEntity | String | uid | Identifier of tracked entity |
orgUnit | String | uid | Identifikátor organizační jednotky |
orgUnitMode see orgUnitModes | String | SELECTED|CHILDREN|DESCENDANTS|ACCESSIBLE|CAPTURE|ALL | Způsob výběru organizačních jednotek může být. Výchozí hodnota je SELECTED, což se týká pouze vybraných organizačních jednotek. |
ouMode deprecated for removal in version 42 use orgUnitMode see orgUnitModes | String | SELECTED|CHILDREN|DESCENDANTS|ACCESSIBLE|CAPTURE|ALL | Způsob výběru organizačních jednotek může být. Výchozí hodnota je SELECTED, což se týká pouze vybraných organizačních jednotek. |
status | String | ACTIVE|COMPLETED|VISITED|SCHEDULE|OVERDUE|SKIPPED | Stav události |
occurredAfter | DateTime | ISO-8601 | Filtrujte události, které nastaly po tomto datu. |
occurredBefore | DateTime | ISO-8601 | Filtrujte události, které nastaly do tohoto data. |
scheduledAfter | DateTime | ISO-8601 | Filtr pro události, které byly naplánovány po tomto datu. |
scheduledBefore | DateTime | ISO-8601 | Filtrujte události, které byly naplánovány před tímto datem. |
updatedAfter | DateTime | ISO-8601 | Filtr pro události, které byly aktualizovány po tomto datu. Nelze použít společně s updatedWithin. |
updatedBefore | DateTime | ISO-8601 | Filtrujte události, které byly do tohoto data aktualizovány. Nelze použít společně s updatedWithin. |
updatedWithin | Duration | ISO-8601 | Include only items which are updated within the given duration. The format is ISO-8601#Duration |
enrollmentEnrolledAfter | DateTime | ISO-8601 | Start date and time for enrollment in the given program |
enrollmentEnrolledBefore | DateTime | ISO-8601 | End date and time for enrollment in the given program |
enrollmentOccurredAfter | DateTime | ISO-8601 | Start date and time for occurred in the given program |
enrollmentOccurredBefore | DateTime | ISO-8601 | End date and time for occurred in the given program |
order | String | Comma-separated list of property name, attribute or data element UID and sort direction pairs in format propName:sortDirection. | Supported fields: assignedUser, assignedUserDisplayName, attributeOptionCombo, completedAt, completedBy, createdAt, createdAtClient, createdBy, deleted, enrolledAt, enrollment, enrollmentStatus, event, followUp, followup (deprecated), occurredAt, orgUnit, program, programStage, scheduledAt, status, storedBy, trackedEntity, updatedAt, updatedAtClient, updatedBy. |
events | String | Comma-separated list of event UIDs. | Filter the result down to a limited set of IDs by using event=id1,id2. |
event deprecated for removal in version 42 use events | String | Semicolon-separated list of uid | Filter the result down to a limited set of IDs by using event=id1;id2. |
attributeCategoryCombo (see note) | String | Attribute category combo identifier. Must be combined with attributeCategoryOptions. | |
attributeCc deprecated for removal in version 42 use attributeCategoryCombo | String | Attribute category combo identifier (must be combined with attributeCos) | |
attributeCategoryOptions (see note) | String | Comma-separated attribute category option identifiers. Must be combined with attributeCategoryCombo. | |
attributeCos deprecated for removal in version 42 use attributeCategoryOptions | String | Semicolon-separated attribute category option identifiers. Must be combined with attributeCc. | |
includeDeleted | Boolean | Když je true, budou do výsledku dotazu zahrnuty měkké odstraněné události. | |
assignedUserMode | String | CURRENT|PROVIDED|NONE|ANY | Režim výběru přiřazeného uživatele |
assignedUsers | String | Comma-separated list of user UIDs to filter based on events assigned to the users. | Filter the result down to a limited set of tracked entities with events that are assigned to the given user IDs by using assignedUser=id1,id2.This parameter will only be considered if assignedUserMode is either PROVIDED or null. The API will error out, if for example, assignedUserMode=CURRENT and assignedUser=someId. |
assignedUser deprecated for removal in version 42 use assignedUsers | String | Semicolon-separated list of user UIDs to filter based on events assigned to the users. | Filter the result down to a limited set of tracked entities with events that are assigned to the given user IDs by using assignedUser=id1;id2.This parameter will only be considered if assignedUserMode is either PROVIDED or null. The API will error out, if for example, assignedUserMode=CURRENT and assignedUser=someId |
Note
If the query contains neither
attributeCategoryOptionsnorattributeCategoryOptions, the server returns events for all attribute option combos where the user has read access.
Example requests¶
Dotaz na všechny události s potomky konkrétní organizační jednotky:
GET /api/tracker/events?orgUnit=YuQRtpLP10I&orgUnitMode=CHILDREN
The query for all events with all descendants of a particular organisation unit, implying all organisation units in the sub-hierarchy:
GET /api/tracker/events?orgUnit=O6uvpzGd5pu&orgUnitMode=DESCENDANTS
Dotaz na všechny události s určitou programovou a organizační jednotkou:
GET /api/tracker/events?orgUnit=DiszpKrYNg8&program=eBAyeGv0exc
Query for all events with a certain program and organisation unit, sorting by scheduled date ascending:
GET /api/tracker/events?orgUnit=DiszpKrYNg8&program=eBAyeGv0exc&order=scheduledAt
Query for the 10 events with the newest occurred date in a certain program and organisation unit - by paging and ordering by occurred date descending:
GET /api/tracker/events?orgUnit=DiszpKrYNg8&program=eBAyeGv0exc&order=occurredAt:desc&pageSize=10&page=1
Query for all events with a certain program and organisation unit for a specific tracked entity:
GET /api/tracker/events?orgUnit=DiszpKrYNg8&program=M3xtLkYBlKI&trackedEntity=dNpxRu1mWG5
Query for all events older or equal to 2024-02-03 and associated with a program and organisation unit:
GET /api/tracker/events?orgUnit=DiszpKrYNg8&program=eBAyeGv0exc&occurredBefore=2024-02-03
A query where multiple operand and filters are specified for a data element UID:
GET /api/tracker/events?orgUnit=g8upMTyEZGZ&program=M3xtLkYBlKI&filter=rFQNCGMYud2:GT:35&filter=rFQNCGMYud2:LT:50
A query filter with a value that needs escaping and will be interpreted as :,/:
GET /api/tracker/events?orgUnit=DiszpKrYNg8&program=lxAQ7Zs9VYR&filter=DanTR5x0WDK:EQ:/:/,//
Events response example¶
The API supports CSV and JSON response for GET /api/tracker/events.
JSON¶
The JSON response can look like the following:
{
"pager": {
"page": 1,
"pageSize": 1
},
"events": [
{
"event": "A7rzcnZTe2T",
"status": "ACTIVE",
"program": "eBAyeGv0exc",
"programStage": "Zj7UnCAulEk",
"enrollment": "RiLEKhWHlxZ",
"orgUnit": "DwpbWkiqjMy",
"occurredAt": "2023-02-13T00:00:00.000",
"scheduledAt": "2023-02-13T00:00:00.000",
"followUp": false,
"deleted": false,
"createdAt": "2017-09-08T21:40:22.000",
"createdAtClient": "2016-09-08T21:40:22.000",
"updatedAt": "2017-09-08T21:40:22.000",
"attributeOptionCombo": "HllvX50cXC0",
"attributeCategoryOptions": "xYerKDKCefk",
"geometry": {
"type": "Point",
"coordinates": [
-11.468912037323042,
7.515913998868316
]
},
"dataValues": [
{
"createdAt": "2016-12-06T18:22:34.438",
"updatedAt": "2016-12-06T18:22:34.438",
"storedBy": "bjorn",
"providedElsewhere": false,
"dataElement": "F3ogKBuviRA",
"value": "[-11.4880220438585,7.50978830548003]"
},
{
"createdAt": "2013-12-30T14:23:57.423",
"updatedAt": "2013-12-30T14:23:57.423",
"storedBy": "lars",
"providedElsewhere": false,
"dataElement": "eMyVanycQSC",
"value": "2018-02-07"
},
{
"createdAt": "2013-12-30T14:23:57.382",
"updatedAt": "2013-12-30T14:23:57.382",
"storedBy": "lars",
"providedElsewhere": false,
"dataElement": "oZg33kd9taw",
"value": "Male"
}
],
"notes": [],
"followup": false
}
]
}
CSV¶
The CSV response can look like the following:
event,status,program,programStage,enrollment,orgUnit,occurredAt,scheduledAt,geometry,latitude,longitude,followUp,deleted,createdAt,createdAtClient,updatedAt,updatedAtClient,completedBy,completedAt,updatedBy,attributeOptionCombo,attributeCategoryOptions,assignedUser,dataElement,value,storedBy,providedElsewhere,storedByDataValue,updatedAtDataValue,createdAtDataValue
A7rzcnZTe2T,ACTIVE,eBAyeGv0exc,Zj7UnCAulEk,RiLEKhWHlxZ,DwpbWkiqjMy,2023-02-12T23:00:00Z,2023-02-12T23:00:00Z,"POINT (-11.468912037323042 7.515913998868316)",7.515913998868316,-11.468912037323042,false,false,2017-09-08T19:40:22Z,,2017-09-08T19:40:22Z,,,,,HllvX50cXC0,xYerKDKCefk,,F3ogKBuviRA,"[-11.4880220438585,7.50978830548003]",admin,false,,2016-12-06T17:22:34.438Z,2016-12-06T17:22:34.438Z
A7rzcnZTe2T,ACTIVE,eBAyeGv0exc,Zj7UnCAulEk,RiLEKhWHlxZ,DwpbWkiqjMy,2023-02-12T23:00:00Z,2023-02-12T23:00:00Z,"POINT (-11.468912037323042 7.515913998868316)",7.515913998868316,-11.468912037323042,false,false,2017-09-08T19:40:22Z,,2017-09-08T19:40:22Z,,,,,HllvX50cXC0,xYerKDKCefk,,eMyVanycQSC,2018-02-07,admin,false,,2013-12-30T13:23:57.423Z,2013-12-30T13:23:57.423Z
A7rzcnZTe2T,ACTIVE,eBAyeGv0exc,Zj7UnCAulEk,RiLEKhWHlxZ,DwpbWkiqjMy,2023-02-12T23:00:00Z,2023-02-12T23:00:00Z,"POINT (-11.468912037323042 7.515913998868316)",7.515913998868316,-11.468912037323042,false,false,2017-09-08T19:40:22Z,,2017-09-08T19:40:22Z,,,,,HllvX50cXC0,xYerKDKCefk,,msodh3rEMJa,2018-02-13,admin,false,,2013-12-30T13:23:57.467Z,2013-12-30T13:23:57.467Z
Koncový bod jednoho objektu událostí GET /api/tracker/events/{uid}¶
Účelem tohoto koncového bodu je načíst jednu událost s jejím uid.
Požádat o syntaxi¶
GET /api/tracker/events/{uid}?fields={fields}
| Parametr požadavku | Typ | Povolené hodnoty | Popis |
|---|---|---|---|
uid | String | uid | Vraťte událost se zadaným uid |
fields | String | Jakýkoli platný filtr polí (výchozí *,!relationships) | Zahrnout do odpovědi zadané dílčí objekty |
Example requests¶
Dotaz na událost:
GET /api/tracker/events/rgWr86qs0sI
Event response example¶
The API supports CSV and JSON response for GET /api/tracker/trackedEntities
JSON¶
{
"event": "rgWr86qs0sI",
"status": "ACTIVE",
"program": "kla3mAPgvCH",
"programStage": "aNLq9ZYoy9W",
"enrollment": "Lo3SHzCnMSm",
"orgUnit": "DiszpKrYNg8",
"occurredAt": "2024-10-12T00:00:00.000",
"followUp": false,
"deleted": false,
"createdAt": "2018-10-20T12:09:19.492",
"createdAtClient": "2017-10-20T12:09:19.492",
"updatedAt": "2018-10-20T12:09:19.492",
"attributeOptionCombo": "amw2rQP6r6M",
"attributeCategoryOptions": "RkbOhHwiOgW",
"dataValues": [
{
"createdAt": "2015-10-20T12:09:19.640",
"updatedAt": "2015-10-20T12:09:19.640",
"storedBy": "system",
"providedElsewhere": false,
"dataElement": "HyJL2Lt37jN",
"value": "12"
}
],
"notes": [],
"followup": false
}
CSV¶
The response will be the same as the collection endpoint but referring to a single event, although it might have multiple rows for each data element value.
Event data value change logs¶
GET /api/tracker/events/{uid}/changeLogs
This endpoint retrieves change logs for the data values of a specific event. It returns a list of all event data values that have changed over time for that particular event.
| Parametr | Typ | Povolené hodnoty |
|---|---|---|
path /{uid} | String | Event UID. |
Event data value change logs response example¶
Příklad odpovědi json:
{
"pager":{
"page":1,
"pageSize":10
},
"changeLogs":[
{
"createdBy":{
"uid":"AIK2aQOJIbj",
"username":"tracker",
"firstName":"Tracker demo",
"surname":"User"
},
"createdAt":"2024-06-20T15:43:36.342",
"type":"DELETE",
"change":{
"dataValue":{
"dataElement":"UXz7xuGCEhU",
"previousValue":"12"
}
}
},
{
"createdBy":{
"uid":"AIK2aQOJIbj",
"username":"tracker",
"firstName":"Tracker demo",
"surname":"User"
},
"createdAt":"2024-06-20T15:43:27.175",
"type":"CREATE",
"change":{
"dataValue":{
"dataElement":"UXz7xuGCEhU",
"currentValue":"12"
}
}
},
{
"createdBy":{
"uid":"AIK2aQOJIbj",
"username":"tracker",
"firstName":"Tracker demo",
"surname":"User"
},
"createdAt":"2024-06-20T14:51:16.433",
"type":"UPDATE",
"change":{
"dataValue":{
"dataElement":"bx6fsa0t90x",
"previousValue":"true",
"currentValue":"false"
}
}
}
]
}
The change log type can be CREATE, UPDATE, or DELETE. CREATE and DELETE will always hold a single value: the former shows the current value, and the latter shows the value that was deleted. UPDATE will hold two values: the previous and the current.
Relationships (GET /api/tracker/relationships)¶
Relationships are links between two entities in the Tracker. These entities can be tracked entities, enrollments, and events.
Účelem tohoto koncového bodu je načíst vztahy mezi objekty.
Na rozdíl od jiných koncových bodů trasovaných objektů vztahy odhalují pouze jeden koncový bod:
GET /api/tracker/relationships?[trackedEntity={trackedEntityUid}|enrollment={enrollmentUid}|event={eventUid}]&fields=[fields]
Request parameters¶
| Parametr požadavku | Typ | Povolené hodnoty | Popis |
|---|---|---|---|
trackedEntity | String | uid | Identifier of a tracked entity |
enrollment | String | uid | Identifier of an enrollment |
event | String | uid | Identifier of an event |
fields | String | Any valid field filter (default relationship,relationshipType,createdAtClient,from[trackedEntity[trackedEntity],enrollment[enrollment],event[event]],to[trackedEntity[trackedEntity],enrollment[enrollment],event[event]]) | Zahrnout do odpovědi zadané dílčí objekty |
order | String | Comma-separated list of property name or attribute or UID and sort direction pairs in format propName:sortDirection. | Supported fields: createdAt, createdAtClient. |
includeDeleted | Boolean | true|false | whether to include soft-deleted elements in your query result |
Následující pravidla platí pro parametry dotazu.
- lze předat pouze jeden parametr mezi
trackedEntity,enrollment,event
NOTE
Using
trackedEntity,enrollmentoreventparams, will return any relationship where the trackedEntity, enrollment or event is part of the relationship (either from or to). As long as the user has access to it.
Example response¶
{
"pager": {
"page": 1,
"pageSize": 2
},
"relationships": [
{
"relationship": "oGtgtJpp6fG",
"relationshipType": "Mv8R4MPcNcX",
"from": {
"trackedEntity": {
"trackedEntity": "neR4cmMY22o"
}
},
"to": {
"trackedEntity": {
"trackedEntity": "DsSlC54GNXy"
}
}
},
{
"relationship": "SSfIicJKbh5",
"relationshipType": "Mv8R4MPcNcX",
"from": {
"trackedEntity": {
"trackedEntity": "neR4cmMY22o"
}
},
"to": {
"trackedEntity": {
"trackedEntity": "rEYUGH97Ssd"
}
}
}
]
}
Tracker Access Control¶
Tracker has a few different concepts in regards to access control, like sharing, organisation unit scopes, ownership, and access levels. The following sections provide a short introduction to the different topics.
Sdílení metadat¶
Sharing setting is standard DHIS2 functionality that applies to both Tracker and Aggregate metadata/data as well as dashboards and visualization items. At the core of sharing is the ability to define who can see/do what. In general, there are five possible sharing configurations – no access, metadata read, metadata write, data read, and data write. These access configurations can be granted at user and/or user group level (for more flexibility). With a focus on Tracker, the following metadata and their sharing setting is of particular importance: Data Element, Category Option, Program, Program Stage, Tracked Entity Type, Tracked Entity Attribute as well as Tracker related Dashboards and Dashboard Items.
How sharing setting works is straightforward – the settings are enforced during Tracker data import/export processes. To read value, one needs to have data read access. If a user is expected to modify data, he/she needs to have data write access. Similarly, if a user is expected to modify metadata, it is essential to grant metadata write access.
One critical point with Tracker data is the need to have a holistic approach. For example, a user won’t be able to see the Data Element value by having read access to just the Data Element. The user needs to have data read to access the parent Program Stage and Program where this Data Element belongs. It is the same with the category option combination. In Tracker, the Event is related to AttributeOptionCombo, which is made up of a combination of Category Options. Therefore, for a user to read data of an Event, he/she needs to have data read access to all Category Options and corresponding Categories that constitute the AttributeOptionCombo of the Event in question. If a user lacks access to just one Category Option or Category, then the user has no access to the entire Event.
When it comes to accessing Enrollment data, it is essential to have access to the Tracked Entity first. Access to a Tracked Entity is controlled through sharing setting of Program, Tracked Entity Type, and Tracked Entity Attribute. Once Enrollment is accessed, it is possible to access Event data, again depending on Program Stage and Data element sharing setting.
Another vital point to consider is how to map out access to different Program Stages of a Program. Sometimes we could be in a situation where we need to grant access to a specific stage – for example, “Lab Result” – to a specific group of users (Lab Technicians). In this situation, we can provide data write access to "Lab Result" stage, probably data read to one or more stages just in case we want Lab Technicians to read other medical results or no access if we think it not necessary for the Lab Technicians to see data other than lab related.
In summary, DHIS2 has a fine-grained sharing setting that we can use to implement access control mechanisms both at the data and metadata level. These sharing settings can be applied directly at the user level or user group level. How exactly to apply a sharing setting depends on the use-case at hand.
For more detailed information about data sharing, check out Data sharing.
Organisation Unit Scopes¶
Organisation units are one of the most fundamental objects in DHIS2. They define a universe under which a user is allowed to record and/or read data. There are three types of organisation units that can be assigned to a user. These are data capture, data view (not used in tracker), and tracker search. As the name implies, these organisation units define a scope under which a user is allowed to conduct the respective operations.
However, to further fine-tune the scope, DHIS2 Tracker introduces a concept that we call OrganisationUnitSelectionMode. Such a mode is often used at the time exporting tracker objects. For example, given that a user has a particular tracker search scope, does it mean that we have to use this scope every time a user tries to search for a tracker, Enrollment, or Event object? Or is the user interested in limiting the searching just to the selected org unit, or the entire capture org unit scope, and so on.
Users can do the fine-tuning by passing a specific value of orgUnitMode in their API request:
api/tracker/trackedEntities?orgUnit=UID&orgUnitMode=specific_organisation_unit_selection_mode
Currently, there are six selection modes available: SELECTED, CHILDREN, DESCENDANTS, CAPTURE, ACCESSIBLE, and ALL.
- SELECTED: As the name implies, this mode narrows down all operations initiated by the requesting API to the specified organisation unit in the request.
- CHILDREN: Under this mode, the organisation unit scope is constructed using the selected organisation unit and its immediate children, i.e., the organisation units at the level below.
- DESCENDANTS: In this mode, the selected organisation unit and everything underneath it, encompassing not only the immediate children but all descendants, constitute the data operation universe.
- CAPTURE: This mode includes the data capture organization units associated with the current user and all descendants. It encompasses all organization units in the sub-hierarchy.
- ACCESSIBLE: This mode is designed to retrieve data within the user's search scope organization units. This encompasses everything visible to the user, including open and audited programs within its search scope, as well as data in protected and closed programs within the user's capture scope. If a user lacks search organization units, the system defaults to capture scope, ensuring that the user always has access to at least one universe. The capture scope, being mandatory, serves as a foundational element in guaranteeing a data environment for the user.
- ALL: This mode is reserved for authorized users, specifically those with the authority ALL (super users). Users with the authority F_TRACKED_ENTITY_INSTANCE_SEARCH_IN_ALL_ORGUNITS can also search system-wide but need sharing access to the returned program, program stage, and/or tracked entity type. For non-authorized users, an exception will be raised.
The first three modes, SELECTED, CHILDREN and DESCENDANTS expect an organisation unit to be supplied in the request, while the last three, CAPTURE, ACCESSIBLE and ALL do not expect it and in fact the request will fail if an organisation unit is provided.
The organisation unit mode will be one of the ones listed above when it's explicitly provided in the API request. Since it's not a mandatory field, in case it's not specified, then the default value will be SELECTED if an organisation unit is present, and ACCESSIBLE otherwise.
It makes little sense to pass these modes at the time of tracker import operations. Because when writing tracker data, each of the objects needs to have a specific organisation unit attached to them. The system will then ensure if each of the mentioned organisation units falls under the CAPTURE scope. If not, the system will simply reject the write operation.
Note that there is 4 type of organisation unit associations relevant for Tracker objects. A TrackedEntity has an organisation unit, commonly referred to as the Registration Organisation unit. Enrollments have an organisation unit associated with them. Events also have an organisation unit associated with them. There is also an Owner organisation unit for a TrackedEntity-Program combination.
When fetching Tracker objects, depending on the context, the organisation unit scope is applied to one of the above four organisation unit associations.
For example, when retrieving TrackedEntities without the context of a program, the organisation unit scope is applied to the registration organisation unit of the TrackedEntity. Whereas, when retrieving TrackedEntities, including specific program data, the organisation unit scope is applied to the Owner organisation unit.
Tracker Program Ownership¶
A new concept called Tracker Ownership is introduced from 2.30. This introduces a new organisation unit association for a TrackedEntity - Program combination. We call this the Owner (or Owning) Organisation unit of a TrackedEntity in the context of a Program. The Owner organisation unit is used to decide access privileges when reading and writing tracker data related to a program. This, along with the Program's Access Level configuration, decides the access behavior for Program-related data (Enrollments and Events). A user can access a TrackedEntity's Program data if the corresponding Owner OrganisationUnit for that TrackedEntity-Program combination falls under the user's organisation unit scope (Search/Capture). For Programs that are configured with access level OPEN or AUDITED , the Owner OrganisationUnit has to be in the user's search scope. For Programs that are configured with access level PROTECTED or CLOSED , the Owner OrganisationUnit has to be in the user's capture scope to be able to access the corresponding program data for the specific tracked entity. Irrespective of the program access level, to access Tracker objects, the requested organisation unit must always be within the user's search scope. A user cannot request objects outside its search scope unless it's using the organisation unit mode ALL and has enough privileges to use that mode.
When requesting tracked entities without specifying a program, the response will include only tracked entities that satisfy metadata sharing settings and one of the following criteria: - The tracked entity is enrolled in at least one program the user has data access to, and the user has access to the owner organisation unit. - The tracked entity is not enrolled in any program the user has data access to, but the user has access to the tracked entity registering organisation unit.
Tracker Ownership Override: Break the Glass¶
It is possible to temporarily override the ownership privilege for a program that is configured with an access level of PROTECTED. Any user with the org unit owner within their search scope, can temporarily access the program-related data by providing a reason for accessing it.
This act of temporarily gaining access is termed breaking the glass. Currently, temporary access is granted for 3 hours. DHIS2 audits breaking the glass along with the reason specified by the user. It is not possible to gain temporary access to a program that has been configured with an access level of CLOSED.
To break the glass for a TrackedEntity-Program combination, the following POST request can be used:
/api/tracker/ownership/override?trackedEntity=DiszpKrYNg8&program=eBAyeGv0exc&reason=patient+showed+up+for+emergency+care
Převod vlastnictví trasovače¶
It is possible to transfer the ownership of a TrackedEntity-Program from one organisation unit to another. This will be useful in case of patient referrals or migrations. Only a user who has Ownership access (or temporary access by breaking the glass) can transfer the ownership. To transfer ownership of a TrackedEntity-Program to another organisation unit, the following PUT request can be used:
/api/tracker/ownership/transfer?trackedEntity=DiszpKrYNg8&program=eBAyeGv0exc&ou=EJNxP3WreNP
Úroveň přístupu¶
DHIS2 treats Tracker data with an extra level of protection. In addition to the standard feature of metadata and data protection through sharing settings, Tracker data are shielded with additional access level protection mechanisms. Currently, there are four access levels that can be configured for a Program: Open, Audited, Protected, and Closed.
These access levels are only triggered when users try to interact with program data, namely Enrollments and Events data. The different Access Level configuration for Program is a degree of openness (or closedness) of program data. Note that all other sharing settings are still respected, and the access level is only an additional layer of access control. Here is a short description of the four access levels that can be configured for a Program.
Open¶
This access level is the least restricted among the access levels. Data inside an OPEN program can be accessed and modified by users if the Owner organisation unit falls under the user's search scope. With this access level, accessing and modifying data outside the capture scope is possible without any justification or consequence.
Audited¶
This is the same as the Open access level. The difference here is that the system will automatically add an audit log entry on the data being accessed by the specific user.
Protected¶
This access level is slightly more restricted. Data inside a PROTECTED program can only be accessed by users if the Owner organisation unit falls under the user's capture scope. However, a user who only has the Owner organisation unit in the search scope can gain temporary ownership by breaking the glass. The user has to provide a justification of why they are accessing the data at hand. The system will then put a log of both the justification and access audit and provide temporary access for 3 hours to the user. Note that when breaking the glass, the Owner Organisation Unit remains unchanged, and only the user who has broken the glass gains temporary access.
Closed¶
This is the most restricted access level. Data recorded under programs configured with access level CLOSED will not be accessible if the Owner Organisation Unit does not fall within the user's capture scope. It is also not possible to break the glass or gain temporary ownership in this configuration. Note that it is still possible to transfer the ownership to another organisation unit. Only a user who has access to the data can transfer the ownership of a TrackedEntity-Program combination to another Organisation Unit. If ownership is transferred, the Owner Organisation Unit is updated.