Skip to content

Commit 138a435

Browse files
committed
Now Dr's app uses questionnairesV2
1 parent 85c3885 commit 138a435

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

dr-lib.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,19 +168,21 @@ async function getPatientDetails(questionaryId, patientEvent) {
168168

169169
// -- get data
170170
// get profile form data
171-
const formProfile = dataDefs.questionnaires[questionaryId].forms.profile;
171+
const formProfile = dataDefs.v2questionnaires[questionaryId].forms.profile;
172172

173-
// get eventTypes
174173

175-
// get the last value of each field
176-
const apiCalls = formProfile.content.map((field) => ({
177-
method: "events.get",
178-
params: {
179-
streams: [field.streamId],
180-
types: [field.eventType],
181-
limit: 1,
182-
},
183-
}));
174+
// get the last value of each itemKey
175+
const apiCalls = formProfile.itemKeys.map((itemKey) => {
176+
const itemDef = hdsModel().itemDefForKey(itemKey);
177+
return {
178+
method: "events.get",
179+
params: {
180+
streams: [itemDef.data.streamId],
181+
types: itemDef.types,
182+
limit: 1,
183+
}
184+
};
185+
});
184186

185187
const profileEventsResults = await patientConnection.api(apiCalls);
186188
for (const profileEventRes of profileEventsResults) {

0 commit comments

Comments
 (0)