author
int64 658
755k
| date
stringlengths 19
19
| timezone
int64 -46,800
43.2k
| hash
stringlengths 40
40
| message
stringlengths 5
490
| mods
list | language
stringclasses 20
values | license
stringclasses 3
values | repo
stringlengths 5
68
| original_message
stringlengths 12
491
|
---|---|---|---|---|---|---|---|---|---|
288,254 | 08.02.2020 17:47:54 | 0 | 099e50d846e1574dff2b28aafd77b7d01c4da955 | fix(patients): internationalize No Related Persons warning & loading
re | [
{
"change_type": "MODIFY",
"old_path": "src/locales/en-US/translation.json",
"new_path": "src/locales/en-US/translation.json",
"diff": "\"relatedPersonRequired\": \"Related Person is required.\",\n\"relationshipTypeRequired\": \"Relationship Type is required.\"\n},\n+ \"warning\": {\n+ \"noRelatedPersons\": \"No Related Persons\"\n+ },\n\"label\": \"Related Persons\",\n\"new\": \"New Related Person\",\n- \"relationshipType\": \"Relationship Type\"\n+ \"relationshipType\": \"Relationship Type\",\n+ \"addRelatedPersonAbove\": \"Add a related person using the button above.\"\n},\n\"types\": {\n\"charity\": \"Charity\",\n},\n\"states\": {\n\"success\": \"Success!\",\n- \"error\": \"Error!\"\n+ \"error\": \"Error!\",\n+ \"loading\": \"Loading...\"\n},\n\"scheduling\": {\n\"label\": \"Scheduling\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/related-persons/RelatedPersonTab.tsx",
"new_path": "src/patients/related-persons/RelatedPersonTab.tsx",
"diff": "@@ -108,12 +108,12 @@ const RelatedPersonTab = (props: Props) => {\n) : (\n<Alert\ncolor=\"warning\"\n- title=\"No Related Persons\"\n- message=\"Add a related person using the button above.\"\n+ title={t('patient.relatedPersons.warning.noRelatedPersons')}\n+ message={t('patient.relatedPersons.addRelatedPersonAbove')}\n/>\n)\n) : (\n- <h1>Loading...</h1>\n+ <h1>{t('states.loading')}</h1>\n)}\n</Panel>\n</div>\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(patients): internationalize No Related Persons warning & loading
re #1789 |
288,254 | 09.02.2020 12:24:30 | 0 | e6ce4cb979d3f3cd7c3704490ad4251955f4922f | fix(patients): replace "Loading..." text with Spinner component
re | [
{
"change_type": "MODIFY",
"old_path": "src/locales/en-US/translation.json",
"new_path": "src/locales/en-US/translation.json",
"diff": "},\n\"states\": {\n\"success\": \"Success!\",\n- \"error\": \"Error!\",\n- \"loading\": \"Loading...\"\n+ \"error\": \"Error!\"\n},\n\"scheduling\": {\n\"label\": \"Scheduling\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/related-persons/RelatedPersonTab.tsx",
"new_path": "src/patients/related-persons/RelatedPersonTab.tsx",
"diff": "import React, { useState, useEffect } from 'react'\n-import { Button, Panel, List, ListItem, Alert } from '@hospitalrun/components'\n+import { Button, Panel, List, ListItem, Alert, Spinner } from '@hospitalrun/components'\nimport NewRelatedPersonModal from 'patients/related-persons/NewRelatedPersonModal'\nimport RelatedPerson from 'model/RelatedPerson'\nimport { useTranslation } from 'react-i18next'\n@@ -113,7 +113,7 @@ const RelatedPersonTab = (props: Props) => {\n/>\n)\n) : (\n- <h1>{t('states.loading')}</h1>\n+ <Spinner color=\"blue\" loading size={[10, 25]} type=\"ScaleLoader\" />\n)}\n</Panel>\n</div>\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(patients): replace "Loading..." text with Spinner component
re #1789 |
288,337 | 09.02.2020 19:39:13 | -3,600 | a68ed7e282ec630049671f1f4a292cae6ed91379 | feat(breadcrumb): customize breadcrumbs for patients and appointments
fix | [
{
"change_type": "MODIFY",
"old_path": "src/HospitalRun.tsx",
"new_path": "src/HospitalRun.tsx",
"diff": "@@ -5,7 +5,7 @@ import { Toaster } from '@hospitalrun/components'\nimport Appointments from 'scheduling/appointments/Appointments'\nimport NewAppointment from 'scheduling/appointments/new/NewAppointment'\nimport ViewAppointment from 'scheduling/appointments/view/ViewAppointment'\n-import Breadcrumb from 'components/Breadcrumb'\n+import Breadcrumb from 'components/breadcrumb/Breadcrumb'\nimport Sidebar from './components/Sidebar'\nimport Permissions from './model/Permissions'\nimport Dashboard from './dashboard/Dashboard'\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/HospitalRun.test.tsx",
"new_path": "src/__tests__/HospitalRun.test.tsx",
"diff": "@@ -77,7 +77,7 @@ describe('HospitalRun', () => {\nstore={mockStore({\ntitle: 'test',\nuser: { permissions: [Permissions.ReadPatients] },\n- patient,\n+ patient: { patient },\n})}\n>\n<MemoryRouter initialEntries={['/patients/123']}>\n@@ -95,6 +95,7 @@ describe('HospitalRun', () => {\nstore={mockStore({\ntitle: 'test',\nuser: { permissions: [] },\n+ patient: { patient: {} },\n})}\n>\n<MemoryRouter initialEntries={['/patients/123']}>\n@@ -133,6 +134,7 @@ describe('HospitalRun', () => {\ntitle: 'test',\nuser: { permissions: [] },\nappointments: { appointments: [] },\n+ appointment: { appointment: {} },\n})}\n>\n<MemoryRouter initialEntries={['/appointments']}>\n"
},
{
"change_type": "DELETE",
"old_path": "src/__tests__/components/Breadcrumb.test.tsx",
"new_path": null,
"diff": "-import '../../__mocks__/matchMediaMock'\n-import React from 'react'\n-import { mount } from 'enzyme'\n-import { createMemoryHistory } from 'history'\n-import { Router } from 'react-router'\n-import Breadcrumb from 'components/Breadcrumb'\n-import {\n- Breadcrumb as HrBreadcrumb,\n- BreadcrumbItem as HrBreadcrumbItem,\n-} from '@hospitalrun/components'\n-\n-describe('Breadcrumb', () => {\n- let history = createMemoryHistory()\n- const setup = (location: string) => {\n- history = createMemoryHistory()\n- history.push(location)\n- return mount(\n- <Router history={history}>\n- <Breadcrumb />\n- </Router>,\n- )\n- }\n-\n- it('should render the breadcrumb items', () => {\n- const wrapper = setup('/patients')\n- const breadcrumbItem = wrapper.find(HrBreadcrumbItem)\n-\n- expect(wrapper.find(HrBreadcrumb)).toHaveLength(1)\n- expect(\n- breadcrumbItem.matchesElement(<HrBreadcrumbItem active>patients</HrBreadcrumbItem>),\n- ).toBeTruthy()\n- })\n-})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/components/breadcrumb/Appointmentbreadcrumb.test.tsx",
"diff": "+import '../../../__mocks__/matchMediaMock'\n+import React from 'react'\n+import { Router } from 'react-router'\n+import { Provider } from 'react-redux'\n+import { mount } from 'enzyme'\n+import configureMockStore from 'redux-mock-store'\n+import { createMemoryHistory } from 'history'\n+import { BreadcrumbItem as HrBreadcrumbItem } from '@hospitalrun/components'\n+import AppointmentBreadcrumb from 'components/breadcrumb/AppointmentBreadcrumb'\n+\n+const mockStore = configureMockStore()\n+\n+describe('Breadcrumb', () => {\n+ const history = createMemoryHistory()\n+ history.push('/appointments/1234')\n+ const wrapper = mount(\n+ <Provider\n+ store={mockStore({\n+ appointment: { appointment: {} },\n+ })}\n+ >\n+ <Router history={history}>\n+ <AppointmentBreadcrumb />\n+ </Router>\n+ </Provider>,\n+ )\n+\n+ it('should render 2 breadcrumb items', () => {\n+ expect(wrapper.find(HrBreadcrumbItem)).toHaveLength(2)\n+ })\n+})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/components/breadcrumb/Breadcrumb.test.tsx",
"diff": "+import '../../../__mocks__/matchMediaMock'\n+import React from 'react'\n+import { Router } from 'react-router'\n+import { Provider } from 'react-redux'\n+import { mount } from 'enzyme'\n+import configureMockStore from 'redux-mock-store'\n+import { createMemoryHistory } from 'history'\n+import DefaultBreadcrumb from 'components/breadcrumb/DefaultBreadcrumb'\n+import PatientBreadcrumb from 'components/breadcrumb/PatientBreadcrumb'\n+import AppointmentBreadcrumb from 'components/breadcrumb/AppointmentBreadcrumb'\n+import Breadcrumb from 'components/breadcrumb/Breadcrumb'\n+\n+const mockStore = configureMockStore()\n+\n+describe('Breadcrumb', () => {\n+ const setup = (location: string) => {\n+ const history = createMemoryHistory()\n+ history.push(location)\n+ return mount(\n+ <Provider\n+ store={mockStore({\n+ patient: { patient: {} },\n+ appointment: { appointment: {} },\n+ })}\n+ >\n+ <Router history={history}>\n+ <Breadcrumb />\n+ </Router>\n+ </Provider>,\n+ )\n+ }\n+ it('should render the patient breadcrumb when /patients/:id is accessed', () => {\n+ const wrapper = setup('/patients/1234')\n+ expect(wrapper.find(PatientBreadcrumb)).toHaveLength(1)\n+ })\n+ it('should render the appointment breadcrumb when /appointments/:id is accessed', () => {\n+ const wrapper = setup('/appointments/1234')\n+ expect(wrapper.find(AppointmentBreadcrumb)).toHaveLength(1)\n+ })\n+\n+ it('should render the default breadcrumb when /patients/new is accessed', () => {\n+ const wrapper = setup('/patients/new')\n+ expect(wrapper.find(DefaultBreadcrumb)).toHaveLength(1)\n+ })\n+\n+ it('should render the default breadcrumb when /appointments/new is accessed', () => {\n+ const wrapper = setup('/appointments/new')\n+ expect(wrapper.find(DefaultBreadcrumb)).toHaveLength(1)\n+ })\n+\n+ it('should render the default breadcrumb when any other path is accessed', () => {\n+ let wrapper = setup('/appointments')\n+ expect(wrapper.find(DefaultBreadcrumb)).toHaveLength(1)\n+\n+ wrapper = setup('/patients')\n+ expect(wrapper.find(DefaultBreadcrumb)).toHaveLength(1)\n+\n+ wrapper = setup('/')\n+ expect(wrapper.find(DefaultBreadcrumb)).toHaveLength(1)\n+ })\n+})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/components/breadcrumb/DefaultBreadcrumb.test.tsx",
"diff": "+import '../../../__mocks__/matchMediaMock'\n+import React from 'react'\n+import { mount } from 'enzyme'\n+import { createMemoryHistory } from 'history'\n+import { Router } from 'react-router'\n+import DefaultBreadcrumb, { getItems } from 'components/breadcrumb/DefaultBreadcrumb'\n+import { BreadcrumbItem as HrBreadcrumbItem } from '@hospitalrun/components'\n+\n+describe('DefaultBreadcrumb', () => {\n+ describe('getItems', () => {\n+ it('should return valid items for pathname /', () => {\n+ expect(getItems('/')).toEqual([{ url: '/', active: true }])\n+ })\n+\n+ it('should return valid items for pathname /patients', () => {\n+ expect(getItems('/patients')).toEqual([{ url: '/patients', active: true }])\n+ })\n+\n+ it('should return valid items for pathname /appointments', () => {\n+ expect(getItems('/appointments')).toEqual([{ url: '/appointments', active: true }])\n+ })\n+\n+ it('should return valid items for pathname /patients/new', () => {\n+ expect(getItems('/patients/new')).toEqual([\n+ { url: '/patients', active: false },\n+ { url: '/patients/new', active: true },\n+ ])\n+ })\n+\n+ it('should return valid items for pathname /appointments/new', () => {\n+ expect(getItems('/appointments/new')).toEqual([\n+ { url: '/appointments', active: false },\n+ { url: '/appointments/new', active: true },\n+ ])\n+ })\n+ })\n+\n+ describe('rendering', () => {\n+ const setup = (location: string) => {\n+ const history = createMemoryHistory()\n+ history.push(location)\n+ return mount(\n+ <Router history={history}>\n+ <DefaultBreadcrumb />\n+ </Router>,\n+ )\n+ }\n+\n+ it('should render one breadcrumb item for the path /', () => {\n+ const wrapper = setup('/')\n+ expect(wrapper.find(HrBreadcrumbItem)).toHaveLength(1)\n+ })\n+ })\n+})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/components/breadcrumb/PatientBreadcrumb.test.tsx",
"diff": "+import '../../../__mocks__/matchMediaMock'\n+import React from 'react'\n+import { Router } from 'react-router'\n+import { Provider } from 'react-redux'\n+import { mount } from 'enzyme'\n+import configureMockStore from 'redux-mock-store'\n+import { createMemoryHistory } from 'history'\n+import { BreadcrumbItem as HrBreadcrumbItem } from '@hospitalrun/components'\n+import PatientBreadcrumb from 'components/breadcrumb/PatientBreadcrumb'\n+\n+const mockStore = configureMockStore()\n+\n+describe('Breadcrumb', () => {\n+ const history = createMemoryHistory()\n+ history.push('/patients/1234')\n+ const wrapper = mount(\n+ <Provider\n+ store={mockStore({\n+ patient: { patient: {} },\n+ })}\n+ >\n+ <Router history={history}>\n+ <PatientBreadcrumb />\n+ </Router>\n+ </Provider>,\n+ )\n+\n+ it('should render 2 breadcrumb items', () => {\n+ expect(wrapper.find(HrBreadcrumbItem)).toHaveLength(2)\n+ })\n+})\n"
},
{
"change_type": "DELETE",
"old_path": "src/components/Breadcrumb.tsx",
"new_path": null,
"diff": "-import React from 'react'\n-import { useLocation, useHistory } from 'react-router'\n-import {\n- Breadcrumb as HrBreadcrumb,\n- BreadcrumbItem as HrBreadcrumbItem,\n-} from '@hospitalrun/components'\n-\n-interface Item {\n- name: string\n- url: string\n-}\n-\n-function getItems(pathname: string): Item[] {\n- if (!pathname || pathname === '/') {\n- return [{ name: 'dashboard', url: '/' }]\n- }\n-\n- return pathname\n- .substring(1)\n- .split('/')\n- .map((name) => ({ name, url: '/' }))\n-}\n-\n-const Breadcrumb = () => {\n- const { pathname } = useLocation()\n- const history = useHistory()\n- const items = getItems(pathname)\n- const lastIndex = items.length - 1\n-\n- return (\n- <HrBreadcrumb>\n- {items.map((item, index) => {\n- const isLast = index === lastIndex\n- const onClick = !isLast ? () => history.push(item.url) : undefined\n-\n- return (\n- <HrBreadcrumbItem key={item.name} active={isLast} onClick={onClick}>\n- {item.name}\n- </HrBreadcrumbItem>\n- )\n- })}\n- </HrBreadcrumb>\n- )\n-}\n-\n-export default Breadcrumb\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/components/breadcrumb/AppointmentBreadcrumb.tsx",
"diff": "+import React from 'react'\n+import { useHistory } from 'react-router'\n+import { useSelector } from 'react-redux'\n+import { useTranslation } from 'react-i18next'\n+import {\n+ Breadcrumb as HrBreadcrumb,\n+ BreadcrumbItem as HrBreadcrumbItem,\n+} from '@hospitalrun/components'\n+import { RootState } from '../../store'\n+\n+const AppointmentBreacrumb = () => {\n+ const { t } = useTranslation()\n+ const { appointment } = useSelector((state: RootState) => state.appointment)\n+ const history = useHistory()\n+ let appointmentLabel = ''\n+\n+ if (appointment.startDateTime && appointment.endDateTime) {\n+ const startDateLabel = new Date(appointment.startDateTime).toLocaleString()\n+ const endDateLabel = new Date(appointment.endDateTime).toLocaleString()\n+ appointmentLabel = `${startDateLabel} - ${endDateLabel}`\n+ }\n+\n+ return (\n+ <HrBreadcrumb>\n+ <HrBreadcrumbItem onClick={() => history.push('/appointments')}>\n+ {t('scheduling.appointments.label')}\n+ </HrBreadcrumbItem>\n+ <HrBreadcrumbItem active>{appointmentLabel}</HrBreadcrumbItem>\n+ </HrBreadcrumb>\n+ )\n+}\n+\n+export default AppointmentBreacrumb\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/components/breadcrumb/Breadcrumb.tsx",
"diff": "+import React from 'react'\n+import { Switch, Route } from 'react-router'\n+import DefaultBreadcrumb from 'components/breadcrumb/DefaultBreadcrumb'\n+import PatientBreadcrumb from 'components/breadcrumb/PatientBreadcrumb'\n+import AppointmentBreadcrumb from 'components/breadcrumb/AppointmentBreadcrumb'\n+\n+const Breadcrumb = () => (\n+ <Switch>\n+ <Route exact path={['/patients/new', '/appointments/new']} component={DefaultBreadcrumb} />\n+ <Route path=\"/patients/:id\" component={PatientBreadcrumb} />\n+ <Route path=\"/appointments/:id\" component={AppointmentBreadcrumb} />\n+ <Route path=\"*\" component={DefaultBreadcrumb} />\n+ </Switch>\n+)\n+\n+export default Breadcrumb\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/components/breadcrumb/DefaultBreadcrumb.tsx",
"diff": "+import React from 'react'\n+import { useLocation, useHistory } from 'react-router'\n+import { useTranslation } from 'react-i18next'\n+import {\n+ Breadcrumb as HrBreadcrumb,\n+ BreadcrumbItem as HrBreadcrumbItem,\n+} from '@hospitalrun/components'\n+\n+interface Item {\n+ url: string\n+ active: boolean\n+}\n+\n+const urlToi18nKey: { [url: string]: string } = {\n+ '/': 'dashboard.label',\n+ '/patients': 'patients.label',\n+ '/patients/new': 'patients.newPatient',\n+ '/appointments': 'scheduling.appointments.label',\n+ '/appointments/new': 'scheduling.appointments.new',\n+}\n+\n+export function getItems(pathname: string): Item[] {\n+ let url = ''\n+ const paths = pathname.substring(1).split('/')\n+\n+ return paths.map((path, index) => {\n+ url += `/${path}`\n+ return { url, active: index === paths.length - 1 }\n+ })\n+}\n+\n+const DefaultBreadcrumb = () => {\n+ const { t } = useTranslation()\n+ const { pathname } = useLocation()\n+ const history = useHistory()\n+ const items = getItems(pathname)\n+\n+ return (\n+ <HrBreadcrumb>\n+ {items.map((item) => {\n+ const onClick = !item.active ? () => history.push(item.url) : undefined\n+\n+ return (\n+ <HrBreadcrumbItem key={item.url} active={item.active} onClick={onClick}>\n+ {t(urlToi18nKey[item.url])}\n+ </HrBreadcrumbItem>\n+ )\n+ })}\n+ </HrBreadcrumb>\n+ )\n+}\n+\n+export default DefaultBreadcrumb\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/components/breadcrumb/PatientBreadcrumb.tsx",
"diff": "+import React from 'react'\n+import { useHistory } from 'react-router'\n+import { useSelector } from 'react-redux'\n+import { useTranslation } from 'react-i18next'\n+import {\n+ Breadcrumb as HrBreadcrumb,\n+ BreadcrumbItem as HrBreadcrumbItem,\n+} from '@hospitalrun/components'\n+import { getPatientFullName } from 'patients/util/patient-name-util'\n+import { RootState } from '../../store'\n+\n+const PatientBreacrumb = () => {\n+ const { t } = useTranslation()\n+ const { patient } = useSelector((state: RootState) => state.patient)\n+ const history = useHistory()\n+\n+ return (\n+ <HrBreadcrumb>\n+ <HrBreadcrumbItem onClick={() => history.push('/patients')}>\n+ {t('patients.label')}\n+ </HrBreadcrumbItem>\n+ <HrBreadcrumbItem active>{getPatientFullName(patient)}</HrBreadcrumbItem>\n+ </HrBreadcrumb>\n+ )\n+}\n+\n+export default PatientBreacrumb\n"
},
{
"change_type": "MODIFY",
"old_path": "src/index.css",
"new_path": "src/index.css",
"diff": "@@ -94,9 +94,4 @@ code {\nposition: relative;\npadding: .2rem 1rem;\nbackground-color: white;\n- border-bottom: .1rem solid lightgray;\n-}\n-\n-.breadcrumb-item > span, .breadcrumb-item > a {\n- text-transform: capitalize;\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(breadcrumb): customize breadcrumbs for patients and appointments
fix #1770 |
288,337 | 09.02.2020 20:12:18 | -3,600 | 63517e8a2a309788f9147107553d8bf1a26b601f | feat(breadcrumb): add a patient to the store in HispitalRun.tests.tsx
fix | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/HospitalRun.test.tsx",
"new_path": "src/__tests__/HospitalRun.test.tsx",
"diff": "@@ -96,6 +96,7 @@ describe('HospitalRun', () => {\nstore={mockStore({\ntitle: 'test',\nuser: { permissions: [Permissions.WritePatients] },\n+ patient: { patient: {} },\n})}\n>\n<MemoryRouter initialEntries={['/patients/edit/123']}>\n@@ -113,6 +114,7 @@ describe('HospitalRun', () => {\nstore={mockStore({\ntitle: 'test',\nuser: { permissions: [Permissions.ReadPatients] },\n+ patient: { patient: {} },\n})}\n>\n<MemoryRouter initialEntries={['/patients/edit/123']}>\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(breadcrumb): add a patient to the store in HispitalRun.tests.tsx
fix #1770 |
288,323 | 09.02.2020 22:58:06 | 21,600 | 7f0fe7fa47d0705d585f7ca15d4796e1c90c2f16 | feat(env): adds hospitalrun server information | [
{
"change_type": "ADD",
"old_path": null,
"new_path": ".env.example",
"diff": "+REACT_APP_HOSPITALRUN_SERVER=http://0.0.0.0:3001\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -27,6 +27,15 @@ Contributions are always welcome. Before contributing please read our [contribut\n3. Install the dependencies: `yarn`\n4. Run `yarn run start` to build and watch for code changes\n+## Connecting to HospitalRun Server\n+\n+__Note: The following instructions are for connecting to HospitalRun Server during development and are not intended to be for production use. For production deployments, see the deployment instructions.__\n+\n+1. Configure [HospitalRun Server](https://github.com/HospitalRun/hospitalrun-server)\n+2. Start the HospitalRun Development Server\n+3. Copy the `.env.example` file to `.env.local` or `.env`\n+4. Change the `REACT_APP_HOSPITALRUN_SERVER` variable to point to the HospitalRun Development Server.\n+\n## Working on an Issue\nIn order to optimize the workflow and to prevent multiple contributors working on the same issue without interactions, a contributor must ask to be assigned to an issue by one of the core team members: it's enough to ask it inside the specific issue.\n"
},
{
"change_type": "MODIFY",
"old_path": "src/config/pouchdb.ts",
"new_path": "src/config/pouchdb.ts",
"diff": "@@ -16,15 +16,12 @@ function createDb(name: string) {\n}\nconst db = new PouchDB(name)\n- // db.sync(\n- // `https://a27fa3db-db4d-4456-8465-da953aee0f5b-bluemix:cd6f332d39f24d2b7cfc89d82f6836d46012ef3188698319b0d5fff177cb2ddc@a27fa3db-db4d-4456-8465-da953aee0f5b-bluemix.cloudantnosqldb.appdomain.cloud/${name}`,\n- // {\n- // live: true,\n- // retry: true,\n- // },\n- // ).on('change', (info) => {\n- // console.log(info)\n- // })\n+ db.sync(`${process.env.REAC_APP_HOSPITALRUN_SERVER}/_db/${name}`, {\n+ live: true,\n+ retry: true,\n+ }).on('change', (info) => {\n+ console.log(info)\n+ })\nreturn db\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(env): adds hospitalrun server information |
288,328 | 11.02.2020 19:38:58 | 21,600 | 7cbc1576fd5f1d5d983cf243c2c785f7e237144a | test(tests): stopped mocking Date() due to timezone issues | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/GeneralInformation.test.tsx",
"new_path": "src/__tests__/patients/GeneralInformation.test.tsx",
"diff": "@@ -4,6 +4,7 @@ import { Router } from 'react-router'\nimport { mount, ReactWrapper } from 'enzyme'\nimport GeneralInformation from 'patients/GeneralInformation'\nimport { createMemoryHistory } from 'history'\n+import { startOfDay, subYears } from 'date-fns'\nimport { Alert } from '@hospitalrun/components'\nimport { act } from '@testing-library/react'\nimport Patient from '../../model/Patient'\n@@ -42,7 +43,7 @@ describe('General Information, without isEditable', () => {\nemail: '[email protected]',\naddress: 'address',\nfriendlyId: 'P00001',\n- dateOfBirth: '1957-06-14T05:00:00.000Z',\n+ dateOfBirth: startOfDay(subYears(new Date(), 30)).toISOString(),\nisApproximateDateOfBirth: false,\n} as Patient\n@@ -162,10 +163,7 @@ describe('General Information, without isEditable', () => {\nexpect(addressInput.prop('isEditable')).toBeFalsy()\n})\n- it('should render the age and date of birth as approximate if patient.isApproximateDateOfBirth is true', async () => {\n- jest\n- .spyOn(global.Date, 'now')\n- .mockImplementation(() => new Date('1987-06-14T05:00:00.000Z').valueOf())\n+ it('should render the approximate age if patient.isApproximateDateOfBirth is true', async () => {\npatient.isApproximateDateOfBirth = true\nawait act(async () => {\nwrapper = await mount(\n@@ -178,6 +176,7 @@ describe('General Information, without isEditable', () => {\nwrapper.update()\nconst ageInput = wrapper.findWhere((w: any) => w.prop('name') === 'approximateAge')\n+\nexpect(ageInput.prop('value')).toEqual('30')\nexpect(ageInput.prop('label')).toEqual('patient.approximateAge')\nexpect(ageInput.prop('isEditable')).toBeFalsy()\n@@ -199,7 +198,7 @@ describe('General Information, isEditable', () => {\nemail: '[email protected]',\naddress: 'address',\nfriendlyId: 'P00001',\n- dateOfBirth: '1957-06-14T05:00:00.000Z',\n+ dateOfBirth: startOfDay(subYears(new Date(), 30)).toISOString(),\nisApproximateDateOfBirth: false,\n} as Patient\n@@ -449,11 +448,7 @@ describe('General Information, isEditable', () => {\n)\n})\n- it('should render the age and date of birth as approximate if patient.isApproximateDateOfBirth is true', async () => {\n- jest\n- .spyOn(global.Date, 'now')\n- .mockImplementation(() => new Date('1987-06-14T05:00:00.000Z').valueOf())\n-\n+ it('should render the approximate age if patient.isApproximateDateOfBirth is true', async () => {\npatient.isApproximateDateOfBirth = true\nawait act(async () => {\nwrapper = await mount(\n@@ -465,9 +460,6 @@ describe('General Information, isEditable', () => {\nwrapper.update()\n- // original patient born in '57, Date.now() mocked to '87, so value should be initially\n- // set to 30 years. when user changes to 20 years, onFieldChange should be called to\n- // set dateOfBirth to '67.\nconst approximateAgeInput = wrapper.findWhere((w: any) => w.prop('name') === 'approximateAge')\nconst generalInformation = wrapper.find(GeneralInformation)\nexpect(approximateAgeInput.prop('value')).toEqual('30')\n@@ -480,7 +472,7 @@ describe('General Information, isEditable', () => {\nexpect(generalInformation.prop('onFieldChange')).toHaveBeenCalledWith(\n'dateOfBirth',\n- '1967-06-14T05:00:00.000Z',\n+ startOfDay(subYears(new Date(Date.now()), 20)).toISOString(),\n)\n})\n})\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | test(tests): stopped mocking Date() due to timezone issues |
288,323 | 11.02.2020 20:56:27 | 21,600 | cddc812ae5bd1f1b05e7310b5a504b51ecee1981 | feat(env): change env variable names | [
{
"change_type": "MODIFY",
"old_path": ".env.example",
"new_path": ".env.example",
"diff": "-REACT_APP_HOSPITALRUN_SERVER=http://0.0.0.0:3001\n\\ No newline at end of file\n+REACT_APP_HOSPITALRUN_API=http://0.0.0.0:3001\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -33,8 +33,8 @@ __Note: The following instructions are for connecting to HospitalRun Server duri\n1. Configure [HospitalRun Server](https://github.com/HospitalRun/hospitalrun-server)\n2. Start the HospitalRun Development Server\n-3. Copy the `.env.example` file to `.env.local` or `.env`\n-4. Change the `REACT_APP_HOSPITALRUN_SERVER` variable to point to the HospitalRun Development Server.\n+3. Copy the `.env.example` file to `.env`\n+4. Change the `REACT_APP_HOSPITALRUN_API` variable to point to the HospitalRun Development Server.\n## Working on an Issue\n"
},
{
"change_type": "MODIFY",
"old_path": "src/config/pouchdb.ts",
"new_path": "src/config/pouchdb.ts",
"diff": "@@ -16,7 +16,7 @@ function createDb(name: string) {\n}\nconst db = new PouchDB(name)\n- db.sync(`${process.env.REAC_APP_HOSPITALRUN_SERVER}/_db/${name}`, {\n+ db.sync(`${process.env.REACT_APP_HOSPITALRUN_API}/_db/${name}`, {\nlive: true,\nretry: true,\n}).on('change', (info) => {\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(env): change env variable names |
288,337 | 12.02.2020 20:22:46 | -3,600 | a6eaf2a9547875a4a0947f4e9a7e21e41add11c8 | feat(breadcrumb): display the breadcrumb in the appointment components
fix | [
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/Appointments.tsx",
"new_path": "src/scheduling/appointments/Appointments.tsx",
"diff": "@@ -6,6 +6,7 @@ import { useSelector, useDispatch } from 'react-redux'\nimport { RootState } from 'store'\nimport { useHistory } from 'react-router'\nimport PatientRepository from 'clients/db/PatientRepository'\n+import useSetBreadcrumbs from 'breadcrumbs/useSetBreadcrumbs'\nimport { fetchAppointments } from './appointments-slice'\ninterface Event {\n@@ -16,10 +17,13 @@ interface Event {\nallDay: boolean\n}\n+const breadcrumbs = [{ i18nKey: 'scheduling.appointments.label', location: '/patients' }]\n+\nconst Appointments = () => {\nconst { t } = useTranslation()\nconst history = useHistory()\nuseTitle(t('scheduling.appointments.label'))\n+ useSetBreadcrumbs(breadcrumbs)\nconst dispatch = useDispatch()\nconst { appointments } = useSelector((state: RootState) => state.appointments)\nconst [events, setEvents] = useState<Event[]>([])\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/new/NewAppointment.tsx",
"new_path": "src/scheduling/appointments/new/NewAppointment.tsx",
"diff": "import React, { useState } from 'react'\nimport useTitle from 'page-header/useTitle'\nimport { useTranslation } from 'react-i18next'\n-\nimport roundToNearestMinutes from 'date-fns/roundToNearestMinutes'\nimport { useHistory } from 'react-router'\nimport { useDispatch } from 'react-redux'\n@@ -9,14 +8,21 @@ import Appointment from 'model/Appointment'\nimport addMinutes from 'date-fns/addMinutes'\nimport { isBefore } from 'date-fns'\nimport { Button, Alert } from '@hospitalrun/components'\n+import useSetBreadcrumbs from '../../../breadcrumbs/useSetBreadcrumbs'\nimport { createAppointment } from '../appointments-slice'\nimport AppointmentDetailForm from '../AppointmentDetailForm'\n+const breadcrumbs = [\n+ { i18nKey: 'scheduling.appointments.label', location: '/appointments' },\n+ { i18nKey: 'scheduling.appointments.new', location: '/appointments/new' },\n+]\n+\nconst NewAppointment = () => {\nconst { t } = useTranslation()\nconst history = useHistory()\nconst dispatch = useDispatch()\nuseTitle(t('scheduling.appointments.new'))\n+ useSetBreadcrumbs(breadcrumbs)\nconst startDateTime = roundToNearestMinutes(new Date(), { nearestTo: 15 })\nconst endDateTime = addMinutes(startDateTime, 60)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/view/ViewAppointment.tsx",
"new_path": "src/scheduling/appointments/view/ViewAppointment.tsx",
"diff": "-import React, { useEffect } from 'react'\n+import React, { useEffect, useMemo } from 'react'\nimport useTitle from 'page-header/useTitle'\nimport { useSelector, useDispatch } from 'react-redux'\nimport { RootState } from 'store'\nimport { useParams } from 'react-router'\nimport { Spinner } from '@hospitalrun/components'\nimport { useTranslation } from 'react-i18next'\n+import Appointment from 'model/Appointment'\nimport { fetchAppointment } from '../appointment-slice'\nimport AppointmentDetailForm from '../AppointmentDetailForm'\n+import useSetBreadcrumbs from '../../../breadcrumbs/useSetBreadcrumbs'\n+\n+function getAppointmentLabel(appointment: Appointment) {\n+ const { id, startDateTime, endDateTime } = appointment\n+\n+ return startDateTime && endDateTime\n+ ? `${new Date(startDateTime).toLocaleString()} - ${new Date(endDateTime).toLocaleString()}`\n+ : id\n+}\nconst ViewAppointment = () => {\nconst { t } = useTranslation()\n@@ -15,6 +25,15 @@ const ViewAppointment = () => {\nconst { id } = useParams()\nconst { appointment, patient, isLoading } = useSelector((state: RootState) => state.appointment)\n+ const breadcrumbs = useMemo(\n+ () => [\n+ { i18nKey: 'scheduling.appointments.label', location: '/appointments' },\n+ { text: getAppointmentLabel(appointment), location: `/patients/${appointment.id}` },\n+ ],\n+ [appointment],\n+ )\n+ useSetBreadcrumbs(breadcrumbs)\n+\nuseEffect(() => {\nif (id) {\ndispatch(fetchAppointment(id))\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(breadcrumb): display the breadcrumb in the appointment components
fix #1770 |
288,337 | 12.02.2020 20:30:46 | -3,600 | 9bdbb343f3b1a524344b44dd19a85afcff4a36b3 | docs(readme): improve 'How to commit' section | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -33,7 +33,7 @@ In order to optimize the workflow and to prevent multiple contributors working o\n## How to commit\n-This repo uses Conventional Commits. Commitizen is mandatory for making proper commits. Once you have staged your changes, can run npm run commit or yarn commit from the root directory in order to commit following our standards.\n+This repo uses Conventional Commits. Commitizen is mandatory for making proper commits. Once you have staged your changes, can run `npm run commit` or `yarn commit` from the root directory in order to commit following our standards.\n<hr />\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | docs(readme): improve 'How to commit' section |
288,230 | 12.02.2020 14:35:07 | 21,600 | d20e294340a155cb90138ea9bf5210e6e697ea71 | fix(patient-slice.ts): conditionally render family name and suffix
fix | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/patient-slice.test.ts",
"new_path": "src/__tests__/patients/patient-slice.test.ts",
"diff": "@@ -310,5 +310,29 @@ describe('patients slice', () => {\n`Successfully updated patient ${expectedGivenName} ${expectedFamilyName} ${expectedSuffix}`,\n)\n})\n+\n+ it('should call the Toaster with message only including given name', async () => {\n+ jest.spyOn(components, 'Toast')\n+ const expectedPatientId = '12345'\n+ const expectedGivenName = 'John'\n+ const expectedPatient = {\n+ id: expectedPatientId,\n+ givenName: expectedGivenName,\n+ } as Patient\n+ const mockedPatientRepository = mocked(PatientRepository, true)\n+ mockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedPatient)\n+ const mockedComponents = mocked(components, true)\n+ const history = createMemoryHistory()\n+ const dispatch = jest.fn()\n+ const getState = jest.fn()\n+\n+ await updatePatient(expectedPatient, history)(dispatch, getState, null)\n+\n+ expect(mockedComponents.Toast).toHaveBeenCalledWith(\n+ 'success',\n+ 'Success!',\n+ `Successfully updated patient ${expectedGivenName}`,\n+ )\n+ })\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/patient-slice.ts",
"new_path": "src/patients/patient-slice.ts",
"diff": "@@ -67,9 +67,9 @@ export const createPatient = (patient: Patient, history: any): AppThunk => async\nToast(\n'success',\nil8n.t('Success!'),\n- `${il8n.t('patients.successfullyCreated')} ${patient.givenName} ${patient.familyName} ${\n- patient.suffix\n- }`,\n+ `${il8n.t('patients.successfullyCreated')} ${patient.givenName} ${\n+ patient.familyName ? patient.familyName : ''\n+ } ${patient.suffix ? patient.suffix : ''}`.trimEnd(),\n)\n}\n@@ -81,9 +81,9 @@ export const updatePatient = (patient: Patient, history: any): AppThunk => async\nToast(\n'success',\nil8n.t('Success!'),\n- `${il8n.t('patients.successfullyUpdated')} ${patient.givenName} ${patient.familyName} ${\n- patient.suffix\n- }`,\n+ `${il8n.t('patients.successfullyUpdated')} ${patient.givenName} ${\n+ patient.familyName ? patient.familyName : ''\n+ } ${patient.suffix ? patient.suffix : ''}`.trimEnd(),\n)\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(patient-slice.ts): conditionally render family name and suffix
fix #1818 |
288,230 | 13.02.2020 09:21:15 | 21,600 | b82c180a6f94c6e07528111b5634ed4c746c55ec | refactor: addressing comment: use patient.fullName | [
{
"change_type": "MODIFY",
"old_path": "src/patients/patient-slice.ts",
"new_path": "src/patients/patient-slice.ts",
"diff": "@@ -67,9 +67,7 @@ export const createPatient = (patient: Patient, history: any): AppThunk => async\nToast(\n'success',\nil8n.t('Success!'),\n- `${il8n.t('patients.successfullyCreated')} ${patient.givenName} ${\n- patient.familyName ? patient.familyName : ''\n- } ${patient.suffix ? patient.suffix : ''}`.trimEnd(),\n+ `${il8n.t('patients.successfullyCreated')} ${patient.fullName}`,\n)\n}\n@@ -81,9 +79,7 @@ export const updatePatient = (patient: Patient, history: any): AppThunk => async\nToast(\n'success',\nil8n.t('Success!'),\n- `${il8n.t('patients.successfullyUpdated')} ${patient.givenName} ${\n- patient.familyName ? patient.familyName : ''\n- } ${patient.suffix ? patient.suffix : ''}`.trimEnd(),\n+ `${il8n.t('patients.successfullyUpdated')} ${patient.fullName}`,\n)\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | refactor: addressing comment: use patient.fullName |
288,230 | 13.02.2020 10:02:07 | 21,600 | 3bdd62d3361626c7b949b209986ce717791e3d4f | refactor patient-slice tests for Toast message | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/patient-slice.test.ts",
"new_path": "src/__tests__/patients/patient-slice.test.ts",
"diff": "@@ -161,14 +161,10 @@ describe('patients slice', () => {\nit('should call the Toaster function with the correct data', async () => {\njest.spyOn(components, 'Toast')\nconst expectedPatientId = '12345'\n- const expectedGivenName = 'given'\n- const expectedFamilyName = 'family'\n- const expectedSuffix = 'suffix'\n+ const expectedFullName = 'John Doe II'\nconst expectedPatient = {\nid: expectedPatientId,\n- givenName: expectedGivenName,\n- familyName: expectedFamilyName,\n- suffix: expectedSuffix,\n+ fullName: expectedFullName,\n} as Patient\nconst mockedPatientRepository = mocked(PatientRepository, true)\nmockedPatientRepository.save.mockResolvedValue(expectedPatient)\n@@ -182,7 +178,7 @@ describe('patients slice', () => {\nexpect(mockedComponents.Toast).toHaveBeenCalledWith(\n'success',\n'Success!',\n- `patients.successfullyCreated ${expectedGivenName} ${expectedFamilyName} ${expectedSuffix}`,\n+ `patients.successfullyCreated ${expectedFullName}`,\n)\n})\n})\n@@ -286,14 +282,10 @@ describe('patients slice', () => {\nit('should call the Toaster function with the correct data', async () => {\njest.spyOn(components, 'Toast')\nconst expectedPatientId = '12345'\n- const expectedGivenName = 'given'\n- const expectedFamilyName = 'family'\n- const expectedSuffix = 'suffix'\n+ const fullName = 'John Doe II'\nconst expectedPatient = {\nid: expectedPatientId,\n- givenName: expectedGivenName,\n- familyName: expectedFamilyName,\n- suffix: expectedSuffix,\n+ fullName,\n} as Patient\nconst mockedPatientRepository = mocked(PatientRepository, true)\nmockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedPatient)\n@@ -307,31 +299,7 @@ describe('patients slice', () => {\nexpect(mockedComponents.Toast).toHaveBeenCalledWith(\n'success',\n'Success!',\n- `patients.successfullyUpdated ${expectedGivenName} ${expectedFamilyName} ${expectedSuffix}`,\n- )\n- })\n-\n- it('should call the Toaster with message only including given name', async () => {\n- jest.spyOn(components, 'Toast')\n- const expectedPatientId = '12345'\n- const expectedGivenName = 'John'\n- const expectedPatient = {\n- id: expectedPatientId,\n- givenName: expectedGivenName,\n- } as Patient\n- const mockedPatientRepository = mocked(PatientRepository, true)\n- mockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedPatient)\n- const mockedComponents = mocked(components, true)\n- const history = createMemoryHistory()\n- const dispatch = jest.fn()\n- const getState = jest.fn()\n-\n- await updatePatient(expectedPatient, history)(dispatch, getState, null)\n-\n- expect(mockedComponents.Toast).toHaveBeenCalledWith(\n- 'success',\n- 'Success!',\n- `Successfully updated patient ${expectedGivenName}`,\n+ `patients.successfullyUpdated ${fullName}`,\n)\n})\n})\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | refactor patient-slice tests for Toast message |
288,230 | 13.02.2020 17:39:10 | 21,600 | deee00e52f2bab2fec8518d4e8cdfa6f67c2cf75 | feat(appointmentslist): add an appointments tab to the patient view
add an appointments tab to the patient view which shows appointments list for corresponding patient.
Uses same layout as patient list view and also implements fuzzy search | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"private\": false,\n\"license\": \"MIT\",\n\"dependencies\": {\n- \"@hospitalrun/components\": \"^0.33.0\",\n+ \"@hospitalrun/components\": \"^0.33.1\",\n\"@reduxjs/toolkit\": \"~1.2.1\",\n\"@types/pouchdb-find\": \"~6.3.4\",\n\"bootstrap\": \"~4.4.1\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/view/ViewPatient.test.tsx",
"new_path": "src/__tests__/patients/view/ViewPatient.test.tsx",
"diff": "@@ -79,7 +79,7 @@ describe('ViewPatient', () => {\nwrapper.update()\n- const editButton = wrapper.find(Button).at(2)\n+ const editButton = wrapper.find(Button).at(3)\nconst onClick = editButton.prop('onClick') as any\nexpect(editButton.text().trim()).toEqual('actions.edit')\n@@ -120,9 +120,10 @@ describe('ViewPatient', () => {\nconst tabs = tabsHeader.find(Tab)\nexpect(tabsHeader).toHaveLength(1)\n- expect(tabs).toHaveLength(2)\n+ expect(tabs).toHaveLength(3)\nexpect(tabs.at(0).prop('label')).toEqual('patient.generalInformation')\nexpect(tabs.at(1).prop('label')).toEqual('patient.relatedPersons.label')\n+ expect(tabs.at(2).prop('label')).toEqual('scheduling.appointments.label')\n})\nit('should mark the general information tab as active and render the general information component when route is /patients/:id', async () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/clients/db/AppointmentsRepository.ts",
"new_path": "src/clients/db/AppointmentsRepository.ts",
"diff": "@@ -6,6 +6,38 @@ export class AppointmentRepository extends Repository<Appointment> {\nconstructor() {\nsuper(appointments)\n}\n+\n+ // Fuzzy search for patient appointments. Used for patient appointment search bar\n+ async searchPatientAppointments(patientId: string, text: string): Promise<Appointment[]> {\n+ return super.search({\n+ selector: {\n+ $and: [\n+ {\n+ patientId,\n+ },\n+ {\n+ $or: [\n+ {\n+ location: {\n+ $regex: RegExp(text, 'i'),\n+ },\n+ },\n+ {\n+ reason: {\n+ $regex: RegExp(text, 'i'),\n+ },\n+ },\n+ {\n+ type: {\n+ $regex: RegExp(text, 'i'),\n+ },\n+ },\n+ ],\n+ },\n+ ],\n+ },\n+ })\n+ }\n}\nexport default new AppointmentRepository()\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/appointments/AppointmentsList.tsx",
"diff": "+import React, { useEffect, useState } from 'react'\n+import { useSelector, useDispatch } from 'react-redux'\n+import { useHistory } from 'react-router'\n+import { useTranslation } from 'react-i18next'\n+import { TextInput, Button, List, ListItem, Container, Row } from '@hospitalrun/components'\n+import { RootState } from '../../store'\n+import { fetchPatientAppointments } from '../../scheduling/appointments/appointments-slice'\n+\n+interface Props {\n+ patientId: string\n+}\n+\n+const AppointmentsList = (props: Props) => {\n+ const dispatch = useDispatch()\n+ const history = useHistory()\n+ const { t } = useTranslation()\n+\n+ const { patientId } = props\n+ const { appointments } = useSelector((state: RootState) => state.appointments)\n+ const [searchText, setSearchText] = useState<string>('')\n+\n+ useEffect(() => {\n+ dispatch(fetchPatientAppointments(patientId))\n+ }, [dispatch, patientId])\n+\n+ const list = (\n+ // inline style added to pick up on newlines for string literal\n+ <ul style={{ whiteSpace: 'pre-line' }}>\n+ {appointments.map((a) => (\n+ <ListItem action key={a.id} onClick={() => history.push(`/appointments/${a.id}`)}>\n+ {`${t('scheduling.appointment.location')}: ${a.location}\n+ ${t('scheduling.appointment.reason')}: ${a.reason}\n+ ${t('scheduling.appointment.type')}: ${a.type}\n+ ${t('scheduling.appointment.startDate')}: ${new Date(a.startDateTime).toLocaleString()}\n+ ${t('scheduling.appointment.endDate')}: ${new Date(a.endDateTime).toLocaleString()}`}\n+ </ListItem>\n+ ))}\n+ </ul>\n+ )\n+\n+ const onSearchBoxChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n+ setSearchText(event.target.value)\n+ }\n+\n+ const onSearchFormSubmit = (event: React.FormEvent | React.MouseEvent) => {\n+ event.preventDefault()\n+ dispatch(fetchPatientAppointments(patientId, searchText))\n+ }\n+\n+ return (\n+ <Container>\n+ <form className=\"form-inline\" onSubmit={onSearchFormSubmit}>\n+ <div className=\"input-group\" style={{ width: '100%' }}>\n+ <TextInput\n+ size=\"lg\"\n+ value={searchText}\n+ placeholder={t('actions.search')}\n+ onChange={onSearchBoxChange}\n+ />\n+ <div className=\"input-group-append\">\n+ <Button onClick={onSearchFormSubmit}>{t('actions.search')}</Button>\n+ </div>\n+ </div>\n+ </form>\n+\n+ <Row>\n+ <List layout=\"flush\" style={{ width: '100%', marginTop: '10px', marginLeft: '-25px' }}>\n+ {list}\n+ </List>\n+ </Row>\n+ </Container>\n+ )\n+}\n+\n+export default AppointmentsList\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/view/ViewPatient.tsx",
"new_path": "src/patients/view/ViewPatient.tsx",
"diff": "@@ -11,6 +11,7 @@ import { getPatientFullName } from '../util/patient-name-util'\nimport Patient from '../../model/Patient'\nimport GeneralInformation from '../GeneralInformation'\nimport RelatedPerson from '../related-persons/RelatedPersonTab'\n+import AppointmentsList from '../appointments/AppointmentsList'\nconst getFriendlyId = (p: Patient): string => {\nif (p) {\n@@ -54,6 +55,11 @@ const ViewPatient = () => {\nlabel={t('patient.relatedPersons.label')}\nonClick={() => history.push(`/patients/${patient.id}/relatedpersons`)}\n/>\n+ <Tab\n+ active={location.pathname === `/patients/${patient.id}/appointments`}\n+ label={t('scheduling.appointments.label')}\n+ onClick={() => history.push(`/patients/${patient.id}/appointments`)}\n+ />\n</TabsHeader>\n<Panel>\n<Route exact path=\"/patients/:id\">\n@@ -76,6 +82,9 @@ const ViewPatient = () => {\n<Route exact path=\"/patients/:id/relatedpersons\">\n<RelatedPerson patient={patient} />\n</Route>\n+ <Route exact path=\"/patients/:id/appointments\">\n+ <AppointmentsList patientId={patient.id} />\n+ </Route>\n</Panel>\n</div>\n)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/appointments-slice.ts",
"new_path": "src/scheduling/appointments/appointments-slice.ts",
"diff": "@@ -42,6 +42,23 @@ export const fetchAppointments = (): AppThunk => async (dispatch) => {\ndispatch(fetchAppointmentsSuccess(appointments))\n}\n+export const fetchPatientAppointments = (\n+ patientId: string,\n+ searchString?: string,\n+): AppThunk => async (dispatch) => {\n+ dispatch(fetchAppointmentsStart())\n+\n+ let appointments\n+ if (searchString === undefined || searchString.trim() === '') {\n+ const query = { selector: { patientId } }\n+ appointments = await AppointmentRepository.search(query)\n+ } else {\n+ appointments = await AppointmentRepository.searchPatientAppointments(patientId, searchString)\n+ }\n+\n+ dispatch(fetchAppointmentsSuccess(appointments))\n+}\n+\nexport const createAppointment = (appointment: Appointment, history: any): AppThunk => async (\ndispatch,\n) => {\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(appointmentslist): add an appointments tab to the patient view
add an appointments tab to the patient view which shows appointments list for corresponding patient.
Uses same layout as patient list view and also implements fuzzy search
#1769 |
288,334 | 14.02.2020 18:32:00 | -3,600 | 72c24f9756faaa223656e51c23f75c72fcd47656 | build(docker): improves dockerfile and updates dockerignore | [
{
"change_type": "MODIFY",
"old_path": ".dockerignore",
"new_path": ".dockerignore",
"diff": "-node_modules\n+# Items that don't need to be in a Docker image.\n+# Anything not used by the build system should go here.\n+.gitignore\n+*.md\n+*.yml\n+.git\n+*.js\n+azure\n+.editorconfig\n+.github\n+.npmrc\n+.nvmrc\n+.prettierrc\n+.replit\n+.vscode\n+LICENSE\n+docs\n+*.log\n+.env*\n"
},
{
"change_type": "MODIFY",
"old_path": ".travis.yml",
"new_path": ".travis.yml",
"diff": "language: node_js\nnode_js:\n- - \"lts/*\"\n+ - 'lts/*'\nbranches:\nonly:\n"
},
{
"change_type": "MODIFY",
"old_path": "Dockerfile",
"new_path": "Dockerfile",
"diff": "-FROM node:10-alpine as build\n-LABEL maintainer=\"Michael Feher, Matteo Vivona, Maksim Sinik\"\n+FROM node:12-alpine as build\n-# set app basepath\nENV HOME=/home/app\n-\n-# copy all app files\nCOPY . $HOME/node/\n-# change workgin dir and install deps in quiet mode\nWORKDIR $HOME/node\nRUN npm ci -q\n-# compile typescript and build all production stuff\nRUN npm run build\n-\n-# remove dev dependencies that are not needed in production\nRUN npm prune --production\n-# start new image for lower size\n-FROM node:10-alpine\n-\n-# create use with no permissions\n-RUN addgroup -g 101 -S app && adduser -u 100 -S -G app -s /bin/false app\n-\n-# set app basepath\n-ENV HOME=/home/app\n-\n-# copy production complied node app to the new image\n-COPY --from=build $HOME/node/ $HOME/node/\n-RUN chown -R app:app $HOME/*\n-\n-# run app with low permissions level user\n-USER app\n-WORKDIR $HOME/node\n-\n-EXPOSE 3000\n-\n-ENV NODE_ENV=production\n+FROM nginx:stable-alpine\n-CMD [ \"yarn\", \"start\" ]\n+COPY --from=build /home/app/node/build/ /usr/share/nginx/html\n+COPY nginx.conf /etc/nginx/conf.d/default.conf\n+EXPOSE 80\n+CMD [\"nginx\", \"-g\", \"daemon off;\"]\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "nginx.conf",
"diff": "+server {\n+ listen 80;\n+ server_name localhost;\n+ location / {\n+ root /usr/share/nginx/html;\n+ index index.html index.htm;\n+ try_files $uri /index.html;\n+ }\n+\n+ error_page 500 502 503 504 /50x.html;\n+\n+ location = /50x.html {\n+ root /usr/share/nginx/html;\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"commit\": \"npx git-cz\",\n\"start\": \"react-scripts start\",\n\"build\": \"react-scripts build\",\n- \"start:serve\": \"npm run build && serve -s build\",\n\"prepublishOnly\": \"npm run build\",\n\"test\": \"react-scripts test --detectOpenHandles\",\n\"test:ci\": \"cross-env CI=true react-scripts test\",\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | build(docker): improves dockerfile and updates dockerignore |
288,334 | 15.02.2020 11:04:55 | -3,600 | d7906d4a4fd710e51b4ec3833bf1010b77ac166c | ci(build): removes azure pipeline and updates github ci | [
{
"change_type": "MODIFY",
"old_path": ".github/workflows/ci.yml",
"new_path": ".github/workflows/ci.yml",
"diff": "@@ -9,16 +9,17 @@ jobs:\nstrategy:\nmatrix:\nnode-version: [12.x, 13.x]\n- os: [ubuntu-18.04]\n+ os: [ubuntu-latest, windows-latest, macOS-latest]\n+ exclude:\n+ - os: windows-latest\n+ node-version: 13.x\nsteps:\n- uses: actions/checkout@v1\n-\n- name: Use Node.js\nuses: actions/setup-node@v1\nwith:\nnode-version: ${{ matrix.node-version }}\n-\n- name: Install with npm\nrun: |\nnpm install\n@@ -31,22 +32,24 @@ jobs:\n- name: Run tests\nrun: |\nnpm run test:ci\n+ # - name: Coveralls Parallel\n+ # uses: coverallsapp/github-action@master\n+ # with:\n+ # github-token: ${{ secrets.GH_TOKEN }}\n+ # parallel: true\n+\nyarn:\nruns-on: ${{ matrix.os }}\n-\nstrategy:\nmatrix:\nnode-version: [12.x, 13.x]\nos: [ubuntu-18.04]\n-\nsteps:\n- uses: actions/checkout@v1\n-\n- name: Use Node.js\nuses: actions/setup-node@v1\nwith:\nnode-version: ${{ matrix.node-version }}\n-\n- name: Install with yarn\nrun: |\ncurl -o- -L https://yarnpkg.com/install.sh | bash\n@@ -60,3 +63,12 @@ jobs:\n- name: Run tests\nrun: |\nyarn test:ci\n+ # coverage:\n+ # needs: test\n+ # runs-on: ubuntu-latest\n+ # steps:\n+ # - name: Coveralls Finished\n+ # uses: coverallsapp/github-action@master\n+ # with:\n+ # github-token: ${{ secrets.GH_TOKEN }}\n+ # parallel-finished: true\n"
},
{
"change_type": "DELETE",
"old_path": "azure-pipeline.yml",
"new_path": null,
"diff": "-trigger:\n- branches:\n- include:\n- - master\n-\n-jobs:\n- - template: azure/azure-pipelines-npm.yml\n- parameters:\n- name: Windows_npm\n- vmImage: vs2017-win2016\n- - template: azure/azure-pipelines-npm.yml\n- parameters:\n- name: macOs_npm\n- vmImage: macOS-10.14\n- - template: azure/azure-pipelines-yarn.yml\n- parameters:\n- name: Windows_yarn\n- vmImage: vs2017-win2016\n- - template: azure/azure-pipelines-yarn.yml\n- parameters:\n- name: macOS_yarn\n- vmImage: macOS-10.14\n"
},
{
"change_type": "DELETE",
"old_path": "azure/azure-pipelines-npm.yml",
"new_path": null,
"diff": "-jobs:\n- - job: ${{ parameters.name }}\n- pool:\n- vmImage: ${{ parameters.vmImage }}\n-\n- strategy:\n- matrix:\n- node_12_x:\n- node_version: 12.x\n- maxParallel: 5\n-\n- steps:\n- - task: NodeTool@0\n- inputs:\n- versionSpec: $(node_version)\n- displayName: Install Node.js\n-\n- - bash: npm i\n- displayName: Install dependencies\n-\n- - bash: npm run build\n- displayName: Lint and Build\n"
},
{
"change_type": "DELETE",
"old_path": "azure/azure-pipelines-yarn.yml",
"new_path": null,
"diff": "-jobs:\n- - job: ${{ parameters.name }}\n- pool:\n- vmImage: ${{ parameters.vmImage }}\n-\n- strategy:\n- matrix:\n- node_12_x:\n- node_version: 12.x\n- maxParallel: 5\n-\n- steps:\n- - task: NodeTool@0\n- inputs:\n- versionSpec: $(node_version)\n- displayName: Install Node.js\n-\n- - bash: yarn install\n- displayName: Install dependencies\n-\n- - bash: yarn build\n- displayName: Lint and Build\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | ci(build): removes azure pipeline and updates github ci |
288,334 | 15.02.2020 11:13:14 | -3,600 | 1fbd9658b4869d7f98b4ae918e731012e4b4b9a3 | fix(prettier): changes endofline option | [
{
"change_type": "MODIFY",
"old_path": ".github/workflows/ci.yml",
"new_path": ".github/workflows/ci.yml",
"diff": "@@ -10,9 +10,9 @@ jobs:\nmatrix:\nnode-version: [12.x, 13.x]\nos: [ubuntu-latest, windows-latest, macOS-latest]\n- exclude:\n- - os: windows-latest\n- node-version: 13.x\n+ # exclude:\n+ # - os: windows-latest\n+ # node-version: 13.x\nsteps:\n- uses: actions/checkout@v1\n"
},
{
"change_type": "MODIFY",
"old_path": ".prettierrc",
"new_path": ".prettierrc",
"diff": "\"bracketSpacing\": true,\n\"jsxBracketSameLine\": false,\n\"arrowParens\": \"always\",\n- \"endOfLine\": \"lf\"\n+ \"endOfLine\": \"auto\"\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(prettier): changes endofline option |
288,334 | 15.02.2020 11:29:36 | -3,600 | 8796c7f803663edf36a54a652fb0154e1d37a120 | build(build): updates github ci strategy | [
{
"change_type": "MODIFY",
"old_path": ".github/workflows/ci.yml",
"new_path": ".github/workflows/ci.yml",
"diff": "@@ -5,7 +5,6 @@ on: [push, pull_request]\njobs:\nnpm:\nruns-on: ${{ matrix.os }}\n-\nstrategy:\nmatrix:\nnode-version: [12.x, 13.x]\n@@ -13,7 +12,6 @@ jobs:\n# exclude:\n# - os: windows-latest\n# node-version: 13.x\n-\nsteps:\n- uses: actions/checkout@v1\n- name: Use Node.js\n@@ -43,7 +41,10 @@ jobs:\nstrategy:\nmatrix:\nnode-version: [12.x, 13.x]\n- os: [ubuntu-18.04]\n+ os: [ubuntu-latest, windows-latest, macOS-latest]\n+ # exclude:\n+ # - os: windows-latest\n+ # node-version: 13.x\nsteps:\n- uses: actions/checkout@v1\n- name: Use Node.js\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | build(build): updates github ci strategy |
288,334 | 15.02.2020 13:15:57 | -3,600 | 76f57e3d4ddd9328eb849b8f424675bd689b8ff3 | ci(azure): adds new azure pipeline yaml | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "azure.yaml",
"diff": "+trigger:\n+ branches:\n+ include:\n+ - refs/tags/v*\n+\n+jobs:\n+ - job: npm_job\n+ continueOnError: false\n+ pool:\n+ vmImage: ubuntu-latest\n+ strategy:\n+ matrix:\n+ node_12_x:\n+ node_version: 12.x\n+ maxParallel: 5\n+ steps:\n+ - task: NodeTool@0\n+ inputs:\n+ versionSpec: $(node_version)\n+ displayName: 'Install Node.js'\n+ - bash: npm install\n+ displayName: 'Install dependencies'\n+ - bash: npm lint\n+ displayName: 'Lint code'\n+ - bash: npm run build\n+ displayName: 'Build code'\n+ - bash: npm run test:ci\n+ displayName: 'Test compiled code'\n+\n+ - job: yarn_job\n+ continueOnError: false\n+ pool:\n+ vmImage: ubuntu-latest\n+ strategy:\n+ matrix:\n+ node_12_x:\n+ node_version: 12.x\n+ maxParallel: 5\n+ steps:\n+ - task: NodeTool@0\n+ inputs:\n+ versionSpec: $(node_version)\n+ displayName: 'Install Node.js'\n+ - bash: yarn install\n+ displayName: 'Install dependencies'\n+ - bash: yarn lint\n+ displayName: 'Lint code'\n+ - bash: yarn build\n+ displayName: 'Build code'\n+ - bash: yarn test:ci\n+ displayName: 'Test compiled code'\n+\n+ - job: docker_job\n+ dependsOn: [npm_job, yarn_job]\n+ continueOnError: false\n+ pool:\n+ vmImage: ubuntu-latest\n+ steps:\n+ - script: |\n+ echo '{ \"experimental\": true }' | sudo tee /etc/docker/daemon.json\n+ sudo service docker restart\n+ displayName: 'Enable Docker Engine experimental '\n+ - script: |\n+ GIT_TAG=`git describe --tags` && VERSION_TAG=\"$(cut -d'-' -f1 <<<\"$GIT_TAG\")\" && echo \"##vso[task.setvariable variable=VERSION_TAG]$VERSION_TAG\"\n+ displayName: 'Get Git Tag'\n+ - task: Docker@0\n+ displayName: 'Build an image'\n+ inputs:\n+ containerregistrytype: 'Container Registry'\n+ dockerRegistryConnection: Docker\n+ dockerFile: ./Dockerfile\n+ buildArguments: '--rm --squash'\n+ imageName: '$(Build.Repository.Name):$(VERSION_TAG)'\n+ - task: Docker@0\n+ displayName: 'Push an image'\n+ inputs:\n+ containerregistrytype: 'Container Registry'\n+ dockerRegistryConnection: Docker\n+ action: 'Push an image'\n+ imageName: '$(Build.Repository.Name):$(VERSION_TAG)'\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | ci(azure): adds new azure pipeline yaml |
288,334 | 15.02.2020 13:54:44 | -3,600 | 814e712be03fa7ccbe587a9c7ef8b8cda4a12f7f | fix(build): fixes yarn install on github ci | [
{
"change_type": "MODIFY",
"old_path": ".github/workflows/ci.yml",
"new_path": ".github/workflows/ci.yml",
"diff": "@@ -51,9 +51,11 @@ jobs:\nuses: actions/setup-node@v1\nwith:\nnode-version: ${{ matrix.node-version }}\n+ - name: Init yarn\n+ run: |\n+ npm install -g yarn\n- name: Install with yarn\nrun: |\n- curl -o- -L https://yarnpkg.com/install.sh | bash\nyarn install\n- name: Lint code\nrun: |\n@@ -61,6 +63,9 @@ jobs:\n- name: Build\nrun: |\nyarn build\n+ - name: Storybook build\n+ run: |\n+ yarn build-storybook\n- name: Run tests\nrun: |\nyarn test:ci\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(build): fixes yarn install on github ci |
288,334 | 15.02.2020 14:06:42 | -3,600 | eaf28e429e29e2cc79b34b8936e1077d69abb650 | build(azure): adds stages on azure pipeline yaml | [
{
"change_type": "MODIFY",
"old_path": "azure.yaml",
"new_path": "azure.yaml",
"diff": "@@ -5,6 +5,8 @@ trigger:\npr: none\n+stages:\n+ - stage: Build, lint and test code\njobs:\n- job: npm_job\ncontinueOnError: false\n@@ -28,7 +30,6 @@ jobs:\ndisplayName: 'Build code'\n- bash: npm run test:ci\ndisplayName: 'Test compiled code'\n-\n- job: yarn_job\ncontinueOnError: false\npool:\n@@ -52,6 +53,8 @@ jobs:\n- bash: yarn test:ci\ndisplayName: 'Test compiled code'\n+ - stage: Docker image build and push\n+ jobs:\n- job: docker_job\ndependsOn: [npm_job, yarn_job]\ncontinueOnError: false\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | build(azure): adds stages on azure pipeline yaml |
288,334 | 15.02.2020 14:10:22 | -3,600 | eb55decad73ecd0e2afbc2a1049747fbe6074ce1 | build(azure): fixes stage name on azure pipeline yaml | [
{
"change_type": "MODIFY",
"old_path": "azure.yaml",
"new_path": "azure.yaml",
"diff": "@@ -6,7 +6,7 @@ trigger:\npr: none\nstages:\n- - stage: Build, lint and test code\n+ - stage: Build\njobs:\n- job: npm_job\ncontinueOnError: false\n@@ -53,7 +53,7 @@ stages:\n- bash: yarn test:ci\ndisplayName: 'Test compiled code'\n- - stage: Docker image build and push\n+ - stage: Docker\njobs:\n- job: docker_job\ndependsOn: [npm_job, yarn_job]\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | build(azure): fixes stage name on azure pipeline yaml |
288,334 | 15.02.2020 14:16:02 | -3,600 | d57539a5fa2453ec7af7d32edb79c21d4a33c3ac | build(azure): improves azure pipeline stage conditions | [
{
"change_type": "MODIFY",
"old_path": "azure.yaml",
"new_path": "azure.yaml",
"diff": "@@ -56,7 +56,8 @@ stages:\n- stage: Docker\njobs:\n- job: docker_job\n- dependsOn: [npm_job, yarn_job]\n+ dependsOn: Build\n+ condition: succeeded('Build')\ncontinueOnError: false\npool:\nvmImage: ubuntu-latest\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | build(azure): improves azure pipeline stage conditions |
288,337 | 15.02.2020 16:25:11 | -3,600 | a44ac9f9dcc38ff98c1eb85476e25be4cc6598ac | feat(breadcrumb): add Breadcrumbs unit tests (component/slice/hook)
fix | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/breadcrumbs/Breadcrumbs.test.tsx",
"new_path": "src/__tests__/breadcrumbs/Breadcrumbs.test.tsx",
"diff": "import '../../__mocks__/matchMediaMock'\n+import React from 'react'\n+import { Provider } from 'react-redux'\n+import { mount } from 'enzyme'\n+import { createMemoryHistory } from 'history'\n+import { Router } from 'react-router-dom'\n+import configureMockStore from 'redux-mock-store'\n+import { BreadcrumbItem } from '@hospitalrun/components'\n-it('should return true', () => {\n- expect(true).toBeTruthy()\n+import Breadcrumbs from 'breadcrumbs/Breadcrumbs'\n+import Breadcrumb from 'model/Breadcrumb'\n+\n+const mockStore = configureMockStore()\n+\n+describe('Breadcrumbs', () => {\n+ const setup = (breadcrumbs: Breadcrumb[]) => {\n+ const history = createMemoryHistory()\n+ const store = mockStore({\n+ breadcrumbs: { breadcrumbs },\n+ })\n+\n+ const wrapper = mount(\n+ <Provider store={store}>\n+ <Router history={history}>\n+ <Breadcrumbs />\n+ </Router>\n+ </Provider>,\n+ )\n+\n+ return wrapper\n+ }\n+\n+ it('should render breadcrumbs items', () => {\n+ const breadcrumbs = [\n+ { text: 'Edit Patient', location: '/patient/1/edit' },\n+ { i18nKey: 'patient.label', location: '/patient' },\n+ { text: 'Bob', location: '/patient/1' },\n+ ]\n+ const wrapper = setup(breadcrumbs)\n+\n+ const items = wrapper.find(BreadcrumbItem)\n+\n+ expect(items).toHaveLength(3)\n+ expect(items.at(0).text()).toEqual('patient.label')\n+ expect(items.at(1).text()).toEqual('Bob')\n+ expect(items.at(2).text()).toEqual('Edit Patient')\n+ })\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/breadcrumbs/breadcrumbs-slice.test.ts",
"new_path": "src/__tests__/breadcrumbs/breadcrumbs-slice.test.ts",
"diff": "import '../../__mocks__/matchMediaMock'\n+import { AnyAction } from 'redux'\n+import breadcrumbs, { addBreadcrumbs, removeBreadcrumbs } from '../../breadcrumbs/breadcrumbs-slice'\n-it('should return true', () => {\n- expect(true).toBeTruthy()\n+describe('breadcrumbs slice', () => {\n+ describe('breadcrumbs reducer', () => {\n+ it('should create the proper initial state with empty patients array', () => {\n+ const breadcrumbsStore = breadcrumbs(undefined, {} as AnyAction)\n+\n+ expect(breadcrumbsStore.breadcrumbs).toEqual([])\n+ })\n+\n+ it('should handle the ADD_BREADCRUMBS action', () => {\n+ const breadcrumbsToAdd = [\n+ { text: 'user', location: '/user' },\n+ { text: 'Bob', location: '/user/1' },\n+ ]\n+\n+ const breadcrumbsStore = breadcrumbs(undefined, {\n+ type: addBreadcrumbs.type,\n+ payload: breadcrumbsToAdd,\n+ })\n+\n+ expect(breadcrumbsStore.breadcrumbs).toEqual(breadcrumbsToAdd)\n+ })\n+\n+ it('should handle the ADD_BREADCRUMBS action with existing breadcreumbs', () => {\n+ const breadcrumbsToAdd = [{ text: 'Bob', location: '/user/1' }]\n+\n+ const state = {\n+ breadcrumbs: [{ text: 'user', location: '/user' }],\n+ }\n+\n+ const breadcrumbsStore = breadcrumbs(state, {\n+ type: addBreadcrumbs.type,\n+ payload: breadcrumbsToAdd,\n+ })\n+\n+ expect(breadcrumbsStore.breadcrumbs).toEqual([...state.breadcrumbs, ...breadcrumbsToAdd])\n+ })\n+\n+ it('should handle the REMOVE_BREADCRUMBS action', () => {\n+ const breadcrumbsToRemove = [{ text: 'Bob', location: '/user/1' }]\n+\n+ const state = {\n+ breadcrumbs: [\n+ { text: 'user', location: '/user' },\n+ { text: 'Bob', location: '/user/1' },\n+ ],\n+ }\n+\n+ const breadcrumbsStore = breadcrumbs(state, {\n+ type: removeBreadcrumbs.type,\n+ payload: breadcrumbsToRemove,\n+ })\n+\n+ expect(breadcrumbsStore.breadcrumbs).toEqual([{ text: 'user', location: '/user' }])\n+ })\n+ })\n})\n"
},
{
"change_type": "DELETE",
"old_path": "src/__tests__/breadcrumbs/useAddBreadcrumbs.test.ts",
"new_path": null,
"diff": "-import '../../__mocks__/matchMediaMock'\n-\n-it('should return true', () => {\n- expect(true).toBeTruthy()\n-})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/breadcrumbs/useAddBreadcrumbs.test.tsx",
"diff": "+import React from 'react'\n+import { renderHook } from '@testing-library/react-hooks'\n+import configureMockStore from 'redux-mock-store'\n+import { Provider } from 'react-redux'\n+import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs'\n+import * as breadcrumbsSlice from '../../breadcrumbs/breadcrumbs-slice'\n+\n+const store = configureMockStore()\n+\n+describe('useAddBreadcrumbs', () => {\n+ beforeEach(() => jest.clearAllMocks())\n+\n+ it('should call addBreadcrumbs with the correct data', () => {\n+ const wrapper = ({ children }: any) => <Provider store={store({})}>{children}</Provider>\n+\n+ jest.spyOn(breadcrumbsSlice, 'addBreadcrumbs')\n+ const breadcrumbs = [\n+ {\n+ text: 'Patients',\n+ location: '/patients',\n+ },\n+ ]\n+\n+ renderHook(() => useAddBreadcrumbs(breadcrumbs), { wrapper } as any)\n+ expect(breadcrumbsSlice.addBreadcrumbs).toHaveBeenCalledTimes(1)\n+ expect(breadcrumbsSlice.addBreadcrumbs).toHaveBeenCalledWith(breadcrumbs)\n+ })\n+\n+ it('should call removeBreadcrumbs with the correct data after unmount', () => {\n+ const wrapper = ({ children }: any) => <Provider store={store({})}>{children}</Provider>\n+\n+ jest.spyOn(breadcrumbsSlice, 'addBreadcrumbs')\n+ jest.spyOn(breadcrumbsSlice, 'removeBreadcrumbs')\n+ const breadcrumbs = [\n+ {\n+ text: 'Patients',\n+ location: '/patients',\n+ },\n+ ]\n+\n+ const { unmount } = renderHook(() => useAddBreadcrumbs(breadcrumbs), { wrapper } as any)\n+ unmount()\n+ expect(breadcrumbsSlice.removeBreadcrumbs).toHaveBeenCalledTimes(1)\n+ expect(breadcrumbsSlice.removeBreadcrumbs).toHaveBeenCalledWith(breadcrumbs)\n+ })\n+})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/breadcrumbs/Breadcrumbs.tsx",
"new_path": "src/breadcrumbs/Breadcrumbs.tsx",
"diff": "@@ -2,10 +2,7 @@ import React from 'react'\nimport { useHistory } from 'react-router'\nimport { useSelector } from 'react-redux'\nimport { useTranslation } from 'react-i18next'\n-import {\n- Breadcrumb as HrBreadcrumb,\n- BreadcrumbItem as HrBreadcrumbItem,\n-} from '@hospitalrun/components'\n+import { Breadcrumb, BreadcrumbItem } from '@hospitalrun/components'\nimport { RootState } from '../store'\nconst Breadcrumbs = () => {\n@@ -14,7 +11,7 @@ const Breadcrumbs = () => {\nconst { breadcrumbs } = useSelector((state: RootState) => state.breadcrumbs)\nreturn (\n- <HrBreadcrumb>\n+ <Breadcrumb>\n{breadcrumbs\n.slice()\n.sort((b1, b2) => b1.location.length - b2.location.length)\n@@ -23,12 +20,12 @@ const Breadcrumbs = () => {\nconst onClick = !isLast ? () => history.push(location) : undefined\nreturn (\n- <HrBreadcrumbItem key={location} active={isLast} onClick={onClick}>\n+ <BreadcrumbItem key={location} active={isLast} onClick={onClick}>\n{i18nKey ? t(i18nKey) : text}\n- </HrBreadcrumbItem>\n+ </BreadcrumbItem>\n)\n})}\n- </HrBreadcrumb>\n+ </Breadcrumb>\n)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/breadcrumbs/useAddBreadcrumbs.ts",
"new_path": "src/breadcrumbs/useAddBreadcrumbs.ts",
"diff": "@@ -5,12 +5,14 @@ import { addBreadcrumbs, removeBreadcrumbs } from './breadcrumbs-slice'\nexport default function useAddBreadcrumbs(breadcrumbs: Breadcrumb[]): void {\nconst dispatch = useDispatch()\n+ const breadcrumbsStringified = JSON.stringify(breadcrumbs)\nuseEffect(() => {\n- dispatch(addBreadcrumbs(breadcrumbs))\n+ const breadcrumbsParsed = JSON.parse(breadcrumbsStringified)\n+ dispatch(addBreadcrumbs(breadcrumbsParsed))\nreturn () => {\n- dispatch(removeBreadcrumbs(breadcrumbs))\n+ dispatch(removeBreadcrumbs(breadcrumbsParsed))\n}\n- }, [breadcrumbs, dispatch, JSON.stringify(breadcrumbs)])\n+ }, [breadcrumbsStringified, dispatch])\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(breadcrumb): add Breadcrumbs unit tests (component/slice/hook)
fix #1770 |
288,328 | 15.02.2020 18:31:55 | 21,600 | 0da4043afeb495281e04f4c5c2dcff512d285ea3 | feat(view patient): add 'edit' icon to Edit button | [
{
"change_type": "MODIFY",
"old_path": "src/patients/view/ViewPatient.tsx",
"new_path": "src/patients/view/ViewPatient.tsx",
"diff": "@@ -68,6 +68,7 @@ const ViewPatient = () => {\n<Button\ncolor=\"success\"\noutlined\n+ icon=\"edit\"\nonClick={() => {\nhistory.push(`/patients/edit/${patient.id}`)\n}}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(view patient): add 'edit' icon to Edit button |
288,337 | 17.02.2020 19:36:10 | -3,600 | bbb3ca06ec2d3ed4622b79cea81558a87519a8a8 | feat(breadcrumb): sort the breadcrumbs in addBreadcrumbs action
fix | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/breadcrumbs/Breadcrumbs.test.tsx",
"new_path": "src/__tests__/breadcrumbs/Breadcrumbs.test.tsx",
"diff": "@@ -32,9 +32,9 @@ describe('Breadcrumbs', () => {\nit('should render breadcrumbs items', () => {\nconst breadcrumbs = [\n- { text: 'Edit Patient', location: '/patient/1/edit' },\n{ i18nKey: 'patient.label', location: '/patient' },\n{ text: 'Bob', location: '/patient/1' },\n+ { text: 'Edit Patient', location: '/patient/1/edit' },\n]\nconst wrapper = setup(breadcrumbs)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/breadcrumbs/breadcrumbs-slice.test.ts",
"new_path": "src/__tests__/breadcrumbs/breadcrumbs-slice.test.ts",
"diff": "@@ -24,7 +24,7 @@ describe('breadcrumbs slice', () => {\nexpect(breadcrumbsStore.breadcrumbs).toEqual(breadcrumbsToAdd)\n})\n- it('should handle the ADD_BREADCRUMBS action with existing breadcreumbs', () => {\n+ it('should handle the ADD_BREADCRUMBS action with existing breadcrumbs', () => {\nconst breadcrumbsToAdd = [{ text: 'Bob', location: '/user/1' }]\nconst state = {\n@@ -39,6 +39,28 @@ describe('breadcrumbs slice', () => {\nexpect(breadcrumbsStore.breadcrumbs).toEqual([...state.breadcrumbs, ...breadcrumbsToAdd])\n})\n+ it('should handle the ADD_BREADCRUMBS action and sort the breadcrumbs by their location', () => {\n+ const breadcrumbsToAdd = [{ text: 'Bob', location: '/user/1/' }]\n+\n+ const state = {\n+ breadcrumbs: [\n+ { text: 'user', location: '/user' },\n+ { text: 'edit user', location: '/user/1/edit' },\n+ ],\n+ }\n+\n+ const breadcrumbsStore = breadcrumbs(state, {\n+ type: addBreadcrumbs.type,\n+ payload: breadcrumbsToAdd,\n+ })\n+\n+ expect(breadcrumbsStore.breadcrumbs).toEqual([\n+ { text: 'user', location: '/user' },\n+ { text: 'Bob', location: '/user/1/' },\n+ { text: 'edit user', location: '/user/1/edit' },\n+ ])\n+ })\n+\nit('should handle the REMOVE_BREADCRUMBS action', () => {\nconst breadcrumbsToRemove = [{ text: 'Bob', location: '/user/1' }]\n"
},
{
"change_type": "MODIFY",
"old_path": "src/breadcrumbs/Breadcrumbs.tsx",
"new_path": "src/breadcrumbs/Breadcrumbs.tsx",
"diff": "@@ -12,10 +12,7 @@ const Breadcrumbs = () => {\nreturn (\n<Breadcrumb>\n- {breadcrumbs\n- .slice()\n- .sort((b1, b2) => b1.location.length - b2.location.length)\n- .map(({ i18nKey, text, location }, index) => {\n+ {breadcrumbs.map(({ i18nKey, text, location }, index) => {\nconst isLast = index === breadcrumbs.length - 1\nconst onClick = !isLast ? () => history.push(location) : undefined\n"
},
{
"change_type": "MODIFY",
"old_path": "src/breadcrumbs/breadcrumbs-slice.ts",
"new_path": "src/breadcrumbs/breadcrumbs-slice.ts",
"diff": "@@ -14,7 +14,9 @@ const breadcrumbsSlice = createSlice({\ninitialState,\nreducers: {\naddBreadcrumbs(state, { payload }: PayloadAction<Breadcrumb[]>) {\n- state.breadcrumbs = [...state.breadcrumbs, ...payload]\n+ state.breadcrumbs = [...state.breadcrumbs, ...payload].sort(\n+ (b1, b2) => b1.location.length - b2.location.length,\n+ )\n},\nremoveBreadcrumbs(state, { payload }: PayloadAction<Breadcrumb[]>) {\nconst locations = payload.map((b) => b.location)\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(breadcrumb): sort the breadcrumbs in addBreadcrumbs action
fix #1770 |
288,337 | 17.02.2020 21:37:59 | -3,600 | 492cb37c593f94ad17cce4a26fa527990b1c9639 | feat(breadcrumb): use reduxPatient instead of patient for breadcrumbs | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/HospitalRun.test.tsx",
"new_path": "src/__tests__/HospitalRun.test.tsx",
"diff": "@@ -7,10 +7,12 @@ import { mocked } from 'ts-jest/utils'\nimport thunk from 'redux-thunk'\nimport configureMockStore from 'redux-mock-store'\nimport { Toaster } from '@hospitalrun/components'\n+\nimport { act } from 'react-dom/test-utils'\nimport Dashboard from 'dashboard/Dashboard'\nimport Appointments from 'scheduling/appointments/Appointments'\nimport NewAppointment from 'scheduling/appointments/new/NewAppointment'\n+import { addBreadcrumbs } from 'breadcrumbs/breadcrumbs-slice'\nimport NewPatient from '../patients/new/NewPatient'\nimport EditPatient from '../patients/edit/EditPatient'\nimport ViewPatient from '../patients/view/ViewPatient'\n@@ -76,15 +78,15 @@ describe('HospitalRun', () => {\nmockedPatientRepository.find.mockResolvedValue(patient)\n- const wrapper = mount(\n- <Provider\n- store={mockStore({\n+ const store = mockStore({\ntitle: 'test',\nuser: { permissions: [Permissions.WritePatients, Permissions.ReadPatients] },\n- patient: { patient: {} as Patient },\n+ patient: { patient },\nbreadcrumbs: { breadcrumbs: [] },\n- })}\n- >\n+ })\n+\n+ const wrapper = mount(\n+ <Provider store={store}>\n<MemoryRouter initialEntries={['/patients/edit/123']}>\n<HospitalRun />\n</MemoryRouter>\n@@ -92,6 +94,14 @@ describe('HospitalRun', () => {\n)\nexpect(wrapper.find(EditPatient)).toHaveLength(1)\n+\n+ expect(store.getActions()).toContainEqual(\n+ addBreadcrumbs([\n+ { i18nKey: 'patients.label', location: '/patients' },\n+ { text: 'test test test', location: `/patients/${patient.id}` },\n+ { i18nKey: 'patients.editPatient', location: `/patients/${patient.id}/edit` },\n+ ]),\n+ )\n})\nit('should render the Dashboard when the user does not have read patient privileges', () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/edit/EditPatient.tsx",
"new_path": "src/patients/edit/EditPatient.tsx",
"diff": "@@ -37,8 +37,8 @@ const EditPatient = () => {\nconst breadcrumbs = [\n{ i18nKey: 'patients.label', location: '/patients' },\n- { text: getPatientFullName(patient), location: `/patients/${patient.id}` },\n- { i18nKey: 'patients.editPatient', location: `/patients/${patient.id}/edit` },\n+ { text: getPatientFullName(reduxPatient), location: `/patients/${reduxPatient.id}` },\n+ { i18nKey: 'patients.editPatient', location: `/patients/${reduxPatient.id}/edit` },\n]\nuseAddBreadcrumbs(breadcrumbs)\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(breadcrumb): use reduxPatient instead of patient for breadcrumbs |
288,337 | 17.02.2020 21:55:31 | -3,600 | b5e4c387ed43d1373c43bc5a2a66893c090bad27 | feat(breadcrumb): test the dispatch of addBreadcrumbs action | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/HospitalRun.test.tsx",
"new_path": "src/__tests__/HospitalRun.test.tsx",
"diff": "@@ -27,14 +27,14 @@ describe('HospitalRun', () => {\ndescribe('routing', () => {\ndescribe('/patients/new', () => {\nit('should render the new patient screen when /patients/new is accessed', () => {\n- const wrapper = mount(\n- <Provider\n- store={mockStore({\n+ const store = mockStore({\ntitle: 'test',\nuser: { permissions: [Permissions.WritePatients] },\nbreadcrumbs: { breadcrumbs: [] },\n- })}\n- >\n+ })\n+\n+ const wrapper = mount(\n+ <Provider store={store}>\n<MemoryRouter initialEntries={['/patients/new']}>\n<HospitalRun />\n</MemoryRouter>\n@@ -42,6 +42,13 @@ describe('HospitalRun', () => {\n)\nexpect(wrapper.find(NewPatient)).toHaveLength(1)\n+\n+ expect(store.getActions()).toContainEqual(\n+ addBreadcrumbs([\n+ { i18nKey: 'patients.label', location: '/patients' },\n+ { i18nKey: 'patients.newPatient', location: '/patients/new' },\n+ ]),\n+ )\n})\nit('should render the Dashboard if the user does not have write patient privileges', () => {\n@@ -156,15 +163,15 @@ describe('HospitalRun', () => {\nmockedPatientRepository.find.mockResolvedValue(patient)\n- const wrapper = mount(\n- <Provider\n- store={mockStore({\n+ const store = mockStore({\ntitle: 'test',\nuser: { permissions: [Permissions.ReadPatients] },\npatient: { patient },\nbreadcrumbs: { breadcrumbs: [] },\n- })}\n- >\n+ })\n+\n+ const wrapper = mount(\n+ <Provider store={store}>\n<MemoryRouter initialEntries={['/patients/123']}>\n<HospitalRun />\n</MemoryRouter>\n@@ -172,6 +179,13 @@ describe('HospitalRun', () => {\n)\nexpect(wrapper.find(ViewPatient)).toHaveLength(1)\n+\n+ expect(store.getActions()).toContainEqual(\n+ addBreadcrumbs([\n+ { i18nKey: 'patients.label', location: '/patients' },\n+ { text: 'test test test', location: `/patients/${patient.id}` },\n+ ]),\n+ )\n})\nit('should render the Dashboard when the user does not have read patient privileges', () => {\n@@ -195,15 +209,15 @@ describe('HospitalRun', () => {\ndescribe('/appointments', () => {\nit('should render the appointments screen when /appointments is accessed', async () => {\n- const wrapper = mount(\n- <Provider\n- store={mockStore({\n+ const store = mockStore({\ntitle: 'test',\nuser: { permissions: [Permissions.ReadAppointments] },\nappointments: { appointments: [] },\nbreadcrumbs: { breadcrumbs: [] },\n- })}\n- >\n+ })\n+\n+ const wrapper = mount(\n+ <Provider store={store}>\n<MemoryRouter initialEntries={['/appointments']}>\n<HospitalRun />\n</MemoryRouter>\n@@ -215,6 +229,10 @@ describe('HospitalRun', () => {\n})\nexpect(wrapper.find(Appointments)).toHaveLength(1)\n+\n+ expect(store.getActions()).toContainEqual(\n+ addBreadcrumbs([{ i18nKey: 'scheduling.appointments.label', location: '/appointments' }]),\n+ )\n})\nit('should render the Dashboard when the user does not have read appointment privileges', () => {\n@@ -239,14 +257,14 @@ describe('HospitalRun', () => {\ndescribe('/appointments/new', () => {\nit('should render the new appointment screen when /appointments/new is accessed', async () => {\n- const wrapper = mount(\n- <Provider\n- store={mockStore({\n+ const store = mockStore({\ntitle: 'test',\nuser: { permissions: [Permissions.WriteAppointments] },\nbreadcrumbs: { breadcrumbs: [] },\n- })}\n- >\n+ })\n+\n+ const wrapper = mount(\n+ <Provider store={store}>\n<MemoryRouter initialEntries={['/appointments/new']}>\n<HospitalRun />\n</MemoryRouter>\n@@ -254,6 +272,13 @@ describe('HospitalRun', () => {\n)\nexpect(wrapper.find(NewAppointment)).toHaveLength(1)\n+\n+ expect(store.getActions()).toContainEqual(\n+ addBreadcrumbs([\n+ { i18nKey: 'scheduling.appointments.label', location: '/appointments' },\n+ { i18nKey: 'scheduling.appointments.new', location: '/appointments/new' },\n+ ]),\n+ )\n})\nit('should render the Dashboard when the user does not have read appointment privileges', () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/Appointments.tsx",
"new_path": "src/scheduling/appointments/Appointments.tsx",
"diff": "@@ -17,7 +17,7 @@ interface Event {\nallDay: boolean\n}\n-const breadcrumbs = [{ i18nKey: 'scheduling.appointments.label', location: '/patients' }]\n+const breadcrumbs = [{ i18nKey: 'scheduling.appointments.label', location: '/appointments' }]\nconst Appointments = () => {\nconst { t } = useTranslation()\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(breadcrumb): test the dispatch of addBreadcrumbs action |
288,334 | 18.02.2020 08:15:01 | -3,600 | 38c4b40e9ff7caaefa07df68920eea4c27669d47 | fix(ci): removes storybook command | [
{
"change_type": "MODIFY",
"old_path": ".github/workflows/ci.yml",
"new_path": ".github/workflows/ci.yml",
"diff": "@@ -65,9 +65,6 @@ jobs:\n- name: Build\nrun: |\nyarn build\n- - name: Storybook build\n- run: |\n- yarn build-storybook\n- name: Run tests\nrun: |\nyarn test:ci\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(ci): removes storybook command |
288,323 | 18.02.2020 18:55:15 | 21,600 | 0f061d2bec64883453c7ca283c541db846459f51 | fix(test): cleaned up id and fixed test with sequential insert | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/clients/db/PatientRepository.test.ts",
"new_path": "src/__tests__/clients/db/PatientRepository.test.ts",
"diff": "@@ -2,162 +2,160 @@ import { patients } from 'config/pouchdb'\nimport PatientRepository from 'clients/db/PatientRepository'\nimport Patient from 'model/Patient'\nimport { fromUnixTime } from 'date-fns'\n-import { updatePatientStart } from 'patients/patient-slice'\n+\n+async function removeAllDocs() {\n+ // eslint-disable-next-line\n+ const allDocs = await patients.allDocs({ include_docs: true })\n+ await Promise.all(\n+ allDocs.rows.map(async (row) => {\n+ if (row.doc) {\n+ await patients.remove(row.doc)\n+ }\n+ }),\n+ )\n+}\ndescribe('patient repository', () => {\ndescribe('find', () => {\n+ afterEach(async () => {\n+ await removeAllDocs()\n+ })\nit('should return a patient with the correct data', async () => {\n- await patients.put({ _id: 'id5678' }) // store another patient just to make sure we pull back the right one\n- const expectedPatient = await patients.put({ _id: 'id1234' })\n+ await patients.put({ _id: 'id1111' }) // store another patient just to make sure we pull back the right one\n+ const expectedPatient = await patients.put({ _id: 'id2222' })\n- const actualPatient = await PatientRepository.find('id1234')\n+ const actualPatient = await PatientRepository.find('id2222')\nexpect(actualPatient).toBeDefined()\nexpect(actualPatient.id).toEqual(expectedPatient.id)\n-\n- await patients.remove(await patients.get('id1234'))\n- await patients.remove(await patients.get('id5678'))\n})\n})\ndescribe('search', () => {\n+ afterEach(async () => {\n+ await removeAllDocs()\n+ })\n+\nit('should return all records that friendly ids match search text', async () => {\n// same full name to prove that it is finding by friendly id\nconst expectedFriendlyId = 'P00001'\n- await patients.put({ _id: 'id5678', friendlyId: expectedFriendlyId, fullName: 'test test' })\n- await patients.put({ _id: 'id1234', friendlyId: 'P00002', fullName: 'test test' })\n+ await patients.put({ _id: 'someId1', friendlyId: expectedFriendlyId, fullName: 'test test' })\n+ await patients.put({ _id: 'someId2', friendlyId: 'P00002', fullName: 'test test' })\nconst result = await PatientRepository.search(expectedFriendlyId)\nexpect(result).toHaveLength(1)\nexpect(result[0].friendlyId).toEqual(expectedFriendlyId)\n-\n- await patients.remove(await patients.get('id1234'))\n- await patients.remove(await patients.get('id5678'))\n})\nit('should return all records that fullName contains search text', async () => {\n- await patients.put({ _id: 'id1234', friendlyId: 'P00002', fullName: 'blh test test blah' })\n- await patients.put({ _id: 'id5678', friendlyId: 'P00001', fullName: 'test test' })\n- await patients.put({ _id: 'id2345', friendlyId: 'P00003', fullName: 'not found' })\n+ await patients.put({ _id: 'id3333', friendlyId: 'P00002', fullName: 'blh test test blah' })\n+ await patients.put({ _id: 'id4444', friendlyId: 'P00001', fullName: 'test test' })\n+ await patients.put({ _id: 'id5555', friendlyId: 'P00003', fullName: 'not found' })\nconst result = await PatientRepository.search('test test')\nexpect(result).toHaveLength(2)\n- expect(result[0].id).toEqual('id1234')\n- expect(result[1].id).toEqual('id5678')\n-\n- await patients.remove(await patients.get('id1234'))\n- await patients.remove(await patients.get('id5678'))\n- await patients.remove(await patients.get('id2345'))\n+ expect(result[0].id).toEqual('id3333')\n+ expect(result[1].id).toEqual('id4444')\n})\nit('should match search criteria with case insensitive match', async () => {\n- await patients.put({ _id: 'id5678', friendlyId: 'P00001', fullName: 'test test' })\n- await patients.put({ _id: 'id1234', friendlyId: 'P00002', fullName: 'not found' })\n+ await patients.put({ _id: 'id6666', friendlyId: 'P00001', fullName: 'test test' })\n+ await patients.put({ _id: 'id7777', friendlyId: 'P00002', fullName: 'not found' })\nconst result = await PatientRepository.search('TEST TEST')\nexpect(result).toHaveLength(1)\n- expect(result[0].id).toEqual('id5678')\n-\n- await patients.remove(await patients.get('id1234'))\n- await patients.remove(await patients.get('id5678'))\n+ expect(result[0].id).toEqual('id6666')\n})\n})\ndescribe('findAll', () => {\n+ afterEach(async () => {\n+ await removeAllDocs()\n+ })\nit('should find all patients in the database sorted by their ids', async () => {\n- const expectedPatient2 = await patients.put({ _id: 'id5678' })\n- const expectedPatient1 = await patients.put({ _id: 'id1234' })\n+ const expectedPatient1 = await patients.put({ _id: 'id9999' })\n+ const expectedPatient2 = await patients.put({ _id: 'id8888' })\nconst result = await PatientRepository.findAll()\nexpect(result).toHaveLength(2)\n- expect(result[0].id).toEqual(expectedPatient1.id)\n- expect(result[1].id).toEqual(expectedPatient2.id)\n-\n- await patients.remove(await patients.get('id1234'))\n- await patients.remove(await patients.get('id5678'))\n+ expect(result[0].id).toEqual(expectedPatient2.id)\n+ expect(result[1].id).toEqual(expectedPatient1.id)\n})\n})\ndescribe('save', () => {\n+ afterEach(async () => {\n+ await removeAllDocs()\n+ })\n+\nit('should generate an id that is a timestamp for the patient', async () => {\nconst newPatient = await PatientRepository.save({\nfullName: 'test test',\n} as Patient)\nexpect(fromUnixTime(parseInt(newPatient.id, 10)).getTime() > 0).toBeTruthy()\n-\n- await patients.remove(await patients.get(newPatient.id))\n})\nit('should generate a friendly id', async () => {\nconst newPatient = await PatientRepository.save({\n- fullName: 'test test',\n+ fullName: 'test1 test1',\n} as Patient)\nexpect(newPatient.friendlyId).toEqual('P00001')\n-\n- await patients.remove(await patients.get(newPatient.id))\n})\nit('should sequentially generate a friendly id', async () => {\n- const existingPatient = await PatientRepository.save({\n- fullName: 'test test',\n- } as Patient)\n+ await patients.put({ _id: 'id9999', friendlyId: 'P00001' })\nconst newPatient = await PatientRepository.save({\n- fullName: 'test1 test1',\n+ fullName: 'test3 test3',\n} as Patient)\nexpect(newPatient.friendlyId).toEqual('P00002')\n-\n- await patients.remove(await patients.get(existingPatient.id))\n- await patients.remove(await patients.get(newPatient.id))\n})\n})\ndescribe('saveOrUpdate', () => {\n+ afterEach(async () => {\n+ await removeAllDocs()\n+ })\n+\nit('should save the patient if an id was not on the entity', async () => {\nconst newPatient = await PatientRepository.saveOrUpdate({\n- fullName: 'test1 test1',\n+ fullName: 'test4 test4',\n} as Patient)\nexpect(newPatient.id).toBeDefined()\n-\n- await patients.remove(await patients.get(newPatient.id))\n})\nit('should update the patient if one was already existing', async () => {\nconst existingPatient = await PatientRepository.save({\n- fullName: 'test test',\n+ fullName: 'test5 test5',\n} as Patient)\nconst updatedPatient = await PatientRepository.saveOrUpdate(existingPatient)\nexpect(updatedPatient.id).toEqual(existingPatient.id)\n-\n- await patients.remove(await patients.get(existingPatient.id))\n})\nit('should update the existing fields', async () => {\nconst existingPatient = await PatientRepository.save({\n- fullName: 'test test',\n+ fullName: 'test6 test6',\n} as Patient)\nexistingPatient.fullName = 'changed'\nconst updatedPatient = await PatientRepository.saveOrUpdate(existingPatient)\nexpect(updatedPatient.fullName).toEqual('changed')\n-\n- await patients.remove(await patients.get(existingPatient.id))\n})\nit('should add new fields without changing existing fields', async () => {\nconst existingPatient = await PatientRepository.save({\n- fullName: 'test test',\n+ fullName: 'test7 test7',\n} as Patient)\nexistingPatient.givenName = 'givenName'\n@@ -165,15 +163,13 @@ describe('patient repository', () => {\nexpect(updatedPatient.fullName).toEqual(existingPatient.fullName)\nexpect(updatedPatient.givenName).toEqual('givenName')\n-\n- await patients.remove(await patients.get(existingPatient.id))\n})\n})\ndescribe('delete', () => {\nit('should delete the patient', async () => {\nconst patientToDelete = await PatientRepository.save({\n- fullName: 'test test',\n+ fullName: 'test8 test8',\n} as Patient)\nawait PatientRepository.delete(patientToDelete)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/new/NewPatient.test.tsx",
"new_path": "src/__tests__/patients/new/NewPatient.test.tsx",
"diff": "@@ -52,7 +52,7 @@ describe('New Patient', () => {\n}\nbeforeEach(() => {\n- jest.restoreAllMocks()\n+ jest.resetAllMocks()\n})\nit('should render a general information form', async () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/patient-slice.test.ts",
"new_path": "src/__tests__/patients/patient-slice.test.ts",
"diff": "@@ -105,10 +105,12 @@ describe('patients slice', () => {\ndescribe('createPatient()', () => {\nit('should dispatch the CREATE_PATIENT_START action', async () => {\n+ jest.spyOn(PatientRepository, 'save')\n+ mocked(PatientRepository).save.mockResolvedValue({ id: 'sliceId1' } as Patient)\nconst dispatch = jest.fn()\nconst getState = jest.fn()\nconst expectedPatient = {\n- id: 'id',\n+ id: 'sliceId1',\n} as Patient\nawait createPatient(expectedPatient, createMemoryHistory())(dispatch, getState, null)\n@@ -120,8 +122,9 @@ describe('patients slice', () => {\nconst dispatch = jest.fn()\nconst getState = jest.fn()\njest.spyOn(PatientRepository, 'save')\n+ mocked(PatientRepository).save.mockResolvedValue({ id: 'sliceId2' } as Patient)\nconst expectedPatient = {\n- id: 'id',\n+ id: 'sliceId2',\n} as Patient\nawait createPatient(expectedPatient, createMemoryHistory())(dispatch, getState, null)\n@@ -133,9 +136,9 @@ describe('patients slice', () => {\nconst dispatch = jest.fn()\nconst getState = jest.fn()\nconst mockedPatientRepository = mocked(PatientRepository, true)\n- mockedPatientRepository.save.mockResolvedValue({ id: '12345' } as Patient)\n+ mockedPatientRepository.save.mockResolvedValue({ id: 'slideId3' } as Patient)\nconst expectedPatient = {\n- id: 'id',\n+ id: 'slideId3',\n} as Patient\nawait createPatient(expectedPatient, createMemoryHistory())(dispatch, getState, null)\n@@ -144,7 +147,8 @@ describe('patients slice', () => {\n})\nit('should navigate to the /patients/:id where id is the new patient id', async () => {\n- const expectedPatientId = '12345'\n+ const expectedPatientId = 'sliceId4'\n+ jest.spyOn(PatientRepository, 'save')\nconst mockedPatientRepository = mocked(PatientRepository, true)\nmockedPatientRepository.save.mockResolvedValue({ id: expectedPatientId } as Patient)\nconst history = createMemoryHistory()\n@@ -160,12 +164,13 @@ describe('patients slice', () => {\nit('should call the Toaster function with the correct data', async () => {\njest.spyOn(components, 'Toast')\n- const expectedPatientId = '12345'\n+ const expectedPatientId = 'sliceId5'\nconst expectedFullName = 'John Doe II'\nconst expectedPatient = {\nid: expectedPatientId,\nfullName: expectedFullName,\n} as Patient\n+ jest.spyOn(PatientRepository, 'save')\nconst mockedPatientRepository = mocked(PatientRepository, true)\nmockedPatientRepository.save.mockResolvedValue(expectedPatient)\nconst mockedComponents = mocked(components, true)\n@@ -188,7 +193,7 @@ describe('patients slice', () => {\nconst dispatch = jest.fn()\nconst getState = jest.fn()\njest.spyOn(PatientRepository, 'find')\n- const expectedPatientId = '12345'\n+ const expectedPatientId = 'sliceId6'\nconst expectedPatient = { id: expectedPatientId } as Patient\nconst mockedPatientRepository = mocked(PatientRepository, true)\nmockedPatientRepository.find.mockResolvedValue(expectedPatient)\n@@ -202,7 +207,7 @@ describe('patients slice', () => {\nconst dispatch = jest.fn()\nconst getState = jest.fn()\njest.spyOn(PatientRepository, 'find')\n- const expectedPatientId = '12345'\n+ const expectedPatientId = 'sliceId7'\nconst expectedPatient = { id: expectedPatientId } as Patient\nconst mockedPatientRepository = mocked(PatientRepository, true)\nmockedPatientRepository.find.mockResolvedValue(expectedPatient)\n@@ -217,7 +222,7 @@ describe('patients slice', () => {\nconst dispatch = jest.fn()\nconst getState = jest.fn()\njest.spyOn(PatientRepository, 'find')\n- const expectedPatientId = '12345'\n+ const expectedPatientId = 'sliceId8'\nconst expectedPatient = { id: expectedPatientId } as Patient\nconst mockedPatientRepository = mocked(PatientRepository, true)\nmockedPatientRepository.find.mockResolvedValue(expectedPatient)\n@@ -238,7 +243,7 @@ describe('patients slice', () => {\nconst dispatch = jest.fn()\nconst getState = jest.fn()\njest.spyOn(PatientRepository, 'saveOrUpdate')\n- const expectedPatientId = '12345'\n+ const expectedPatientId = 'sliceId9'\nconst expectedPatient = { id: expectedPatientId } as Patient\nconst mockedPatientRepository = mocked(PatientRepository, true)\nmockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedPatient)\n@@ -252,7 +257,7 @@ describe('patients slice', () => {\nconst dispatch = jest.fn()\nconst getState = jest.fn()\njest.spyOn(PatientRepository, 'saveOrUpdate')\n- const expectedPatientId = '12345'\n+ const expectedPatientId = 'sliceId10'\nconst expectedPatient = { id: expectedPatientId } as Patient\nconst mockedPatientRepository = mocked(PatientRepository, true)\nmockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedPatient)\n@@ -266,7 +271,7 @@ describe('patients slice', () => {\nconst dispatch = jest.fn()\nconst getState = jest.fn()\njest.spyOn(PatientRepository, 'saveOrUpdate')\n- const expectedPatientId = '12345'\n+ const expectedPatientId = 'sliceId11'\nconst expectedPatient = { id: expectedPatientId } as Patient\nconst mockedPatientRepository = mocked(PatientRepository, true)\nmockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedPatient)\n@@ -281,7 +286,7 @@ describe('patients slice', () => {\nit('should call the Toaster function with the correct data', async () => {\njest.spyOn(components, 'Toast')\n- const expectedPatientId = '12345'\n+ const expectedPatientId = 'sliceId11'\nconst fullName = 'John Doe II'\nconst expectedPatient = {\nid: expectedPatientId,\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(test): cleaned up id and fixed test with sequential insert |
288,323 | 18.02.2020 22:38:31 | 21,600 | 55b5fbd58e47f331731aa611d5c08f38438d8890 | fix(test): fix warning about missing key | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/list/Patients.test.tsx",
"new_path": "src/__tests__/patients/list/Patients.test.tsx",
"diff": "@@ -16,7 +16,7 @@ const middlewares = [thunk]\nconst mockStore = configureStore(middlewares)\ndescribe('Patients', () => {\n- const patients = [{ fullName: 'test test', friendlyId: 'P12345' }]\n+ const patients = [{ id: '123', fullName: 'test test', friendlyId: 'P12345' }]\nconst mockedPatientRepository = mocked(PatientRepository, true)\nconst setup = (isLoading?: boolean) => {\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(test): fix warning about missing key |
288,323 | 07.02.2020 17:16:05 | 21,600 | af22ce043a3749db36deb52646cf2530a6662b10 | feat(toolbar): basic button toolbar | [
{
"change_type": "MODIFY",
"old_path": "src/HospitalRun.tsx",
"new_path": "src/HospitalRun.tsx",
"diff": "@@ -5,6 +5,8 @@ import { Toaster } from '@hospitalrun/components'\nimport Appointments from 'scheduling/appointments/Appointments'\nimport NewAppointment from 'scheduling/appointments/new/NewAppointment'\nimport ViewAppointment from 'scheduling/appointments/view/ViewAppointment'\n+import { ButtonBarProvider } from 'page-header/button-bar-context'\n+import ButtonToolBar from 'page-header/ButtonToolBar'\nimport Sidebar from './components/Sidebar'\nimport Permissions from './model/Permissions'\nimport Dashboard from './dashboard/Dashboard'\n@@ -19,15 +21,18 @@ import PrivateRoute from './components/PrivateRoute'\nconst HospitalRun = () => {\nconst { title } = useSelector((state: RootState) => state.title)\nconst { permissions } = useSelector((state: RootState) => state.user)\n+\nreturn (\n<div>\n<Navbar />\n<div className=\"container-fluid\">\n<Sidebar />\n+ <ButtonBarProvider>\n<div className=\"row\">\n<main role=\"main\" className=\"col-md-9 ml-sm-auto col-lg-10 px-4\">\n<div className=\"d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom\">\n<h1 className=\"h2\">{title}</h1>\n+ <ButtonToolBar />\n</div>\n<div>\n<Switch>\n@@ -81,6 +86,7 @@ const HospitalRun = () => {\n<Toaster autoClose={5000} hideProgressBar draggable />\n</main>\n</div>\n+ </ButtonBarProvider>\n</div>\n</div>\n)\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/page-header/ButtonToolBar.tsx",
"diff": "+import React from 'react'\n+import { useButtons } from './button-bar-context'\n+\n+const ButtonToolBar = () => {\n+ const buttons = useButtons()\n+ return <>{buttons.map((button) => button)}</>\n+}\n+\n+export default ButtonToolBar\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/page-header/button-bar-context.tsx",
"diff": "+import React, { useState } from 'react'\n+\n+type Props = {\n+ children: React.ReactNode\n+}\n+\n+type ButtonUpdater = (buttons: React.ReactNode[]) => void\n+\n+const ButtonBarStateContext = React.createContext<React.ReactNode[]>([])\n+const ButtonBarUpdateContext = React.createContext<ButtonUpdater>(() => {})\n+\n+function ButtonBarProvider(props: Props) {\n+ const { children } = props\n+ const [state, setState] = useState<React.ReactNode[]>([])\n+ return (\n+ <ButtonBarStateContext.Provider value={state}>\n+ <ButtonBarUpdateContext.Provider value={setState}>{children}</ButtonBarUpdateContext.Provider>\n+ </ButtonBarStateContext.Provider>\n+ )\n+}\n+function useButtons() {\n+ const context = React.useContext(ButtonBarStateContext)\n+ if (context === undefined) {\n+ throw new Error('useCountState must be used within a CountProvider')\n+ }\n+ return context\n+}\n+function useButtonToolbarSetter() {\n+ const context = React.useContext(ButtonBarUpdateContext)\n+ if (context === undefined) {\n+ throw new Error('useCountDispatch must be used within a CountProvider')\n+ }\n+ return context\n+}\n+\n+export { ButtonBarProvider, useButtons, useButtonToolbarSetter }\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/list/Patients.tsx",
"new_path": "src/patients/list/Patients.tsx",
"diff": "@@ -3,6 +3,7 @@ import { useSelector, useDispatch } from 'react-redux'\nimport { useHistory } from 'react-router'\nimport { useTranslation } from 'react-i18next'\nimport { Spinner, TextInput, Button, List, ListItem, Container, Row } from '@hospitalrun/components'\n+import { useButtonToolbarSetter } from 'page-header/button-bar-context'\nimport { RootState } from '../../store'\nimport { fetchPatients, searchPatients } from '../patients-slice'\nimport useTitle from '../../page-header/useTitle'\n@@ -14,11 +15,27 @@ const Patients = () => {\nconst dispatch = useDispatch()\nconst { patients, isLoading } = useSelector((state: RootState) => state.patients)\n+ const setButtonToolBar = useButtonToolbarSetter()\n+ setButtonToolBar([\n+ <Button\n+ outlined\n+ color=\"success\"\n+ icon=\"patient-add\"\n+ onClick={() => history.push('/patients/new')}\n+ >\n+ {t('patients.newPatient')}\n+ </Button>,\n+ ])\n+\nconst [searchText, setSearchText] = useState<string>('')\nuseEffect(() => {\ndispatch(fetchPatients())\n- }, [dispatch])\n+\n+ return () => {\n+ setButtonToolBar([])\n+ }\n+ }, [dispatch, setButtonToolBar])\nif (isLoading) {\nreturn <Spinner color=\"blue\" loading size={[10, 25]} type=\"ScaleLoader\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/Appointments.tsx",
"new_path": "src/scheduling/appointments/Appointments.tsx",
"diff": "import React, { useEffect, useState } from 'react'\n-import { Calendar } from '@hospitalrun/components'\n+import { Calendar, Button } from '@hospitalrun/components'\nimport useTitle from 'page-header/useTitle'\nimport { useTranslation } from 'react-i18next'\nimport { useSelector, useDispatch } from 'react-redux'\nimport { RootState } from 'store'\nimport { useHistory } from 'react-router'\nimport PatientRepository from 'clients/db/PatientRepository'\n+import { useButtonToolbarSetter } from 'page-header/button-bar-context'\nimport { fetchAppointments } from './appointments-slice'\ninterface Event {\n@@ -23,10 +24,25 @@ const Appointments = () => {\nconst dispatch = useDispatch()\nconst { appointments } = useSelector((state: RootState) => state.appointments)\nconst [events, setEvents] = useState<Event[]>([])\n+ const setButtonToolBar = useButtonToolbarSetter()\n+ setButtonToolBar([\n+ <Button\n+ outlined\n+ color=\"success\"\n+ icon=\"appointment-add\"\n+ onClick={() => history.push('/appointments/new')}\n+ >\n+ New Appointment\n+ </Button>,\n+ ])\nuseEffect(() => {\ndispatch(fetchAppointments())\n- }, [dispatch])\n+\n+ return () => {\n+ setButtonToolBar([])\n+ }\n+ }, [dispatch, setButtonToolBar])\nuseEffect(() => {\nconst getAppointments = async () => {\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(toolbar): basic button toolbar |
288,323 | 17.02.2020 23:42:29 | 21,600 | 0e56e3c0398480235cecc226409e83a40ff4b3da | feat(toolbar): add tests for button toolbar | [
{
"change_type": "MODIFY",
"old_path": "src/HospitalRun.tsx",
"new_path": "src/HospitalRun.tsx",
"diff": "@@ -5,7 +5,7 @@ import { Toaster } from '@hospitalrun/components'\nimport Appointments from 'scheduling/appointments/Appointments'\nimport NewAppointment from 'scheduling/appointments/new/NewAppointment'\nimport ViewAppointment from 'scheduling/appointments/view/ViewAppointment'\n-import { ButtonBarProvider } from 'page-header/button-bar-context'\n+import { ButtonBarProvider } from 'page-header/ButtonBarProvider'\nimport ButtonToolBar from 'page-header/ButtonToolBar'\nimport Sidebar from './components/Sidebar'\nimport Permissions from './model/Permissions'\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/page-header/ButtonBarProvider.test.tsx",
"diff": "+import '../../__mocks__/matchMediaMock'\n+import React from 'react'\n+import { renderHook } from '@testing-library/react-hooks'\n+import {\n+ ButtonBarProvider,\n+ useButtons,\n+ useButtonToolbarSetter,\n+} from 'page-header/ButtonBarProvider'\n+import { Button } from '@hospitalrun/components'\n+\n+describe('Button Bar Provider', () => {\n+ it('should update and fetch data from the button bar provider', () => {\n+ const expectedButtons = [<Button>test 1</Button>]\n+ const wrapper = ({ children }: any) => <ButtonBarProvider>{children}</ButtonBarProvider>\n+\n+ const { result } = renderHook(\n+ () => {\n+ const update = useButtonToolbarSetter()\n+ update(expectedButtons)\n+ return useButtons()\n+ },\n+ { wrapper },\n+ )\n+\n+ expect(result.current).toEqual(expectedButtons)\n+ })\n+})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/page-header/ButtonToolBar.test.tsx",
"diff": "+import '../../__mocks__/matchMediaMock'\n+import React from 'react'\n+import { Button } from '@hospitalrun/components'\n+import { mocked } from 'ts-jest/utils'\n+import { mount } from 'enzyme'\n+import * as ButtonBarProvider from '../../page-header/ButtonBarProvider'\n+import ButtonToolBar from '../../page-header/ButtonToolBar'\n+\n+describe('Button Tool Bar', () => {\n+ beforeEach(() => {\n+ jest.resetAllMocks()\n+ })\n+\n+ it('should render the buttons in the provider', () => {\n+ const buttons: React.ReactNode[] = [<Button>Test 1</Button>, <Button>Test</Button>]\n+ jest.spyOn(ButtonBarProvider, 'useButtons')\n+ mocked(ButtonBarProvider).useButtons.mockReturnValue(buttons)\n+\n+ const wrapper = mount(<ButtonToolBar />)\n+\n+ expect(wrapper.childAt(0).getElement()).toEqual(buttons[0])\n+ expect(wrapper.childAt(1).getElement()).toEqual(buttons[1])\n+ })\n+})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/list/Patients.test.tsx",
"new_path": "src/__tests__/patients/list/Patients.test.tsx",
"diff": "@@ -8,6 +8,7 @@ import thunk from 'redux-thunk'\nimport configureStore from 'redux-mock-store'\nimport { mocked } from 'ts-jest/utils'\nimport { act } from 'react-dom/test-utils'\n+import * as ButtonBarProvider from 'page-header/ButtonBarProvider'\nimport Patients from '../../../patients/list/Patients'\nimport PatientRepository from '../../../clients/db/PatientRepository'\nimport * as patientSlice from '../../../patients/patients-slice'\n@@ -42,6 +43,10 @@ describe('Patients', () => {\n})\ndescribe('layout', () => {\n+ afterEach(() => {\n+ jest.restoreAllMocks()\n+ })\n+\nit('should render a search input with button', () => {\nconst wrapper = setup()\nconst searchInput = wrapper.find(TextInput)\n@@ -66,6 +71,17 @@ describe('Patients', () => {\n`${patients[0].fullName} (${patients[0].friendlyId})`,\n)\n})\n+\n+ it('should add a \"New Patient\" button to the button tool bar', () => {\n+ jest.spyOn(ButtonBarProvider, 'useButtonToolbarSetter')\n+ const setButtonToolBarSpy = jest.fn()\n+ mocked(ButtonBarProvider).useButtonToolbarSetter.mockReturnValue(setButtonToolBarSpy)\n+\n+ setup()\n+\n+ const actualButtons: React.ReactNode[] = setButtonToolBarSpy.mock.calls[0][0]\n+ expect((actualButtons[0] as any).props.children).toEqual('patients.newPatient')\n+ })\n})\ndescribe('search functionality', () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/scheduling/appointments/Appointments.test.tsx",
"new_path": "src/__tests__/scheduling/appointments/Appointments.test.tsx",
"diff": "@@ -11,6 +11,7 @@ import { act } from '@testing-library/react'\nimport PatientRepository from 'clients/db/PatientRepository'\nimport { mocked } from 'ts-jest/utils'\nimport Patient from 'model/Patient'\n+import * as ButtonBarProvider from 'page-header/ButtonBarProvider'\nimport * as titleUtil from '../../../page-header/useTitle'\ndescribe('Appointments', () => {\n@@ -51,6 +52,19 @@ describe('Appointments', () => {\nexpect(titleUtil.default).toHaveBeenCalledWith('scheduling.appointments.label')\n})\n+ it('should add a \"New Appointment\" button to the button tool bar', async () => {\n+ jest.spyOn(ButtonBarProvider, 'useButtonToolbarSetter')\n+ const setButtonToolBarSpy = jest.fn()\n+ mocked(ButtonBarProvider).useButtonToolbarSetter.mockReturnValue(setButtonToolBarSpy)\n+\n+ await act(async () => {\n+ await setup()\n+ })\n+\n+ const actualButtons: React.ReactNode[] = setButtonToolBarSpy.mock.calls[0][0]\n+ expect((actualButtons[0] as any).props.children).toEqual('scheduling.appointments.new')\n+ })\n+\nit('should render a calendar with the proper events', async () => {\nlet wrapper: any\nawait act(async () => {\n"
},
{
"change_type": "RENAME",
"old_path": "src/page-header/button-bar-context.tsx",
"new_path": "src/page-header/ButtonBarProvider.tsx",
"diff": "import React, { useState } from 'react'\ntype Props = {\n- children: React.ReactNode\n+ children?: React.ReactNode\n}\ntype ButtonUpdater = (buttons: React.ReactNode[]) => void\n@@ -19,16 +19,19 @@ function ButtonBarProvider(props: Props) {\n)\n}\nfunction useButtons() {\n+ console.log('use buttons')\nconst context = React.useContext(ButtonBarStateContext)\n+ console.log('bug')\n+ console.log(context)\nif (context === undefined) {\n- throw new Error('useCountState must be used within a CountProvider')\n+ throw new Error('useButtons must be used within a Button Bar Context')\n}\nreturn context\n}\nfunction useButtonToolbarSetter() {\nconst context = React.useContext(ButtonBarUpdateContext)\nif (context === undefined) {\n- throw new Error('useCountDispatch must be used within a CountProvider')\n+ throw new Error('useButtonToolBarSetter must be used within a Button Bar Context')\n}\nreturn context\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/page-header/ButtonToolBar.tsx",
"new_path": "src/page-header/ButtonToolBar.tsx",
"diff": "import React from 'react'\n-import { useButtons } from './button-bar-context'\n+import { useButtons } from './ButtonBarProvider'\nconst ButtonToolBar = () => {\nconst buttons = useButtons()\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/list/Patients.tsx",
"new_path": "src/patients/list/Patients.tsx",
"diff": "@@ -3,7 +3,7 @@ import { useSelector, useDispatch } from 'react-redux'\nimport { useHistory } from 'react-router'\nimport { useTranslation } from 'react-i18next'\nimport { Spinner, TextInput, Button, List, ListItem, Container, Row } from '@hospitalrun/components'\n-import { useButtonToolbarSetter } from 'page-header/button-bar-context'\n+import { useButtonToolbarSetter } from 'page-header/ButtonBarProvider'\nimport { RootState } from '../../store'\nimport { fetchPatients, searchPatients } from '../patients-slice'\nimport useTitle from '../../page-header/useTitle'\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/Appointments.tsx",
"new_path": "src/scheduling/appointments/Appointments.tsx",
"diff": "@@ -6,7 +6,7 @@ import { useSelector, useDispatch } from 'react-redux'\nimport { RootState } from 'store'\nimport { useHistory } from 'react-router'\nimport PatientRepository from 'clients/db/PatientRepository'\n-import { useButtonToolbarSetter } from 'page-header/button-bar-context'\n+import { useButtonToolbarSetter } from 'page-header/ButtonBarProvider'\nimport { fetchAppointments } from './appointments-slice'\ninterface Event {\n@@ -32,7 +32,7 @@ const Appointments = () => {\nicon=\"appointment-add\"\nonClick={() => history.push('/appointments/new')}\n>\n- New Appointment\n+ {t('scheduling.appointments.new')}\n</Button>,\n])\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(toolbar): add tests for button toolbar |
288,323 | 17.02.2020 23:54:40 | 21,600 | 450b8cd2f864ce25068f97aef0f6b4616a8b0a2b | feat(toolbar): change edit patient to toolbar button | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/page-header/ButtonToolBar.test.tsx",
"new_path": "src/__tests__/page-header/ButtonToolBar.test.tsx",
"diff": "@@ -12,7 +12,10 @@ describe('Button Tool Bar', () => {\n})\nit('should render the buttons in the provider', () => {\n- const buttons: React.ReactNode[] = [<Button>Test 1</Button>, <Button>Test</Button>]\n+ const buttons: React.ReactNode[] = [\n+ <Button key=\"test1\">Test 1</Button>,\n+ <Button key=\"test2\">Test 2</Button>,\n+ ]\njest.spyOn(ButtonBarProvider, 'useButtons')\nmocked(ButtonBarProvider).useButtons.mockReturnValue(buttons)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/view/ViewPatient.test.tsx",
"new_path": "src/__tests__/patients/view/ViewPatient.test.tsx",
"diff": "@@ -11,6 +11,7 @@ import thunk from 'redux-thunk'\nimport GeneralInformation from 'patients/GeneralInformation'\nimport { createMemoryHistory } from 'history'\nimport RelatedPersonTab from 'patients/related-persons/RelatedPersonTab'\n+import * as ButtonBarProvider from 'page-header/ButtonBarProvider'\nimport Patient from '../../../model/Patient'\nimport PatientRepository from '../../../clients/db/PatientRepository'\nimport * as titleUtil from '../../../page-header/useTitle'\n@@ -71,25 +72,6 @@ describe('ViewPatient', () => {\njest.restoreAllMocks()\n})\n- it('should navigate to /patients/edit/:id when edit is clicked', async () => {\n- let wrapper: any\n- await act(async () => {\n- wrapper = await setup()\n- })\n-\n- wrapper.update()\n-\n- const editButton = wrapper.find(Button).at(3)\n- const onClick = editButton.prop('onClick') as any\n- expect(editButton.text().trim()).toEqual('actions.edit')\n-\n- act(() => {\n- onClick()\n- })\n-\n- expect(history.location.pathname).toEqual('/patients/edit/123')\n- })\n-\nit('should dispatch fetchPatient when component loads', async () => {\nawait act(async () => {\nawait setup()\n@@ -110,6 +92,17 @@ describe('ViewPatient', () => {\n)\n})\n+ it('should add a \"Edit Patient\" button to the button tool bar', () => {\n+ jest.spyOn(ButtonBarProvider, 'useButtonToolbarSetter')\n+ const setButtonToolBarSpy = jest.fn()\n+ mocked(ButtonBarProvider).useButtonToolbarSetter.mockReturnValue(setButtonToolBarSpy)\n+\n+ setup()\n+\n+ const actualButtons: React.ReactNode[] = setButtonToolBarSpy.mock.calls[0][0]\n+ expect((actualButtons[0] as any).props.children).toEqual('actions.edit')\n+ })\n+\nit('should render a tabs header with the correct tabs', async () => {\nlet wrapper: any\nawait act(async () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/page-header/ButtonBarProvider.tsx",
"new_path": "src/page-header/ButtonBarProvider.tsx",
"diff": "@@ -7,7 +7,9 @@ type Props = {\ntype ButtonUpdater = (buttons: React.ReactNode[]) => void\nconst ButtonBarStateContext = React.createContext<React.ReactNode[]>([])\n-const ButtonBarUpdateContext = React.createContext<ButtonUpdater>(() => {})\n+const ButtonBarUpdateContext = React.createContext<ButtonUpdater>(() => {\n+ // empty initial state\n+})\nfunction ButtonBarProvider(props: Props) {\nconst { children } = props\n@@ -19,10 +21,7 @@ function ButtonBarProvider(props: Props) {\n)\n}\nfunction useButtons() {\n- console.log('use buttons')\nconst context = React.useContext(ButtonBarStateContext)\n- console.log('bug')\n- console.log(context)\nif (context === undefined) {\nthrow new Error('useButtons must be used within a Button Bar Context')\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/list/Patients.tsx",
"new_path": "src/patients/list/Patients.tsx",
"diff": "@@ -18,6 +18,7 @@ const Patients = () => {\nconst setButtonToolBar = useButtonToolbarSetter()\nsetButtonToolBar([\n<Button\n+ key=\"newPatientButton\"\noutlined\ncolor=\"success\"\nicon=\"patient-add\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/view/ViewPatient.tsx",
"new_path": "src/patients/view/ViewPatient.tsx",
"diff": "@@ -4,6 +4,7 @@ import { useParams, withRouter, Route, useHistory, useLocation } from 'react-rou\nimport { Panel, Spinner, TabsHeader, Tab, Button } from '@hospitalrun/components'\nimport { useTranslation } from 'react-i18next'\n+import { useButtonToolbarSetter } from 'page-header/ButtonBarProvider'\nimport useTitle from '../../page-header/useTitle'\nimport { fetchPatient } from '../patient-slice'\nimport { RootState } from '../../store'\n@@ -31,12 +32,31 @@ const ViewPatient = () => {\nuseTitle(`${getPatientFullName(patient)} (${getFriendlyId(patient)})`)\n+ const setButtonToolBar = useButtonToolbarSetter()\n+ setButtonToolBar([\n+ <Button\n+ key=\"editPatientButton\"\n+ color=\"success\"\n+ icon=\"edit\"\n+ outlined\n+ onClick={() => {\n+ history.push(`/patients/edit/${patient.id}`)\n+ }}\n+ >\n+ {t('actions.edit')}\n+ </Button>,\n+ ])\n+\nconst { id } = useParams()\nuseEffect(() => {\nif (id) {\ndispatch(fetchPatient(id))\n}\n- }, [dispatch, id])\n+\n+ return () => {\n+ setButtonToolBar([])\n+ }\n+ }, [dispatch, id, setButtonToolBar])\nif (isLoading || !patient) {\nreturn <Spinner color=\"blue\" loading size={[10, 25]} type=\"ScaleLoader\" />\n@@ -63,21 +83,6 @@ const ViewPatient = () => {\n</TabsHeader>\n<Panel>\n<Route exact path=\"/patients/:id\">\n- <div className=\"row\">\n- <div className=\"col-md-12 d-flex justify-content-end\">\n- <Button\n- color=\"success\"\n- outlined\n- icon=\"edit\"\n- onClick={() => {\n- history.push(`/patients/edit/${patient.id}`)\n- }}\n- >\n- {t('actions.edit')}\n- </Button>\n- </div>\n- </div>\n- <br />\n<GeneralInformation patient={patient} />\n</Route>\n<Route exact path=\"/patients/:id/relatedpersons\">\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/Appointments.tsx",
"new_path": "src/scheduling/appointments/Appointments.tsx",
"diff": "@@ -27,6 +27,7 @@ const Appointments = () => {\nconst setButtonToolBar = useButtonToolbarSetter()\nsetButtonToolBar([\n<Button\n+ key=\"newAppointmentButton\"\noutlined\ncolor=\"success\"\nicon=\"appointment-add\"\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(toolbar): change edit patient to toolbar button |
288,337 | 20.02.2020 20:31:55 | -3,600 | beffc1f059c748e880b9f76766c955d8e5094f08 | feat(breadcrumb): add the dashboard breadcrumb item
add the dashboard item for all the breacrumbs, don't display the breadcrumb for the Dashboard page | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/HospitalRun.test.tsx",
"new_path": "src/__tests__/HospitalRun.test.tsx",
"diff": "@@ -47,6 +47,7 @@ describe('HospitalRun', () => {\naddBreadcrumbs([\n{ i18nKey: 'patients.label', location: '/patients' },\n{ i18nKey: 'patients.newPatient', location: '/patients/new' },\n+ { i18nKey: 'dashboard.label', location: '/' },\n]),\n)\n})\n@@ -107,6 +108,7 @@ describe('HospitalRun', () => {\n{ i18nKey: 'patients.label', location: '/patients' },\n{ text: 'test test test', location: `/patients/${patient.id}` },\n{ i18nKey: 'patients.editPatient', location: `/patients/${patient.id}/edit` },\n+ { i18nKey: 'dashboard.label', location: '/' },\n]),\n)\n})\n@@ -184,6 +186,7 @@ describe('HospitalRun', () => {\naddBreadcrumbs([\n{ i18nKey: 'patients.label', location: '/patients' },\n{ text: 'test test test', location: `/patients/${patient.id}` },\n+ { i18nKey: 'dashboard.label', location: '/' },\n]),\n)\n})\n@@ -231,7 +234,10 @@ describe('HospitalRun', () => {\nexpect(wrapper.find(Appointments)).toHaveLength(1)\nexpect(store.getActions()).toContainEqual(\n- addBreadcrumbs([{ i18nKey: 'scheduling.appointments.label', location: '/appointments' }]),\n+ addBreadcrumbs([\n+ { i18nKey: 'scheduling.appointments.label', location: '/appointments' },\n+ { i18nKey: 'dashboard.label', location: '/' },\n+ ]),\n)\n})\n@@ -277,6 +283,7 @@ describe('HospitalRun', () => {\naddBreadcrumbs([\n{ i18nKey: 'scheduling.appointments.label', location: '/appointments' },\n{ i18nKey: 'scheduling.appointments.new', location: '/appointments/new' },\n+ { i18nKey: 'dashboard.label', location: '/' },\n]),\n)\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/breadcrumbs/Breadcrumbs.test.tsx",
"new_path": "src/__tests__/breadcrumbs/Breadcrumbs.test.tsx",
"diff": "@@ -5,7 +5,10 @@ import { mount } from 'enzyme'\nimport { createMemoryHistory } from 'history'\nimport { Router } from 'react-router-dom'\nimport configureMockStore from 'redux-mock-store'\n-import { BreadcrumbItem } from '@hospitalrun/components'\n+import {\n+ Breadcrumb as HRBreadcrumb,\n+ BreadcrumbItem as HRBreadcrumbItem,\n+} from '@hospitalrun/components'\nimport Breadcrumbs from 'breadcrumbs/Breadcrumbs'\nimport Breadcrumb from 'model/Breadcrumb'\n@@ -30,6 +33,12 @@ describe('Breadcrumbs', () => {\nreturn wrapper\n}\n+ it('should not render the breadcrumb when there is no items in the store', () => {\n+ const wrapper = setup([])\n+\n+ expect(wrapper.find(HRBreadcrumb)).toHaveLength(0)\n+ })\n+\nit('should render breadcrumbs items', () => {\nconst breadcrumbs = [\n{ i18nKey: 'patient.label', location: '/patient' },\n@@ -38,7 +47,7 @@ describe('Breadcrumbs', () => {\n]\nconst wrapper = setup(breadcrumbs)\n- const items = wrapper.find(BreadcrumbItem)\n+ const items = wrapper.find(HRBreadcrumbItem)\nexpect(items).toHaveLength(3)\nexpect(items.at(0).text()).toEqual('patient.label')\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/breadcrumbs/useAddBreadcrumbs.test.tsx",
"new_path": "src/__tests__/breadcrumbs/useAddBreadcrumbs.test.tsx",
"diff": "@@ -26,6 +26,25 @@ describe('useAddBreadcrumbs', () => {\nexpect(breadcrumbsSlice.addBreadcrumbs).toHaveBeenCalledWith(breadcrumbs)\n})\n+ it('should call addBreadcrumbs with an additional dashboard breadcrumb', () => {\n+ const wrapper = ({ children }: any) => <Provider store={store({})}>{children}</Provider>\n+\n+ jest.spyOn(breadcrumbsSlice, 'addBreadcrumbs')\n+ const breadcrumbs = [\n+ {\n+ text: 'Patients',\n+ location: '/patients',\n+ },\n+ ]\n+\n+ renderHook(() => useAddBreadcrumbs(breadcrumbs, true), { wrapper } as any)\n+ expect(breadcrumbsSlice.addBreadcrumbs).toHaveBeenCalledTimes(1)\n+ expect(breadcrumbsSlice.addBreadcrumbs).toHaveBeenCalledWith([\n+ ...breadcrumbs,\n+ { i18nKey: 'dashboard.label', location: '/' },\n+ ])\n+ })\n+\nit('should call removeBreadcrumbs with the correct data after unmount', () => {\nconst wrapper = ({ children }: any) => <Provider store={store({})}>{children}</Provider>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/breadcrumbs/Breadcrumbs.tsx",
"new_path": "src/breadcrumbs/Breadcrumbs.tsx",
"diff": "@@ -10,6 +10,10 @@ const Breadcrumbs = () => {\nconst { t } = useTranslation()\nconst { breadcrumbs } = useSelector((state: RootState) => state.breadcrumbs)\n+ if (breadcrumbs.length === 0) {\n+ return null\n+ }\n+\nreturn (\n<Breadcrumb>\n{breadcrumbs.map(({ i18nKey, text, location }, index) => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/breadcrumbs/useAddBreadcrumbs.ts",
"new_path": "src/breadcrumbs/useAddBreadcrumbs.ts",
"diff": "@@ -3,12 +3,15 @@ import { useDispatch } from 'react-redux'\nimport Breadcrumb from 'model/Breadcrumb'\nimport { addBreadcrumbs, removeBreadcrumbs } from './breadcrumbs-slice'\n-export default function useAddBreadcrumbs(breadcrumbs: Breadcrumb[]): void {\n+export default function useAddBreadcrumbs(breadcrumbs: Breadcrumb[], withDashboard = false): void {\nconst dispatch = useDispatch()\n- const breadcrumbsStringified = JSON.stringify(breadcrumbs)\n+\n+ const breadcrumbsStringified = withDashboard\n+ ? JSON.stringify([...breadcrumbs, { i18nKey: 'dashboard.label', location: '/' }])\n+ : JSON.stringify(breadcrumbs)\nuseEffect(() => {\n- const breadcrumbsParsed = JSON.parse(breadcrumbsStringified)\n+ const breadcrumbsParsed: Breadcrumb[] = JSON.parse(breadcrumbsStringified)\ndispatch(addBreadcrumbs(breadcrumbsParsed))\nreturn () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/dashboard/Dashboard.tsx",
"new_path": "src/dashboard/Dashboard.tsx",
"diff": "import React from 'react'\nimport { useTranslation } from 'react-i18next'\nimport useTitle from '../page-header/useTitle'\n-import useAddBreadcrumbs from '../breadcrumbs/useAddBreadcrumbs'\n-\n-const breadcrumbs = [{ i18nKey: 'dashboard.label', location: '/' }]\nconst Dashboard: React.FC = () => {\nconst { t } = useTranslation()\nuseTitle(t('dashboard.label'))\n- useAddBreadcrumbs(breadcrumbs)\nreturn <h3>Example</h3>\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/edit/EditPatient.tsx",
"new_path": "src/patients/edit/EditPatient.tsx",
"diff": "@@ -40,7 +40,7 @@ const EditPatient = () => {\n{ text: getPatientFullName(reduxPatient), location: `/patients/${reduxPatient.id}` },\n{ i18nKey: 'patients.editPatient', location: `/patients/${reduxPatient.id}/edit` },\n]\n- useAddBreadcrumbs(breadcrumbs)\n+ useAddBreadcrumbs(breadcrumbs, true)\nuseEffect(() => {\nsetPatient(reduxPatient)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/list/Patients.tsx",
"new_path": "src/patients/list/Patients.tsx",
"diff": "@@ -14,7 +14,7 @@ const Patients = () => {\nconst { t } = useTranslation()\nconst history = useHistory()\nuseTitle(t('patients.label'))\n- useAddBreadcrumbs(breadcrumbs)\n+ useAddBreadcrumbs(breadcrumbs, true)\nconst dispatch = useDispatch()\nconst { patients, isLoading } = useSelector((state: RootState) => state.patients)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/new/NewPatient.tsx",
"new_path": "src/patients/new/NewPatient.tsx",
"diff": "@@ -25,7 +25,7 @@ const NewPatient = () => {\nconst [errorMessage, setErrorMessage] = useState('')\nuseTitle(t('patients.newPatient'))\n- useAddBreadcrumbs(breadcrumbs)\n+ useAddBreadcrumbs(breadcrumbs, true)\nconst onCancel = () => {\nhistory.push('/patients')\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/view/ViewPatient.tsx",
"new_path": "src/patients/view/ViewPatient.tsx",
"diff": "@@ -36,7 +36,7 @@ const ViewPatient = () => {\n{ i18nKey: 'patients.label', location: '/patients' },\n{ text: getPatientFullName(patient), location: `/patients/${patient.id}` },\n]\n- useAddBreadcrumbs(breadcrumbs)\n+ useAddBreadcrumbs(breadcrumbs, true)\nconst { id } = useParams()\nuseEffect(() => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/Appointments.tsx",
"new_path": "src/scheduling/appointments/Appointments.tsx",
"diff": "@@ -23,7 +23,7 @@ const Appointments = () => {\nconst { t } = useTranslation()\nconst history = useHistory()\nuseTitle(t('scheduling.appointments.label'))\n- useAddBreadcrumbs(breadcrumbs)\n+ useAddBreadcrumbs(breadcrumbs, true)\nconst dispatch = useDispatch()\nconst { appointments } = useSelector((state: RootState) => state.appointments)\nconst [events, setEvents] = useState<Event[]>([])\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/new/NewAppointment.tsx",
"new_path": "src/scheduling/appointments/new/NewAppointment.tsx",
"diff": "@@ -22,7 +22,7 @@ const NewAppointment = () => {\nconst history = useHistory()\nconst dispatch = useDispatch()\nuseTitle(t('scheduling.appointments.new'))\n- useAddBreadcrumbs(breadcrumbs)\n+ useAddBreadcrumbs(breadcrumbs, true)\nconst startDateTime = roundToNearestMinutes(new Date(), { nearestTo: 15 })\nconst endDateTime = addMinutes(startDateTime, 60)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/view/ViewAppointment.tsx",
"new_path": "src/scheduling/appointments/view/ViewAppointment.tsx",
"diff": "@@ -29,7 +29,7 @@ const ViewAppointment = () => {\n{ i18nKey: 'scheduling.appointments.label', location: '/appointments' },\n{ text: getAppointmentLabel(appointment), location: `/patients/${appointment.id}` },\n]\n- useAddBreadcrumbs(breadcrumbs)\n+ useAddBreadcrumbs(breadcrumbs, true)\nuseEffect(() => {\nif (id) {\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(breadcrumb): add the dashboard breadcrumb item
add the dashboard item for all the breacrumbs, don't display the breadcrumb for the Dashboard page |
288,337 | 20.02.2020 20:34:53 | -3,600 | 03174ad959bc8ef6c6e125d09c80cd97ff05aef9 | feat(breadcrumb): improve Breadcrumbs tests | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/breadcrumbs/Breadcrumbs.test.tsx",
"new_path": "src/__tests__/breadcrumbs/Breadcrumbs.test.tsx",
"diff": "@@ -33,10 +33,11 @@ describe('Breadcrumbs', () => {\nreturn wrapper\n}\n- it('should not render the breadcrumb when there is no items in the store', () => {\n+ it('should not render the breadcrumb when there are no items in the store', () => {\nconst wrapper = setup([])\nexpect(wrapper.find(HRBreadcrumb)).toHaveLength(0)\n+ expect(wrapper.find(HRBreadcrumbItem)).toHaveLength(0)\n})\nit('should render breadcrumbs items', () => {\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(breadcrumb): improve Breadcrumbs tests |
288,328 | 21.02.2020 17:26:33 | 21,600 | c22d02b15d596289ebd7e71ab7ca8b8cae0d8b26 | feat(edit appointment): fix lint errors and typo | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/scheduling/appointments/appointments-slice.test.ts",
"new_path": "src/__tests__/scheduling/appointments/appointments-slice.test.ts",
"diff": "@@ -73,7 +73,7 @@ describe('appointments slice', () => {\nexpect(dispatch).toHaveBeenCalledWith({ type: fetchAppointmentsStart.type })\n})\n- it('should call the AppointmentsRepository findAll() function', async () => {\n+ it('should call the AppointmentRepository findAll() function', async () => {\nconst dispatch = jest.fn()\nconst getState = jest.fn()\nawait fetchAppointments()(dispatch, getState, null)\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(edit appointment): fix lint errors and typo |
288,328 | 22.02.2020 14:51:29 | 21,600 | 4744152317b7a550d5eeda2ff6959b7fa2c160ee | feat(edit appointment): use button toolbar, address other PR issues | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/view/ViewPatient.test.tsx",
"new_path": "src/__tests__/patients/view/ViewPatient.test.tsx",
"diff": "@@ -5,7 +5,7 @@ import { mount } from 'enzyme'\nimport { mocked } from 'ts-jest/utils'\nimport { act } from 'react-dom/test-utils'\nimport { Route, Router } from 'react-router-dom'\n-import { TabsHeader, Tab, Button } from '@hospitalrun/components'\n+import { TabsHeader, Tab } from '@hospitalrun/components'\nimport configureMockStore, { MockStore } from 'redux-mock-store'\nimport thunk from 'redux-thunk'\nimport GeneralInformation from 'patients/GeneralInformation'\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/scheduling/appointments/Appointments.test.tsx",
"new_path": "src/__tests__/scheduling/appointments/Appointments.test.tsx",
"diff": "@@ -62,7 +62,9 @@ describe('Appointments', () => {\n})\nconst actualButtons: React.ReactNode[] = setButtonToolBarSpy.mock.calls[0][0]\n- expect((actualButtons[0] as any).props.children).toEqual('scheduling.appointments.new')\n+ expect((actualButtons[0] as any).props.children).toEqual(\n+ 'scheduling.appointments.newAppointment',\n+ )\n})\nit('should render a calendar with the proper events', async () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx",
"new_path": "src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx",
"diff": "@@ -15,6 +15,7 @@ import { Spinner } from '@hospitalrun/components'\nimport AppointmentDetailForm from 'scheduling/appointments/AppointmentDetailForm'\nimport PatientRepository from 'clients/db/PatientRepository'\nimport Patient from 'model/Patient'\n+import * as ButtonBarProvider from 'page-header/ButtonBarProvider'\nimport * as titleUtil from '../../../../page-header/useTitle'\nimport * as appointmentSlice from '../../../../scheduling/appointments/appointment-slice'\n@@ -72,7 +73,7 @@ describe('View Appointment', () => {\n}\nbeforeEach(() => {\n- jest.resetAllMocks()\n+ jest.restoreAllMocks()\n})\nit('should use the correct title', async () => {\n@@ -84,6 +85,17 @@ describe('View Appointment', () => {\nexpect(titleUtil.default).toHaveBeenCalledWith('scheduling.appointments.viewAppointment')\n})\n+ it('should add a \"Edit Appointment\" button to the button tool bar', () => {\n+ jest.spyOn(ButtonBarProvider, 'useButtonToolbarSetter')\n+ const setButtonToolBarSpy = jest.fn()\n+ mocked(ButtonBarProvider).useButtonToolbarSetter.mockReturnValue(setButtonToolBarSpy)\n+\n+ setup(true)\n+\n+ const actualButtons: React.ReactNode[] = setButtonToolBarSpy.mock.calls[0][0]\n+ expect((actualButtons[0] as any).props.children).toEqual('actions.edit')\n+ })\n+\nit('should dispatch getAppointment if id is present', async () => {\nawait act(async () => {\nawait setup(true)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/edit/EditPatient.tsx",
"new_path": "src/patients/edit/EditPatient.tsx",
"diff": "@@ -86,10 +86,10 @@ const EditPatient = () => {\n/>\n<div className=\"row float-right\">\n<div className=\"btn-group btn-group-lg\">\n- <Button className=\"mr-2\" color=\"success\" onClick={() => onSave()}>\n+ <Button className=\"mr-2\" color=\"success\" onClick={onSave}>\n{t('actions.save')}\n</Button>\n- <Button color=\"danger\" onClick={() => onCancel()}>\n+ <Button color=\"danger\" onClick={onCancel}>\n{t('actions.cancel')}\n</Button>\n</div>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/new/NewPatient.tsx",
"new_path": "src/patients/new/NewPatient.tsx",
"diff": "@@ -57,10 +57,10 @@ const NewPatient = () => {\n/>\n<div className=\"row float-right\">\n<div className=\"btn-group btn-group-lg\">\n- <Button className=\"mr-2\" color=\"success\" onClick={() => onSave()}>\n+ <Button className=\"mr-2\" color=\"success\" onClick={onSave}>\n{t('actions.save')}\n</Button>\n- <Button color=\"danger\" onClick={() => onCancel()}>\n+ <Button color=\"danger\" onClick={onCancel}>\n{t('actions.cancel')}\n</Button>\n</div>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/Appointments.tsx",
"new_path": "src/scheduling/appointments/Appointments.tsx",
"diff": "@@ -33,7 +33,7 @@ const Appointments = () => {\nicon=\"appointment-add\"\nonClick={() => history.push('/appointments/new')}\n>\n- {t('scheduling.appointments.new')}\n+ {t('scheduling.appointments.newAppointment')}\n</Button>,\n])\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/edit/EditAppointment.tsx",
"new_path": "src/scheduling/appointments/edit/EditAppointment.tsx",
"diff": "@@ -74,10 +74,10 @@ const EditAppointment = () => {\n/>\n<div className=\"row float-right\">\n<div className=\"btn-group btn-group-lg\">\n- <Button className=\"mr-2\" color=\"success\" onClick={() => onSave()}>\n+ <Button className=\"mr-2\" color=\"success\" onClick={onSave}>\n{t('actions.save')}\n</Button>\n- <Button color=\"danger\" onClick={() => onCancel()}>\n+ <Button color=\"danger\" onClick={onCancel}>\n{t('actions.cancel')}\n</Button>\n</div>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/view/ViewAppointment.tsx",
"new_path": "src/scheduling/appointments/view/ViewAppointment.tsx",
"diff": "@@ -5,6 +5,8 @@ import { RootState } from 'store'\nimport { useParams, useHistory } from 'react-router'\nimport { Spinner, Button } from '@hospitalrun/components'\nimport { useTranslation } from 'react-i18next'\n+\n+import { useButtonToolbarSetter } from 'page-header/ButtonBarProvider'\nimport { fetchAppointment } from '../appointment-slice'\nimport AppointmentDetailForm from '../AppointmentDetailForm'\n@@ -16,35 +18,38 @@ const ViewAppointment = () => {\nconst history = useHistory()\nconst { appointment, patient, isLoading } = useSelector((state: RootState) => state.appointment)\n+ const setButtonToolBar = useButtonToolbarSetter()\n+ console.log('setButtonToolBar was: ')\n+ console.log(setButtonToolBar)\n+ setButtonToolBar([\n+ <Button\n+ key=\"editAppointmentButton\"\n+ color=\"success\"\n+ icon=\"edit\"\n+ outlined\n+ onClick={() => {\n+ history.push(`/appointments/edit/${appointment.id}`)\n+ }}\n+ >\n+ {t('actions.edit')}\n+ </Button>,\n+ ])\n+\nuseEffect(() => {\nif (id) {\ndispatch(fetchAppointment(id))\n}\n- }, [dispatch, id])\n+\n+ return () => {\n+ setButtonToolBar([])\n+ }\n+ }, [dispatch, id, setButtonToolBar])\nif (!appointment.id || isLoading) {\nreturn <Spinner type=\"BarLoader\" loading />\n}\n- return (\n- <div>\n- <div className=\"row\">\n- <div className=\"col-md-12 d-flex justify-content-end\">\n- <Button\n- color=\"success\"\n- outlined\n- icon=\"edit\"\n- onClick={() => {\n- history.push(`/appointments/edit/${appointment.id}`)\n- }}\n- >\n- {t('actions.edit')}\n- </Button>\n- </div>\n- </div>\n- <AppointmentDetailForm appointment={appointment} isEditable={false} patient={patient} />\n- </div>\n- )\n+ return <AppointmentDetailForm appointment={appointment} isEditable={false} patient={patient} />\n}\nexport default ViewAppointment\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(edit appointment): use button toolbar, address other PR issues |
288,328 | 22.02.2020 22:21:19 | 21,600 | 58117b4e245a5fe14bd4e18c44a95e925bcab46f | feat(edit appointment): add tests for Edit Appointment route | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/HospitalRun.test.tsx",
"new_path": "src/__tests__/HospitalRun.test.tsx",
"diff": "@@ -11,11 +11,14 @@ import { act } from 'react-dom/test-utils'\nimport Dashboard from 'dashboard/Dashboard'\nimport Appointments from 'scheduling/appointments/Appointments'\nimport NewAppointment from 'scheduling/appointments/new/NewAppointment'\n+import EditAppointment from 'scheduling/appointments/edit/EditAppointment'\nimport NewPatient from '../patients/new/NewPatient'\nimport EditPatient from '../patients/edit/EditPatient'\nimport ViewPatient from '../patients/view/ViewPatient'\nimport PatientRepository from '../clients/db/PatientRepository'\n+import AppointmentRepository from '../clients/db/AppointmentRepository'\nimport Patient from '../model/Patient'\n+import Appointment from '../model/Appointment'\nimport HospitalRun from '../HospitalRun'\nimport Permissions from '../model/Permissions'\n@@ -217,7 +220,6 @@ describe('HospitalRun', () => {\nexpect(wrapper.find(Dashboard)).toHaveLength(1)\n})\n})\n- })\ndescribe('/appointments/new', () => {\nit('should render the new appointment screen when /appointments/new is accessed', async () => {\n@@ -255,6 +257,76 @@ describe('HospitalRun', () => {\n})\n})\n+ describe('/appointments/edit/:id', () => {\n+ it('should render the edit appointment screen when /appointments/edit/:id is accessed', () => {\n+ jest.spyOn(AppointmentRepository, 'find')\n+ const mockedAppointmentRepository = mocked(AppointmentRepository, true)\n+ const mockedPatientRepository = mocked(PatientRepository, true)\n+ const appointment = {\n+ id: '123',\n+ patientId: '456',\n+ } as Appointment\n+\n+ const patient = {\n+ id: '456',\n+ } as Patient\n+\n+ mockedAppointmentRepository.find.mockResolvedValue(appointment)\n+ mockedPatientRepository.find.mockResolvedValue(patient)\n+\n+ const wrapper = mount(\n+ <Provider\n+ store={mockStore({\n+ title: 'test',\n+ user: { permissions: [Permissions.WriteAppointments, Permissions.ReadAppointments] },\n+ appointment: { appointment: {} as Appointment, patient: {} as Patient },\n+ })}\n+ >\n+ <MemoryRouter initialEntries={['/appointments/edit/123']}>\n+ <HospitalRun />\n+ </MemoryRouter>\n+ </Provider>,\n+ )\n+\n+ expect(wrapper.find(EditAppointment)).toHaveLength(1)\n+ })\n+\n+ it('should render the Dashboard when the user does not have read appointment privileges', () => {\n+ const wrapper = mount(\n+ <Provider\n+ store={mockStore({\n+ title: 'test',\n+ user: { permissions: [Permissions.WriteAppointments] },\n+ })}\n+ >\n+ <MemoryRouter initialEntries={['/appointments/edit/123']}>\n+ <HospitalRun />\n+ </MemoryRouter>\n+ </Provider>,\n+ )\n+\n+ expect(wrapper.find(Dashboard)).toHaveLength(1)\n+ })\n+\n+ it('should render the Dashboard when the user does not have write appointment privileges', () => {\n+ const wrapper = mount(\n+ <Provider\n+ store={mockStore({\n+ title: 'test',\n+ user: { permissions: [Permissions.ReadAppointments] },\n+ })}\n+ >\n+ <MemoryRouter initialEntries={['/appointments/edit/123']}>\n+ <HospitalRun />\n+ </MemoryRouter>\n+ </Provider>,\n+ )\n+\n+ expect(wrapper.find(Dashboard)).toHaveLength(1)\n+ })\n+ })\n+ })\n+\ndescribe('layout', () => {\nit('should render a Toaster', () => {\nconst wrapper = mount(\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(edit appointment): add tests for Edit Appointment route |
288,323 | 23.02.2020 00:25:57 | 21,600 | dcb46b89acb562e982a99531ca006e976f922d17 | feat(delete appointment): adds ability to delete appointment | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/scheduling/appointments/appointment-slice.test.ts",
"new_path": "src/__tests__/scheduling/appointments/appointment-slice.test.ts",
"diff": "+import '../../../__mocks__/matchMediaMock'\nimport { AnyAction } from 'redux'\nimport Appointment from 'model/Appointment'\nimport AppointmentRepository from 'clients/db/AppointmentsRepository'\n+import * as components from '@hospitalrun/components'\nimport { mocked } from 'ts-jest/utils'\nimport PatientRepository from 'clients/db/PatientRepository'\nimport Patient from 'model/Patient'\n+import { createMemoryHistory } from 'history'\nimport appointment, {\nfetchAppointmentStart,\nfetchAppointmentSuccess,\nfetchAppointment,\n+ deleteAppointment,\n+ deleteAppointmentStart,\n+ deleteAppointmentSuccess,\n} from '../../../scheduling/appointments/appointment-slice'\ndescribe('appointment slice', () => {\n@@ -46,6 +52,22 @@ describe('appointment slice', () => {\nexpect(appointmentStore.appointment).toEqual(expectedAppointment)\nexpect(appointmentStore.patient).toEqual(expectedPatient)\n})\n+\n+ it('should handle the DELETE_APPOINTMENT_START action', () => {\n+ const appointmentStore = appointment(undefined, {\n+ type: deleteAppointmentStart.type,\n+ })\n+\n+ expect(appointmentStore.isLoading).toBeTruthy()\n+ })\n+\n+ it('should handle the DELETE_APPOINTMENT_SUCCESS action', () => {\n+ const appointmentStore = appointment(undefined, {\n+ type: deleteAppointmentSuccess.type,\n+ })\n+\n+ expect(appointmentStore.isLoading).toBeFalsy()\n+ })\n})\ndescribe('fetchAppointment()', () => {\n@@ -107,11 +129,84 @@ describe('appointment slice', () => {\nconst dispatch = jest.fn()\nconst getState = jest.fn()\nawait fetchAppointment('id')(dispatch, getState, null)\n+ })\n+ })\n- expect(dispatch).toHaveBeenCalledWith({\n- type: fetchAppointmentSuccess.type,\n- payload: { appointment: expectedAppointment, patient: expectedPatient },\n+ describe('deleteAppointment()', () => {\n+ let deleteAppointmentSpy = jest.spyOn(AppointmentRepository, 'delete')\n+ let toastSpy = jest.spyOn(components, 'Toast')\n+ beforeEach(() => {\n+ jest.resetAllMocks()\n+ deleteAppointmentSpy = jest.spyOn(AppointmentRepository, 'delete')\n+ toastSpy = jest.spyOn(components, 'Toast')\n+ })\n+\n+ it('should dispatch the DELETE_APPOINTMENT_START action', async () => {\n+ const dispatch = jest.fn()\n+ const getState = jest.fn()\n+\n+ await deleteAppointment({ id: 'test1' } as Appointment, createMemoryHistory())(\n+ dispatch,\n+ getState,\n+ null,\n+ )\n+\n+ expect(dispatch).toHaveBeenCalledWith({ type: deleteAppointmentStart.type })\n})\n+\n+ it('should call the AppointmentRepository delete function with the appointment', async () => {\n+ const expectedAppointment = { id: 'appointmentId1' } as Appointment\n+\n+ const dispatch = jest.fn()\n+ const getState = jest.fn()\n+\n+ await deleteAppointment(expectedAppointment, createMemoryHistory())(dispatch, getState, null)\n+\n+ expect(deleteAppointmentSpy).toHaveBeenCalledTimes(1)\n+ expect(deleteAppointmentSpy).toHaveBeenCalledWith(expectedAppointment)\n+ })\n+\n+ it('should navigate to /appointments after deleting', async () => {\n+ const history = createMemoryHistory()\n+ const expectedAppointment = { id: 'appointmentId1' } as Appointment\n+\n+ const dispatch = jest.fn()\n+ const getState = jest.fn()\n+\n+ await deleteAppointment(expectedAppointment, history)(dispatch, getState, null)\n+\n+ expect(history.location.pathname).toEqual('/appointments')\n+ })\n+\n+ it('should create a toast with a success message', async () => {\n+ const dispatch = jest.fn()\n+ const getState = jest.fn()\n+\n+ await deleteAppointment({ id: 'test1' } as Appointment, createMemoryHistory())(\n+ dispatch,\n+ getState,\n+ null,\n+ )\n+\n+ expect(toastSpy).toHaveBeenCalledTimes(1)\n+ expect(toastSpy).toHaveBeenLastCalledWith(\n+ 'success',\n+ 'states.success',\n+ 'scheduling.appointments.successfullyDeleted',\n+ )\n+ })\n+\n+ it('should dispatch the DELETE_APPOINTMENT_SUCCESS action', async () => {\n+ const dispatch = jest.fn()\n+ const getState = jest.fn()\n+\n+ await deleteAppointment({ id: 'test1' } as Appointment, createMemoryHistory())(\n+ dispatch,\n+ getState,\n+ null,\n+ )\n+\n+ expect(dispatch).toHaveBeenCalledWith({ type: deleteAppointmentSuccess.type })\n})\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx",
"new_path": "src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx",
"diff": "@@ -11,10 +11,12 @@ import { createMemoryHistory } from 'history'\nimport AppointmentRepository from 'clients/db/AppointmentsRepository'\nimport { mocked } from 'ts-jest/utils'\nimport { act } from 'react-dom/test-utils'\n-import { Spinner } from '@hospitalrun/components'\n+import { Spinner, Modal } from '@hospitalrun/components'\nimport AppointmentDetailForm from 'scheduling/appointments/AppointmentDetailForm'\nimport PatientRepository from 'clients/db/PatientRepository'\nimport Patient from 'model/Patient'\n+import * as ButtonBarProvider from 'page-header/ButtonBarProvider'\n+import Permissions from 'model/Permissions'\nimport * as titleUtil from '../../../../page-header/useTitle'\nimport * as appointmentSlice from '../../../../scheduling/appointments/appointment-slice'\n@@ -37,7 +39,7 @@ describe('View Appointment', () => {\nlet history: any\nlet store: MockStore\n- const setup = (isLoading: boolean) => {\n+ const setup = (isLoading: boolean, permissions = [Permissions.DeleteAppointment]) => {\njest.spyOn(AppointmentRepository, 'find')\nconst mockedAppointmentRepository = mocked(AppointmentRepository, true)\nmockedAppointmentRepository.find.mockResolvedValue(appointment)\n@@ -50,6 +52,9 @@ describe('View Appointment', () => {\nhistory.push('/appointments/123')\nstore = mockStore({\n+ user: {\n+ permissions,\n+ },\nappointment: {\nappointment,\nisLoading,\n@@ -115,4 +120,120 @@ describe('View Appointment', () => {\nexpect(appointmentDetailForm.prop('appointment')).toEqual(appointment)\nexpect(appointmentDetailForm.prop('isEditable')).toBeFalsy()\n})\n+\n+ it('should render a modal for delete confirmation', async () => {\n+ let wrapper: any\n+ await act(async () => {\n+ wrapper = await setup(false)\n+ })\n+\n+ const deleteAppointmentConfirmationModal = wrapper.find(Modal)\n+ expect(deleteAppointmentConfirmationModal).toHaveLength(1)\n+ expect(deleteAppointmentConfirmationModal.prop('closeButton').children).toEqual(\n+ 'actions.delete',\n+ )\n+ expect(deleteAppointmentConfirmationModal.prop('body')).toEqual(\n+ 'scheduling.appointment.deleteConfirmationMessage',\n+ )\n+ expect(deleteAppointmentConfirmationModal.prop('title')).toEqual('actions.confirmDelete')\n+ })\n+\n+ describe('delete appointment', () => {\n+ let setButtonToolBarSpy = jest.fn()\n+ let deleteAppointmentSpy = jest.spyOn(AppointmentRepository, 'delete')\n+ beforeEach(() => {\n+ jest.resetAllMocks()\n+ jest.spyOn(ButtonBarProvider, 'useButtonToolbarSetter')\n+ deleteAppointmentSpy = jest.spyOn(AppointmentRepository, 'delete')\n+ setButtonToolBarSpy = jest.fn()\n+ mocked(ButtonBarProvider).useButtonToolbarSetter.mockReturnValue(setButtonToolBarSpy)\n+ })\n+\n+ it('should render a delete appointment button in the button toolbar', async () => {\n+ await act(async () => {\n+ await setup(false)\n+ })\n+\n+ expect(setButtonToolBarSpy).toHaveBeenCalledTimes(1)\n+ const actualButtons: React.ReactNode[] = setButtonToolBarSpy.mock.calls[0][0]\n+ expect((actualButtons[0] as any).props.children).toEqual('scheduling.appointment.delete')\n+ })\n+\n+ it('should pop up the modal when on delete appointment click', async () => {\n+ let wrapper: any\n+ await act(async () => {\n+ wrapper = await setup(false)\n+ })\n+\n+ expect(setButtonToolBarSpy).toHaveBeenCalledTimes(1)\n+ const actualButtons: React.ReactNode[] = setButtonToolBarSpy.mock.calls[0][0]\n+\n+ act(() => {\n+ const { onClick } = (actualButtons[0] as any).props\n+ onClick({ preventDefault: jest.fn() })\n+ })\n+ wrapper.update()\n+\n+ const deleteConfirmationModal = wrapper.find(Modal)\n+ expect(deleteConfirmationModal.prop('show')).toEqual(true)\n+ })\n+\n+ it('should close the modal when the toggle button is clicked', async () => {\n+ let wrapper: any\n+ await act(async () => {\n+ wrapper = await setup(false)\n+ })\n+\n+ expect(setButtonToolBarSpy).toHaveBeenCalledTimes(1)\n+ const actualButtons: React.ReactNode[] = setButtonToolBarSpy.mock.calls[0][0]\n+\n+ act(() => {\n+ const { onClick } = (actualButtons[0] as any).props\n+ onClick({ preventDefault: jest.fn() })\n+ })\n+ wrapper.update()\n+\n+ act(() => {\n+ const deleteConfirmationModal = wrapper.find(Modal)\n+ deleteConfirmationModal.prop('toggle')()\n+ })\n+ wrapper.update()\n+\n+ const deleteConfirmationModal = wrapper.find(Modal)\n+ expect(deleteConfirmationModal.prop('show')).toEqual(false)\n+ })\n+\n+ it('should dispatch DELETE_APPOINTMENT action when modal confirmation button is clicked', async () => {\n+ let wrapper: any\n+ await act(async () => {\n+ wrapper = await setup(false)\n+ })\n+\n+ const deleteConfirmationModal = wrapper.find(Modal)\n+\n+ await act(async () => {\n+ await deleteConfirmationModal.prop('closeButton').onClick()\n+ })\n+ wrapper.update()\n+\n+ expect(deleteAppointmentSpy).toHaveBeenCalledTimes(1)\n+ expect(deleteAppointmentSpy).toHaveBeenCalledWith(appointment)\n+\n+ expect(store.getActions()).toContainEqual(appointmentSlice.deleteAppointmentStart())\n+ expect(store.getActions()).toContainEqual(appointmentSlice.deleteAppointmentSuccess())\n+ })\n+\n+ it('should not add delete appointment button to toolbar if the user does not have delete appointment permissions', async () => {\n+ await act(async () => {\n+ await setup(false, [])\n+ })\n+\n+ expect(setButtonToolBarSpy).toHaveBeenCalledTimes(1)\n+ const actualButtons: React.ReactNode[] = setButtonToolBarSpy.mock.calls[0][0]\n+\n+ expect(\n+ actualButtons.filter((b: any) => b.props.children === 'scheduling.appointment.delete'),\n+ ).toHaveLength(0)\n+ })\n+ })\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/locales/en-US/translation.json",
"new_path": "src/locales/en-US/translation.json",
"diff": "\"cancel\": \"Cancel\",\n\"new\": \"New\",\n\"list\": \"List\",\n- \"search\": \"Search\"\n+ \"search\": \"Search\",\n+ \"delete\": \"Delete\",\n+ \"confirmDelete\": \"Confirm Delete\"\n},\n\"states\": {\n\"success\": \"Success!\",\n\"appointments\": {\n\"label\": \"Appointments\",\n\"new\": \"New Appointment\",\n- \"view\": \"View Appointment\"\n+ \"view\": \"View Appointment\",\n+ \"successfullyDeleted\": \"Successfully deleted appointment!\"\n},\n\"appointment\": {\n\"startDate\": \"Start Date\",\n\"startDateMustBeBeforeEndDate\": \"Start Time must be before End Time.\"\n},\n\"reason\": \"Reason\",\n- \"patient\": \"Patient\"\n+ \"patient\": \"Patient\",\n+ \"delete\": \"Delete Appointment\",\n+ \"deleteConfirmationMessage\": \"Are you sure you want to delete this appointment?\"\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/Permissions.ts",
"new_path": "src/model/Permissions.ts",
"diff": "@@ -3,6 +3,7 @@ enum Permissions {\nWritePatients = 'write:patients',\nReadAppointments = 'read:appointments',\nWriteAppointments = 'write:appointments',\n+ DeleteAppointment = 'delete:appointment',\n}\nexport default Permissions\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/appointment-slice.ts",
"new_path": "src/scheduling/appointments/appointment-slice.ts",
"diff": "import { createSlice, PayloadAction } from '@reduxjs/toolkit'\nimport Appointment from 'model/Appointment'\nimport { AppThunk } from 'store'\n+import { Toast } from '@hospitalrun/components'\nimport AppointmentRepository from 'clients/db/AppointmentsRepository'\nimport Patient from 'model/Patient'\nimport PatientRepository from 'clients/db/PatientRepository'\n+import il8n from '../../i18n'\ninterface AppointmentState {\nappointment: Appointment\n@@ -24,6 +26,12 @@ const appointmentSlice = createSlice({\nfetchAppointmentStart: (state: AppointmentState) => {\nstate.isLoading = true\n},\n+ deleteAppointmentStart: (state: AppointmentState) => {\n+ state.isLoading = true\n+ },\n+ deleteAppointmentSuccess: (state: AppointmentState) => {\n+ state.isLoading = false\n+ },\nfetchAppointmentSuccess: (\nstate,\n{ payload }: PayloadAction<{ appointment: Appointment; patient: Patient }>,\n@@ -35,7 +43,12 @@ const appointmentSlice = createSlice({\n},\n})\n-export const { fetchAppointmentStart, fetchAppointmentSuccess } = appointmentSlice.actions\n+export const {\n+ fetchAppointmentStart,\n+ fetchAppointmentSuccess,\n+ deleteAppointmentStart,\n+ deleteAppointmentSuccess,\n+} = appointmentSlice.actions\nexport const fetchAppointment = (id: string): AppThunk => async (dispatch) => {\ndispatch(fetchAppointmentStart())\n@@ -45,4 +58,18 @@ export const fetchAppointment = (id: string): AppThunk => async (dispatch) => {\ndispatch(fetchAppointmentSuccess({ appointment, patient }))\n}\n+export const deleteAppointment = (appointment: Appointment, history: any): AppThunk => async (\n+ dispatch,\n+) => {\n+ dispatch(deleteAppointmentStart())\n+ await AppointmentRepository.delete(appointment)\n+ history.push('/appointments')\n+ Toast(\n+ 'success',\n+ il8n.t('states.success'),\n+ `${il8n.t('scheduling.appointments.successfullyDeleted')}`,\n+ )\n+ dispatch(deleteAppointmentSuccess())\n+}\n+\nexport default appointmentSlice.reducer\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/view/ViewAppointment.tsx",
"new_path": "src/scheduling/appointments/view/ViewAppointment.tsx",
"diff": "-import React, { useEffect } from 'react'\n+import React, { useEffect, useState } from 'react'\nimport useTitle from 'page-header/useTitle'\nimport { useSelector, useDispatch } from 'react-redux'\nimport { RootState } from 'store'\n-import { useParams } from 'react-router'\n-import { Spinner } from '@hospitalrun/components'\n+import { useParams, useHistory } from 'react-router'\n+import { Spinner, Button, Modal } from '@hospitalrun/components'\nimport { useTranslation } from 'react-i18next'\n-import { fetchAppointment } from '../appointment-slice'\n+import { useButtonToolbarSetter } from 'page-header/ButtonBarProvider'\n+import Permissions from 'model/Permissions'\n+import { fetchAppointment, deleteAppointment } from '../appointment-slice'\nimport AppointmentDetailForm from '../AppointmentDetailForm'\nconst ViewAppointment = () => {\n@@ -13,13 +15,45 @@ const ViewAppointment = () => {\nuseTitle(t('scheduling.appointments.view'))\nconst dispatch = useDispatch()\nconst { id } = useParams()\n+ const history = useHistory()\nconst { appointment, patient, isLoading } = useSelector((state: RootState) => state.appointment)\n+ const { permissions } = useSelector((state: RootState) => state.user)\n+ const [showDeleteConfirmation, setShowDeleteConfirmation] = useState<boolean>(false)\n+\n+ const setButtons = useButtonToolbarSetter()\n+\n+ const onAppointmentDeleteButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n+ event.preventDefault()\n+ setShowDeleteConfirmation(true)\n+ }\n+\n+ const onDeleteConfirmationButtonClick = () => {\n+ dispatch(deleteAppointment(appointment, history))\n+ setShowDeleteConfirmation(false)\n+ }\n+\n+ const buttons = []\n+ if (permissions.includes(Permissions.DeleteAppointment)) {\n+ buttons.push(\n+ <Button\n+ key=\"deleteAppointmentButton\"\n+ color=\"danger\"\n+ icon=\"appointment-remove\"\n+ onClick={onAppointmentDeleteButtonClick}\n+ >\n+ {t('scheduling.appointment.delete')}\n+ </Button>,\n+ )\n+ }\n+\n+ setButtons(buttons)\nuseEffect(() => {\nif (id) {\ndispatch(fetchAppointment(id))\n}\n- }, [dispatch, id])\n+ return () => setButtons([])\n+ }, [dispatch, id, setButtons])\nif (!appointment.id || isLoading) {\nreturn <Spinner type=\"BarLoader\" loading />\n@@ -35,6 +69,18 @@ const ViewAppointment = () => {\n// not editable\n}}\n/>\n+ <Modal\n+ body={t('scheduling.appointment.deleteConfirmationMessage')}\n+ buttonsAlignment=\"right\"\n+ show={showDeleteConfirmation}\n+ closeButton={{\n+ children: t('actions.delete'),\n+ color: 'danger',\n+ onClick: onDeleteConfirmationButtonClick,\n+ }}\n+ title={t('actions.confirmDelete')}\n+ toggle={() => setShowDeleteConfirmation(false)}\n+ />\n</div>\n)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/user/user-slice.ts",
"new_path": "src/user/user-slice.ts",
"diff": "@@ -11,6 +11,7 @@ const initialState: UserState = {\nPermissions.WritePatients,\nPermissions.ReadAppointments,\nPermissions.WriteAppointments,\n+ Permissions.DeleteAppointment,\n],\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(delete appointment): adds ability to delete appointment |
288,323 | 23.02.2020 21:05:29 | 21,600 | 04a21604d449f18351d15ae5c3eafea2e47b7e62 | feat(allergies): adds ability to add allergy to appointment | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/patients/allergies/Allergies.test.tsx",
"diff": "+import '../../../__mocks__/matchMediaMock'\n+import React from 'react'\n+import { mount } from 'enzyme'\n+import Allergies from 'patients/allergies/Allergies'\n+import Permissions from 'model/Permissions'\n+import configureMockStore from 'redux-mock-store'\n+import { createMemoryHistory } from 'history'\n+import thunk from 'redux-thunk'\n+import { Router } from 'react-router'\n+import { Provider } from 'react-redux'\n+import Patient from 'model/Patient'\n+import User from 'model/User'\n+import { Button, Modal, List, ListItem, Alert } from '@hospitalrun/components'\n+import { act } from '@testing-library/react'\n+import { mocked } from 'ts-jest/utils'\n+import PatientRepository from 'clients/db/PatientRepository'\n+import Allergy from 'model/Allergy'\n+import NewAllergyModal from 'patients/allergies/NewAllergyModal'\n+import * as patientSlice from '../../../patients/patient-slice'\n+\n+const mockStore = configureMockStore([thunk])\n+const history = createMemoryHistory()\n+const expectedPatient = {\n+ id: '123',\n+ rev: '123',\n+ allergies: [\n+ { id: '1', name: 'allergy1' },\n+ { id: '2', name: 'allergy2' },\n+ ],\n+} as Patient\n+\n+let user: any\n+let store: any\n+\n+const setup = (patient = expectedPatient, permissions = [Permissions.AddAllergy]) => {\n+ user = { permissions } as User\n+ store = mockStore({ patient, user })\n+ const wrapper = mount(\n+ <Router history={history}>\n+ <Provider store={store}>\n+ <Allergies patient={patient} />\n+ </Provider>\n+ </Router>,\n+ )\n+\n+ return wrapper\n+}\n+\n+describe('Allergies', () => {\n+ beforeEach(() => {\n+ jest.resetAllMocks()\n+ jest.spyOn(PatientRepository, 'saveOrUpdate')\n+ })\n+\n+ describe('add new allergy button', () => {\n+ it('should render a button to add new allergies', () => {\n+ const wrapper = setup()\n+\n+ const addAllergyButton = wrapper.find(Button)\n+ expect(addAllergyButton).toHaveLength(1)\n+ expect(addAllergyButton.text().trim()).toEqual('patient.allergies.new')\n+ })\n+\n+ it('should not render a button to add new allergies if the user does not have permissions', () => {\n+ const wrapper = setup(expectedPatient, [])\n+\n+ const addAllergyButton = wrapper.find(Button)\n+ expect(addAllergyButton).toHaveLength(0)\n+ })\n+\n+ it('should open the New Allergy Modal when clicked', () => {\n+ const wrapper = setup()\n+\n+ act(() => {\n+ const addAllergyButton = wrapper.find(Button)\n+ const onClick = addAllergyButton.prop('onClick') as any\n+ onClick({} as React.MouseEvent<HTMLButtonElement>)\n+ })\n+\n+ wrapper.update()\n+\n+ expect(wrapper.find(Modal).prop('show')).toBeTruthy()\n+ })\n+\n+ it('should update the patient with the new allergy when the save button is clicked', async () => {\n+ const expectedAllergy = { name: 'name' } as Allergy\n+ const expectedUpdatedPatient = {\n+ ...expectedPatient,\n+ allergies: [...(expectedPatient.allergies as any), expectedAllergy],\n+ } as Patient\n+\n+ const mockedPatientRepository = mocked(PatientRepository, true)\n+ mockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedUpdatedPatient)\n+\n+ const wrapper = setup()\n+\n+ await act(async () => {\n+ const modal = wrapper.find(NewAllergyModal)\n+ await modal.prop('onSave')(expectedAllergy)\n+ })\n+\n+ expect(mockedPatientRepository.saveOrUpdate).toHaveBeenCalledWith(expectedUpdatedPatient)\n+ expect(store.getActions()).toContainEqual(patientSlice.updatePatientStart())\n+ expect(store.getActions()).toContainEqual(\n+ patientSlice.updatePatientSuccess(expectedUpdatedPatient),\n+ )\n+ })\n+ })\n+\n+ describe('allergy list', () => {\n+ it('should list the patients allergies', () => {\n+ const allergies = expectedPatient.allergies as Allergy[]\n+ const wrapper = setup()\n+\n+ const list = wrapper.find(List)\n+ const listItems = wrapper.find(ListItem)\n+\n+ expect(list).toHaveLength(1)\n+ expect(listItems).toHaveLength(allergies.length)\n+ })\n+\n+ it('should render a warning message if the patient does not have any allergies', () => {\n+ const wrapper = setup({ ...expectedPatient, allergies: [] })\n+\n+ const alert = wrapper.find(Alert)\n+\n+ expect(alert).toHaveLength(1)\n+ expect(alert.prop('title')).toEqual('patient.allergies.warning.noAllergies')\n+ expect(alert.prop('message')).toEqual('patient.allergies.addAllergyAbove')\n+ })\n+ })\n+})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/patients/allergies/NewAllergyModal.test.tsx",
"diff": "+import '../../../__mocks__/matchMediaMock'\n+import React from 'react'\n+import NewAllergyModal from 'patients/allergies/NewAllergyModal'\n+import { shallow, mount } from 'enzyme'\n+import { Modal, Alert } from '@hospitalrun/components'\n+import { act } from '@testing-library/react'\n+import Allergy from 'model/Allergy'\n+\n+describe('New Allergy Modal', () => {\n+ it('should render a modal with the correct labels', () => {\n+ const wrapper = shallow(\n+ <NewAllergyModal show onCloseButtonClick={jest.fn()} onSave={jest.fn()} />,\n+ )\n+\n+ const modal = wrapper.find(Modal)\n+ expect(modal).toHaveLength(1)\n+ expect(modal.prop('title')).toEqual('patient.allergies.new')\n+ expect(modal.prop('closeButton')?.children).toEqual('actions.cancel')\n+ expect(modal.prop('closeButton')?.color).toEqual('danger')\n+ expect(modal.prop('successButton')?.children).toEqual('patient.allergies.new')\n+ expect(modal.prop('successButton')?.color).toEqual('success')\n+ expect(modal.prop('successButton')?.icon).toEqual('add')\n+ })\n+\n+ describe('cancel', () => {\n+ it('should call the onCloseButtonClick function when the close button is clicked', () => {\n+ const onCloseButtonClickSpy = jest.fn()\n+ const wrapper = shallow(\n+ <NewAllergyModal show onCloseButtonClick={onCloseButtonClickSpy} onSave={jest.fn()} />,\n+ )\n+\n+ act(() => {\n+ const modal = wrapper.find(Modal)\n+ const { onClick } = modal.prop('closeButton') as any\n+ onClick()\n+ })\n+\n+ expect(onCloseButtonClickSpy).toHaveBeenCalledTimes(1)\n+ })\n+ })\n+\n+ describe('save', () => {\n+ it('should call the onSave function with the correct data when the save button is clicked', () => {\n+ const expectedName = 'expected name'\n+ const onSaveSpy = jest.fn()\n+ const wrapper = mount(\n+ <NewAllergyModal show onCloseButtonClick={jest.fn()} onSave={onSaveSpy} />,\n+ )\n+\n+ act(() => {\n+ const input = wrapper.findWhere((c) => c.prop('name') === 'name')\n+ const onChange = input.prop('onChange')\n+ onChange({ target: { value: expectedName } })\n+ })\n+\n+ wrapper.update()\n+\n+ act(() => {\n+ const modal = wrapper.find(Modal)\n+ const onSave = (modal.prop('successButton') as any).onClick\n+ onSave({} as React.MouseEvent<HTMLButtonElement>)\n+ })\n+\n+ expect(onSaveSpy).toHaveBeenCalledTimes(1)\n+ expect(onSaveSpy).toHaveBeenCalledWith({ name: expectedName } as Allergy)\n+ })\n+\n+ it('should display an error message if the name field is not filled out', () => {\n+ const wrapper = mount(\n+ <NewAllergyModal\n+ show\n+ toggle={jest.fn()}\n+ onCloseButtonClick={jest.fn()}\n+ onSave={jest.fn()}\n+ />,\n+ )\n+\n+ act(() => {\n+ const modal = wrapper.find(Modal)\n+ const onSave = (modal.prop('successButton') as any).onClick\n+ onSave({} as React.MouseEvent<HTMLButtonElement>)\n+ })\n+ wrapper.update()\n+\n+ expect(wrapper.find(Alert)).toHaveLength(1)\n+ expect(wrapper.find(Alert).prop('title')).toEqual('states.error')\n+ expect(wrapper.find(Alert).prop('message')).toContain('patient.allergies.error.nameRequired')\n+ })\n+ })\n+})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/view/ViewPatient.test.tsx",
"new_path": "src/__tests__/patients/view/ViewPatient.test.tsx",
"diff": "@@ -12,6 +12,7 @@ import GeneralInformation from 'patients/GeneralInformation'\nimport { createMemoryHistory } from 'history'\nimport RelatedPersonTab from 'patients/related-persons/RelatedPersonTab'\nimport * as ButtonBarProvider from 'page-header/ButtonBarProvider'\n+import Allergies from 'patients/allergies/Allergies'\nimport Patient from '../../../model/Patient'\nimport PatientRepository from '../../../clients/db/PatientRepository'\nimport * as titleUtil from '../../../page-header/useTitle'\n@@ -113,10 +114,11 @@ describe('ViewPatient', () => {\nconst tabs = tabsHeader.find(Tab)\nexpect(tabsHeader).toHaveLength(1)\n- expect(tabs).toHaveLength(3)\n+ expect(tabs).toHaveLength(4)\nexpect(tabs.at(0).prop('label')).toEqual('patient.generalInformation')\nexpect(tabs.at(1).prop('label')).toEqual('patient.relatedPersons.label')\nexpect(tabs.at(2).prop('label')).toEqual('scheduling.appointments.label')\n+ expect(tabs.at(3).prop('label')).toEqual('patient.allergies.label')\n})\nit('should mark the general information tab as active and render the general information component when route is /patients/:id', async () => {\n@@ -173,4 +175,28 @@ describe('ViewPatient', () => {\nexpect(relatedPersonTab).toHaveLength(1)\nexpect(relatedPersonTab.prop('patient')).toEqual(patient)\n})\n+\n+ it('should mark the rallergies tab as active when it is clicked and render the allergies component when route is /patients/:id/allergies', async () => {\n+ let wrapper: any\n+ await act(async () => {\n+ wrapper = await setup()\n+ })\n+\n+ await act(async () => {\n+ const tabsHeader = wrapper.find(TabsHeader)\n+ const tabs = tabsHeader.find(Tab)\n+ tabs.at(3).prop('onClick')()\n+ })\n+\n+ wrapper.update()\n+\n+ const tabsHeader = wrapper.find(TabsHeader)\n+ const tabs = tabsHeader.find(Tab)\n+ const allergiesTab = wrapper.find(Allergies)\n+\n+ expect(history.location.pathname).toEqual(`/patients/${patient.id}/allergies`)\n+ expect(tabs.at(3).prop('active')).toBeTruthy()\n+ expect(allergiesTab).toHaveLength(1)\n+ expect(allergiesTab.prop('patient')).toEqual(patient)\n+ })\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/locales/en-US/translation.json",
"new_path": "src/locales/en-US/translation.json",
"diff": "},\n\"errors\": {\n\"patientGivenNameRequired\": \"Patient Given Name is required.\"\n+ },\n+ \"allergies\": {\n+ \"label\": \"Allergies\",\n+ \"new\": \"Add Allergy\",\n+ \"error\": {\n+ \"nameRequired\": \"Name is required.\"\n+ },\n+ \"warning\": {\n+ \"noAllergies\": \"No Allergies\"\n+ },\n+ \"addAllergyAbove\": \"Add an allergy using the button above.\"\n}\n},\n\"sex\": {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/model/Allergy.ts",
"diff": "+export default interface Allergy {\n+ id: string\n+ name: string\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/Patient.ts",
"new_path": "src/model/Patient.ts",
"diff": "@@ -2,6 +2,7 @@ import AbstractDBModel from './AbstractDBModel'\nimport Name from './Name'\nimport ContactInformation from './ContactInformation'\nimport RelatedPerson from './RelatedPerson'\n+import Allergy from './Allergy'\nexport default interface Patient extends AbstractDBModel, Name, ContactInformation {\nsex: string\n@@ -12,4 +13,5 @@ export default interface Patient extends AbstractDBModel, Name, ContactInformati\ntype?: string\nfriendlyId: string\nrelatedPersons?: RelatedPerson[]\n+ allergies?: Allergy[]\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/Permissions.ts",
"new_path": "src/model/Permissions.ts",
"diff": "@@ -4,6 +4,7 @@ enum Permissions {\nReadAppointments = 'read:appointments',\nWriteAppointments = 'write:appointments',\nDeleteAppointment = 'delete:appointment',\n+ AddAllergy = 'write:allergy',\n}\nexport default Permissions\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/allergies/Allergies.tsx",
"diff": "+import React, { useState } from 'react'\n+import useAddBreadcrumbs from 'breadcrumbs/useAddBreadcrumbs'\n+import Patient from 'model/Patient'\n+import { Button, List, ListItem, Alert } from '@hospitalrun/components'\n+import { useSelector, useDispatch } from 'react-redux'\n+import { RootState } from 'store'\n+import Permissions from 'model/Permissions'\n+import { useTranslation } from 'react-i18next'\n+import Allergy from 'model/Allergy'\n+import { useHistory } from 'react-router'\n+import { updatePatient } from 'patients/patient-slice'\n+import { getTimestampId } from 'patients/util/timestamp-id-generator'\n+import NewAllergyModal from './NewAllergyModal'\n+\n+interface AllergiesProps {\n+ patient: Patient\n+}\n+\n+const Allergies = (props: AllergiesProps) => {\n+ const { t } = useTranslation()\n+ const history = useHistory()\n+ const dispatch = useDispatch()\n+ const { patient } = props\n+ const { permissions } = useSelector((state: RootState) => state.user)\n+ const [showNewAllergyModal, setShowNewAllergyModal] = useState(false)\n+\n+ const breadcrumbs = [\n+ {\n+ i18nKey: 'patient.allergies.label',\n+ location: `/patients/${patient.id}/allergies`,\n+ },\n+ ]\n+ useAddBreadcrumbs(breadcrumbs)\n+\n+ const onAddAllergy = (allergy: Allergy) => {\n+ allergy.id = getTimestampId()\n+ const allergies = []\n+ if (patient.allergies) {\n+ allergies.push(...patient.allergies)\n+ }\n+\n+ allergies.push(allergy)\n+ const patientToUpdate = { ...patient, allergies }\n+ dispatch(updatePatient(patientToUpdate, history))\n+ }\n+\n+ return (\n+ <>\n+ <div className=\"row\">\n+ <div className=\"col-md-12 d-flex justify-content-end\">\n+ {permissions.includes(Permissions.AddAllergy) && (\n+ <Button\n+ outlined\n+ color=\"success\"\n+ icon=\"add\"\n+ iconLocation=\"left\"\n+ onClick={() => setShowNewAllergyModal(true)}\n+ >\n+ {t('patient.allergies.new')}\n+ </Button>\n+ )}\n+ </div>\n+ </div>\n+ <br />\n+ {(!patient.allergies || patient.allergies.length === 0) && (\n+ <Alert\n+ color=\"warning\"\n+ title={t('patient.allergies.warning.noAllergies')}\n+ message={t('patient.allergies.addAllergyAbove')}\n+ />\n+ )}\n+ <List>\n+ {patient.allergies?.map((a: Allergy) => (\n+ <ListItem key={a.id}>{a.name}</ListItem>\n+ ))}\n+ </List>\n+ <NewAllergyModal\n+ show={showNewAllergyModal}\n+ onCloseButtonClick={() => setShowNewAllergyModal(false)}\n+ onSave={(allergy) => onAddAllergy(allergy)}\n+ />\n+ </>\n+ )\n+}\n+\n+export default Allergies\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/allergies/NewAllergyModal.tsx",
"diff": "+import React, { useState, useEffect } from 'react'\n+import { Modal, Alert } from '@hospitalrun/components'\n+import { useTranslation } from 'react-i18next'\n+import Allergy from 'model/Allergy'\n+import TextInputWithLabelFormGroup from 'components/input/TextInputWithLabelFormGroup'\n+\n+interface NewAllergyModalProps {\n+ show: boolean\n+ onCloseButtonClick: () => void\n+ onSave: (allergy: Allergy) => void\n+}\n+\n+const NewAllergyModal = (props: NewAllergyModalProps) => {\n+ const { show, onCloseButtonClick, onSave } = props\n+ const [allergy, setAllergy] = useState({ name: '' })\n+ const [errorMessage, setErrorMessage] = useState('')\n+ const { t } = useTranslation()\n+\n+ useEffect(() => {\n+ setErrorMessage('')\n+ setAllergy({ name: '' })\n+ }, [show])\n+\n+ const onNameChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n+ const name = event.target.value\n+ setAllergy((prevAllergy) => ({ ...prevAllergy, name }))\n+ }\n+\n+ const onSaveButtonClick = () => {\n+ let newErrorMessage = ''\n+ if (!allergy.name) {\n+ newErrorMessage += `${t('patient.allergies.error.nameRequired')} `\n+ }\n+\n+ if (newErrorMessage) {\n+ setErrorMessage(newErrorMessage.trim())\n+ return\n+ }\n+\n+ onSave(allergy as Allergy)\n+ }\n+\n+ const onClose = () => {\n+ onCloseButtonClick()\n+ }\n+\n+ const body = (\n+ <>\n+ {errorMessage && <Alert color=\"danger\" title={t('states.error')} message={errorMessage} />}\n+ <form>\n+ <TextInputWithLabelFormGroup\n+ name=\"name\"\n+ label=\"Name\"\n+ isEditable\n+ placeholder=\"Allergy\"\n+ value={allergy.name}\n+ onChange={onNameChange}\n+ />\n+ </form>\n+ </>\n+ )\n+\n+ return (\n+ <Modal\n+ show={show}\n+ toggle={onClose}\n+ title={t('patient.allergies.new')}\n+ body={body}\n+ closeButton={{\n+ children: t('actions.cancel'),\n+ color: 'danger',\n+ onClick: onClose,\n+ }}\n+ successButton={{\n+ children: t('patient.allergies.new'),\n+ color: 'success',\n+ icon: 'add',\n+ iconLocation: 'left',\n+ onClick: onSaveButtonClick,\n+ }}\n+ />\n+ )\n+}\n+\n+export default NewAllergyModal\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/util/timestamp-id-generator.ts",
"diff": "+import { getTime } from 'date-fns'\n+\n+export function getTimestampId() {\n+ return getTime(new Date()).toString()\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/view/ViewPatient.tsx",
"new_path": "src/patients/view/ViewPatient.tsx",
"diff": "@@ -5,6 +5,7 @@ import { Panel, Spinner, TabsHeader, Tab, Button } from '@hospitalrun/components\nimport { useTranslation } from 'react-i18next'\nimport { useButtonToolbarSetter } from 'page-header/ButtonBarProvider'\n+import Allergies from 'patients/allergies/Allergies'\nimport useTitle from '../../page-header/useTitle'\nimport { fetchPatient } from '../patient-slice'\nimport { RootState } from '../../store'\n@@ -87,6 +88,11 @@ const ViewPatient = () => {\nlabel={t('scheduling.appointments.label')}\nonClick={() => history.push(`/patients/${patient.id}/appointments`)}\n/>\n+ <Tab\n+ active={location.pathname === `/patients/${patient.id}/allergies`}\n+ label={t('patient.allergies.label')}\n+ onClick={() => history.push(`/patients/${patient.id}/allergies`)}\n+ />\n</TabsHeader>\n<Panel>\n<Route exact path=\"/patients/:id\">\n@@ -98,6 +104,9 @@ const ViewPatient = () => {\n<Route exact path=\"/patients/:id/appointments\">\n<AppointmentsList patientId={patient.id} />\n</Route>\n+ <Route exact path=\"/patients/:id/allergies\">\n+ <Allergies patient={patient} />\n+ </Route>\n</Panel>\n</div>\n)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/user/user-slice.ts",
"new_path": "src/user/user-slice.ts",
"diff": "@@ -12,6 +12,7 @@ const initialState: UserState = {\nPermissions.ReadAppointments,\nPermissions.WriteAppointments,\nPermissions.DeleteAppointment,\n+ Permissions.AddAllergy,\n],\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(allergies): adds ability to add allergy to appointment |
288,334 | 24.02.2020 09:01:05 | -3,600 | 656a03726000d143564744e91e2ccd05799d0bbe | ci(deps): updates checkout action | [
{
"change_type": "MODIFY",
"old_path": ".github/workflows/ci.yml",
"new_path": ".github/workflows/ci.yml",
"diff": "@@ -14,7 +14,7 @@ jobs:\n# node-version: 13.x\nsteps:\n- run: git config --global core.autocrlf false # this is needed to prevent git changing EOL after cloning on Windows OS\n- - uses: actions/checkout@v1\n+ - uses: actions/checkout@v2\n- name: Use Node.js\nuses: actions/setup-node@v1\nwith:\n@@ -48,7 +48,7 @@ jobs:\n# node-version: 13.x\nsteps:\n- run: git config --global core.autocrlf false # this is needed to prevent git changing EOL after cloning on Windows OS\n- - uses: actions/checkout@v1\n+ - uses: actions/checkout@v2\n- name: Use Node.js\nuses: actions/setup-node@v1\nwith:\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | ci(deps): updates checkout action |
288,381 | 24.02.2020 14:39:30 | -21,600 | 7b6b2cc5f5135f4b68256985c3056a75c8cdb7d6 | fix(newPatient): correct input types of email and phone fields | [
{
"change_type": "MODIFY",
"old_path": "src/patients/GeneralInformation.tsx",
"new_path": "src/patients/GeneralInformation.tsx",
"diff": "@@ -205,6 +205,7 @@ const GeneralInformation = (props: Props) => {\nonChange={(event: React.ChangeEvent<HTMLInputElement>) => {\nonInputElementChange(event, 'phoneNumber')\n}}\n+ type=\"number\"\n/>\n</div>\n<div className=\"col\">\n@@ -217,6 +218,7 @@ const GeneralInformation = (props: Props) => {\nonChange={(event: React.ChangeEvent<HTMLInputElement>) => {\nonInputElementChange(event, 'email')\n}}\n+ type=\"email\"\n/>\n</div>\n</div>\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(newPatient): correct input types of email and phone fields |
288,381 | 24.02.2020 14:42:17 | -21,600 | 21285004c478e07c590eed5ac2670b4eeec45e20 | feat(textInput): add new input type tel | [
{
"change_type": "MODIFY",
"old_path": "src/components/input/TextInputWithLabelFormGroup.tsx",
"new_path": "src/components/input/TextInputWithLabelFormGroup.tsx",
"diff": "@@ -6,7 +6,7 @@ interface Props {\nlabel: string\nname: string\nisEditable?: boolean\n- type: 'text' | 'email' | 'number'\n+ type: 'text' | 'email' | 'number' | 'tel'\nplaceholder?: string\nonChange?: (event: React.ChangeEvent<HTMLInputElement>) => void\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/GeneralInformation.tsx",
"new_path": "src/patients/GeneralInformation.tsx",
"diff": "@@ -205,7 +205,7 @@ const GeneralInformation = (props: Props) => {\nonChange={(event: React.ChangeEvent<HTMLInputElement>) => {\nonInputElementChange(event, 'phoneNumber')\n}}\n- type=\"number\"\n+ type=\"tel\"\n/>\n</div>\n<div className=\"col\">\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(textInput): add new input type tel |
288,337 | 26.02.2020 20:24:12 | -3,600 | 3cee57808d00fc92057ab4cd5df0be4838ff166b | fix(breadcrumb): add the breadcrumb for the edit appointment view
fix | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/HospitalRun.test.tsx",
"new_path": "src/__tests__/HospitalRun.test.tsx",
"diff": "@@ -327,15 +327,15 @@ describe('HospitalRun', () => {\nmockedAppointmentRepository.find.mockResolvedValue(appointment)\nmockedPatientRepository.find.mockResolvedValue(patient)\n- const wrapper = mount(\n- <Provider\n- store={mockStore({\n+ const store = mockStore({\ntitle: 'test',\nuser: { permissions: [Permissions.WriteAppointments, Permissions.ReadAppointments] },\n- appointment: { appointment: {} as Appointment, patient: {} as Patient },\n+ appointment: { appointment, patient: {} as Patient },\nbreadcrumbs: { breadcrumbs: [] },\n- })}\n- >\n+ })\n+\n+ const wrapper = mount(\n+ <Provider store={store}>\n<MemoryRouter initialEntries={['/appointments/edit/123']}>\n<HospitalRun />\n</MemoryRouter>\n@@ -343,6 +343,18 @@ describe('HospitalRun', () => {\n)\nexpect(wrapper.find(EditAppointment)).toHaveLength(1)\n+\n+ expect(store.getActions()).toContainEqual(\n+ addBreadcrumbs([\n+ { i18nKey: 'scheduling.appointments.label', location: '/appointments' },\n+ { text: '123', location: '/appointments/123' },\n+ {\n+ i18nKey: 'scheduling.appointments.editAppointment',\n+ location: '/appointments/edit/123',\n+ },\n+ { i18nKey: 'dashboard.label', location: '/' },\n+ ]),\n+ )\n})\nit('should render the Dashboard when the user does not have read appointment privileges', () => {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/scheduling/appointments/util/scheduling-appointment.util.test.ts",
"diff": "+import Appointment from 'model/Appointment'\n+import { getAppointmentLabel } from '../../../../scheduling/appointments/util/scheduling-appointment.util'\n+\n+describe('scheduling appointment util', () => {\n+ describe('getAppointmentLabel', () => {\n+ it('should return the locale string representation of the start time and end time', () => {\n+ const appointment = {\n+ id: '123',\n+ startDateTime: '2020-03-07T18:15:00.000Z',\n+ endDateTime: '2020-03-07T20:15:00.000Z',\n+ } as Appointment\n+\n+ expect(getAppointmentLabel(appointment)).toEqual(\n+ `${new Date(appointment.startDateTime).toLocaleString()} - ${new Date(\n+ appointment.endDateTime,\n+ ).toLocaleString()}`,\n+ )\n+ })\n+\n+ it('should return the appointment id when start time is not defined', () => {\n+ const appointment = {\n+ id: '123',\n+ startDateTime: '2020-03-07T18:15:00.000Z',\n+ } as Appointment\n+\n+ expect(getAppointmentLabel(appointment)).toEqual('123')\n+ })\n+\n+ it('should return the appointment id when end time is not defined', () => {\n+ const appointment = {\n+ id: '123',\n+ endDateTime: '2020-03-07T20:15:00.000Z',\n+ } as Appointment\n+\n+ expect(getAppointmentLabel(appointment)).toEqual('123')\n+ })\n+\n+ it('should return the appointment id when start time and end time are not defined', () => {\n+ const appointment = {\n+ id: '123',\n+ } as Appointment\n+\n+ expect(getAppointmentLabel(appointment)).toEqual('123')\n+ })\n+ })\n+})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/edit/EditAppointment.tsx",
"new_path": "src/scheduling/appointments/edit/EditAppointment.tsx",
"diff": "@@ -10,6 +10,8 @@ import useTitle from '../../../page-header/useTitle'\nimport Appointment from '../../../model/Appointment'\nimport { updateAppointment, fetchAppointment } from '../appointment-slice'\nimport { RootState } from '../../../store'\n+import { getAppointmentLabel } from '../util/scheduling-appointment.util'\n+import useAddBreadcrumbs from '../../../breadcrumbs/useAddBreadcrumbs'\nconst EditAppointment = () => {\nconst { t } = useTranslation()\n@@ -22,6 +24,18 @@ const EditAppointment = () => {\nconst { appointment: reduxAppointment, patient, isLoading } = useSelector(\n(state: RootState) => state.appointment,\n)\n+ const breadcrumbs = [\n+ { i18nKey: 'scheduling.appointments.label', location: '/appointments' },\n+ {\n+ text: getAppointmentLabel(reduxAppointment),\n+ location: `/appointments/${reduxAppointment.id}`,\n+ },\n+ {\n+ i18nKey: 'scheduling.appointments.editAppointment',\n+ location: `/appointments/edit/${reduxAppointment.id}`,\n+ },\n+ ]\n+ useAddBreadcrumbs(breadcrumbs, true)\nuseEffect(() => {\nsetAppointment(reduxAppointment)\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/scheduling/appointments/util/scheduling-appointment.util.ts",
"diff": "+import Appointment from '../../../model/Appointment'\n+\n+export function getAppointmentLabel(appointment: Appointment) {\n+ const { id, startDateTime, endDateTime } = appointment\n+\n+ return startDateTime && endDateTime\n+ ? `${new Date(startDateTime).toLocaleString()} - ${new Date(endDateTime).toLocaleString()}`\n+ : id\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/view/ViewAppointment.tsx",
"new_path": "src/scheduling/appointments/view/ViewAppointment.tsx",
"diff": "@@ -7,19 +7,11 @@ import { Spinner, Button, Modal } from '@hospitalrun/components'\nimport { useTranslation } from 'react-i18next'\nimport { useButtonToolbarSetter } from 'page-header/ButtonBarProvider'\nimport Permissions from 'model/Permissions'\n-import Appointment from 'model/Appointment'\nimport { fetchAppointment, deleteAppointment } from '../appointment-slice'\nimport AppointmentDetailForm from '../AppointmentDetailForm'\n+import { getAppointmentLabel } from '../util/scheduling-appointment.util'\nimport useAddBreadcrumbs from '../../../breadcrumbs/useAddBreadcrumbs'\n-function getAppointmentLabel(appointment: Appointment) {\n- const { id, startDateTime, endDateTime } = appointment\n-\n- return startDateTime && endDateTime\n- ? `${new Date(startDateTime).toLocaleString()} - ${new Date(endDateTime).toLocaleString()}`\n- : id\n-}\n-\nconst ViewAppointment = () => {\nconst { t } = useTranslation()\nuseTitle(t('scheduling.appointments.viewAppointment'))\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(breadcrumb): add the breadcrumb for the edit appointment view
fix #1854 |
288,362 | 26.02.2020 20:27:19 | -3,600 | 2a8e778a95721102d9b2f65b1ee6cd787be60370 | Add CTA slack
adding the call to action to join the slack group | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -17,6 +17,7 @@ React frontend for [HospitalRun](http://hospitalrun.io/): free software for deve\n- To contribute, follow the guidelines in the readme or alternatively ask for details on Slack channel [#contributors](https://hospitalrun-slack.herokuapp.com).\n- To use version 1.0.0-beta (not production ready) in a hospital facility, ask for support on Slack channel [#troubleshooting](https://hospitalrun-slack.herokuapp.com) or Spectrum channel [#support](https://spectrum.chat/hospitalrun).\n+### [Join our slack development group](https://hospitalrun-slack.herokuapp.com)\n# Contributing\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | Add CTA slack
adding the call to action to join the slack group |
288,337 | 27.02.2020 22:19:13 | -3,600 | 33b4dc31f710af25266dbb786983cb68936ef2f3 | fix(breadcrumb): set appointment date precision to minutes in breadcrumb
fix | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/scheduling/appointments/util/scheduling-appointment.util.test.ts",
"new_path": "src/__tests__/scheduling/appointments/util/scheduling-appointment.util.test.ts",
"diff": "@@ -4,17 +4,24 @@ import { getAppointmentLabel } from '../../../../scheduling/appointments/util/sc\ndescribe('scheduling appointment util', () => {\ndescribe('getAppointmentLabel', () => {\nit('should return the locale string representation of the start time and end time', () => {\n+ const options = {\n+ year: 'numeric',\n+ month: '2-digit',\n+ day: '2-digit',\n+ hour: '2-digit',\n+ minute: '2-digit',\n+ }\n+\nconst appointment = {\nid: '123',\nstartDateTime: '2020-03-07T18:15:00.000Z',\nendDateTime: '2020-03-07T20:15:00.000Z',\n} as Appointment\n- expect(getAppointmentLabel(appointment)).toEqual(\n- `${new Date(appointment.startDateTime).toLocaleString()} - ${new Date(\n- appointment.endDateTime,\n- ).toLocaleString()}`,\n- )\n+ const startDateLabel = new Date(appointment.startDateTime).toLocaleString([], options)\n+ const endDateLabel = new Date(appointment.endDateTime).toLocaleString([], options)\n+\n+ expect(getAppointmentLabel(appointment)).toEqual(`${startDateLabel} - ${endDateLabel}`)\n})\nit('should return the appointment id when start time is not defined', () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/util/scheduling-appointment.util.ts",
"new_path": "src/scheduling/appointments/util/scheduling-appointment.util.ts",
"diff": "import Appointment from '../../../model/Appointment'\n+const options = {\n+ year: 'numeric',\n+ month: '2-digit',\n+ day: '2-digit',\n+ hour: '2-digit',\n+ minute: '2-digit',\n+}\n+\n+function toLocaleString(date: Date) {\n+ return date.toLocaleString([], options)\n+}\n+\nexport function getAppointmentLabel(appointment: Appointment) {\nconst { id, startDateTime, endDateTime } = appointment\nreturn startDateTime && endDateTime\n- ? `${new Date(startDateTime).toLocaleString()} - ${new Date(endDateTime).toLocaleString()}`\n+ ? `${toLocaleString(new Date(startDateTime))} - ${toLocaleString(new Date(endDateTime))}`\n: id\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(breadcrumb): set appointment date precision to minutes in breadcrumb
fix #1853 |
288,337 | 28.02.2020 20:05:55 | -3,600 | 9b2e721a0d9e7b33cd91fe7da4e110dfc2130ee6 | fix(button toolbar): align buttons to the right in the toolbar
fix | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/page-header/ButtonToolBar.test.tsx",
"new_path": "src/__tests__/page-header/ButtonToolBar.test.tsx",
"diff": "@@ -19,9 +19,18 @@ describe('Button Tool Bar', () => {\njest.spyOn(ButtonBarProvider, 'useButtons')\nmocked(ButtonBarProvider).useButtons.mockReturnValue(buttons)\n- const wrapper = mount(<ButtonToolBar />)\n+ const wrapper = mount(<ButtonToolBar />).find('.button-toolbar')\nexpect(wrapper.childAt(0).getElement()).toEqual(buttons[0])\nexpect(wrapper.childAt(1).getElement()).toEqual(buttons[1])\n})\n+\n+ it('should return null when there is no button in the provider', () => {\n+ jest.spyOn(ButtonBarProvider, 'useButtons')\n+ mocked(ButtonBarProvider).useButtons.mockReturnValue([])\n+\n+ const wrapper = mount(<ButtonToolBar />)\n+\n+ expect(wrapper.html()).toBeNull()\n+ })\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/index.css",
"new_path": "src/index.css",
"diff": "@@ -93,3 +93,7 @@ code {\npadding: 0;\nbackground-color: white;\n}\n+\n+.button-toolbar > button {\n+ margin-left: .5rem;\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/page-header/ButtonToolBar.tsx",
"new_path": "src/page-header/ButtonToolBar.tsx",
"diff": "@@ -3,7 +3,12 @@ import { useButtons } from './ButtonBarProvider'\nconst ButtonToolBar = () => {\nconst buttons = useButtons()\n- return <>{buttons.map((button) => button)}</>\n+\n+ if (buttons.length === 0) {\n+ return null\n+ }\n+\n+ return <div className=\"button-toolbar\">{buttons.map((button) => button)}</div>\n}\nexport default ButtonToolBar\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(button toolbar): align buttons to the right in the toolbar
fix #1852 |
288,323 | 25.02.2020 20:46:55 | 21,600 | bdf7aa1126ffcc453a7c5a5eab9d55a66186c9a0 | feat(diagnoses): add diagnoses tab | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/view/ViewPatient.test.tsx",
"new_path": "src/__tests__/patients/view/ViewPatient.test.tsx",
"diff": "@@ -13,6 +13,7 @@ import { createMemoryHistory } from 'history'\nimport RelatedPersonTab from 'patients/related-persons/RelatedPersonTab'\nimport * as ButtonBarProvider from 'page-header/ButtonBarProvider'\nimport Allergies from 'patients/allergies/Allergies'\n+import Diagnoses from 'patients/diagnoses/Diagnoses'\nimport Patient from '../../../model/Patient'\nimport PatientRepository from '../../../clients/db/PatientRepository'\nimport * as titleUtil from '../../../page-header/useTitle'\n@@ -126,11 +127,12 @@ describe('ViewPatient', () => {\nconst tabs = tabsHeader.find(Tab)\nexpect(tabsHeader).toHaveLength(1)\n- expect(tabs).toHaveLength(4)\n+ expect(tabs).toHaveLength(5)\nexpect(tabs.at(0).prop('label')).toEqual('patient.generalInformation')\nexpect(tabs.at(1).prop('label')).toEqual('patient.relatedPersons.label')\nexpect(tabs.at(2).prop('label')).toEqual('scheduling.appointments.label')\nexpect(tabs.at(3).prop('label')).toEqual('patient.allergies.label')\n+ expect(tabs.at(4).prop('label')).toEqual('patient.diagnoses.label')\n})\nit('should mark the general information tab as active and render the general information component when route is /patients/:id', async () => {\n@@ -188,7 +190,7 @@ describe('ViewPatient', () => {\nexpect(relatedPersonTab.prop('patient')).toEqual(patient)\n})\n- it('should mark the rallergies tab as active when it is clicked and render the allergies component when route is /patients/:id/allergies', async () => {\n+ it('should mark the allergies tab as active when it is clicked and render the allergies component when route is /patients/:id/allergies', async () => {\nlet wrapper: any\nawait act(async () => {\nwrapper = await setup()\n@@ -211,4 +213,28 @@ describe('ViewPatient', () => {\nexpect(allergiesTab).toHaveLength(1)\nexpect(allergiesTab.prop('patient')).toEqual(patient)\n})\n+\n+ it('should mark the diagnoses tab as active when it is clicked and render the diagnoses component when route is /patients/:id/diagnoses', async () => {\n+ let wrapper: any\n+ await act(async () => {\n+ wrapper = await setup()\n+ })\n+\n+ await act(async () => {\n+ const tabsHeader = wrapper.find(TabsHeader)\n+ const tabs = tabsHeader.find(Tab)\n+ tabs.at(4).prop('onClick')()\n+ })\n+\n+ wrapper.update()\n+\n+ const tabsHeader = wrapper.find(TabsHeader)\n+ const tabs = tabsHeader.find(Tab)\n+ const diagnosesTab = wrapper.find(Diagnoses)\n+\n+ expect(history.location.pathname).toEqual(`/patients/${patient.id}/diagnoses`)\n+ expect(tabs.at(4).prop('active')).toBeTruthy()\n+ expect(diagnosesTab).toHaveLength(1)\n+ expect(diagnosesTab.prop('patient')).toEqual(patient)\n+ })\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/locales/en-US/translation.json",
"new_path": "src/locales/en-US/translation.json",
"diff": "\"noAllergies\": \"No Allergies\"\n},\n\"addAllergyAbove\": \"Add an allergy using the button above.\"\n+ },\n+ \"diagnoses\": {\n+ \"label\": \"Diagnoses\"\n}\n},\n\"sex\": {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/diagnoses/Diagnoses.tsx",
"diff": "+import React from 'react'\n+import Patient from 'model/Patient'\n+import useAddBreadcrumbs from 'breadcrumbs/useAddBreadcrumbs'\n+\n+interface Props {\n+ patient: Patient\n+}\n+\n+const Diagnoses = (props: Props) => {\n+ const { patient } = props\n+ const breadcrumbs = [\n+ {\n+ i18nKey: 'patient.diagnoses.label',\n+ location: `/patients/${patient.id}/diagnoses`,\n+ },\n+ ]\n+ useAddBreadcrumbs(breadcrumbs)\n+\n+ return <h1>Diagnoses</h1>\n+}\n+\n+export default Diagnoses\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/view/ViewPatient.tsx",
"new_path": "src/patients/view/ViewPatient.tsx",
"diff": "@@ -6,6 +6,7 @@ import { useTranslation } from 'react-i18next'\nimport { useButtonToolbarSetter } from 'page-header/ButtonBarProvider'\nimport Allergies from 'patients/allergies/Allergies'\n+import Diagnoses from 'patients/diagnoses/Diagnoses'\nimport useTitle from '../../page-header/useTitle'\nimport { fetchPatient } from '../patient-slice'\nimport { RootState } from '../../store'\n@@ -101,6 +102,11 @@ const ViewPatient = () => {\nlabel={t('patient.allergies.label')}\nonClick={() => history.push(`/patients/${patient.id}/allergies`)}\n/>\n+ <Tab\n+ active={location.pathname === `/patients/${patient.id}/diagnoses`}\n+ label={t('patient.diagnoses.label')}\n+ onClick={() => history.push(`/patients/${patient.id}/diagnoses`)}\n+ />\n</TabsHeader>\n<Panel>\n<Route exact path=\"/patients/:id\">\n@@ -115,6 +121,9 @@ const ViewPatient = () => {\n<Route exact path=\"/patients/:id/allergies\">\n<Allergies patient={patient} />\n</Route>\n+ <Route exact path=\"/patients/:id/diagnoses\">\n+ <Diagnoses patient={patient} />\n+ </Route>\n</Panel>\n</div>\n)\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(diagnoses): add diagnoses tab |
288,323 | 01.03.2020 21:11:37 | 21,600 | e1ce6c95451116e966bee58f7c240c4952a84a32 | feat(diagnoses): adds ability to add a diagnosis | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/allergies/Allergies.test.tsx",
"new_path": "src/__tests__/patients/allergies/Allergies.test.tsx",
"diff": "@@ -9,7 +9,6 @@ import thunk from 'redux-thunk'\nimport { Router } from 'react-router'\nimport { Provider } from 'react-redux'\nimport Patient from 'model/Patient'\n-import User from 'model/User'\nimport { Button, Modal, List, ListItem, Alert } from '@hospitalrun/components'\nimport { act } from '@testing-library/react'\nimport { mocked } from 'ts-jest/utils'\n@@ -33,7 +32,7 @@ let user: any\nlet store: any\nconst setup = (patient = expectedPatient, permissions = [Permissions.AddAllergy]) => {\n- user = { permissions } as User\n+ user = { permissions }\nstore = mockStore({ patient, user })\nconst wrapper = mount(\n<Router history={history}>\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/patients/diagnoses/AddDiagnosisModal.test.tsx",
"diff": "+import '../../../__mocks__/matchMediaMock'\n+import React from 'react'\n+import { shallow, mount } from 'enzyme'\n+import { Modal, Alert } from '@hospitalrun/components'\n+import { act } from '@testing-library/react'\n+import AddDiagnosisModal from 'patients/diagnoses/AddDiagnosisModal'\n+import Diagnosis from 'model/Diagnosis'\n+\n+describe('Add Diagnosis Modal', () => {\n+ it('should render a modal with the correct labels', () => {\n+ const wrapper = shallow(\n+ <AddDiagnosisModal show onCloseButtonClick={jest.fn()} onSave={jest.fn()} />,\n+ )\n+\n+ const modal = wrapper.find(Modal)\n+ expect(modal).toHaveLength(1)\n+ expect(modal.prop('title')).toEqual('patient.diagnoses.new')\n+ expect(modal.prop('closeButton')?.children).toEqual('actions.cancel')\n+ expect(modal.prop('closeButton')?.color).toEqual('danger')\n+ expect(modal.prop('successButton')?.children).toEqual('patient.diagnoses.new')\n+ expect(modal.prop('successButton')?.color).toEqual('success')\n+ expect(modal.prop('successButton')?.icon).toEqual('add')\n+ })\n+\n+ describe('cancel', () => {\n+ it('should call the onCloseButtonClick function when the close button is clicked', () => {\n+ const onCloseButtonClickSpy = jest.fn()\n+ const wrapper = shallow(\n+ <AddDiagnosisModal show onCloseButtonClick={onCloseButtonClickSpy} onSave={jest.fn()} />,\n+ )\n+\n+ act(() => {\n+ const modal = wrapper.find(Modal)\n+ const { onClick } = modal.prop('closeButton') as any\n+ onClick()\n+ })\n+\n+ expect(onCloseButtonClickSpy).toHaveBeenCalledTimes(1)\n+ })\n+ })\n+\n+ describe('save', () => {\n+ it('should call the onSave function with the correct data when the save button is clicked', () => {\n+ const expectedName = 'expected name'\n+ const expectedDate = new Date()\n+ const onSaveSpy = jest.fn()\n+ const wrapper = mount(\n+ <AddDiagnosisModal show onCloseButtonClick={jest.fn()} onSave={onSaveSpy} />,\n+ )\n+\n+ act(() => {\n+ const input = wrapper.findWhere((c: any) => c.prop('name') === 'name')\n+ const onChange = input.prop('onChange')\n+ onChange({ target: { value: expectedName } })\n+ })\n+ wrapper.update()\n+\n+ act(() => {\n+ const input = wrapper.findWhere((c: any) => c.prop('name') === 'diagnosisDate')\n+ const onChange = input.prop('onChange')\n+ onChange(expectedDate)\n+ })\n+ wrapper.update()\n+\n+ act(() => {\n+ const modal = wrapper.find(Modal)\n+ const onSave = (modal.prop('successButton') as any).onClick\n+ onSave({} as React.MouseEvent<HTMLButtonElement>)\n+ })\n+\n+ expect(onSaveSpy).toHaveBeenCalledTimes(1)\n+ expect(onSaveSpy).toHaveBeenCalledWith({\n+ name: expectedName,\n+ diagnosisDate: expectedDate.toISOString(),\n+ } as Diagnosis)\n+ })\n+\n+ it('should display an error message if the name field is not filled out', () => {\n+ const wrapper = mount(\n+ <AddDiagnosisModal show onCloseButtonClick={jest.fn()} onSave={jest.fn()} />,\n+ )\n+\n+ act(() => {\n+ const modal = wrapper.find(Modal)\n+ const onSave = (modal.prop('successButton') as any).onClick\n+ onSave({} as React.MouseEvent<HTMLButtonElement>)\n+ })\n+ wrapper.update()\n+\n+ expect(wrapper.find(Alert)).toHaveLength(1)\n+ expect(wrapper.find(Alert).prop('title')).toEqual('states.error')\n+ expect(wrapper.find(Alert).prop('message')).toContain('patient.diagnoses.error.nameRequired')\n+ })\n+ })\n+})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/patients/diagnoses/Diagnoses.test.tsx",
"diff": "+import '../../../__mocks__/matchMediaMock'\n+import React from 'react'\n+import { mount } from 'enzyme'\n+import { createMemoryHistory } from 'history'\n+import configureMockStore from 'redux-mock-store'\n+import thunk from 'redux-thunk'\n+import Patient from 'model/Patient'\n+import Diagnosis from 'model/Diagnosis'\n+import Permissions from 'model/Permissions'\n+import { Router } from 'react-router'\n+import { Provider } from 'react-redux'\n+import Diagnoses from 'patients/diagnoses/Diagnoses'\n+import { Button, Modal, List, ListItem, Alert } from '@hospitalrun/components'\n+import { act } from 'react-dom/test-utils'\n+import { mocked } from 'ts-jest/utils'\n+import PatientRepository from 'clients/db/PatientRepository'\n+import AddDiagnosisModal from 'patients/diagnoses/AddDiagnosisModal'\n+import * as patientSlice from '../../../patients/patient-slice'\n+\n+const expectedPatient = {\n+ id: '123',\n+ diagnoses: [\n+ { id: '123', name: 'diagnosis1', diagnosisDate: new Date().toISOString() } as Diagnosis,\n+ ],\n+} as Patient\n+\n+const mockStore = configureMockStore([thunk])\n+const history = createMemoryHistory()\n+\n+let user: any\n+let store: any\n+\n+const setup = (patient = expectedPatient, permissions = [Permissions.AddDiagnosis]) => {\n+ user = { permissions }\n+ store = mockStore({ patient, user })\n+ const wrapper = mount(\n+ <Router history={history}>\n+ <Provider store={store}>\n+ <Diagnoses patient={patient} />\n+ </Provider>\n+ </Router>,\n+ )\n+\n+ return wrapper\n+}\n+describe('Diagnoses', () => {\n+ describe('add diagnoses button', () => {\n+ beforeEach(() => {\n+ jest.resetAllMocks()\n+ jest.spyOn(PatientRepository, 'saveOrUpdate')\n+ })\n+\n+ it('should render a add diagnoses button', () => {\n+ const wrapper = setup()\n+\n+ const addDiagnosisButton = wrapper.find(Button)\n+ expect(addDiagnosisButton).toHaveLength(1)\n+ expect(addDiagnosisButton.text().trim()).toEqual('patient.diagnoses.new')\n+ })\n+\n+ it('should not render a diagnoses button if the user does not have permissions', () => {\n+ const wrapper = setup(expectedPatient, [])\n+\n+ const addDiagnosisButton = wrapper.find(Button)\n+ expect(addDiagnosisButton).toHaveLength(0)\n+ })\n+\n+ it('should open the Add Diagnosis Modal', () => {\n+ const wrapper = setup()\n+\n+ act(() => {\n+ wrapper.find(Button).prop('onClick')()\n+ })\n+ wrapper.update()\n+\n+ expect(wrapper.find(Modal).prop('show')).toBeTruthy()\n+ })\n+\n+ it('should update the patient with the new diagnosis when the save button is clicked', async () => {\n+ const expectedDiagnosis = {\n+ name: 'name',\n+ diagnosisDate: new Date().toISOString(),\n+ } as Diagnosis\n+ const expectedUpdatedPatient = {\n+ ...expectedPatient,\n+ diagnoses: [...(expectedPatient.diagnoses as any), expectedDiagnosis],\n+ } as Patient\n+\n+ const mockedPatientRepository = mocked(PatientRepository, true)\n+ mockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedUpdatedPatient)\n+\n+ const wrapper = setup()\n+\n+ await act(async () => {\n+ const modal = wrapper.find(AddDiagnosisModal)\n+ await modal.prop('onSave')(expectedDiagnosis)\n+ })\n+\n+ expect(mockedPatientRepository.saveOrUpdate).toHaveBeenCalledWith(expectedUpdatedPatient)\n+ expect(store.getActions()).toContainEqual(patientSlice.updatePatientStart())\n+ expect(store.getActions()).toContainEqual(\n+ patientSlice.updatePatientSuccess(expectedUpdatedPatient),\n+ )\n+ })\n+ })\n+\n+ describe('diagnoses list', () => {\n+ it('should list the patients diagnoses', () => {\n+ const diagnoses = expectedPatient.diagnoses as Diagnosis[]\n+ const wrapper = setup()\n+\n+ const list = wrapper.find(List)\n+ const listItems = wrapper.find(ListItem)\n+\n+ expect(list).toHaveLength(1)\n+ expect(listItems).toHaveLength(diagnoses.length)\n+ })\n+\n+ it('should render a warning message if the patient does not have any diagnoses', () => {\n+ const wrapper = setup({ ...expectedPatient, diagnoses: [] })\n+\n+ const alert = wrapper.find(Alert)\n+\n+ expect(alert).toHaveLength(1)\n+ expect(alert.prop('title')).toEqual('patient.diagnoses.warning.noDiagnoses')\n+ expect(alert.prop('message')).toEqual('patient.diagnoses.addDiagnosisAbove')\n+ })\n+ })\n+})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/locales/en-US/translation.json",
"new_path": "src/locales/en-US/translation.json",
"diff": "\"addAllergyAbove\": \"Add an allergy using the button above.\"\n},\n\"diagnoses\": {\n- \"label\": \"Diagnoses\"\n+ \"label\": \"Diagnoses\",\n+ \"new\": \"Add Diagnoses\",\n+ \"diagnosisName\": \"Diagnosis Name\",\n+ \"diagnosisDate\": \"Diagnosis Date\",\n+ \"warning\": {\n+ \"noDiagnoses\": \"No Diagnoses\"\n+ },\n+ \"error\": {\n+ \"nameRequired\": \"Diagnosis Name is required.\",\n+ \"dateRequired\": \"Diagnosis Date is required.\"\n+ },\n+ \"addDiagnosisAbove\": \"Add a diagnosis using the button above.\"\n+\n}\n},\n\"sex\": {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/model/Diagnosis.ts",
"diff": "+export default interface Diagnosis {\n+ id: string\n+ name: string\n+ diagnosisDate: string\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/Patient.ts",
"new_path": "src/model/Patient.ts",
"diff": "@@ -3,6 +3,7 @@ import Name from './Name'\nimport ContactInformation from './ContactInformation'\nimport RelatedPerson from './RelatedPerson'\nimport Allergy from './Allergy'\n+import Diagnosis from './Diagnosis'\nexport default interface Patient extends AbstractDBModel, Name, ContactInformation {\nsex: string\n@@ -14,4 +15,5 @@ export default interface Patient extends AbstractDBModel, Name, ContactInformati\nfriendlyId: string\nrelatedPersons?: RelatedPerson[]\nallergies?: Allergy[]\n+ diagnoses?: Diagnosis[]\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/Permissions.ts",
"new_path": "src/model/Permissions.ts",
"diff": "@@ -5,6 +5,7 @@ enum Permissions {\nWriteAppointments = 'write:appointments',\nDeleteAppointment = 'delete:appointment',\nAddAllergy = 'write:allergy',\n+ AddDiagnosis = 'write:diagnosis',\n}\nexport default Permissions\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/diagnoses/AddDiagnosisModal.tsx",
"diff": "+import React, { useState, useEffect } from 'react'\n+import { Modal, Alert } from '@hospitalrun/components'\n+import { useTranslation } from 'react-i18next'\n+import Diagnosis from 'model/Diagnosis'\n+import TextInputWithLabelFormGroup from 'components/input/TextInputWithLabelFormGroup'\n+import DatePickerWithLabelFormGroup from 'components/input/DatePickerWithLabelFormGroup'\n+\n+interface Props {\n+ show: boolean\n+ onCloseButtonClick: () => void\n+ onSave: (diagnosis: Diagnosis) => void\n+}\n+\n+const AddDiagnosisModal = (props: Props) => {\n+ const { show, onCloseButtonClick, onSave } = props\n+ const [diagnosis, setDiagnosis] = useState({ name: '', diagnosisDate: new Date().toISOString() })\n+ const [errorMessage, setErrorMessage] = useState('')\n+\n+ const { t } = useTranslation()\n+\n+ useEffect(() => {\n+ setErrorMessage('')\n+ setDiagnosis({ name: '', diagnosisDate: new Date().toISOString() })\n+ }, [show])\n+\n+ const onSaveButtonClick = () => {\n+ let newErrorMessage = ''\n+ if (!diagnosis.name) {\n+ newErrorMessage += t('patient.diagnoses.error.nameRequired')\n+ }\n+ setErrorMessage(newErrorMessage)\n+\n+ if (!newErrorMessage) {\n+ onSave(diagnosis as Diagnosis)\n+ }\n+ }\n+\n+ const onNameChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n+ const name = event.target.value\n+ setDiagnosis((prevDiagnosis) => ({ ...prevDiagnosis, name }))\n+ }\n+\n+ const onDiagnosisDateChange = (diagnosisDate: Date) => {\n+ if (diagnosisDate) {\n+ setDiagnosis((prevDiagnosis) => ({\n+ ...prevDiagnosis,\n+ diagnosisDate: diagnosisDate.toISOString(),\n+ }))\n+ }\n+ }\n+\n+ const body = (\n+ <>\n+ <form>\n+ {errorMessage && <Alert color=\"danger\" title={t('states.error')} message={errorMessage} />}\n+ <div className=\"row\">\n+ <div className=\"col-md-12\">\n+ <div className=\"form-group\">\n+ <TextInputWithLabelFormGroup\n+ name=\"name\"\n+ label={t('patient.diagnoses.diagnosisName')}\n+ isEditable\n+ placeholder={t('patient.diagnoses.diagnosisName')}\n+ value={diagnosis.name}\n+ onChange={onNameChange}\n+ />\n+ </div>\n+ </div>\n+ </div>\n+ <div className=\"row\">\n+ <div className=\"col-md-12\">\n+ <DatePickerWithLabelFormGroup\n+ name=\"diagnosisDate\"\n+ label={t('patient.diagnoses.diagnosisDate')}\n+ value={new Date(diagnosis.diagnosisDate)}\n+ isEditable\n+ onChange={onDiagnosisDateChange}\n+ />\n+ </div>\n+ </div>\n+ </form>\n+ </>\n+ )\n+ return (\n+ <Modal\n+ show={show}\n+ toggle={onCloseButtonClick}\n+ title={t('patient.diagnoses.new')}\n+ body={body}\n+ closeButton={{\n+ children: t('actions.cancel'),\n+ color: 'danger',\n+ onClick: onCloseButtonClick,\n+ }}\n+ successButton={{\n+ children: t('patient.diagnoses.new'),\n+ color: 'success',\n+ icon: 'add',\n+ iconLocation: 'left',\n+ onClick: onSaveButtonClick,\n+ }}\n+ />\n+ )\n+}\n+\n+export default AddDiagnosisModal\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/diagnoses/Diagnoses.tsx",
"new_path": "src/patients/diagnoses/Diagnoses.tsx",
"diff": "-import React from 'react'\n+import React, { useState } from 'react'\n+import { RootState } from 'store'\nimport Patient from 'model/Patient'\nimport useAddBreadcrumbs from 'breadcrumbs/useAddBreadcrumbs'\n+import { useSelector, useDispatch } from 'react-redux'\n+import Permissions from 'model/Permissions'\n+import { Button, List, ListItem, Alert } from '@hospitalrun/components'\n+import { useTranslation } from 'react-i18next'\n+import Diagnosis from 'model/Diagnosis'\n+import { getTimestampId } from 'patients/util/timestamp-id-generator'\n+import { updatePatient } from 'patients/patient-slice'\n+import { useHistory } from 'react-router'\n+import AddDiagnosisModal from './AddDiagnosisModal'\ninterface Props {\npatient: Patient\n@@ -8,6 +18,13 @@ interface Props {\nconst Diagnoses = (props: Props) => {\nconst { patient } = props\n+ const [showDiagnosisModal, setShowDiagnosisModal] = useState(false)\n+\n+ const history = useHistory()\n+ const dispatch = useDispatch()\n+ const { t } = useTranslation()\n+ const { permissions } = useSelector((state: RootState) => state.user)\n+\nconst breadcrumbs = [\n{\ni18nKey: 'patient.diagnoses.label',\n@@ -16,7 +33,59 @@ const Diagnoses = (props: Props) => {\n]\nuseAddBreadcrumbs(breadcrumbs)\n- return <h1>Diagnoses</h1>\n+ const onAddDiagnosisModalClose = () => {\n+ setShowDiagnosisModal(false)\n+ }\n+\n+ const onDiagnosisSave = (diagnosis: Diagnosis) => {\n+ diagnosis.id = getTimestampId()\n+ const diagnoses = []\n+ if (patient.diagnoses) {\n+ diagnoses.push(...patient.diagnoses)\n+ }\n+ diagnoses.push(diagnosis)\n+ const patientToUpdate = { ...patient, diagnoses }\n+ dispatch(updatePatient(patientToUpdate, history))\n+ setShowDiagnosisModal(false)\n+ }\n+\n+ return (\n+ <>\n+ <div className=\"row\">\n+ <div className=\"col-md-12 d-flex justify-content-end\">\n+ {permissions.includes(Permissions.AddDiagnosis) && (\n+ <Button\n+ outlined\n+ color=\"success\"\n+ icon=\"add\"\n+ iconLocation=\"left\"\n+ onClick={() => setShowDiagnosisModal(true)}\n+ >\n+ {t('patient.diagnoses.new')}\n+ </Button>\n+ )}\n+ </div>\n+ </div>\n+ <br />\n+ {(!patient.diagnoses || patient.diagnoses.length === 0) && (\n+ <Alert\n+ color=\"warning\"\n+ title={t('patient.diagnoses.warning.noDiagnoses')}\n+ message={t('patient.diagnoses.addDiagnosisAbove')}\n+ />\n+ )}\n+ <List>\n+ {patient.diagnoses?.map((a: Diagnosis) => (\n+ <ListItem key={a.id}>{a.name}</ListItem>\n+ ))}\n+ </List>\n+ <AddDiagnosisModal\n+ show={showDiagnosisModal}\n+ onCloseButtonClick={onAddDiagnosisModalClose}\n+ onSave={onDiagnosisSave}\n+ />\n+ </>\n+ )\n}\nexport default Diagnoses\n"
},
{
"change_type": "MODIFY",
"old_path": "src/user/user-slice.ts",
"new_path": "src/user/user-slice.ts",
"diff": "@@ -13,6 +13,7 @@ const initialState: UserState = {\nPermissions.WriteAppointments,\nPermissions.DeleteAppointment,\nPermissions.AddAllergy,\n+ Permissions.AddDiagnosis,\n],\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(diagnoses): adds ability to add a diagnosis |
288,333 | 02.03.2020 13:12:45 | 28,800 | c9b1d327fb4af12740ad073be453cff66ffa470a | chore(deps): update react-scripts to version 3.4 | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"react-redux\": \"~7.2.0\",\n\"react-router\": \"~5.1.2\",\n\"react-router-dom\": \"~5.1.2\",\n- \"react-scripts\": \"~3.3.0\",\n+ \"react-scripts\": \"3.4.0\",\n\"redux\": \"~4.0.5\",\n\"redux-thunk\": \"~2.3.0\",\n\"typescript\": \"~3.8.2\"\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | chore(deps): update react-scripts to version 3.4 |
288,333 | 02.03.2020 19:52:40 | 28,800 | 0968c2840b2f02288e5ce79103cc227b610932ce | fix(appointments): changed appointment type 'Walk Up' to 'Walk In' | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/scheduling/appointments/AppointmentDetailForm.test.tsx",
"new_path": "src/__tests__/scheduling/appointments/AppointmentDetailForm.test.tsx",
"diff": "@@ -78,8 +78,8 @@ describe('AppointmentDetailForm', () => {\nexpect(typeSelect.prop('options')[2].value).toEqual('follow up')\nexpect(typeSelect.prop('options')[3].label).toEqual('scheduling.appointment.types.routine')\nexpect(typeSelect.prop('options')[3].value).toEqual('routine')\n- expect(typeSelect.prop('options')[4].label).toEqual('scheduling.appointment.types.walkUp')\n- expect(typeSelect.prop('options')[4].value).toEqual('walk up')\n+ expect(typeSelect.prop('options')[4].label).toEqual('scheduling.appointment.types.walkIn')\n+ expect(typeSelect.prop('options')[4].value).toEqual('walk in')\nexpect(typeSelect.prop('value')).toEqual(expectedAppointment.type)\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/locales/en-US/translation.json",
"new_path": "src/locales/en-US/translation.json",
"diff": "\"emergency\": \"Emergency\",\n\"followUp\": \"Follow Up\",\n\"routine\": \"Routine\",\n- \"walkUp\": \"Walk Up\"\n+ \"walkIn\": \"Walk In\"\n},\n\"errors\": {\n\"patientRequired\": \"Patient is required.\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/AppointmentDetailForm.tsx",
"new_path": "src/scheduling/appointments/AppointmentDetailForm.tsx",
"diff": "@@ -101,7 +101,7 @@ const AppointmentDetailForm = (props: Props) => {\n{ label: t('scheduling.appointment.types.emergency'), value: 'emergency' },\n{ label: t('scheduling.appointment.types.followUp'), value: 'follow up' },\n{ label: t('scheduling.appointment.types.routine'), value: 'routine' },\n- { label: t('scheduling.appointment.types.walkUp'), value: 'walk up' },\n+ { label: t('scheduling.appointment.types.walkIn'), value: 'walk in' },\n]}\nonChange={(event: React.ChangeEvent<HTMLSelectElement>) => {\nonSelectChange(event, 'type')\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(appointments): changed appointment type 'Walk Up' to 'Walk In' |
288,381 | 03.03.2020 11:33:20 | -21,600 | c2c491d2083a957c7469d700af79d2b6c94ebc8c | feat(patients): success alert on new related person | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"react-redux\": \"~7.2.0\",\n\"react-router\": \"~5.1.2\",\n\"react-router-dom\": \"~5.1.2\",\n- \"react-scripts\": \"~3.3.0\",\n+ \"react-scripts\": \"~3.4.0\",\n\"redux\": \"~4.0.5\",\n\"redux-thunk\": \"~2.3.0\",\n\"typescript\": \"~3.8.2\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/locales/en-US/translation.json",
"new_path": "src/locales/en-US/translation.json",
"diff": "\"newPatient\": \"New Patient\",\n\"editPatient\": \"Edit Patient\",\n\"successfullyCreated\": \"Successfully created patient\",\n- \"successfullyUpdated\": \"Successfully updated patient\"\n+ \"successfullyUpdated\": \"Successfully updated patient\",\n+ \"successfullyAddedRelatedPerson\": \"Successfully added the new related person\"\n},\n\"patient\": {\n\"suffix\": \"Suffix\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/patient-slice.ts",
"new_path": "src/patients/patient-slice.ts",
"diff": "@@ -71,7 +71,11 @@ export const createPatient = (patient: Patient, history: any): AppThunk => async\n)\n}\n-export const updatePatient = (patient: Patient, history: any): AppThunk => async (dispatch) => {\n+export const updatePatient = (\n+ patient: Patient,\n+ history: any,\n+ relatedPerson?: boolean,\n+): AppThunk => async (dispatch) => {\ndispatch(updatePatientStart())\nconst updatedPatient = await PatientRepository.saveOrUpdate(patient)\ndispatch(updatePatientSuccess(updatedPatient))\n@@ -81,6 +85,14 @@ export const updatePatient = (patient: Patient, history: any): AppThunk => async\nil8n.t('Success!'),\n`${il8n.t('patients.successfullyUpdated')} ${patient.fullName}`,\n)\n+ if (relatedPerson) {\n+ Toast(\n+ 'success',\n+ il8n.t('Success!'),\n+ `${il8n.t('patients.successfullyAddedRelatedPerson')}`,\n+ 'top-left',\n+ )\n+ }\n}\nexport default patientSlice.reducer\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/related-persons/RelatedPersonTab.tsx",
"new_path": "src/patients/related-persons/RelatedPersonTab.tsx",
"diff": "@@ -80,7 +80,7 @@ const RelatedPersonTab = (props: Props) => {\nrelatedPersons: newRelatedPersons,\n}\n- dispatch(updatePatient(patientToUpdate, history))\n+ dispatch(updatePatient(patientToUpdate, history, true))\ncloseNewRelatedPersonModal()\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(patients): success alert on new related person |
288,323 | 03.03.2020 20:06:38 | 21,600 | 1d6047d536e994618a5e6a18f03bf3c575adffe0 | feat(patients): use randomly generated code instead of sequence
BREAKING CHANGE: Any patient saved with friendly id will no longer map friendly id to the patient
object, thus not displaying it in the UI or have it available for search
fix | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"react-scripts\": \"3.4.0\",\n\"redux\": \"~4.0.5\",\n\"redux-thunk\": \"~2.3.0\",\n+ \"shortid\": \"^2.2.15\",\n\"typescript\": \"~3.8.2\"\n},\n\"repository\": {\n\"@types/react-router\": \"~5.1.2\",\n\"@types/react-router-dom\": \"~5.1.0\",\n\"@types/redux-mock-store\": \"~1.0.1\",\n+ \"@types/shortid\": \"^0.0.29\",\n\"@typescript-eslint/eslint-plugin\": \"~2.22.0\",\n\"@typescript-eslint/parser\": \"~2.22.0\",\n\"commitizen\": \"~4.0.3\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/HospitalRun.test.tsx",
"new_path": "src/__tests__/HospitalRun.test.tsx",
"diff": "@@ -84,7 +84,7 @@ describe('HospitalRun', () => {\ngivenName: 'test',\nfamilyName: 'test',\nsuffix: 'test',\n- friendlyId: 'P00001',\n+ code: 'P00001',\n} as Patient\nmockedPatientRepository.find.mockResolvedValue(patient)\n@@ -163,7 +163,7 @@ describe('HospitalRun', () => {\ngivenName: 'test',\nfamilyName: 'test',\nsuffix: 'test',\n- friendlyId: 'P00001',\n+ code: 'P00001',\n} as Patient\nmockedPatientRepository.find.mockResolvedValue(patient)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/clients/db/PatientRepository.test.ts",
"new_path": "src/__tests__/clients/db/PatientRepository.test.ts",
"diff": "@@ -2,6 +2,7 @@ import { patients } from 'config/pouchdb'\nimport PatientRepository from 'clients/db/PatientRepository'\nimport Patient from 'model/Patient'\nimport { fromUnixTime } from 'date-fns'\n+import * as shortid from 'shortid'\nasync function removeAllDocs() {\n// eslint-disable-next-line\n@@ -36,22 +37,22 @@ describe('patient repository', () => {\nawait removeAllDocs()\n})\n- it('should return all records that friendly ids match search text', async () => {\n- // same full name to prove that it is finding by friendly id\n- const expectedFriendlyId = 'P00001'\n- await patients.put({ _id: 'someId1', friendlyId: expectedFriendlyId, fullName: 'test test' })\n- await patients.put({ _id: 'someId2', friendlyId: 'P00002', fullName: 'test test' })\n+ it('should return all records that patient code matches search text', async () => {\n+ // same full name to prove that it is finding by patient code\n+ const expectedPatientCode = 'P00001'\n+ await patients.put({ _id: 'someId1', code: expectedPatientCode, fullName: 'test test' })\n+ await patients.put({ _id: 'someId2', code: 'P00002', fullName: 'test test' })\n- const result = await PatientRepository.search(expectedFriendlyId)\n+ const result = await PatientRepository.search(expectedPatientCode)\nexpect(result).toHaveLength(1)\n- expect(result[0].friendlyId).toEqual(expectedFriendlyId)\n+ expect(result[0].code).toEqual(expectedPatientCode)\n})\nit('should return all records that fullName contains search text', async () => {\n- await patients.put({ _id: 'id3333', friendlyId: 'P00002', fullName: 'blh test test blah' })\n- await patients.put({ _id: 'id4444', friendlyId: 'P00001', fullName: 'test test' })\n- await patients.put({ _id: 'id5555', friendlyId: 'P00003', fullName: 'not found' })\n+ await patients.put({ _id: 'id3333', code: 'P00002', fullName: 'blh test test blah' })\n+ await patients.put({ _id: 'id4444', code: 'P00001', fullName: 'test test' })\n+ await patients.put({ _id: 'id5555', code: 'P00003', fullName: 'not found' })\nconst result = await PatientRepository.search('test test')\n@@ -61,8 +62,8 @@ describe('patient repository', () => {\n})\nit('should match search criteria with case insensitive match', async () => {\n- await patients.put({ _id: 'id6666', friendlyId: 'P00001', fullName: 'test test' })\n- await patients.put({ _id: 'id7777', friendlyId: 'P00002', fullName: 'not found' })\n+ await patients.put({ _id: 'id6666', code: 'P00001', fullName: 'test test' })\n+ await patients.put({ _id: 'id7777', code: 'P00002', fullName: 'not found' })\nconst result = await PatientRepository.search('TEST TEST')\n@@ -100,22 +101,12 @@ describe('patient repository', () => {\nexpect(fromUnixTime(parseInt(newPatient.id, 10)).getTime() > 0).toBeTruthy()\n})\n- it('should generate a friendly id', async () => {\n+ it('should generate a patient code', async () => {\nconst newPatient = await PatientRepository.save({\nfullName: 'test1 test1',\n} as Patient)\n- expect(newPatient.friendlyId).toEqual('P00001')\n- })\n-\n- it('should sequentially generate a friendly id', async () => {\n- await patients.put({ _id: 'id9999', friendlyId: 'P00001' })\n-\n- const newPatient = await PatientRepository.save({\n- fullName: 'test3 test3',\n- } as Patient)\n-\n- expect(newPatient.friendlyId).toEqual('P00002')\n+ expect(shortid.isValid(newPatient.code)).toBeTruthy()\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/GeneralInformation.test.tsx",
"new_path": "src/__tests__/patients/GeneralInformation.test.tsx",
"diff": "@@ -42,7 +42,7 @@ describe('General Information, without isEditable', () => {\nphoneNumber: 'phoneNumber',\nemail: '[email protected]',\naddress: 'address',\n- friendlyId: 'P00001',\n+ code: 'P00001',\ndateOfBirth: startOfDay(subYears(new Date(), 30)).toISOString(),\nisApproximateDateOfBirth: false,\n} as Patient\n@@ -197,7 +197,7 @@ describe('General Information, isEditable', () => {\nphoneNumber: 'phoneNumber',\nemail: '[email protected]',\naddress: 'address',\n- friendlyId: 'P00001',\n+ code: 'P00001',\ndateOfBirth: startOfDay(subYears(new Date(), 30)).toISOString(),\nisApproximateDateOfBirth: false,\n} as Patient\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/edit/EditPatient.test.tsx",
"new_path": "src/__tests__/patients/edit/EditPatient.test.tsx",
"diff": "@@ -33,7 +33,7 @@ describe('Edit Patient', () => {\nphoneNumber: 'phoneNumber',\nemail: '[email protected]',\naddress: 'address',\n- friendlyId: 'P00001',\n+ code: 'P00001',\ndateOfBirth: new Date().toISOString(),\n} as Patient\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/list/Patients.test.tsx",
"new_path": "src/__tests__/patients/list/Patients.test.tsx",
"diff": "@@ -17,7 +17,7 @@ const middlewares = [thunk]\nconst mockStore = configureStore(middlewares)\ndescribe('Patients', () => {\n- const patients = [{ id: '123', fullName: 'test test', friendlyId: 'P12345' }]\n+ const patients = [{ id: '123', fullName: 'test test', code: 'P12345' }]\nconst mockedPatientRepository = mocked(PatientRepository, true)\nconst setup = (isLoading?: boolean) => {\n@@ -67,9 +67,7 @@ describe('Patients', () => {\nconst patientListItems = wrapper.find(ListItem)\nexpect(patientListItems).toHaveLength(1)\n- expect(patientListItems.at(0).text()).toEqual(\n- `${patients[0].fullName} (${patients[0].friendlyId})`,\n- )\n+ expect(patientListItems.at(0).text()).toEqual(`${patients[0].fullName} (${patients[0].code})`)\n})\nit('should add a \"New Patient\" button to the button tool bar', () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/view/ViewPatient.test.tsx",
"new_path": "src/__tests__/patients/view/ViewPatient.test.tsx",
"diff": "@@ -37,7 +37,7 @@ describe('ViewPatient', () => {\nphoneNumber: 'phoneNumber',\nemail: '[email protected]',\naddress: 'address',\n- friendlyId: 'P00001',\n+ code: 'P00001',\ndateOfBirth: new Date().toISOString(),\n} as Patient\n@@ -90,7 +90,7 @@ describe('ViewPatient', () => {\nawait setup()\n})\nexpect(titleUtil.default).toHaveBeenCalledWith(\n- `${patient.givenName} ${patient.familyName} ${patient.suffix} (${patient.friendlyId})`,\n+ `${patient.givenName} ${patient.familyName} ${patient.suffix} (${patient.code})`,\n)\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/scheduling/appointments/edit/EditAppointment.test.tsx",
"new_path": "src/__tests__/scheduling/appointments/edit/EditAppointment.test.tsx",
"diff": "@@ -46,7 +46,7 @@ describe('Edit Appointment', () => {\nphoneNumber: 'phoneNumber',\nemail: '[email protected]',\naddress: 'address',\n- friendlyId: 'P00001',\n+ code: 'P00001',\ndateOfBirth: new Date().toISOString(),\n} as Patient\n"
},
{
"change_type": "MODIFY",
"old_path": "src/clients/db/PatientRepository.ts",
"new_path": "src/clients/db/PatientRepository.ts",
"diff": "+import * as shortid from 'shortid'\nimport Patient from '../../model/Patient'\nimport Repository from './Repository'\nimport { patients } from '../../config/pouchdb'\n-const formatFriendlyId = (prefix: string, sequenceNumber: string) => `${prefix}${sequenceNumber}`\n+const formatPatientCode = (prefix: string, sequenceNumber: string) => `${prefix}${sequenceNumber}`\n-const generateSequenceNumber = (currentNumber: number): string => {\n- const newNumber = currentNumber + 1\n- if (newNumber < 10000) {\n- return newNumber.toString().padStart(5, '0')\n- }\n-\n- return newNumber.toString()\n-}\n+const getPatientCode = (): string => formatPatientCode('P-', shortid.generate())\nexport class PatientRepository extends Repository<Patient> {\nconstructor() {\n@@ -28,30 +22,16 @@ export class PatientRepository extends Repository<Patient> {\n},\n},\n{\n- friendlyId: text,\n+ code: text,\n},\n],\n},\n})\n}\n- async getFriendlyId(): Promise<string> {\n- const storedPatients = await this.findAll()\n-\n- if (storedPatients.length === 0) {\n- return formatFriendlyId('P', generateSequenceNumber(0))\n- }\n-\n- const maxPatient = storedPatients[storedPatients.length - 1]\n- const { friendlyId } = maxPatient\n- const currentSequenceNumber = friendlyId.slice(1, friendlyId.length)\n-\n- return formatFriendlyId('P', generateSequenceNumber(parseInt(currentSequenceNumber, 10)))\n- }\n-\nasync save(entity: Patient): Promise<Patient> {\n- const friendlyId = await this.getFriendlyId()\n- entity.friendlyId = friendlyId\n+ const patientCode = getPatientCode()\n+ entity.code = patientCode\nreturn super.save(entity)\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/Patient.ts",
"new_path": "src/model/Patient.ts",
"diff": "@@ -12,7 +12,7 @@ export default interface Patient extends AbstractDBModel, Name, ContactInformati\npreferredLanguage?: string\noccupation?: string\ntype?: string\n- friendlyId: string\n+ code: string\nrelatedPersons?: RelatedPerson[]\nallergies?: Allergy[]\ndiagnoses?: Diagnosis[]\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/edit/EditPatient.tsx",
"new_path": "src/patients/edit/EditPatient.tsx",
"diff": "@@ -12,9 +12,9 @@ import { RootState } from '../../store'\nimport { getPatientFullName, getPatientName } from '../util/patient-name-util'\nimport useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs'\n-const getFriendlyId = (p: Patient): string => {\n+const getPatientCode = (p: Patient): string => {\nif (p) {\n- return p.friendlyId\n+ return p.code\n}\nreturn ''\n@@ -30,7 +30,7 @@ const EditPatient = () => {\nconst { patient: reduxPatient, isLoading } = useSelector((state: RootState) => state.patient)\nuseTitle(\n- `${t('patients.editPatient')}: ${getPatientFullName(reduxPatient)} (${getFriendlyId(\n+ `${t('patients.editPatient')}: ${getPatientFullName(reduxPatient)} (${getPatientCode(\nreduxPatient,\n)})`,\n)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/list/Patients.tsx",
"new_path": "src/patients/list/Patients.tsx",
"diff": "@@ -50,7 +50,7 @@ const Patients = () => {\n<ul>\n{patients.map((p) => (\n<ListItem action key={p.id} onClick={() => history.push(`/patients/${p.id}`)}>\n- {p.fullName} ({p.friendlyId})\n+ {p.fullName} ({p.code})\n</ListItem>\n))}\n</ul>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/related-persons/NewRelatedPersonModal.tsx",
"new_path": "src/patients/related-persons/NewRelatedPersonModal.tsx",
"diff": "@@ -51,7 +51,7 @@ const NewRelatedPersonModal = (props: Props) => {\nonChange={onPatientSelect}\nonSearch={async (query: string) => PatientRepository.search(query)}\nrenderMenuItemChildren={(patient: Patient) => (\n- <div>{`${patient.fullName} (${patient.friendlyId})`}</div>\n+ <div>{`${patient.fullName} (${patient.code})`}</div>\n)}\n/>\n</div>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/view/ViewPatient.tsx",
"new_path": "src/patients/view/ViewPatient.tsx",
"diff": "@@ -18,9 +18,9 @@ import RelatedPerson from '../related-persons/RelatedPersonTab'\nimport useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs'\nimport AppointmentsList from '../appointments/AppointmentsList'\n-const getFriendlyId = (p: Patient): string => {\n+const getPatientCode = (p: Patient): string => {\nif (p) {\n- return p.friendlyId\n+ return p.code\n}\nreturn ''\n@@ -35,7 +35,7 @@ const ViewPatient = () => {\nconst { patient, isLoading } = useSelector((state: RootState) => state.patient)\nconst { permissions } = useSelector((state: RootState) => state.user)\n- useTitle(`${getPatientFullName(patient)} (${getFriendlyId(patient)})`)\n+ useTitle(`${getPatientFullName(patient)} (${getPatientCode(patient)})`)\nconst setButtonToolBar = useButtonToolbarSetter()\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/AppointmentDetailForm.tsx",
"new_path": "src/scheduling/appointments/AppointmentDetailForm.tsx",
"diff": "@@ -45,9 +45,7 @@ const AppointmentDetailForm = (props: Props) => {\nonChange={(p: Patient[]) => onFieldChange && onFieldChange('patientId', p[0].id)}\nonSearch={async (query: string) => PatientRepository.search(query)}\nsearchAccessor=\"fullName\"\n- renderMenuItemChildren={(p: Patient) => (\n- <div>{`${p.fullName} (${p.friendlyId})`}</div>\n- )}\n+ renderMenuItemChildren={(p: Patient) => <div>{`${p.fullName} (${p.code})`}</div>}\n/>\n</div>\n</div>\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(patients): use randomly generated code instead of sequence
BREAKING CHANGE: Any patient saved with friendly id will no longer map friendly id to the patient
object, thus not displaying it in the UI or have it available for search
fix #1876 |
288,323 | 03.03.2020 20:21:46 | 21,600 | 258cab8494ccce2830077fa4f8cfa2bf50ada0b8 | fix: use uuidv4 instead of timestamps for autogenerated ids
fix | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"redux\": \"~4.0.5\",\n\"redux-thunk\": \"~2.3.0\",\n\"shortid\": \"^2.2.15\",\n- \"typescript\": \"~3.8.2\"\n+ \"typescript\": \"~3.8.2\",\n+ \"uuid\": \"^7.0.1\"\n},\n\"repository\": {\n\"type\": \"git\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/clients/db/AppointmentRepository.test.ts",
"new_path": "src/__tests__/clients/db/AppointmentRepository.test.ts",
"diff": "import AppointmentRepository from 'clients/db/AppointmentRepository'\nimport { appointments } from 'config/pouchdb'\nimport Appointment from 'model/Appointment'\n-import { fromUnixTime } from 'date-fns'\n+\n+const uuidV4Regex = /^[A-F\\d]{8}-[A-F\\d]{4}-4[A-F\\d]{3}-[89AB][A-F\\d]{3}-[A-F\\d]{12}$/i\ndescribe('Appointment Repository', () => {\nit('should create a repository with the database set to the appointments database', () => {\n@@ -24,12 +25,12 @@ describe('Appointment Repository', () => {\n})\ndescribe('save', () => {\n- it('should create an id that is a timestamp', async () => {\n+ it('should create an id that is a uuid', async () => {\nconst newAppointment = await AppointmentRepository.save({\npatientId: 'id',\n} as Appointment)\n- expect(fromUnixTime(parseInt(newAppointment.id, 10)).getTime() > 0).toBeTruthy()\n+ expect(uuidV4Regex.test(newAppointment.id)).toBeTruthy()\nawait appointments.remove(await appointments.get(newAppointment.id))\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/clients/db/PatientRepository.test.ts",
"new_path": "src/__tests__/clients/db/PatientRepository.test.ts",
"diff": "import { patients } from 'config/pouchdb'\nimport PatientRepository from 'clients/db/PatientRepository'\nimport Patient from 'model/Patient'\n-import { fromUnixTime } from 'date-fns'\nimport * as shortid from 'shortid'\n+const uuidV4Regex = /^[A-F\\d]{8}-[A-F\\d]{4}-4[A-F\\d]{3}-[89AB][A-F\\d]{3}-[A-F\\d]{12}$/i\n+\nasync function removeAllDocs() {\n// eslint-disable-next-line\nconst allDocs = await patients.allDocs({ include_docs: true })\n@@ -93,12 +94,12 @@ describe('patient repository', () => {\nawait removeAllDocs()\n})\n- it('should generate an id that is a timestamp for the patient', async () => {\n+ it('should generate an id that is a uuid for the patient', async () => {\nconst newPatient = await PatientRepository.save({\nfullName: 'test test',\n} as Patient)\n- expect(fromUnixTime(parseInt(newPatient.id, 10)).getTime() > 0).toBeTruthy()\n+ expect(uuidV4Regex.test(newPatient.id)).toBeTruthy()\n})\nit('should generate a patient code', async () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/clients/db/Repository.ts",
"new_path": "src/clients/db/Repository.ts",
"diff": "/* eslint \"@typescript-eslint/camelcase\": \"off\" */\nimport { getTime } from 'date-fns'\n+import { v4 as uuidv4 } from 'uuid'\nimport AbstractDBModel from '../../model/AbstractDBModel'\nfunction mapRow(row: any): any {\n@@ -48,7 +49,7 @@ export default class Repository<T extends AbstractDBModel> {\nasync save(entity: T): Promise<T> {\nconst { id, rev, ...valuesToSave } = entity\n- const savedEntity = await this.db.put({ _id: getTime(new Date()).toString(), ...valuesToSave })\n+ const savedEntity = await this.db.put({ _id: uuidv4(), ...valuesToSave })\nreturn this.find(savedEntity.id)\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix: use uuidv4 instead of timestamps for autogenerated ids
fix #1877 |
288,323 | 03.03.2020 21:07:26 | 21,600 | 16ab294a5391406e153532179c2b92fa26a64e57 | feat: add created date and last updated date
fix | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/clients/db/AppointmentRepository.test.ts",
"new_path": "src/__tests__/clients/db/AppointmentRepository.test.ts",
"diff": "import AppointmentRepository from 'clients/db/AppointmentRepository'\nimport { appointments } from 'config/pouchdb'\nimport Appointment from 'model/Appointment'\n+import { fromUnixTime } from 'date-fns'\nconst uuidV4Regex = /^[A-F\\d]{8}-[A-F\\d]{4}-4[A-F\\d]{3}-[89AB][A-F\\d]{3}-[A-F\\d]{12}$/i\n@@ -34,5 +35,16 @@ describe('Appointment Repository', () => {\nawait appointments.remove(await appointments.get(newAppointment.id))\n})\n+\n+ it('should generate a timestamp for created date and last updated date', async () => {\n+ const newAppointment = await AppointmentRepository.save({\n+ patientId: 'id',\n+ } as Appointment)\n+\n+ expect(newAppointment.createdDate).toBeDefined()\n+ expect(fromUnixTime(newAppointment.createdDate).getTime() > 0).toBeTruthy()\n+ expect(newAppointment.lastUpdatedDate).toBeDefined()\n+ expect(fromUnixTime(newAppointment.lastUpdatedDate).getTime() > 0).toBeTruthy()\n+ })\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/clients/db/PatientRepository.test.ts",
"new_path": "src/__tests__/clients/db/PatientRepository.test.ts",
"diff": "@@ -2,6 +2,7 @@ import { patients } from 'config/pouchdb'\nimport PatientRepository from 'clients/db/PatientRepository'\nimport Patient from 'model/Patient'\nimport * as shortid from 'shortid'\n+import { fromUnixTime, getTime, isAfter } from 'date-fns'\nconst uuidV4Regex = /^[A-F\\d]{8}-[A-F\\d]{4}-4[A-F\\d]{3}-[89AB][A-F\\d]{3}-[A-F\\d]{12}$/i\n@@ -109,6 +110,29 @@ describe('patient repository', () => {\nexpect(shortid.isValid(newPatient.code)).toBeTruthy()\n})\n+\n+ it('should generate a timestamp for created date and last updated date', async () => {\n+ const newPatient = await PatientRepository.save({\n+ fullName: 'test1 test1',\n+ } as Patient)\n+\n+ expect(newPatient.createdDate).toBeDefined()\n+ expect(fromUnixTime(newPatient.createdDate).getTime() > 0).toBeTruthy()\n+ expect(newPatient.lastUpdatedDate).toBeDefined()\n+ expect(fromUnixTime(newPatient.lastUpdatedDate).getTime() > 0).toBeTruthy()\n+ })\n+\n+ it('should override the created date and last updated date even if one was passed in', async () => {\n+ const unexpectedTime = getTime(new Date(2020, 2, 1))\n+ const newPatient = await PatientRepository.save({\n+ fullName: 'test1 test1',\n+ createdDate: unexpectedTime,\n+ lastUpdatedDate: unexpectedTime,\n+ } as Patient)\n+\n+ expect(newPatient.createdDate).not.toEqual(unexpectedTime)\n+ expect(newPatient.lastUpdatedDate).not.toEqual(unexpectedTime)\n+ })\n})\ndescribe('saveOrUpdate', () => {\n@@ -156,6 +180,30 @@ describe('patient repository', () => {\nexpect(updatedPatient.fullName).toEqual(existingPatient.fullName)\nexpect(updatedPatient.givenName).toEqual('givenName')\n})\n+\n+ it('should update the last updated date', async () => {\n+ const existingPatient = await PatientRepository.save({\n+ fullName: 'test7 test7',\n+ } as Patient)\n+ existingPatient.givenName = 'givenName'\n+\n+ const updatedPatient = await PatientRepository.saveOrUpdate(existingPatient)\n+\n+ expect(isAfter(updatedPatient.lastUpdatedDate, updatedPatient.createdDate)).toBeTruthy()\n+ expect(updatedPatient.lastUpdatedDate).not.toEqual(existingPatient.lastUpdatedDate)\n+ })\n+\n+ it('should not update the created date', async () => {\n+ const existingPatient = await PatientRepository.save({\n+ fullName: 'test7 test7',\n+ } as Patient)\n+ existingPatient.givenName = 'givenName'\n+ existingPatient.createdDate = getTime(new Date())\n+\n+ const updatedPatient = await PatientRepository.saveOrUpdate(existingPatient)\n+\n+ expect(updatedPatient.createdDate).toEqual(existingPatient.createdDate)\n+ })\n})\ndescribe('delete', () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/clients/db/Repository.ts",
"new_path": "src/clients/db/Repository.ts",
"diff": "@@ -48,8 +48,15 @@ export default class Repository<T extends AbstractDBModel> {\n}\nasync save(entity: T): Promise<T> {\n+ const currentTime = getTime(new Date())\n+\nconst { id, rev, ...valuesToSave } = entity\n- const savedEntity = await this.db.put({ _id: uuidv4(), ...valuesToSave })\n+ const savedEntity = await this.db.put({\n+ _id: uuidv4(),\n+ ...valuesToSave,\n+ createdDate: currentTime,\n+ lastUpdatedDate: currentTime,\n+ })\nreturn this.find(savedEntity.id)\n}\n@@ -66,6 +73,7 @@ export default class Repository<T extends AbstractDBModel> {\n_id: id,\n_rev: rev,\n...dataToSave,\n+ lastUpdatedDate: getTime(new Date()),\n}\nawait this.db.put(entityToUpdate)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/AbstractDBModel.ts",
"new_path": "src/model/AbstractDBModel.ts",
"diff": "export default interface AbstractDBModel {\nid: string\nrev: string\n+ createdDate: number\n+ lastUpdatedDate: number\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat: add created date and last updated date
fix #1879 |
288,323 | 03.03.2020 21:56:30 | 21,600 | 4b94d53bf839ca6b99c71c9009a25edb94bb8522 | fix: fix time based test | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/clients/db/PatientRepository.test.ts",
"new_path": "src/__tests__/clients/db/PatientRepository.test.ts",
"diff": "@@ -182,10 +182,9 @@ describe('patient repository', () => {\n})\nit('should update the last updated date', async () => {\n- const existingPatient = await PatientRepository.save({\n- fullName: 'test7 test7',\n- } as Patient)\n- existingPatient.givenName = 'givenName'\n+ const time = getTime(new Date(2020, 1, 1))\n+ await patients.put({ _id: 'id2222222', createdDate: time, lastUpdatedDate: time })\n+ const existingPatient = await PatientRepository.find('id2222222')\nconst updatedPatient = await PatientRepository.saveOrUpdate(existingPatient)\n@@ -194,12 +193,9 @@ describe('patient repository', () => {\n})\nit('should not update the created date', async () => {\n- const existingPatient = await PatientRepository.save({\n- fullName: 'test7 test7',\n- } as Patient)\n- existingPatient.givenName = 'givenName'\n- existingPatient.createdDate = getTime(new Date())\n-\n+ const time = getTime(new Date(2020, 1, 1))\n+ await patients.put({ _id: 'id111111', createdDate: time, lastUpdatedDate: time })\n+ const existingPatient = await PatientRepository.find('id111111')\nconst updatedPatient = await PatientRepository.saveOrUpdate(existingPatient)\nexpect(updatedPatient.createdDate).toEqual(existingPatient.createdDate)\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix: fix time based test |
288,381 | 04.03.2020 12:44:09 | -21,600 | bd22057c5b599005da20ba3cc757178ac3a1bb1d | feat(patients): addRealtedPerson function | [
{
"change_type": "MODIFY",
"old_path": "src/patients/patient-slice.ts",
"new_path": "src/patients/patient-slice.ts",
"diff": "@@ -71,11 +71,19 @@ export const createPatient = (patient: Patient, history: any): AppThunk => async\n)\n}\n-export const updatePatient = (\n- patient: Patient,\n- history: any,\n- relatedPerson?: boolean,\n-): AppThunk => async (dispatch) => {\n+export const updatePatient = (patient: Patient, history: any): AppThunk => async (dispatch) => {\n+ dispatch(updatePatientStart())\n+ const updatedPatient = await PatientRepository.saveOrUpdate(patient)\n+ dispatch(updatePatientSuccess(updatedPatient))\n+ history.push(`/patients/${updatedPatient.id}`)\n+ Toast(\n+ 'success',\n+ il8n.t('Success!'),\n+ `${il8n.t('patients.successfullyUpdated')} ${patient.fullName}`,\n+ )\n+}\n+\n+export const addRelatedPerson = (patient: Patient, history: any): AppThunk => async (dispatch) => {\ndispatch(updatePatientStart())\nconst updatedPatient = await PatientRepository.saveOrUpdate(patient)\ndispatch(updatePatientSuccess(updatedPatient))\n@@ -85,7 +93,6 @@ export const updatePatient = (\nil8n.t('Success!'),\n`${il8n.t('patients.successfullyUpdated')} ${patient.fullName}`,\n)\n- if (relatedPerson) {\nToast(\n'success',\nil8n.t('Success!'),\n@@ -93,6 +100,5 @@ export const updatePatient = (\n'top-left',\n)\n}\n-}\nexport default patientSlice.reducer\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/related-persons/RelatedPersonTab.tsx",
"new_path": "src/patients/related-persons/RelatedPersonTab.tsx",
"diff": "@@ -5,7 +5,7 @@ import RelatedPerson from 'model/RelatedPerson'\nimport { useTranslation } from 'react-i18next'\nimport { useHistory } from 'react-router'\nimport Patient from 'model/Patient'\n-import { updatePatient } from 'patients/patient-slice'\n+import { addRelatedPerson } from 'patients/patient-slice'\nimport { useDispatch, useSelector } from 'react-redux'\nimport { RootState } from 'store'\nimport Permissions from 'model/Permissions'\n@@ -80,7 +80,7 @@ const RelatedPersonTab = (props: Props) => {\nrelatedPersons: newRelatedPersons,\n}\n- dispatch(updatePatient(patientToUpdate, history, true))\n+ dispatch(addRelatedPerson(patientToUpdate, history))\ncloseNewRelatedPersonModal()\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(patients): addRealtedPerson function |
288,323 | 04.03.2020 19:34:06 | 21,600 | 8827df18d7141b9b6f94d00fc99b1bf00fae66dc | feat: change to use standard naming and use iso dates
fix | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/clients/db/AppointmentRepository.test.ts",
"new_path": "src/__tests__/clients/db/AppointmentRepository.test.ts",
"diff": "import AppointmentRepository from 'clients/db/AppointmentRepository'\nimport { appointments } from 'config/pouchdb'\nimport Appointment from 'model/Appointment'\n-import { fromUnixTime } from 'date-fns'\nconst uuidV4Regex = /^[A-F\\d]{8}-[A-F\\d]{4}-4[A-F\\d]{3}-[89AB][A-F\\d]{3}-[A-F\\d]{12}$/i\n@@ -41,10 +40,8 @@ describe('Appointment Repository', () => {\npatientId: 'id',\n} as Appointment)\n- expect(newAppointment.createdDate).toBeDefined()\n- expect(fromUnixTime(newAppointment.createdDate).getTime() > 0).toBeTruthy()\n- expect(newAppointment.lastUpdatedDate).toBeDefined()\n- expect(fromUnixTime(newAppointment.lastUpdatedDate).getTime() > 0).toBeTruthy()\n+ expect(newAppointment.createdAt).toBeDefined()\n+ expect(newAppointment.updatedAt).toBeDefined()\n})\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/clients/db/PatientRepository.test.ts",
"new_path": "src/__tests__/clients/db/PatientRepository.test.ts",
"diff": "@@ -2,7 +2,7 @@ import { patients } from 'config/pouchdb'\nimport PatientRepository from 'clients/db/PatientRepository'\nimport Patient from 'model/Patient'\nimport * as shortid from 'shortid'\n-import { fromUnixTime, getTime, isAfter } from 'date-fns'\n+import { getTime, isAfter } from 'date-fns'\nconst uuidV4Regex = /^[A-F\\d]{8}-[A-F\\d]{4}-4[A-F\\d]{3}-[89AB][A-F\\d]{3}-[A-F\\d]{12}$/i\n@@ -116,22 +116,20 @@ describe('patient repository', () => {\nfullName: 'test1 test1',\n} as Patient)\n- expect(newPatient.createdDate).toBeDefined()\n- expect(fromUnixTime(newPatient.createdDate).getTime() > 0).toBeTruthy()\n- expect(newPatient.lastUpdatedDate).toBeDefined()\n- expect(fromUnixTime(newPatient.lastUpdatedDate).getTime() > 0).toBeTruthy()\n+ expect(newPatient.createdAt).toBeDefined()\n+ expect(newPatient.updatedAt).toBeDefined()\n})\nit('should override the created date and last updated date even if one was passed in', async () => {\n- const unexpectedTime = getTime(new Date(2020, 2, 1))\n+ const unexpectedTime = new Date(2020, 2, 1).toISOString()\nconst newPatient = await PatientRepository.save({\nfullName: 'test1 test1',\n- createdDate: unexpectedTime,\n- lastUpdatedDate: unexpectedTime,\n+ createdAt: unexpectedTime,\n+ updatedAt: unexpectedTime,\n} as Patient)\n- expect(newPatient.createdDate).not.toEqual(unexpectedTime)\n- expect(newPatient.lastUpdatedDate).not.toEqual(unexpectedTime)\n+ expect(newPatient.createdAt).not.toEqual(unexpectedTime)\n+ expect(newPatient.updatedAt).not.toEqual(unexpectedTime)\n})\n})\n@@ -182,23 +180,25 @@ describe('patient repository', () => {\n})\nit('should update the last updated date', async () => {\n- const time = getTime(new Date(2020, 1, 1))\n- await patients.put({ _id: 'id2222222', createdDate: time, lastUpdatedDate: time })\n+ const time = new Date(2020, 1, 1).toISOString()\n+ await patients.put({ _id: 'id2222222', createdAt: time, updatedAt: time })\nconst existingPatient = await PatientRepository.find('id2222222')\nconst updatedPatient = await PatientRepository.saveOrUpdate(existingPatient)\n- expect(isAfter(updatedPatient.lastUpdatedDate, updatedPatient.createdDate)).toBeTruthy()\n- expect(updatedPatient.lastUpdatedDate).not.toEqual(existingPatient.lastUpdatedDate)\n+ expect(\n+ isAfter(new Date(updatedPatient.updatedAt), new Date(updatedPatient.createdAt)),\n+ ).toBeTruthy()\n+ expect(updatedPatient.updatedAt).not.toEqual(existingPatient.updatedAt)\n})\nit('should not update the created date', async () => {\nconst time = getTime(new Date(2020, 1, 1))\n- await patients.put({ _id: 'id111111', createdDate: time, lastUpdatedDate: time })\n+ await patients.put({ _id: 'id111111', createdAt: time, updatedAt: time })\nconst existingPatient = await PatientRepository.find('id111111')\nconst updatedPatient = await PatientRepository.saveOrUpdate(existingPatient)\n- expect(updatedPatient.createdDate).toEqual(existingPatient.createdDate)\n+ expect(updatedPatient.createdAt).toEqual(existingPatient.createdAt)\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/clients/db/Repository.ts",
"new_path": "src/clients/db/Repository.ts",
"diff": "/* eslint \"@typescript-eslint/camelcase\": \"off\" */\n-import { getTime } from 'date-fns'\nimport { v4 as uuidv4 } from 'uuid'\nimport AbstractDBModel from '../../model/AbstractDBModel'\n@@ -48,14 +47,14 @@ export default class Repository<T extends AbstractDBModel> {\n}\nasync save(entity: T): Promise<T> {\n- const currentTime = getTime(new Date())\n+ const currentTime = new Date().toISOString()\nconst { id, rev, ...valuesToSave } = entity\nconst savedEntity = await this.db.put({\n_id: uuidv4(),\n...valuesToSave,\n- createdDate: currentTime,\n- lastUpdatedDate: currentTime,\n+ createdAt: currentTime,\n+ updatedAt: currentTime,\n})\nreturn this.find(savedEntity.id)\n}\n@@ -73,7 +72,7 @@ export default class Repository<T extends AbstractDBModel> {\n_id: id,\n_rev: rev,\n...dataToSave,\n- lastUpdatedDate: getTime(new Date()),\n+ updatedAt: new Date().toISOString(),\n}\nawait this.db.put(entityToUpdate)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/AbstractDBModel.ts",
"new_path": "src/model/AbstractDBModel.ts",
"diff": "export default interface AbstractDBModel {\nid: string\nrev: string\n- createdDate: number\n- lastUpdatedDate: number\n+ createdAt: string\n+ updatedAt: string\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat: change to use standard naming and use iso dates
fix #1879 |
288,323 | 04.03.2020 19:43:39 | 21,600 | a6e97ea019ccb14cf459d7f265fee8bd469ac1f8 | fix: use a different style import | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/clients/db/PatientRepository.test.ts",
"new_path": "src/__tests__/clients/db/PatientRepository.test.ts",
"diff": "import { patients } from 'config/pouchdb'\nimport PatientRepository from 'clients/db/PatientRepository'\nimport Patient from 'model/Patient'\n-import * as shortid from 'shortid'\n+import shortid from 'shortid'\nimport { getTime, isAfter } from 'date-fns'\nconst uuidV4Regex = /^[A-F\\d]{8}-[A-F\\d]{4}-4[A-F\\d]{3}-[89AB][A-F\\d]{3}-[A-F\\d]{12}$/i\n"
},
{
"change_type": "MODIFY",
"old_path": "src/clients/db/PatientRepository.ts",
"new_path": "src/clients/db/PatientRepository.ts",
"diff": "-import * as shortid from 'shortid'\n+import shortid from 'shortid'\nimport Patient from '../../model/Patient'\nimport Repository from './Repository'\nimport { patients } from '../../config/pouchdb'\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix: use a different style import |
288,323 | 04.03.2020 21:27:05 | 21,600 | 73677e2df83ef0032b9c3f1fe4a9da94d87b1e5b | feat(patients): fixes notifactions for updating/creating patient | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/allergies/Allergies.test.tsx",
"new_path": "src/__tests__/patients/allergies/Allergies.test.tsx",
"diff": "@@ -10,6 +10,7 @@ import { Router } from 'react-router'\nimport { Provider } from 'react-redux'\nimport Patient from 'model/Patient'\nimport { Button, Modal, List, ListItem, Alert } from '@hospitalrun/components'\n+import * as components from '@hospitalrun/components'\nimport { act } from '@testing-library/react'\nimport { mocked } from 'ts-jest/utils'\nimport PatientRepository from 'clients/db/PatientRepository'\n@@ -104,6 +105,33 @@ describe('Allergies', () => {\npatientSlice.updatePatientSuccess(expectedUpdatedPatient),\n)\n})\n+\n+ it('should display a success message after the allergy is successfully added', async () => {\n+ jest.spyOn(components, 'Toast')\n+ const mockedComponents = mocked(components, true)\n+\n+ const expectedAllergy = { name: 'name' } as Allergy\n+ const expectedUpdatedPatient = {\n+ ...expectedPatient,\n+ allergies: [...(expectedPatient.allergies as any), expectedAllergy],\n+ } as Patient\n+\n+ const mockedPatientRepository = mocked(PatientRepository, true)\n+ mockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedUpdatedPatient)\n+\n+ const wrapper = setup()\n+\n+ await act(async () => {\n+ const modal = wrapper.find(NewAllergyModal)\n+ await modal.prop('onSave')(expectedAllergy)\n+ })\n+\n+ expect(mockedComponents.Toast).toHaveBeenCalledWith(\n+ 'success',\n+ 'Success!',\n+ 'patient.allergies.successfullyAdded',\n+ )\n+ })\n})\ndescribe('allergy list', () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/diagnoses/Diagnoses.test.tsx",
"new_path": "src/__tests__/patients/diagnoses/Diagnoses.test.tsx",
"diff": "@@ -11,6 +11,7 @@ import { Router } from 'react-router'\nimport { Provider } from 'react-redux'\nimport Diagnoses from 'patients/diagnoses/Diagnoses'\nimport { Button, Modal, List, ListItem, Alert } from '@hospitalrun/components'\n+import * as components from '@hospitalrun/components'\nimport { act } from 'react-dom/test-utils'\nimport { mocked } from 'ts-jest/utils'\nimport PatientRepository from 'clients/db/PatientRepository'\n@@ -102,6 +103,36 @@ describe('Diagnoses', () => {\npatientSlice.updatePatientSuccess(expectedUpdatedPatient),\n)\n})\n+\n+ it('should display a success message when successfully added', async () => {\n+ jest.spyOn(components, 'Toast')\n+ const mockedComponents = mocked(components, true)\n+\n+ const expectedDiagnosis = {\n+ name: 'name',\n+ diagnosisDate: new Date().toISOString(),\n+ } as Diagnosis\n+ const expectedUpdatedPatient = {\n+ ...expectedPatient,\n+ diagnoses: [...(expectedPatient.diagnoses as any), expectedDiagnosis],\n+ } as Patient\n+\n+ const mockedPatientRepository = mocked(PatientRepository, true)\n+ mockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedUpdatedPatient)\n+\n+ const wrapper = setup()\n+\n+ await act(async () => {\n+ const modal = wrapper.find(AddDiagnosisModal)\n+ await modal.prop('onSave')(expectedDiagnosis)\n+ })\n+\n+ expect(mockedComponents.Toast).toHaveBeenCalledWith(\n+ 'success',\n+ 'Success!',\n+ 'patient.diagnoses.successfullyAdded',\n+ )\n+ })\n})\ndescribe('diagnoses list', () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/new/NewPatient.test.tsx",
"new_path": "src/__tests__/patients/new/NewPatient.test.tsx",
"diff": "@@ -9,6 +9,7 @@ import { act } from 'react-dom/test-utils'\nimport { Button } from '@hospitalrun/components'\nimport configureMockStore, { MockStore } from 'redux-mock-store'\nimport thunk from 'redux-thunk'\n+import * as components from '@hospitalrun/components'\nimport NewPatient from '../../../patients/new/NewPatient'\nimport GeneralInformation from '../../../patients/GeneralInformation'\n@@ -126,6 +127,38 @@ describe('New Patient', () => {\nexpect(store.getActions()).toContainEqual(patientSlice.createPatientSuccess())\n})\n+ it('should navigate to /patients/:id and display a message after a new patient is successfully created', async () => {\n+ jest.spyOn(components, 'Toast')\n+ const mockedComponents = mocked(components, true)\n+ let wrapper: any\n+ await act(async () => {\n+ wrapper = await setup()\n+ })\n+\n+ const generalInformationForm = wrapper.find(GeneralInformation)\n+\n+ act(() => {\n+ generalInformationForm.prop('onFieldChange')('givenName', 'first')\n+ })\n+\n+ wrapper.update()\n+\n+ const saveButton = wrapper.find(Button).at(0)\n+ const onClick = saveButton.prop('onClick') as any\n+ expect(saveButton.text().trim()).toEqual('actions.save')\n+\n+ await act(async () => {\n+ await onClick()\n+ })\n+\n+ expect(history.location.pathname).toEqual(`/patients/${patient.id}`)\n+ expect(mockedComponents.Toast).toHaveBeenCalledWith(\n+ 'success',\n+ 'Success!',\n+ `patients.successfullyCreated ${patient.fullName}`,\n+ )\n+ })\n+\nit('should navigate to /patients when cancel is clicked', async () => {\nlet wrapper: any\nawait act(async () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/patient-slice.test.ts",
"new_path": "src/__tests__/patients/patient-slice.test.ts",
"diff": "import '../../__mocks__/matchMediaMock'\nimport { AnyAction } from 'redux'\nimport { mocked } from 'ts-jest/utils'\n-import { createMemoryHistory } from 'history'\nimport * as components from '@hospitalrun/components'\nimport patient, {\n@@ -113,7 +112,7 @@ describe('patients slice', () => {\nid: 'sliceId1',\n} as Patient\n- await createPatient(expectedPatient, createMemoryHistory())(dispatch, getState, null)\n+ await createPatient(expectedPatient)(dispatch, getState, null)\nexpect(dispatch).toHaveBeenCalledWith({ type: createPatientStart.type })\n})\n@@ -127,7 +126,7 @@ describe('patients slice', () => {\nid: 'sliceId2',\n} as Patient\n- await createPatient(expectedPatient, createMemoryHistory())(dispatch, getState, null)\n+ await createPatient(expectedPatient)(dispatch, getState, null)\nexpect(PatientRepository.save).toHaveBeenCalledWith(expectedPatient)\n})\n@@ -141,29 +140,13 @@ describe('patients slice', () => {\nid: 'slideId3',\n} as Patient\n- await createPatient(expectedPatient, createMemoryHistory())(dispatch, getState, null)\n+ await createPatient(expectedPatient)(dispatch, getState, null)\nexpect(dispatch).toHaveBeenCalledWith({ type: createPatientSuccess.type })\n})\n- it('should navigate to the /patients/:id where id is the new patient id', async () => {\n- const expectedPatientId = 'sliceId4'\n- jest.spyOn(PatientRepository, 'save')\n- const mockedPatientRepository = mocked(PatientRepository, true)\n- mockedPatientRepository.save.mockResolvedValue({ id: expectedPatientId } as Patient)\n- const history = createMemoryHistory()\n-\n- const dispatch = jest.fn()\n- const getState = jest.fn()\n- const expectedPatient = {} as Patient\n-\n- await createPatient(expectedPatient, history)(dispatch, getState, null)\n-\n- expect(history.entries[1].pathname).toEqual(`/patients/${expectedPatientId}`)\n- })\n-\n- it('should call the Toaster function with the correct data', async () => {\n- jest.spyOn(components, 'Toast')\n+ it('should call the on success function', async () => {\n+ const onSuccessSpy = jest.fn()\nconst expectedPatientId = 'sliceId5'\nconst expectedFullName = 'John Doe II'\nconst expectedPatient = {\n@@ -173,18 +156,13 @@ describe('patients slice', () => {\njest.spyOn(PatientRepository, 'save')\nconst mockedPatientRepository = mocked(PatientRepository, true)\nmockedPatientRepository.save.mockResolvedValue(expectedPatient)\n- const mockedComponents = mocked(components, true)\n- const history = createMemoryHistory()\nconst dispatch = jest.fn()\nconst getState = jest.fn()\n- await createPatient(expectedPatient, history)(dispatch, getState, null)\n+ await createPatient(expectedPatient, onSuccessSpy)(dispatch, getState, null)\n- expect(mockedComponents.Toast).toHaveBeenCalledWith(\n- 'success',\n- 'Success!',\n- `patients.successfullyCreated ${expectedFullName}`,\n- )\n+ expect(onSuccessSpy).toHaveBeenCalled()\n+ expect(onSuccessSpy).toHaveBeenCalledWith(expectedPatient)\n})\n})\n@@ -248,7 +226,7 @@ describe('patients slice', () => {\nconst mockedPatientRepository = mocked(PatientRepository, true)\nmockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedPatient)\n- await updatePatient(expectedPatient, createMemoryHistory())(dispatch, getState, null)\n+ await updatePatient(expectedPatient)(dispatch, getState, null)\nexpect(dispatch).toHaveBeenCalledWith({ type: updatePatientStart.type })\n})\n@@ -262,7 +240,7 @@ describe('patients slice', () => {\nconst mockedPatientRepository = mocked(PatientRepository, true)\nmockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedPatient)\n- await updatePatient(expectedPatient, createMemoryHistory())(dispatch, getState, null)\n+ await updatePatient(expectedPatient)(dispatch, getState, null)\nexpect(PatientRepository.saveOrUpdate).toHaveBeenCalledWith(expectedPatient)\n})\n@@ -276,7 +254,7 @@ describe('patients slice', () => {\nconst mockedPatientRepository = mocked(PatientRepository, true)\nmockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedPatient)\n- await updatePatient(expectedPatient, createMemoryHistory())(dispatch, getState, null)\n+ await updatePatient(expectedPatient)(dispatch, getState, null)\nexpect(dispatch).toHaveBeenCalledWith({\ntype: updatePatientSuccess.type,\n@@ -284,7 +262,8 @@ describe('patients slice', () => {\n})\n})\n- it('should call the Toaster function with the correct data', async () => {\n+ it('should call the onSuccess function', async () => {\n+ const onSuccessSpy = jest.fn()\njest.spyOn(components, 'Toast')\nconst expectedPatientId = 'sliceId11'\nconst fullName = 'John Doe II'\n@@ -294,18 +273,13 @@ describe('patients slice', () => {\n} as Patient\nconst mockedPatientRepository = mocked(PatientRepository, true)\nmockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedPatient)\n- const mockedComponents = mocked(components, true)\n- const history = createMemoryHistory()\nconst dispatch = jest.fn()\nconst getState = jest.fn()\n- await updatePatient(expectedPatient, history)(dispatch, getState, null)\n+ await updatePatient(expectedPatient, onSuccessSpy)(dispatch, getState, null)\n- expect(mockedComponents.Toast).toHaveBeenCalledWith(\n- 'success',\n- 'Success!',\n- `patients.successfullyUpdated ${fullName}`,\n- )\n+ expect(onSuccessSpy).toHaveBeenCalled()\n+ expect(onSuccessSpy).toHaveBeenCalledWith(expectedPatient)\n})\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/related-persons/RelatedPersons.test.tsx",
"new_path": "src/__tests__/patients/related-persons/RelatedPersons.test.tsx",
"diff": "@@ -5,6 +5,8 @@ import { createMemoryHistory } from 'history'\nimport { mount } from 'enzyme'\nimport RelatedPersonTab from 'patients/related-persons/RelatedPersonTab'\nimport { Button, List, ListItem, Alert } from '@hospitalrun/components'\n+import * as components from '@hospitalrun/components'\n+\nimport NewRelatedPersonModal from 'patients/related-persons/NewRelatedPersonModal'\nimport { act } from '@testing-library/react'\nimport PatientRepository from 'clients/db/PatientRepository'\n@@ -26,8 +28,12 @@ describe('Related Persons Tab', () => {\ndescribe('Add New Related Person', () => {\nlet patient: any\nlet user: any\n+ jest.spyOn(components, 'Toast')\n+ let mockedComponents = mocked(components, true)\nbeforeEach(() => {\n+ jest.resetAllMocks()\n+ mockedComponents = mocked(components, true)\nhistory = createMemoryHistory()\npatient = {\n@@ -150,6 +156,21 @@ describe('Related Persons Tab', () => {\nconst newRelatedPersonModal = wrapper.find(NewRelatedPersonModal)\nexpect(newRelatedPersonModal.prop('show')).toBeFalsy()\n})\n+\n+ it('should display a success message when the new related person is added', async () => {\n+ await act(async () => {\n+ const newRelatedPersonModal = wrapper.find(NewRelatedPersonModal)\n+ const onSave = newRelatedPersonModal.prop('onSave') as any\n+ await onSave({ patientId: 'testMessage', type: 'type' })\n+ })\n+ wrapper.update()\n+\n+ expect(mockedComponents.Toast).toHaveBeenCalledWith(\n+ 'success',\n+ 'Success!',\n+ 'patient.relatedPersons.successfullyAdded',\n+ )\n+ })\n})\ndescribe('List', () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/locales/en-US/translation.json",
"new_path": "src/locales/en-US/translation.json",
"diff": "\"label\": \"Related Persons\",\n\"new\": \"New Related Person\",\n\"relationshipType\": \"Relationship Type\",\n- \"addRelatedPersonAbove\": \"Add a related person using the button above.\"\n+ \"addRelatedPersonAbove\": \"Add a related person using the button above.\",\n+ \"successfullyAdded\": \"Successfully added a new related person!\"\n},\n\"types\": {\n\"charity\": \"Charity\",\n\"warning\": {\n\"noAllergies\": \"No Allergies\"\n},\n- \"addAllergyAbove\": \"Add an allergy using the button above.\"\n+ \"addAllergyAbove\": \"Add an allergy using the button above.\",\n+ \"successfullyAdded\": \"Successfully added a new allergy!\"\n},\n\"diagnoses\": {\n\"label\": \"Diagnoses\",\n\"nameRequired\": \"Diagnosis Name is required.\",\n\"dateRequired\": \"Diagnosis Date is required.\"\n},\n- \"addDiagnosisAbove\": \"Add a diagnosis using the button above.\"\n-\n+ \"addDiagnosisAbove\": \"Add a diagnosis using the button above.\",\n+ \"successfullyAdded\": \"Successfully added a new diagnosis!\"\n}\n},\n\"sex\": {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/allergies/Allergies.tsx",
"new_path": "src/patients/allergies/Allergies.tsx",
"diff": "import React, { useState } from 'react'\nimport useAddBreadcrumbs from 'breadcrumbs/useAddBreadcrumbs'\nimport Patient from 'model/Patient'\n-import { Button, List, ListItem, Alert } from '@hospitalrun/components'\n+import { Button, List, ListItem, Alert, Toast } from '@hospitalrun/components'\nimport { useSelector, useDispatch } from 'react-redux'\nimport { RootState } from 'store'\nimport Permissions from 'model/Permissions'\nimport { useTranslation } from 'react-i18next'\nimport Allergy from 'model/Allergy'\n-import { useHistory } from 'react-router'\nimport { updatePatient } from 'patients/patient-slice'\nimport { getTimestampId } from 'patients/util/timestamp-id-generator'\nimport NewAllergyModal from './NewAllergyModal'\n@@ -18,7 +17,6 @@ interface AllergiesProps {\nconst Allergies = (props: AllergiesProps) => {\nconst { t } = useTranslation()\n- const history = useHistory()\nconst dispatch = useDispatch()\nconst { patient } = props\nconst { permissions } = useSelector((state: RootState) => state.user)\n@@ -32,6 +30,10 @@ const Allergies = (props: AllergiesProps) => {\n]\nuseAddBreadcrumbs(breadcrumbs)\n+ const onAddAllergySuccess = () => {\n+ Toast('success', t('Success!'), `${t('patient.allergies.successfullyAdded')}`)\n+ }\n+\nconst onAddAllergy = (allergy: Allergy) => {\nallergy.id = getTimestampId()\nconst allergies = []\n@@ -41,7 +43,7 @@ const Allergies = (props: AllergiesProps) => {\nallergies.push(allergy)\nconst patientToUpdate = { ...patient, allergies }\n- dispatch(updatePatient(patientToUpdate, history))\n+ dispatch(updatePatient(patientToUpdate, onAddAllergySuccess))\n}\nreturn (\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/diagnoses/Diagnoses.tsx",
"new_path": "src/patients/diagnoses/Diagnoses.tsx",
"diff": "@@ -4,12 +4,11 @@ import Patient from 'model/Patient'\nimport useAddBreadcrumbs from 'breadcrumbs/useAddBreadcrumbs'\nimport { useSelector, useDispatch } from 'react-redux'\nimport Permissions from 'model/Permissions'\n-import { Button, List, ListItem, Alert } from '@hospitalrun/components'\n+import { Button, List, ListItem, Alert, Toast } from '@hospitalrun/components'\nimport { useTranslation } from 'react-i18next'\nimport Diagnosis from 'model/Diagnosis'\nimport { getTimestampId } from 'patients/util/timestamp-id-generator'\nimport { updatePatient } from 'patients/patient-slice'\n-import { useHistory } from 'react-router'\nimport AddDiagnosisModal from './AddDiagnosisModal'\ninterface Props {\n@@ -20,7 +19,6 @@ const Diagnoses = (props: Props) => {\nconst { patient } = props\nconst [showDiagnosisModal, setShowDiagnosisModal] = useState(false)\n- const history = useHistory()\nconst dispatch = useDispatch()\nconst { t } = useTranslation()\nconst { permissions } = useSelector((state: RootState) => state.user)\n@@ -37,6 +35,10 @@ const Diagnoses = (props: Props) => {\nsetShowDiagnosisModal(false)\n}\n+ const onAddDiagnosisSuccess = () => {\n+ Toast('success', t('Success!'), t('patient.diagnoses.successfullyAdded'))\n+ }\n+\nconst onDiagnosisSave = (diagnosis: Diagnosis) => {\ndiagnosis.id = getTimestampId()\nconst diagnoses = []\n@@ -45,7 +47,7 @@ const Diagnoses = (props: Props) => {\n}\ndiagnoses.push(diagnosis)\nconst patientToUpdate = { ...patient, diagnoses }\n- dispatch(updatePatient(patientToUpdate, history))\n+ dispatch(updatePatient(patientToUpdate, onAddDiagnosisSuccess))\nsetShowDiagnosisModal(false)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/edit/EditPatient.tsx",
"new_path": "src/patients/edit/EditPatient.tsx",
"diff": "@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'\nimport { useHistory, useParams } from 'react-router-dom'\nimport { useTranslation } from 'react-i18next'\nimport { useDispatch, useSelector } from 'react-redux'\n-import { Spinner, Button } from '@hospitalrun/components'\n+import { Spinner, Button, Toast } from '@hospitalrun/components'\nimport GeneralInformation from '../GeneralInformation'\nimport useTitle from '../../page-header/useTitle'\n@@ -57,6 +57,11 @@ const EditPatient = () => {\nhistory.push(`/patients/${patient.id}`)\n}\n+ const onSuccessfulSave = (updatedPatient: Patient) => {\n+ history.push(`/patients/${updatedPatient.id}`)\n+ Toast('success', t('Success!'), `${t('patients.successfullyUpdated')} ${patient.fullName}`)\n+ }\n+\nconst onSave = () => {\nif (!patient.givenName) {\nsetErrorMessage(t('patient.errors.patientGivenNameRequired'))\n@@ -67,7 +72,7 @@ const EditPatient = () => {\n...patient,\nfullName: getPatientName(patient.givenName, patient.familyName, patient.suffix),\n},\n- history,\n+ onSuccessfulSave,\n),\n)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/new/NewPatient.tsx",
"new_path": "src/patients/new/NewPatient.tsx",
"diff": "@@ -2,7 +2,7 @@ import React, { useState } from 'react'\nimport { useHistory } from 'react-router'\nimport { useTranslation } from 'react-i18next'\nimport { useDispatch } from 'react-redux'\n-import { Button } from '@hospitalrun/components'\n+import { Button, Toast } from '@hospitalrun/components'\nimport GeneralInformation from '../GeneralInformation'\nimport useTitle from '../../page-header/useTitle'\n@@ -31,6 +31,11 @@ const NewPatient = () => {\nhistory.push('/patients')\n}\n+ const onSuccessfulSave = (newPatient: Patient) => {\n+ history.push(`/patients/${newPatient.id}`)\n+ Toast('success', t('Success!'), `${t('patients.successfullyCreated')} ${newPatient.fullName}`)\n+ }\n+\nconst onSave = () => {\nif (!patient.givenName) {\nsetErrorMessage(t('patient.errors.patientGivenNameRequired'))\n@@ -41,7 +46,7 @@ const NewPatient = () => {\n...patient,\nfullName: getPatientName(patient.givenName, patient.familyName, patient.suffix),\n},\n- history,\n+ onSuccessfulSave,\n),\n)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/patient-slice.ts",
"new_path": "src/patients/patient-slice.ts",
"diff": "import { createSlice, PayloadAction } from '@reduxjs/toolkit'\n-import { Toast } from '@hospitalrun/components'\nimport Patient from '../model/Patient'\nimport PatientRepository from '../clients/db/PatientRepository'\nimport { AppThunk } from '../store'\n-import il8n from '../i18n'\ninterface PatientState {\nisLoading: boolean\n@@ -59,28 +57,30 @@ export const fetchPatient = (id: string): AppThunk => async (dispatch) => {\ndispatch(fetchPatientSuccess(patient))\n}\n-export const createPatient = (patient: Patient, history: any): AppThunk => async (dispatch) => {\n+export const createPatient = (\n+ patient: Patient,\n+ onSuccess?: (patient: Patient) => void,\n+): AppThunk => async (dispatch) => {\ndispatch(createPatientStart())\nconst newPatient = await PatientRepository.save(patient)\ndispatch(createPatientSuccess())\n- history.push(`/patients/${newPatient.id}`)\n- Toast(\n- 'success',\n- il8n.t('Success!'),\n- `${il8n.t('patients.successfullyCreated')} ${patient.fullName}`,\n- )\n+\n+ if (onSuccess) {\n+ onSuccess(newPatient)\n+ }\n}\n-export const updatePatient = (patient: Patient, history: any): AppThunk => async (dispatch) => {\n+export const updatePatient = (\n+ patient: Patient,\n+ onSuccess?: (patient: Patient) => void,\n+): AppThunk => async (dispatch) => {\ndispatch(updatePatientStart())\nconst updatedPatient = await PatientRepository.saveOrUpdate(patient)\ndispatch(updatePatientSuccess(updatedPatient))\n- history.push(`/patients/${updatedPatient.id}`)\n- Toast(\n- 'success',\n- il8n.t('Success!'),\n- `${il8n.t('patients.successfullyUpdated')} ${patient.fullName}`,\n- )\n+\n+ if (onSuccess) {\n+ onSuccess(updatedPatient)\n+ }\n}\nexport default patientSlice.reducer\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/related-persons/RelatedPersonTab.tsx",
"new_path": "src/patients/related-persons/RelatedPersonTab.tsx",
"diff": "import React, { useState, useEffect } from 'react'\n-import { Button, Panel, List, ListItem, Alert, Spinner } from '@hospitalrun/components'\n+import { Button, Panel, List, ListItem, Alert, Spinner, Toast } from '@hospitalrun/components'\nimport NewRelatedPersonModal from 'patients/related-persons/NewRelatedPersonModal'\nimport RelatedPerson from 'model/RelatedPerson'\nimport { useTranslation } from 'react-i18next'\n@@ -66,6 +66,10 @@ const RelatedPersonTab = (props: Props) => {\nsetShowRelatedPersonModal(false)\n}\n+ const onAddRelatedPersonSuccess = () => {\n+ Toast('success', t('Success!'), t('patient.relatedPersons.successfullyAdded'))\n+ }\n+\nconst onRelatedPersonSave = (relatedPerson: RelatedPerson) => {\nconst newRelatedPersons: RelatedPerson[] = []\n@@ -80,7 +84,7 @@ const RelatedPersonTab = (props: Props) => {\nrelatedPersons: newRelatedPersons,\n}\n- dispatch(updatePatient(patientToUpdate, history))\n+ dispatch(updatePatient(patientToUpdate, onAddRelatedPersonSuccess))\ncloseNewRelatedPersonModal()\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(patients): fixes notifactions for updating/creating patient |
288,323 | 04.03.2020 22:08:24 | 21,600 | c077d75eb654747d5c6691369210942184325512 | feat(appointments): add callbacks for appointment actions | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/scheduling/appointments/appointment-slice.test.ts",
"new_path": "src/__tests__/scheduling/appointments/appointment-slice.test.ts",
"diff": "@@ -135,7 +135,7 @@ describe('appointment slice', () => {\nreason: 'reason',\n} as Appointment\n- await createAppointment(expectedAppointment, createMemoryHistory())(dispatch, getState, null)\n+ await createAppointment(expectedAppointment)(dispatch, getState, null)\nexpect(dispatch).toHaveBeenCalledWith({ type: createAppointmentStart.type })\n})\n@@ -155,18 +155,21 @@ describe('appointment slice', () => {\nreason: 'reason',\n} as Appointment\n- await createAppointment(expectedAppointment, createMemoryHistory())(dispatch, getState, null)\n+ await createAppointment(expectedAppointment)(dispatch, getState, null)\nexpect(appointmentRepositorySaveSpy).toHaveBeenCalled()\nexpect(appointmentRepositorySaveSpy).toHaveBeenCalledWith(expectedAppointment)\n})\n- it('should navigate the /appointments when an appointment is successfully created', async () => {\n+ it('should call the onSuccess function', async () => {\n+ const onSuccessSpy = jest.fn()\njest.spyOn(AppointmentRepository, 'save')\n- mocked(AppointmentRepository, true).save.mockResolvedValue({ id: '123' } as Appointment)\n+ const expectedSavedAppointment = { id: '123' }\n+ mocked(AppointmentRepository, true).save.mockResolvedValue(\n+ expectedSavedAppointment as Appointment,\n+ )\nconst dispatch = jest.fn()\nconst getState = jest.fn()\n- const history = createMemoryHistory()\nconst expectedAppointment = {\npatientId: '123',\n@@ -177,9 +180,9 @@ describe('appointment slice', () => {\nreason: 'reason',\n} as Appointment\n- await createAppointment(expectedAppointment, history)(dispatch, getState, null)\n+ await createAppointment(expectedAppointment, onSuccessSpy)(dispatch, getState, null)\n- expect(history.location.pathname).toEqual('/appointments')\n+ expect(onSuccessSpy).toHaveBeenCalledWith(expectedSavedAppointment)\n})\n})\n@@ -247,22 +250,16 @@ describe('appointment slice', () => {\ndescribe('deleteAppointment()', () => {\nlet deleteAppointmentSpy = jest.spyOn(AppointmentRepository, 'delete')\n- let toastSpy = jest.spyOn(components, 'Toast')\nbeforeEach(() => {\njest.resetAllMocks()\ndeleteAppointmentSpy = jest.spyOn(AppointmentRepository, 'delete')\n- toastSpy = jest.spyOn(components, 'Toast')\n})\nit('should dispatch the DELETE_APPOINTMENT_START action', async () => {\nconst dispatch = jest.fn()\nconst getState = jest.fn()\n- await deleteAppointment({ id: 'test1' } as Appointment, createMemoryHistory())(\n- dispatch,\n- getState,\n- null,\n- )\n+ await deleteAppointment({ id: 'test1' } as Appointment)(dispatch, getState, null)\nexpect(dispatch).toHaveBeenCalledWith({ type: deleteAppointmentStart.type })\n})\n@@ -273,51 +270,31 @@ describe('appointment slice', () => {\nconst dispatch = jest.fn()\nconst getState = jest.fn()\n- await deleteAppointment(expectedAppointment, createMemoryHistory())(dispatch, getState, null)\n+ await deleteAppointment(expectedAppointment)(dispatch, getState, null)\nexpect(deleteAppointmentSpy).toHaveBeenCalledTimes(1)\nexpect(deleteAppointmentSpy).toHaveBeenCalledWith(expectedAppointment)\n})\n- it('should navigate to /appointments after deleting', async () => {\n- const history = createMemoryHistory()\n- const expectedAppointment = { id: 'appointmentId1' } as Appointment\n-\n+ it('should call the onSuccess function after successfully deleting', async () => {\n+ const onSuccessSpy = jest.fn()\nconst dispatch = jest.fn()\nconst getState = jest.fn()\n- await deleteAppointment(expectedAppointment, history)(dispatch, getState, null)\n-\n- expect(history.location.pathname).toEqual('/appointments')\n- })\n-\n- it('should create a toast with a success message', async () => {\n- const dispatch = jest.fn()\n- const getState = jest.fn()\n-\n- await deleteAppointment({ id: 'test1' } as Appointment, createMemoryHistory())(\n+ await deleteAppointment({ id: 'test1' } as Appointment, onSuccessSpy)(\ndispatch,\ngetState,\nnull,\n)\n- expect(toastSpy).toHaveBeenCalledTimes(1)\n- expect(toastSpy).toHaveBeenLastCalledWith(\n- 'success',\n- 'states.success',\n- 'scheduling.appointments.successfullyDeleted',\n- )\n+ expect(onSuccessSpy).toHaveBeenCalled()\n})\nit('should dispatch the DELETE_APPOINTMENT_SUCCESS action', async () => {\nconst dispatch = jest.fn()\nconst getState = jest.fn()\n- await deleteAppointment({ id: 'test1' } as Appointment, createMemoryHistory())(\n- dispatch,\n- getState,\n- null,\n- )\n+ await deleteAppointment({ id: 'test1' } as Appointment)(dispatch, getState, null)\nexpect(dispatch).toHaveBeenCalledWith({ type: deleteAppointmentSuccess.type })\n})\n@@ -333,7 +310,7 @@ describe('appointment slice', () => {\nconst mockedAppointmentRepository = mocked(AppointmentRepository, true)\nmockedAppointmentRepository.saveOrUpdate.mockResolvedValue(expectedAppointment)\n- await updateAppointment(expectedAppointment, createMemoryHistory())(dispatch, getState, null)\n+ await updateAppointment(expectedAppointment)(dispatch, getState, null)\nexpect(dispatch).toHaveBeenCalledWith({ type: updateAppointmentStart.type })\n})\n@@ -347,7 +324,7 @@ describe('appointment slice', () => {\nconst mockedAppointmentRepository = mocked(AppointmentRepository, true)\nmockedAppointmentRepository.saveOrUpdate.mockResolvedValue(expectedAppointment)\n- await updateAppointment(expectedAppointment, createMemoryHistory())(dispatch, getState, null)\n+ await updateAppointment(expectedAppointment)(dispatch, getState, null)\nexpect(AppointmentRepository.saveOrUpdate).toHaveBeenCalledWith(expectedAppointment)\n})\n@@ -361,12 +338,27 @@ describe('appointment slice', () => {\nconst mockedAppointmentRepository = mocked(AppointmentRepository, true)\nmockedAppointmentRepository.saveOrUpdate.mockResolvedValue(expectedAppointment)\n- await updateAppointment(expectedAppointment, createMemoryHistory())(dispatch, getState, null)\n+ await updateAppointment(expectedAppointment)(dispatch, getState, null)\nexpect(dispatch).toHaveBeenCalledWith({\ntype: updateAppointmentSuccess.type,\npayload: expectedAppointment,\n})\n})\n+\n+ it('should call on the onSuccess function after successfully updating', async () => {\n+ const onSuccessSpy = jest.fn()\n+ const dispatch = jest.fn()\n+ const getState = jest.fn()\n+ jest.spyOn(AppointmentRepository, 'saveOrUpdate')\n+ const expectedAppointmentId = 'sliceId11'\n+ const expectedAppointment = { id: expectedAppointmentId } as Appointment\n+ const mockedAppointmentRepository = mocked(AppointmentRepository, true)\n+ mockedAppointmentRepository.saveOrUpdate.mockResolvedValue(expectedAppointment)\n+\n+ await updateAppointment(expectedAppointment, onSuccessSpy)(dispatch, getState, null)\n+\n+ expect(onSuccessSpy).toHaveBeenCalledWith(expectedAppointment)\n+ })\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/scheduling/appointments/edit/EditAppointment.test.tsx",
"new_path": "src/__tests__/scheduling/appointments/edit/EditAppointment.test.tsx",
"diff": "@@ -184,6 +184,24 @@ describe('Edit Appointment', () => {\n)\n})\n+ it('should navigate to /appointments/:id when save is successful', async () => {\n+ let wrapper: any\n+ await act(async () => {\n+ wrapper = await setup()\n+ })\n+\n+ wrapper.update()\n+\n+ const saveButton = wrapper.find(Button).at(0)\n+ const onClick = saveButton.prop('onClick') as any\n+\n+ await act(async () => {\n+ await onClick()\n+ })\n+\n+ expect(history.location.pathname).toEqual('/appointments/123')\n+ })\n+\nit('should navigate to /appointments/:id when cancel is clicked', async () => {\nlet wrapper: any\nawait act(async () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/scheduling/appointments/new/NewAppointment.test.tsx",
"new_path": "src/__tests__/scheduling/appointments/new/NewAppointment.test.tsx",
"diff": "@@ -24,10 +24,13 @@ const mockStore = configureMockStore([thunk])\ndescribe('New Appointment', () => {\nlet history: MemoryHistory\nlet store: MockStore\n+ const expectedNewAppointment = { id: '123' }\nconst setup = () => {\njest.spyOn(AppointmentRepository, 'save')\n- mocked(AppointmentRepository, true).save.mockResolvedValue({ id: '123' } as Appointment)\n+ mocked(AppointmentRepository, true).save.mockResolvedValue(\n+ expectedNewAppointment as Appointment,\n+ )\nhistory = createMemoryHistory()\nstore = mockStore({\n@@ -154,6 +157,41 @@ describe('New Appointment', () => {\nexpect(store.getActions()).toContainEqual(appointmentSlice.createAppointmentSuccess())\n})\n+ it('should navigate to /appointments/:id when a new appointment is created', async () => {\n+ let wrapper: any\n+ await act(async () => {\n+ wrapper = await setup()\n+ })\n+\n+ const expectedAppointment = {\n+ patientId: '123',\n+ startDateTime: roundToNearestMinutes(new Date(), { nearestTo: 15 }).toISOString(),\n+ endDateTime: addMinutes(\n+ roundToNearestMinutes(new Date(), { nearestTo: 15 }),\n+ 60,\n+ ).toISOString(),\n+ location: 'location',\n+ reason: 'reason',\n+ type: 'type',\n+ } as Appointment\n+\n+ act(() => {\n+ const appointmentDetailForm = wrapper.find(AppointmentDetailForm)\n+ const onFieldChange = appointmentDetailForm.prop('onFieldChange')\n+ onFieldChange('patientId', expectedAppointment.patientId)\n+ })\n+ wrapper.update()\n+ const saveButton = wrapper.find(Button).at(0)\n+ expect(saveButton.text().trim()).toEqual('actions.save')\n+ const onClick = saveButton.prop('onClick') as any\n+\n+ await act(async () => {\n+ await onClick()\n+ })\n+\n+ expect(history.location.pathname).toEqual(`/appointments/${expectedNewAppointment.id}`)\n+ })\n+\nit('should display an error if there is no patient id', async () => {\nlet wrapper: any\nawait act(async () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx",
"new_path": "src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx",
"diff": "@@ -12,6 +12,7 @@ import AppointmentRepository from 'clients/db/AppointmentRepository'\nimport { mocked } from 'ts-jest/utils'\nimport { act } from 'react-dom/test-utils'\nimport { Spinner, Modal } from '@hospitalrun/components'\n+import * as components from '@hospitalrun/components'\nimport AppointmentDetailForm from 'scheduling/appointments/AppointmentDetailForm'\nimport PatientRepository from 'clients/db/PatientRepository'\nimport Patient from 'model/Patient'\n@@ -261,5 +262,29 @@ describe('View Appointment', () => {\nexpect(store.getActions()).toContainEqual(appointmentSlice.deleteAppointmentStart())\nexpect(store.getActions()).toContainEqual(appointmentSlice.deleteAppointmentSuccess())\n})\n+\n+ it('should navigate to /appointments and display a message when delete is successful', async () => {\n+ jest.spyOn(components, 'Toast')\n+ const mockedComponents = mocked(components, true)\n+\n+ let wrapper: any\n+ await act(async () => {\n+ wrapper = await setup(false, [Permissions.ReadAppointments, Permissions.DeleteAppointment])\n+ })\n+\n+ const deleteConfirmationModal = wrapper.find(Modal)\n+\n+ await act(async () => {\n+ await deleteConfirmationModal.prop('closeButton').onClick()\n+ })\n+ wrapper.update()\n+\n+ expect(history.location.pathname).toEqual('/appointments')\n+ expect(mockedComponents.Toast).toHaveBeenCalledWith(\n+ 'success',\n+ 'states.success',\n+ 'scheduling.appointments.successfullyDeleted',\n+ )\n+ })\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/appointment-slice.ts",
"new_path": "src/scheduling/appointments/appointment-slice.ts",
"diff": "@@ -71,36 +71,42 @@ export const fetchAppointment = (id: string): AppThunk => async (dispatch) => {\ndispatch(fetchAppointmentSuccess({ appointment, patient }))\n}\n-export const createAppointment = (appointment: Appointment, history: any): AppThunk => async (\n- dispatch,\n-) => {\n+export const createAppointment = (\n+ appointment: Appointment,\n+ onSuccess?: (appointment: Appointment) => void,\n+): AppThunk => async (dispatch) => {\ndispatch(createAppointmentStart())\n- await AppointmentRepository.save(appointment)\n+ const newAppointment = await AppointmentRepository.save(appointment)\ndispatch(createAppointmentSuccess())\n- history.push('/appointments')\n+ if (onSuccess) {\n+ onSuccess(newAppointment)\n+ }\n}\n-export const updateAppointment = (appointment: Appointment, history: any): AppThunk => async (\n- dispatch,\n-) => {\n+export const updateAppointment = (\n+ appointment: Appointment,\n+ onSuccess?: (appointment: Appointment) => void,\n+): AppThunk => async (dispatch) => {\ndispatch(updateAppointmentStart())\nconst updatedAppointment = await AppointmentRepository.saveOrUpdate(appointment)\ndispatch(updateAppointmentSuccess(updatedAppointment))\n- history.push(`/appointments/${updatedAppointment.id}`)\n+\n+ if (onSuccess) {\n+ onSuccess(updatedAppointment)\n+ }\n}\n-export const deleteAppointment = (appointment: Appointment, history: any): AppThunk => async (\n- dispatch,\n-) => {\n+export const deleteAppointment = (\n+ appointment: Appointment,\n+ onSuccess?: () => void,\n+): AppThunk => async (dispatch) => {\ndispatch(deleteAppointmentStart())\nawait AppointmentRepository.delete(appointment)\n- history.push('/appointments')\n- Toast(\n- 'success',\n- il8n.t('states.success'),\n- `${il8n.t('scheduling.appointments.successfullyDeleted')}`,\n- )\ndispatch(deleteAppointmentSuccess())\n+\n+ if (onSuccess) {\n+ onSuccess()\n+ }\n}\nexport default appointmentSlice.reducer\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/edit/EditAppointment.tsx",
"new_path": "src/scheduling/appointments/edit/EditAppointment.tsx",
"diff": "@@ -52,6 +52,10 @@ const EditAppointment = () => {\nhistory.push(`/appointments/${appointment.id}`)\n}\n+ const onSaveSuccess = () => {\n+ history.push(`/appointments/${appointment.id}`)\n+ }\n+\nconst onSave = () => {\nlet newErrorMessage = ''\nif (isBefore(new Date(appointment.endDateTime), new Date(appointment.startDateTime))) {\n@@ -63,7 +67,7 @@ const EditAppointment = () => {\nreturn\n}\n- dispatch(updateAppointment(appointment as Appointment, history))\n+ dispatch(updateAppointment(appointment as Appointment, onSaveSuccess))\n}\nconst onFieldChange = (key: string, value: string | boolean) => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/new/NewAppointment.tsx",
"new_path": "src/scheduling/appointments/new/NewAppointment.tsx",
"diff": "@@ -7,7 +7,7 @@ import { useDispatch } from 'react-redux'\nimport Appointment from 'model/Appointment'\nimport addMinutes from 'date-fns/addMinutes'\nimport { isBefore } from 'date-fns'\n-import { Button } from '@hospitalrun/components'\n+import { Button, Toast } from '@hospitalrun/components'\nimport useAddBreadcrumbs from '../../../breadcrumbs/useAddBreadcrumbs'\nimport { createAppointment } from '../appointment-slice'\nimport AppointmentDetailForm from '../AppointmentDetailForm'\n@@ -40,6 +40,10 @@ const NewAppointment = () => {\nhistory.push('/appointments')\n}\n+ const onNewAppointmentSaveSuccess = (newAppointment: Appointment) => {\n+ history.push(`/appointments/${newAppointment.id}`)\n+ }\n+\nconst onSave = () => {\nlet newErrorMessage = ''\nif (!appointment.patientId) {\n@@ -54,7 +58,7 @@ const NewAppointment = () => {\nreturn\n}\n- dispatch(createAppointment(appointment as Appointment, history))\n+ dispatch(createAppointment(appointment as Appointment, onNewAppointmentSaveSuccess))\n}\nconst onFieldChange = (key: string, value: string | boolean) => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/view/ViewAppointment.tsx",
"new_path": "src/scheduling/appointments/view/ViewAppointment.tsx",
"diff": "@@ -3,7 +3,7 @@ import useTitle from 'page-header/useTitle'\nimport { useSelector, useDispatch } from 'react-redux'\nimport { RootState } from 'store'\nimport { useParams, useHistory } from 'react-router'\n-import { Spinner, Button, Modal } from '@hospitalrun/components'\n+import { Spinner, Button, Modal, Toast } from '@hospitalrun/components'\nimport { useTranslation } from 'react-i18next'\nimport { useButtonToolbarSetter } from 'page-header/ButtonBarProvider'\nimport Permissions from 'model/Permissions'\n@@ -29,8 +29,13 @@ const ViewAppointment = () => {\nsetShowDeleteConfirmation(true)\n}\n+ const onDeleteSuccess = () => {\n+ history.push('/appointments')\n+ Toast('success', t('states.success'), t('scheduling.appointments.successfullyDeleted'))\n+ }\n+\nconst onDeleteConfirmationButtonClick = () => {\n- dispatch(deleteAppointment(appointment, history))\n+ dispatch(deleteAppointment(appointment, onDeleteSuccess))\nsetShowDeleteConfirmation(false)\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(appointments): add callbacks for appointment actions |
288,323 | 04.03.2020 22:17:17 | 21,600 | e1e1f4c33e984f87a81390cf3399632172cc8c4b | fix: fix multiple imports lint error | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/allergies/Allergies.test.tsx",
"new_path": "src/__tests__/patients/allergies/Allergies.test.tsx",
"diff": "@@ -9,7 +9,6 @@ import thunk from 'redux-thunk'\nimport { Router } from 'react-router'\nimport { Provider } from 'react-redux'\nimport Patient from 'model/Patient'\n-import { Button, Modal, List, ListItem, Alert } from '@hospitalrun/components'\nimport * as components from '@hospitalrun/components'\nimport { act } from '@testing-library/react'\nimport { mocked } from 'ts-jest/utils'\n@@ -56,7 +55,7 @@ describe('Allergies', () => {\nit('should render a button to add new allergies', () => {\nconst wrapper = setup()\n- const addAllergyButton = wrapper.find(Button)\n+ const addAllergyButton = wrapper.find(components.Button)\nexpect(addAllergyButton).toHaveLength(1)\nexpect(addAllergyButton.text().trim()).toEqual('patient.allergies.new')\n})\n@@ -64,7 +63,7 @@ describe('Allergies', () => {\nit('should not render a button to add new allergies if the user does not have permissions', () => {\nconst wrapper = setup(expectedPatient, [])\n- const addAllergyButton = wrapper.find(Button)\n+ const addAllergyButton = wrapper.find(components.Button)\nexpect(addAllergyButton).toHaveLength(0)\n})\n@@ -72,14 +71,14 @@ describe('Allergies', () => {\nconst wrapper = setup()\nact(() => {\n- const addAllergyButton = wrapper.find(Button)\n+ const addAllergyButton = wrapper.find(components.Button)\nconst onClick = addAllergyButton.prop('onClick') as any\nonClick({} as React.MouseEvent<HTMLButtonElement>)\n})\nwrapper.update()\n- expect(wrapper.find(Modal).prop('show')).toBeTruthy()\n+ expect(wrapper.find(components.Modal).prop('show')).toBeTruthy()\n})\nit('should update the patient with the new allergy when the save button is clicked', async () => {\n@@ -139,8 +138,8 @@ describe('Allergies', () => {\nconst allergies = expectedPatient.allergies as Allergy[]\nconst wrapper = setup()\n- const list = wrapper.find(List)\n- const listItems = wrapper.find(ListItem)\n+ const list = wrapper.find(components.List)\n+ const listItems = wrapper.find(components.ListItem)\nexpect(list).toHaveLength(1)\nexpect(listItems).toHaveLength(allergies.length)\n@@ -149,7 +148,7 @@ describe('Allergies', () => {\nit('should render a warning message if the patient does not have any allergies', () => {\nconst wrapper = setup({ ...expectedPatient, allergies: [] })\n- const alert = wrapper.find(Alert)\n+ const alert = wrapper.find(components.Alert)\nexpect(alert).toHaveLength(1)\nexpect(alert.prop('title')).toEqual('patient.allergies.warning.noAllergies')\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/diagnoses/Diagnoses.test.tsx",
"new_path": "src/__tests__/patients/diagnoses/Diagnoses.test.tsx",
"diff": "@@ -10,7 +10,6 @@ import Permissions from 'model/Permissions'\nimport { Router } from 'react-router'\nimport { Provider } from 'react-redux'\nimport Diagnoses from 'patients/diagnoses/Diagnoses'\n-import { Button, Modal, List, ListItem, Alert } from '@hospitalrun/components'\nimport * as components from '@hospitalrun/components'\nimport { act } from 'react-dom/test-utils'\nimport { mocked } from 'ts-jest/utils'\n@@ -54,7 +53,7 @@ describe('Diagnoses', () => {\nit('should render a add diagnoses button', () => {\nconst wrapper = setup()\n- const addDiagnosisButton = wrapper.find(Button)\n+ const addDiagnosisButton = wrapper.find(components.Button)\nexpect(addDiagnosisButton).toHaveLength(1)\nexpect(addDiagnosisButton.text().trim()).toEqual('patient.diagnoses.new')\n})\n@@ -62,7 +61,7 @@ describe('Diagnoses', () => {\nit('should not render a diagnoses button if the user does not have permissions', () => {\nconst wrapper = setup(expectedPatient, [])\n- const addDiagnosisButton = wrapper.find(Button)\n+ const addDiagnosisButton = wrapper.find(components.Button)\nexpect(addDiagnosisButton).toHaveLength(0)\n})\n@@ -70,11 +69,11 @@ describe('Diagnoses', () => {\nconst wrapper = setup()\nact(() => {\n- wrapper.find(Button).prop('onClick')()\n+ wrapper.find(components.Button).prop('onClick')()\n})\nwrapper.update()\n- expect(wrapper.find(Modal).prop('show')).toBeTruthy()\n+ expect(wrapper.find(components.Modal).prop('show')).toBeTruthy()\n})\nit('should update the patient with the new diagnosis when the save button is clicked', async () => {\n@@ -140,8 +139,8 @@ describe('Diagnoses', () => {\nconst diagnoses = expectedPatient.diagnoses as Diagnosis[]\nconst wrapper = setup()\n- const list = wrapper.find(List)\n- const listItems = wrapper.find(ListItem)\n+ const list = wrapper.find(components.List)\n+ const listItems = wrapper.find(components.ListItem)\nexpect(list).toHaveLength(1)\nexpect(listItems).toHaveLength(diagnoses.length)\n@@ -150,7 +149,7 @@ describe('Diagnoses', () => {\nit('should render a warning message if the patient does not have any diagnoses', () => {\nconst wrapper = setup({ ...expectedPatient, diagnoses: [] })\n- const alert = wrapper.find(Alert)\n+ const alert = wrapper.find(components.Alert)\nexpect(alert).toHaveLength(1)\nexpect(alert.prop('title')).toEqual('patient.diagnoses.warning.noDiagnoses')\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/new/NewPatient.test.tsx",
"new_path": "src/__tests__/patients/new/NewPatient.test.tsx",
"diff": "@@ -6,7 +6,6 @@ import { Provider } from 'react-redux'\nimport { mocked } from 'ts-jest/utils'\nimport { createMemoryHistory } from 'history'\nimport { act } from 'react-dom/test-utils'\n-import { Button } from '@hospitalrun/components'\nimport configureMockStore, { MockStore } from 'redux-mock-store'\nimport thunk from 'redux-thunk'\nimport * as components from '@hospitalrun/components'\n@@ -86,7 +85,7 @@ describe('New Patient', () => {\nconst generalInformationForm = wrapper.find(GeneralInformation)\nexpect(generalInformationForm.prop('errorMessage')).toBe('')\n- const saveButton = wrapper.find(Button).at(0)\n+ const saveButton = wrapper.find(components.Button).at(0)\nconst onClick = saveButton.prop('onClick') as any\nexpect(saveButton.text().trim()).toEqual('actions.save')\n@@ -114,7 +113,7 @@ describe('New Patient', () => {\nwrapper.update()\n- const saveButton = wrapper.find(Button).at(0)\n+ const saveButton = wrapper.find(components.Button).at(0)\nconst onClick = saveButton.prop('onClick') as any\nexpect(saveButton.text().trim()).toEqual('actions.save')\n@@ -143,7 +142,7 @@ describe('New Patient', () => {\nwrapper.update()\n- const saveButton = wrapper.find(Button).at(0)\n+ const saveButton = wrapper.find(components.Button).at(0)\nconst onClick = saveButton.prop('onClick') as any\nexpect(saveButton.text().trim()).toEqual('actions.save')\n@@ -165,7 +164,7 @@ describe('New Patient', () => {\nwrapper = await setup()\n})\n- const cancelButton = wrapper.find(Button).at(1)\n+ const cancelButton = wrapper.find(components.Button).at(1)\nconst onClick = cancelButton.prop('onClick') as any\nexpect(cancelButton.text().trim()).toEqual('actions.cancel')\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/related-persons/RelatedPersons.test.tsx",
"new_path": "src/__tests__/patients/related-persons/RelatedPersons.test.tsx",
"diff": "@@ -4,7 +4,6 @@ import { Router } from 'react-router'\nimport { createMemoryHistory } from 'history'\nimport { mount } from 'enzyme'\nimport RelatedPersonTab from 'patients/related-persons/RelatedPersonTab'\n-import { Button, List, ListItem, Alert } from '@hospitalrun/components'\nimport * as components from '@hospitalrun/components'\nimport NewRelatedPersonModal from 'patients/related-persons/NewRelatedPersonModal'\n@@ -56,7 +55,7 @@ describe('Related Persons Tab', () => {\n})\nit('should render a New Related Person button', () => {\n- const newRelatedPersonButton = wrapper.find(Button)\n+ const newRelatedPersonButton = wrapper.find(components.Button)\nexpect(newRelatedPersonButton).toHaveLength(1)\nexpect(newRelatedPersonButton.text().trim()).toEqual('patient.relatedPersons.new')\n@@ -73,7 +72,7 @@ describe('Related Persons Tab', () => {\n</Router>,\n)\n})\n- const newRelatedPersonButton = wrapper.find(Button)\n+ const newRelatedPersonButton = wrapper.find(components.Button)\nexpect(newRelatedPersonButton).toHaveLength(0)\n})\n@@ -85,7 +84,7 @@ describe('Related Persons Tab', () => {\n})\nit('should show the New Related Person modal when the New Related Person button is clicked', () => {\n- const newRelatedPersonButton = wrapper.find(Button)\n+ const newRelatedPersonButton = wrapper.find(components.Button)\nact(() => {\n;(newRelatedPersonButton.prop('onClick') as any)()\n@@ -118,7 +117,7 @@ describe('Related Persons Tab', () => {\n)\n})\nact(() => {\n- const newRelatedPersonButton = wrapper.find(Button)\n+ const newRelatedPersonButton = wrapper.find(components.Button)\nconst onClick = newRelatedPersonButton.prop('onClick') as any\nonClick()\n})\n@@ -138,7 +137,7 @@ describe('Related Persons Tab', () => {\nit('should close the modal when the save button is clicked', () => {\nact(() => {\n- const newRelatedPersonButton = wrapper.find(Button)\n+ const newRelatedPersonButton = wrapper.find(components.Button)\nconst onClick = newRelatedPersonButton.prop('onClick') as any\nonClick()\n})\n@@ -204,15 +203,15 @@ describe('Related Persons Tab', () => {\n})\nit('should render a list of related persons with their full name being displayed', () => {\n- const list = wrapper.find(List)\n- const listItems = wrapper.find(ListItem)\n+ const list = wrapper.find(components.List)\n+ const listItems = wrapper.find(components.ListItem)\nexpect(list).toHaveLength(1)\nexpect(listItems).toHaveLength(1)\nexpect(listItems.at(0).text()).toEqual('test test')\n})\nit('should navigate to related person patient profile on related person click', () => {\n- const list = wrapper.find(List)\n- const listItems = wrapper.find(ListItem)\n+ const list = wrapper.find(components.List)\n+ const listItems = wrapper.find(components.ListItem)\nact(() => {\n;(listItems.at(0).prop('onClick') as any)()\n})\n@@ -252,7 +251,7 @@ describe('Related Persons Tab', () => {\n})\nit('should display a warning if patient has no related persons', () => {\n- const warning = wrapper.find(Alert)\n+ const warning = wrapper.find(components.Alert)\nexpect(warning).toBeDefined()\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx",
"new_path": "src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx",
"diff": "@@ -11,7 +11,6 @@ import { createMemoryHistory } from 'history'\nimport AppointmentRepository from 'clients/db/AppointmentRepository'\nimport { mocked } from 'ts-jest/utils'\nimport { act } from 'react-dom/test-utils'\n-import { Spinner, Modal } from '@hospitalrun/components'\nimport * as components from '@hospitalrun/components'\nimport AppointmentDetailForm from 'scheduling/appointments/AppointmentDetailForm'\nimport PatientRepository from 'clients/db/PatientRepository'\n@@ -145,7 +144,7 @@ describe('View Appointment', () => {\nwrapper = await setup(true)\n})\n- expect(wrapper.find(Spinner)).toHaveLength(1)\n+ expect(wrapper.find(components.Spinner)).toHaveLength(1)\n})\nit('should render a AppointmentDetailForm with the correct data', async () => {\n@@ -165,7 +164,7 @@ describe('View Appointment', () => {\nwrapper = await setup(false)\n})\n- const deleteAppointmentConfirmationModal = wrapper.find(Modal)\n+ const deleteAppointmentConfirmationModal = wrapper.find(components.Modal)\nexpect(deleteAppointmentConfirmationModal).toHaveLength(1)\nexpect(deleteAppointmentConfirmationModal.prop('closeButton').children).toEqual(\n'actions.delete',\n@@ -214,7 +213,7 @@ describe('View Appointment', () => {\n})\nwrapper.update()\n- const deleteConfirmationModal = wrapper.find(Modal)\n+ const deleteConfirmationModal = wrapper.find(components.Modal)\nexpect(deleteConfirmationModal.prop('show')).toEqual(true)\n})\n@@ -234,12 +233,12 @@ describe('View Appointment', () => {\nwrapper.update()\nact(() => {\n- const deleteConfirmationModal = wrapper.find(Modal)\n+ const deleteConfirmationModal = wrapper.find(components.Modal)\ndeleteConfirmationModal.prop('toggle')()\n})\nwrapper.update()\n- const deleteConfirmationModal = wrapper.find(Modal)\n+ const deleteConfirmationModal = wrapper.find(components.Modal)\nexpect(deleteConfirmationModal.prop('show')).toEqual(false)\n})\n@@ -249,7 +248,7 @@ describe('View Appointment', () => {\nwrapper = await setup(false, [Permissions.ReadAppointments, Permissions.DeleteAppointment])\n})\n- const deleteConfirmationModal = wrapper.find(Modal)\n+ const deleteConfirmationModal = wrapper.find(components.Modal)\nawait act(async () => {\nawait deleteConfirmationModal.prop('closeButton').onClick()\n@@ -272,7 +271,7 @@ describe('View Appointment', () => {\nwrapper = await setup(false, [Permissions.ReadAppointments, Permissions.DeleteAppointment])\n})\n- const deleteConfirmationModal = wrapper.find(Modal)\n+ const deleteConfirmationModal = wrapper.find(components.Modal)\nawait act(async () => {\nawait deleteConfirmationModal.prop('closeButton').onClick()\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix: fix multiple imports lint error |
288,296 | 06.03.2020 11:52:47 | -21,600 | 168a112802cf07331331364f26e7e13afa881f88 | feat: making sidebar collapsible
this changes make the sidebar collapsible
"fix #1858" | [
{
"change_type": "MODIFY",
"old_path": "src/HospitalRun.tsx",
"new_path": "src/HospitalRun.tsx",
"diff": "@@ -23,6 +23,7 @@ import PrivateRoute from './components/PrivateRoute'\nconst HospitalRun = () => {\nconst { title } = useSelector((state: RootState) => state.title)\nconst { permissions } = useSelector((state: RootState) => state.user)\n+ const { sidebarCollapsed } = useSelector((state: RootState) => state.components)\nreturn (\n<div>\n@@ -31,7 +32,12 @@ const HospitalRun = () => {\n<Sidebar />\n<ButtonBarProvider>\n<div className=\"row\">\n- <main role=\"main\" className=\"col-md-9 ml-sm-auto col-lg-10 px-4\">\n+ <main\n+ role=\"main\"\n+ className={`${\n+ sidebarCollapsed ? 'col-md-10 col-lg-11' : 'col-md-9 col-lg-10'\n+ } ml-sm-auto px-4`}\n+ >\n<div className=\"d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom\">\n<h1 className=\"h2\">{title}</h1>\n<ButtonToolBar />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/HospitalRun.test.tsx",
"new_path": "src/__tests__/HospitalRun.test.tsx",
"diff": "@@ -34,6 +34,7 @@ describe('HospitalRun', () => {\ntitle: 'test',\nuser: { permissions: [Permissions.WritePatients] },\nbreadcrumbs: { breadcrumbs: [] },\n+ components: { sidebarCollapsed: false },\n})\nconst wrapper = mount(\n@@ -62,6 +63,7 @@ describe('HospitalRun', () => {\ntitle: 'test',\nuser: { permissions: [] },\nbreadcrumbs: { breadcrumbs: [] },\n+ components: { sidebarCollapsed: false },\n})}\n>\n<MemoryRouter initialEntries={['/patients/new']}>\n@@ -94,6 +96,7 @@ describe('HospitalRun', () => {\nuser: { permissions: [Permissions.WritePatients, Permissions.ReadPatients] },\npatient: { patient },\nbreadcrumbs: { breadcrumbs: [] },\n+ components: { sidebarCollapsed: false },\n})\nconst wrapper = mount(\n@@ -123,6 +126,7 @@ describe('HospitalRun', () => {\ntitle: 'test',\nuser: { permissions: [Permissions.WritePatients] },\nbreadcrumbs: { breadcrumbs: [] },\n+ components: { sidebarCollapsed: false },\n})}\n>\n<MemoryRouter initialEntries={['/patients/edit/123']}>\n@@ -141,6 +145,7 @@ describe('HospitalRun', () => {\ntitle: 'test',\nuser: { permissions: [Permissions.ReadPatients] },\nbreadcrumbs: { breadcrumbs: [] },\n+ components: { sidebarCollapsed: false },\n})}\n>\n<MemoryRouter initialEntries={['/patients/edit/123']}>\n@@ -173,6 +178,7 @@ describe('HospitalRun', () => {\nuser: { permissions: [Permissions.ReadPatients] },\npatient: { patient },\nbreadcrumbs: { breadcrumbs: [] },\n+ components: { sidebarCollapsed: false },\n})\nconst wrapper = mount(\n@@ -201,6 +207,7 @@ describe('HospitalRun', () => {\ntitle: 'test',\nuser: { permissions: [] },\nbreadcrumbs: { breadcrumbs: [] },\n+ components: { sidebarCollapsed: false },\n})}\n>\n<MemoryRouter initialEntries={['/patients/123']}>\n@@ -220,6 +227,7 @@ describe('HospitalRun', () => {\nuser: { permissions: [Permissions.ReadAppointments] },\nappointments: { appointments: [] },\nbreadcrumbs: { breadcrumbs: [] },\n+ components: { sidebarCollapsed: false },\n})\nconst wrapper = mount(\n@@ -251,6 +259,7 @@ describe('HospitalRun', () => {\ntitle: 'test',\nuser: { permissions: [] },\nbreadcrumbs: { breadcrumbs: [] },\n+ components: { sidebarCollapsed: false },\n})}\n>\n<MemoryRouter initialEntries={['/appointments']}>\n@@ -269,6 +278,7 @@ describe('HospitalRun', () => {\ntitle: 'test',\nuser: { permissions: [Permissions.WriteAppointments] },\nbreadcrumbs: { breadcrumbs: [] },\n+ components: { sidebarCollapsed: false },\n})\nconst wrapper = mount(\n@@ -298,6 +308,7 @@ describe('HospitalRun', () => {\ntitle: 'test',\nuser: { permissions: [] },\nbreadcrumbs: { breadcrumbs: [] },\n+ components: { sidebarCollapsed: false },\n})}\n>\n<MemoryRouter initialEntries={['/appointments/new']}>\n@@ -332,6 +343,7 @@ describe('HospitalRun', () => {\nuser: { permissions: [Permissions.WriteAppointments, Permissions.ReadAppointments] },\nappointment: { appointment, patient: {} as Patient },\nbreadcrumbs: { breadcrumbs: [] },\n+ components: { sidebarCollapsed: false },\n})\nconst wrapper = mount(\n@@ -364,6 +376,7 @@ describe('HospitalRun', () => {\ntitle: 'test',\nuser: { permissions: [Permissions.WriteAppointments] },\nbreadcrumbs: { breadcrumbs: [] },\n+ components: { sidebarCollapsed: false },\n})}\n>\n<MemoryRouter initialEntries={['/appointments/edit/123']}>\n@@ -382,6 +395,7 @@ describe('HospitalRun', () => {\ntitle: 'test',\nuser: { permissions: [Permissions.ReadAppointments] },\nbreadcrumbs: { breadcrumbs: [] },\n+ components: { sidebarCollapsed: false },\n})}\n>\n<MemoryRouter initialEntries={['/appointments/edit/123']}>\n@@ -403,6 +417,7 @@ describe('HospitalRun', () => {\ntitle: 'test',\nuser: { permissions: [Permissions.WritePatients] },\nbreadcrumbs: { breadcrumbs: [] },\n+ components: { sidebarCollapsed: false },\n})}\n>\n<MemoryRouter initialEntries={['/']}>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/components/Sidebar.test.tsx",
"new_path": "src/__tests__/components/Sidebar.test.tsx",
"diff": "@@ -6,15 +6,25 @@ import Sidebar from 'components/Sidebar'\nimport { Router } from 'react-router'\nimport { ListItem } from '@hospitalrun/components'\nimport { act } from '@testing-library/react'\n+import configureMockStore from 'redux-mock-store'\n+import thunk from 'redux-thunk'\n+import { Provider } from 'react-redux'\n+\n+const mockStore = configureMockStore([thunk])\ndescribe('Sidebar', () => {\nlet history = createMemoryHistory()\n+ const store = mockStore({\n+ components: { sidebarCollapsed: false },\n+ })\nconst setup = (location: string) => {\nhistory = createMemoryHistory()\nhistory.push(location)\nreturn mount(\n<Router history={history}>\n+ <Provider store={store}>\n<Sidebar />\n+ </Provider>\n</Router>,\n)\n}\n@@ -27,7 +37,7 @@ describe('Sidebar', () => {\nexpect(\nlistItems\n- .at(0)\n+ .at(1)\n.text()\n.trim(),\n).toEqual('dashboard.label')\n@@ -38,7 +48,7 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\n- expect(listItems.at(0).prop('active')).toBeTruthy()\n+ expect(listItems.at(1).prop('active')).toBeTruthy()\n})\nit('should navigate to / when the dashboard link is clicked', () => {\n@@ -47,7 +57,7 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\nact(() => {\n- ;(listItems.at(0).prop('onClick') as any)()\n+ ;(listItems.at(1).prop('onClick') as any)()\n})\nexpect(history.location.pathname).toEqual('/')\n@@ -62,7 +72,7 @@ describe('Sidebar', () => {\nexpect(\nlistItems\n- .at(1)\n+ .at(2)\n.text()\n.trim(),\n).toEqual('patients.label')\n@@ -73,7 +83,7 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\n- expect(listItems.at(1).prop('active')).toBeTruthy()\n+ expect(listItems.at(2).prop('active')).toBeTruthy()\n})\nit('should navigate to /patients when the patients link is clicked', () => {\n@@ -82,7 +92,7 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\nact(() => {\n- ;(listItems.at(1).prop('onClick') as any)()\n+ ;(listItems.at(2).prop('onClick') as any)()\n})\nexpect(history.location.pathname).toEqual('/patients')\n@@ -97,7 +107,7 @@ describe('Sidebar', () => {\nexpect(\nlistItems\n- .at(2)\n+ .at(3)\n.text()\n.trim(),\n).toEqual('scheduling.label')\n@@ -108,7 +118,7 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\n- expect(listItems.at(2).prop('active')).toBeTruthy()\n+ expect(listItems.at(3).prop('active')).toBeTruthy()\n})\nit('should navigate to /appointments when the scheduling link is clicked', () => {\n@@ -117,7 +127,7 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\nact(() => {\n- ;(listItems.at(2).prop('onClick') as any)()\n+ ;(listItems.at(3).prop('onClick') as any)()\n})\nexpect(history.location.pathname).toEqual('/appointments')\n"
},
{
"change_type": "MODIFY",
"old_path": "src/components/Sidebar.tsx",
"new_path": "src/components/Sidebar.tsx",
"diff": "@@ -2,8 +2,14 @@ import React, { CSSProperties } from 'react'\nimport { List, ListItem, Icon } from '@hospitalrun/components'\nimport { useTranslation } from 'react-i18next'\nimport { useLocation, useHistory } from 'react-router'\n+import { useSelector, useDispatch } from 'react-redux'\n+import { RootState } from '../store'\n+import { updateSidebar } from './component-slice'\nconst Sidebar = () => {\n+ const dispatch = useDispatch()\n+ const { sidebarCollapsed } = useSelector((state: RootState) => state.components)\n+\nconst { t } = useTranslation()\nconst path = useLocation()\nconst history = useHistory()\n@@ -18,16 +24,29 @@ const Sidebar = () => {\n}\nreturn (\n- <nav className=\"col-md-2 d-none d-md-block bg-light sidebar\">\n+ <nav\n+ className=\"col-md-2 d-none d-md-block bg-light sidebar\"\n+ style={{ width: sidebarCollapsed ? '56px' : '' }}\n+ >\n<div className=\"sidebar-sticky\">\n<List layout=\"flush\" className=\"nav flex-column\">\n+ <ListItem\n+ onClick={() => dispatch(updateSidebar())}\n+ className=\"nav-item\"\n+ style={listItemStyle}\n+ >\n+ <Icon\n+ style={{ float: sidebarCollapsed ? 'left' : 'right' }}\n+ icon={sidebarCollapsed ? 'right-arrow' : 'left-arrow'}\n+ />\n+ </ListItem>\n<ListItem\nactive={pathname === '/'}\nonClick={() => navigateTo('/')}\nclassName=\"nav-item\"\nstyle={listItemStyle}\n>\n- <Icon icon=\"dashboard\" /> {t('dashboard.label')}\n+ <Icon icon=\"dashboard\" /> {!sidebarCollapsed && t('dashboard.label')}\n</ListItem>\n<ListItem\nactive={pathname.split('/')[1].includes('patient')}\n@@ -35,7 +54,7 @@ const Sidebar = () => {\nclassName=\"nav-item\"\nstyle={listItemStyle}\n>\n- <Icon icon=\"patients\" /> {t('patients.label')}\n+ <Icon icon=\"patients\" /> {!sidebarCollapsed && t('patients.label')}\n</ListItem>\n<ListItem\nactive={pathname.split('/')[1].includes('appointments')}\n@@ -43,7 +62,7 @@ const Sidebar = () => {\nclassName=\"nav-item\"\nstyle={listItemStyle}\n>\n- <Icon icon=\"appointment\" /> {t('scheduling.label')}\n+ <Icon icon=\"appointment\" /> {!sidebarCollapsed && t('scheduling.label')}\n</ListItem>\n</List>\n</div>\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/components/component-slice.ts",
"diff": "+import { createSlice } from '@reduxjs/toolkit'\n+import { AppThunk } from '../store'\n+\n+interface ComponentState {\n+ sidebarCollapsed: boolean\n+}\n+\n+const initialState: ComponentState = {\n+ sidebarCollapsed: false,\n+}\n+\n+const componentSlice = createSlice({\n+ name: 'components',\n+ initialState,\n+ reducers: {\n+ toggleSidebar(state) {\n+ state.sidebarCollapsed = !state.sidebarCollapsed\n+ },\n+ },\n+})\n+\n+export const { toggleSidebar } = componentSlice.actions\n+\n+export const updateSidebar = (): AppThunk => async (dispatch) => {\n+ dispatch(toggleSidebar())\n+}\n+\n+export default componentSlice.reducer\n"
},
{
"change_type": "MODIFY",
"old_path": "src/index.css",
"new_path": "src/index.css",
"diff": "@@ -25,7 +25,7 @@ code {\nleft: 0;\nz-index: 0; /* Behind the navbar */\npadding: 48px 0 0; /* Height of navbar */\n- box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);\n+ border-right: 1px solid rgba(0, 0, 0, .1);\n}\n.sidebar-sticky {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/store/index.ts",
"new_path": "src/store/index.ts",
"diff": "@@ -7,6 +7,7 @@ import appointments from '../scheduling/appointments/appointments-slice'\nimport title from '../page-header/title-slice'\nimport user from '../user/user-slice'\nimport breadcrumbs from '../breadcrumbs/breadcrumbs-slice'\n+import components from '../components/component-slice'\nconst reducer = combineReducers({\npatient,\n@@ -16,6 +17,7 @@ const reducer = combineReducers({\nappointment,\nappointments,\nbreadcrumbs,\n+ components,\n})\nconst store = configureStore({\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat: making sidebar collapsible
this changes make the sidebar collapsible
"fix #1858" |
288,334 | 06.03.2020 16:20:33 | -3,600 | 5eeef8928d8716479e9e5bb0dd79d9a0ed3ded95 | test(eslintrc): remove createDefaultProgram and update jest config | [
{
"change_type": "MODIFY",
"old_path": ".eslintrc.js",
"new_path": ".eslintrc.js",
"diff": "module.exports = {\n+ ignorePatterns: ['commitlint.config.js', 'jest.config.js'],\nenv: {\nbrowser: true,\nes6: true,\n@@ -10,7 +11,7 @@ module.exports = {\n'prettier',\n'prettier/@typescript-eslint',\n'plugin:prettier/recommended',\n- 'eslint-config-prettier'\n+ 'eslint-config-prettier',\n],\nglobals: {\nAtomics: 'readonly',\n@@ -20,8 +21,6 @@ module.exports = {\nparserOptions: {\nproject: './tsconfig.json',\ntsconfigRootDir: './',\n- // TODO: we need this because of an issue with @typescript-eslint/parser: https://github.com/typescript-eslint/typescript-eslint/issues/864\n- createDefaultProgram: true,\n},\nsettings: {\n'import/resolver': {\n@@ -32,7 +31,7 @@ module.exports = {\n},\nplugins: ['react', '@typescript-eslint', 'prettier', 'jest'],\nrules: {\n- \"prettier/prettier\": \"error\",\n+ 'prettier/prettier': 'error',\n'@typescript-eslint/member-delimiter-style': 'off',\n'@typescript-eslint/explicit-function-return-type': 'off',\n'@typescript-eslint/no-explicit-any': 'off',\n"
},
{
"change_type": "MODIFY",
"old_path": "jest.config.js",
"new_path": "jest.config.js",
"diff": "module.exports = {\nroots: ['<rootDir>/src'],\n- testMatch: ['**/__tests__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'],\n+ testMatch: ['**/__tests__/**/*.+(ts|tsx)', '**/?(*.)+(spec|test).+(ts|tsx)'],\ntransform: {\n'^.+\\\\.(ts|tsx)$': 'ts-jest',\n},\ncoverageDirectory: './coverage',\n+ testPathIgnorePatterns: ['<rootDir>/jest.config.js'],\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"build\": \"react-scripts build\",\n\"prepublishOnly\": \"npm run build\",\n\"test\": \"react-scripts test --detectOpenHandles\",\n- \"test:ci\": \"cross-env CI=true react-scripts test\",\n+ \"test:ci\": \"cross-env CI=true react-scripts test --passWithNoTests\",\n\"lint\": \"eslint \\\"src/**/*.{js,jsx,ts,tsx}\\\"\",\n\"lint:fix\": \"eslint \\\"src/**/*.{js,jsx,ts,tsx}\\\" --fix\",\n\"lint-staged\": \"lint-staged\",\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | test(eslintrc): remove createDefaultProgram and update jest config |
288,323 | 09.03.2020 20:45:56 | 18,000 | 008cb5fdf5b89cb9a911a7cfd88ae7086fd61130 | feat(i8ln): add missing translations | [
{
"change_type": "DELETE",
"old_path": "src/locales/en-US/translation.json",
"new_path": null,
"diff": "-{\n- \"dashboard\": {\n- \"label\": \"Dashboard\"\n- },\n- \"patients\": {\n- \"label\": \"Patients\",\n- \"viewPatients\": \"View Patients\",\n- \"viewPatient\": \"View Patient\",\n- \"newPatient\": \"New Patient\",\n- \"editPatient\": \"Edit Patient\",\n- \"successfullyCreated\": \"Successfully created patient\",\n- \"successfullyUpdated\": \"Successfully updated patient\"\n- },\n- \"patient\": {\n- \"suffix\": \"Suffix\",\n- \"prefix\": \"Prefix\",\n- \"givenName\": \"Given Name\",\n- \"familyName\": \"Family Name\",\n- \"dateOfBirth\": \"Date of Birth\",\n- \"approximateDateOfBirth\": \"Approximate Date of Birth\",\n- \"age\": \"Age\",\n- \"approximateAge\": \"Approximate Age\",\n- \"placeOfBirth\": \"Place of Birth\",\n- \"sex\": \"Sex\",\n- \"phoneNumber\": \"Phone Number\",\n- \"email\": \"Email\",\n- \"address\": \"Address\",\n- \"occupation\": \"Occupation\",\n- \"type\": \"Patient Type\",\n- \"preferredLanguage\": \"Preferred Language\",\n- \"basicInformation\": \"Basic Information\",\n- \"generalInformation\": \"General Information\",\n- \"contactInformation\": \"Contact Information\",\n- \"unknownDateOfBirth\": \"Unknown\",\n- \"relatedPerson\": \"Related Person\",\n- \"relatedPersons\": {\n- \"error\": {\n- \"relatedPersonRequired\": \"Related Person is required.\",\n- \"relationshipTypeRequired\": \"Relationship Type is required.\"\n- },\n- \"warning\": {\n- \"noRelatedPersons\": \"No Related Persons\"\n- },\n- \"label\": \"Related Persons\",\n- \"new\": \"New Related Person\",\n- \"relationshipType\": \"Relationship Type\",\n- \"addRelatedPersonAbove\": \"Add a related person using the button above.\",\n- \"successfullyAdded\": \"Successfully added a new related person!\"\n- },\n- \"types\": {\n- \"charity\": \"Charity\",\n- \"private\": \"Private\"\n- },\n- \"errors\": {\n- \"patientGivenNameRequired\": \"Patient Given Name is required.\"\n- },\n- \"allergies\": {\n- \"label\": \"Allergies\",\n- \"new\": \"Add Allergy\",\n- \"error\": {\n- \"nameRequired\": \"Name is required.\"\n- },\n- \"warning\": {\n- \"noAllergies\": \"No Allergies\"\n- },\n- \"addAllergyAbove\": \"Add an allergy using the button above.\",\n- \"successfullyAdded\": \"Successfully added a new allergy!\"\n- },\n- \"diagnoses\": {\n- \"label\": \"Diagnoses\",\n- \"new\": \"Add Diagnoses\",\n- \"diagnosisName\": \"Diagnosis Name\",\n- \"diagnosisDate\": \"Diagnosis Date\",\n- \"warning\": {\n- \"noDiagnoses\": \"No Diagnoses\"\n- },\n- \"error\": {\n- \"nameRequired\": \"Diagnosis Name is required.\",\n- \"dateRequired\": \"Diagnosis Date is required.\"\n- },\n- \"addDiagnosisAbove\": \"Add a diagnosis using the button above.\",\n- \"successfullyAdded\": \"Successfully added a new diagnosis!\"\n- }\n- },\n- \"sex\": {\n- \"male\": \"Male\",\n- \"female\": \"Female\",\n- \"other\": \"Other\",\n- \"unknown\": \"Unknown\"\n- },\n- \"actions\": {\n- \"edit\": \"Edit\",\n- \"save\": \"Save\",\n- \"cancel\": \"Cancel\",\n- \"new\": \"New\",\n- \"list\": \"List\",\n- \"search\": \"Search\",\n- \"delete\": \"Delete\",\n- \"confirmDelete\": \"Confirm Delete\"\n- },\n- \"states\": {\n- \"success\": \"Success!\",\n- \"error\": \"Error!\"\n- },\n- \"scheduling\": {\n- \"label\": \"Scheduling\",\n- \"appointments\": {\n- \"label\": \"Appointments\",\n- \"newAppointment\": \"New Appointment\",\n- \"editAppointment\": \"Edit Appointment\",\n- \"viewAppointment\": \"View Appointment\",\n- \"deleteAppointment\": \"Delete Appointment\",\n- \"successfullyDeleted\": \"Successfully deleted appointment!\"\n- },\n- \"appointment\": {\n- \"startDate\": \"Start Date\",\n- \"endDate\": \"End Date\",\n- \"location\": \"Location\",\n- \"type\": \"Type\",\n- \"types\": {\n- \"checkup\": \"Checkup\",\n- \"emergency\": \"Emergency\",\n- \"followUp\": \"Follow Up\",\n- \"routine\": \"Routine\",\n- \"walkIn\": \"Walk In\"\n- },\n- \"errors\": {\n- \"patientRequired\": \"Patient is required.\",\n- \"startDateMustBeBeforeEndDate\": \"Start Time must be before End Time.\"\n- },\n- \"reason\": \"Reason\",\n- \"patient\": \"Patient\",\n- \"deleteConfirmationMessage\": \"Are you sure you want to delete this appointment?\"\n- }\n- }\n-}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/locales/enUs/translations/patient/index.ts",
"new_path": "src/locales/enUs/translations/patient/index.ts",
"diff": "@@ -32,6 +32,33 @@ export default {\nnew: 'New Related Person',\nrelationshipType: 'Relationship Type',\n},\n+ allergies: {\n+ label: 'Allergies',\n+ new: 'Add Allergy',\n+ error: {\n+ nameRequired: 'Name is required.',\n+ },\n+ warning: {\n+ noAllergies: 'No Allergies',\n+ },\n+ addAllergyAbove: 'Add an allergy using the button above.',\n+ successfullyAdded: 'Successfully added a new allergy!',\n+ },\n+ diagnoses: {\n+ label: 'Diagnoses',\n+ new: 'Add Diagnoses',\n+ diagnosisName: 'Diagnosis Name',\n+ diagnosisDate: 'Diagnosis Date',\n+ warning: {\n+ noDiagnoses: 'No Diagnoses',\n+ },\n+ error: {\n+ nameRequired: 'Diagnosis Name is required.',\n+ dateRequired: 'Diagnosis Date is required.',\n+ },\n+ addDiagnosisAbove: 'Add a diagnosis using the button above.',\n+ successfullyAdded: 'Successfully added a new diagnosis!',\n+ },\ntypes: {\ncharity: 'Charity',\nprivate: 'Private',\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/Appointments.tsx",
"new_path": "src/scheduling/appointments/Appointments.tsx",
"diff": "@@ -36,7 +36,7 @@ const Appointments = () => {\nicon=\"appointment-add\"\nonClick={() => history.push('/appointments/new')}\n>\n- {t('scheduling.appointments.newAppointment')}\n+ {t('scheduling.appointments.new')}\n</Button>,\n])\nuseAddBreadcrumbs(breadcrumbs, true)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/new/NewAppointment.tsx",
"new_path": "src/scheduling/appointments/new/NewAppointment.tsx",
"diff": "@@ -14,14 +14,14 @@ import AppointmentDetailForm from '../AppointmentDetailForm'\nconst breadcrumbs = [\n{ i18nKey: 'scheduling.appointments.label', location: '/appointments' },\n- { i18nKey: 'scheduling.appointments.newAppointment', location: '/appointments/new' },\n+ { i18nKey: 'scheduling.appointments.new', location: '/appointments/new' },\n]\nconst NewAppointment = () => {\nconst { t } = useTranslation()\nconst history = useHistory()\nconst dispatch = useDispatch()\n- useTitle(t('scheduling.appointments.newAppointment'))\n+ useTitle(t('scheduling.appointments.new'))\nuseAddBreadcrumbs(breadcrumbs, true)\nconst startDateTime = roundToNearestMinutes(new Date(), { nearestTo: 15 })\nconst endDateTime = addMinutes(startDateTime, 60)\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(i8ln): add missing translations |
288,323 | 09.03.2020 20:48:47 | 18,000 | 3f58dd5253c37c16cb1ea27d6f467ef2d7afb7ea | feat(i8ln): accidently committed deleted file | [
{
"change_type": "DELETE",
"old_path": "src/__tests__/scheduling/appointments-slice.test.ts",
"new_path": null,
"diff": "-import { AnyAction } from 'redux'\n-import Appointment from 'model/Appointment'\n-import { createMemoryHistory } from 'history'\n-import AppointmentRepository from 'clients/db/AppointmentsRepository'\n-import { mocked } from 'ts-jest/utils'\n-import appointments, {\n- createAppointmentStart,\n- createAppointment,\n-} from '../../scheduling/appointments/appointments-slice'\n-\n-describe('appointments slice', () => {\n- describe('appointments reducer', () => {\n- it('should create the initial state properly', () => {\n- const appointmentsStore = appointments(undefined, {} as AnyAction)\n-\n- expect(appointmentsStore.isLoading).toBeFalsy()\n- })\n- it('should handle the CREATE_APPOINTMENT_START action', () => {\n- const appointmentsStore = appointments(undefined, {\n- type: createAppointmentStart.type,\n- })\n-\n- expect(appointmentsStore.isLoading).toBeTruthy()\n- })\n- })\n-\n- describe('createAppointments()', () => {\n- it('should dispatch the CREATE_APPOINTMENT_START action', async () => {\n- jest.spyOn(AppointmentRepository, 'save')\n- mocked(AppointmentRepository, true).save.mockResolvedValue({ id: '123' } as Appointment)\n- const dispatch = jest.fn()\n- const getState = jest.fn()\n- const expectedAppointment = {\n- patientId: '123',\n- startDateTime: new Date().toISOString(),\n- endDateTime: new Date().toISOString(),\n- location: 'location',\n- type: 'type',\n- reason: 'reason',\n- } as Appointment\n-\n- await createAppointment(expectedAppointment, createMemoryHistory())(dispatch, getState, null)\n-\n- expect(dispatch).toHaveBeenCalledWith({ type: createAppointmentStart.type })\n- })\n-\n- it('should call the the AppointmentRepository save function with the correct data', async () => {\n- const dispatch = jest.fn()\n- const getState = jest.fn()\n- const appointmentRepositorySaveSpy = jest.spyOn(AppointmentRepository, 'save')\n- mocked(AppointmentRepository, true).save.mockResolvedValue({ id: '123' } as Appointment)\n-\n- const expectedAppointment = {\n- patientId: '123',\n- startDateTime: new Date().toISOString(),\n- endDateTime: new Date().toISOString(),\n- location: 'location',\n- type: 'type',\n- reason: 'reason',\n- } as Appointment\n-\n- await createAppointment(expectedAppointment, createMemoryHistory())(dispatch, getState, null)\n-\n- expect(appointmentRepositorySaveSpy).toHaveBeenCalled()\n- expect(appointmentRepositorySaveSpy).toHaveBeenCalledWith(expectedAppointment)\n- })\n-\n- it('should navigate the /appointments when an appointment is successfully created', async () => {\n- jest.spyOn(AppointmentRepository, 'save')\n- mocked(AppointmentRepository, true).save.mockResolvedValue({ id: '123' } as Appointment)\n- const dispatch = jest.fn()\n- const getState = jest.fn()\n- const history = createMemoryHistory()\n-\n- const expectedAppointment = {\n- patientId: '123',\n- startDateTime: new Date().toISOString(),\n- endDateTime: new Date().toISOString(),\n- location: 'location',\n- type: 'type',\n- reason: 'reason',\n- } as Appointment\n-\n- await createAppointment(expectedAppointment, history)(dispatch, getState, null)\n-\n- expect(history.location.pathname).toEqual('/appointments')\n- })\n- })\n-})\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(i8ln): accidently committed deleted file |
288,323 | 09.03.2020 21:00:03 | 18,000 | 0f0a7c3edc5e2121624d4a1181963ddc7d45c65b | feat(i18n): fix tests | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/HospitalRun.test.tsx",
"new_path": "src/__tests__/HospitalRun.test.tsx",
"diff": "@@ -295,7 +295,7 @@ describe('HospitalRun', () => {\nexpect(store.getActions()).toContainEqual(\naddBreadcrumbs([\n{ i18nKey: 'scheduling.appointments.label', location: '/appointments' },\n- { i18nKey: 'scheduling.appointments.newAppointment', location: '/appointments/new' },\n+ { i18nKey: 'scheduling.appointments.new', location: '/appointments/new' },\n{ i18nKey: 'dashboard.label', location: '/' },\n]),\n)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/scheduling/appointments/Appointments.test.tsx",
"new_path": "src/__tests__/scheduling/appointments/Appointments.test.tsx",
"diff": "@@ -62,9 +62,7 @@ describe('Appointments', () => {\n})\nconst actualButtons: React.ReactNode[] = setButtonToolBarSpy.mock.calls[0][0]\n- expect((actualButtons[0] as any).props.children).toEqual(\n- 'scheduling.appointments.newAppointment',\n- )\n+ expect((actualButtons[0] as any).props.children).toEqual('scheduling.appointments.new')\n})\nit('should render a calendar with the proper events', async () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/scheduling/appointments/new/NewAppointment.test.tsx",
"new_path": "src/__tests__/scheduling/appointments/new/NewAppointment.test.tsx",
"diff": "@@ -62,7 +62,7 @@ describe('New Appointment', () => {\nawait setup()\n})\n- expect(titleUtil.default).toHaveBeenCalledWith('scheduling.appointments.newAppointment')\n+ expect(titleUtil.default).toHaveBeenCalledWith('scheduling.appointments.new')\n})\n})\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(i18n): fix tests |
288,323 | 09.03.2020 21:03:12 | 18,000 | 697552d6b0331d128fc16d2a7d4ec8262432b24b | feat(i18n): add more missing translations | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/components/Navbar.test.tsx",
"new_path": "src/__tests__/components/Navbar.test.tsx",
"diff": "@@ -75,7 +75,7 @@ describe('Navbar', () => {\n'scheduling.appointments.label',\n)\nexpect(scheduleLinkList.first().props().children[1].props.children).toEqual(\n- 'scheduling.appointments.newAppointment',\n+ 'scheduling.appointments.new',\n)\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/components/Navbar.tsx",
"new_path": "src/components/Navbar.tsx",
"diff": "@@ -63,7 +63,7 @@ const Navbar = () => {\n},\n{\ntype: 'link',\n- label: t('scheduling.appointments.newAppointment'),\n+ label: t('scheduling.appointments.new'),\nonClick: () => {\nhistory.push('/appointments/new')\n},\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(i18n): add more missing translations |
288,240 | 11.03.2020 09:09:29 | 25,200 | 837987d9a4e848c7d68fb2034954ea151977e28f | fix(./locales/enus/translations/scheduling/index.ts): changed 'Walk Up'
scheduling/appointments/AppointmentDetailForm.tsx label for 'walk in' is trying to consume
scheduling.appointment.types.walkIn but the translation file lists 'walkUp'. I changed the
translation file to reflect the value 'walk in' | [
{
"change_type": "MODIFY",
"old_path": "src/locales/enUs/translations/scheduling/index.ts",
"new_path": "src/locales/enUs/translations/scheduling/index.ts",
"diff": "@@ -15,7 +15,7 @@ export default {\nemergency: 'Emergency',\nfollowUp: 'Follow Up',\nroutine: 'Routine',\n- walkUp: 'Walk Up',\n+ walkIn: 'Walk In',\n},\nerrors: {\npatientRequired: 'Patient is required.',\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(./locales/enus/translations/scheduling/index.ts): changed 'Walk Up'
scheduling/appointments/AppointmentDetailForm.tsx label for 'walk in' is trying to consume
scheduling.appointment.types.walkIn but the translation file lists 'walkUp'. I changed the
translation file to reflect the value 'walk in' |
288,380 | 12.03.2020 01:08:19 | 10,800 | b43ae1146d5ee9622e57626050fe7f471c29bdb6 | feat(notes): add notes to pacient
fix | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/view/ViewPatient.test.tsx",
"new_path": "src/__tests__/patients/view/ViewPatient.test.tsx",
"diff": "@@ -14,6 +14,7 @@ import RelatedPersonTab from 'patients/related-persons/RelatedPersonTab'\nimport * as ButtonBarProvider from 'page-header/ButtonBarProvider'\nimport Allergies from 'patients/allergies/Allergies'\nimport Diagnoses from 'patients/diagnoses/Diagnoses'\n+import NotesTab from 'patients/notes/NoteTab'\nimport Patient from '../../../model/Patient'\nimport PatientRepository from '../../../clients/db/PatientRepository'\nimport * as titleUtil from '../../../page-header/useTitle'\n@@ -127,12 +128,13 @@ describe('ViewPatient', () => {\nconst tabs = tabsHeader.find(Tab)\nexpect(tabsHeader).toHaveLength(1)\n- expect(tabs).toHaveLength(5)\n+ expect(tabs).toHaveLength(6)\nexpect(tabs.at(0).prop('label')).toEqual('patient.generalInformation')\nexpect(tabs.at(1).prop('label')).toEqual('patient.relatedPersons.label')\nexpect(tabs.at(2).prop('label')).toEqual('scheduling.appointments.label')\nexpect(tabs.at(3).prop('label')).toEqual('patient.allergies.label')\nexpect(tabs.at(4).prop('label')).toEqual('patient.diagnoses.label')\n+ expect(tabs.at(5).prop('label')).toEqual('patient.notes.label')\n})\nit('should mark the general information tab as active and render the general information component when route is /patients/:id', async () => {\n@@ -237,4 +239,28 @@ describe('ViewPatient', () => {\nexpect(diagnosesTab).toHaveLength(1)\nexpect(diagnosesTab.prop('patient')).toEqual(patient)\n})\n+\n+ it('should mark the notes tab as active when it is clicked and render the note component when route is /patients/:id/notes', async () => {\n+ let wrapper: any\n+ await act(async () => {\n+ wrapper = await setup()\n+ })\n+\n+ await act(async () => {\n+ const tabsHeader = wrapper.find(TabsHeader)\n+ const tabs = tabsHeader.find(Tab)\n+ tabs.at(5).prop('onClick')()\n+ })\n+\n+ wrapper.update()\n+\n+ const tabsHeader = wrapper.find(TabsHeader)\n+ const tabs = tabsHeader.find(Tab)\n+ const notesTab = wrapper.find(NotesTab)\n+\n+ expect(history.location.pathname).toEqual(`/patients/${patient.id}/notes`)\n+ expect(tabs.at(5).prop('active')).toBeTruthy()\n+ expect(notesTab).toHaveLength(1)\n+ expect(notesTab.prop('patient')).toEqual(patient)\n+ })\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/locales/enUs/translations/patient/index.ts",
"new_path": "src/locales/enUs/translations/patient/index.ts",
"diff": "@@ -59,6 +59,18 @@ export default {\naddDiagnosisAbove: 'Add a diagnosis using the button above.',\nsuccessfullyAdded: 'Successfully added a new diagnosis!',\n},\n+ note: 'Note',\n+ notes: {\n+ label: 'Notes',\n+ new: 'New Note',\n+ warning: {\n+ noNotes: 'No Notes',\n+ },\n+ error: {\n+ noteRequired: 'Note is required.',\n+ },\n+ addNoteAbove: 'Add a note using the button above.',\n+ },\ntypes: {\ncharity: 'Charity',\nprivate: 'Private',\n"
},
{
"change_type": "MODIFY",
"old_path": "src/locales/enUs/translations/patients/index.ts",
"new_path": "src/locales/enUs/translations/patients/index.ts",
"diff": "@@ -6,5 +6,6 @@ export default {\nnewPatient: 'New Patient',\nsuccessfullyCreated: 'Successfully created patient',\nsuccessfullyAddedRelatedPerson: 'Successfully added the new related person',\n+ successfullyAddedNote: 'Successfully added the new note',\n},\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/model/Note.ts",
"diff": "+export default interface Note {\n+ noteDate: Date\n+ text: string\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/Patient.ts",
"new_path": "src/model/Patient.ts",
"diff": "@@ -4,6 +4,7 @@ import ContactInformation from './ContactInformation'\nimport RelatedPerson from './RelatedPerson'\nimport Allergy from './Allergy'\nimport Diagnosis from './Diagnosis'\n+import Note from './Note'\nexport default interface Patient extends AbstractDBModel, Name, ContactInformation {\nsex: string\n@@ -16,4 +17,5 @@ export default interface Patient extends AbstractDBModel, Name, ContactInformati\nrelatedPersons?: RelatedPerson[]\nallergies?: Allergy[]\ndiagnoses?: Diagnosis[]\n+ notes?: Note[]\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/notes/NewNoteModal.tsx",
"diff": "+import React, { useState } from 'react'\n+import { Modal, Alert, RichText, Label } from '@hospitalrun/components'\n+import { useTranslation } from 'react-i18next'\n+import Note from '../../model/Note'\n+\n+interface Props {\n+ show: boolean\n+ toggle: () => void\n+ onCloseButtonClick: () => void\n+ onSave: (note: Note) => void\n+}\n+\n+const NewNoteModal = (props: Props) => {\n+ const { show, toggle, onCloseButtonClick, onSave } = props\n+ const { t } = useTranslation()\n+ const [errorMessage, setErrorMessage] = useState('')\n+ const [note, setNote] = useState({\n+ noteDate: new Date(),\n+ text: '',\n+ })\n+\n+ const onFieldChange = (key: string, value: string | any) => {\n+ setNote({\n+ ...note,\n+ [key]: value,\n+ })\n+ }\n+\n+ const onRichTextElementChange = (\n+ event: React.KeyboardEvent<HTMLTextAreaElement>,\n+ fieldName: string,\n+ ) => {\n+ onFieldChange(fieldName, event)\n+ }\n+\n+ const body = (\n+ <form>\n+ {errorMessage && <Alert color=\"danger\" title={t('states.error')} message={errorMessage} />}\n+ <div className=\"row\">\n+ <div className=\"col-md-12\">\n+ <div className=\"form-group\">\n+ <Label text={t('patient.note')} htmlFor=\"noteText\" />\n+ <RichText\n+ id=\"noteText\"\n+ value={note.text}\n+ onChange={(event: React.KeyboardEvent<HTMLTextAreaElement>) => {\n+ onRichTextElementChange(event, 'text')\n+ }}\n+ />\n+ </div>\n+ </div>\n+ </div>\n+ </form>\n+ )\n+\n+ return (\n+ <Modal\n+ show={show}\n+ toggle={toggle}\n+ title={t('patient.notes.new')}\n+ body={body}\n+ closeButton={{\n+ children: t('actions.cancel'),\n+ color: 'danger',\n+ onClick: onCloseButtonClick,\n+ }}\n+ successButton={{\n+ children: t('patient.notes.new'),\n+ color: 'success',\n+ icon: 'add',\n+ iconLocation: 'left',\n+ onClick: () => {\n+ let newErrorMessage = ''\n+\n+ if (!note) {\n+ newErrorMessage += `${t('patient.notes.error.noteRequired')} `\n+ }\n+\n+ if (!newErrorMessage) {\n+ onSave(note as Note)\n+ } else {\n+ setErrorMessage(newErrorMessage.trim())\n+ }\n+ },\n+ }}\n+ />\n+ )\n+}\n+\n+export default NewNoteModal\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/notes/NoteTab.tsx",
"diff": "+/* eslint-disable react/no-danger */\n+import React, { useState } from 'react'\n+import { useSelector, useDispatch } from 'react-redux'\n+import { useTranslation } from 'react-i18next'\n+import { Button, List, ListItem, Toast, Alert } from '@hospitalrun/components'\n+import NewNoteModal from 'patients/notes/NewNoteModal'\n+import Note from 'model/Note'\n+import Patient from 'model/Patient'\n+import { updatePatient } from 'patients/patient-slice'\n+import { RootState } from '../../store'\n+import Permissions from '../../model/Permissions'\n+\n+interface Props {\n+ patient: Patient\n+}\n+\n+const NoteTab = (props: Props) => {\n+ const dispatch = useDispatch()\n+ const { patient } = props\n+ const { t } = useTranslation()\n+ const { permissions } = useSelector((state: RootState) => state.user)\n+ const [showNewNoteModal, setShowNoteModal] = useState<boolean>(false)\n+\n+ const onNewNoteClick = () => {\n+ setShowNoteModal(true)\n+ }\n+\n+ const closeNewNoteModal = () => {\n+ setShowNoteModal(false)\n+ }\n+\n+ const onAddNoteSuccess = () => {\n+ Toast('success', t('Success!'), t('patients.successfullyAddedNote'))\n+ }\n+\n+ const onNoteSave = (note: Note) => {\n+ const newNotes: Note[] = []\n+\n+ if (patient.notes) {\n+ newNotes.push(...patient.notes)\n+ }\n+\n+ newNotes.push(note)\n+\n+ const patientToUpdate = {\n+ ...patient,\n+ notes: newNotes,\n+ }\n+\n+ dispatch(updatePatient(patientToUpdate, onAddNoteSuccess))\n+ closeNewNoteModal()\n+ }\n+ return (\n+ <div>\n+ <div className=\"row\">\n+ <div className=\"col-md-12 d-flex justify-content-end\">\n+ {permissions.includes(Permissions.WritePatients) && (\n+ <Button\n+ outlined\n+ color=\"success\"\n+ icon=\"add\"\n+ iconLocation=\"left\"\n+ onClick={onNewNoteClick}\n+ >\n+ {t('patient.notes.new')}\n+ </Button>\n+ )}\n+ </div>\n+ </div>\n+ <br />\n+ {(!patient.notes || patient.notes.length === 0) && (\n+ <Alert\n+ color=\"warning\"\n+ title={t('patient.notes.warning.noNotes')}\n+ message={t('patient.notes.addNoteAbove')}\n+ />\n+ )}\n+ <List>\n+ {patient.notes?.map((a: Note) => (\n+ <ListItem>\n+ {new Date(a.noteDate).toLocaleString()}\n+ <div dangerouslySetInnerHTML={{ __html: a.text }} />\n+ </ListItem>\n+ ))}\n+ </List>\n+ <NewNoteModal\n+ show={showNewNoteModal}\n+ toggle={closeNewNoteModal}\n+ onCloseButtonClick={closeNewNoteModal}\n+ onSave={onNoteSave}\n+ />\n+ </div>\n+ )\n+}\n+\n+export default NoteTab\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/view/ViewPatient.tsx",
"new_path": "src/patients/view/ViewPatient.tsx",
"diff": "@@ -17,6 +17,7 @@ import GeneralInformation from '../GeneralInformation'\nimport RelatedPerson from '../related-persons/RelatedPersonTab'\nimport useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs'\nimport AppointmentsList from '../appointments/AppointmentsList'\n+import Note from '../notes/NoteTab'\nconst getPatientCode = (p: Patient): string => {\nif (p) {\n@@ -107,6 +108,11 @@ const ViewPatient = () => {\nlabel={t('patient.diagnoses.label')}\nonClick={() => history.push(`/patients/${patient.id}/diagnoses`)}\n/>\n+ <Tab\n+ active={location.pathname === `/patients/${patient.id}/notes`}\n+ label={t('patient.notes.label')}\n+ onClick={() => history.push(`/patients/${patient.id}/notes`)}\n+ />\n</TabsHeader>\n<Panel>\n<Route exact path=\"/patients/:id\">\n@@ -124,6 +130,9 @@ const ViewPatient = () => {\n<Route exact path=\"/patients/:id/diagnoses\">\n<Diagnoses patient={patient} />\n</Route>\n+ <Route exact path=\"/patients/:id/notes\">\n+ <Note patient={patient} />\n+ </Route>\n</Panel>\n</div>\n)\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(notes): add notes to pacient
fix #1771 |
288,406 | 12.03.2020 10:47:49 | 18,000 | 4c0b8fec526d8aa3730ca550db70dbdd01d593e3 | feat: added successful alert when adding new appointments
Added successful alert when adding new appointments. Replicated successful alert from new patients
process and added the successful property on the translation file
re | [
{
"change_type": "MODIFY",
"old_path": "src/locales/enUs/translations/scheduling/index.ts",
"new_path": "src/locales/enUs/translations/scheduling/index.ts",
"diff": "@@ -17,6 +17,7 @@ export default {\nroutine: 'Routine',\nwalkUp: 'Walk Up',\n},\n+ successfullyCreated: 'Appointment successfully created.',\nerrors: {\npatientRequired: 'Patient is required.',\nerrorCreatingAppointment: 'Error Creating Appointment!',\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/new/NewAppointment.tsx",
"new_path": "src/scheduling/appointments/new/NewAppointment.tsx",
"diff": "@@ -7,7 +7,7 @@ import { useDispatch } from 'react-redux'\nimport Appointment from 'model/Appointment'\nimport addMinutes from 'date-fns/addMinutes'\nimport { isBefore } from 'date-fns'\n-import { Button } from '@hospitalrun/components'\n+import { Button, Toast } from '@hospitalrun/components'\nimport useAddBreadcrumbs from '../../../breadcrumbs/useAddBreadcrumbs'\nimport { createAppointment } from '../appointment-slice'\nimport AppointmentDetailForm from '../AppointmentDetailForm'\n@@ -42,6 +42,11 @@ const NewAppointment = () => {\nconst onNewAppointmentSaveSuccess = (newAppointment: Appointment) => {\nhistory.push(`/appointments/${newAppointment.id}`)\n+ Toast(\n+ 'success',\n+ t('Success!'),\n+ `${t('scheduling.appointment.successfullyCreated')} ${newAppointment.id}`,\n+ )\n}\nconst onSave = () => {\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat: added successful alert when adding new appointments
Added successful alert when adding new appointments. Replicated successful alert from new patients
process and added the successful property on the translation file
re #1894 |
288,240 | 13.03.2020 11:19:09 | 25,200 | 91baf9d25dde7c61981ba1c20826d3d98f224f72 | fix(schedual button): fixed delete appointment button
Delete appointment button no longer displays internationalization keys and instead reads correctly. | [
{
"change_type": "MODIFY",
"old_path": "src/locales/enUs/translations/scheduling/index.ts",
"new_path": "src/locales/enUs/translations/scheduling/index.ts",
"diff": "@@ -4,6 +4,7 @@ export default {\nappointments: {\nlabel: 'Appointments',\nnew: 'New Appointment',\n+ deleteAppointment: 'Delete Appointment',\n},\nappointment: {\nstartDate: 'Start Date',\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(schedual button): fixed delete appointment button
Delete appointment button no longer displays internationalization keys and instead reads correctly.
#1901 |
288,329 | 15.03.2020 13:19:57 | -3,600 | 58f94027db50bcfb4a04170c08b7e9facafaf68b | fix(#1899): added warning messages | [
{
"change_type": "MODIFY",
"old_path": "src/locales/enUs/translations/patient/index.ts",
"new_path": "src/locales/enUs/translations/patient/index.ts",
"diff": "@@ -31,6 +31,10 @@ export default {\nlabel: 'Related Persons',\nnew: 'New Related Person',\nrelationshipType: 'Relationship Type',\n+ warning: {\n+ noRelatedPersons: 'No related persons',\n+ },\n+ addRelatedPersonAbove: 'Add a related person using the button above.',\n},\nallergies: {\nlabel: 'Allergies',\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(#1899): added warning messages |
288,333 | 15.03.2020 09:25:32 | 25,200 | 89f0bcdeb858635eda4fae4585d95e64281ea49b | fix( fixed button position | [
{
"change_type": "MODIFY",
"old_path": "src/patients/new/NewPatient.tsx",
"new_path": "src/patients/new/NewPatient.tsx",
"diff": "@@ -68,7 +68,7 @@ const NewPatient = () => {\nerrorMessage={errorMessage}\n/>\n<div className=\"row float-right\">\n- <div className=\"btn-group btn-group-lg\">\n+ <div className=\"btn-group btn-group-lg mt-3\">\n<Button className=\"mr-2\" color=\"success\" onClick={onSave}>\n{t('actions.save')}\n</Button>\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix( #1906): fixed button position |
288,264 | 16.03.2020 18:08:34 | 14,400 | b7465be520174327be6775753854fdbf65cca4a4 | fix: typo in changelog.md | [
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "@@ -149,7 +149,7 @@ All notable changes to this project will be documented in this file. See [standa\n* **test:** updates coveralls script ([f8844ed](https://github.com/HospitalRun/hospitalrun-frontend/commit/f8844ed74345a6bf455bcfb28154ed03f21e6d51))\n* **tests:** fix matchMediaMock issue when running tests ([2edfe1b](https://github.com/HospitalRun/hospitalrun-frontend/commit/2edfe1b247ec5d0e5d5e372e0facb82be535af3f))\n* remove swap files inadverdently checked in ([9d2040d](https://github.com/HospitalRun/hospitalrun-frontend/commit/9d2040da45bf1e0a90d6468d4ab7d493e7a41e91))\n-* when deleting patient records, also delete appointsments, payments, invoice line items and proc charges ([5939a73](https://github.com/HospitalRun/hospitalrun-frontend/commit/5939a738f3fce786dca84e32246236c4681767f4))\n+* when deleting patient records, also delete appointments, payments, invoice line items and proc charges ([5939a73](https://github.com/HospitalRun/hospitalrun-frontend/commit/5939a738f3fce786dca84e32246236c4681767f4))\n* drop support for Node.js 0.10 ([#782](https://github.com/HospitalRun/hospitalrun-frontend/issues/782)) ([c3e2dae](https://github.com/HospitalRun/hospitalrun-frontend/commit/c3e2dae5f3f16010a572a046697be9372169daa5))\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix: typo in changelog.md |
288,406 | 17.03.2020 19:28:38 | 18,000 | d1abb6f6c4976e746cc0aa2496d5ad858774664e | refactor: added test to new appoinment success message
Added test for toast when a new appointment is created successfully
re | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/scheduling/appointments/new/NewAppointment.test.tsx",
"new_path": "src/__tests__/scheduling/appointments/new/NewAppointment.test.tsx",
"diff": "@@ -4,7 +4,6 @@ import NewAppointment from 'scheduling/appointments/new/NewAppointment'\nimport { Router, Route } from 'react-router'\nimport { Provider } from 'react-redux'\nimport { mount } from 'enzyme'\n-import { Button, Alert } from '@hospitalrun/components'\nimport { roundToNearestMinutes, addMinutes } from 'date-fns'\nimport { createMemoryHistory, MemoryHistory } from 'history'\nimport { act } from '@testing-library/react'\n@@ -16,10 +15,12 @@ import thunk from 'redux-thunk'\nimport Appointment from 'model/Appointment'\nimport Patient from 'model/Patient'\nimport AppointmentDetailForm from 'scheduling/appointments/AppointmentDetailForm'\n+import * as components from '@hospitalrun/components'\nimport * as titleUtil from '../../../../page-header/useTitle'\nimport * as appointmentSlice from '../../../../scheduling/appointments/appointment-slice'\nconst mockStore = configureMockStore([thunk])\n+const mockedComponents = mocked(components, true)\ndescribe('New Appointment', () => {\nlet history: MemoryHistory\n@@ -144,7 +145,7 @@ describe('New Appointment', () => {\nwrapper.update()\n- const saveButton = wrapper.find(Button).at(0)\n+ const saveButton = wrapper.find(mockedComponents.Button).at(0)\nexpect(saveButton.text().trim()).toEqual('actions.save')\nconst onClick = saveButton.prop('onClick') as any\n@@ -158,6 +159,7 @@ describe('New Appointment', () => {\n})\nit('should navigate to /appointments/:id when a new appointment is created', async () => {\n+ jest.spyOn(components, 'Toast')\nlet wrapper: any\nawait act(async () => {\nwrapper = await setup()\n@@ -181,7 +183,7 @@ describe('New Appointment', () => {\nonFieldChange('patientId', expectedAppointment.patientId)\n})\nwrapper.update()\n- const saveButton = wrapper.find(Button).at(0)\n+ const saveButton = wrapper.find(mockedComponents.Button).at(0)\nexpect(saveButton.text().trim()).toEqual('actions.save')\nconst onClick = saveButton.prop('onClick') as any\n@@ -190,6 +192,11 @@ describe('New Appointment', () => {\n})\nexpect(history.location.pathname).toEqual(`/appointments/${expectedNewAppointment.id}`)\n+ expect(mockedComponents.Toast).toHaveBeenCalledWith(\n+ 'success',\n+ 'Success!',\n+ `scheduling.appointment.successfullyCreated ${expectedNewAppointment.id}`,\n+ )\n})\nit('should display an error if there is no patient id', async () => {\n@@ -199,13 +206,13 @@ describe('New Appointment', () => {\n})\nact(() => {\n- const saveButton = wrapper.find(Button).at(0)\n+ const saveButton = wrapper.find(mockedComponents.Button).at(0)\nconst onClick = saveButton.prop('onClick') as any\nonClick()\n})\nwrapper.update()\n- const alert = wrapper.find(Alert)\n+ const alert = wrapper.find(mockedComponents.Alert)\nexpect(alert).toHaveLength(1)\nexpect(alert.prop('message')).toEqual('scheduling.appointment.errors.patientRequired')\n})\n@@ -245,14 +252,14 @@ describe('New Appointment', () => {\nwrapper.update()\nact(() => {\n- const saveButton = wrapper.find(Button).at(0)\n+ const saveButton = wrapper.find(mockedComponents.Button).at(0)\nconst onClick = saveButton.prop('onClick') as any\nonClick()\n})\nwrapper.update()\n- const alert = wrapper.find(Alert)\n+ const alert = wrapper.find(mockedComponents.Alert)\nexpect(alert).toHaveLength(1)\nexpect(alert.prop('message')).toEqual(\n'scheduling.appointment.errors.startDateMustBeBeforeEndDate',\n@@ -267,7 +274,7 @@ describe('New Appointment', () => {\nwrapper = await setup()\n})\n- const cancelButton = wrapper.find(Button).at(1)\n+ const cancelButton = wrapper.find(mockedComponents.Button).at(1)\nact(() => {\nconst onClick = cancelButton.prop('onClick') as any\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | refactor: added test to new appoinment success message
Added test for toast when a new appointment is created successfully
re #1894 |
288,323 | 18.03.2020 19:07:53 | 18,000 | 392c7cd021b49fa8ada4d27505325cc4f33fd4b4 | test: use components library typeahead | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/related-persons/NewRelatedPersonModal.test.tsx",
"new_path": "src/__tests__/patients/related-persons/NewRelatedPersonModal.test.tsx",
"diff": "import '../../../__mocks__/matchMediaMock'\nimport React from 'react'\nimport { ReactWrapper, mount } from 'enzyme'\n-import { Modal, Alert } from '@hospitalrun/components'\n+import { Modal, Alert, Typeahead } from '@hospitalrun/components'\nimport { act } from '@testing-library/react'\n-import { Typeahead } from 'react-bootstrap-typeahead'\nimport NewRelatedPersonModal from '../../../patients/related-persons/NewRelatedPersonModal'\nimport TextInputWithLabelFormGroup from '../../../components/input/TextInputWithLabelFormGroup'\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | test: use components library typeahead |
288,323 | 18.03.2020 19:16:58 | 18,000 | 44f05e7573bf79a95d388e874c8b80bf3b32794b | style: makes unused vars error with linting | [
{
"change_type": "MODIFY",
"old_path": ".eslintrc.js",
"new_path": ".eslintrc.js",
"diff": "@@ -35,7 +35,7 @@ module.exports = {\n'@typescript-eslint/member-delimiter-style': 'off',\n'@typescript-eslint/explicit-function-return-type': 'off',\n'@typescript-eslint/no-explicit-any': 'off',\n- '@typescript-eslint/no-unused-vars': 'off',\n+ '@typescript-eslint/no-unused-vars': 'error',\n'@typescript-eslint/unified-signatures': 'error',\n'@typescript-eslint/no-inferrable-types': ['error', { ignoreParameters: true }],\n'react/jsx-filename-extension': ['error', { extensions: ['.tsx'] }],\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/related-persons/NewRelatedPersonModal.test.tsx",
"new_path": "src/__tests__/patients/related-persons/NewRelatedPersonModal.test.tsx",
"diff": "@@ -85,7 +85,6 @@ describe('New Related Person Modal', () => {\n})\nwrapper.update()\n- const addNewButton = wrapper.findWhere((w) => w.text() === 'patient.relatedPersons.new')\nact(() => {\n;(wrapper.find(Modal).prop('successButton') as any).onClick(\n{} as React.MouseEvent<HTMLButtonElement, MouseEvent>,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/clients/db/Repository.ts",
"new_path": "src/clients/db/Repository.ts",
"diff": "-/* eslint \"@typescript-eslint/camelcase\": \"off\" */\n+/* eslint \"@typescript-eslint/camelcase\": \"off\", \"@typescript-eslint/no-unused-vars\": \"off\" */\nimport { v4 as uuidv4 } from 'uuid'\nimport AbstractDBModel from '../../model/AbstractDBModel'\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | style: makes unused vars error with linting |
288,333 | 19.03.2020 11:36:25 | 25,200 | b43facf64e11e412fd1b4dfb2b872602e5ae0f75 | fix(#1915): ark required fields as required for new/edit Patient | [
{
"change_type": "MODIFY",
"old_path": "src/components/input/TextInputWithLabelFormGroup.tsx",
"new_path": "src/components/input/TextInputWithLabelFormGroup.tsx",
"diff": "@@ -9,14 +9,15 @@ interface Props {\ntype: 'text' | 'email' | 'number' | 'tel'\nplaceholder?: string\nonChange?: (event: React.ChangeEvent<HTMLInputElement>) => void\n+ isRequired?: boolean\n}\nconst TextInputWithLabelFormGroup = (props: Props) => {\n- const { value, label, name, isEditable, onChange, placeholder, type } = props\n+ const { value, label, name, isEditable, onChange, placeholder, type, isRequired } = props\nconst id = `${name}TextInput`\nreturn (\n<div className=\"form-group\">\n- <Label text={label} htmlFor={id} />\n+ <Label text={label} htmlFor={id} isRequired={isRequired} />\n<TextInput\nid={id}\nvalue={value}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/GeneralInformation.tsx",
"new_path": "src/patients/GeneralInformation.tsx",
"diff": "@@ -71,6 +71,7 @@ const GeneralInformation = (props: Props) => {\nonChange={(event: React.ChangeEvent<HTMLInputElement>) => {\nonInputElementChange(event, 'givenName')\n}}\n+ isRequired\n/>\n</div>\n<div className=\"col-md-4\">\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(#1915): ark required fields as required for new/edit Patient |
288,373 | 20.03.2020 23:15:04 | 14,400 | 735c8f3172d50a5bd0af2405fd1784899ed58492 | fix(component): changed Add Diagnoses button to Add Diagnosis for
Changed the spelling of the Add Diagnoses Button to Add Diagnosis for Issue Number 1929.
fix | [
{
"change_type": "MODIFY",
"old_path": "src/locales/enUs/translations/patient/index.ts",
"new_path": "src/locales/enUs/translations/patient/index.ts",
"diff": "@@ -50,7 +50,7 @@ export default {\n},\ndiagnoses: {\nlabel: 'Diagnoses',\n- new: 'Add Diagnoses',\n+ new: 'Add Diagnosis',\ndiagnosisName: 'Diagnosis Name',\ndiagnosisDate: 'Diagnosis Date',\nwarning: {\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(component): changed Add Diagnoses button to Add Diagnosis for #1929
Changed the spelling of the Add Diagnoses Button to Add Diagnosis for Issue Number 1929.
fix #1929 |
288,329 | 21.03.2020 11:25:29 | -3,600 | 47d14a0d1643a77f6b2b21197918d6c6f541f638 | fix(patient): mark required fields in New Appointment/Edit Appointment
Mark required fields with the *.
fix | [
{
"change_type": "MODIFY",
"old_path": "src/components/input/DateTimePickerWithLabelFormGroup.tsx",
"new_path": "src/components/input/DateTimePickerWithLabelFormGroup.tsx",
"diff": "@@ -14,7 +14,7 @@ const DateTimePickerWithLabelFormGroup = (props: Props) => {\nconst id = `${name}DateTimePicker`\nreturn (\n<div className=\"form-group\">\n- <Label text={label} htmlFor={id} />\n+ <Label text={label} isRequired htmlFor={id} />\n<DateTimePicker\ndateFormat=\"MM/dd/yyyy h:mm aa\"\ndateFormatCalendar=\"LLLL yyyy\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/AppointmentDetailForm.tsx",
"new_path": "src/scheduling/appointments/AppointmentDetailForm.tsx",
"diff": "@@ -36,7 +36,11 @@ const AppointmentDetailForm = (props: Props) => {\n<div className=\"row\">\n<div className=\"col\">\n<div className=\"form-group\">\n- <Label htmlFor=\"patientTypeahead\" text={t('scheduling.appointment.patient')} />\n+ <Label\n+ htmlFor=\"patientTypeahead\"\n+ isRequired\n+ text={t('scheduling.appointment.patient')}\n+ />\n<Typeahead\nid=\"patientTypeahead\"\ndisabled={!isEditable || patient !== undefined}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(patient): mark required fields in New Appointment/Edit Appointment
Mark required fields with the *.
fix #1916 |
288,292 | 21.03.2020 11:18:20 | 25,200 | b4100f5c692d6a589c90c75246676aa9e4a28b04 | fix(adddiagnosismodal and datepickerwithlabelformgroups): required field
Added required fields to diagnosis name and date
fix | [
{
"change_type": "MODIFY",
"old_path": "src/components/input/DatePickerWithLabelFormGroup.tsx",
"new_path": "src/components/input/DatePickerWithLabelFormGroup.tsx",
"diff": "@@ -7,14 +7,15 @@ interface Props {\nvalue: Date | undefined\nisEditable?: boolean\nonChange?: (date: Date) => void\n+ isRequired?: boolean\n}\nconst DatePickerWithLabelFormGroup = (props: Props) => {\n- const { onChange, label, name, isEditable, value } = props\n+ const { onChange, label, name, isEditable, value, isRequired } = props\nconst id = `${name}DatePicker`\nreturn (\n<div className=\"form-group\">\n- <Label text={label} htmlFor={id} />\n+ <Label text={label} htmlFor={id} isRequired={isRequired} />\n<DateTimePicker\ndateFormat=\"MM/dd/yyyy\"\ndateFormatCalendar=\"LLLL yyyy\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/diagnoses/AddDiagnosisModal.tsx",
"new_path": "src/patients/diagnoses/AddDiagnosisModal.tsx",
"diff": "@@ -63,6 +63,7 @@ const AddDiagnosisModal = (props: Props) => {\nplaceholder={t('patient.diagnoses.diagnosisName')}\nvalue={diagnosis.name}\nonChange={onNameChange}\n+ isRequired\n/>\n</div>\n</div>\n@@ -75,6 +76,7 @@ const AddDiagnosisModal = (props: Props) => {\nvalue={new Date(diagnosis.diagnosisDate)}\nisEditable\nonChange={onDiagnosisDateChange}\n+ isRequired\n/>\n</div>\n</div>\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(adddiagnosismodal and datepickerwithlabelformgroups): required field
Added required fields to diagnosis name and date
fix #1926 |
288,323 | 21.03.2020 17:08:20 | 18,000 | 5c67b72f46f32e177b10b6a30bc2039ca2874514 | fix(search): fixes search inputs being too small | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/view/ViewPatient.test.tsx",
"new_path": "src/__tests__/patients/view/ViewPatient.test.tsx",
"diff": "@@ -113,7 +113,6 @@ describe('ViewPatient', () => {\nsetup()\nconst actualButtons: React.ReactNode[] = setButtonToolBarSpy.mock.calls[0][0]\n- console.log(actualButtons)\nexpect(actualButtons.length).toEqual(0)\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/appointments/AppointmentsList.tsx",
"new_path": "src/patients/appointments/AppointmentsList.tsx",
"diff": "@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'\nimport { useSelector, useDispatch } from 'react-redux'\nimport { useHistory } from 'react-router'\nimport { useTranslation } from 'react-i18next'\n-import { TextInput, Button, List, ListItem, Container, Row } from '@hospitalrun/components'\n+import { TextInput, Button, List, ListItem, Container, Row, Column } from '@hospitalrun/components'\nimport { RootState } from '../../store'\nimport { fetchPatientAppointments } from '../../scheduling/appointments/appointments-slice'\nimport useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs'\n@@ -54,18 +54,23 @@ const AppointmentsList = (props: Props) => {\nreturn (\n<Container>\n- <form className=\"form-inline\" onSubmit={onSearchFormSubmit}>\n- <div className=\"input-group\" style={{ width: '100%' }}>\n+ <form className=\"form\" onSubmit={onSearchFormSubmit}>\n+ <Row>\n+ <Column md={10}>\n<TextInput\nsize=\"lg\"\n+ type=\"text\"\n+ onChange={onSearchBoxChange}\nvalue={searchText}\nplaceholder={t('actions.search')}\n- onChange={onSearchBoxChange}\n/>\n- <div className=\"input-group-append\">\n- <Button onClick={onSearchFormSubmit}>{t('actions.search')}</Button>\n- </div>\n- </div>\n+ </Column>\n+ <Column md={2}>\n+ <Button size=\"large\" onClick={onSearchFormSubmit}>\n+ {t('actions.search')}\n+ </Button>\n+ </Column>\n+ </Row>\n</form>\n<Row>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/list/Patients.tsx",
"new_path": "src/patients/list/Patients.tsx",
"diff": "@@ -2,7 +2,16 @@ import React, { useEffect, useState } from 'react'\nimport { useSelector, useDispatch } from 'react-redux'\nimport { useHistory } from 'react-router'\nimport { useTranslation } from 'react-i18next'\n-import { Spinner, TextInput, Button, List, ListItem, Container, Row } from '@hospitalrun/components'\n+import {\n+ Spinner,\n+ Button,\n+ List,\n+ ListItem,\n+ Container,\n+ Row,\n+ TextInput,\n+ Column,\n+} from '@hospitalrun/components'\nimport { useButtonToolbarSetter } from 'page-header/ButtonBarProvider'\nimport { RootState } from '../../store'\nimport { fetchPatients, searchPatients } from '../patients-slice'\n@@ -67,18 +76,23 @@ const Patients = () => {\nreturn (\n<Container>\n- <form className=\"form-inline\" onSubmit={onSearchFormSubmit}>\n- <div className=\"input-group\" style={{ width: '100%' }}>\n+ <form className=\"form\" onSubmit={onSearchFormSubmit}>\n+ <Row>\n+ <Column md={10}>\n<TextInput\nsize=\"lg\"\n+ type=\"text\"\n+ onChange={onSearchBoxChange}\nvalue={searchText}\nplaceholder={t('actions.search')}\n- onChange={onSearchBoxChange}\n/>\n- <div className=\"input-group-append\">\n- <Button onClick={onSearchFormSubmit}>{t('actions.search')}</Button>\n- </div>\n- </div>\n+ </Column>\n+ <Column md={2}>\n+ <Button size=\"large\" onClick={onSearchFormSubmit}>\n+ {t('actions.search')}\n+ </Button>\n+ </Column>\n+ </Row>\n</form>\n<Row>\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(search): fixes search inputs being too small |
288,323 | 23.03.2020 21:45:00 | 18,000 | 4495ab800f28009f8010ac07fa9488c33e99202b | style(eslint): better eslint rules for unused vars | [
{
"change_type": "MODIFY",
"old_path": ".eslintrc.js",
"new_path": ".eslintrc.js",
"diff": "@@ -35,7 +35,7 @@ module.exports = {\n'@typescript-eslint/member-delimiter-style': 'off',\n'@typescript-eslint/explicit-function-return-type': 'off',\n'@typescript-eslint/no-explicit-any': 'off',\n- '@typescript-eslint/no-unused-vars': 'error',\n+ '@typescript-eslint/no-unused-vars': ['error', { \"ignoreRestSiblings\": true }],\n'@typescript-eslint/unified-signatures': 'error',\n'@typescript-eslint/no-inferrable-types': ['error', { ignoreParameters: true }],\n'react/jsx-filename-extension': ['error', { extensions: ['.tsx'] }],\n"
},
{
"change_type": "MODIFY",
"old_path": "src/clients/db/Repository.ts",
"new_path": "src/clients/db/Repository.ts",
"diff": "-/* eslint \"@typescript-eslint/camelcase\": \"off\", \"@typescript-eslint/no-unused-vars\": \"off\" */\n+/* eslint \"@typescript-eslint/camelcase\": \"off\" */\nimport { v4 as uuidv4 } from 'uuid'\nimport AbstractDBModel from '../../model/AbstractDBModel'\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | style(eslint): better eslint rules for unused vars |
288,323 | 23.03.2020 21:47:57 | 18,000 | 490ad87848525fee643a2932e24cc8c49a65cae0 | style(eslint): add more recommended plugins | [
{
"change_type": "MODIFY",
"old_path": ".eslintrc.js",
"new_path": ".eslintrc.js",
"diff": "@@ -7,7 +7,9 @@ module.exports = {\n},\nextends: [\n'airbnb',\n- 'plugin:@typescript-eslint/recommended',\n+ \"eslint:recommended\",\n+ \"plugin:@typescript-eslint/eslint-recommended\",\n+ \"plugin:@typescript-eslint/recommended\",\n'prettier',\n'prettier/@typescript-eslint',\n'plugin:prettier/recommended',\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | style(eslint): add more recommended plugins |
288,329 | 24.03.2020 03:55:08 | -3,600 | 37ac2b5aa0574c807e5b222ba5fd139f4f22cb88 | feat(patient): provide better feedback on patient form | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/GeneralInformation.test.tsx",
"new_path": "src/__tests__/patients/GeneralInformation.test.tsx",
"diff": "@@ -17,14 +17,14 @@ describe('Error handling', () => {\n<GeneralInformation\npatient={{} as Patient}\nisEditable\n- errorMessage=\"patient.errors.patientGivenNameRequired\"\n+ errorMessage=\"patient.errors.patientGivenNameRequiredOnCreate\"\n/>\n</Router>,\n)\nconst errorMessage = wrapper.find(Alert)\nexpect(errorMessage).toBeTruthy()\n- expect(errorMessage.prop('message')).toMatch('patient.errors.patientGivenNameRequired')\n+ expect(errorMessage.prop('message')).toMatch('patient.errors.patientGivenNameRequiredOnCreate')\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/new/NewPatient.test.tsx",
"new_path": "src/__tests__/patients/new/NewPatient.test.tsx",
"diff": "@@ -95,8 +95,9 @@ describe('New Patient', () => {\nwrapper.update()\nexpect(wrapper.find(GeneralInformation).prop('errorMessage')).toMatch(\n- 'patient.errors.patientGivenNameRequired',\n+ 'patient.errors.patientGivenNameRequiredOnCreate',\n)\n+ expect(wrapper.update.isInvalid === true)\n})\nit('should dispatch createPatient when save button is clicked', async () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/components/input/TextInputWithLabelFormGroup.tsx",
"new_path": "src/components/input/TextInputWithLabelFormGroup.tsx",
"diff": "@@ -10,16 +10,31 @@ interface Props {\nplaceholder?: string\nonChange?: (event: React.ChangeEvent<HTMLInputElement>) => void\nisRequired?: boolean\n+ feedback?: string\n+ isInvalid?: boolean\n}\nconst TextInputWithLabelFormGroup = (props: Props) => {\n- const { value, label, name, isEditable, onChange, placeholder, type, isRequired } = props\n+ const {\n+ value,\n+ label,\n+ name,\n+ isEditable,\n+ onChange,\n+ placeholder,\n+ type,\n+ isRequired,\n+ feedback,\n+ isInvalid,\n+ } = props\nconst id = `${name}TextInput`\nreturn (\n<div className=\"form-group\">\n<Label text={label} htmlFor={id} isRequired={isRequired} />\n<TextInput\n+ feedback={feedback}\nid={id}\n+ isInvalid={isInvalid}\nvalue={value}\ndisabled={!isEditable}\nonChange={onChange}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/locales/enUs/translations/patient/index.ts",
"new_path": "src/locales/enUs/translations/patient/index.ts",
"diff": "@@ -69,7 +69,9 @@ export default {\nprivate: 'Private',\n},\nerrors: {\n- patientGivenNameRequired: 'Patient Given Name is required.',\n+ patientGivenNameRequiredOnCreate: 'Could not create new patient.',\n+ patientGivenNameRequiredOnUpdate: 'Could not update patient.',\n+ patientGivenNameFeedback: 'Given Name is required.',\n},\n},\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/GeneralInformation.tsx",
"new_path": "src/patients/GeneralInformation.tsx",
"diff": "@@ -14,11 +14,20 @@ interface Props {\nisEditable?: boolean\nerrorMessage?: string\nonFieldChange?: (key: string, value: string | boolean) => void\n+ isInvalid?: boolean\n+ patientGivenNameFeedback?: string\n}\nconst GeneralInformation = (props: Props) => {\nconst { t } = useTranslation()\n- const { patient, isEditable, onFieldChange, errorMessage } = props\n+ const {\n+ patient,\n+ isEditable,\n+ onFieldChange,\n+ errorMessage,\n+ isInvalid,\n+ patientGivenNameFeedback,\n+ } = props\nconst onSelectChange = (event: React.ChangeEvent<HTMLSelectElement>, fieldName: string) =>\nonFieldChange && onFieldChange(fieldName, event.target.value)\n@@ -72,6 +81,8 @@ const GeneralInformation = (props: Props) => {\nonInputElementChange(event, 'givenName')\n}}\nisRequired\n+ isInvalid={isInvalid}\n+ feedback={patientGivenNameFeedback}\n/>\n</div>\n<div className=\"col-md-4\">\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/edit/EditPatient.tsx",
"new_path": "src/patients/edit/EditPatient.tsx",
"diff": "@@ -27,6 +27,8 @@ const EditPatient = () => {\nconst [patient, setPatient] = useState({} as Patient)\nconst [errorMessage, setErrorMessage] = useState('')\n+ const [isInvalid, setIsInvalid] = useState(false)\n+ const [patientGivenNameFeedback, setPatientGivenNameFeedback] = useState('')\nconst { patient: reduxPatient, isLoading } = useSelector((state: RootState) => state.patient)\nuseTitle(\n@@ -68,7 +70,9 @@ const EditPatient = () => {\nconst onSave = () => {\nif (!patient.givenName) {\n- setErrorMessage(t('patient.errors.patientGivenNameRequired'))\n+ setErrorMessage(t('patient.errors.patientGivenNameRequiredOnUpdate'))\n+ setIsInvalid(true)\n+ setPatientGivenNameFeedback(t('patient.errors.patientGivenNameFeedback'))\n} else {\ndispatch(\nupdatePatient(\n@@ -100,6 +104,8 @@ const EditPatient = () => {\npatient={patient}\nonFieldChange={onFieldChange}\nerrorMessage={errorMessage}\n+ isInvalid={isInvalid}\n+ patientGivenNameFeedback={patientGivenNameFeedback}\n/>\n<div className=\"row float-right\">\n<div className=\"btn-group btn-group-lg\">\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/new/NewPatient.tsx",
"new_path": "src/patients/new/NewPatient.tsx",
"diff": "@@ -23,6 +23,8 @@ const NewPatient = () => {\nconst [patient, setPatient] = useState({} as Patient)\nconst [errorMessage, setErrorMessage] = useState('')\n+ const [isInvalid, setIsInvalid] = useState(false)\n+ const [patientGivenNameFeedback, setPatientGivenNameFeedback] = useState('')\nuseTitle(t('patients.newPatient'))\nuseAddBreadcrumbs(breadcrumbs, true)\n@@ -42,7 +44,9 @@ const NewPatient = () => {\nconst onSave = () => {\nif (!patient.givenName) {\n- setErrorMessage(t('patient.errors.patientGivenNameRequired'))\n+ setErrorMessage(t('patient.errors.patientGivenNameRequiredOnCreate'))\n+ setIsInvalid(true)\n+ setPatientGivenNameFeedback(t('patient.errors.patientGivenNameFeedback'))\n} else {\ndispatch(\ncreatePatient(\n@@ -70,6 +74,8 @@ const NewPatient = () => {\npatient={patient}\nonFieldChange={onFieldChange}\nerrorMessage={errorMessage}\n+ isInvalid={isInvalid}\n+ patientGivenNameFeedback={patientGivenNameFeedback}\n/>\n<div className=\"row float-right\">\n<div className=\"btn-group btn-group-lg mt-3\">\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(patient): provide better feedback on patient form (#1938) |
288,279 | 24.03.2020 17:56:41 | 14,400 | b7e7142031b408b7bf8c41abe07d91b347cee0a2 | feat(patients): added an asterisk to the Allergy Name field | [
{
"change_type": "MODIFY",
"old_path": "src/patients/allergies/NewAllergyModal.tsx",
"new_path": "src/patients/allergies/NewAllergyModal.tsx",
"diff": "@@ -50,6 +50,7 @@ const NewAllergyModal = (props: NewAllergyModalProps) => {\n<form>\n<TextInputWithLabelFormGroup\nname=\"name\"\n+ isRequired\nlabel={t('patient.allergies.allergyName')}\nisEditable\nplaceholder={t('patient.allergies.allergyName')}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(patients): added an asterisk to the Allergy Name field (#1944) |
288,265 | 28.03.2020 21:41:01 | 14,400 | d6904e74e4ec21da57529046243e1166c6287c8f | feat(patients): better form feedback for add allergy | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/allergies/NewAllergyModal.test.tsx",
"new_path": "src/__tests__/patients/allergies/NewAllergyModal.test.tsx",
"diff": "@@ -84,7 +84,7 @@ describe('New Allergy Modal', () => {\nexpect(wrapper.find(Alert)).toHaveLength(1)\nexpect(wrapper.find(Alert).prop('title')).toEqual('states.error')\n- expect(wrapper.find(Alert).prop('message')).toContain('patient.allergies.error.nameRequired')\n+ expect(wrapper.find(Alert).prop('message')).toContain('patient.allergies.error.unableToAdd')\n})\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/locales/enUs/translations/patient/index.ts",
"new_path": "src/locales/enUs/translations/patient/index.ts",
"diff": "@@ -42,6 +42,7 @@ export default {\nnew: 'Add Allergy',\nerror: {\nnameRequired: 'Name is required.',\n+ unableToAdd: 'Unable to add allergy.',\n},\nwarning: {\nnoAllergies: 'No Allergies',\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/allergies/NewAllergyModal.tsx",
"new_path": "src/patients/allergies/NewAllergyModal.tsx",
"diff": "@@ -14,6 +14,8 @@ const NewAllergyModal = (props: NewAllergyModalProps) => {\nconst { show, onCloseButtonClick, onSave } = props\nconst [allergy, setAllergy] = useState({ name: '' })\nconst [errorMessage, setErrorMessage] = useState('')\n+ const [isAllergyNameInvalid, setIsAllergynameInvalid] = useState(false)\n+ const [nameRequiredFeedback, setNameRequiredFeedback] = useState('')\nconst { t } = useTranslation()\nuseEffect(() => {\n@@ -29,7 +31,9 @@ const NewAllergyModal = (props: NewAllergyModalProps) => {\nconst onSaveButtonClick = () => {\nlet newErrorMessage = ''\nif (!allergy.name) {\n- newErrorMessage += `${t('patient.allergies.error.nameRequired')} `\n+ newErrorMessage += `${t('patient.allergies.error.unableToAdd')} `\n+ setIsAllergynameInvalid(true)\n+ setNameRequiredFeedback(`${t('patient.allergies.error.nameRequired')} `)\n}\nif (newErrorMessage) {\n@@ -49,6 +53,7 @@ const NewAllergyModal = (props: NewAllergyModalProps) => {\n{errorMessage && <Alert color=\"danger\" title={t('states.error')} message={errorMessage} />}\n<form>\n<TextInputWithLabelFormGroup\n+ feedback={nameRequiredFeedback}\nname=\"name\"\nisRequired\nlabel={t('patient.allergies.allergyName')}\n@@ -56,6 +61,7 @@ const NewAllergyModal = (props: NewAllergyModalProps) => {\nplaceholder={t('patient.allergies.allergyName')}\nvalue={allergy.name}\nonChange={onNameChange}\n+ isInvalid={isAllergyNameInvalid}\n/>\n</form>\n</>\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(patients): better form feedback for add allergy (#1945) |
288,313 | 29.03.2020 13:04:16 | 25,200 | e17dd1db2f33795f7fa6e76b3b4f90d5bdee7e48 | feat: indicate required fields in new Related Person Modal | [
{
"change_type": "MODIFY",
"old_path": "src/patients/related-persons/NewRelatedPersonModal.tsx",
"new_path": "src/patients/related-persons/NewRelatedPersonModal.tsx",
"diff": "@@ -43,7 +43,7 @@ const NewRelatedPersonModal = (props: Props) => {\n<div className=\"row\">\n<div className=\"col-md-12\">\n<div className=\"form-group\">\n- <Label text={t('patient.relatedPerson')} htmlFor=\"relatedPersonTypeAhead\" />\n+ <Label text={t('patient.relatedPerson')} htmlFor=\"relatedPersonTypeAhead\" isRequired />\n<Typeahead\nid=\"relatedPersonTypeAhead\"\nsearchAccessor=\"fullName\"\n@@ -64,6 +64,7 @@ const NewRelatedPersonModal = (props: Props) => {\nlabel={t('patient.relatedPersons.relationshipType')}\nvalue={relatedPerson.type}\nisEditable\n+ isRequired\nonChange={(event: React.ChangeEvent<HTMLInputElement>) => {\nonInputElementChange(event, 'type')\n}}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat: indicate required fields in new Related Person Modal (#1950) |
288,334 | 27.03.2020 21:05:28 | -3,600 | a64327419193557d124c1260049fde7270a09e49 | chore(lint): linting test files | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/components/Navbar.test.tsx",
"new_path": "src/__tests__/components/Navbar.test.tsx",
"diff": "@@ -30,10 +30,7 @@ describe('Navbar', () => {\n})\nit('should navigate to / when the header is clicked', () => {\nact(() => {\n- header\n- .first()\n- .props()\n- .onClick()\n+ header.first().props().onClick()\n})\nexpect(history.location.pathname).toEqual('/')\n})\n@@ -48,19 +45,13 @@ describe('Navbar', () => {\n})\nit('should navigate to /patients when the list option is selected', () => {\nact(() => {\n- patientsLinkList\n- .first()\n- .props()\n- .children[0].props.onClick()\n+ patientsLinkList.first().props().children[0].props.onClick()\n})\nexpect(history.location.pathname).toEqual('/patients')\n})\nit('should navigate to /patients/new when the list option is selected', () => {\nact(() => {\n- patientsLinkList\n- .first()\n- .props()\n- .children[1].props.onClick()\n+ patientsLinkList.first().props().children[1].props.onClick()\n})\nexpect(history.location.pathname).toEqual('/patients/new')\n})\n@@ -81,20 +72,14 @@ describe('Navbar', () => {\nit('should navigate to to /appointments when the appointment list option is selected', () => {\nact(() => {\n- scheduleLinkList\n- .first()\n- .props()\n- .children[0].props.onClick()\n+ scheduleLinkList.first().props().children[0].props.onClick()\n})\nexpect(history.location.pathname).toEqual('/appointments')\n})\nit('should navigate to /appointments/new when the new appointment list option is selected', () => {\nact(() => {\n- scheduleLinkList\n- .first()\n- .props()\n- .children[1].props.onClick()\n+ scheduleLinkList.first().props().children[1].props.onClick()\n})\nexpect(history.location.pathname).toEqual('/appointments/new')\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/components/Sidebar.test.tsx",
"new_path": "src/__tests__/components/Sidebar.test.tsx",
"diff": "@@ -35,12 +35,7 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\n- expect(\n- listItems\n- .at(1)\n- .text()\n- .trim(),\n- ).toEqual('dashboard.label')\n+ expect(listItems.at(1).text().trim()).toEqual('dashboard.label')\n})\nit('should be active when the current path is /', () => {\n@@ -70,12 +65,7 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\n- expect(\n- listItems\n- .at(2)\n- .text()\n- .trim(),\n- ).toEqual('patients.label')\n+ expect(listItems.at(2).text().trim()).toEqual('patients.label')\n})\nit('should be active when the current path is /', () => {\n@@ -105,12 +95,7 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\n- expect(\n- listItems\n- .at(3)\n- .text()\n- .trim(),\n- ).toEqual('scheduling.label')\n+ expect(listItems.at(3).text().trim()).toEqual('scheduling.label')\n})\nit('should be active when the current path is /appointments', () => {\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | chore(lint): linting test files |
288,308 | 31.03.2020 17:36:49 | 25,200 | 0afeee19bc70ac17cd5898baa7f6a8813fa68218 | feat(patients): new related person to add related person | [
{
"change_type": "RENAME",
"old_path": "src/__tests__/patients/related-persons/NewRelatedPersonModal.test.tsx",
"new_path": "src/__tests__/patients/related-persons/AddRelatedPersonModal.test.tsx",
"diff": "@@ -3,15 +3,15 @@ import React from 'react'\nimport { ReactWrapper, mount } from 'enzyme'\nimport { Modal, Alert, Typeahead } from '@hospitalrun/components'\nimport { act } from '@testing-library/react'\n-import NewRelatedPersonModal from '../../../patients/related-persons/NewRelatedPersonModal'\n+import AddRelatedPersonModal from '../../../patients/related-persons/AddRelatedPersonModal'\nimport TextInputWithLabelFormGroup from '../../../components/input/TextInputWithLabelFormGroup'\n-describe('New Related Person Modal', () => {\n+describe('Add Related Person Modal', () => {\ndescribe('layout', () => {\nlet wrapper: ReactWrapper\nbeforeEach(() => {\nwrapper = mount(\n- <NewRelatedPersonModal\n+ <AddRelatedPersonModal\nshow\nonSave={jest.fn()}\nonCloseButtonClick={jest.fn()}\n@@ -46,14 +46,16 @@ describe('New Related Person Modal', () => {\n})\nit('should render a cancel button', () => {\n- const cancelButton = wrapper.findWhere((w) => w.text() === 'actions.cancel')\n+ const cancelButton = wrapper.findWhere(\n+ (w: { text: () => string }) => w.text() === 'actions.cancel',\n+ )\nexpect(cancelButton).toHaveLength(1)\n})\nit('should render an add new related person button button', () => {\nconst modal = wrapper.find(Modal)\n- expect(modal.prop('successButton').children).toEqual('patient.relatedPersons.new')\n+ expect(modal.prop('successButton').children).toEqual('patient.relatedPersons.add')\n})\n})\n@@ -63,7 +65,7 @@ describe('New Related Person Modal', () => {\nbeforeEach(() => {\nonSaveSpy = jest.fn()\nwrapper = mount(\n- <NewRelatedPersonModal\n+ <AddRelatedPersonModal\nshow\nonSave={onSaveSpy}\nonCloseButtonClick={jest.fn()}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/related-persons/RelatedPersons.test.tsx",
"new_path": "src/__tests__/patients/related-persons/RelatedPersons.test.tsx",
"diff": "@@ -6,7 +6,7 @@ import { mount } from 'enzyme'\nimport RelatedPersonTab from 'patients/related-persons/RelatedPersonTab'\nimport * as components from '@hospitalrun/components'\n-import NewRelatedPersonModal from 'patients/related-persons/NewRelatedPersonModal'\n+import AddRelatedPersonModal from 'patients/related-persons/AddRelatedPersonModal'\nimport { act } from '@testing-library/react'\nimport PatientRepository from 'clients/db/PatientRepository'\nimport Patient from 'model/Patient'\n@@ -58,7 +58,7 @@ describe('Related Persons Tab', () => {\nconst newRelatedPersonButton = wrapper.find(components.Button)\nexpect(newRelatedPersonButton).toHaveLength(1)\n- expect(newRelatedPersonButton.text().trim()).toEqual('patient.relatedPersons.new')\n+ expect(newRelatedPersonButton.text().trim()).toEqual('patient.relatedPersons.add')\n})\nit('should not render a New Related Person button if the user does not have write privileges for a patient', () => {\n@@ -77,7 +77,7 @@ describe('Related Persons Tab', () => {\n})\nit('should render a New Related Person modal', () => {\n- const newRelatedPersonModal = wrapper.find(NewRelatedPersonModal)\n+ const newRelatedPersonModal = wrapper.find(AddRelatedPersonModal)\nexpect(newRelatedPersonModal.prop('show')).toBeFalsy()\nexpect(newRelatedPersonModal).toHaveLength(1)\n@@ -92,7 +92,7 @@ describe('Related Persons Tab', () => {\nwrapper.update()\n- const newRelatedPersonModal = wrapper.find(NewRelatedPersonModal)\n+ const newRelatedPersonModal = wrapper.find(AddRelatedPersonModal)\nexpect(newRelatedPersonModal.prop('show')).toBeTruthy()\n})\n@@ -124,7 +124,7 @@ describe('Related Persons Tab', () => {\nwrapper.update()\nawait act(async () => {\n- const newRelatedPersonModal = wrapper.find(NewRelatedPersonModal)\n+ const newRelatedPersonModal = wrapper.find(AddRelatedPersonModal)\nconst onSave = newRelatedPersonModal.prop('onSave') as any\nonSave(expectedRelatedPerson)\n})\n@@ -145,20 +145,20 @@ describe('Related Persons Tab', () => {\nwrapper.update()\nact(() => {\n- const newRelatedPersonModal = wrapper.find(NewRelatedPersonModal)\n+ const newRelatedPersonModal = wrapper.find(AddRelatedPersonModal)\nconst onSave = newRelatedPersonModal.prop('onSave') as any\nonSave({ patientId: '123', type: 'type' })\n})\nwrapper.update()\n- const newRelatedPersonModal = wrapper.find(NewRelatedPersonModal)\n+ const newRelatedPersonModal = wrapper.find(AddRelatedPersonModal)\nexpect(newRelatedPersonModal.prop('show')).toBeFalsy()\n})\nit('should display a success message when the new related person is added', async () => {\nawait act(async () => {\n- const newRelatedPersonModal = wrapper.find(NewRelatedPersonModal)\n+ const newRelatedPersonModal = wrapper.find(AddRelatedPersonModal)\nconst onSave = newRelatedPersonModal.prop('onSave') as any\nawait onSave({ patientId: 'testMessage', type: 'type' })\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/locales/enUs/translations/patient/index.ts",
"new_path": "src/locales/enUs/translations/patient/index.ts",
"diff": "@@ -30,6 +30,7 @@ export default {\n},\nlabel: 'Related Persons',\nnew: 'New Related Person',\n+ add: 'Add Related Person',\nrelationshipType: 'Relationship Type',\nwarning: {\nnoRelatedPersons: 'No related persons',\n"
},
{
"change_type": "RENAME",
"old_path": "src/patients/related-persons/NewRelatedPersonModal.tsx",
"new_path": "src/patients/related-persons/AddRelatedPersonModal.tsx",
"diff": "@@ -13,7 +13,7 @@ interface Props {\nonSave: (relatedPerson: RelatedPerson) => void\n}\n-const NewRelatedPersonModal = (props: Props) => {\n+const AddRelatedPersonModal = (props: Props) => {\nconst { show, toggle, onCloseButtonClick, onSave } = props\nconst { t } = useTranslation()\nconst [errorMessage, setErrorMessage] = useState('')\n@@ -78,7 +78,7 @@ const NewRelatedPersonModal = (props: Props) => {\n<Modal\nshow={show}\ntoggle={toggle}\n- title={t('patient.relatedPersons.new')}\n+ title={t('patient.relatedPersons.add')}\nbody={body}\ncloseButton={{\nchildren: t('actions.cancel'),\n@@ -86,7 +86,7 @@ const NewRelatedPersonModal = (props: Props) => {\nonClick: onCloseButtonClick,\n}}\nsuccessButton={{\n- children: t('patient.relatedPersons.new'),\n+ children: t('patient.relatedPersons.add'),\ncolor: 'success',\nicon: 'add',\niconLocation: 'left',\n@@ -111,4 +111,4 @@ const NewRelatedPersonModal = (props: Props) => {\n)\n}\n-export default NewRelatedPersonModal\n+export default AddRelatedPersonModal\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/related-persons/RelatedPersonTab.tsx",
"new_path": "src/patients/related-persons/RelatedPersonTab.tsx",
"diff": "import React, { useState, useEffect } from 'react'\nimport { Button, Panel, List, ListItem, Alert, Spinner, Toast } from '@hospitalrun/components'\n-import NewRelatedPersonModal from 'patients/related-persons/NewRelatedPersonModal'\n+import AddRelatedPersonModal from 'patients/related-persons/AddRelatedPersonModal'\nimport RelatedPerson from 'model/RelatedPerson'\nimport { useTranslation } from 'react-i18next'\nimport { useHistory } from 'react-router'\n@@ -100,7 +100,7 @@ const RelatedPersonTab = (props: Props) => {\niconLocation=\"left\"\nonClick={onNewRelatedPersonClick}\n>\n- {t('patient.relatedPersons.new')}\n+ {t('patient.relatedPersons.add')}\n</Button>\n)}\n</div>\n@@ -132,7 +132,7 @@ const RelatedPersonTab = (props: Props) => {\n</div>\n</div>\n- <NewRelatedPersonModal\n+ <AddRelatedPersonModal\nshow={showNewRelatedPersonModal}\ntoggle={closeNewRelatedPersonModal}\nonCloseButtonClick={closeNewRelatedPersonModal}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(patients): new related person to add related person (#1955) |
288,406 | 02.04.2020 16:12:50 | 18,000 | c74dec0d755ae5a4ac6ac997b6421dac70f336eb | feat: Added new proposed links to the sidebar | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/components/Sidebar.test.tsx",
"new_path": "src/__tests__/components/Sidebar.test.tsx",
"diff": "@@ -89,6 +89,66 @@ describe('Sidebar', () => {\n})\n})\n+ describe('patients_list link', () => {\n+ it('should render the patients_list link', () => {\n+ const wrapper = setup('/patients')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ expect(listItems.at(4).text().trim()).toEqual('patients.patientsList')\n+ })\n+\n+ it('should be active when the current path is /patients', () => {\n+ const wrapper = setup('/patients')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ expect(listItems.at(4).prop('active')).toBeTruthy()\n+ })\n+\n+ it('should navigate to /patients when the patients link is clicked', () => {\n+ const wrapper = setup('/patients')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ act(() => {\n+ ;(listItems.at(4).prop('onClick') as any)()\n+ })\n+\n+ expect(history.location.pathname).toEqual('/patients')\n+ })\n+ })\n+\n+ describe('new_patient link', () => {\n+ it('should render the new_patient link', () => {\n+ const wrapper = setup('/patients')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ expect(listItems.at(3).text().trim()).toEqual('patients.newPatient')\n+ })\n+\n+ it('should be active when the current path is /patients/new', () => {\n+ const wrapper = setup('/patients/new')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ expect(listItems.at(3).prop('active')).toBeTruthy()\n+ })\n+\n+ it('should navigate to /patients/new when the patients link is clicked', () => {\n+ const wrapper = setup('/patients')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ act(() => {\n+ ;(listItems.at(3).prop('onClick') as any)()\n+ })\n+\n+ expect(history.location.pathname).toEqual('/patients/new')\n+ })\n+ })\n+\ndescribe('appointments link', () => {\nit('should render the scheduling link', () => {\nconst wrapper = setup('/appointments')\n@@ -118,4 +178,64 @@ describe('Sidebar', () => {\nexpect(history.location.pathname).toEqual('/appointments')\n})\n})\n+\n+ describe('appointment_schedule link', () => {\n+ it('should render the appointment_schedule link', () => {\n+ const wrapper = setup('/appointments')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ expect(listItems.at(5).text().trim()).toEqual('scheduling.appointments.schedule')\n+ })\n+\n+ it('should be active when the current path is /appointments', () => {\n+ const wrapper = setup('/appointments')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ expect(listItems.at(5).prop('active')).toBeTruthy()\n+ })\n+\n+ it('should navigate to /appointments when the appointments_schedule link is clicked', () => {\n+ const wrapper = setup('/appointments')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ act(() => {\n+ ;(listItems.at(5).prop('onClick') as any)()\n+ })\n+\n+ expect(history.location.pathname).toEqual('/appointments')\n+ })\n+ })\n+\n+ describe('new_appointment link', () => {\n+ it('should render the new_appointment link', () => {\n+ const wrapper = setup('/appointments/new')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ expect(listItems.at(4).text().trim()).toEqual('scheduling.appointments.new')\n+ })\n+\n+ it('should be active when the current path is /appointments/new', () => {\n+ const wrapper = setup('/appointments/new')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ expect(listItems.at(4).prop('active')).toBeTruthy()\n+ })\n+\n+ it('should navigate to /appointments/new when the new_appointment link is clicked', () => {\n+ const wrapper = setup('/appointments')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ act(() => {\n+ ;(listItems.at(4).prop('onClick') as any)()\n+ })\n+\n+ expect(history.location.pathname).toEqual('/appointments/new')\n+ })\n+ })\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/components/Navbar.tsx",
"new_path": "src/components/Navbar.tsx",
"diff": "@@ -31,7 +31,7 @@ const Navbar = () => {\n{\ntype: 'link-list',\nlabel: t('patients.label'),\n- className: 'patients-link-list',\n+ className: 'patients-link-list d-md-none d-block',\nchildren: [\n{\ntype: 'link',\n@@ -52,7 +52,7 @@ const Navbar = () => {\n{\ntype: 'link-list',\nlabel: t('scheduling.label'),\n- className: 'scheduling-link-list',\n+ className: 'scheduling-link-list d-md-none d-block',\nchildren: [\n{\ntype: 'link',\n"
},
{
"change_type": "MODIFY",
"old_path": "src/components/Sidebar.tsx",
"new_path": "src/components/Sidebar.tsx",
"diff": "-import React, { CSSProperties } from 'react'\n+import React, { useState, CSSProperties } from 'react'\nimport { List, ListItem, Icon } from '@hospitalrun/components'\nimport { useTranslation } from 'react-i18next'\nimport { useLocation, useHistory } from 'react-router'\n@@ -14,6 +14,7 @@ const Sidebar = () => {\nconst path = useLocation()\nconst history = useHistory()\nconst { pathname } = path\n+ const splittedPath = pathname.split('/')\nconst navigateTo = (location: string) => {\nhistory.push(location)\n@@ -23,6 +24,53 @@ const Sidebar = () => {\ncursor: 'pointer',\n}\n+ const expandibleArrow: CSSProperties = {\n+ marginRight: '20px',\n+ }\n+\n+ const iconMargin: CSSProperties = {\n+ marginRight: '10px',\n+ }\n+\n+ const [expandedItem, setExpandedItem] = useState(\n+ splittedPath[1].includes('patients')\n+ ? 'patient'\n+ : splittedPath[1].includes('appointments')\n+ ? 'appointment'\n+ : 'none',\n+ )\n+\n+ const setExpansion = (item: string) => {\n+ if (expandedItem === item) {\n+ setExpandedItem('none')\n+ return\n+ }\n+\n+ setExpandedItem(item.toString())\n+ }\n+\n+ const listSubItemStyleNew: CSSProperties = {\n+ cursor: 'pointer',\n+ fontSize: 'small',\n+ borderBottomWidth: 0,\n+ color:\n+ (splittedPath[1].includes('patients') || splittedPath[1].includes('appointments')) &&\n+ splittedPath.length > 2\n+ ? 'white'\n+ : 'black',\n+ }\n+\n+ const listSubItemStyle: CSSProperties = {\n+ cursor: 'pointer',\n+ fontSize: 'small',\n+ borderBottomWidth: 0,\n+ color:\n+ (splittedPath[1].includes('patients') || splittedPath[1].includes('appointments')) &&\n+ splittedPath.length < 3\n+ ? 'white'\n+ : 'black',\n+ }\n+\nreturn (\n<nav\nclassName=\"col-md-2 d-none d-md-block bg-light sidebar\"\n@@ -42,28 +90,102 @@ const Sidebar = () => {\n</ListItem>\n<ListItem\nactive={pathname === '/'}\n- onClick={() => navigateTo('/')}\n+ onClick={() => {\n+ navigateTo('/')\n+ setExpansion('none')\n+ }}\nclassName=\"nav-item\"\nstyle={listItemStyle}\n>\n<Icon icon=\"dashboard\" /> {!sidebarCollapsed && t('dashboard.label')}\n</ListItem>\n<ListItem\n- active={pathname.split('/')[1].includes('patient')}\n- onClick={() => navigateTo('/patients')}\n+ active={splittedPath[1].includes('patient')}\n+ onClick={() => {\n+ navigateTo('/patients')\n+ if (expandedItem === 'patient') {\n+ setExpandedItem('none')\n+ return\n+ }\n+\n+ setExpandedItem('patient')\n+ }}\nclassName=\"nav-item\"\nstyle={listItemStyle}\n>\n+ <Icon\n+ icon={\n+ splittedPath[1].includes('patient') && expandedItem === 'patient'\n+ ? 'down-arrow'\n+ : 'right-arrow'\n+ }\n+ style={expandibleArrow}\n+ />\n<Icon icon=\"patients\" /> {!sidebarCollapsed && t('patients.label')}\n</ListItem>\n+ {splittedPath[1].includes('patient') && expandedItem === 'patient' && (\n+ <List layout=\"flush\">\n<ListItem\n- active={pathname.split('/')[1].includes('appointments')}\n- onClick={() => navigateTo('/appointments')}\n+ className=\"nav-item\"\n+ style={listSubItemStyleNew}\n+ onClick={() => navigateTo('/patients/new')}\n+ active={splittedPath[1].includes('patients') && splittedPath.length > 2}\n+ >\n+ <Icon icon=\"patient-add\" style={iconMargin} />\n+ {!sidebarCollapsed && t('patients.newPatient')}\n+ </ListItem>\n+ <ListItem\n+ className=\"nav-item\"\n+ style={listSubItemStyle}\n+ onClick={() => navigateTo('/patients')}\n+ active={splittedPath[1].includes('patients') && splittedPath.length < 3}\n+ >\n+ <Icon icon=\"incident\" style={iconMargin} />\n+ {!sidebarCollapsed && t('patients.patientsList')}\n+ </ListItem>\n+ </List>\n+ )}\n+ <ListItem\n+ active={splittedPath[1].includes('appointments')}\n+ onClick={() => {\n+ navigateTo('/appointments')\n+ setExpansion('appointment')\n+ }}\nclassName=\"nav-item\"\nstyle={listItemStyle}\n>\n+ <Icon\n+ icon={\n+ splittedPath[1].includes('appointments') && expandedItem === 'appointment'\n+ ? 'down-arrow'\n+ : 'right-arrow'\n+ }\n+ style={expandibleArrow}\n+ />\n<Icon icon=\"appointment\" /> {!sidebarCollapsed && t('scheduling.label')}\n</ListItem>\n+ {splittedPath[1].includes('appointment') && expandedItem === 'appointment' && (\n+ <List layout=\"flush\" className=\"nav flex-column\">\n+ <ListItem\n+ className=\"nav-item\"\n+ style={listSubItemStyleNew}\n+ onClick={() => navigateTo('/appointments/new')}\n+ active={splittedPath[1].includes('appointments') && splittedPath.length > 2}\n+ >\n+ <Icon icon=\"appointment-add\" style={iconMargin} />\n+ {!sidebarCollapsed && t('scheduling.appointments.new')}\n+ </ListItem>\n+ <ListItem\n+ className=\"nav-item\"\n+ style={listSubItemStyle}\n+ onClick={() => navigateTo('/appointments')}\n+ active={splittedPath[1].includes('appointments') && splittedPath.length < 3}\n+ >\n+ <Icon icon=\"incident\" style={iconMargin} />\n+ {!sidebarCollapsed && t('scheduling.appointments.schedule')}\n+ </ListItem>\n+ </List>\n+ )}\n</List>\n</div>\n</nav>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/locales/enUs/translations/patients/index.ts",
"new_path": "src/locales/enUs/translations/patients/index.ts",
"diff": "export default {\npatients: {\nlabel: 'Patients',\n+ patientsList: 'Patients List',\nviewPatients: 'View Patients',\n- editPatient: 'Edit Patient',\nviewPatient: 'View Patient',\nnewPatient: 'New Patient',\nsuccessfullyCreated: 'Successfully created patient',\n- successfullyAddedRelatedPerson: 'Successfully added a new related person',\n+ successfullyAddedRelatedPerson: 'Successfully added the new related person',\n},\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/locales/enUs/translations/scheduling/index.ts",
"new_path": "src/locales/enUs/translations/scheduling/index.ts",
"diff": "@@ -4,9 +4,7 @@ export default {\nappointments: {\nlabel: 'Appointments',\nnew: 'New Appointment',\n- deleteAppointment: 'Delete Appointment',\n- viewAppointment: 'Appointment',\n- editAppointment: 'Edit Appointment',\n+ schedule: 'Appointment Schedule',\n},\nappointment: {\nstartDate: 'Start Date',\n@@ -20,7 +18,6 @@ export default {\nroutine: 'Routine',\nwalkIn: 'Walk In',\n},\n- successfullyCreated: 'Appointment successfully created.',\nerrors: {\npatientRequired: 'Patient is required.',\nerrorCreatingAppointment: 'Error Creating Appointment!',\n@@ -28,8 +25,6 @@ export default {\n},\nreason: 'Reason',\npatient: 'Patient',\n- successfullyDeleted: 'Appointment successfully deleted.',\n- deleteConfirmationMessage: 'Are you sure you want to delete this appointment?',\n},\n},\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat: Added new proposed links to the sidebar (#1956) |
288,323 | 02.04.2020 20:42:19 | 18,000 | b3ddd24b083a8cfda36bf7c207e3480a78948709 | feat(patients): adds tests for new notes modal | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/notes/NewNoteModal.test.tsx",
"new_path": "src/__tests__/patients/notes/NewNoteModal.test.tsx",
"diff": "@@ -2,7 +2,7 @@ import '../../../__mocks__/matchMediaMock'\nimport React from 'react'\nimport NewNoteModal from 'patients/notes/NewNoteModal'\nimport { shallow, mount } from 'enzyme'\n-import { Modal, Label, RichText, TextField } from '@hospitalrun/components'\n+import { Modal, Alert } from '@hospitalrun/components'\nimport { act } from '@testing-library/react'\nimport TextFieldWithLabelFormGroup from 'components/input/TextFieldWithLabelFormGroup'\n@@ -86,18 +86,26 @@ describe('New Note Modal', () => {\n})\n})\n- it('should require a note be added', () => {\n+ it('should require a note be added', async () => {\nconst onSaveSpy = jest.fn()\nconst wrapper = mount(\n<NewNoteModal show onCloseButtonClick={jest.fn()} onSave={onSaveSpy} toggle={jest.fn()} />,\n)\n- act(() => {\n+ await act(async () => {\nconst modal = wrapper.find(Modal)\nconst { onClick } = modal.prop('successButton') as any\n- onClick()\n+ await onClick()\n})\n+ wrapper.update()\n+\n+ const notesTextField = wrapper.find(TextFieldWithLabelFormGroup)\n+ const errorAlert = wrapper.find(Alert)\n+ expect(errorAlert).toHaveLength(1)\n+ expect(errorAlert.prop('title')).toEqual('states.error')\n+ expect(errorAlert.prop('message')).toEqual('patient.notes.error.unableToAdd')\n+ expect(notesTextField.prop('feedback')).toEqual('patient.notes.error.noteRequired')\nexpect(onSaveSpy).not.toHaveBeenCalled()\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/components/input/TextFieldWithLabelFormGroup.tsx",
"new_path": "src/components/input/TextFieldWithLabelFormGroup.tsx",
"diff": "@@ -8,16 +8,25 @@ interface Props {\nisEditable?: boolean\nplaceholder?: string\nonChange?: (event: React.ChangeEvent<HTMLTextAreaElement>) => void\n- isRequired: boolean\n+ isRequired?: boolean\n+ feedback?: string\n+ isInvalid?: boolean\n}\nconst TextFieldWithLabelFormGroup = (props: Props) => {\n- const { value, label, name, isEditable, onChange } = props\n+ const { value, label, name, isEditable, isInvalid, feedback, onChange } = props\nconst id = `${name}TextField`\nreturn (\n<div className=\"form-group\">\n<Label text={label} htmlFor={id} isRequired />\n- <TextField rows={4} value={value} disabled={!isEditable} onChange={onChange} />\n+ <TextField\n+ rows={4}\n+ value={value}\n+ disabled={!isEditable}\n+ onChange={onChange}\n+ isInvalid={isInvalid}\n+ feedback={feedback}\n+ />\n</div>\n)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/locales/enUs/translations/patient/index.ts",
"new_path": "src/locales/enUs/translations/patient/index.ts",
"diff": "@@ -69,12 +69,13 @@ export default {\nnote: 'Note',\nnotes: {\nlabel: 'Notes',\n- new: 'New Note',\n+ new: 'Add New Note',\nwarning: {\nnoNotes: 'No Notes',\n},\nerror: {\nnoteRequired: 'Note is required.',\n+ unableToAdd: 'Unable to add new note.',\n},\naddNoteAbove: 'Add a note using the button above.',\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/notes/NewNoteModal.tsx",
"new_path": "src/patients/notes/NewNoteModal.tsx",
"diff": "import React, { useState } from 'react'\n-import { Modal, Alert, RichText, Label } from '@hospitalrun/components'\n+import { Modal, Alert } from '@hospitalrun/components'\nimport { useTranslation } from 'react-i18next'\nimport TextFieldWithLabelFormGroup from 'components/input/TextFieldWithLabelFormGroup'\nimport Note from '../../model/Note'\n@@ -14,7 +14,8 @@ interface Props {\nconst NewNoteModal = (props: Props) => {\nconst { show, toggle, onCloseButtonClick, onSave } = props\nconst { t } = useTranslation()\n- const [errorMessage, setErrorMessage] = useState('')\n+ const [isNoteInvalid, setIsNoteInvalid] = useState(false)\n+ const [noteFeedback, setNoteFeedback] = useState()\nconst [note, setNote] = useState({\ndate: new Date(Date.now().valueOf()).toISOString(),\ntext: '',\n@@ -33,30 +34,35 @@ const NewNoteModal = (props: Props) => {\n}\nconst onSaveButtonClick = () => {\n- let newErrorMessage = ''\n-\n- if (!note) {\n- newErrorMessage += `${t('patient.notes.error.noteRequired')} `\n+ if (!note.text) {\n+ setIsNoteInvalid(true)\n+ setNoteFeedback(t('patient.notes.error.noteRequired'))\n+ return\n}\n- if (!newErrorMessage) {\nonSave(note as Note)\n- } else {\n- setErrorMessage(newErrorMessage.trim())\n- }\n}\nconst body = (\n<form>\n- {errorMessage && <Alert color=\"danger\" title={t('states.error')} message={errorMessage} />}\n+ {isNoteInvalid && (\n+ <Alert\n+ color=\"danger\"\n+ title={t('states.error')}\n+ message={t('patient.notes.error.unableToAdd')}\n+ />\n+ )}\n<div className=\"row\">\n<div className=\"col-md-12\">\n<div className=\"form-group\">\n<TextFieldWithLabelFormGroup\n+ isEditable\nisRequired\nname=\"noteTextField\"\nlabel={t('patient.note')}\nvalue={note.text}\n+ isInvalid={isNoteInvalid}\n+ feedback={noteFeedback}\nonChange={onNoteTextChange}\n/>\n</div>\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(patients): adds tests for new notes modal |
288,323 | 02.04.2020 20:58:23 | 18,000 | 6edc0ad3ba352c92c8d85ec58148fedb9fc57a98 | feat(patient): add notes tab tests | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/patients/notes/NotesTab.test.tsx",
"diff": "+import '../../../__mocks__/matchMediaMock'\n+import React from 'react'\n+import PatientRepository from 'clients/db/PatientRepository'\n+import Note from 'model/Note'\n+import { createMemoryHistory } from 'history'\n+import configureMockStore from 'redux-mock-store'\n+import Patient from 'model/Patient'\n+import thunk from 'redux-thunk'\n+import { mount } from 'enzyme'\n+import { Router } from 'react-router'\n+import { Provider } from 'react-redux'\n+import NoteTab from 'patients/notes/NoteTab'\n+import * as components from '@hospitalrun/components'\n+import { act } from 'react-dom/test-utils'\n+import { mocked } from 'ts-jest/utils'\n+import NewNoteModal from 'patients/notes/NewNoteModal'\n+import Permissions from '../../../model/Permissions'\n+import * as patientSlice from '../../../patients/patient-slice'\n+\n+const expectedPatient = {\n+ id: '123',\n+ notes: [{ date: new Date().toISOString(), text: 'notes1' } as Note],\n+} as Patient\n+\n+const mockStore = configureMockStore([thunk])\n+const history = createMemoryHistory()\n+\n+let user: any\n+let store: any\n+\n+const setup = (patient = expectedPatient, permissions = [Permissions.WritePatients]) => {\n+ user = { permissions }\n+ store = mockStore({ patient, user })\n+ const wrapper = mount(\n+ <Router history={history}>\n+ <Provider store={store}>\n+ <NoteTab patient={patient} />\n+ </Provider>\n+ </Router>,\n+ )\n+\n+ return wrapper\n+}\n+\n+describe('Notes Tab', () => {\n+ describe('Add New Note', () => {\n+ beforeEach(() => {\n+ jest.resetAllMocks()\n+ jest.spyOn(PatientRepository, 'saveOrUpdate')\n+ })\n+\n+ it('should render a add notes button', () => {\n+ const wrapper = setup()\n+\n+ const addNoteButton = wrapper.find(components.Button)\n+ expect(addNoteButton).toHaveLength(1)\n+ expect(addNoteButton.text().trim()).toEqual('patient.notes.new')\n+ })\n+\n+ it('should not render a add notes button if the user does not have permissions', () => {\n+ const wrapper = setup(expectedPatient, [])\n+\n+ const addNotesButton = wrapper.find(components.Button)\n+ expect(addNotesButton).toHaveLength(0)\n+ })\n+\n+ it('should open the Add Notes Modal', () => {\n+ const wrapper = setup()\n+\n+ act(() => {\n+ const onClick = wrapper.find(components.Button).prop('onClick') as any\n+ onClick()\n+ })\n+ wrapper.update()\n+\n+ expect(wrapper.find(components.Modal).prop('show')).toBeTruthy()\n+ })\n+\n+ it('should update the patient with the new diagnosis when the save button is clicked', async () => {\n+ const expectedNote = {\n+ text: 'note text',\n+ date: new Date().toISOString(),\n+ } as Note\n+ const expectedUpdatedPatient = {\n+ ...expectedPatient,\n+ notes: [...(expectedPatient.notes as any), expectedNote],\n+ } as Patient\n+\n+ const mockedPatientRepository = mocked(PatientRepository, true)\n+ mockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedUpdatedPatient)\n+\n+ const wrapper = setup()\n+\n+ await act(async () => {\n+ const modal = wrapper.find(NewNoteModal)\n+ await modal.prop('onSave')(expectedNote)\n+ })\n+\n+ expect(mockedPatientRepository.saveOrUpdate).toHaveBeenCalledWith(expectedUpdatedPatient)\n+ expect(store.getActions()).toContainEqual(patientSlice.updatePatientStart())\n+ expect(store.getActions()).toContainEqual(\n+ patientSlice.updatePatientSuccess(expectedUpdatedPatient),\n+ )\n+ })\n+ })\n+\n+ describe('notes list', () => {\n+ it('should list the patients diagnoses', () => {\n+ const notes = expectedPatient.notes as Note[]\n+ const wrapper = setup()\n+\n+ const list = wrapper.find(components.List)\n+ const listItems = wrapper.find(components.ListItem)\n+\n+ expect(list).toHaveLength(1)\n+ expect(listItems).toHaveLength(notes.length)\n+ })\n+\n+ it('should render a warning message if the patient does not have any diagnoses', () => {\n+ const wrapper = setup({ ...expectedPatient, notes: [] })\n+\n+ const alert = wrapper.find(components.Alert)\n+\n+ expect(alert).toHaveLength(1)\n+ expect(alert.prop('title')).toEqual('patient.notes.warning.noNotes')\n+ expect(alert.prop('message')).toEqual('patient.notes.addNoteAbove')\n+ })\n+ })\n+})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/notes/NoteTab.tsx",
"new_path": "src/patients/notes/NoteTab.tsx",
"diff": "@@ -76,10 +76,10 @@ const NoteTab = (props: Props) => {\n/>\n)}\n<List>\n- {patient.notes?.map((a: Note) => (\n- <ListItem>\n- {new Date(a.date).toLocaleString()}\n- <div dangerouslySetInnerHTML={{ __html: a.text }} />\n+ {patient.notes?.map((note: Note) => (\n+ <ListItem key={note.date}>\n+ {new Date(note.date).toLocaleString()}\n+ <p>{note.text}</p>\n</ListItem>\n))}\n</List>\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(patient): add notes tab tests |
288,323 | 02.04.2020 22:07:25 | 18,000 | 2f15ea9ba17290b8c8076e4e4999c836748be158 | style(sidebar): fixes lint errors in test file | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/components/Sidebar.test.tsx",
"new_path": "src/__tests__/components/Sidebar.test.tsx",
"diff": "@@ -35,7 +35,12 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\n- expect(listItems.at(1).text().trim()).toEqual('dashboard.label')\n+ expect(\n+ listItems\n+ .at(1)\n+ .text()\n+ .trim(),\n+ ).toEqual('dashboard.label')\n})\nit('should be active when the current path is /', () => {\n@@ -52,7 +57,8 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\nact(() => {\n- ;(listItems.at(1).prop('onClick') as any)()\n+ const onClick = listItems.at(1).prop('onClick') as any\n+ onClick()\n})\nexpect(history.location.pathname).toEqual('/')\n@@ -65,7 +71,12 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\n- expect(listItems.at(2).text().trim()).toEqual('patients.label')\n+ expect(\n+ listItems\n+ .at(2)\n+ .text()\n+ .trim(),\n+ ).toEqual('patients.label')\n})\nit('should be active when the current path is /', () => {\n@@ -82,7 +93,8 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\nact(() => {\n- ;(listItems.at(2).prop('onClick') as any)()\n+ const onClick = listItems.at(2).prop('onClick') as any\n+ onClick()\n})\nexpect(history.location.pathname).toEqual('/patients')\n@@ -95,7 +107,12 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\n- expect(listItems.at(4).text().trim()).toEqual('patients.patientsList')\n+ expect(\n+ listItems\n+ .at(4)\n+ .text()\n+ .trim(),\n+ ).toEqual('patients.patientsList')\n})\nit('should be active when the current path is /patients', () => {\n@@ -112,7 +129,8 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\nact(() => {\n- ;(listItems.at(4).prop('onClick') as any)()\n+ const onClick = listItems.at(4).prop('onClick') as any\n+ onClick()\n})\nexpect(history.location.pathname).toEqual('/patients')\n@@ -125,7 +143,12 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\n- expect(listItems.at(3).text().trim()).toEqual('patients.newPatient')\n+ expect(\n+ listItems\n+ .at(3)\n+ .text()\n+ .trim(),\n+ ).toEqual('patients.newPatient')\n})\nit('should be active when the current path is /patients/new', () => {\n@@ -155,7 +178,12 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\n- expect(listItems.at(3).text().trim()).toEqual('scheduling.label')\n+ expect(\n+ listItems\n+ .at(3)\n+ .text()\n+ .trim(),\n+ ).toEqual('scheduling.label')\n})\nit('should be active when the current path is /appointments', () => {\n@@ -172,7 +200,8 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\nact(() => {\n- ;(listItems.at(3).prop('onClick') as any)()\n+ const onClick = listItems.at(3).prop('onClick') as any\n+ onClick()\n})\nexpect(history.location.pathname).toEqual('/appointments')\n@@ -185,7 +214,12 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\n- expect(listItems.at(5).text().trim()).toEqual('scheduling.appointments.schedule')\n+ expect(\n+ listItems\n+ .at(5)\n+ .text()\n+ .trim(),\n+ ).toEqual('scheduling.appointments.schedule')\n})\nit('should be active when the current path is /appointments', () => {\n@@ -202,7 +236,8 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\nact(() => {\n- ;(listItems.at(5).prop('onClick') as any)()\n+ const onClick = listItems.at(5).prop('onClick') as any\n+ onClick()\n})\nexpect(history.location.pathname).toEqual('/appointments')\n@@ -215,7 +250,12 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\n- expect(listItems.at(4).text().trim()).toEqual('scheduling.appointments.new')\n+ expect(\n+ listItems\n+ .at(4)\n+ .text()\n+ .trim(),\n+ ).toEqual('scheduling.appointments.new')\n})\nit('should be active when the current path is /appointments/new', () => {\n@@ -232,7 +272,8 @@ describe('Sidebar', () => {\nconst listItems = wrapper.find(ListItem)\nact(() => {\n- ;(listItems.at(4).prop('onClick') as any)()\n+ const onClick = listItems.at(4).prop('onClick') as any\n+ onClick()\n})\nexpect(history.location.pathname).toEqual('/appointments/new')\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | style(sidebar): fixes lint errors in test file |
288,323 | 02.04.2020 23:07:43 | 18,000 | 23bbb1bd637e443ba28d688432c741939c67c309 | style(navbar): fix lint errors in navbar test | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/components/Navbar.test.tsx",
"new_path": "src/__tests__/components/Navbar.test.tsx",
"diff": "@@ -30,7 +30,10 @@ describe('Navbar', () => {\n})\nit('should navigate to / when the header is clicked', () => {\nact(() => {\n- header.first().props().onClick()\n+ header\n+ .first()\n+ .props()\n+ .onClick()\n})\nexpect(history.location.pathname).toEqual('/')\n})\n@@ -45,13 +48,19 @@ describe('Navbar', () => {\n})\nit('should navigate to /patients when the list option is selected', () => {\nact(() => {\n- patientsLinkList.first().props().children[0].props.onClick()\n+ patientsLinkList\n+ .first()\n+ .props()\n+ .children[0].props.onClick()\n})\nexpect(history.location.pathname).toEqual('/patients')\n})\nit('should navigate to /patients/new when the list option is selected', () => {\nact(() => {\n- patientsLinkList.first().props().children[1].props.onClick()\n+ patientsLinkList\n+ .first()\n+ .props()\n+ .children[1].props.onClick()\n})\nexpect(history.location.pathname).toEqual('/patients/new')\n})\n@@ -72,14 +81,20 @@ describe('Navbar', () => {\nit('should navigate to to /appointments when the appointment list option is selected', () => {\nact(() => {\n- scheduleLinkList.first().props().children[0].props.onClick()\n+ scheduleLinkList\n+ .first()\n+ .props()\n+ .children[0].props.onClick()\n})\nexpect(history.location.pathname).toEqual('/appointments')\n})\nit('should navigate to /appointments/new when the new appointment list option is selected', () => {\nact(() => {\n- scheduleLinkList.first().props().children[1].props.onClick()\n+ scheduleLinkList\n+ .first()\n+ .props()\n+ .children[1].props.onClick()\n})\nexpect(history.location.pathname).toEqual('/appointments/new')\n})\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | style(navbar): fix lint errors in navbar test |
288,323 | 28.03.2020 21:24:23 | 18,000 | a9c4100f4d70c71d41b890d1bad0fe761fea6ee2 | feat(labs): adds labs route | [
{
"change_type": "MODIFY",
"old_path": "src/HospitalRun.tsx",
"new_path": "src/HospitalRun.tsx",
"diff": "@@ -9,6 +9,7 @@ import ViewAppointment from 'scheduling/appointments/view/ViewAppointment'\nimport Breadcrumbs from 'breadcrumbs/Breadcrumbs'\nimport { ButtonBarProvider } from 'page-header/ButtonBarProvider'\nimport ButtonToolBar from 'page-header/ButtonToolBar'\n+import Labs from 'labs/Labs'\nimport Sidebar from './components/Sidebar'\nimport Permissions from './model/Permissions'\nimport Dashboard from './dashboard/Dashboard'\n@@ -99,6 +100,7 @@ const HospitalRun = () => {\npath=\"/appointments/:id\"\ncomponent={ViewAppointment}\n/>\n+ <PrivateRoute isAuthenticated exact path=\"/labs\" component={Labs} />\n</Switch>\n</div>\n<Toaster autoClose={5000} hideProgressBar draggable />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/components/Sidebar.tsx",
"new_path": "src/components/Sidebar.tsx",
"diff": "@@ -164,29 +164,15 @@ const Sidebar = () => {\n/>\n<Icon icon=\"appointment\" /> {!sidebarCollapsed && t('scheduling.label')}\n</ListItem>\n- {splittedPath[1].includes('appointment') && expandedItem === 'appointment' && (\n- <List layout=\"flush\" className=\"nav flex-column\">\n- <ListItem\n- className=\"nav-item\"\n- style={listSubItemStyleNew}\n- onClick={() => navigateTo('/appointments/new')}\n- active={splittedPath[1].includes('appointments') && splittedPath.length > 2}\n- >\n- <Icon icon=\"appointment-add\" style={iconMargin} />\n- {!sidebarCollapsed && t('scheduling.appointments.new')}\n- </ListItem>\n<ListItem\n+ active={pathname.split('/')[1].includes('labs')}\n+ onClick={() => navigateTo('/labs')}\nclassName=\"nav-item\"\n- style={listSubItemStyle}\n- onClick={() => navigateTo('/appointments')}\n- active={splittedPath[1].includes('appointments') && splittedPath.length < 3}\n+ style={listItemStyle}\n>\n- <Icon icon=\"incident\" style={iconMargin} />\n- {!sidebarCollapsed && t('scheduling.appointments.schedule')}\n+ <Icon icon=\"lab\" /> {!sidebarCollapsed && t('labs.label')}\n</ListItem>\n</List>\n- )}\n- </List>\n</div>\n</nav>\n)\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/labs/Labs.tsx",
"diff": "+import React from 'react'\n+import PrivateRoute from 'components/PrivateRoute'\n+import { Switch } from 'react-router'\n+import LabRequests from './requests/LabRequests'\n+\n+const Labs = () => (\n+ <Switch>\n+ <PrivateRoute isAuthenticated exact path=\"/labs\" component={LabRequests} />\n+ </Switch>\n+)\n+\n+export default Labs\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/labs/requests/LabRequests.tsx",
"diff": "+import React from 'react'\n+import useTitle from 'page-header/useTitle'\n+import { useTranslation } from 'react-i18next'\n+\n+const LabRequests = () => {\n+ const { t } = useTranslation()\n+ useTitle(t('labs.requests.label'))\n+\n+ return <h1>Lab Requests</h1>\n+}\n+\n+export default LabRequests\n"
},
{
"change_type": "MODIFY",
"old_path": "src/locales/enUs/translations/index.ts",
"new_path": "src/locales/enUs/translations/index.ts",
"diff": "@@ -5,6 +5,7 @@ import patients from './patients'\nimport scheduling from './scheduling'\nimport states from './states'\nimport sex from './sex'\n+import labs from './labs'\nexport default {\n...actions,\n@@ -14,4 +15,5 @@ export default {\n...scheduling,\n...states,\n...sex,\n+ ...labs,\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/locales/enUs/translations/labs/index.ts",
"diff": "+export default {\n+ labs: {\n+ label: 'Labs',\n+ requests: {\n+ label: 'Lab Requests',\n+ },\n+ },\n+}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(labs): adds labs route |
288,323 | 30.03.2020 00:55:07 | 18,000 | efba8349df7c99f5e49ce46d03b26d29e73c2955 | feat(labs): adds ability to request and view labs | [
{
"change_type": "MODIFY",
"old_path": "src/HospitalRun.tsx",
"new_path": "src/HospitalRun.tsx",
"diff": "@@ -100,7 +100,7 @@ const HospitalRun = () => {\npath=\"/appointments/:id\"\ncomponent={ViewAppointment}\n/>\n- <PrivateRoute isAuthenticated exact path=\"/labs\" component={Labs} />\n+ <PrivateRoute isAuthenticated path=\"/labs\" component={Labs} />\n</Switch>\n</div>\n<Toaster autoClose={5000} hideProgressBar draggable />\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/clients/db/LabRepository.ts",
"diff": "+import Lab from 'model/Lab'\n+import Repository from './Repository'\n+import { labs } from '../../config/pouchdb'\n+\n+export class LabRepository extends Repository<Lab> {\n+ constructor() {\n+ super(labs)\n+ }\n+}\n+\n+export default new LabRepository()\n"
},
{
"change_type": "MODIFY",
"old_path": "src/components/Navbar.tsx",
"new_path": "src/components/Navbar.tsx",
"diff": "@@ -70,6 +70,27 @@ const Navbar = () => {\n},\n],\n},\n+ {\n+ type: 'link-list',\n+ label: t('labs.label'),\n+ className: 'labs-link-list',\n+ children: [\n+ {\n+ type: 'link',\n+ label: t('labs.label'),\n+ onClick: () => {\n+ history.push('/labs')\n+ },\n+ },\n+ {\n+ type: 'link',\n+ label: t('labs.requests.new'),\n+ onClick: () => {\n+ history.push('/labs/new')\n+ },\n+ },\n+ ],\n+ },\n{\ntype: 'search',\nplaceholderText: t('actions.search'),\n"
},
{
"change_type": "MODIFY",
"old_path": "src/config/pouchdb.ts",
"new_path": "src/config/pouchdb.ts",
"diff": "@@ -28,3 +28,4 @@ function createDb(name: string) {\nexport const patients = createDb('patients')\nexport const appointments = createDb('appointments')\n+export const labs = createDb('labs')\n"
},
{
"change_type": "MODIFY",
"old_path": "src/labs/Labs.tsx",
"new_path": "src/labs/Labs.tsx",
"diff": "import React from 'react'\nimport PrivateRoute from 'components/PrivateRoute'\nimport { Switch } from 'react-router'\n-import LabRequests from './requests/LabRequests'\n+import useAddBreadcrumbs from 'breadcrumbs/useAddBreadcrumbs'\n+import { useSelector } from 'react-redux'\n+import Permissions from 'model/Permissions'\n+import LabRequests from './ViewLabs'\n+import NewLabRequest from './requests/NewLabRequest'\n+import ViewLab from './ViewLab'\n+import { RootState } from '../store'\n-const Labs = () => (\n+const Labs = () => {\n+ const { permissions } = useSelector((state: RootState) => state.user)\n+ const breadcrumbs = [\n+ {\n+ i18nKey: 'labs.label',\n+ location: `/labs`,\n+ },\n+ ]\n+ useAddBreadcrumbs(breadcrumbs, true)\n+\n+ return (\n<Switch>\n- <PrivateRoute isAuthenticated exact path=\"/labs\" component={LabRequests} />\n+ <PrivateRoute\n+ isAuthenticated={permissions.includes(Permissions.ViewLabs)}\n+ exact\n+ path=\"/labs\"\n+ component={LabRequests}\n+ />\n+ <PrivateRoute\n+ isAuthenticated={permissions.includes(Permissions.RequestLab)}\n+ exact\n+ path=\"/labs/new\"\n+ component={NewLabRequest}\n+ />\n+ <PrivateRoute\n+ isAuthenticated={permissions.includes(Permissions.ViewLab)}\n+ exact\n+ path=\"/labs/:id\"\n+ component={ViewLab}\n+ />\n</Switch>\n)\n+}\nexport default Labs\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/labs/ViewLab.tsx",
"diff": "+import React, { useEffect, useState } from 'react'\n+import { useParams, useHistory } from 'react-router'\n+import format from 'date-fns/format'\n+import LabRepository from 'clients/db/LabRepository'\n+import Lab from 'model/Lab'\n+import Patient from 'model/Patient'\n+import PatientRepository from 'clients/db/PatientRepository'\n+import useTitle from 'page-header/useTitle'\n+import { useTranslation } from 'react-i18next'\n+import { Row, Column, Badge, Button, Alert } from '@hospitalrun/components'\n+import TextFieldWithLabelFormGroup from 'components/input/TextFieldWithLabelFormGroup'\n+import { useButtonToolbarSetter } from 'page-header/ButtonBarProvider'\n+import useAddBreadcrumbs from 'breadcrumbs/useAddBreadcrumbs'\n+import { useSelector } from 'react-redux'\n+import Permissions from 'model/Permissions'\n+import { RootState } from '../store'\n+\n+const getTitle = (patient: Patient | undefined, lab: Lab | undefined) =>\n+ patient && lab ? `${lab.type} for ${patient.fullName}` : ''\n+\n+const ViewLab = () => {\n+ const { id } = useParams()\n+ const { t } = useTranslation()\n+ const history = useHistory()\n+ const setButtons = useButtonToolbarSetter()\n+\n+ const { permissions } = useSelector((state: RootState) => state.user)\n+ const [patient, setPatient] = useState<Patient | undefined>()\n+ const [lab, setLab] = useState<Lab | undefined>()\n+ const [isEditable, setIsEditable] = useState<boolean>(true)\n+ const [isResultInvalid, setIsResultInvalid] = useState<boolean>(false)\n+ const [resultFeedback, setResultFeedback] = useState()\n+ const [errorMessage, setErrorMessage] = useState()\n+\n+ useTitle(getTitle(patient, lab))\n+\n+ const breadcrumbs = [\n+ {\n+ i18nKey: 'labs.requests.view',\n+ location: `/labs/${lab?.id}`,\n+ },\n+ ]\n+ useAddBreadcrumbs(breadcrumbs)\n+\n+ useEffect(() => {\n+ const fetchLab = async () => {\n+ if (id) {\n+ const fetchedLab = await LabRepository.find(id)\n+ setLab(fetchedLab)\n+ setIsEditable(fetchedLab.status === 'requested')\n+ }\n+ }\n+ fetchLab()\n+ }, [id])\n+\n+ useEffect(() => {\n+ const fetchPatient = async () => {\n+ if (lab) {\n+ const fetchedPatient = await PatientRepository.find(lab.patientId)\n+ setPatient(fetchedPatient)\n+ }\n+ }\n+\n+ fetchPatient()\n+ }, [lab])\n+\n+ const onResultChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n+ const result = event.currentTarget.value\n+ const newLab = lab as Lab\n+ setLab({ ...newLab, result })\n+ }\n+\n+ const onNotesChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n+ const notes = event.currentTarget.value\n+ const newLab = lab as Lab\n+ setLab({ ...newLab, notes })\n+ }\n+\n+ const onUpdate = async () => {\n+ await LabRepository.saveOrUpdate(lab as Lab)\n+ history.push('/labs')\n+ }\n+\n+ const onComplete = async () => {\n+ const newLab = lab as Lab\n+\n+ if (!newLab.result) {\n+ setIsResultInvalid(true)\n+ setResultFeedback(t('labs.requests.error.resultRequiredToComplete'))\n+ setErrorMessage(t('labs.requests.error.unableToComplete'))\n+ return\n+ }\n+\n+ await LabRepository.saveOrUpdate({\n+ ...newLab,\n+ completedOn: new Date().toISOString(),\n+ status: 'completed',\n+ })\n+ history.push('/labs')\n+ }\n+\n+ const onCancel = async () => {\n+ const newLab = lab as Lab\n+ await LabRepository.saveOrUpdate({\n+ ...newLab,\n+ canceledOn: new Date().toISOString(),\n+ status: 'canceled',\n+ })\n+ history.push('/labs')\n+ }\n+\n+ const getButtons = () => {\n+ const buttons: React.ReactNode[] = []\n+ if (lab?.status === 'completed' || lab?.status === 'canceled') {\n+ return buttons\n+ }\n+\n+ if (permissions.includes(Permissions.CompleteLab)) {\n+ buttons.push(\n+ <Button onClick={onComplete} color=\"primary\">\n+ {t('labs.requests.complete')}\n+ </Button>,\n+ )\n+ }\n+\n+ if (permissions.includes(Permissions.CancelLab)) {\n+ buttons.push(\n+ <Button onClick={onCancel} color=\"danger\">\n+ {t('labs.requests.cancel')}\n+ </Button>,\n+ )\n+ }\n+\n+ return buttons\n+ }\n+\n+ setButtons(getButtons())\n+\n+ if (lab && patient) {\n+ const getBadgeColor = () => {\n+ if (lab.status === 'completed') {\n+ return 'primary'\n+ }\n+ if (lab.status === 'canceled') {\n+ return 'danger'\n+ }\n+ return 'warning'\n+ }\n+\n+ const getCanceledOnOrCompletedOnDate = () => {\n+ if (lab.status === 'completed') {\n+ return (\n+ <Column>\n+ <div className=\"form-group\">\n+ <h4>{t('labs.lab.completedOn')}</h4>\n+ <h5>{format(new Date(lab.completedOn), 'yyyy-MM-dd hh:mm a')}</h5>\n+ </div>\n+ </Column>\n+ )\n+ }\n+ if (lab.status === 'canceled') {\n+ return (\n+ <Column>\n+ <div className=\"form-group\">\n+ <h4>{t('labs.lab.canceledOn')}</h4>\n+ <h5>{format(new Date(lab.completedOn), 'yyyy-MM-dd hh:mm a')}</h5>\n+ </div>\n+ </Column>\n+ )\n+ }\n+ return <></>\n+ }\n+\n+ return (\n+ <>\n+ {isResultInvalid && (\n+ <Alert color=\"danger\" title={t('states.error')} message={errorMessage} />\n+ )}\n+ <Row>\n+ <Column>\n+ <div className=\"form-group\">\n+ <h4>{t('labs.lab.status')}</h4>\n+ <Badge color={getBadgeColor()}>\n+ <h5>{lab.status}</h5>\n+ </Badge>\n+ </div>\n+ </Column>\n+ <Column>\n+ <div className=\"form-group\">\n+ <h4>{t('labs.lab.for')}</h4>\n+ <h5>{patient.fullName}</h5>\n+ </div>\n+ </Column>\n+ <Column>\n+ <div className=\"form-group\">\n+ <h4>{t('labs.lab.type')}</h4>\n+ <h5>{lab.type}</h5>\n+ </div>\n+ </Column>\n+ <Column>\n+ <div className=\"form-group\">\n+ <h4>{t('labs.lab.requestedOn')}</h4>\n+ <h5>{format(new Date(lab.requestedOn), 'yyyy/mm/dd hh:mm a')}</h5>\n+ </div>\n+ </Column>\n+ {getCanceledOnOrCompletedOnDate()}\n+ </Row>\n+ <div className=\"border-bottom\" />\n+ <form>\n+ <TextFieldWithLabelFormGroup\n+ name=\"result\"\n+ label={t('labs.lab.result')}\n+ isEditable={isEditable}\n+ isInvalid={isResultInvalid}\n+ feedback={resultFeedback}\n+ onChange={onResultChange}\n+ />\n+ <TextFieldWithLabelFormGroup\n+ name=\"notes\"\n+ label={t('labs.lab.notes')}\n+ value={lab.notes}\n+ isEditable={isEditable}\n+ onChange={onNotesChange}\n+ />\n+ {isEditable && (\n+ <div className=\"row float-right\">\n+ <div className=\"btn-group btn-group-lg mt-3\">\n+ <Button className=\"mr-2\" color=\"success\" onClick={onUpdate}>\n+ {t('actions.update')}\n+ </Button>\n+ </div>\n+ </div>\n+ )}\n+ </form>\n+ </>\n+ )\n+ }\n+ return <h1>Loading...</h1>\n+}\n+\n+export default ViewLab\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/labs/ViewLabs.tsx",
"diff": "+import React, { useState, useEffect } from 'react'\n+import useTitle from 'page-header/useTitle'\n+import { useTranslation } from 'react-i18next'\n+import format from 'date-fns/format'\n+import { useButtonToolbarSetter } from 'page-header/ButtonBarProvider'\n+import { Button } from '@hospitalrun/components'\n+import { useHistory } from 'react-router'\n+import LabRepository from 'clients/db/LabRepository'\n+import Lab from 'model/Lab'\n+import { useSelector } from 'react-redux'\n+import Permissions from 'model/Permissions'\n+import { RootState } from '../store'\n+\n+const ViewLabs = () => {\n+ const { t } = useTranslation()\n+ const history = useHistory()\n+ const setButtons = useButtonToolbarSetter()\n+ useTitle(t('labs.label'))\n+\n+ const { permissions } = useSelector((state: RootState) => state.user)\n+ const [labs, setLabs] = useState<Lab[]>([])\n+\n+ const getButtons = () => {\n+ const buttons: React.ReactNode[] = []\n+\n+ if (permissions.includes(Permissions.RequestLab)) {\n+ buttons.push(\n+ <Button icon=\"add\" onClick={() => history.push('/labs/new')}>\n+ {t('labs.requests.new')}\n+ </Button>,\n+ )\n+ }\n+\n+ return buttons\n+ }\n+\n+ setButtons([getButtons()])\n+\n+ useEffect(() => {\n+ const fetch = async () => {\n+ const fetchedLabs = await LabRepository.findAll()\n+ setLabs(fetchedLabs)\n+ }\n+\n+ fetch()\n+ }, [])\n+\n+ const onTableRowClick = (lab: Lab) => {\n+ history.push(`/labs/${lab.id}`)\n+ }\n+\n+ return (\n+ <>\n+ <table className=\"table table-hover\">\n+ <thead className=\"thead-light\">\n+ <tr>\n+ <th>Lab Type</th>\n+ <th>Requested On</th>\n+ <th>Status</th>\n+ </tr>\n+ </thead>\n+ <tbody>\n+ {labs.map((lab) => (\n+ <tr onClick={() => onTableRowClick(lab)}>\n+ <td>{lab.type}</td>\n+ <td>{format(new Date(lab.requestedOn), 'yyyy-MM-dd hh:mm a')}</td>\n+ <td>{lab.status}</td>\n+ </tr>\n+ ))}\n+ </tbody>\n+ </table>\n+ </>\n+ )\n+}\n+\n+export default ViewLabs\n"
},
{
"change_type": "DELETE",
"old_path": "src/labs/requests/LabRequests.tsx",
"new_path": null,
"diff": "-import React from 'react'\n-import useTitle from 'page-header/useTitle'\n-import { useTranslation } from 'react-i18next'\n-\n-const LabRequests = () => {\n- const { t } = useTranslation()\n- useTitle(t('labs.requests.label'))\n-\n- return <h1>Lab Requests</h1>\n-}\n-\n-export default LabRequests\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/labs/requests/NewLabRequest.tsx",
"diff": "+import React, { useState } from 'react'\n+import useTitle from 'page-header/useTitle'\n+import { useTranslation } from 'react-i18next'\n+import { Typeahead, Label, Button, Alert } from '@hospitalrun/components'\n+import PatientRepository from 'clients/db/PatientRepository'\n+import Patient from 'model/Patient'\n+import TextInputWithLabelFormGroup from 'components/input/TextInputWithLabelFormGroup'\n+import { useHistory } from 'react-router'\n+import LabRepository from 'clients/db/LabRepository'\n+import Lab from 'model/Lab'\n+import TextFieldWithLabelFormGroup from 'components/input/TextFieldWithLabelFormGroup'\n+import useAddBreadcrumbs from 'breadcrumbs/useAddBreadcrumbs'\n+\n+const NewLabRequest = () => {\n+ const { t } = useTranslation()\n+ const history = useHistory()\n+ useTitle(t('labs.requests.new'))\n+\n+ const [isPatientInvalid, setIsPatientInvalid] = useState(false)\n+ const [isTypeInvalid, setIsTypeInvalid] = useState(false)\n+ const [typeFeedback, setTypeFeedback] = useState()\n+\n+ const [newLabRequest, setNewLabRequest] = useState({\n+ patientId: '',\n+ type: '',\n+ notes: '',\n+ status: 'requested',\n+ })\n+\n+ const breadcrumbs = [\n+ {\n+ i18nKey: 'labs.requests.new',\n+ location: `/labs/new`,\n+ },\n+ ]\n+ useAddBreadcrumbs(breadcrumbs)\n+\n+ const onPatientChange = (patient: Patient) => {\n+ setNewLabRequest((previousNewLabRequest) => ({\n+ ...previousNewLabRequest,\n+ patientId: patient.id,\n+ }))\n+ }\n+\n+ const onLabTypeChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n+ const type = event.currentTarget.value\n+ setNewLabRequest((previousNewLabRequest) => ({\n+ ...previousNewLabRequest,\n+ type,\n+ }))\n+ }\n+\n+ const onNoteChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n+ const notes = event.currentTarget.value\n+ setNewLabRequest((previousNewLabRequest) => ({\n+ ...previousNewLabRequest,\n+ notes,\n+ }))\n+ }\n+\n+ const onSave = async () => {\n+ const newLab = newLabRequest as Lab\n+\n+ if (!newLab.patientId) {\n+ setIsPatientInvalid(true)\n+ }\n+\n+ if (!newLab.type) {\n+ setIsTypeInvalid(true)\n+ setTypeFeedback(t('labs.requests.error.typeRequired'))\n+ return\n+ }\n+\n+ newLab.requestedOn = new Date().toISOString()\n+ const createdLab = await LabRepository.save(newLab)\n+ history.push(`/labs/${createdLab.id}`)\n+ }\n+ const onCancel = () => {\n+ history.push('/labs')\n+ }\n+\n+ return (\n+ <>\n+ {(isTypeInvalid || isPatientInvalid) && (\n+ <Alert\n+ color=\"danger\"\n+ title={t('states.error')}\n+ message={t('labs.requests.error.unableToRequest')}\n+ />\n+ )}\n+ <form>\n+ <div className=\"form-group\">\n+ <Label htmlFor=\"patientTypeahead\" isRequired text={t('scheduling.appointment.patient')} />\n+ <Typeahead\n+ id=\"patientTypeahead\"\n+ placeholder={t('scheduling.appointment.patient')}\n+ onChange={(p: Patient[]) => onPatientChange(p[0])}\n+ onSearch={async (query: string) => PatientRepository.search(query)}\n+ searchAccessor=\"fullName\"\n+ renderMenuItemChildren={(p: Patient) => <div>{`${p.fullName} (${p.code})`}</div>}\n+ />\n+ </div>\n+ <TextInputWithLabelFormGroup\n+ name=\"labType\"\n+ label={t('labs.lab.type')}\n+ isRequired\n+ isEditable\n+ isInvalid={isTypeInvalid}\n+ feedback={typeFeedback}\n+ value={newLabRequest.type}\n+ onChange={onLabTypeChange}\n+ />\n+ <div className=\"form-group\">\n+ <TextFieldWithLabelFormGroup\n+ name=\"labNotes\"\n+ label={t('labs.lab.notes')}\n+ isEditable\n+ value={newLabRequest.notes}\n+ onChange={onNoteChange}\n+ />\n+ </div>\n+ <div className=\"row float-right\">\n+ <div className=\"btn-group btn-group-lg mt-3\">\n+ <Button className=\"mr-2\" color=\"success\" onClick={onSave}>\n+ {t('actions.save')}\n+ </Button>\n+ <Button color=\"danger\" onClick={onCancel}>\n+ {t('actions.cancel')}\n+ </Button>\n+ </div>\n+ </div>\n+ </form>\n+ </>\n+ )\n+}\n+\n+export default NewLabRequest\n"
},
{
"change_type": "MODIFY",
"old_path": "src/locales/enUs/translations/actions/index.ts",
"new_path": "src/locales/enUs/translations/actions/index.ts",
"diff": "@@ -2,11 +2,13 @@ export default {\nactions: {\nedit: 'Edit',\nsave: 'Save',\n+ update: 'Update',\n+ complete: 'Complete',\n+ delete: 'Delete',\ncancel: 'Cancel',\nnew: 'New',\nlist: 'List',\nsearch: 'Search',\n- delete: 'Delete',\nconfirmDelete: 'Delete Confirmation',\n},\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/locales/enUs/translations/labs/index.ts",
"new_path": "src/locales/enUs/translations/labs/index.ts",
"diff": "@@ -3,6 +3,26 @@ export default {\nlabel: 'Labs',\nrequests: {\nlabel: 'Lab Requests',\n+ new: 'New Lab Request',\n+ view: 'View Lab',\n+ cancel: 'Cancel Lab',\n+ complete: 'Complete Lab',\n+ error: {\n+ unableToRequest: 'Unable to create new lab request.',\n+ unableToComplete: 'Unable to complete lab request.',\n+ typeRequired: 'Type is required.',\n+ resultRequiredToComplete: 'Result is required to complete.',\n+ },\n+ },\n+ lab: {\n+ status: 'Status',\n+ for: 'For',\n+ type: 'Type',\n+ result: 'Result',\n+ notes: 'Notes',\n+ requestedOn: 'Requested On',\n+ completedOn: 'Completed On',\n+ canceledOn: 'Canceled On',\n},\n},\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/model/Lab.ts",
"diff": "+import AbstractDBModel from './AbstractDBModel'\n+\n+export default interface Lab extends AbstractDBModel {\n+ patientId: string\n+ type: string\n+ notes: string\n+ result: string\n+ status: 'requested' | 'completed' | 'canceled'\n+ requestedOn: string\n+ completedOn: string\n+ canceledOn: string\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/Permissions.ts",
"new_path": "src/model/Permissions.ts",
"diff": "@@ -6,6 +6,11 @@ enum Permissions {\nDeleteAppointment = 'delete:appointment',\nAddAllergy = 'write:allergy',\nAddDiagnosis = 'write:diagnosis',\n+ RequestLab = 'write:labs',\n+ CancelLab = 'cancel:lab',\n+ CompleteLab = 'complete:lab',\n+ ViewLab = 'read:lab',\n+ ViewLabs = 'read:labs',\n}\nexport default Permissions\n"
},
{
"change_type": "MODIFY",
"old_path": "src/user/user-slice.ts",
"new_path": "src/user/user-slice.ts",
"diff": "@@ -14,6 +14,11 @@ const initialState: UserState = {\nPermissions.DeleteAppointment,\nPermissions.AddAllergy,\nPermissions.AddDiagnosis,\n+ Permissions.ViewLabs,\n+ Permissions.ViewLab,\n+ Permissions.RequestLab,\n+ Permissions.CompleteLab,\n+ Permissions.CancelLab,\n],\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(labs): adds ability to request and view labs |
288,323 | 02.04.2020 21:49:59 | 18,000 | 186754354bd8dacc30aa15c32619bd50e237c63f | feat(labs): adds view lab tests | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/labs/ViewLab.test.tsx",
"new_path": "src/__tests__/labs/ViewLab.test.tsx",
"diff": "@@ -13,9 +13,8 @@ import Lab from 'model/Lab'\nimport Patient from 'model/Patient'\nimport * as ButtonBarProvider from 'page-header/ButtonBarProvider'\nimport createMockStore from 'redux-mock-store'\n-import { Badge, Button } from '@hospitalrun/components'\n+import { Badge, Button, Alert } from '@hospitalrun/components'\nimport TextFieldWithLabelFormGroup from 'components/input/TextFieldWithLabelFormGroup'\n-import ButtonToolBar from 'page-header/ButtonToolBar'\nimport * as titleUtil from '../../page-header/useTitle'\nimport ViewLab from '../../labs/ViewLab'\n@@ -36,8 +35,10 @@ describe('View Labs', () => {\nlet setButtonToolBarSpy: any\nlet titleSpy: any\nlet labRepositorySaveSpy: any\n+ const expectedDate = new Date()\nconst setup = async (lab: Lab, permissions: Permissions[]) => {\njest.resetAllMocks()\n+ Date.now = jest.fn(() => expectedDate.valueOf())\nsetButtonToolBarSpy = jest.fn()\ntitleSpy = jest.spyOn(titleUtil, 'default')\njest.spyOn(ButtonBarProvider, 'useButtonToolbarSetter').mockReturnValue(setButtonToolBarSpy)\n@@ -196,14 +197,36 @@ describe('View Labs', () => {\nexpect(badge.text().trim()).toEqual(expectedLab.status)\n})\n- it('should display a complete lab and cancel lab button if the lab is in a requested state', async () => {\n+ it('should display a update lab, complete lab, and cancel lab button if the lab is in a requested state', async () => {\nconst expectedLab = { ...mockLab, notes: 'expected notes' } as Lab\n- setup(expectedLab, [Permissions.ViewLab, Permissions.CompleteLab, Permissions.CancelLab])\n+ const wrapper = await setup(expectedLab, [\n+ Permissions.ViewLab,\n+ Permissions.CompleteLab,\n+ Permissions.CancelLab,\n+ ])\n+\n+ const buttons = wrapper.find(Button)\n+ expect(\n+ buttons\n+ .at(0)\n+ .text()\n+ .trim(),\n+ ).toEqual('actions.update')\n- const actualButtons: React.ReactNode[] = setButtonToolBarSpy.mock.calls[0][0]\n- expect((actualButtons[0] as any).props.children).toEqual('labs.requests.complete')\n- expect((actualButtons[1] as any).props.children).toEqual('labs.requests.cancel')\n+ expect(\n+ buttons\n+ .at(1)\n+ .text()\n+ .trim(),\n+ ).toEqual('labs.requests.complete')\n+\n+ expect(\n+ buttons\n+ .at(2)\n+ .text()\n+ .trim(),\n+ ).toEqual('labs.requests.cancel')\n})\n})\n@@ -249,18 +272,17 @@ describe('View Labs', () => {\n).toEqual('2020-03-29 11:45 PM')\n})\n- it('should not display complete and cancel button if the lab is canceled', async () => {\n+ it('should not display update, complete, and cancel button if the lab is canceled', async () => {\nconst expectedLab = { ...mockLab, status: 'canceled' } as Lab\n- await setup(expectedLab, [\n+ const wrapper = await setup(expectedLab, [\nPermissions.ViewLab,\nPermissions.CompleteLab,\nPermissions.CancelLab,\n])\n- const { calls } = setButtonToolBarSpy.mock\n- const actualButtons: React.ReactNode[] = calls[calls.length - 1][0]\n- expect(actualButtons as any).toEqual([])\n+ const buttons = wrapper.find(Button)\n+ expect(buttons).toHaveLength(0)\n})\nit('should not display an update button if the lab is canceled', async () => {\n@@ -314,26 +336,17 @@ describe('View Labs', () => {\n).toEqual('2020-03-29 11:44 PM')\n})\n- it('should not display complete and cancel button if the lab is completed', async () => {\n+ it('should not display update, complete, and cancel buttons if the lab is completed', async () => {\nconst expectedLab = { ...mockLab, status: 'completed' } as Lab\n- await setup(expectedLab, [\n+ const wrapper = await setup(expectedLab, [\nPermissions.ViewLab,\nPermissions.CompleteLab,\nPermissions.CancelLab,\n])\n- const { calls } = setButtonToolBarSpy.mock\n- const actualButtons: React.ReactNode[] = calls[calls.length - 1][0]\n- expect(actualButtons as any).toEqual([])\n- })\n-\n- it('should not display an update button if the lab is completed', async () => {\n- const expectedLab = { ...mockLab, status: 'canceled' } as Lab\n- const wrapper = await setup(expectedLab, [Permissions.ViewLab])\n-\n- const updateButton = wrapper.find(Button)\n- expect(updateButton).toHaveLength(0)\n+ const buttons = wrapper.find(Button)\n+ expect(buttons).toHaveLength(0)\n})\n})\n})\n@@ -385,25 +398,86 @@ describe('View Labs', () => {\nconst onChange = resultTextField.prop('onChange')\nawait onChange({ currentTarget: { value: expectedResult } })\n})\n+ wrapper.update()\n- const completeButton = setButtonToolBarSpy.mock.calls[0][0][0]\n+ const completeButton = wrapper.find(Button).at(1)\nawait act(async () => {\n- const { onClick } = completeButton.props\n+ const onClick = completeButton.prop('onClick')\nawait onClick()\n})\nwrapper.update()\nexpect(labRepositorySaveSpy).toHaveBeenCalledTimes(1)\nexpect(labRepositorySaveSpy).toHaveBeenCalledWith(\n- expect.objectContaining({ ...mockLab, result: expectedResult }),\n+ expect.objectContaining({\n+ ...mockLab,\n+ result: expectedResult,\n+ status: 'completed',\n+ completedOn: expectedDate.toISOString(),\n+ }),\n)\nexpect(history.location.pathname).toEqual('/labs')\n})\n- it('should validate that the result has been filled in', () => {})\n+ it('should validate that the result has been filled in', async () => {\n+ const wrapper = await setup(mockLab, [\n+ Permissions.ViewLab,\n+ Permissions.CompleteLab,\n+ Permissions.CancelLab,\n+ ])\n+\n+ const completeButton = wrapper.find(Button).at(1)\n+ await act(async () => {\n+ const onClick = completeButton.prop('onClick')\n+ await onClick()\n+ })\n+ wrapper.update()\n+\n+ const alert = wrapper.find(Alert)\n+ const resultField = wrapper.find(TextFieldWithLabelFormGroup).at(0)\n+ expect(alert).toHaveLength(1)\n+ expect(alert.prop('title')).toEqual('states.error')\n+ expect(alert.prop('message')).toEqual('labs.requests.error.unableToComplete')\n+ expect(resultField.prop('isInvalid')).toBeTruthy()\n+ expect(resultField.prop('feedback')).toEqual('labs.requests.error.resultRequiredToComplete')\n+\n+ expect(labRepositorySaveSpy).not.toHaveBeenCalled()\n+ })\n})\ndescribe('on cancel', () => {\n- it('should mark the status as completed and fill in the cancelled on date with the current time', () => {})\n+ it('should mark the status as canceled and fill in the cancelled on date with the current time', async () => {\n+ const wrapper = await setup(mockLab, [\n+ Permissions.ViewLab,\n+ Permissions.CompleteLab,\n+ Permissions.CancelLab,\n+ ])\n+ const expectedResult = 'expected result'\n+\n+ const resultTextField = wrapper.find(TextFieldWithLabelFormGroup).at(0)\n+ await act(async () => {\n+ const onChange = resultTextField.prop('onChange')\n+ await onChange({ currentTarget: { value: expectedResult } })\n+ })\n+ wrapper.update()\n+\n+ const cancelButton = wrapper.find(Button).at(2)\n+ await act(async () => {\n+ const onClick = cancelButton.prop('onClick')\n+ await onClick()\n+ })\n+ wrapper.update()\n+\n+ expect(labRepositorySaveSpy).toHaveBeenCalledTimes(1)\n+ expect(labRepositorySaveSpy).toHaveBeenCalledWith(\n+ expect.objectContaining({\n+ ...mockLab,\n+ result: expectedResult,\n+ status: 'canceled',\n+ canceledOn: expectedDate.toISOString(),\n+ }),\n+ )\n+ expect(history.location.pathname).toEqual('/labs')\n+ })\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/labs/ViewLab.tsx",
"new_path": "src/labs/ViewLab.tsx",
"diff": "@@ -9,7 +9,6 @@ import useTitle from 'page-header/useTitle'\nimport { useTranslation } from 'react-i18next'\nimport { Row, Column, Badge, Button, Alert } from '@hospitalrun/components'\nimport TextFieldWithLabelFormGroup from 'components/input/TextFieldWithLabelFormGroup'\n-import { useButtonToolbarSetter } from 'page-header/ButtonBarProvider'\nimport useAddBreadcrumbs from 'breadcrumbs/useAddBreadcrumbs'\nimport { useSelector } from 'react-redux'\nimport Permissions from 'model/Permissions'\n@@ -22,8 +21,6 @@ const ViewLab = () => {\nconst { id } = useParams()\nconst { t } = useTranslation()\nconst history = useHistory()\n- const setButtons = useButtonToolbarSetter()\n-\nconst { permissions } = useSelector((state: RootState) => state.user)\nconst [patient, setPatient] = useState<Patient | undefined>()\nconst [lab, setLab] = useState<Lab | undefined>()\n@@ -93,7 +90,7 @@ const ViewLab = () => {\nawait LabRepository.saveOrUpdate({\n...newLab,\n- completedOn: new Date().toISOString(),\n+ completedOn: new Date(Date.now().valueOf()).toISOString(),\nstatus: 'completed',\n})\nhistory.push('/labs')\n@@ -103,7 +100,7 @@ const ViewLab = () => {\nconst newLab = lab as Lab\nawait LabRepository.saveOrUpdate({\n...newLab,\n- canceledOn: new Date().toISOString(),\n+ canceledOn: new Date(Date.now().valueOf()).toISOString(),\nstatus: 'canceled',\n})\nhistory.push('/labs')\n@@ -115,9 +112,15 @@ const ViewLab = () => {\nreturn buttons\n}\n+ buttons.push(\n+ <Button className=\"mr-2\" color=\"success\" onClick={onUpdate}>\n+ {t('actions.update')}\n+ </Button>,\n+ )\n+\nif (permissions.includes(Permissions.CompleteLab)) {\nbuttons.push(\n- <Button onClick={onComplete} color=\"primary\">\n+ <Button className=\"mr-2\" onClick={onComplete} color=\"primary\">\n{t('labs.requests.complete')}\n</Button>,\n)\n@@ -134,8 +137,6 @@ const ViewLab = () => {\nreturn buttons\n}\n- setButtons(getButtons())\n-\nif (lab && patient) {\nconst getBadgeColor = () => {\nif (lab.status === 'completed') {\n@@ -225,11 +226,7 @@ const ViewLab = () => {\n/>\n{isEditable && (\n<div className=\"row float-right\">\n- <div className=\"btn-group btn-group-lg mt-3\">\n- <Button className=\"mr-2\" color=\"success\" onClick={onUpdate}>\n- {t('actions.update')}\n- </Button>\n- </div>\n+ <div className=\"btn-group btn-group-lg mt-3\">{getButtons()}</div>\n</div>\n)}\n</form>\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(labs): adds view lab tests |
288,323 | 02.04.2020 22:46:37 | 18,000 | 691572ba578fffb044c914ec84ca524fde066a59 | feat(labs): adds labs sidebar/navbar links | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/components/Navbar.test.tsx",
"new_path": "src/__tests__/components/Navbar.test.tsx",
"diff": "@@ -85,6 +85,36 @@ describe('Navbar', () => {\n})\n})\n+ describe('labs', () => {\n+ const labsLinkList = hospitalRunNavbar.find('.labs-link-list')\n+\n+ it('should render a labs dropdown', () => {\n+ expect(labsLinkList.first().props().title).toEqual('labs.label')\n+ expect(labsLinkList.first().props().children[0].props.children).toEqual('labs.label')\n+ expect(labsLinkList.first().props().children[1].props.children).toEqual('labs.requests.new')\n+ })\n+\n+ it('should navigate to to /labs when the labs list option is selected', () => {\n+ act(() => {\n+ labsLinkList\n+ .first()\n+ .props()\n+ .children[0].props.onClick()\n+ })\n+ expect(history.location.pathname).toEqual('/labs')\n+ })\n+\n+ it('should navigate to /labs/new when the new labs list option is selected', () => {\n+ act(() => {\n+ labsLinkList\n+ .first()\n+ .props()\n+ .children[1].props.onClick()\n+ })\n+ expect(history.location.pathname).toEqual('/labs/new')\n+ })\n+ })\n+\ndescribe('search', () => {\nconst navSearch = hospitalRunNavbar.find('.nav-search')\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/components/Sidebar.test.tsx",
"new_path": "src/__tests__/components/Sidebar.test.tsx",
"diff": "@@ -29,13 +29,18 @@ describe('Sidebar', () => {\n)\n}\n- describe('dashboard link', () => {\n+ describe('dashboard links', () => {\nit('should render the dashboard link', () => {\nconst wrapper = setup('/')\nconst listItems = wrapper.find(ListItem)\n- expect(listItems.at(1).text().trim()).toEqual('dashboard.label')\n+ expect(\n+ listItems\n+ .at(1)\n+ .text()\n+ .trim(),\n+ ).toEqual('dashboard.label')\n})\nit('should be active when the current path is /', () => {\n@@ -60,16 +65,47 @@ describe('Sidebar', () => {\n})\n})\n- describe('patients link', () => {\n- it('should render the dashboard link', () => {\n+ describe('patients links', () => {\n+ it('should render the patients main link', () => {\nconst wrapper = setup('/')\nconst listItems = wrapper.find(ListItem)\n- expect(listItems.at(2).text().trim()).toEqual('patients.label')\n+ expect(\n+ listItems\n+ .at(2)\n+ .text()\n+ .trim(),\n+ ).toEqual('patients.label')\n})\n- it('should be active when the current path is /', () => {\n+ it('should render the new_patient link', () => {\n+ const wrapper = setup('/patients')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ expect(\n+ listItems\n+ .at(3)\n+ .text()\n+ .trim(),\n+ ).toEqual('patients.newPatient')\n+ })\n+\n+ it('should render the patients_list link', () => {\n+ const wrapper = setup('/patients')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ expect(\n+ listItems\n+ .at(4)\n+ .text()\n+ .trim(),\n+ ).toEqual('patients.patientsList')\n+ })\n+\n+ it('main patients link should be active when the current path is /patients', () => {\nconst wrapper = setup('/patients')\nconst listItems = wrapper.find(ListItem)\n@@ -77,7 +113,7 @@ describe('Sidebar', () => {\nexpect(listItems.at(2).prop('active')).toBeTruthy()\n})\n- it('should navigate to /patients when the patients link is clicked', () => {\n+ it('should navigate to /patients when the patients main link is clicked', () => {\nconst wrapper = setup('/')\nconst listItems = wrapper.find(ListItem)\n@@ -89,18 +125,29 @@ describe('Sidebar', () => {\nexpect(history.location.pathname).toEqual('/patients')\n})\n+\n+ it('new patient should be active when the current path is /patients/new', () => {\n+ const wrapper = setup('/patients/new')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ expect(listItems.at(3).prop('active')).toBeTruthy()\n})\n- describe('patients_list link', () => {\n- it('should render the patients_list link', () => {\n+ it('should navigate to /patients/new when the patients new link is clicked', () => {\nconst wrapper = setup('/patients')\nconst listItems = wrapper.find(ListItem)\n- expect(listItems.at(4).text().trim()).toEqual('patients.patientsList')\n+ act(() => {\n+ const onClick = listItems.at(3).prop('onClick') as any\n+ onClick()\n+ })\n+\n+ expect(history.location.pathname).toEqual('/patients/new')\n})\n- it('should be active when the current path is /patients', () => {\n+ it('patients list link should be active when the current path is /patients', () => {\nconst wrapper = setup('/patients')\nconst listItems = wrapper.find(ListItem)\n@@ -108,7 +155,7 @@ describe('Sidebar', () => {\nexpect(listItems.at(4).prop('active')).toBeTruthy()\n})\n- it('should navigate to /patients when the patients link is clicked', () => {\n+ it('should navigate to /patients when the patients list link is clicked', () => {\nconst wrapper = setup('/patients')\nconst listItems = wrapper.find(ListItem)\n@@ -122,46 +169,47 @@ describe('Sidebar', () => {\n})\n})\n- describe('new_patient link', () => {\n- it('should render the new_patient link', () => {\n- const wrapper = setup('/patients')\n-\n- const listItems = wrapper.find(ListItem)\n-\n- expect(listItems.at(3).text().trim()).toEqual('patients.newPatient')\n- })\n-\n- it('should be active when the current path is /patients/new', () => {\n- const wrapper = setup('/patients/new')\n+ describe('appointments link', () => {\n+ it('should render the scheduling link', () => {\n+ const wrapper = setup('/appointments')\nconst listItems = wrapper.find(ListItem)\n- expect(listItems.at(3).prop('active')).toBeTruthy()\n+ expect(\n+ listItems\n+ .at(3)\n+ .text()\n+ .trim(),\n+ ).toEqual('scheduling.label')\n})\n- it('should navigate to /patients/new when the patients link is clicked', () => {\n- const wrapper = setup('/patients')\n+ it('should render the new appointment link', () => {\n+ const wrapper = setup('/appointments/new')\nconst listItems = wrapper.find(ListItem)\n- act(() => {\n- ;(listItems.at(3).prop('onClick') as any)()\n- })\n-\n- expect(history.location.pathname).toEqual('/patients/new')\n- })\n+ expect(\n+ listItems\n+ .at(4)\n+ .text()\n+ .trim(),\n+ ).toEqual('scheduling.appointments.new')\n})\n- describe('appointments link', () => {\n- it('should render the scheduling link', () => {\n+ it('should render the appointments schedule link', () => {\nconst wrapper = setup('/appointments')\nconst listItems = wrapper.find(ListItem)\n- expect(listItems.at(3).text().trim()).toEqual('scheduling.label')\n+ expect(\n+ listItems\n+ .at(5)\n+ .text()\n+ .trim(),\n+ ).toEqual('scheduling.appointments.schedule')\n})\n- it('should be active when the current path is /appointments', () => {\n+ it('main scheduling link should be active when the current path is /appointments', () => {\nconst wrapper = setup('/appointments')\nconst listItems = wrapper.find(ListItem)\n@@ -169,7 +217,7 @@ describe('Sidebar', () => {\nexpect(listItems.at(3).prop('active')).toBeTruthy()\n})\n- it('should navigate to /appointments when the scheduling link is clicked', () => {\n+ it('should navigate to /appointments when the main scheduling link is clicked', () => {\nconst wrapper = setup('/')\nconst listItems = wrapper.find(ListItem)\n@@ -181,18 +229,29 @@ describe('Sidebar', () => {\nexpect(history.location.pathname).toEqual('/appointments')\n})\n+\n+ it('new appointment link should be active when the current path is /appointments/new', () => {\n+ const wrapper = setup('/appointments/new')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ expect(listItems.at(4).prop('active')).toBeTruthy()\n})\n- describe('appointment_schedule link', () => {\n- it('should render the appointment_schedule link', () => {\n+ it('should navigate to /appointments/new when the new appointment link is clicked', () => {\nconst wrapper = setup('/appointments')\nconst listItems = wrapper.find(ListItem)\n- expect(listItems.at(5).text().trim()).toEqual('scheduling.appointments.schedule')\n+ act(() => {\n+ const onClick = listItems.at(4).prop('onClick') as any\n+ onClick()\n+ })\n+\n+ expect(history.location.pathname).toEqual('/appointments/new')\n})\n- it('should be active when the current path is /appointments', () => {\n+ it('appointments schedule link should be active when the current path is /appointments', () => {\nconst wrapper = setup('/appointments')\nconst listItems = wrapper.find(ListItem)\n@@ -200,7 +259,7 @@ describe('Sidebar', () => {\nexpect(listItems.at(5).prop('active')).toBeTruthy()\n})\n- it('should navigate to /appointments when the appointments_schedule link is clicked', () => {\n+ it('should navigate to /appointments when the appointments schedule link is clicked', () => {\nconst wrapper = setup('/appointments')\nconst listItems = wrapper.find(ListItem)\n@@ -214,25 +273,56 @@ describe('Sidebar', () => {\n})\n})\n- describe('new_appointment link', () => {\n- it('should render the new_appointment link', () => {\n- const wrapper = setup('/appointments/new')\n+ describe('labs links', () => {\n+ it('should render the main labs link', () => {\n+ const wrapper = setup('/labs')\nconst listItems = wrapper.find(ListItem)\n- expect(listItems.at(4).text().trim()).toEqual('scheduling.appointments.new')\n+ expect(\n+ listItems\n+ .at(4)\n+ .text()\n+ .trim(),\n+ ).toEqual('labs.label')\n})\n- it('should be active when the current path is /appointments/new', () => {\n- const wrapper = setup('/appointments/new')\n+ it('should render the new labs request link', () => {\n+ const wrapper = setup('/labs')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ expect(\n+ listItems\n+ .at(5)\n+ .text()\n+ .trim(),\n+ ).toEqual('labs.requests.new')\n+ })\n+\n+ it('should render the labs list link', () => {\n+ const wrapper = setup('/labs')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ expect(\n+ listItems\n+ .at(6)\n+ .text()\n+ .trim(),\n+ ).toEqual('labs.requests.label')\n+ })\n+\n+ it('main labs link should be active when the current path is /labs', () => {\n+ const wrapper = setup('/labs')\nconst listItems = wrapper.find(ListItem)\nexpect(listItems.at(4).prop('active')).toBeTruthy()\n})\n- it('should navigate to /appointments/new when the new_appointment link is clicked', () => {\n- const wrapper = setup('/appointments')\n+ it('should navigate to /labs when the main lab link is clicked', () => {\n+ const wrapper = setup('/')\nconst listItems = wrapper.find(ListItem)\n@@ -241,7 +331,49 @@ describe('Sidebar', () => {\nonClick()\n})\n- expect(history.location.pathname).toEqual('/appointments/new')\n+ expect(history.location.pathname).toEqual('/labs')\n+ })\n+\n+ it('new lab request link should be active when the current path is /labs/new', () => {\n+ const wrapper = setup('/labs/new')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ expect(listItems.at(5).prop('active')).toBeTruthy()\n+ })\n+\n+ it('should navigate to /labs/new when the new labs link is clicked', () => {\n+ const wrapper = setup('/labs')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ act(() => {\n+ const onClick = listItems.at(5).prop('onClick') as any\n+ onClick()\n+ })\n+\n+ expect(history.location.pathname).toEqual('/labs/new')\n+ })\n+\n+ it('labs list link should be active when the current path is /labs', () => {\n+ const wrapper = setup('/labs')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ expect(listItems.at(6).prop('active')).toBeTruthy()\n+ })\n+\n+ it('should navigate to /labs when the labs list link is clicked', () => {\n+ const wrapper = setup('/labs/new')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ act(() => {\n+ const onClick = listItems.at(6).prop('onClick') as any\n+ onClick()\n+ })\n+\n+ expect(history.location.pathname).toEqual('/labs')\n})\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/components/Navbar.tsx",
"new_path": "src/components/Navbar.tsx",
"diff": "@@ -73,7 +73,7 @@ const Navbar = () => {\n{\ntype: 'link-list',\nlabel: t('labs.label'),\n- className: 'labs-link-list',\n+ className: 'labs-link-list d-md-none d-block',\nchildren: [\n{\ntype: 'link',\n"
},
{
"change_type": "MODIFY",
"old_path": "src/components/Sidebar.tsx",
"new_path": "src/components/Sidebar.tsx",
"diff": "@@ -37,6 +37,8 @@ const Sidebar = () => {\n? 'patient'\n: splittedPath[1].includes('appointments')\n? 'appointment'\n+ : splittedPath[1].includes('labs')\n+ ? 'labs'\n: 'none',\n)\n@@ -71,23 +73,8 @@ const Sidebar = () => {\n: 'black',\n}\n- return (\n- <nav\n- className=\"col-md-2 d-none d-md-block bg-light sidebar\"\n- style={{ width: sidebarCollapsed ? '56px' : '' }}\n- >\n- <div className=\"sidebar-sticky\">\n- <List layout=\"flush\" className=\"nav flex-column\">\n- <ListItem\n- onClick={() => dispatch(updateSidebar())}\n- className=\"nav-item\"\n- style={listItemStyle}\n- >\n- <Icon\n- style={{ float: sidebarCollapsed ? 'left' : 'right' }}\n- icon={sidebarCollapsed ? 'right-arrow' : 'left-arrow'}\n- />\n- </ListItem>\n+ const getDashboardLink = () => (\n+ <>\n<ListItem\nactive={pathname === '/'}\nonClick={() => {\n@@ -99,6 +86,11 @@ const Sidebar = () => {\n>\n<Icon icon=\"dashboard\" /> {!sidebarCollapsed && t('dashboard.label')}\n</ListItem>\n+ </>\n+ )\n+\n+ const getPatientLinks = () => (\n+ <>\n<ListItem\nactive={splittedPath[1].includes('patient')}\nonClick={() => {\n@@ -145,6 +137,11 @@ const Sidebar = () => {\n</ListItem>\n</List>\n)}\n+ </>\n+ )\n+\n+ const getAppointmentLinks = () => (\n+ <>\n<ListItem\nactive={splittedPath[1].includes('appointments')}\nonClick={() => {\n@@ -164,14 +161,98 @@ const Sidebar = () => {\n/>\n<Icon icon=\"appointment\" /> {!sidebarCollapsed && t('scheduling.label')}\n</ListItem>\n+ {splittedPath[1].includes('appointment') && expandedItem === 'appointment' && (\n+ <List layout=\"flush\" className=\"nav flex-column\">\n<ListItem\n- active={pathname.split('/')[1].includes('labs')}\n- onClick={() => navigateTo('/labs')}\n+ className=\"nav-item\"\n+ style={listSubItemStyleNew}\n+ onClick={() => navigateTo('/appointments/new')}\n+ active={splittedPath[1].includes('appointments') && splittedPath.length > 2}\n+ >\n+ <Icon icon=\"appointment-add\" style={iconMargin} />\n+ {!sidebarCollapsed && t('scheduling.appointments.new')}\n+ </ListItem>\n+ <ListItem\n+ className=\"nav-item\"\n+ style={listSubItemStyle}\n+ onClick={() => navigateTo('/appointments')}\n+ active={splittedPath[1].includes('appointments') && splittedPath.length < 3}\n+ >\n+ <Icon icon=\"incident\" style={iconMargin} />\n+ {!sidebarCollapsed && t('scheduling.appointments.schedule')}\n+ </ListItem>\n+ </List>\n+ )}\n+ </>\n+ )\n+\n+ const getLabLinks = () => (\n+ <>\n+ <ListItem\n+ active={splittedPath[1].includes('labs')}\n+ onClick={() => {\n+ navigateTo('/labs')\n+ setExpansion('labs')\n+ }}\nclassName=\"nav-item\"\nstyle={listItemStyle}\n>\n+ <Icon\n+ icon={\n+ splittedPath[1].includes('labs') && expandedItem === 'labs'\n+ ? 'down-arrow'\n+ : 'right-arrow'\n+ }\n+ style={expandibleArrow}\n+ />\n<Icon icon=\"lab\" /> {!sidebarCollapsed && t('labs.label')}\n</ListItem>\n+ {splittedPath[1].includes('labs') && expandedItem === 'labs' && (\n+ <List layout=\"flush\" className=\"nav flex-column\">\n+ <ListItem\n+ className=\"nav-item\"\n+ style={listSubItemStyleNew}\n+ onClick={() => navigateTo('/labs/new')}\n+ active={splittedPath[1].includes('labs') && splittedPath.length > 2}\n+ >\n+ <Icon icon=\"add\" style={iconMargin} />\n+ {!sidebarCollapsed && t('labs.requests.new')}\n+ </ListItem>\n+ <ListItem\n+ className=\"nav-item\"\n+ style={listSubItemStyle}\n+ onClick={() => navigateTo('/labs')}\n+ active={splittedPath[1].includes('labs') && splittedPath.length < 3}\n+ >\n+ <Icon icon=\"incident\" style={iconMargin} />\n+ {!sidebarCollapsed && t('labs.requests.label')}\n+ </ListItem>\n+ </List>\n+ )}\n+ </>\n+ )\n+\n+ return (\n+ <nav\n+ className=\"col-md-2 d-none d-md-block bg-light sidebar\"\n+ style={{ width: sidebarCollapsed ? '56px' : '' }}\n+ >\n+ <div className=\"sidebar-sticky\">\n+ <List layout=\"flush\" className=\"nav flex-column\">\n+ <ListItem\n+ onClick={() => dispatch(updateSidebar())}\n+ className=\"nav-item\"\n+ style={listItemStyle}\n+ >\n+ <Icon\n+ style={{ float: sidebarCollapsed ? 'left' : 'right' }}\n+ icon={sidebarCollapsed ? 'right-arrow' : 'left-arrow'}\n+ />\n+ </ListItem>\n+ {getDashboardLink()}\n+ {getPatientLinks()}\n+ {getAppointmentLinks()}\n+ {getLabLinks()}\n</List>\n</div>\n</nav>\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(labs): adds labs sidebar/navbar links |
Subsets and Splits