@iapps/ng-dhis2-ui 1.1.46 → 1.1.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3141,7 +3141,7 @@ class LineListService {
|
|
|
3141
3141
|
const filterParams = buildFilters(filters);
|
|
3142
3142
|
const dateFilter = startDate && endDate ? `&programStartDate=${startDate}&programEndDate=${endDate}` : '';
|
|
3143
3143
|
const ouModeIdentifier = ouMode ? `&ouMode=${ouMode}` : ``;
|
|
3144
|
-
return this.httpClient.get(`trackedEntityInstances.json?program=${programId}&ou=${orgUnit}${ouModeIdentifier}&page=${page}&pageSize=${pageSize}&fields=trackedEntityInstance,attributes[*,displayInList],enrollments[*]&totalPages=true&${filterParams}${dateFilter}&order=created:desc`).pipe(map$1((response) => {
|
|
3144
|
+
return this.httpClient.get(`trackedEntityInstances.json?program=${programId}&ou=${orgUnit}${ouModeIdentifier}&page=${page}&pageSize=${pageSize}&fields=trackedEntityInstance,orgUnit,attributes[*,displayInList],enrollments[*]&totalPages=true&${filterParams}${dateFilter}&order=created:desc`).pipe(map$1((response) => {
|
|
3145
3145
|
//TODO: use the api to to order by desc
|
|
3146
3146
|
// response.trackedEntityInstances.reverse();
|
|
3147
3147
|
return response;
|
|
@@ -3217,20 +3217,21 @@ const getTrackedEntityData = (response, programId, pager, filters) => {
|
|
|
3217
3217
|
let teis = response.data
|
|
3218
3218
|
.trackedEntityInstances;
|
|
3219
3219
|
let programMetaData = response.metadata.programTrackedEntityAttributes;
|
|
3220
|
-
//
|
|
3220
|
+
//organisation units from metadata
|
|
3221
|
+
let orgUnitsFromMetaData = response.metadata.organisationUnits;
|
|
3222
|
+
//a Map to efficiently look up orgUnit names by ID
|
|
3223
|
+
const orgUnitMap = new Map(orgUnitsFromMetaData.map((ou) => [ou.id, ou.name]));
|
|
3221
3224
|
const mappedProgramMetadataAttributes = programMetaData.map((attr) => ({
|
|
3222
3225
|
displayInList: attr.displayInList,
|
|
3223
3226
|
searchable: attr.searchable,
|
|
3224
3227
|
id: attr.trackedEntityAttribute.id,
|
|
3225
3228
|
}));
|
|
3226
|
-
console.log('the mapped attributes', mappedProgramMetadataAttributes);
|
|
3227
3229
|
const programAttributesMap = programMetaData.reduce((acc, attribute) => {
|
|
3228
3230
|
if (attribute.displayInList) {
|
|
3229
3231
|
acc[attribute.id] = attribute.displayName;
|
|
3230
3232
|
}
|
|
3231
3233
|
return acc;
|
|
3232
3234
|
}, {});
|
|
3233
|
-
console.log('metadat attributes', programMetaData);
|
|
3234
3235
|
if (filters) {
|
|
3235
3236
|
teis = getFilteredTrackedEntityInstances(teis, filters);
|
|
3236
3237
|
}
|
|
@@ -3242,11 +3243,6 @@ const getTrackedEntityData = (response, programId, pager, filters) => {
|
|
|
3242
3243
|
: tei.attributes;
|
|
3243
3244
|
attributes.forEach((attr) => allAttributes.add(attr.attribute));
|
|
3244
3245
|
});
|
|
3245
|
-
console.log('all of the attributes', allAttributes);
|
|
3246
|
-
// const filteredAttributes = new Set(
|
|
3247
|
-
// [...allAttributes].filter((attributeId) => programAttributesMap[attributeId])
|
|
3248
|
-
// );
|
|
3249
|
-
// console.log('Filtered All Attributes:', filteredAttributes);
|
|
3250
3246
|
let entityColumns = Array.from(allAttributes).map((attrId) => {
|
|
3251
3247
|
const foundAttribute = teis
|
|
3252
3248
|
.flatMap((tei) => {
|
|
@@ -3265,6 +3261,15 @@ const getTrackedEntityData = (response, programId, pager, filters) => {
|
|
|
3265
3261
|
// Check if the column label is part of any value in programAttributesMap
|
|
3266
3262
|
return Object.values(programAttributesMap).some((value) => value.includes(column.label));
|
|
3267
3263
|
});
|
|
3264
|
+
// entityColumns.push({
|
|
3265
|
+
// label: 'Location',
|
|
3266
|
+
// key: 'orgUnit',
|
|
3267
|
+
// });
|
|
3268
|
+
// Add orgUnit as the first column
|
|
3269
|
+
entityColumns.unshift({
|
|
3270
|
+
label: 'Location',
|
|
3271
|
+
key: 'orgUnit',
|
|
3272
|
+
});
|
|
3268
3273
|
const searchableAttributes = mappedProgramMetadataAttributes
|
|
3269
3274
|
.filter((attr) => attr.searchable && attr.displayInList)
|
|
3270
3275
|
.map((attr) => ({
|
|
@@ -3275,8 +3280,6 @@ const getTrackedEntityData = (response, programId, pager, filters) => {
|
|
|
3275
3280
|
const searchableKeys = new Set(searchableAttributes.map((attr) => attr.key));
|
|
3276
3281
|
// Filter entityColumns to keep only those whose key exists in searchableAttributes
|
|
3277
3282
|
const filteredEntityColumns = entityColumns.filter((column) => searchableKeys.has(column.key));
|
|
3278
|
-
console.log('show the filtered values', filteredEntityColumns);
|
|
3279
|
-
console.log('the answer is ', searchableAttributes);
|
|
3280
3283
|
const attributesData = teis.map((tei, idx) => {
|
|
3281
3284
|
let row = {
|
|
3282
3285
|
trackedEntityInstance: tei.trackedEntityInstance,
|
|
@@ -3288,9 +3291,10 @@ const getTrackedEntityData = (response, programId, pager, filters) => {
|
|
|
3288
3291
|
? matchingEnrollment.attributes
|
|
3289
3292
|
: tei.attributes;
|
|
3290
3293
|
attributesToUse.forEach((attr) => (row[attr.attribute] = attr.value));
|
|
3294
|
+
// Access the name of the orgUnit using the Map
|
|
3295
|
+
row['orgUnit'] = orgUnitMap.get(tei.orgUnit) || tei.orgUnit || 'N/A';
|
|
3291
3296
|
return row;
|
|
3292
3297
|
});
|
|
3293
|
-
console.log('attributes to use', entityColumns);
|
|
3294
3298
|
return { columns: entityColumns, data: attributesData, filteredEntityColumns: filteredEntityColumns };
|
|
3295
3299
|
};
|
|
3296
3300
|
const getEventData = (response, pager) => {
|