It is preferable to always supply an explicit list of fields so this section¶
will do so.
List organisation units with id and name:¶
/api/organisationUnits/gist?fields=id,name
List organisation units with id and name and total count:
/api/organisationUnits/gist?fields=id,name&total=true¶
List users with id and username:
/api/users/gist?fields=id,userCredentials.username
List users with id, username and last login date:
/api/users/gist?fields=id,userCredentials[username,lastLogin]
List only organisation units on second level with id, name and level:
/api/organisationUnits/gist?fields=id,name,level&filter=level:eq:2
List only organisation units that have more than 1 child with id, name and number of children:
/api/organisationUnits/gist?fields=id,name,children::size&filter=children:gt:1
List only organisation units that are not yet a children of another unit zFDYIgyGmXG:
/api/organisationUnits/zFDYIgyGmXG/children/gist?fields=id,name&inverse=true
List users and flag whether they are a member of a specific user group NTC8GjJ7p8P and name that field is-member in the response:
/api/users/gist?fields=id,userCredentials.username,userGroups::member(NTC8GjJ7p8P)~rename(is-member)
List links to all users in pages of 10 items:
/api/users/gist?fields=href&absoluteUrls&pageSize=10
数据 { #data }
“ dataelement”,“ period”,“ orgunit”,“ catoptcombo”,“ attroptcombo”,“ value”,“ strby”,“ lstupd”,“ cmt”
“ dataElementID”,“ period”,“ orgUnitID”,“ cocID”,“ aocID”,“ 1”,“用户名”,“ 2015-04-01”,“ comment1”
“ dataElementID”,“ period”,“ orgUnitID”,“ cocID”,“ aocID”,“ 2”,“用户名”,“ 2015-04-01”,“ comment2”
“ dataElementID”,“ period”,“ orgUnitID”,“ cocID”,“ aocID”,“ 3”,“用户名”,“ 2015-04-01”,“ comment3”
本节关于发送和读取数据值。
/api/dataValueSets
发送数据值 { #webapi_sending_data_values }
To send data values you can make a POST request to the following resource.
POST /api/dataValueSets
A common use-case for system integration is the need to send a set of data values from a third-party system into DHIS. In this example, we will use the DHIS2 demo on http://play.dhis2.org/demo as basis. We assume that we have collected case-based data using a simple software client running on mobile phones for the Mortality <5 years data set in the community of Ngelehun CHC (in Badjia chiefdom, Bo district) for the month of January 2014. We have now aggregated our data into a statistical report and want to send that data to the DHIS2 instance. The base URL to the demo API is http://play.dhis2.org/demo/api. The following links are relative to the base URL.
最适合我们发送数据的资源 values 是 /api/dataValueSets 资源。一个数据值集代表一个 一组具有关系的数据值,通常来自 从相同的数据输入表单中捕获。格式看起来像 这:
```xml¶
JSON支持以下格式:
```json
{
"dataSet": "dataSetID",
"completeDate": "date",
"period": "period",
"orgUnit": "orgUnitID",
"attributeOptionCombo": "aocID",
"dataValues": [
{
"dataElement": "dataElementID",
"categoryOptionCombo": "cocID",
"value": "1",
"comment": "comment1"
},
{
"dataElement": "dataElementID",
"categoryOptionCombo": "cocID",
"value": "2",
"comment": "comment2"
},
{
"dataElement": "dataElementID",
"categoryOptionCombo": "cocID",
"value": "3",
"comment": "comment3"
}
]
}
CSV支持以下格式:
“ dataelement”,“ period”,“ orgunit”,“ catoptcombo”,“ attroptcombo”,“ value”,“ strby”,“ lstupd”,“ cmt”
“ dataElementID”,“ period”,“ orgUnitID”,“ cocID”,“ aocID”,“ 1”,“用户名”,“ 2015-04-01”,“ comment1”
“ dataElementID”,“ period”,“ orgUnitID”,“ cocID”,“ aocID”,“ 2”,“用户名”,“ 2015-04-01”,“ comment2”
“ dataElementID”,“ period”,“ orgUnitID”,“ cocID”,“ aocID”,“ 3”,“用户名”,“ 2015-04-01”,“ comment3”
Note
Please refer to the date and period section above for time formats.
Note
Any imported data value which is seen as unchanged will be ignored and the import summary will reflect this. An unchanged data value is classed as one which has the same value for all 3 of these properties: - value - comment - followUp
从这个例子中,我们可以看出我们需要识别周期, 数据集、组织单位(设施)和数据元素 报告。
To obtain the identifier for the data set we make a request to the /api/dataSets resource. From there we find and follow the link to the Mortality < 5 years data set which leads us to /api/dataSets/pBOMPrpg1QX. The resource representation for the Mortality < 5 years data set conveniently advertises links to the data elements which are members of it. From here we can follow these links and obtain the identifiers of the data elements. For brevity we will only report on three data elements: Measles with id f7n9E0hX8qk, Dysentery with id Ix2HsbDMLea and Cholera with id eY5ehpbEsB7.
剩下的就是掌握组织的标识符 单元。 dataSet 表示方便地提供了到组织的链接 报告它的单位,所以我们搜索 Ngelehun CHC 并按照 链接到 /api/organisationUnits/DiszpKrYNg8 中的 HTML 表示,其中 告诉我们这个组织单位的标识符是DiszpKrYNg8。
发送数据值 { #webapi_sending_data_values }
<dataValueSet xmlns="http://dhis2.org/schema/dxf/2.0" dataSet="pBOMPrpg1QX"
completeDate="2014-02-03" period="201401" orgUnit="DiszpKrYNg8">
<dataValue dataElement="f7n9E0hX8qk" value="12"/>
<dataValue dataElement="Ix2HsbDMLea" value="14"/>
<dataValue dataElement="eY5ehpbEsB7" value="16"/>
</dataValueSet>
JSON格式:
{
"dataSet": "pBOMPrpg1QX",
"completeDate": "2014-02-03",
"period": "201401",
"orgUnit": "DiszpKrYNg8",
"dataValues": [
{
"dataElement": "f7n9E0hX8qk",
"value": "1"
},
{
"dataElement": "Ix2HsbDMLea",
"value": "2"
},
{
"dataElement": "eY5ehpbEsB7",
"value": "3"
}
]
}
To perform functional testing we will use the curl tool which provides an easy way of transferring data using HTTP. First, we save the data value set XML content in a file called datavalueset.xml. From the directory where this file resides we invoke the following from the command line:
curl -d @datavalueset.xml "https://play.dhis2.org/demo/api/dataValueSets"
-H "Content-Type:application/xml" -u admin:district
要发送 JSON 内容,您必须设置 content-type 标头¶
因此:
curl -d @datavalueset.json "https://play.dhis2.org/demo/api/dataValueSets"
-H "Content-Type:application/json" -u admin:district
选项(第一项为默认值)
| 默认值 | 发送大量数据值 { #webapi_sending_bulks_data_values } | Parameter name |
|---|---|---|
| DateTime | CSV格式: | JSON格式: |
| programStageIdScheme | CSV格式: | ```csv |
| “ dataelement”,“ period”,“ orgunit”,“ categoryoptioncombo”,“ attributeoptioncombo”,“ value” | ||
| “ f7n9E0hX8qk”,“ 201401”,“ DiszpKrYNg8”,“ bRowv6yZOF2”,“ bRowv6yZOF2”,“ 1” | ||
| “ Ix2HsbDMLea”,“ 201401”,“ DiszpKrYNg8”,“ bRowv6yZOF2”,“ bRowv6yZOF2”,“ 2” | ||
| “ eY5ehpbEsB7”,“ 201401”,“ DiszpKrYNg8”,“ bRowv6yZOF2”,“ bRowv6yZOF2”,“ 3” | ||
| ``` | ||
| End date for the time span of the values to export | orgUnitIdScheme | 请注意,使用 CSV 格式时,您必须使用二进制数据选项 |
| 保留 CSV 文件中的换行符: | ||
| programIdScheme | CSV格式: | ```xml |
| ``` | ||
| outlining how to resolve identified issues | orgUnitIdScheme | The import process can be customized using a set of import parameters. |
| Table: Import parameters | orgUnitIdScheme | Values (default first) |
UID, CODE, NAME, ATTRIBUTE:{uid} | orgUnitIdScheme | uid | name | code | attribute:ID |
| 描述 | orgUnitIdScheme | uid | name | code | attribute:ID |
| 假 | 假 | uid | name | code| attribute:ID |
| 总览 | 假 | source.target.request.categoryOptionComboIdScheme |
Sets import strategy, CREATE_AND_UPDATE will try and match on identifier, if it doesn't exist, it will create the object. | dataSetIdScheme | id | name | code | attribute:ID |
| Property of the data set to use to map the complete registrations. | 假 | uid | name | code| attribute:ID |
| Property of the category object to use to map the data values (ADX only). | 假 | source.target.request.orgUnitIdScheme |
| 异步导入时,会立即返回一个 Location 标头,指向 importReport 的位置。有效载荷还包含一个已创建任务的 json 对象。 | 假 | id | name | code | attribute:ID |
| Property of any of the above objects if they are not specified, to use to map the data values. | 假 | false | true |
| 描述 | storedByDataValue | false | true |
Whether to save changes on the server or just return the import summary.
importStrategy
CREATE | UPDATE | CREATE_AND_UPDATE | DELETE
Save objects of all, new or update import status on the server.
skipExistingCheck
false | true¶
Skip checks for existing data values. Improves performance. Only use for empty databases or when the data values to import do not exist already.
skipAudit
| false | true | Skip audit, meaning audit values will not be generated. Improves performance at the cost of ability to audit changes. Requires authority "F_SKIP_DATA_IMPORT_AUDIT". | async |
|---|---|---|
JSON object for ADD proposal, JSON array for UPDATE proposal, nothing for REMOVE proposal | Indicates whether the import should be done asynchronous or synchronous. The former is suitable for very large imports as it ensures that the request does not time out, although it has a significant performance overhead. The latter is faster but requires the connection to persist until the process is finished. | force |
false | true¶
Indicates whether the import should be forced. Data import could be rejected for various reasons of data set locking for example due to approval, data input period, expiry days, etc. In order to override such locks and force data input one can use data import with force=true. However, one needs to be a *superuser* for this parameter to work.
dataSet
uid
-
Provide the data set ID for CSV import where the ID cannot be provided in the file itself 所有参数都是可选的,可以作为查询参数提供 请求 URL 是这样的:
-
/api/dataValueSets?dataElementIdScheme=code&orgUnitIdScheme=name &dryRun=true&importStrategy=CREATE 它们也可以作为数据值集上的 XML 属性提供 元素如下。 XML 属性将覆盖查询字符串 参数。
-
```xml
请注意,`preheatCache` 参数会对 表现。对于小的导入文件,将其设置为 false 会很快。 对于包含大量不同数据的大型导入文件 元素和组织单位,将其设置为 true 将是 幅度更快。 数据值要求 { #webapi_data_values_import_requirement } - storedByDataValue - 是的 - displayColumnOrder - 要求 评论 #### BOOLEAN true | True | TRUE | false | False | FALSE | 1 | 0 | t | f | Used when the value is a boolean, true or false value. The import service does not care if the input begins with an uppercase or lowercase letter, or if it's all uppercase. 标识符方案 { #webapi_data_values_identifier_schemes } Regarding the id schemes, by default the identifiers used in the XML messages use the DHIS2 stable object identifiers referred to as `UID`. In certain interoperability situations we might experience that an external system decides the identifiers of the objects. In that case we can use the `code` property of the organisation units and other objects to set fixed identifiers. When importing data values we hence need to reference the code property instead of the identifier property of these metadata objects. Identifier schemes can be specified in the XML message as well as in the request as query parameters. To specify it in the XML payload you can do this: ```xml <dataValueSet xmlns="http://dhis2.org/schema/dxf/2.0" dataElementIdScheme="CODE" orgUnitIdScheme="UID" idScheme="CODE"> </dataValueSet>
上面的参数表解释了如何指定 id 方案¶
作为查询参数。以下规则适用于 优先级:
XML 或 JSON 负载中定义的 ID 方案优先于
id 方案定义为 URL 查询参数。
| Specific id schemes such as dataElementIdScheme or | 检索和删除项目通知模板 | Parameter name |
| 描述 | ```json | |
| { | ||
| "name": "Case notification", | ||
| "notificationTrigger": "ENROLLMENT", | ||
| "subjectTemplate": "Case notification V{org_unit_name}", | ||
| "displaySubjectTemplate": "Case notification V{org_unit_name}", | ||
| "notifyUsersInHierarchyOnly": false, | ||
| "sendRepeatable": false, | ||
| "notificationRecipient": "ORGANISATION_UNIT_CONTACT", | ||
| "notifyParentOrganisationUnitOnly": false, | ||
| "displayMessageTemplate": "Case notification A{h5FuguPFF2j}", | ||
| "messageTemplate": "Case notification A{h5FuguPFF2j}", | ||
| "deliveryChannels": [ | ||
| "EMAIL" | ||
| ] | ||
| } | ||
| ``` | uid | |
| 码 | ```json | |
| { | ||
| "name": "Case notification", | ||
| "notificationTrigger": "ENROLLMENT", | ||
| "subjectTemplate": "Case notification V{org_unit_name}", | ||
| "displaySubjectTemplate": "Case notification V{org_unit_name}", | ||
| "notifyUsersInHierarchyOnly": false, | ||
| "sendRepeatable": false, | ||
| "notificationRecipient": "ORGANISATION_UNIT_CONTACT", | ||
| "notifyParentOrganisationUnitOnly": false, | ||
| "displayMessageTemplate": "Case notification A{h5FuguPFF2j}", | ||
| "messageTemplate": "Case notification A{h5FuguPFF2j}", | ||
| "deliveryChannels": [ | ||
| "EMAIL" | ||
| ] | ||
| } | ||
| ``` | 属性(后跟属性的UID) | |
| 属性选项是特殊的,指的是元数据属性 | ||
已被标记为*独特*。使用此选项时,attribute 必须 | ||
| 紧随其后的是属性的标识符,例如 | ||
| “属性:DnrLSdo4hMl”。 | ```json | |
| { | ||
| "name": "Case notification", | ||
| "notificationTrigger": "ENROLLMENT", | ||
| "subjectTemplate": "Case notification V{org_unit_name}", | ||
| "displaySubjectTemplate": "Case notification V{org_unit_name}", | ||
| "notifyUsersInHierarchyOnly": false, | ||
| "sendRepeatable": false, | ||
| "notificationRecipient": "ORGANISATION_UNIT_CONTACT", | ||
| "notifyParentOrganisationUnitOnly": false, | ||
| "displayMessageTemplate": "Case notification A{h5FuguPFF2j}", | ||
| "messageTemplate": "Case notification A{h5FuguPFF2j}", | ||
| "deliveryChannels": [ | ||
| "EMAIL" | ||
| ] | ||
| } | ||
| ``` | uid | |
| /api/dataValueSets?async=true | Program notification template | ```json |
| { | ||
| "httpStatus": "OK", | ||
| "httpStatusCode": 200, | ||
| "status": "OK", | ||
| "message": "Initiated dataValueImport", | ||
| "response": { | ||
| "name": "dataValueImport", | ||
| "id": "YR1UxOUXmzT", | ||
| "created": "2018-08-20T14:17:28.429", | ||
| "jobType": "DATAVALUE_IMPORT", | ||
| "relativeNotifierEndpoint": "/api/system/tasks/DATAVALUE_IMPORT/YR1UxOUXmzT" | ||
| } | ||
| } | ||
| ``` | ||
| 请阅读有关*异步任务状态*的部分了解更多信息 | ||
| 信息。 | Program notification template | 以下部分描述了 DHIS2 中使用的 CSV 格式。首先 |
| 行被假定为标题行,在导入期间将被忽略。 | ||
| ```json | ||
| { | ||
| "object": { | ||
| "publicAccess": "rw------", | ||
| "externalAccess": false, | ||
| "user": {}, | ||
| "userAccesses": [], | ||
| "userGroupAccesses": [ | ||
| { | ||
| "id": "hj0nnsVsPLU", | ||
| "access": "rw------" | ||
| }, | ||
| { | ||
| "id": "qMjBflJMOfB", | ||
| "access": "r-------" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ``` | Program notification template | 需要 |
| 描述 | Program notification template | 是的 |
| Refers to ID by default, can also be name and code based on selected id scheme | Program notification template | 是的 |
| async | Program notification template | 是的 |
| Refers to ID by default, can also be name and code based on selected id scheme | Program notification template | 不 |
Refers to ID
Attribute option combo
不¶
Refers to ID (from version 2.16)
值
不
您还可以请求CSV格式的数据,如下所示:
| eventCreatedPeriod | 检索和删除项目通知模板 | Parameter name |
|---|---|---|
| eventDate | Program notification template | Date in ISO format |
{"type":"ABSOLUTE","startDate":"2020-03-01","endDate":"2022-12-30"} | Program notification template | Free text comment |
| 描述 | Program notification template | true or false |
| programStageIdScheme | Program notification template | 生成数据值集模板 { #webapi_data_values_template } |
| DateTime | Program notification template | 描述了可用于进一步调整输出的参数 |
| 以下: |
Table: Data values query parameters¶
查询参数
需要
描述
Whether to save changes on the server or just return the import summary.
| 默认值 | Parameter name |
|---|---|
| 描述 | 不 |
| Organisation unit to use, supports multiple orgUnits, both id and code can be used. | comment |
| 最小最大数据元素 | Should comments be include, default: Yes. |
| eventDate | 不 |
| dueDate | 数据元素标识方案 |
| lastUpdatedDate | Data-element scheme to use, supports id | code. |
{"type":"ABSOLUTE","startDate":"2020-03-01","endDate":"2022-12-30"} | To read data values you can make a GET request to the following resource. |
| Table: Data value set query parameters | Data values can be retrieved in XML, JSON, CSV, and ADX format. Since we want to read data we will use the GET HTTP verb. We will also specify that we are |
interested in the XML resource representation by including an Accept HTTP header with our request. The following query parameters are | |
| available. | |
| 读取完整的数据集注册 { #webapi_reading_complete_data_sets } | Parameter |
| > 注 | |
| > | |
| > 以下属性可能使用了外部系统的引用,因此被特意排除在合并之外。如果这些字段出现问题,可能需要更新。 | |
| > | |
| > 指标: aggregateExportCategoryOptionCombo & aggregateExportAttributeOptionCombo | |
| > | |
| > 项目指标: aggregateExportCategoryOptionCombo & aggregateExportAttributeOptionCombo | dataSet |
| 串 | dataElementGroup |
| 不 | dataElement |
| Data element identifier. Can be repeated any number of times. | period |
| 不 | 开始日期 |
| DateTime | 结束日期 |
| programStageIdScheme | orgUnit |
| programIdScheme | children |
| End date for the time span of the values to export | orgUnitGroup |
| outlining how to resolve identified issues | attributeOptionCombo |
| Table: Import parameters | includeDeleted |
UID, CODE, NAME, ATTRIBUTE:{uid} | lastUpdated |
| 描述 | lastUpdatedDuration |
| Include only data values which are updated within the given duration. The format is <value><time-unit>, where the supported time units are "d" (days), "h" (hours), "m" (minutes) and "s" (seconds). | limit |
| The max number of results in the response. | 数据元素标识方案 |
| Property of the data element object to use for data values in response. | orgUnitIdScheme |
| Property of the org unit object to use for data values in response. | categoryOptionComboIdScheme |
| The name of the headers to be returned as part of the response. One or more headers name separated by comma | attributeOptionComboIdScheme |
| Property of the attribute option combo objects to use for data values in response. | dataSetIdScheme |
| Property of the data set object to use in the response. | categoryIdScheme |
Property of the category object to use in the response (ADX only). - categoryOptionIdScheme - Property of the category option object to use in the response (ADX only). - 方案
Property of any of the above objects if they are not specified, to use in the response. If not specified, the default idScheme for ADX is code, and for all other formats is uid.
-
E7126
-
临界点
-
组织单位分析资源使您可以指定一系列查询参数:
-
Identifier property used for the provided
dataSetparameter values;idorcode
inputDataElementGroupIdScheme
Identifier property used for the provided dataElementGroup parameter values; id or code
inputDataElementIdScheme
Identifier property used for the provided dataElement parameter values; id or code
inputIdScheme
General identifier property used for all object types, specific identifier schemes will override the general scheme; id or code
The following parameters from the list above are required:
Whether to compress the response payload; none, gzip or zip
attachment
File name to use for the response, a non-blank value indicates rendering the response as an attachment.
The following parameters from the list above are required:
either dataSet or dataElementGroup (for ADX this must be dataSet)
either period, both startDate and endDate, lastUpdated, or lastUpdatedDuration
either orgUnit or orgUnitGroup
支持以下响应格式:
xml(应用项目/ xml)
The following parameters from the list above are required:
csv(应用项目/ csv)
adx(应用项目/ adx + xml)
假设我们已经根据 上一节称为 发送数据值 我们现在可以放在一起 我们对单个数据值集的请求并使用 cURL 请求它:
curl "https://play.dhis2.org/demo/api/dataValueSets?dataSet=pBOMPrpg1QX&period=201401&orgUnit=DiszpKrYNg8"
-H "Accept:application/xml" -u admin:district
我们还可以使用开始和结束日期查询参数来请求一个 大量的数据值。 IE。您还可以请求数据值 多个数据集和组织单位以及一个时间跨度以便导出 更大的数据块。请注意,期间查询参数采用 优先于开始和结束日期参数。一个例子看起来像 这:
-
```bash curl "https://play.dhis2.org/demo/api/dataValueSets?dataSet=pBOMPrpg1QX&dataSet=BfMAe6Itzgt &startDate=2013-01-01&endDate=2013-01-31&orgUnit=YuQRtpLP10I&orgUnit=vWbkYPRmKyS&children=true" -H "Accept:application/xml" -u admin:district
您可以使用JSON格式请求数据,如下所示:- 检索已创建或更新的数据值 过去 10 天,您可以提出这样的请求: / api / dataValueSets?dataSet = pBOMPrpg1QX&orgUnit = DiszpKrYNg8&lastUpdatedDuration = 10d - A robust measure of the spread of data values, calculated as the median of the absolute deviations from the median. - ```xml <?xml version='1.0' encoding='UTF-8'?> <dataValueSet xmlns="http://dhis2.org/schema/dxf/2.0" dataSet="pBOMPrpg1QX" completeDate="2014-01-02" period="201401" orgUnit="DiszpKrYNg8"> <dataValue dataElement="eY5ehpbEsB7" period="201401" orgUnit="DiszpKrYNg8" categoryOptionCombo="bRowv6yZOF2" value="10003"/> <dataValue dataElement="Ix2HsbDMLea" period="201401" orgUnit="DiszpKrYNg8" categoryOptionCombo="bRowv6yZOF2" value="10002"/> <dataValue dataElement="f7n9E0hX8qk" period="201401" orgUnit="DiszpKrYNg8" categoryOptionCombo="bRowv6yZOF2" value="10001"/> </dataValueSet> -
/api/dataValueSets.json?dataSet=pBOMPrpg1QX&period=201401&orgUnit=DiszpKrYNg8
响应将如下所示:¶
{
"dataSet": "pBOMPrpg1QX",
"completeDate": "2014-02-03",
"period": "201401",
"orgUnit": "DiszpKrYNg8",
"dataValues": [
{
"dataElement": "eY5ehpbEsB7",
"categoryOptionCombo": "bRowv6yZOF2",
"period": "201401",
"orgUnit": "DiszpKrYNg8",
"value": "10003"
},
{
"dataElement": "Ix2HsbDMLea",
"categoryOptionCombo": "bRowv6yZOF2",
"period": "201401",
"orgUnit": "DiszpKrYNg8",
"value": "10002"
},
{
"dataElement": "f7n9E0hX8qk",
"categoryOptionCombo": "bRowv6yZOF2",
"period": "201401",
"orgUnit": "DiszpKrYNg8",
"value": "10001"
}
]
}
请注意,数据值是软删除的,即删除的值具有 deleted 属性设置为 true 而不是被永久删除。 这在集成多个系统以进行通信时很有用 删除。您可以在响应中包含已删除的值,如下所示:
/api/dataValueSets.json?dataSet=pBOMPrpg1QX&period=201401
&orgUnit=DiszpKrYNg8&includeDeleted=true
您还可以请求CSV格式的数据,如下所示:
| eventCreatedPeriod | 检索和删除项目通知模板 | Parameter name |
|---|---|---|
| Any delete operation will require the authority Perform maintenance tasks. | ```json | |
| { | ||
| "name": "Case notification", | ||
| "notificationTrigger": "ENROLLMENT", | ||
| "subjectTemplate": "Case notification V{org_unit_name}", | ||
| "displaySubjectTemplate": "Case notification V{org_unit_name}", | ||
| "notifyUsersInHierarchyOnly": false, | ||
| "sendRepeatable": false, | ||
| "notificationRecipient": "ORGANISATION_UNIT_CONTACT", | ||
| "notifyParentOrganisationUnitOnly": false, | ||
| "displayMessageTemplate": "Case notification A{h5FuguPFF2j}", | ||
| "messageTemplate": "Case notification A{h5FuguPFF2j}", | ||
| "deliveryChannels": [ | ||
| "EMAIL" | ||
| ] | ||
| } | ||
| ``` | / api / 33 / system / flags | |
| E7228 | ```json | |
| { | ||
| "name": "Case notification", | ||
| "notificationTrigger": "ENROLLMENT", | ||
| "subjectTemplate": "Case notification V{org_unit_name}", | ||
| "displaySubjectTemplate": "Case notification V{org_unit_name}", | ||
| "notifyUsersInHierarchyOnly": false, | ||
| "sendRepeatable": false, | ||
| "notificationRecipient": "ORGANISATION_UNIT_CONTACT", | ||
| "notifyParentOrganisationUnitOnly": false, | ||
| "displayMessageTemplate": "Case notification A{h5FuguPFF2j}", | ||
| "messageTemplate": "Case notification A{h5FuguPFF2j}", | ||
| "deliveryChannels": [ | ||
| "EMAIL" | ||
| ] | ||
| } | ||
| ``` | 必须是至少一个期间或开始日期和结束日期 | |
| Filter on whether the current user can manage the returned users through the managed user group relationships. | ```json | |
| { | ||
| "name": "Case notification", | ||
| "notificationTrigger": "ENROLLMENT", | ||
| "subjectTemplate": "Case notification V{org_unit_name}", | ||
| "displaySubjectTemplate": "Case notification V{org_unit_name}", | ||
| "notifyUsersInHierarchyOnly": false, | ||
| "sendRepeatable": false, | ||
| "notificationRecipient": "ORGANISATION_UNIT_CONTACT", | ||
| "notifyParentOrganisationUnitOnly": false, | ||
| "displayMessageTemplate": "Case notification A{h5FuguPFF2j}", | ||
| "messageTemplate": "Case notification A{h5FuguPFF2j}", | ||
| "deliveryChannels": [ | ||
| "EMAIL" | ||
| ] | ||
| } | ||
| ``` | / api / 33 / system / taskSummaries / {task-category-id} | |
| 描述 | Program notification template | 发送,读取和删除单个数据值 { #webapi_sending_individual_data_values } |
| ```bash | ||
| GET /api/33/completeDataSetRegistrations?dataSet=pBOMPrpg1QX | ||
| &startDate=2014-01-01&endDate=2014-01-31&orgUnit=YuQRtpLP10I | ||
| &orgUnit=vWbkYPRmKyS&children=true | ||
| ``` | POST /api/dataValues | 此资源支持以下查询参数: |
| 本节说明如何取消注册数据的完整性 | ||
| 放。要取消完成数据集,您将与 | ||
| completeDataSetRegistrations 资源: | 查询参数 | 需要 |
| Table: Query parameters | Program notification template | 是的 |
| 日期时间 | Program notification template | 是的 |
| 描述 | Program notification template | 是的 |
| Table: Program Stage Query Criteria | Program notification template | 不 |
Category option combo identifier, default will be used if omitted
cc
No (must be combined with cp)
Attribute category combo identifier
cp
No (must be combined with cc)
Attribute category option identifiers, separated with ; for multiple values
ds¶
不
Data set, to check if POST or DELETE is allowed for period and organisation unit. If specified, the data element must be assigned to this data set. If not specified, a data set containing the data element will be chosen to check if the operation is allowed.
价值
不
Data value. For boolean values, the following will be accepted: true | True | TRUE | false | False | FALSE | 1 | 0 | t | f |
comment
不
Data comment¶
跟进
不
-
Follow up on data value, will toggle the current boolean value 如果给定的任何标识符无效,如果数据值或 评论无效或如果数据被锁定,响应将包含 409 Conflict 状态代码和描述性文本消息。如果 操作导致保存或更新的值,200 OK 将被返回。 请求的示例如下所示:
-
```bash curl "https://play.dhis2.org/demo/api/dataValues?de=s46m5MS0hxu &pe=201301&ou=DiszpKrYNg8&co=Prlt0C1RF0s&value=12" -X POST -u admin:district
您可以使用 GET 方法通过请求检索数据值。这 value、comment 和 followUp 参数在这方面不适用:此资源还允许使用特殊语法将值关联到 一个属性选项组合。这可以通过发送 属性类别组合的标识符,连同标识符 值代表的属性类别选项 组合。类别组合由 `cc` 参数指定,而 类别选项被指定为分号分隔的字符串,带有`cp` 范围。有必要确保类别选项都是部分 的类别组合。一个示例如下所示: 1. ```bash curl "https://play.dhis2.org/demo/api/dataValues?de=s46m5MS0hxu&ou=DiszpKrYNg8 &pe=201308&cc=dzjKKQq0cSO&cp=wbrDrL2aYEc;btOyqprQ9e8&value=26" -X POST -u admin:district -
```bash curl "https://play.dhis2.org/demo/api/dataValues?de=s46m5MS0hxu &pe=201301&ou=DiszpKrYNg8&co=Prlt0C1RF0s" -u admin:district
POST /api/dataValues3. 您可以使用 *DELETE* 方法通过请求删除数据值。 Sending individual data values as payload { #webapi_sending_individual_data_values_as_payload } You can send individual data values as a JSON payload using the following resource using `Content-Type: application/json`.The resource will create a new data value or update a data value if it already exists. The JSON payload format is defined below. ## ```json { "dataElement": "fbfJHSPpUQD", "categoryOptionCombo": "PT59n8BQbqM", "period": "202201", "orgUnit": "DiszpKrYNg8", "value": "10", "comment": "OK" }
The endpoint supports specifying attribute option combos in a nested structure.
{
"dataElement": "BOSZApCrBni",
"categoryOptionCombo": "TkDhg29x18A",
"attribute": {
"combo": "O4VaNks6tta",
"options": [
"C6nZpLKjEJr", "i4Nbp8S2G6A"
]
},
"dataSet": "lyLU2wR22tC",
"period": "202201",
"orgUnit": "DiszpKrYNg8",
"value": "15",
"comment": "Good"
}
如果数据值已成功保存或更新,则状态代码将为201 Created,如果存在验证错误,则状态代码将为409 Conflict。
处理文件数据值¶
处理具有 file 类型数据元素的数据值时 与上述方法存在一些偏差。这些数据 值的特殊之处在于值的内容是一个 UID 引用 到 FileResource 对象而不是自包含常量。这些 数据值的行为就像其他存储文本的数据值一样 内容,但应以不同方式处理以产生 有意义的输入和输出。
There are two methods of storing file resource data values.¶
Upload the file to the /api/dataValues/file endpoint as
described in the file resource section. This works on versions 2.36 and later.
If you are writing code that needs to be compatible
with versions of DHIS2 before 2.36, then the process is:¶
如所述将文件上传到 /api/fileResources 端点
在文件资源部分。
| Retrieve the id property of the returned file resource. | Store the retrieved identifier using the value property of the data value using any | 上面描述的方法。 | 数据值和文件资源之间只有一对一的关系 允许。这是在内部强制执行的,以便保存文件资源 ID 在多个数据值中是不允许的,并且会返回错误。删除 数据值将删除引用的文件资源。直接删除 的文件资源是不可能的。 | |---|---|---|---| | 数据值现在可以作为除返回数据以外的任何其他值进行检索 将是文件资源的 UID。为了检索实际 内容(意味着存储在映射的文件资源中的文件 到数据值)必须向 /api/dataValues/files 发出 GET 请求 镜像查询参数,因为它们将用于数据值 本身。 /api/dataValues/files 端点仅支持 GET 请求。 | 值得注意的是,由于底层存储机制工作 异步文件内容可能不会立即准备好 从/api/dataValues/files 端点下载。这是特别真实的 对于可能需要耗时上传的大文件 外部文件存储的背景(取决于系统 配置)。从文件资源元数据中检索 /api/fileResources/ <id> 端点允许检查 storageStatus 在尝试下载内容之前。 | Oct 04 2017-Oct 10-2017 | From version 2.20 we have included support for an international standard for aggregate data exchange called ADX. ADX is developed and maintained by the Quality Research and Public Health committee of the IHE (Integrating the HealthCare Enterprise). The wiki page detailing QRPH activity can be found at wiki.ihe.net. ADX is still under active development and has now been published for trial implementation. Note that what is implemented currently in DHIS2 is the functionality to read and write ADX formatted data, i.e. what is described as Content Consumer and Content Producer actors in the ADX profile. | | ADX 数据消息的结构与您可能的结构非常相似 从前面描述的 DXF 2 数据中已经熟悉了。有一个 几个重要的区别。我们将描述这些差异 参考一个小例子: | Unlike dxf2, ADX requires that the datavalues are grouped according to orgUnit, period and dataSet. The example above shows a data report for the "(TB/HIV) VCCT" dataset from the online demo database. This example is using codes as identifiers instead of dhis2 uids. Codes are the preferred form of identifier when using ADX. | The ADX root element { #the-adx-root-element } | The ADX root element has only one mandatory attribute, which is the exported timestamp. In common with other ADX elements, the schema is extensible in that it does not restrict additional application specific attributes. | | The ADX group element { #the-adx-group-element } | Unlike dxf2, ADX requires that the datavalues are grouped according to orgUnit, period and dataSet. The example above shows a data report for the "(TB/HIV) VCCT" dataset from the online demo database. This example is using codes as identifiers instead of dhis2 uids. Codes are the preferred form of identifier when using ADX. | The orgUnit, period and dataSet attributes are mandatory in ADX. The group element may contain additional attributes. In our DHIS2 implementation any additional attributes are simply passed through to the underlying importer. This means that all attributes which currently have meaning in dxf2 (such as completeDate in the example above) can continue to be used in ADX and they will be processed in the same way. | A significant difference between ADX and dxf2 is in the way that periods are encoded. ADX makes strict use of ISO8601 and encodes the reporting period as (date|datetime)/(duration). So the period in the example above is a period of 1 month (P1M) starting on 2015-06-01. So it is the data for June 2015. The notation is a bit more verbose, but it is very flexible and allows us to support all existing period types in DHIS2 | | ADX期间定义 { #adx-period-definitions } | Unlike dxf2, ADX requires that the datavalues are grouped according to orgUnit, period and dataSet. The example above shows a data report for the "(TB/HIV) VCCT" dataset from the online demo database. This example is using codes as identifiers instead of dhis2 uids. Codes are the preferred form of identifier when using ADX. | Table: ADX Periods | 期间类型 | | Duration notation | Unlike dxf2, ADX requires that the datavalues are grouped according to orgUnit, period and dataSet. The example above shows a data report for the "(TB/HIV) VCCT" dataset from the online demo database. This example is using codes as identifiers instead of dhis2 uids. Codes are the preferred form of identifier when using ADX. | Duration(s) | 日常 | | P1D | Unlike dxf2, ADX requires that the datavalues are grouped according to orgUnit, period and dataSet. The example above shows a data report for the "(TB/HIV) VCCT" dataset from the online demo database. This example is using codes as identifiers instead of dhis2 uids. Codes are the preferred form of identifier when using ADX. | Oct 01 2017 | Weekly | | P7D | 2017-10-02/P7D | Oct 02 2017-Oct 08-2017 | Weekly Wednesday | | P7D | 2017-10-04/P7D | Oct 04 2017-Oct 10-2017 | Weekly Thursday | | P7D | 2017-10-05/P7D | Oct 05 2017-Oct 011-2017 | Weekly Saturday | | P7D | 2017-10-07/P7D | Oct 07 2017-Oct 13-2017 | Weekly Sunday | | P7D | 2017-10-01/P1M | Oct 01 2017-Oct 07-2017 | Bi-weekly | | P14D | 2017-10-01/P1M | Oct 02 2017-Oct 15 2017 | Monthly | | P1M | 2017-10-01/P1M | Oct 01 2017-Oct 31 2017 | 双月刊 | | P2M | 2017-01-01/P6M
2017-07-01/P6M | Nov 01 2017-Dec 31 2017 | Quarterly | | P3M | 2017-01-01/P6M
2017-07-01/P6M | Sep 01 2017-Dec 31 2017 | Six-monthly | | P6M | 2017-01-01/P6M
2017-07-01/P6M | Jan 01 2017-Jun 30 2017
Jul 01 2017-Dec 31 2017 | Six-monthly April | | P6M | 2017-01-01/P6M
2017-07-01/P6M | Apr 01 2017-Sep 30 2017
Oct 01 2017-Mar 31 2018 | Six-monthly November | | P6M | 2017-01-01/P6M
2017-07-01/P6M | Nov 01 2017-Apr 30 2018
May 01 2018-Oct 31 2018 | Yearly |
P1Y¶
2017-01-01/P1Y
Jan 01 2017-Dec 31 2017
Financial April
P1Y
-
2017-04-01/P1Y April 1 2017-Mar 31 2018
-
Financial July P1Y 2017-07-01/P1Y July 1 2017-June 30 2018
Financial October
P1Y
2017-10-01/P1Y¶
Oct 01 2017-Sep 30 2018
Financial November
P1Y
2017-11-01/P1Y¶
Nov 01 2017-Oct 31 2018
ADX Data values { #adx-data-values }
The dataValue element in ADX is very similar to its equivalent in DXF. The mandatory attributes are dataElement and value. The orgUnit and period attributes don't appear in the dataValue as they are required at the group level.
The most significant difference is the way that disaggregation is¶
represented. DXF uses the categoryOptionCombo to indicate the disaggregation of data. In ADX the disaggregations (e.g. AGE_GROUP and SEX) are expressed explicitly as attributes. If you use code as the id scheme for category, not that you must assign a code to all the categories used for dataElements in the dataSet, and further, that code must be of a form which is suitable for use as an XML attribute. The exact constraint on an XML attribute name is described in the W3C XML standard - in practice, this means no spaces, no non-alphanumeric characters other than '_' and it may not start with a letter. The example above shows examples of 'good' category codes ('GENDER' and 'HIV_AGE'). The same restrictions apply if you use name or attribute as id schemes.
In ADX, only category identifiers are used as XML attributes; identifiers for other metadata types do not have to be usalbe as XML attributes. Note that this syntax is not enforced by DHIS2 when you are assigning names, codes, or DHIS2 attributes, but you will get an informative error message if you try to import ADX data and the category identifiers are either not assigned or not suitable.
使用分解数据的显式维度的主要好处是¶
那
生成数据的系统不必与
DHIS2 中的 categoryOptionCombo。
生产者和消费者可以将他们的代码与第三方进行匹配
权威来源,例如 vterminology 服务。请注意,在
上面的性别和年龄组代码示例使用的是代码列表
来自世卫组织全球卫生观察站。
Note that this feature may be extremely useful, for example when producing disaggregated data from an EMR system, but there may be cases where a categoryOptionCombo mapping is easier or more desirable. The DHIS2 implementation of ADX will check for the existence of a categoryOptionCombo attribute and, if it exists, it will use that in preference to exploded dimension attributes. Similarly, an attributeOptionCombo attribute on the group element will be processed in the legacy way. Otherwise, the attributeOptionCombo can be treated as exploded categories just as on the dataValue.
In the simple example above, each of the dataElements in the dataSet have the same dimensionality (categorycombo) so the data is neatly rectangular. This need not be the case. dataSets may contain dataElements with different categoryCombos, resulting in a ragged-right ADX data message (i.e. values for different dataElements may have different numbers of categories.)
Importing ADX data { #importing-adx-data }
DHIS2 exposes an endpoint for POST ADX data at /api/dataValueSets using application/xml+adx as content type. So, for example, the following curl command can be used to POST the example data above to the DHIS2 demo server:
curl -u admin:district -X POST -H "Content-Type: application/adx+xml"
-d @data.xml "https://play.dhis2.org/demo/api/dataValueSets?dataElementIdScheme=code&orgUnitIdScheme=code"
Note the query parameters are the same as are used with DXF data. The ADX endpoint should interpret all the existing DXF parameters with the same semantics as DXF.
Exporting ADX data { #exporting-adx-data }
DHIS2 exposes an endpoint to GET ADX data sets at /api/dataValueSets using application/xml+adx as the accepted content type. So, for example, the following curl command can be used to retrieve the ADX data: