diff --git a/src/ui-client/src/containers/Root.tsx b/src/ui-client/src/containers/Root.tsx
index a0241f404..179170814 100644
--- a/src/ui-client/src/containers/Root.tsx
+++ b/src/ui-client/src/containers/Root.tsx
@@ -6,8 +6,8 @@
*/
import React from 'react';
-import { DndProvider } from 'react-dnd';
-import HTML5Backend from 'react-dnd-html5-backend';
+import { DndProvider } from 'react-dnd-cjs';
+import HTML5Backend from 'react-dnd-html5-backend-cjs';
import { Provider } from 'react-redux';
import { AppState } from '../models/state/AppState';
import { defaultAuthorizationState } from '../reducers/auth';
diff --git a/src/ui-client/src/models/admin/Dataset.ts b/src/ui-client/src/models/admin/Dataset.ts
index 89f7b914b..98d94e72c 100644
--- a/src/ui-client/src/models/admin/Dataset.ts
+++ b/src/ui-client/src/models/admin/Dataset.ts
@@ -8,9 +8,11 @@
import { PatientListDatasetShape } from "../patientList/Dataset";
import { Constraint } from "./Concept";
import { PatientListColumnType } from "../patientList/Column";
+import { CustomColumnNames } from "../cohort/DemographicDTO";
-export interface AdminDemographicQuery {
+export interface AdminDemographicQueryDTO {
sqlStatement: string;
+ columnNames: CustomColumnNames;
lastChanged: string;
changedBy: string;
}
@@ -26,6 +28,7 @@ interface BaseAdminDatasetQuery {
sqlStatement: string;
tags: string[];
isEncounterBased: boolean;
+ isDefault?: boolean;
sqlFieldDate?: string;
sqlFieldValueString?: string;
sqlFieldValueNumeric?: string;
@@ -41,6 +44,10 @@ export interface AdminDatasetQuery extends BaseAdminDatasetQuery {
schema?: DynamicDatasetQuerySchema;
}
+export interface AdminDemographicQuery extends AdminDatasetQuery {
+ columnNames: Map
;
+}
+
export interface DatasetQueryCategory {
id: number;
category: string;
diff --git a/src/ui-client/src/models/cohort/DemographicDTO.ts b/src/ui-client/src/models/cohort/DemographicDTO.ts
index a1498dc51..5bdc7dc66 100644
--- a/src/ui-client/src/models/cohort/DemographicDTO.ts
+++ b/src/ui-client/src/models/cohort/DemographicDTO.ts
@@ -10,6 +10,11 @@ import { PatientListRowDTO } from '../patientList/Patient';
export interface DemographicDTO {
patients: PatientListRowDTO[];
statistics: DemographicStatistics;
+ columnNames: CustomColumnNames;
+}
+
+export interface CustomColumnNames {
+ [key: string]: string;
}
export interface BinarySplitPair {
diff --git a/src/ui-client/src/models/patientList/Configuration.ts b/src/ui-client/src/models/patientList/Configuration.ts
index df9e3bf91..634592321 100644
--- a/src/ui-client/src/models/patientList/Configuration.ts
+++ b/src/ui-client/src/models/patientList/Configuration.ts
@@ -20,6 +20,7 @@ export interface PatientListSort {
export interface PatientListConfiguration {
multirowDatasets: Map;
singletonDatasets: Map;
+ customColumnNames: Map;
displayColumns: PatientListColumn[];
isFetching: boolean;
fetchingDataset?: string;
diff --git a/src/ui-client/src/models/patientList/Dataset.ts b/src/ui-client/src/models/patientList/Dataset.ts
index 3eae80407..a322a25f8 100644
--- a/src/ui-client/src/models/patientList/Dataset.ts
+++ b/src/ui-client/src/models/patientList/Dataset.ts
@@ -99,6 +99,7 @@ export interface PatientListDatasetQueryDTO {
shape: PatientListDatasetShape;
tags: string[];
universalId?: string;
+ isDefault?: boolean;
}
export interface PatientListDatasetQuery extends PatientListDatasetQueryDTO {
diff --git a/src/ui-client/src/models/state/AdminState.ts b/src/ui-client/src/models/state/AdminState.ts
index 0c58e5bc3..ba93c1eb0 100644
--- a/src/ui-client/src/models/state/AdminState.ts
+++ b/src/ui-client/src/models/state/AdminState.ts
@@ -10,7 +10,7 @@ import { Concept as UserConcept } from '../concept/Concept';
import { PanelFilter } from '../admin/PanelFilter';
import { AdminConfiguration } from '../admin/Configuration';
import { Panel } from '../panel/Panel';
-import { AdminDatasetQuery, DatasetQueryCategory } from '../admin/Dataset';
+import { AdminDatasetQuery, DatasetQueryCategory, AdminDemographicQuery } from '../admin/Dataset';
import { AdminPanelPatientListColumnTemplate } from '../patientList/Column';
import { NetworkIdentity } from '../NetworkResponder';
import { NetworkEndpoint, Certificate } from '../admin/Network';
@@ -75,7 +75,7 @@ export interface AdminDatasetState {
expectedColumns: AdminPanelPatientListColumnTemplate[];
currentDataset?: AdminDatasetQuery;
datasets: Map;
- demographicsDataset: AdminDatasetQuery;
+ demographicsDataset: AdminDemographicQuery;
sqlColumns: Set;
state: AdminPanelLoadState;
}
diff --git a/src/ui-client/src/providers/datasetSearch/datasetSearchWebWorker.ts b/src/ui-client/src/providers/datasetSearch/datasetSearchWebWorker.ts
index 317ddc044..7c7f3a99a 100644
--- a/src/ui-client/src/providers/datasetSearch/datasetSearchWebWorker.ts
+++ b/src/ui-client/src/providers/datasetSearch/datasetSearchWebWorker.ts
@@ -414,6 +414,8 @@ export default class DatasetSearchEngineWebWorker {
*/
for (let i = 0; i < all.length; i++) {
const ds = all[i];
+ if (ds.isDefault) continue;
+
let tokens = ds.name.toLowerCase().split(' ').concat(ds.tags.map(t => t.toLowerCase()));
if (ds.category) { tokens = tokens.concat(ds.category.toLowerCase().split(' ')); }
if (ds.description) { tokens = tokens.concat(ds.description.toLowerCase().split(' ')); }
diff --git a/src/ui-client/src/providers/datasetSearch/datasetSearchWebWorkerContext.ts b/src/ui-client/src/providers/datasetSearch/datasetSearchWebWorkerContext.ts
index 21d3cb3e6..3f3d320ef 100644
--- a/src/ui-client/src/providers/datasetSearch/datasetSearchWebWorkerContext.ts
+++ b/src/ui-client/src/providers/datasetSearch/datasetSearchWebWorkerContext.ts
@@ -282,6 +282,7 @@ var reindexCacheCache = function (datasets) {
*/
for (var i = 0; i < all.length; i++) {
var ds = all[i];
+ if (ds.isDefault) continue;
var tokens = ds.name.toLowerCase().split(' ').concat(ds.tags.map(t => t.toLowerCase()));
if (ds.category) {
tokens = tokens.concat(ds.category.toLowerCase().split(' '));
diff --git a/src/ui-client/src/providers/patientList/patientListWebWorker.ts b/src/ui-client/src/providers/patientList/patientListWebWorker.ts
index 2bc68b173..3bf0636b8 100644
--- a/src/ui-client/src/providers/patientList/patientListWebWorker.ts
+++ b/src/ui-client/src/providers/patientList/patientListWebWorker.ts
@@ -953,7 +953,11 @@ export default class PatientListWebWorker {
}
// Add column headers
- rows.push(cols.map((col: PatientListColumn) => col.id).join(','));
+ rows.push(cols.map((col: PatientListColumn) => {
+ const renamed = config!.customColumnNames.get(col.id);
+ if (renamed) return renamed;
+ return col.id;
+ }).join(','));
// Add rows
patientMap.forEach((p: Patient) => {
diff --git a/src/ui-client/src/providers/patientList/patientListWebWorkerContext.ts b/src/ui-client/src/providers/patientList/patientListWebWorkerContext.ts
index df63a9990..e5015a068 100644
--- a/src/ui-client/src/providers/patientList/patientListWebWorkerContext.ts
+++ b/src/ui-client/src/providers/patientList/patientListWebWorkerContext.ts
@@ -710,10 +710,6 @@ var getMultirowDataCsv = function (payload) {
row.push(q+valueToCsvString(d)+q);
}
}
- for (var j = 0; j < cols.length; j++) {
- var d = vals[cols[j].id];
- row.push(q+valueToCsvString(d)+q);
- }
rows.push(row.join(','));
}
}
@@ -745,7 +741,11 @@ var getSingletonDataCsv = function (payload) {
});
}
// Add column headers
- rows.push(cols.map(function (col) { return col.id; }).join(','));
+ rows.push(cols.map((col) => {
+ var renamed = config.customColumnNames.get(col.id);
+ if (renamed) return renamed;
+ return col.id;
+ }).join(','));
// Add rows
patientMap.forEach(function (p) {
var row = [];
diff --git a/src/ui-client/src/providers/redcapExport/redcapExportWebWorker.ts b/src/ui-client/src/providers/redcapExport/redcapExportWebWorker.ts
index bb2192229..b4746f22b 100644
--- a/src/ui-client/src/providers/redcapExport/redcapExportWebWorker.ts
+++ b/src/ui-client/src/providers/redcapExport/redcapExportWebWorker.ts
@@ -168,7 +168,7 @@ export default class REDCapExportWebWorker {
/*
* Ensure the id generate for each dataset in REDCap has
- * only valid characters and is wiithin the length limit.
+ * only valid characters and is within the length limit.
*/
patientList!.forEach((d) => d.datasetId = cleanName(d.datasetId, dsNameLenLimit));
diff --git a/src/ui-client/src/reducers/admin/admin.ts b/src/ui-client/src/reducers/admin/admin.ts
index 2b6b03744..57756aee0 100644
--- a/src/ui-client/src/reducers/admin/admin.ts
+++ b/src/ui-client/src/reducers/admin/admin.ts
@@ -138,6 +138,7 @@ export const defaultAdminState = (): AdminState => {
datasets: new Map(),
demographicsDataset: {
id: '',
+ columnNames: new Map(),
constraints: [],
isEncounterBased: false,
name: 'Basic Demographics',
diff --git a/src/ui-client/src/reducers/cohort/cohort.ts b/src/ui-client/src/reducers/cohort/cohort.ts
index d1e314b51..1e646d63d 100644
--- a/src/ui-client/src/reducers/cohort/cohort.ts
+++ b/src/ui-client/src/reducers/cohort/cohort.ts
@@ -30,7 +30,8 @@ import {
PATIENT_LIST_DATASET_RECEIVED,
PATIENT_LIST_NETWORK_DATASET_RECEIVED,
PATIENT_LIST_DATASET_REQUESTED,
- PATIENT_LIST_DATASET_NOT_IMPLEMENTED
+ PATIENT_LIST_DATASET_NOT_IMPLEMENTED,
+ PATIENTLIST_SET_CUSTOM_COLUMN_NAMES
} from '../../actions/cohort/patientList';
import {
CohortVisualizationAction,
@@ -83,7 +84,8 @@ import {
setNetworkPatientListDatasetReceived,
setPatientListDatasetReceived,
setPatientListDatasetRequested,
- setNetworkPatientListDatasetNotImplemented
+ setNetworkPatientListDatasetNotImplemented,
+ setCustomColumnNames
} from './patientList';
import { defaultVisualizationState, setAggregateCohortVisualization, setNetworkCohortVisualization } from './visualize';
import {
@@ -361,6 +363,8 @@ export const cohort = (state: CohortState = defaultCohortState(), action: Cohort
return setNetworkPatientListDatasetFailure(state, action);
case PATIENT_LIST_DATASET_NOT_IMPLEMENTED:
return setNetworkPatientListDatasetNotImplemented(state, action);
+ case PATIENTLIST_SET_CUSTOM_COLUMN_NAMES:
+ return setCustomColumnNames(state, action);
// Enabled/disabling responders after data loaded
case ENABLE_RESPONDER:
diff --git a/src/ui-client/src/reducers/cohort/patientList.ts b/src/ui-client/src/reducers/cohort/patientList.ts
index 49000a5de..551798d4b 100644
--- a/src/ui-client/src/reducers/cohort/patientList.ts
+++ b/src/ui-client/src/reducers/cohort/patientList.ts
@@ -21,6 +21,7 @@ export function defaultNetworkPatientListState(): PatientListNetworkState {
export function defaultPatientListState(): PatientListState {
return {
configuration: {
+ customColumnNames: new Map(),
displayColumns: [],
isFetching: false,
multirowDatasets: new Map(),
@@ -80,6 +81,17 @@ export function setPagination(state: CohortState, action: CohortPatientListActio
})
};
+export function setCustomColumnNames(state: CohortState, action: CohortPatientListAction): CohortState {
+ return Object.assign({}, state, {
+ patientList: {
+ ...state.patientList,
+ configuration: Object.assign({}, state.patientList.configuration, {
+ customColumnNames: action.customColumnNames
+ })
+ }
+ })
+};
+
export function setPatientList(state: CohortState, action: CohortPatientListAction): CohortState {
return Object.assign({}, state, {
patientList: {
@@ -137,6 +149,7 @@ export function setPatientListDatasetReceived(state: CohortState, action: Cohort
const copy = Object.assign({}, state, {
patientList: {
...state.patientList,
+ state: CohortStateType.LOADED,
configuration: {
...state.patientList.configuration,
isFetching: false,
diff --git a/src/ui-client/src/services/admin/datasetApi.ts b/src/ui-client/src/services/admin/datasetApi.ts
index 2fa3a1b04..b4b83d257 100644
--- a/src/ui-client/src/services/admin/datasetApi.ts
+++ b/src/ui-client/src/services/admin/datasetApi.ts
@@ -7,8 +7,9 @@
import { AppState } from '../../models/state/AppState';
import { HttpFactory } from './../HttpFactory';
-import { AdminDatasetQuery, AdminDemographicQuery, toDTO, fromDTO, AdminDatasetQueryDTO } from '../../models/admin/Dataset';
+import { AdminDatasetQuery, AdminDemographicQuery, toDTO, fromDTO, AdminDatasetQueryDTO, AdminDemographicQueryDTO } from '../../models/admin/Dataset';
import { PatientListDatasetShape } from '../../models/patientList/Dataset';
+import { mapToObject } from '../../utils/mapToObject';
/*
* Gets a Dataset.
@@ -58,13 +59,14 @@ export const deleteDataset = async (state: AppState, dataset: AdminDatasetQuery)
/*
* Gets the Demographics Dataset.
*/
-export const getAdminDemographicsDataset = async (state: AppState): Promise => {
+export const getAdminDemographicsDataset = async (state: AppState): Promise => {
const { token } = state.session.context!;
const http = HttpFactory.authenticated(token);
const resp = await http.get(`api/admin/demographics`);
- const ds = resp.data as AdminDemographicQuery;
- const converted: AdminDatasetQuery = {
+ const ds = resp.data as AdminDemographicQueryDTO;
+ const converted: AdminDemographicQuery = {
id: 'demographics',
+ columnNames: new Map(Object.entries(ds.columnNames)),
constraints: [],
isEncounterBased: false,
name: 'Basic Demographics',
@@ -79,16 +81,22 @@ export const getAdminDemographicsDataset = async (state: AppState): Promise => {
+export const upsertDemographicsDataset = async (state: AppState, dataset: AdminDemographicQuery): Promise => {
const { token } = state.session.context!;
const http = HttpFactory.authenticated(token);
- const resp = await http.put(`api/admin/demographics`, {
- sqlStatement: dataset.sqlStatement
- });
+ const params: any = {
+ sqlStatement: dataset.sqlStatement,
+ columnNames: {}
+ };
+ for (const pair of dataset.columnNames.entries()) {
+ params.columnNames[pair[0]] = pair[1];
+ }
+ const resp = await http.put(`api/admin/demographics`, params);
const ds = resp.data as AdminDemographicQuery;
- const converted: AdminDatasetQuery = {
+ const converted: AdminDemographicQuery = {
...dataset,
...ds,
+ columnNames: new Map(Object.entries(ds.columnNames)),
unsaved: false
};
return converted;
diff --git a/src/ui-client/src/services/patientListApi.ts b/src/ui-client/src/services/patientListApi.ts
index 72a12f66a..378ef9242 100644
--- a/src/ui-client/src/services/patientListApi.ts
+++ b/src/ui-client/src/services/patientListApi.ts
@@ -268,6 +268,7 @@ export const addDemographicsDataset = async (
await patientListProvider.addDemographics(def, patients, responderId);
patientList.display = await patientListProvider.getPatients(patientList.configuration) as PatientListRow[];
patientList.totalPatients = getState().cohort.patientList.totalPatients + patients.length;
+ patientList.configuration.customColumnNames = getState().cohort.patientList.configuration.customColumnNames;
patientList.state = CohortStateType.LOADED;
return patientList;
};