new update(resourceType, path, data, optionsopt, callbackopt) → {Operation}
Update data. A generic helper function to update a resource object of any type.
Updating an object requires to send `all required fields` or the `full body`
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
resourceType |
string | The type of resource to be updated. E.g. `dataElements`, `organisationUnits`, etc. | |
path |
string | The `id` or `path` to the `object` to be updated. E.g. `FTRrcoaog83` or `FTRrcoaog83/{collection-name}/{object-id}` | |
data |
Object | Data to update. It requires to send `all required fields` or the `full body`. If you want `partial updates`, use `patch` operation. | |
options |
Object |
<optional> |
Optional `options` to define URL parameters via params (E.g. `filter`, `dimension` and other import parameters), request config (E.g. `auth`) and the DHIS2 apiVersion. |
callback |
function |
<optional> |
Optional callback to handle the response |
- Source:
Returns:
- Type
- Operation
Examples
update('programs', 'qAZJCrNJK8H', {
name: '14e1aa02c3f0a31618e096f2c6d03bed',
shortName: '14e1aa02',
programType: 'WITHOUT_REGISTRATION',
});
update('events', 'PVqUD2hvU4E', {
program: 'eBAyeGv0exc',
orgUnit: 'Ngelehun CHC',
status: 'COMPLETED',
storedBy: 'admin',
dataValues: [],
});
update('trackedEntityInstances', 'IeQfgUtGPq2', {
created: '2015-08-06T21:12:37.256',
orgUnit: 'TSyzvBiovKh',
createdAtClient: '2015-08-06T21:12:37.256',
trackedEntityInstance: 'IeQfgUtGPq2',
lastUpdated: '2015-08-06T21:12:37.257',
trackedEntityType: 'nEenWmSyUEp',
inactive: false,
deleted: false,
featureType: 'NONE',
programOwners: [
{
ownerOrgUnit: 'TSyzvBiovKh',
program: 'IpHINAT79UW',
trackedEntityInstance: 'IeQfgUtGPq2',
},
],
enrollments: [],
relationships: [],
attributes: [
{
lastUpdated: '2016-01-12T00:00:00.000',
displayName: 'Last name',
created: '2016-01-12T00:00:00.000',
valueType: 'TEXT',
attribute: 'zDhUuAYrxNC',
value: 'Russell',
},
{
lastUpdated: '2016-01-12T00:00:00.000',
code: 'MMD_PER_NAM',
displayName: 'First name',
created: '2016-01-12T00:00:00.000',
valueType: 'TEXT',
attribute: 'w75KJ2mc4zz',
value: 'Catherine',
},
],
});
update('dataSets', 'lyLU2wR22tC', { name: 'OpenFN Data Set', periodType: 'Weekly' });
update('dataSetNotificationTemplates', 'VbQBwdm1wVP', {
dataSetNotificationTrigger: 'DATA_SET_COMPLETION',
notificationRecipient: 'ORGANISATION_UNIT_CONTACT',
name: 'Notification',
messageTemplate: 'Hello Updated,
deliveryChannels: ['SMS'],
dataSets: [],
});
update('dataElements', 'FTRrcoaog83', {
aggregationType: 'SUM',
domainType: 'AGGREGATE',
valueType: 'NUMBER',
name: 'Paracetamol',
shortName: 'Para',
});
update('dataElementGroups', 'QrprHT61XFk', {
name: 'Data Element Group 1',
dataElements: [],
});
update('dataElementGroupSets', 'VxWloRvAze8', {
name: 'Data Element Group Set 4',
dataDimension: true,
shortName: 'DEGS4',
dataElementGroups: [],
});
update('dataValueSets', 'AsQj6cDsUq4', {
dataElement: 'f7n9E0hX8qk',
period: '201401',
orgUnit: 'DiszpKrYNg8',
value: '12',
});
update('dataValueSets', 'Ix2HsbDMLea', {
dataSet: 'pBOMPrpg1QX',
completeDate: '2014-02-03',
period: '201401',
orgUnit: 'DiszpKrYNg8',
dataValues: [
{
dataElement: 'f7n9E0hX8qk',
value: '1',
},
{
dataElement: 'Ix2HsbDMLea',
value: '2',
},
{
dataElement: 'eY5ehpbEsB7',
value: '3',
},
],
});
update('enrollments', 'CmsHzercTBa' {
trackedEntityInstance: 'bmshzEacgxa',
orgUnit: 'TSyzvBiovKh',
program: 'gZBxv9Ujxg0',
enrollmentDate: '2013-10-17',
incidentDate: '2013-10-17',
});