Hi all,
Is it possible to post a full document via outbound push without mapping?
Hi all,
Is it possible to post a full document via outbound push without mapping?
Hi @irene
From what I can tell, this is not possible. I would not think it’s advisable either, since a lot of documents will contain CouchDb metadata (like _attachments for example) or CHT-Core metadata which would not be relevant outside of the CHT scope.
Can you please share a few more details about your use-case and the need to push a whole document?
Thanks!
Source code: cht-core/shared-libs/outbound/src/outbound.js at master · medic/cht-core · GitHub
Thank you @diana.
The need to push a whole doc was informed by having most of the fields from person registration being sent to another service, and also visibility of the payload in the service.
There’s probably some other use-cases perhaps @kitsao can add on to this.
Hey @diana,
One of the echis integration points is community referrals by CHVs to be added to a shared health record (FHIR) to be consumed at health facility via an EHR system.
We wish to configure a generic outbound push module (rather than a module for each of the forms) to serve all 10 sources then handle the formatting logic in the OpenHIM mediator.
cc @irene
I will try but it might be possible because it seems that obectpath.get can retrieve complex object
"mapping":{
"orgUnit": "doc.fields.inputs.contact.external_id",
"reported_date": "doc.reported_date",
"case_id":"doc._id",
"properties: "doc.fields"
}
I will keep you posted
doc.fields seems to work fine
little follow up because doc.fields have the full structure which can be annoying to process (in my case the structure does not matter because I don’t use repeats)
this is a openFN lightining job that flatten the payload
alterState((state) => {
// Function to process object entries and flatten the structure
const processObjectEntries = (result, entries, prefix = '') => {
for (let [key, value] of entries) {
const newKey = key; // Create a flat key with dot notation
if (value === null || typeof value !== 'object') {
result[newKey] = value; // Store leaf value in result
} else {
// Recursively process nested objects or arrays
if (Array.isArray(value)) {
value.forEach((item, index) => {
processObjectEntries(result, Object.entries(item), `${newKey}[${index}]`);
});
} else {
processObjectEntries(result, Object.entries(value), newKey);
}
}
}
return result;
};
// Initialize result as an object, not an array
let result = {};
// Start processing with the state.data
result = processObjectEntries(result, Object.entries(state.data.properties));
// Update state.data with the flattened result
state.data.properties= result;
return state;
});