Skip to content

Commit

Permalink
Migrate Requests page to using a direct Neo4j query (#170)
Browse files Browse the repository at this point in the history
* Define GraphQL types for the new Requests query

* Define logic and resolvers for the new Requests query

* Rewrite the Requests frontend page to use the new query

* Sort Patients page by importDate by default
  • Loading branch information
qu8n authored Nov 14, 2024
1 parent d9c2b5b commit b8c9a2d
Show file tree
Hide file tree
Showing 9 changed files with 999 additions and 120 deletions.
2 changes: 1 addition & 1 deletion codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ generates:
withHooks: false
./graphql.schema.json:
plugins:
- "introspection"
- "introspection"
172 changes: 170 additions & 2 deletions frontend/src/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,28 @@ export type DashboardRecordSort = {
sort: AgGridSortDirection;
};

export type DashboardRequest = {
__typename?: "DashboardRequest";
bicAnalysis?: Maybe<Scalars["Boolean"]>;
dataAccessEmails?: Maybe<Scalars["String"]>;
dataAnalystEmail?: Maybe<Scalars["String"]>;
dataAnalystName?: Maybe<Scalars["String"]>;
genePanel?: Maybe<Scalars["String"]>;
igoProjectId?: Maybe<Scalars["String"]>;
igoRequestId: Scalars["String"];
importDate?: Maybe<Scalars["String"]>;
investigatorEmail?: Maybe<Scalars["String"]>;
investigatorName?: Maybe<Scalars["String"]>;
isCmoRequest?: Maybe<Scalars["Boolean"]>;
labHeadEmail?: Maybe<Scalars["String"]>;
labHeadName?: Maybe<Scalars["String"]>;
otherContactEmails?: Maybe<Scalars["String"]>;
piEmail?: Maybe<Scalars["String"]>;
projectManagerName?: Maybe<Scalars["String"]>;
qcAccessEmails?: Maybe<Scalars["String"]>;
totalSampleCount?: Maybe<Scalars["Int"]>;
};

export type DashboardSample = {
__typename?: "DashboardSample";
accessLevel?: Maybe<Scalars["String"]>;
Expand Down Expand Up @@ -4550,6 +4572,8 @@ export type Query = {
cohortsConnection: CohortsConnection;
dashboardPatientCount: DashboardRecordCount;
dashboardPatients: Array<DashboardPatient>;
dashboardRequestCount: DashboardRecordCount;
dashboardRequests: Array<DashboardRequest>;
dashboardSampleCount: DashboardRecordCount;
dashboardSamples: Array<DashboardSample>;
mafCompletes: Array<MafComplete>;
Expand Down Expand Up @@ -4652,6 +4676,19 @@ export type QueryDashboardPatientsArgs = {
sort: DashboardRecordSort;
};

export type QueryDashboardRequestCountArgs = {
filter?: InputMaybe<DashboardRecordFilter>;
searchVals?: InputMaybe<Array<Scalars["String"]>>;
};

export type QueryDashboardRequestsArgs = {
filter?: InputMaybe<DashboardRecordFilter>;
limit: Scalars["Int"];
offset: Scalars["Int"];
searchVals?: InputMaybe<Array<Scalars["String"]>>;
sort: DashboardRecordSort;
};

export type QueryDashboardSampleCountArgs = {
context?: InputMaybe<DashboardRecordContext>;
filter?: InputMaybe<DashboardRecordFilter>;
Expand Down Expand Up @@ -6760,7 +6797,7 @@ export type Sample = {
requestsHasSample: Array<Request>;
requestsHasSampleAggregate?: Maybe<SampleRequestRequestsHasSampleAggregationSelection>;
requestsHasSampleConnection: SampleRequestsHasSampleConnection;
revisable: Scalars["Boolean"];
revisable?: Maybe<Scalars["Boolean"]>;
sampleAliasesIsAlias: Array<SampleAlias>;
sampleAliasesIsAliasAggregate?: Maybe<SampleSampleAliasSampleAliasesIsAliasAggregationSelection>;
sampleAliasesIsAliasConnection: SampleSampleAliasesIsAliasConnection;
Expand Down Expand Up @@ -7534,7 +7571,7 @@ export type SampleCreateInput = {
hasTempoTempos?: InputMaybe<SampleHasTempoTemposFieldInput>;
patientsHasSample?: InputMaybe<SamplePatientsHasSampleFieldInput>;
requestsHasSample?: InputMaybe<SampleRequestsHasSampleFieldInput>;
revisable: Scalars["Boolean"];
revisable?: InputMaybe<Scalars["Boolean"]>;
sampleAliasesIsAlias?: InputMaybe<SampleSampleAliasesIsAliasFieldInput>;
sampleCategory: Scalars["String"];
sampleClass: Scalars["String"];
Expand Down Expand Up @@ -12505,6 +12542,43 @@ export type PatientsListQuery = {
}>;
};

export type DashboardRequestsQueryVariables = Exact<{
searchVals?: InputMaybe<Array<Scalars["String"]> | Scalars["String"]>;
filter?: InputMaybe<DashboardRecordFilter>;
sort: DashboardRecordSort;
limit: Scalars["Int"];
offset: Scalars["Int"];
}>;

export type DashboardRequestsQuery = {
__typename?: "Query";
dashboardRequestCount: {
__typename?: "DashboardRecordCount";
totalCount: number;
};
dashboardRequests: Array<{
__typename?: "DashboardRequest";
igoRequestId: string;
igoProjectId?: string | null;
importDate?: string | null;
totalSampleCount?: number | null;
projectManagerName?: string | null;
investigatorName?: string | null;
investigatorEmail?: string | null;
piEmail?: string | null;
dataAnalystName?: string | null;
dataAnalystEmail?: string | null;
genePanel?: string | null;
labHeadName?: string | null;
labHeadEmail?: string | null;
qcAccessEmails?: string | null;
dataAccessEmails?: string | null;
bicAnalysis?: boolean | null;
isCmoRequest?: boolean | null;
otherContactEmails?: string | null;
}>;
};

export type DashboardPatientsQueryVariables = Exact<{
searchVals?: InputMaybe<Array<Scalars["String"]> | Scalars["String"]>;
filter?: InputMaybe<DashboardRecordFilter>;
Expand Down Expand Up @@ -13007,6 +13081,100 @@ export type PatientsListQueryResult = Apollo.QueryResult<
PatientsListQuery,
PatientsListQueryVariables
>;
export const DashboardRequestsDocument = gql`
query DashboardRequests(
$searchVals: [String!]
$filter: DashboardRecordFilter
$sort: DashboardRecordSort!
$limit: Int!
$offset: Int!
) {
dashboardRequestCount(searchVals: $searchVals, filter: $filter) {
totalCount
}
dashboardRequests(
searchVals: $searchVals
filter: $filter
sort: $sort
limit: $limit
offset: $offset
) {
igoRequestId
igoProjectId
importDate
totalSampleCount
projectManagerName
investigatorName
investigatorEmail
piEmail
dataAnalystName
dataAnalystEmail
genePanel
labHeadName
labHeadEmail
qcAccessEmails
dataAccessEmails
bicAnalysis
isCmoRequest
otherContactEmails
}
}
`;

/**
* __useDashboardRequestsQuery__
*
* To run a query within a React component, call `useDashboardRequestsQuery` and pass it any options that fit your needs.
* When your component renders, `useDashboardRequestsQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useDashboardRequestsQuery({
* variables: {
* searchVals: // value for 'searchVals'
* filter: // value for 'filter'
* sort: // value for 'sort'
* limit: // value for 'limit'
* offset: // value for 'offset'
* },
* });
*/
export function useDashboardRequestsQuery(
baseOptions: Apollo.QueryHookOptions<
DashboardRequestsQuery,
DashboardRequestsQueryVariables
>
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useQuery<
DashboardRequestsQuery,
DashboardRequestsQueryVariables
>(DashboardRequestsDocument, options);
}
export function useDashboardRequestsLazyQuery(
baseOptions?: Apollo.LazyQueryHookOptions<
DashboardRequestsQuery,
DashboardRequestsQueryVariables
>
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useLazyQuery<
DashboardRequestsQuery,
DashboardRequestsQueryVariables
>(DashboardRequestsDocument, options);
}
export type DashboardRequestsQueryHookResult = ReturnType<
typeof useDashboardRequestsQuery
>;
export type DashboardRequestsLazyQueryHookResult = ReturnType<
typeof useDashboardRequestsLazyQuery
>;
export type DashboardRequestsQueryResult = Apollo.QueryResult<
DashboardRequestsQuery,
DashboardRequestsQueryVariables
>;
export const DashboardPatientsDocument = gql`
query DashboardPatients(
$searchVals: [String!]
Expand Down
12 changes: 3 additions & 9 deletions frontend/src/pages/patients/PatientsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { Tooltip } from "@material-ui/core";
import InfoIcon from "@material-ui/icons/InfoOutlined";
import { parseUserSearchVal } from "../../utils/parseSearchQueries";
import {
MAX_ROWS_EXPORT,
MAX_ROWS_EXPORT_WARNING,
PatientsListColumns,
SampleMetadataDetailsColumns,
} from "../../shared/helpers";
Expand All @@ -24,14 +26,6 @@ function addCDashToCMOId(cmoId: string): string {
return cmoId.length === 6 ? `C-${cmoId}` : cmoId;
}

const MAX_ROWS_EXPORT = 10000;

const MAX_ROWS_EXPORT_WARNING = {
title: "Warning",
content:
"You can only download up to 10,000 rows of data at a time. Please refine your search and try again. If you need the full dataset, contact the SMILE team at cmosmile@mskcc.org.",
};

const PHI_WARNING = {
title: "Warning",
content:
Expand Down Expand Up @@ -204,7 +198,7 @@ export default function PatientsPage({
const sampleQueryParamFieldName = "patientId";
const sampleQueryParamValue = params[sampleQueryParamFieldName];
const defaultSort = {
colId: "dmpPatientId",
colId: "latestImportDate",
sort: AgGridSortDirection.Desc,
};

Expand Down
Loading

0 comments on commit b8c9a2d

Please sign in to comment.