-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(frontend, backend): connect rxdb (#6)
* Make a terrible rxdb implementation * Fix issues with updating patients * Style fixes * Small fixes * Lay groundwork for GraphQL sync * Add push replication * Fix bug with unknown consult entity * Change uid to id, connect RxDB pull * Fix issues with push-replication, DOB field * Fix a few errors * Fix serialization issues * Never lose a patient again * Fix deletedAt * Fix enums... again * !!Fix vulnerabilities (includes run of npm update) * Fix npm CI(?) * roll back node version for CD npm/cli#4942 * whoops wrong version * Fix frontend tests * Refactor for readability * Fix issues * Automatically select first tab where available * Add required fields * Ugly hack to reduce traffic * match project file structure * fix nitpick * match project file structure * Fix error with patient ordering in feed * move usePatients hook Co-authored-by: Jackson Chadfield <[email protected]>
- Loading branch information
Showing
31 changed files
with
12,581 additions
and
4,101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { InputType, Field, PartialType } from '@nestjs/graphql'; | ||
import { UpdatePatientInput } from './update-patient.input'; | ||
|
||
@InputType() | ||
export class SetPatientInput extends PartialType(UpdatePatientInput) { | ||
// TODO: add field descriptions | ||
@Field(() => String, { nullable: false }) | ||
id: string; | ||
|
||
@Field({ nullable: true }) | ||
deletedAt: Date; | ||
|
||
@Field({ nullable: true }) | ||
updatedAt: Date; | ||
} |
21 changes: 21 additions & 0 deletions
21
apps/backend/src/app/patients/graphql/date-of-birth.scalar.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { GraphQLScalarType, Kind } from 'graphql'; | ||
|
||
export const DateOfBirthScalar = new GraphQLScalarType({ | ||
name: 'DateOfBirth', | ||
description: 'Date custom scalar type', | ||
parseValue(value: string | number | Date) { | ||
return new Date(value); // value from the client | ||
}, | ||
serialize(value: string | number | Date) { | ||
if (value instanceof Date) { | ||
return value.toISOString(); // value sent to the client | ||
} | ||
return new Date(value).toISOString(); | ||
}, | ||
parseLiteral(ast) { | ||
if (ast.kind === Kind.INT) { | ||
return new Date(ast.value); // ast value is always in string format | ||
} | ||
return null; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 40 additions & 86 deletions
126
apps/frontend/src/app/patients/patient-details-page/patient-details-page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,114 +1,68 @@ | ||
import React from 'react'; | ||
import { ScrollArea, SimpleGrid } from '@mantine/core'; | ||
import { useState } from 'react'; | ||
import { Center, ScrollArea, SimpleGrid, Text } from '@mantine/core'; | ||
import { Button } from '@shared'; | ||
import { PatientTabs } from '../patient-tabs'; | ||
import { PatientInputs } from '../patient-inputs'; | ||
import { PatientRecords } from '../patient-records'; | ||
|
||
export type IPatient = { | ||
uid: string; | ||
id: string; | ||
firstName?: string; | ||
lastName?: string; | ||
dob?: string; | ||
patientId?: string; | ||
dateOfBirth?: string; | ||
ethnicity?: string; | ||
gender?: string; | ||
school?: string; | ||
year?: number; | ||
yearLevel?: number; | ||
room?: string; | ||
address?: { | ||
street?: string; | ||
suburb?: string; | ||
city?: string; | ||
postCode?: string; | ||
}; | ||
streetAddress?: string; | ||
suburb?: string; | ||
city?: string; | ||
postcode?: string; | ||
caregiverFirstName?: string; | ||
caregiverLastName?: string; | ||
phoneNumber?: string; | ||
email?: string; | ||
notes?: string; | ||
adminNotes?: string; | ||
}; | ||
|
||
export const PatientDetailsPage = () => { | ||
// TODO: Replace with actual data | ||
const [patients, setPatients] = React.useState<IPatient[]>([ | ||
{ | ||
uid: '8c78e8d5-26e5-4a99-a112-0b8602bf2c1b', | ||
firstName: 'Yulia', | ||
lastName: 'Pechorina', | ||
dob: '2001-02-21', | ||
patientId: '12345', | ||
ethnicity: 'other european', | ||
gender: 'female', | ||
school: 'The University of Auckland', | ||
year: 4, | ||
room: 'N/A', | ||
address: { | ||
street: '1000 Fifth Avenue', | ||
suburb: 'Manhattan', | ||
city: 'New York', | ||
postCode: '10028', | ||
}, | ||
caregiverFirstName: 'John', | ||
caregiverLastName: 'Doe', | ||
phoneNumber: '+64 9 12345678', | ||
email: '[email protected]', | ||
notes: 'Nothing to add', | ||
}, | ||
{ | ||
uid: 'c7695a78-33ae-4f71-9c54-4a3336628965', | ||
firstName: 'Kid', | ||
lastName: 'Cudi', | ||
dob: '1984-01-30', | ||
patientId: '54321', | ||
gender: 'male', | ||
}, | ||
]); | ||
|
||
const [currentPatient, setCurrentPatient] = React.useState<IPatient>( | ||
patients[0] | ||
); | ||
const [currentPatientUid, setCurrentPatientUid] = useState< | ||
string | undefined | ||
>(); | ||
|
||
const handlePatientChange = (uid: string) => { | ||
const patient = patients.find((p) => p.uid === uid); | ||
if (patient) { | ||
setCurrentPatient(patient); | ||
} | ||
}; | ||
|
||
const handleUpdatePatient = (updatedPatient: IPatient) => { | ||
setCurrentPatient(updatedPatient); | ||
const newPatients = patients.map((p) => { | ||
if (p.uid === updatedPatient.uid) { | ||
return updatedPatient; | ||
} | ||
return p; | ||
}); | ||
setPatients(newPatients); | ||
setCurrentPatientUid(uid); | ||
}; | ||
|
||
return ( | ||
<> | ||
<PatientTabs patients={patients} onPatientChange={handlePatientChange} /> | ||
<ScrollArea className="h-full p-8"> | ||
<SimpleGrid | ||
cols={3} | ||
spacing={180} | ||
breakpoints={[ | ||
{ maxWidth: 1024, cols: 2, spacing: 100 }, | ||
{ maxWidth: 1280, cols: 3, spacing: 100 }, | ||
]} | ||
> | ||
<PatientInputs | ||
patient={currentPatient} | ||
onUpdatePatient={handleUpdatePatient} | ||
/> | ||
</SimpleGrid> | ||
<div className="flex mt-5 -mb-5 justify-end w-full"> | ||
<Button className="ml-auto">CREATE NEW RECORD</Button> | ||
</div> | ||
<PatientRecords className="pb-5" /> | ||
</ScrollArea> | ||
<PatientTabs | ||
currentPatientUid={currentPatientUid} | ||
onPatientChange={handlePatientChange} | ||
/> | ||
{currentPatientUid ? ( | ||
<ScrollArea className="h-full p-8"> | ||
<SimpleGrid | ||
cols={3} | ||
spacing={180} | ||
breakpoints={[ | ||
{ maxWidth: 1024, cols: 2, spacing: 100 }, | ||
{ maxWidth: 1280, cols: 3, spacing: 100 }, | ||
]} | ||
> | ||
<PatientInputs patientUid={currentPatientUid} /> | ||
</SimpleGrid> | ||
<div className="flex mt-5 -mb-5 justify-end w-full"> | ||
<Button className="ml-auto">CREATE NEW RECORD</Button> | ||
</div> | ||
<PatientRecords className="pb-5" /> | ||
</ScrollArea> | ||
) : ( | ||
<Center className="h-full"> | ||
<Text>Click on a patient to view their details</Text> | ||
</Center> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
Oops, something went wrong.