Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions adaptors/library/jobs/DHIS2-DataValues-API.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
// ----
// Add data to data value sets in DHIS2 using a generic JSON message, submitted
// by Taylor Downs @ OpenFn.
// by Taylor Downs @ OpenFn. Co-authored by @mtuchi
// ---

dataValueSet(
fields(
field('dataSet', 'pBOMPrpg1QX'),
field('orgUnit', 'DiszpKrYNg8'),
field('period', '201401'),
field('completeData', dataValue('form.date')),
field('dataValues', function (state) {
return [
dataElement('qrur9Dvnyt5', dataValue('form.prop_a')(state)),
dataElement('oZg33kd9taw', dataValue('form.prop_b')(state)),
dataElement('msodh3rEMJa', dataValue('form.prop_c')(state)),
];
})
)
);
create('dataValueSets', {
dataSet: 'pBOMPrpg1QX',
completeDate: $.form.date,
period: '201401',
orgUnit: 'DiszpKrYNg8',
dataValues: [
{
dataElement: 'f7n9E0hX8qk',
value: $.form.prop_a,
},
{
dataElement: 'Ix2HsbDMLea',
value: $.form.prop_b,
},
{
dataElement: 'eY5ehpbEsB7',
value: $.form.prop_c,
},
],
});
47 changes: 26 additions & 21 deletions adaptors/library/jobs/DHIS2-Events-API.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
// ----
// Create new events in DHIS2 using a generic JSON message, submitted by
// Taylor Downs @ OpenFn for demonstration porpoises.
// Taylor Downs @ OpenFn, Co-authored by @mtuchi
// ---

event(
fields(
field('program', 'eBAyeGv0exc'),
field('orgUnit', 'DiszpKrYNg8'),
field('eventDate', dataValue('meta.date')),
field('status', 'COMPLETED'),
field('storedBy', 'admin'),
field('coordinate', {
latitude: '59.8',
longitude: '10.9',
}),
field('dataValues', function (state) {
return [
dataElement('qrur9Dvnyt5', dataValue('form.prop_a')(state)),
dataElement('oZg33kd9taw', dataValue('form.prop_b')(state)),
dataElement('msodh3rEMJa', dataValue('form.prop_c')(state)),
];
})
)
);
create('events', {
program: 'eBAyeGv0exc',
orgUnit: 'DiszpKrYNg8',
occurredAt: $.meta.date,
status: 'COMPLETED',
storedBy: 'admin',
geometry: {
type: 'POINT',
coordinates: [59.8, 10.9],
},
dataValues: [
{
dataElement: 'qrur9Dvnyt5',
value: $.form.prop_a,
},
{
dataElement: 'oZg33kd9taw',
value: $.form.prop_b,
},
{
dataElement: 'msodh3rEMJa',
value: $.form.prop_c,
},
],
});
4 changes: 2 additions & 2 deletions adaptors/library/staticExamples.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@
{
"expressionPath": "jobs/DHIS2-DataValues-API",
"adaptor": "dhis2",
"name": "Add data values"
"name": "Create data values"
},
{
"expressionPath": "jobs/DHIS2-Events-API",
"adaptor": "dhis2",
"name": "Add events"
"name": "Create new events"
},
{
"expressionPath": "jobs/ODK-Create-Many-Records-Moving-In-And-Out-Of-Repeat-Blocks",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"generate-library": "docusaurus generate-library",
"generate-adaptors": "docusaurus generate-adaptors",
"start": "docusaurus generate-adaptors & docusaurus start",
"start:dev": "docusaurus generate-adaptors -m && docusaurus start",
"start:dev": "docusaurus generate-adaptors -m && docusaurus generate-library && docusaurus start",
"start-offline": "docusaurus start",
"build": "docusaurus build",
"swizzle": "docusaurus swizzle",
Expand Down Expand Up @@ -62,4 +62,4 @@
"cytoscape": "3.28.1"
},
"packageManager": "yarn@3.2.3"
}
}
Loading