-
Notifications
You must be signed in to change notification settings - Fork 0
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
Results list route #78
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I think it's worth taking advantage of the fact that we know the data structure if we can (which I think should be fairly straightforward) from the existing typescript libraries for FHIR
src/pages/Results.tsx
Outdated
const [parsedResults, setParsedResults] = useState<parsedResultsModel | null>(null); | ||
|
||
useEffect(() => { | ||
const observationQueryUrl = `${FHIR_URL}/Observation?_profile=http://hl7.org/fhir/uv/genomics-reporting/StructureDefinition/variant&_include=Observation:subject`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the fhir context is instantiated with the base URL, so can just use this and remove the reuse of the env variable
const observationQueryUrl = `${FHIR_URL}/Observation?_profile=http://hl7.org/fhir/uv/genomics-reporting/StructureDefinition/variant&_include=Observation:subject`; | |
const observationQueryUrl = `/Observation?_profile=http://hl7.org/fhir/uv/genomics-reporting/StructureDefinition/variant&_include=Observation:subject`; |
…assed successfully
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, some non-blocking suggestions
type trimmedObservation = { cDnaChange: string | undefined; observationId: string | undefined }; | ||
type patientResult = { | ||
firstName: string | undefined; | ||
lastName: string | undefined; | ||
patientId: string | undefined; | ||
observations: trimmedObservation[]; | ||
}; | ||
export type parsedResultsModel = patientResult[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the convention for types is to have a capital first letter, or am I getting my languages mixed up?
const [parsedResults, setParsedResults] = useState<parsedResultsModel | null>(null); | ||
|
||
useEffect(() => { | ||
const observationQueryUrl = `${FHIR_URL}/Observation?_profile=http://hl7.org/fhir/uv/genomics-reporting/StructureDefinition/variant&_include=Observation:subject`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need the FHIR URL in this, and can remove the import
const observationQueryUrl = `${FHIR_URL}/Observation?_profile=http://hl7.org/fhir/uv/genomics-reporting/StructureDefinition/variant&_include=Observation:subject`; | |
const observationQueryUrl = `/Observation?_profile=http://hl7.org/fhir/uv/genomics-reporting/StructureDefinition/variant&_include=Observation:subject`; |
return subjectIdLong.includes(patientId); | ||
}); | ||
|
||
if (!patientObservations || patientObservations.length === 0) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
personal preference but I'd aim to make logic branches obvious
if (!patientObservations || patientObservations.length === 0) return; | |
if (!patientObservations || patientObservations.length === 0) { | |
return; | |
} |
}; | ||
|
||
if (!parsedResults) { | ||
return <div>Getting observations.</div>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this getting observations at that point? - I would have thought that's covered in loading spinner but maybe I'm getting confused
if (!observation || !observation.component) return; | ||
|
||
const trimmedObservation = observation.component.filter((component) => { | ||
const loincCode = "48004-6"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be worth having this as a constant at the top level of the file and name it as something like HGVS_CDNA_LOINC
any
type in these cases. Is there a better way to add accurate typings here?app.tsx
to expose the necessary methods toResults.tsx
. As a result, I have removed a few imports inNewReport.tsx
.