new create(resourceType, data, optionsopt, callbackopt) → {Operation}
Create a record
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
resourceType |
string | Type of resource to create. E.g. `trackedEntityInstances`, `programs`, `events`, ... | |
data |
Object | Data that will be used to create a given instance of resource. To create a single instance of a resource, `data` must be a javascript object, and to create multiple instances of a resources, `data` must be an array of javascript objects. | |
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
create('programs', {
name: 'name 20',
shortName: 'n20',
programType: 'WITHOUT_REGISTRATION',
});
create('events', {
program: 'eBAyeGv0exc',
orgUnit: 'DiszpKrYNg8',
status: 'COMPLETED',
});
create('trackedEntityInstances', {
orgUnit: 'TSyzvBiovKh',
trackedEntityType: 'nEenWmSyUEp',
attributes: [
{
attribute: 'w75KJ2mc4zz',
value: 'Gigiwe',
},
]
});
create('dataSets', { name: 'OpenFn Data Set', periodType: 'Monthly' });
create('dataSetNotificationTemplates', {
dataSetNotificationTrigger: 'DATA_SET_COMPLETION',
notificationRecipient: 'ORGANISATION_UNIT_CONTACT',
name: 'Notification',
messageTemplate: 'Hello',
deliveryChannels: ['SMS'],
dataSets: [],
});
create('dataElements', {
aggregationType: 'SUM',
domainType: 'AGGREGATE',
valueType: 'NUMBER',
name: 'Paracetamol',
shortName: 'Para',
});
create('dataElementGroups', {
name: 'Data Element Group 1',
dataElements: [],
});
create('dataElementGroupSets', {
name: 'Data Element Group Set 4',
dataDimension: true,
shortName: 'DEGS4',
dataElementGroups: [],
});
create('dataValueSets', {
dataElement: 'f7n9E0hX8qk',
period: '201401',
orgUnit: 'DiszpKrYNg8',
value: '12',
});
create('dataValueSets', {
dataSet: 'pBOMPrpg1QX',
completeDate: '2014-02-03',
period: '201401',
orgUnit: 'DiszpKrYNg8',
dataValues: [
{
dataElement: 'f7n9E0hX8qk',
value: '1',
},
{
dataElement: 'Ix2HsbDMLea',
value: '2',
},
{
dataElement: 'eY5ehpbEsB7',
value: '3',
},
],
});
create('enrollments', {
trackedEntityInstance: 'bmshzEacgxa',
orgUnit: 'TSyzvBiovKh',
program: 'gZBxv9Ujxg0',
enrollmentDate: '2013-09-17',
incidentDate: '2013-09-17',
});