Skip to content

Commit

Permalink
Merge pull request #106 from CanDIG/fnguyen/uuid-fix
Browse files Browse the repository at this point in the history
Fix for the Katsu UUID change
  • Loading branch information
OrdiNeu authored Dec 19, 2023
2 parents 15f8114 + 78d0039 commit a723d4f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/layout/MainLayout/Sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const Sidebar = ({ drawerOpen, drawerToggle, window }) => {
</PerfectScrollbar>
</BrowserView>
<MobileView>
<Box sx={{ px: 2 }} />
<Box sx={{ px: 2 }}>{sidebarContext || <></>}</Box>
</MobileView>
</>
);
Expand Down
5 changes: 1 addition & 4 deletions src/views/clinicalGenomic/search/SearchHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ function SearchHandler() {
useEffect(() => {
// First, we abort any currently-running search promises
// controller.abort();
console.log('Query re-initiated');
console.log(reader.query);

const CollateSummary = (data, statName) => {
const summaryStat = {};
data.forEach((site) => {
Expand Down Expand Up @@ -146,7 +143,7 @@ function SearchHandler() {
const clinicalData = {};
data.forEach((site) => {
discoveryCounts.patients_per_cohort[site.location.name] = site.results?.summary?.patients_per_cohort;
clinicalData[site.location.name] = site?.results?.results;
clinicalData[site.location.name] = site?.results;
});

const genomicData = data
Expand Down
25 changes: 25 additions & 0 deletions src/views/clinicalGenomic/widgets/clinicalData.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import { useSearchQueryWriterContext, useSearchResultsReaderContext } from '../S

function ClinicalView() {
const theme = useTheme();
const [paginationModel, setPaginationModel] = React.useState({
pageSize: 25,
page: 0
});

// Mobile
const [desktopResolution, setdesktopResolution] = React.useState(window.innerWidth > 1200);
Expand All @@ -24,6 +28,7 @@ function ClinicalView() {
if (searchResults) {
rows =
Object.values(searchResults)
?.map((results) => results.results)
?.flat(1)
?.map((patient, index) => {
// Make sure each row has an ID and a deceased status
Expand Down Expand Up @@ -52,6 +57,22 @@ function ClinicalView() {
{ field: 'date_of_death', headerName: 'Date of Death', minWidth: 220, sortable: false }
];

const HandlePageChange = (newPage) => {
if (newPage !== paginationModel.page) {
writerContext((old) => ({ ...old, query: { ...old.query, page: newPage } }));
}
setPaginationModel({
pageSize: 10,
page: newPage
});
};

const totalRows = searchResults
? Object.values(searchResults)
?.map((site) => site.count)
.reduce((partial, a) => partial + a, 0)
: 0;

return (
<Box mr={2} ml={1} p={1} sx={{ border: 1, borderRadius: 2, boxShadow: 2, borderColor: theme.palette.primary[200] + 75 }}>
<Typography pb={1} variant="h4">
Expand All @@ -62,8 +83,12 @@ function ClinicalView() {
rows={rows}
columns={columns}
pageSize={10}
rowCount={totalRows}
rowsPerPageOptions={[10]}
onRowClick={(rowData) => handleRowClick(rowData.row)}
paginationModel={paginationModel}
onPageChange={HandlePageChange}
paginationMode="server"
hideFooterSelectedRowCount
/>
</div>
Expand Down
11 changes: 9 additions & 2 deletions src/views/clinicalGenomic/widgets/patientCounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ function PatientCounts() {
// Has this node been excluded from the results?
if (!(filters && filters?.node?.includes(entry.location.name))) {
const match = searchResults[entry.location.name];
// Iterate through each donor in this site
Object.keys(match.summary.patients_per_cohort).forEach((cohort) => {
if (cohort in counts) {
counts[cohort] += match.summary.patients_per_cohort[cohort];
} else {
counts[cohort] = match.summary.patients_per_cohort[cohort];
}
});
/* // Iterate through each donor in this site
match.forEach((donor) => {
if (filters && filters?.program_id?.includes(donor.program_id)) {
// Exclude based on cohort
Expand All @@ -45,7 +52,7 @@ function PatientCounts() {
} else {
counts[donor.program_id] = 1;
}
});
}); */
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/views/clinicalGenomic/widgets/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ function Sidebar() {

// Parse out what we need:
const sites = readerContext?.programs?.map((loc) => loc.location.name) || [];
const cohorts = readerContext?.programs?.map((loc) => loc.results.results.map((cohort) => cohort.program_id)).flat(1) || [];
const cohorts = readerContext?.programs?.map((loc) => loc?.results?.items.map((cohort) => cohort.program_id)).flat(1) || [];
const treatmentTypes = ExtractSidebarElements('treatment_types');
const tumourPrimarySites = ExtractSidebarElements('tumour_primary_sites');
const chemotherapyDrugNames = ExtractSidebarElements('chemotherapy_drug_names');
Expand Down

0 comments on commit a723d4f

Please sign in to comment.