Skip to content

Commit

Permalink
[Closes #97, #44] Admin/Staff/Volunteer user can register a new Patie…
Browse files Browse the repository at this point in the history
…nt from an unused QR code (#109)

* Basic patient registration form structure

* Able to query db for medical data inputs

* Add ability to add multiple allergies, conditions, etc to be sent to server

* Remove eslint error for importing React

* Add propTypes and JSDOC comments

* Add propTypes declaration at bottom of file

* Fix linter warnings

* Replace New Patient icon

* Rename accordion sections to better match Figma

* Use mantine form for form validation for almost all sections

* Hide selected conditions from showing up in medical data search

* Properly conditionally render empty and all options selected display

* Move selected options to be shown below the input field

* Switch to TextInput to properly display Loader

* Properly modify form data by using useForm API"

* Able to successfully send form data to server and database

* Resolve bugs due to dead code restructuring

* Utilize notifications from Mantine to notify which accordion sections have errors

* Display an error message when receiving an error from server

* Simplify form validation logic

* Simplify conditional logic and close dropdown after selecting option

* Add some basic error handling for searching medical data

* Merge branch 'dev' into issue-97

* Add error handling for duplicate id situation

* Update route to enable patientId to be extracted for patient registation

* Partially working form submission when changing sections

* Update expected request structure to reflect structure of client side form

* Update tests for new changes

* Form submission when changing sections working

* Format files

* Prevent opening accordion from triggering server requests if previously collapsed

* Remove additional patient registration request

* Refactor to reduce nesting of conditional logic

* Redirect user after submitting form to dashboard

* Adjust CSS of register form

* Tweak CSS styling

* Refactor accordion into own component

* Restyle accordion CSS

* Refactor error message function

* Rename patient registration component

* Basic stories set up

* Format file

* Replace loader component with loader in button

* Update routes to handle invalid patient IDs

* Add new error messages for patient ID issues

* Add validation and error handling for bad request format for uuid fields

* Update link for new patient to send to root

* Launch Prisma Studio with everything else

* Allow Select inputs to be searchable when typing

* Properly conditionally show a single toast when completing Basic Information

* Add Hospitals list to seeds

* Resolve console warning when handling null openedSection

* Allow user to go back to previous sections without triggering a validation error

* Add physician seed values

* Add endpoint to list hospitals

* Add a route to query for a physician of a specific hospital

* Update conditional for error/success notifications

* Basic functioning hospital search

* Basic working physician search

* Allow clicking on input to open options dropdown again

* Replace placeholder healthcare choices input fields with searchable ones

* Format and lint files

* Refactor to move combobox into its own component

* Disable PCP input field when hospital is not selected yet

* Write tests for listing all hospitals route

* Create a route that queries for all physicians in the database

* Update tests

* Update form to query db for all physicians

* Install Mantine dates for datepicker component

* Utilize Mantine DateInput to have better UX for entering DOB

* Install react imask for input masking with Mantine

* Utilize masking to make entering phone numbers easier

* Utilize InputBase component to properly display validation error of phone number

* Fix linting and regex errors

* Prevent form from submitting when pressing enter

* Allow contact phone to be empty when submitting form

* Trim user inputted strings and convert empty strings into null for db

* Add a patient GET /:id route and update tests

* Initilize form with existing values from backend

* Ignore eslint warning about adding form to dependency array

* Add explanation for disabling eslint warning for useeffect

* Properly initialize medical information data section of form

* Add a safeguard for accessing the registration form when not logged in initially

* Simplify middleName processing with optional chaining

* Update medical information to display inital values without affecting what will be sent to server

* Move healthcare choice api calls to its own file

* Make physician and hospital input fields into reusable components

* Properly load healthcare choices for preexisting patient

* Include email field for contact data

* Update schema for field changes

* Simplify passing in data to the database

* Update tests due to schema changes

* Modify update route so existing contact information is updated rather than creating a new contact everytime

* Allow for nullable healthcare choices

* Update form initialization to handle empty edge cases

* Properly disconnect patient and hospital and physician tables if necessary

* Resolve bug with changing healthcare choices from intial values

* Properly allow querying for a physician first, last and full name

* Update tests to handle edge cases regarding empty strings and undefined

* Add edge case of removing hospital and physician from a patient record

* Resolve issue of causing an input to go from defined to undefined

* Reduce redundancy of conditional register or update patient

Since the component now checks first if a patient already exists, that takes care of the conditional check for register or update

* Prevent form data loss from refetching and add guard statement for physician

* Format files

* Refactor form submission logic for registering and updating

* Resolve bug that removed all form values when transforming data

* Resolved submitPatient bugs

* Refactor api calls to a separate file

* Refactor to move medical data api calls to separate file

* Keep track of the section opened so refreshing page reopens it

* Refactor and organize registration form components

* Update import routing

* Reduce restrictions on which fields are required beyond basic info

* Add a Modal to inform user of unvisited sections before continuing

* Prevent creating a new contact if all fields are not filled out

* Refactor Search related components to be more DRY

* Clean up files

* When opening the registration form properly mark opened section as visited

* Properly handle throwing a duplicate patient error

* Properly extract the relevant fields from preexisting contact data

* Disconnect existing contact if all fields are empty

* Format files

* Resolve CSS bug that misaligned items on smaller screens

* Remove console log

* Wrap search functions in useDebounced

To reduce the number of API calls, api calls for a search query are debounced

* Adjust styling of pills and conditional logic of combobox options

* Remove unnecessary horizontal scroll bar and add gap between bottom of page

* Update GET patient/:id to also allow first responders

---------

Co-authored-by: Francis Li <[email protected]>
  • Loading branch information
samau3 and francisli committed Sep 17, 2024
1 parent 13c3884 commit e660562
Show file tree
Hide file tree
Showing 28 changed files with 5,131 additions and 3,345 deletions.
1 change: 1 addition & 0 deletions Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
client: npm run dev -w client -- --port $PORT --host 0.0.0.0
server: npm run dev -w server
prisma: npm run db:preview -w server
storybook: npm run storybook -w client
1 change: 1 addition & 0 deletions client/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = {
plugins: ['react-refresh'],
rules: {
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'react/react-in-jsx-scope': 'off',
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
Expand Down
3 changes: 3 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
},
"dependencies": {
"@mantine/core": "^7.12.1",
"@mantine/dates": "^7.12.1",
"@mantine/form": "^7.12.1",
"@mantine/hooks": "^7.12.1",
"@mantine/notifications": "^7.12.1",
"@tabler/icons-react": "^3.12.0",
"@tanstack/react-query": "^5.51.23",
"dayjs": "^1.11.13",
"http-status-codes": "^2.3.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-imask": "^7.6.1",
"react-qrcode-logo": "^3.0.0",
"react-router-dom": "^6.26.0"
},
Expand Down
5 changes: 5 additions & 0 deletions client/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import PasswordForgot from './pages/auth/password-forgot/passwordForgot';
import PasswordReset from './pages/auth/password-reset/passwordReset';
import AuthLayout from './stories/AuthLayout/AuthLayout';
import Verify from './pages/verify/verify';
import PatientRegistration from './pages/patients/PatientRegistration';

const RedirectProps = {
isLoading: PropTypes.bool.isRequired,
Expand Down Expand Up @@ -96,6 +97,10 @@ function App() {
path="/admin/patients/generate"
element={<AdminPatientsGenerate />}
/>
<Route
path="/admin/patients/register/:patientId"
element={<PatientRegistration />}
/>
<Route path="/admin/users" element={<AdminUsers />} />
<Route
path="/admin/pending-users"
Expand Down
6 changes: 6 additions & 0 deletions client/src/components/Sidebar/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
IconNotification,
IconSpeakerphone,
IconSquareArrowRight,
IconClipboardPlus,
} from '@tabler/icons-react';

import { SidebarNavSection, SidebarLink } from './SidebarNavSection';
Expand All @@ -24,6 +25,11 @@ const sections = [
icon: null,
links: [
{ label: 'Patient', href: '/', icon: <IconEmergencyBed stroke={2} /> },
{
label: 'New Patient',
href: '/',
icon: <IconClipboardPlus stroke={2} />,
},
{
label: 'Team Member',
href: '/admin/users',
Expand Down
1 change: 1 addition & 0 deletions client/src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Notifications } from '@mantine/notifications';

import '@mantine/core/styles.css';
import '@mantine/notifications/styles.css';
import '@mantine/dates/styles.css';

import App from './App.jsx';
import { theme } from './theme';
Expand Down
68 changes: 68 additions & 0 deletions client/src/pages/patients/LifelineAPI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
const SERVER_BASE_URL = '/api/v1';

export default class LifelineAPI {
static async getHealthcareChoices(route, query) {
if (route === 'hospital') {
return this.getHospitals(query);
} else if (route === 'physician') {
return this.getPhysicians(query);
}
}

static async getPhysicians(query) {
const response = await fetch(
`${SERVER_BASE_URL}/physicians?physician=${query}`,
);
const data = await response.json();
return data.map((item) => {
return {
...item,
name: `${item.firstName} ${item.lastName}`,
};
});
}

static async getHospitals(query) {
const response = await fetch(
`${SERVER_BASE_URL}/hospitals?hospital=${query}`,
);
const data = await response.json();
return data;
}

static async getPatient(patientId) {
const response = await fetch(`${SERVER_BASE_URL}/patients/${patientId}`);
return response;
}

static async registerPatient(data, patientId) {
const response = await fetch(`${SERVER_BASE_URL}/patients`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ ...data, id: patientId }),
});

return response;
}

static async updatePatient(data, patientId) {
const response = await fetch(`${SERVER_BASE_URL}/patients/${patientId}`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});
return response;
}

static async getMedicalData(path, pathInfo, query) {
const response = await fetch(
`${SERVER_BASE_URL}/${path}?${pathInfo}=${query}`,
);
const data = await response.json();
return data;
}
}
12 changes: 12 additions & 0 deletions client/src/pages/patients/PatientRegistationAccordion.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.control {
background-color: var(--mantine-color-gray-6);
font-weight: 600;

&[data-active] {
background-color: white;
}
}

.label {
font-size: 1.5rem;
}
Loading

0 comments on commit e660562

Please sign in to comment.