Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup clinical entity data table #173

Merged
merged 18 commits into from
Apr 15, 2024

Conversation

ciaranschutte
Copy link
Contributor

@ciaranschutte ciaranschutte commented Apr 14, 2024

Context:
Lots of code "copy/pasted" from platform-ui have TS types written be developers.
These clash with generated types from GQL endpoints.
The GQL generated types is the correct way, as our written don't always encompass the types correctly and are prone to error.

Additionally we have many places that have empty objects as default values. These cause type errors when they differ from the actual returned object. Example, a filter function is expecting ClinicalData[] but it actually gets EmptyClinicalData[] that doesn't quite satisfy type constraints. This leads to writing code to type narrow/account for both of these types OR making them satisfy the same type. Array methods in particular are tricky.

Another difference is there is a major TS version change between platform-ui and rdpc-ui so the "copy/paste" approach from platform-ui surfaced a lot of errors. ( v4 vs v5 )

Changes:
This PR mostly changes types, fixes a couple of generics and adds extra property to satisfy types.
A couple of instances of using any because it's a bigger issue that needs to be fixed at a component level.
For clinical data page a lot of code reorganisation to solve type issues by type narrowing in correct place eg. if no data/loading, there's often a lot of code we don't ever need to worry about unless we do have data or are not loading.

Disables ESLint on build. We can re-enable later when repo is in better shape. For now step 1 is having project successfully build.

@ciaranschutte
Copy link
Contributor Author

ciaranschutte commented Apr 14, 2024

@joneubank tagging for visibility as I know you were looking at this also. fixing TS build issues.

@@ -29,8 +29,7 @@ import {
import union from 'lodash/union';
import { ComponentProps, ReactNode, createRef } from 'react';

export type ErrorReportColumns = { header: string; id: string };

export type ErrorReportColumns = any;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file needs additional work. #175
Changing to any type for now to keep ErrorNotification fix isolated to it's own branch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me incredibly nervous... Its hard to get any types out once they are in, everything that uses them will have no type checking performed.

clinicalData: {
programShortName: '',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not ideal but works ok as a type-fix - this is just an empty object meant as a default value to display nothing - "emtptyClinicalDataResponse"

the root cause is the mismatch between TS types and GQL generated types.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this used, could we change this from an empty object to a function that returns the empty object?

export const emptyClinicalDataResponse = 
  (programShortName: string): SubmittedDataSideMenuQuery => 
    ({/*...content of the empty object but with a populated short name...*/});

@ciaranschutte ciaranschutte marked this pull request as ready for review April 15, 2024 15:59
Copy link
Member

@joneubank joneubank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, just need to remove the any usage and this is fine.

I left one other question, let me know your thoughts... no change needed.

clinicalData: {
programShortName: '',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this used, could we change this from an empty object to a function that returns the empty object?

export const emptyClinicalDataResponse = 
  (programShortName: string): SubmittedDataSideMenuQuery => 
    ({/*...content of the empty object but with a populated short name...*/});

@@ -29,8 +29,7 @@ import {
import union from 'lodash/union';
import { ComponentProps, ReactNode, createRef } from 'react';

export type ErrorReportColumns = { header: string; id: string };

export type ErrorReportColumns = any;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me incredibly nervous... Its hard to get any types out once they are in, everything that uses them will have no type checking performed.


const { clinicalData } = clinicalEntityData;

// TODO: can you have ClinicalEntityErrors without ClinicalEntityData?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically yes ClinicalEntityErrors is supposed to work as a separate standalone query, so this TODO can be removed.
However I tested and it is not working in Develop. I have a patch PR coming in shortly.

@ciaranschutte
Copy link
Contributor Author

discussed offline, adding back in ErrorNotification type. build will remain broke but will address full fix in seperate PR

@ciaranschutte ciaranschutte requested a review from joneubank April 15, 2024 20:36
@ciaranschutte ciaranschutte merged commit cead516 into develop Apr 15, 2024
@ciaranschutte ciaranschutte deleted the cleanup_clinical_entity_data_table branch April 15, 2024 21:18
This was referenced Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants