Skip to content

Commit 5e20751

Browse files
committed
Fixing invite filtering
1 parent 4e45c00 commit 5e20751

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

dr-controler.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,11 @@ async function refreshInviteList(collector) {
124124

125125
// get all invites
126126
const invites = await collector.getInvites(); // Todo add a "filter by" maybe only list "Pending" invites
127-
const pendingInvites = invites.filter(i => i.status === 'Pending');
127+
console.log('## refreshInviteList invites ', invites);
128+
const pendingInvites = invites.filter(i => i.status === 'pending');
128129
pendingInvites.sort((a, b) => b.dateCreation - a.dateCreation); // sort by creation date reverse
129130

130-
console.log('## refreshInviteList current ', pendingInvites);
131+
console.log('## refreshInviteList pending ', pendingInvites);
131132

132133
for (const invite of pendingInvites) {
133134
const row = table.insertRow(-1);
@@ -179,11 +180,11 @@ async function setPatientList(collector) {
179180

180181
// get all invites
181182
const invites = await collector.getInvites();
182-
const pendingInvites = invites.filter(i => i.status !== 'Pending');
183-
pendingInvites.sort((a, b) => b.dateCreation - a.dateCreation); // sort by creation date reverse
183+
const activeInvites = invites.filter(i => i.status === 'active');
184+
activeInvites.sort((a, b) => b.dateCreation - a.dateCreation); // sort by creation date reverse
184185

185186
// fetch patient data
186-
const patientPromises = invites.map((invite) =>
187+
const patientPromises = activeInvites.map((invite) =>
187188
drLib.getPatientDetails(invite, itemDefs)
188189
);
189190
const patientsResults = await Promise.all(patientPromises);

dr-lib.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ async function getPatientDetails(invite, itemDefs) {
217217
const patientInfo = await invite.connection.accessInfo();
218218
patient.username = patientInfo.user.username;
219219
} catch (e) {
220-
console.error("## Error getting patient info: " + patient.apiEndpoint, e);
220+
console.error("## Error getting patient info from invite ", patient, invite, e);
221221
// -- mark as revoked
222222
// TODO call invite.markRevoked();
223223
}

0 commit comments

Comments
 (0)