diff --git a/adaptors/library/jobs/DHIS2-DataValues-API.js b/adaptors/library/jobs/DHIS2-DataValues-API.js index b305cd97743..ef582f0a7c0 100644 --- a/adaptors/library/jobs/DHIS2-DataValues-API.js +++ b/adaptors/library/jobs/DHIS2-DataValues-API.js @@ -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, + }, + ], +}); diff --git a/adaptors/library/jobs/DHIS2-Events-API.js b/adaptors/library/jobs/DHIS2-Events-API.js index e1b02e6b837..ff5175fdddc 100644 --- a/adaptors/library/jobs/DHIS2-Events-API.js +++ b/adaptors/library/jobs/DHIS2-Events-API.js @@ -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, + }, + ], +}); diff --git a/adaptors/library/staticExamples.json b/adaptors/library/staticExamples.json index 02cd577b75e..6b3c2f65f04 100644 --- a/adaptors/library/staticExamples.json +++ b/adaptors/library/staticExamples.json @@ -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", diff --git a/package.json b/package.json index 46fd827deaf..63d8248ff64 100644 --- a/package.json +++ b/package.json @@ -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", @@ -62,4 +62,4 @@ "cytoscape": "3.28.1" }, "packageManager": "yarn@3.2.3" -} +} \ No newline at end of file