diff --git a/.eslintrc.js b/.eslintrc.js index 2692cbdf5b..e397908a74 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -28,10 +28,17 @@ module.exports = { 'import/resolver': { node: { extensions: ['.js', '.jsx', '.ts', '.tsx'], + moduleDirectory: ["node_modules"], }, + "typescript": { + alwaysTryTypes: true, + } + }, + 'import/parsers': { + '@typescript-eslint/parser': ['.ts', '.tsx'], }, }, - plugins: ['react', '@typescript-eslint', 'prettier', 'jest'], + plugins: ['react', '@typescript-eslint', 'prettier', 'jest', 'import'], rules: { 'prettier/prettier': 'error', '@typescript-eslint/member-delimiter-style': 'off', @@ -47,12 +54,26 @@ module.exports = { 'arrow-body-style': ['warn', 'as-needed'], 'no-param-reassign': ['error', { props: false }], 'import/prefer-default-export': 'off', + 'import/no-cycle': 'off', 'no-console': 'off', 'eol-last': ['error', 'always'], 'no-debugger': 'error', 'no-nested-ternary': 'off', 'import/no-unresolved': 'off', 'import/extensions': ['error', 'never'], + 'import/order': ["error", { + "groups": [ + "external", + ["sibling","parent","internal"], + "builtin", + "unknown", + ], + "newlines-between": "always", + "alphabetize": { + "order": 'asc', + "caseInsensitive": true, + }, + }], curly: ['error', 'all'], }, } diff --git a/package.json b/package.json index 804258fbef..1300646217 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,8 @@ "eslint": "~6.8.0", "eslint-config-airbnb": "~18.1.0", "eslint-config-prettier": "~6.11.0", - "eslint-plugin-import": "~2.20.0", + "eslint-import-resolver-typescript": "~2.0.0", + "eslint-plugin-import": "~2.20.2", "eslint-plugin-jest": "~23.13.0", "eslint-plugin-jsx-a11y": "~6.2.3", "eslint-plugin-prettier": "~3.1.2", diff --git a/src/App.tsx b/src/App.tsx index f813de0874..5d69f48774 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,9 +1,9 @@ +import { Spinner } from '@hospitalrun/components' import React, { Suspense } from 'react' -import { BrowserRouter } from 'react-router-dom' import { Provider } from 'react-redux' -import { Spinner } from '@hospitalrun/components' -import HospitalRun from './HospitalRun' +import { BrowserRouter } from 'react-router-dom' +import HospitalRun from './HospitalRun' import store from './store' const App: React.FC = () => ( diff --git a/src/HospitalRun.tsx b/src/HospitalRun.tsx index 0ef1b026e6..df0a8f7d43 100644 --- a/src/HospitalRun.tsx +++ b/src/HospitalRun.tsx @@ -1,19 +1,20 @@ +import { Toaster } from '@hospitalrun/components' import React from 'react' -import { Switch, Route } from 'react-router-dom' import { useSelector } from 'react-redux' -import { Toaster } from '@hospitalrun/components' -import Breadcrumbs from 'breadcrumbs/Breadcrumbs' -import { ButtonBarProvider } from 'page-header/ButtonBarProvider' -import ButtonToolBar from 'page-header/ButtonToolBar' -import Labs from 'labs/Labs' -import Sidebar from './components/Sidebar' -import Dashboard from './dashboard/Dashboard' -import { RootState } from './store' +import { Switch, Route } from 'react-router-dom' + +import Breadcrumbs from './breadcrumbs/Breadcrumbs' import Navbar from './components/Navbar' import PrivateRoute from './components/PrivateRoute' -import Patients from './patients/Patients' +import Sidebar from './components/Sidebar' +import Dashboard from './dashboard/Dashboard' import Incidents from './incidents/Incidents' +import Labs from './labs/Labs' +import { ButtonBarProvider } from './page-header/ButtonBarProvider' +import ButtonToolBar from './page-header/ButtonToolBar' +import Patients from './patients/Patients' import Appointments from './scheduling/appointments/Appointments' +import { RootState } from './store' const HospitalRun = () => { const { title } = useSelector((state: RootState) => state.title) diff --git a/src/__tests__/App.test.tsx b/src/__tests__/App.test.tsx index 9d82e2646a..f3379a0293 100644 --- a/src/__tests__/App.test.tsx +++ b/src/__tests__/App.test.tsx @@ -1,8 +1,10 @@ import '../__mocks__/matchMediaMock' -import React from 'react' + import { mount } from 'enzyme' -import HospitalRun from '../HospitalRun' +import React from 'react' + import App from '../App' +import HospitalRun from '../HospitalRun' it('renders without crashing', () => { const wrapper = mount() diff --git a/src/__tests__/HospitalRun.test.tsx b/src/__tests__/HospitalRun.test.tsx index 5e919d7412..049e966179 100644 --- a/src/__tests__/HospitalRun.test.tsx +++ b/src/__tests__/HospitalRun.test.tsx @@ -1,20 +1,22 @@ import '../__mocks__/matchMediaMock' -import React from 'react' + +import { Toaster } from '@hospitalrun/components' import { mount } from 'enzyme' -import { MemoryRouter } from 'react-router-dom' +import React from 'react' +import { act } from 'react-dom/test-utils' import { Provider } from 'react-redux' -import thunk from 'redux-thunk' +import { MemoryRouter } from 'react-router-dom' import createMockStore from 'redux-mock-store' -import { Toaster } from '@hospitalrun/components' -import { act } from 'react-dom/test-utils' -import Dashboard from 'dashboard/Dashboard' -import ViewLabs from 'labs/ViewLabs' -import LabRepository from 'clients/db/LabRepository' -import { addBreadcrumbs } from 'breadcrumbs/breadcrumbs-slice' -import Appointments from 'scheduling/appointments/Appointments' +import thunk from 'redux-thunk' + +import { addBreadcrumbs } from '../breadcrumbs/breadcrumbs-slice' +import LabRepository from '../clients/db/LabRepository' +import Dashboard from '../dashboard/Dashboard' import HospitalRun from '../HospitalRun' -import Permissions from '../model/Permissions' import Incidents from '../incidents/Incidents' +import ViewLabs from '../labs/ViewLabs' +import Permissions from '../model/Permissions' +import Appointments from '../scheduling/appointments/Appointments' import { RootState } from '../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/breadcrumbs/Breadcrumbs.test.tsx b/src/__tests__/breadcrumbs/Breadcrumbs.test.tsx index b6198d1269..664af2a3bd 100644 --- a/src/__tests__/breadcrumbs/Breadcrumbs.test.tsx +++ b/src/__tests__/breadcrumbs/Breadcrumbs.test.tsx @@ -1,18 +1,18 @@ import '../../__mocks__/matchMediaMock' -import React from 'react' -import { Provider } from 'react-redux' -import { mount } from 'enzyme' -import { createMemoryHistory } from 'history' -import { Router } from 'react-router-dom' -import createMockStore from 'redux-mock-store' import { Breadcrumb as HRBreadcrumb, BreadcrumbItem as HRBreadcrumbItem, } from '@hospitalrun/components' - -import Breadcrumbs from 'breadcrumbs/Breadcrumbs' -import Breadcrumb from 'model/Breadcrumb' +import { mount } from 'enzyme' +import { createMemoryHistory } from 'history' +import React from 'react' +import { Provider } from 'react-redux' +import { Router } from 'react-router-dom' +import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' + +import Breadcrumbs from '../../breadcrumbs/Breadcrumbs' +import Breadcrumb from '../../model/Breadcrumb' import { RootState } from '../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/breadcrumbs/breadcrumbs-slice.test.ts b/src/__tests__/breadcrumbs/breadcrumbs-slice.test.ts index 10f73f19ff..a3b46992b1 100644 --- a/src/__tests__/breadcrumbs/breadcrumbs-slice.test.ts +++ b/src/__tests__/breadcrumbs/breadcrumbs-slice.test.ts @@ -1,5 +1,7 @@ import '../../__mocks__/matchMediaMock' + import { AnyAction } from 'redux' + import breadcrumbs, { addBreadcrumbs, removeBreadcrumbs } from '../../breadcrumbs/breadcrumbs-slice' describe('breadcrumbs slice', () => { diff --git a/src/__tests__/breadcrumbs/useAddBreadcrumbs.test.tsx b/src/__tests__/breadcrumbs/useAddBreadcrumbs.test.tsx index 5b0f8aff1c..f67b9fd22f 100644 --- a/src/__tests__/breadcrumbs/useAddBreadcrumbs.test.tsx +++ b/src/__tests__/breadcrumbs/useAddBreadcrumbs.test.tsx @@ -1,10 +1,11 @@ -import React from 'react' import { renderHook } from '@testing-library/react-hooks' -import createMockStore from 'redux-mock-store' +import React from 'react' import { Provider } from 'react-redux' +import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' + import * as breadcrumbsSlice from '../../breadcrumbs/breadcrumbs-slice' +import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' import { RootState } from '../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/clients/db/AppointmentRepository.test.ts b/src/__tests__/clients/db/AppointmentRepository.test.ts index 042b4e8c96..6877aa2083 100644 --- a/src/__tests__/clients/db/AppointmentRepository.test.ts +++ b/src/__tests__/clients/db/AppointmentRepository.test.ts @@ -1,6 +1,6 @@ -import AppointmentRepository from 'clients/db/AppointmentRepository' -import { appointments, patients } from 'config/pouchdb' -import Appointment from 'model/Appointment' +import AppointmentRepository from '../../../clients/db/AppointmentRepository' +import { appointments, patients } from '../../../config/pouchdb' +import Appointment from '../../../model/Appointment' 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 diff --git a/src/__tests__/clients/db/LabRepository.test.ts b/src/__tests__/clients/db/LabRepository.test.ts index f9ed08130e..cbbc7238a0 100644 --- a/src/__tests__/clients/db/LabRepository.test.ts +++ b/src/__tests__/clients/db/LabRepository.test.ts @@ -1,8 +1,10 @@ /* eslint "@typescript-eslint/camelcase": "off" */ + import shortid from 'shortid' -import { labs } from 'config/pouchdb' -import LabRepository from 'clients/db/LabRepository' -import SortRequest from 'clients/db/SortRequest' + +import LabRepository from '../../../clients/db/LabRepository' +import SortRequest from '../../../clients/db/SortRequest' +import { labs } from '../../../config/pouchdb' import Lab from '../../../model/Lab' interface SearchContainer { diff --git a/src/__tests__/clients/db/PatientRepository.test.ts b/src/__tests__/clients/db/PatientRepository.test.ts index e45cd7262b..1a30bd157e 100644 --- a/src/__tests__/clients/db/PatientRepository.test.ts +++ b/src/__tests__/clients/db/PatientRepository.test.ts @@ -1,8 +1,9 @@ -import { patients } from 'config/pouchdb' -import PatientRepository from 'clients/db/PatientRepository' -import Patient from 'model/Patient' -import shortid from 'shortid' import { getTime, isAfter } from 'date-fns' +import shortid from 'shortid' + +import PatientRepository from '../../../clients/db/PatientRepository' +import { patients } from '../../../config/pouchdb' +import Patient from '../../../model/Patient' 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 diff --git a/src/__tests__/components/Navbar.test.tsx b/src/__tests__/components/Navbar.test.tsx index 8354bce74d..a345692aa6 100644 --- a/src/__tests__/components/Navbar.test.tsx +++ b/src/__tests__/components/Navbar.test.tsx @@ -1,10 +1,12 @@ import '../../__mocks__/matchMediaMock' -import React from 'react' -import { Router } from 'react-router-dom' -import { mount } from 'enzyme' + import { Navbar as HospitalRunNavbar } from '@hospitalrun/components' -import { act } from 'react-dom/test-utils' +import { mount } from 'enzyme' import { createMemoryHistory } from 'history' +import React from 'react' +import { act } from 'react-dom/test-utils' +import { Router } from 'react-router-dom' + import Navbar from '../../components/Navbar' describe('Navbar', () => { diff --git a/src/__tests__/components/Sidebar.test.tsx b/src/__tests__/components/Sidebar.test.tsx index 89186c1e73..285dfb41a8 100644 --- a/src/__tests__/components/Sidebar.test.tsx +++ b/src/__tests__/components/Sidebar.test.tsx @@ -1,14 +1,16 @@ import '../../__mocks__/matchMediaMock' -import React from 'react' + +import { ListItem } from '@hospitalrun/components' +import { act } from '@testing-library/react' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' -import Sidebar from 'components/Sidebar' +import React from 'react' +import { Provider } from 'react-redux' import { Router } from 'react-router-dom' -import { ListItem } from '@hospitalrun/components' -import { act } from '@testing-library/react' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import { Provider } from 'react-redux' + +import Sidebar from '../../components/Sidebar' import { RootState } from '../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/components/input/DatePickerWithLabelFormGroup.test.tsx b/src/__tests__/components/input/DatePickerWithLabelFormGroup.test.tsx index 0bb2fec902..ee3c169a82 100644 --- a/src/__tests__/components/input/DatePickerWithLabelFormGroup.test.tsx +++ b/src/__tests__/components/input/DatePickerWithLabelFormGroup.test.tsx @@ -1,7 +1,9 @@ import '../../../__mocks__/matchMediaMock' -import React, { ChangeEvent } from 'react' + import { DateTimePicker, Label } from '@hospitalrun/components' import { shallow } from 'enzyme' +import React, { ChangeEvent } from 'react' + import DatePickerWithLabelFormGroup from '../../../components/input/DatePickerWithLabelFormGroup' describe('date picker with label form group', () => { diff --git a/src/__tests__/components/input/DateTimePickerWithLabelFormGroup.test.tsx b/src/__tests__/components/input/DateTimePickerWithLabelFormGroup.test.tsx index cba26f9131..9052cd0fe9 100644 --- a/src/__tests__/components/input/DateTimePickerWithLabelFormGroup.test.tsx +++ b/src/__tests__/components/input/DateTimePickerWithLabelFormGroup.test.tsx @@ -1,7 +1,9 @@ import '../../../__mocks__/matchMediaMock' -import React, { ChangeEvent } from 'react' + import { DateTimePicker, Label } from '@hospitalrun/components' import { shallow } from 'enzyme' +import React, { ChangeEvent } from 'react' + import DateTimePickerWithLabelFormGroup from '../../../components/input/DateTimePickerWithLabelFormGroup' describe('date picker with label form group', () => { diff --git a/src/__tests__/components/input/SelectWithLabelFormGroup.test.tsx b/src/__tests__/components/input/SelectWithLabelFormGroup.test.tsx index 74be6cbfeb..96b04df022 100644 --- a/src/__tests__/components/input/SelectWithLabelFormGroup.test.tsx +++ b/src/__tests__/components/input/SelectWithLabelFormGroup.test.tsx @@ -1,7 +1,9 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' -import { shallow } from 'enzyme' + import { Label, Select } from '@hospitalrun/components' +import { shallow } from 'enzyme' +import React from 'react' + import SelectWithLabelFormGroup from '../../../components/input/SelectWithLableFormGroup' describe('select with label form group', () => { diff --git a/src/__tests__/components/input/TestInputWithLabelFormGroup.test.tsx b/src/__tests__/components/input/TestInputWithLabelFormGroup.test.tsx index 01fbc66d14..4dd9841647 100644 --- a/src/__tests__/components/input/TestInputWithLabelFormGroup.test.tsx +++ b/src/__tests__/components/input/TestInputWithLabelFormGroup.test.tsx @@ -1,7 +1,9 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' + import { Label, TextInput } from '@hospitalrun/components' import { shallow } from 'enzyme' +import React from 'react' + import TextInputWithLabelFormGroup from '../../../components/input/TextInputWithLabelFormGroup' describe('text input with label form group', () => { diff --git a/src/__tests__/components/input/TextFieldWithLabelFormGroup.test.tsx b/src/__tests__/components/input/TextFieldWithLabelFormGroup.test.tsx index 64367b1e64..5e033bb987 100644 --- a/src/__tests__/components/input/TextFieldWithLabelFormGroup.test.tsx +++ b/src/__tests__/components/input/TextFieldWithLabelFormGroup.test.tsx @@ -1,7 +1,9 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' + import { Label, TextField } from '@hospitalrun/components' import { shallow } from 'enzyme' +import React from 'react' + import TextFieldWithLabelFormGroup from '../../../components/input/TextFieldWithLabelFormGroup' describe('text field with label form group', () => { diff --git a/src/__tests__/hooks/debounce.test.ts b/src/__tests__/hooks/debounce.test.ts index 73be39e3eb..d4ced8c57d 100644 --- a/src/__tests__/hooks/debounce.test.ts +++ b/src/__tests__/hooks/debounce.test.ts @@ -1,5 +1,6 @@ import { renderHook, act } from '@testing-library/react-hooks' -import useDebounce from 'hooks/debounce' + +import useDebounce from '../../hooks/debounce' describe('useDebounce', () => { beforeAll(() => jest.useFakeTimers()) diff --git a/src/__tests__/incidents/Incidents.test.tsx b/src/__tests__/incidents/Incidents.test.tsx index 34079ce554..ecc4626461 100644 --- a/src/__tests__/incidents/Incidents.test.tsx +++ b/src/__tests__/incidents/Incidents.test.tsx @@ -1,17 +1,19 @@ import '../../__mocks__/matchMediaMock' -import React from 'react' + +import { act } from '@testing-library/react' import { mount } from 'enzyme' -import { MemoryRouter } from 'react-router' +import React from 'react' import { Provider } from 'react-redux' -import thunk from 'redux-thunk' +import { MemoryRouter } from 'react-router-dom' import createMockStore from 'redux-mock-store' -import { act } from '@testing-library/react' -import Permissions from 'model/Permissions' -import ViewIncident from '../../incidents/view/ViewIncident' +import thunk from 'redux-thunk' + +import IncidentRepository from '../../clients/db/IncidentRepository' import Incidents from '../../incidents/Incidents' import ReportIncident from '../../incidents/report/ReportIncident' +import ViewIncident from '../../incidents/view/ViewIncident' import Incident from '../../model/Incident' -import IncidentRepository from '../../clients/db/IncidentRepository' +import Permissions from '../../model/Permissions' import { RootState } from '../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/incidents/incident-slice.test.ts b/src/__tests__/incidents/incident-slice.test.ts index 0e157df0d4..103462c9e3 100644 --- a/src/__tests__/incidents/incident-slice.test.ts +++ b/src/__tests__/incidents/incident-slice.test.ts @@ -1,8 +1,10 @@ +import { addDays } from 'date-fns' import { AnyAction } from 'redux' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' import shortid from 'shortid' -import { addDays } from 'date-fns' + +import IncidentRepository from '../../clients/db/IncidentRepository' import incident, { reportIncidentStart, reportIncidentSuccess, @@ -13,10 +15,9 @@ import incident, { fetchIncident, } from '../../incidents/incident-slice' import Incident from '../../model/Incident' -import { RootState } from '../../store' -import IncidentRepository from '../../clients/db/IncidentRepository' import Permissions from '../../model/Permissions' import User from '../../model/User' +import { RootState } from '../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/incidents/incidents-slice.test.ts b/src/__tests__/incidents/incidents-slice.test.ts index fd869a9116..6dbddd628f 100644 --- a/src/__tests__/incidents/incidents-slice.test.ts +++ b/src/__tests__/incidents/incidents-slice.test.ts @@ -1,14 +1,15 @@ +import { AnyAction } from 'redux' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import { AnyAction } from 'redux' -import { RootState } from '../../store' + +import IncidentRepository from '../../clients/db/IncidentRepository' import incidents, { fetchIncidents, fetchIncidentsStart, fetchIncidentsSuccess, } from '../../incidents/incidents-slice' -import IncidentRepository from '../../clients/db/IncidentRepository' import Incident from '../../model/Incident' +import { RootState } from '../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/incidents/list/ViewIncidents.test.tsx b/src/__tests__/incidents/list/ViewIncidents.test.tsx index ca8cd7b78f..13b2fcbe9a 100644 --- a/src/__tests__/incidents/list/ViewIncidents.test.tsx +++ b/src/__tests__/incidents/list/ViewIncidents.test.tsx @@ -1,19 +1,21 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' + +import { act } from '@testing-library/react' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' -import { act } from '@testing-library/react' +import React from 'react' import { Provider } from 'react-redux' -import { Route, Router } from 'react-router' +import { Route, Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import Permissions from '../../../model/Permissions' -import * as titleUtil from '../../../page-header/useTitle' -import * as ButtonBarProvider from '../../../page-header/ButtonBarProvider' + import * as breadcrumbUtil from '../../../breadcrumbs/useAddBreadcrumbs' +import IncidentRepository from '../../../clients/db/IncidentRepository' import ViewIncidents from '../../../incidents/list/ViewIncidents' import Incident from '../../../model/Incident' -import IncidentRepository from '../../../clients/db/IncidentRepository' +import Permissions from '../../../model/Permissions' +import * as ButtonBarProvider from '../../../page-header/ButtonBarProvider' +import * as titleUtil from '../../../page-header/useTitle' import { RootState } from '../../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/incidents/report/ReportIncident.test.tsx b/src/__tests__/incidents/report/ReportIncident.test.tsx index 6a9cfbf97d..51a301ae30 100644 --- a/src/__tests__/incidents/report/ReportIncident.test.tsx +++ b/src/__tests__/incidents/report/ReportIncident.test.tsx @@ -1,19 +1,21 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' + +import { Button } from '@hospitalrun/components' +import { act } from '@testing-library/react' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' -import { act } from '@testing-library/react' +import React from 'react' import { Provider } from 'react-redux' -import { Route, Router } from 'react-router' +import { Route, Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import { Button } from '@hospitalrun/components' -import Permissions from '../../../model/Permissions' -import * as titleUtil from '../../../page-header/useTitle' -import * as ButtonBarProvider from '../../../page-header/ButtonBarProvider' + import * as breadcrumbUtil from '../../../breadcrumbs/useAddBreadcrumbs' -import ReportIncident from '../../../incidents/report/ReportIncident' import IncidentRepository from '../../../clients/db/IncidentRepository' +import ReportIncident from '../../../incidents/report/ReportIncident' +import Permissions from '../../../model/Permissions' +import * as ButtonBarProvider from '../../../page-header/ButtonBarProvider' +import * as titleUtil from '../../../page-header/useTitle' import { RootState } from '../../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/incidents/view/ViewIncident.test.tsx b/src/__tests__/incidents/view/ViewIncident.test.tsx index 097b0fdf85..d8bdeae1aa 100644 --- a/src/__tests__/incidents/view/ViewIncident.test.tsx +++ b/src/__tests__/incidents/view/ViewIncident.test.tsx @@ -1,19 +1,21 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' + +import { act } from '@testing-library/react' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' -import { act } from '@testing-library/react' +import React from 'react' import { Provider } from 'react-redux' -import { Route, Router } from 'react-router' +import { Route, Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import Permissions from '../../../model/Permissions' -import * as titleUtil from '../../../page-header/useTitle' -import * as ButtonBarProvider from '../../../page-header/ButtonBarProvider' + import * as breadcrumbUtil from '../../../breadcrumbs/useAddBreadcrumbs' +import IncidentRepository from '../../../clients/db/IncidentRepository' import ViewIncident from '../../../incidents/view/ViewIncident' import Incident from '../../../model/Incident' -import IncidentRepository from '../../../clients/db/IncidentRepository' +import Permissions from '../../../model/Permissions' +import * as ButtonBarProvider from '../../../page-header/ButtonBarProvider' +import * as titleUtil from '../../../page-header/useTitle' import { RootState } from '../../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/labs/Labs.test.tsx b/src/__tests__/labs/Labs.test.tsx index 1f1ac1c87d..9489b30f8c 100644 --- a/src/__tests__/labs/Labs.test.tsx +++ b/src/__tests__/labs/Labs.test.tsx @@ -1,19 +1,21 @@ import '../../__mocks__/matchMediaMock' -import React from 'react' + +import { act } from '@testing-library/react' import { mount } from 'enzyme' -import { MemoryRouter } from 'react-router-dom' +import React from 'react' import { Provider } from 'react-redux' -import thunk from 'redux-thunk' +import { MemoryRouter } from 'react-router-dom' import createMockStore from 'redux-mock-store' -import { act } from '@testing-library/react' -import Labs from 'labs/Labs' -import NewLabRequest from 'labs/requests/NewLabRequest' -import Permissions from 'model/Permissions' -import ViewLab from 'labs/ViewLab' -import LabRepository from 'clients/db/LabRepository' -import Lab from 'model/Lab' -import Patient from 'model/Patient' -import PatientRepository from 'clients/db/PatientRepository' +import thunk from 'redux-thunk' + +import LabRepository from '../../clients/db/LabRepository' +import PatientRepository from '../../clients/db/PatientRepository' +import Labs from '../../labs/Labs' +import NewLabRequest from '../../labs/requests/NewLabRequest' +import ViewLab from '../../labs/ViewLab' +import Lab from '../../model/Lab' +import Patient from '../../model/Patient' +import Permissions from '../../model/Permissions' import { RootState } from '../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/labs/ViewLab.test.tsx b/src/__tests__/labs/ViewLab.test.tsx index 66a84f9105..f7c0963aea 100644 --- a/src/__tests__/labs/ViewLab.test.tsx +++ b/src/__tests__/labs/ViewLab.test.tsx @@ -1,23 +1,25 @@ import '../../__mocks__/matchMediaMock' + +import { Badge, Button, Alert } from '@hospitalrun/components' +import { act } from '@testing-library/react' +import format from 'date-fns/format' +import { mount } from 'enzyme' +import { createMemoryHistory } from 'history' import React from 'react' import { Provider } from 'react-redux' import { Router, Route } from 'react-router-dom' -import { mount } from 'enzyme' -import thunk from 'redux-thunk' -import { createMemoryHistory } from 'history' -import Permissions from 'model/Permissions' -import { act } from '@testing-library/react' -import LabRepository from 'clients/db/LabRepository' -import PatientRepository from 'clients/db/PatientRepository' -import Lab from 'model/Lab' -import Patient from 'model/Patient' -import * as ButtonBarProvider from 'page-header/ButtonBarProvider' import createMockStore from 'redux-mock-store' -import { Badge, Button, Alert } from '@hospitalrun/components' -import TextFieldWithLabelFormGroup from 'components/input/TextFieldWithLabelFormGroup' -import format from 'date-fns/format' -import * as titleUtil from '../../page-header/useTitle' +import thunk from 'redux-thunk' + +import LabRepository from '../../clients/db/LabRepository' +import PatientRepository from '../../clients/db/PatientRepository' +import TextFieldWithLabelFormGroup from '../../components/input/TextFieldWithLabelFormGroup' import ViewLab from '../../labs/ViewLab' +import Lab from '../../model/Lab' +import Patient from '../../model/Patient' +import Permissions from '../../model/Permissions' +import * as ButtonBarProvider from '../../page-header/ButtonBarProvider' +import * as titleUtil from '../../page-header/useTitle' import { RootState } from '../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/labs/ViewLabs.test.tsx b/src/__tests__/labs/ViewLabs.test.tsx index 8bdc8716b6..2c3eae5a1b 100644 --- a/src/__tests__/labs/ViewLabs.test.tsx +++ b/src/__tests__/labs/ViewLabs.test.tsx @@ -1,20 +1,22 @@ import '../../__mocks__/matchMediaMock' + +import { TextInput, Select } from '@hospitalrun/components' +import { act } from '@testing-library/react' +import format from 'date-fns/format' +import { mount, ReactWrapper } from 'enzyme' +import { createMemoryHistory } from 'history' import React from 'react' import { Provider } from 'react-redux' import { Router } from 'react-router-dom' -import ViewLabs from 'labs/ViewLabs' -import { mount, ReactWrapper } from 'enzyme' -import { TextInput, Select } from '@hospitalrun/components' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import { createMemoryHistory } from 'history' -import Permissions from 'model/Permissions' -import { act } from '@testing-library/react' -import LabRepository from 'clients/db/LabRepository' -import * as labsSlice from 'labs/labs-slice' -import Lab from 'model/Lab' -import format from 'date-fns/format' -import * as ButtonBarProvider from 'page-header/ButtonBarProvider' + +import LabRepository from '../../clients/db/LabRepository' +import * as labsSlice from '../../labs/labs-slice' +import ViewLabs from '../../labs/ViewLabs' +import Lab from '../../model/Lab' +import Permissions from '../../model/Permissions' +import * as ButtonBarProvider from '../../page-header/ButtonBarProvider' import * as titleUtil from '../../page-header/useTitle' import { RootState } from '../../store' diff --git a/src/__tests__/labs/lab-slice.test.ts b/src/__tests__/labs/lab-slice.test.ts index 6296f36b7e..a6dbe8de95 100644 --- a/src/__tests__/labs/lab-slice.test.ts +++ b/src/__tests__/labs/lab-slice.test.ts @@ -1,9 +1,8 @@ -import thunk from 'redux-thunk' import createMockStore from 'redux-mock-store' -import PatientRepository from '../../clients/db/PatientRepository' +import thunk from 'redux-thunk' + import LabRepository from '../../clients/db/LabRepository' -import Lab from '../../model/Lab' -import Patient from '../../model/Patient' +import PatientRepository from '../../clients/db/PatientRepository' import labSlice, { requestLab, fetchLabStart, @@ -23,6 +22,8 @@ import labSlice, { requestLabError, updateLab, } from '../../labs/lab-slice' +import Lab from '../../model/Lab' +import Patient from '../../model/Patient' import { RootState } from '../../store' const mockStore = createMockStore([thunk]) @@ -303,11 +304,19 @@ describe('lab slice', () => { }) it('should request a new lab', async () => { - const store = mockStore() + const store = mockStore({ + user: { + user: { + id: 'fake id', + }, + }, + } as any) + const expectedRequestedLab = { ...mockLab, requestedOn: new Date(Date.now()).toISOString(), status: 'requested', + requestedBy: store.getState().user.user.id, } as Lab await store.dispatch(requestLab(mockLab)) @@ -320,7 +329,13 @@ describe('lab slice', () => { }) it('should execute the onSuccess callback if provided', async () => { - const store = mockStore() + const store = mockStore({ + user: { + user: { + id: 'fake id', + }, + }, + } as any) const onSuccessSpy = jest.fn() await store.dispatch(requestLab(mockLab, onSuccessSpy)) diff --git a/src/__tests__/labs/labs.slice.test.ts b/src/__tests__/labs/labs.slice.test.ts index a380d0beb3..d02dbca38b 100644 --- a/src/__tests__/labs/labs.slice.test.ts +++ b/src/__tests__/labs/labs.slice.test.ts @@ -1,9 +1,10 @@ import { AnyAction } from 'redux' import { mocked } from 'ts-jest/utils' -import SortRequest from 'clients/db/SortRequest' + +import LabRepository from '../../clients/db/LabRepository' +import SortRequest from '../../clients/db/SortRequest' import labs, { fetchLabsStart, fetchLabsSuccess, searchLabs } from '../../labs/labs-slice' import Lab from '../../model/Lab' -import LabRepository from '../../clients/db/LabRepository' interface SearchContainer { text: string diff --git a/src/__tests__/labs/requests/NewLabRequest.test.tsx b/src/__tests__/labs/requests/NewLabRequest.test.tsx index e832109747..3270cf682c 100644 --- a/src/__tests__/labs/requests/NewLabRequest.test.tsx +++ b/src/__tests__/labs/requests/NewLabRequest.test.tsx @@ -1,20 +1,22 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' -import NewLabRequest from 'labs/requests/NewLabRequest' -import TextFieldWithLabelFormGroup from 'components/input/TextFieldWithLabelFormGroup' -import TextInputWithLabelFormGroup from 'components/input/TextInputWithLabelFormGroup' -import { mount, ReactWrapper } from 'enzyme' + import { Button, Typeahead, Label, Alert } from '@hospitalrun/components' -import { Router } from 'react-router-dom' +import { mount, ReactWrapper } from 'enzyme' +import { createMemoryHistory } from 'history' +import React from 'react' +import { act } from 'react-dom/test-utils' import { Provider } from 'react-redux' +import { Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import { createMemoryHistory } from 'history' -import { act } from 'react-dom/test-utils' -import LabRepository from 'clients/db/LabRepository' -import PatientRepository from 'clients/db/PatientRepository' -import Lab from 'model/Lab' -import Patient from 'model/Patient' + +import LabRepository from '../../../clients/db/LabRepository' +import PatientRepository from '../../../clients/db/PatientRepository' +import TextFieldWithLabelFormGroup from '../../../components/input/TextFieldWithLabelFormGroup' +import TextInputWithLabelFormGroup from '../../../components/input/TextInputWithLabelFormGroup' +import NewLabRequest from '../../../labs/requests/NewLabRequest' +import Lab from '../../../model/Lab' +import Patient from '../../../model/Patient' import * as titleUtil from '../../../page-header/useTitle' import { RootState } from '../../../store' @@ -196,7 +198,11 @@ describe('New Lab Request', () => { .mockResolvedValue([{ id: expectedLab.patientId, fullName: 'some full name' }] as Patient[]) history.push('/labs/new') - const store = mockStore({ title: '', lab: { status: 'loading', error: {} } } as any) + const store = mockStore({ + title: '', + lab: { status: 'loading', error: {} }, + user: { user: { id: 'fake id' } }, + } as any) wrapper = mount( diff --git a/src/__tests__/page-header/ButtonBarProvider.test.tsx b/src/__tests__/page-header/ButtonBarProvider.test.tsx index af8527735d..70e8f95713 100644 --- a/src/__tests__/page-header/ButtonBarProvider.test.tsx +++ b/src/__tests__/page-header/ButtonBarProvider.test.tsx @@ -1,12 +1,14 @@ import '../../__mocks__/matchMediaMock' -import React, { useEffect } from 'react' + +import { Button } from '@hospitalrun/components' import { renderHook } from '@testing-library/react-hooks' +import React, { useEffect } from 'react' + import { ButtonBarProvider, useButtons, useButtonToolbarSetter, -} from 'page-header/ButtonBarProvider' -import { Button } from '@hospitalrun/components' +} from '../../page-header/ButtonBarProvider' describe('Button Bar Provider', () => { it('should update and fetch data from the button bar provider', () => { diff --git a/src/__tests__/page-header/ButtonToolBar.test.tsx b/src/__tests__/page-header/ButtonToolBar.test.tsx index ff369b086d..f5ac62fe16 100644 --- a/src/__tests__/page-header/ButtonToolBar.test.tsx +++ b/src/__tests__/page-header/ButtonToolBar.test.tsx @@ -1,8 +1,10 @@ import '../../__mocks__/matchMediaMock' -import React from 'react' + import { Button } from '@hospitalrun/components' -import { mocked } from 'ts-jest/utils' import { mount } from 'enzyme' +import React from 'react' +import { mocked } from 'ts-jest/utils' + import * as ButtonBarProvider from '../../page-header/ButtonBarProvider' import ButtonToolBar from '../../page-header/ButtonToolBar' diff --git a/src/__tests__/page-header/title-slice.test.ts b/src/__tests__/page-header/title-slice.test.ts index d15bfef444..0c56a92fe3 100644 --- a/src/__tests__/page-header/title-slice.test.ts +++ b/src/__tests__/page-header/title-slice.test.ts @@ -1,4 +1,5 @@ import { AnyAction } from 'redux' + import title, { updateTitle, changeTitle } from '../../page-header/title-slice' describe('title slice', () => { diff --git a/src/__tests__/page-header/useTitle.test.tsx b/src/__tests__/page-header/useTitle.test.tsx index ac1defd7d5..1534ca2b58 100644 --- a/src/__tests__/page-header/useTitle.test.tsx +++ b/src/__tests__/page-header/useTitle.test.tsx @@ -1,10 +1,11 @@ -import React from 'react' import { renderHook } from '@testing-library/react-hooks' +import React from 'react' +import { Provider } from 'react-redux' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import { Provider } from 'react-redux' -import useTitle from '../../page-header/useTitle' + import * as titleSlice from '../../page-header/title-slice' +import useTitle from '../../page-header/useTitle' import { RootState } from '../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/GeneralInformation.test.tsx b/src/__tests__/patients/GeneralInformation.test.tsx index 368079a078..353334e293 100644 --- a/src/__tests__/patients/GeneralInformation.test.tsx +++ b/src/__tests__/patients/GeneralInformation.test.tsx @@ -1,13 +1,15 @@ import '../../__mocks__/matchMediaMock' -import React from 'react' -import { Router } from 'react-router' -import { mount, ReactWrapper } from 'enzyme' -import GeneralInformation from 'patients/GeneralInformation' -import { createMemoryHistory } from 'history' -import { startOfDay, subYears } from 'date-fns' + import { Alert } from '@hospitalrun/components' import { act } from '@testing-library/react' +import { startOfDay, subYears } from 'date-fns' +import { mount, ReactWrapper } from 'enzyme' +import { createMemoryHistory } from 'history' +import React from 'react' +import { Router } from 'react-router-dom' + import Patient from '../../model/Patient' +import GeneralInformation from '../../patients/GeneralInformation' describe('Error handling', () => { it('should display errors', () => { diff --git a/src/__tests__/patients/Patients.test.tsx b/src/__tests__/patients/Patients.test.tsx index ce4f42bc31..08e99e36fb 100644 --- a/src/__tests__/patients/Patients.test.tsx +++ b/src/__tests__/patients/Patients.test.tsx @@ -1,19 +1,21 @@ import '../../__mocks__/matchMediaMock' + +import { mount } from 'enzyme' import React from 'react' +import { act } from 'react-dom/test-utils' import { Provider } from 'react-redux' -import { MemoryRouter } from 'react-router' +import { MemoryRouter } from 'react-router-dom' import createMockStore from 'redux-mock-store' -import { mount } from 'enzyme' import thunk from 'redux-thunk' -import { act } from 'react-dom/test-utils' -import Permissions from '../../model/Permissions' -import HospitalRun from '../../HospitalRun' -import NewPatient from '../../patients/new/NewPatient' + import { addBreadcrumbs } from '../../breadcrumbs/breadcrumbs-slice' -import Dashboard from '../../dashboard/Dashboard' import PatientRepository from '../../clients/db/PatientRepository' +import Dashboard from '../../dashboard/Dashboard' +import HospitalRun from '../../HospitalRun' import Patient from '../../model/Patient' +import Permissions from '../../model/Permissions' import EditPatient from '../../patients/edit/EditPatient' +import NewPatient from '../../patients/new/NewPatient' import ViewPatient from '../../patients/view/ViewPatient' import { RootState } from '../../store' diff --git a/src/__tests__/patients/allergies/Allergies.test.tsx b/src/__tests__/patients/allergies/Allergies.test.tsx index 622f65c2b1..87ef0dd253 100644 --- a/src/__tests__/patients/allergies/Allergies.test.tsx +++ b/src/__tests__/patients/allergies/Allergies.test.tsx @@ -1,18 +1,20 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' + +import * as components from '@hospitalrun/components' +import { act } from '@testing-library/react' import { mount } from 'enzyme' -import Allergies from 'patients/allergies/Allergies' -import Permissions from 'model/Permissions' -import createMockStore from 'redux-mock-store' import { createMemoryHistory } from 'history' -import thunk from 'redux-thunk' -import { Router } from 'react-router-dom' +import React from 'react' import { Provider } from 'react-redux' -import Patient from 'model/Patient' -import * as components from '@hospitalrun/components' -import { act } from '@testing-library/react' -import PatientRepository from 'clients/db/PatientRepository' -import Allergy from 'model/Allergy' +import { Router } from 'react-router-dom' +import createMockStore from 'redux-mock-store' +import thunk from 'redux-thunk' + +import PatientRepository from '../../../clients/db/PatientRepository' +import Allergy from '../../../model/Allergy' +import Patient from '../../../model/Patient' +import Permissions from '../../../model/Permissions' +import Allergies from '../../../patients/allergies/Allergies' import { RootState } from '../../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/allergies/NewAllergyModal.test.tsx b/src/__tests__/patients/allergies/NewAllergyModal.test.tsx index c00827adc6..6492bc0b8c 100644 --- a/src/__tests__/patients/allergies/NewAllergyModal.test.tsx +++ b/src/__tests__/patients/allergies/NewAllergyModal.test.tsx @@ -1,16 +1,18 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' -import NewAllergyModal from 'patients/allergies/NewAllergyModal' -import { mount } from 'enzyme' + import { Modal, Alert } from '@hospitalrun/components' import { act } from '@testing-library/react' +import { mount } from 'enzyme' +import React from 'react' +import { Provider } from 'react-redux' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import { Provider } from 'react-redux' -import TextInputWithLabelFormGroup from '../../../components/input/TextInputWithLabelFormGroup' -import * as patientSlice from '../../../patients/patient-slice' + import PatientRepository from '../../../clients/db/PatientRepository' +import TextInputWithLabelFormGroup from '../../../components/input/TextInputWithLabelFormGroup' import Patient from '../../../model/Patient' +import NewAllergyModal from '../../../patients/allergies/NewAllergyModal' +import * as patientSlice from '../../../patients/patient-slice' import { RootState } from '../../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/appointments/AppointmentsList.test.tsx b/src/__tests__/patients/appointments/AppointmentsList.test.tsx index 0eec654b33..0aca51515a 100644 --- a/src/__tests__/patients/appointments/AppointmentsList.test.tsx +++ b/src/__tests__/patients/appointments/AppointmentsList.test.tsx @@ -1,15 +1,17 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' + +import * as components from '@hospitalrun/components' import { mount, ReactWrapper } from 'enzyme' import { createMemoryHistory } from 'history' +import React from 'react' +import { act } from 'react-dom/test-utils' +import { Provider } from 'react-redux' +import { Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import Patient from 'model/Patient' -import { Router } from 'react-router-dom' -import { Provider } from 'react-redux' -import AppointmentsList from 'patients/appointments/AppointmentsList' -import * as components from '@hospitalrun/components' -import { act } from 'react-dom/test-utils' + +import Patient from '../../../model/Patient' +import AppointmentsList from '../../../patients/appointments/AppointmentsList' import * as appointmentsSlice from '../../../scheduling/appointments/appointments-slice' import { RootState } from '../../../store' diff --git a/src/__tests__/patients/diagnoses/AddDiagnosisModal.test.tsx b/src/__tests__/patients/diagnoses/AddDiagnosisModal.test.tsx index 67f3fc6878..c31be04acd 100644 --- a/src/__tests__/patients/diagnoses/AddDiagnosisModal.test.tsx +++ b/src/__tests__/patients/diagnoses/AddDiagnosisModal.test.tsx @@ -1,18 +1,20 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' -import { mount } from 'enzyme' + import { Modal, Alert } from '@hospitalrun/components' import { act } from '@testing-library/react' -import AddDiagnosisModal from 'patients/diagnoses/AddDiagnosisModal' +import { mount } from 'enzyme' +import React from 'react' +import { Provider } from 'react-redux' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import { Provider } from 'react-redux' -import TextInputWithLabelFormGroup from '../../../components/input/TextInputWithLabelFormGroup' + +import PatientRepository from '../../../clients/db/PatientRepository' import DatePickerWithLabelFormGroup from '../../../components/input/DatePickerWithLabelFormGroup' +import TextInputWithLabelFormGroup from '../../../components/input/TextInputWithLabelFormGroup' import Diagnosis from '../../../model/Diagnosis' -import * as patientSlice from '../../../patients/patient-slice' -import PatientRepository from '../../../clients/db/PatientRepository' import Patient from '../../../model/Patient' +import AddDiagnosisModal from '../../../patients/diagnoses/AddDiagnosisModal' +import * as patientSlice from '../../../patients/patient-slice' import { RootState } from '../../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/diagnoses/Diagnoses.test.tsx b/src/__tests__/patients/diagnoses/Diagnoses.test.tsx index e3e9d384c4..f53e29c021 100644 --- a/src/__tests__/patients/diagnoses/Diagnoses.test.tsx +++ b/src/__tests__/patients/diagnoses/Diagnoses.test.tsx @@ -1,18 +1,20 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' + +import * as components from '@hospitalrun/components' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' +import React from 'react' +import { act } from 'react-dom/test-utils' +import { Provider } from 'react-redux' +import { Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import Patient from 'model/Patient' -import Diagnosis from 'model/Diagnosis' -import Permissions from 'model/Permissions' -import { Router } from 'react-router-dom' -import { Provider } from 'react-redux' -import Diagnoses from 'patients/diagnoses/Diagnoses' -import * as components from '@hospitalrun/components' -import { act } from 'react-dom/test-utils' -import PatientRepository from 'clients/db/PatientRepository' + +import PatientRepository from '../../../clients/db/PatientRepository' +import Diagnosis from '../../../model/Diagnosis' +import Patient from '../../../model/Patient' +import Permissions from '../../../model/Permissions' +import Diagnoses from '../../../patients/diagnoses/Diagnoses' import { RootState } from '../../../store' const expectedPatient = { diff --git a/src/__tests__/patients/edit/EditPatient.test.tsx b/src/__tests__/patients/edit/EditPatient.test.tsx index 9ecd4ba2c0..01260ff4d1 100644 --- a/src/__tests__/patients/edit/EditPatient.test.tsx +++ b/src/__tests__/patients/edit/EditPatient.test.tsx @@ -1,20 +1,22 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' + +import { Button } from '@hospitalrun/components' +import { subDays } from 'date-fns' import { mount } from 'enzyme' -import { Router, Route } from 'react-router-dom' -import { Provider } from 'react-redux' import { createMemoryHistory } from 'history' +import React from 'react' import { act } from 'react-dom/test-utils' +import { Provider } from 'react-redux' +import { Router, Route } from 'react-router-dom' import createMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' -import { Button } from '@hospitalrun/components' -import { subDays } from 'date-fns' -import EditPatient from '../../../patients/edit/EditPatient' -import GeneralInformation from '../../../patients/GeneralInformation' + +import PatientRepository from '../../../clients/db/PatientRepository' import Patient from '../../../model/Patient' import * as titleUtil from '../../../page-header/useTitle' +import EditPatient from '../../../patients/edit/EditPatient' +import GeneralInformation from '../../../patients/GeneralInformation' import * as patientSlice from '../../../patients/patient-slice' -import PatientRepository from '../../../clients/db/PatientRepository' import { RootState } from '../../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/labs/LabsTab.test.tsx b/src/__tests__/patients/labs/LabsTab.test.tsx index fec0584787..5a36aca1c9 100644 --- a/src/__tests__/patients/labs/LabsTab.test.tsx +++ b/src/__tests__/patients/labs/LabsTab.test.tsx @@ -1,19 +1,20 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' -import createMockStore from 'redux-mock-store' -import thunk from 'redux-thunk' -import { mount } from 'enzyme' -import { createMemoryHistory } from 'history' -import { Router } from 'react-router-dom' -import { Provider } from 'react-redux' import * as components from '@hospitalrun/components' import format from 'date-fns/format' +import { mount } from 'enzyme' +import { createMemoryHistory } from 'history' +import React from 'react' import { act } from 'react-dom/test-utils' -import LabsTab from '../../../patients/labs/LabsTab' -import Patient from '../../../model/Patient' +import { Provider } from 'react-redux' +import { Router } from 'react-router-dom' +import createMockStore from 'redux-mock-store' +import thunk from 'redux-thunk' + +import LabRepository from '../../../clients/db/LabRepository' import Lab from '../../../model/Lab' +import Patient from '../../../model/Patient' import Permissions from '../../../model/Permissions' -import LabRepository from '../../../clients/db/LabRepository' +import LabsTab from '../../../patients/labs/LabsTab' import { RootState } from '../../../store' const expectedPatient = { diff --git a/src/__tests__/patients/list/ViewPatients.test.tsx b/src/__tests__/patients/list/ViewPatients.test.tsx index a250d28a1d..b85e7d6be3 100644 --- a/src/__tests__/patients/list/ViewPatients.test.tsx +++ b/src/__tests__/patients/list/ViewPatients.test.tsx @@ -1,17 +1,19 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' -import { mount } from 'enzyme' + import { TextInput, Spinner } from '@hospitalrun/components' -import { MemoryRouter } from 'react-router-dom' +import format from 'date-fns/format' +import { mount } from 'enzyme' +import React from 'react' +import { act } from 'react-dom/test-utils' import { Provider } from 'react-redux' -import thunk from 'redux-thunk' +import { MemoryRouter } from 'react-router-dom' import configureStore from 'redux-mock-store' +import thunk from 'redux-thunk' import { mocked } from 'ts-jest/utils' -import { act } from 'react-dom/test-utils' -import * as ButtonBarProvider from 'page-header/ButtonBarProvider' -import format from 'date-fns/format' -import ViewPatients from '../../../patients/list/ViewPatients' + import PatientRepository from '../../../clients/db/PatientRepository' +import * as ButtonBarProvider from '../../../page-header/ButtonBarProvider' +import ViewPatients from '../../../patients/list/ViewPatients' import * as patientSlice from '../../../patients/patients-slice' const middlewares = [thunk] diff --git a/src/__tests__/patients/new/NewPatient.test.tsx b/src/__tests__/patients/new/NewPatient.test.tsx index 49d2e0010a..f5237c1091 100644 --- a/src/__tests__/patients/new/NewPatient.test.tsx +++ b/src/__tests__/patients/new/NewPatient.test.tsx @@ -1,20 +1,22 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' + +import * as components from '@hospitalrun/components' import { mount } from 'enzyme' -import { Router, Route } from 'react-router-dom' -import { Provider } from 'react-redux' -import { mocked } from 'ts-jest/utils' import { createMemoryHistory } from 'history' +import React from 'react' import { act } from 'react-dom/test-utils' +import { Provider } from 'react-redux' +import { Router, Route } from 'react-router-dom' import createMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' -import * as components from '@hospitalrun/components' -import NewPatient from '../../../patients/new/NewPatient' -import GeneralInformation from '../../../patients/GeneralInformation' +import { mocked } from 'ts-jest/utils' + +import PatientRepository from '../../../clients/db/PatientRepository' import Patient from '../../../model/Patient' -import * as patientSlice from '../../../patients/patient-slice' import * as titleUtil from '../../../page-header/useTitle' -import PatientRepository from '../../../clients/db/PatientRepository' +import GeneralInformation from '../../../patients/GeneralInformation' +import NewPatient from '../../../patients/new/NewPatient' +import * as patientSlice from '../../../patients/patient-slice' import { RootState } from '../../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/notes/NewNoteModal.test.tsx b/src/__tests__/patients/notes/NewNoteModal.test.tsx index b0cb9e8c7a..ba9a4abd7d 100644 --- a/src/__tests__/patients/notes/NewNoteModal.test.tsx +++ b/src/__tests__/patients/notes/NewNoteModal.test.tsx @@ -1,16 +1,18 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' -import NewNoteModal from 'patients/notes/NewNoteModal' -import { mount } from 'enzyme' + import { Alert, Modal } from '@hospitalrun/components' import { act } from '@testing-library/react' -import TextFieldWithLabelFormGroup from 'components/input/TextFieldWithLabelFormGroup' +import { mount } from 'enzyme' +import React from 'react' +import { Provider } from 'react-redux' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import { Provider } from 'react-redux' -import * as patientSlice from '../../../patients/patient-slice' + import PatientRepository from '../../../clients/db/PatientRepository' +import TextFieldWithLabelFormGroup from '../../../components/input/TextFieldWithLabelFormGroup' import Patient from '../../../model/Patient' +import NewNoteModal from '../../../patients/notes/NewNoteModal' +import * as patientSlice from '../../../patients/patient-slice' import { RootState } from '../../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/notes/NotesTab.test.tsx b/src/__tests__/patients/notes/NotesTab.test.tsx index 5937d26cd4..b4191e03ae 100644 --- a/src/__tests__/patients/notes/NotesTab.test.tsx +++ b/src/__tests__/patients/notes/NotesTab.test.tsx @@ -1,18 +1,20 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' -import PatientRepository from 'clients/db/PatientRepository' -import Note from 'model/Note' + +import * as components from '@hospitalrun/components' +import { mount } from 'enzyme' import { createMemoryHistory } from 'history' +import React from 'react' +import { act } from 'react-dom/test-utils' +import { Provider } from 'react-redux' +import { Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' -import Patient from 'model/Patient' import thunk from 'redux-thunk' -import { mount } from 'enzyme' -import { Router } from 'react-router-dom' -import { Provider } from 'react-redux' -import NoteTab from 'patients/notes/NoteTab' -import * as components from '@hospitalrun/components' -import { act } from 'react-dom/test-utils' + +import PatientRepository from '../../../clients/db/PatientRepository' +import Note from '../../../model/Note' +import Patient from '../../../model/Patient' import Permissions from '../../../model/Permissions' +import NoteTab from '../../../patients/notes/NoteTab' import { RootState } from '../../../store' const expectedPatient = { diff --git a/src/__tests__/patients/patient-slice.test.ts b/src/__tests__/patients/patient-slice.test.ts index dba7899dcd..f49ca7caa1 100644 --- a/src/__tests__/patients/patient-slice.test.ts +++ b/src/__tests__/patients/patient-slice.test.ts @@ -1,9 +1,15 @@ import '../../__mocks__/matchMediaMock' + +import { addDays } from 'date-fns' import { AnyAction } from 'redux' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import { addDays } from 'date-fns' -import * as uuid from '../../util/uuid' + +import PatientRepository from '../../clients/db/PatientRepository' +import Allergy from '../../model/Allergy' +import Diagnosis from '../../model/Diagnosis' +import Patient from '../../model/Patient' +import RelatedPerson from '../../model/RelatedPerson' import patient, { fetchPatientStart, fetchPatientSuccess, @@ -24,12 +30,8 @@ import patient, { addDiagnosisError, addRelatedPersonError, } from '../../patients/patient-slice' -import Patient from '../../model/Patient' -import PatientRepository from '../../clients/db/PatientRepository' import { RootState } from '../../store' -import RelatedPerson from '../../model/RelatedPerson' -import Diagnosis from '../../model/Diagnosis' -import Allergy from '../../model/Allergy' +import * as uuid from '../../util/uuid' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/patients-slice.test.ts b/src/__tests__/patients/patients-slice.test.ts index b0f32778a5..bbf1efd90b 100644 --- a/src/__tests__/patients/patients-slice.test.ts +++ b/src/__tests__/patients/patients-slice.test.ts @@ -1,13 +1,15 @@ import '../../__mocks__/matchMediaMock' + import { AnyAction } from 'redux' import { mocked } from 'ts-jest/utils' + +import PatientRepository from '../../clients/db/PatientRepository' +import Patient from '../../model/Patient' import patients, { fetchPatientsStart, fetchPatientsSuccess, searchPatients, } from '../../patients/patients-slice' -import Patient from '../../model/Patient' -import PatientRepository from '../../clients/db/PatientRepository' describe('patients slice', () => { beforeEach(() => { diff --git a/src/__tests__/patients/related-persons/AddRelatedPersonModal.test.tsx b/src/__tests__/patients/related-persons/AddRelatedPersonModal.test.tsx index 69342ae725..37f65a319f 100644 --- a/src/__tests__/patients/related-persons/AddRelatedPersonModal.test.tsx +++ b/src/__tests__/patients/related-persons/AddRelatedPersonModal.test.tsx @@ -1,16 +1,18 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' -import { ReactWrapper, mount } from 'enzyme' + import { Modal, Alert, Typeahead } from '@hospitalrun/components' import { act } from '@testing-library/react' +import { ReactWrapper, mount } from 'enzyme' +import React from 'react' import { Provider } from 'react-redux' -import thunk from 'redux-thunk' import createMockStore, { MockStore } from 'redux-mock-store' -import Patient from 'model/Patient' +import thunk from 'redux-thunk' + +import PatientRepository from '../../../clients/db/PatientRepository' import TextInputWithLabelFormGroup from '../../../components/input/TextInputWithLabelFormGroup' -import AddRelatedPersonModal from '../../../patients/related-persons/AddRelatedPersonModal' +import Patient from '../../../model/Patient' import * as patientSlice from '../../../patients/patient-slice' -import PatientRepository from '../../../clients/db/PatientRepository' +import AddRelatedPersonModal from '../../../patients/related-persons/AddRelatedPersonModal' import { RootState } from '../../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/related-persons/RelatedPersons.test.tsx b/src/__tests__/patients/related-persons/RelatedPersons.test.tsx index 9b427de8ca..2beacd71b9 100644 --- a/src/__tests__/patients/related-persons/RelatedPersons.test.tsx +++ b/src/__tests__/patients/related-persons/RelatedPersons.test.tsx @@ -1,20 +1,22 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' -import { Router } from 'react-router-dom' -import { createMemoryHistory } from 'history' -import { mount } from 'enzyme' -import RelatedPersonTab from 'patients/related-persons/RelatedPersonTab' + import * as components from '@hospitalrun/components' -import AddRelatedPersonModal from 'patients/related-persons/AddRelatedPersonModal' import { act } from '@testing-library/react' -import PatientRepository from 'clients/db/PatientRepository' -import Patient from 'model/Patient' +import { mount } from 'enzyme' +import { createMemoryHistory } from 'history' +import React from 'react' +import { Provider } from 'react-redux' +import { Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import { Provider } from 'react-redux' -import Permissions from 'model/Permissions' -import RelatedPerson from 'model/RelatedPerson' + +import PatientRepository from '../../../clients/db/PatientRepository' +import Patient from '../../../model/Patient' +import Permissions from '../../../model/Permissions' +import RelatedPerson from '../../../model/RelatedPerson' import * as patientSlice from '../../../patients/patient-slice' +import AddRelatedPersonModal from '../../../patients/related-persons/AddRelatedPersonModal' +import RelatedPersonTab from '../../../patients/related-persons/RelatedPersonTab' import { RootState } from '../../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/util/patient-name-util.test.ts b/src/__tests__/patients/util/patient-name-util.test.ts index bc65a1289c..ef668c36fd 100644 --- a/src/__tests__/patients/util/patient-name-util.test.ts +++ b/src/__tests__/patients/util/patient-name-util.test.ts @@ -1,5 +1,5 @@ -import { getPatientFullName, getPatientName } from 'patients/util/patient-name-util' -import Patient from 'model/Patient' +import Patient from '../../../model/Patient' +import { getPatientFullName, getPatientName } from '../../../patients/util/patient-name-util' describe('patient name util', () => { describe('getPatientName', () => { diff --git a/src/__tests__/patients/view/ViewPatient.test.tsx b/src/__tests__/patients/view/ViewPatient.test.tsx index 8a0d3dd815..71207f49bd 100644 --- a/src/__tests__/patients/view/ViewPatient.test.tsx +++ b/src/__tests__/patients/view/ViewPatient.test.tsx @@ -1,28 +1,30 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' -import { Provider } from 'react-redux' + +import { TabsHeader, Tab } from '@hospitalrun/components' import { mount } from 'enzyme' -import { mocked } from 'ts-jest/utils' +import { createMemoryHistory } from 'history' +import React from 'react' import { act } from 'react-dom/test-utils' +import { Provider } from 'react-redux' import { Route, Router } from 'react-router-dom' -import { TabsHeader, Tab } from '@hospitalrun/components' import createMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' -import GeneralInformation from 'patients/GeneralInformation' -import { createMemoryHistory } from 'history' -import RelatedPersonTab from 'patients/related-persons/RelatedPersonTab' -import * as ButtonBarProvider from 'page-header/ButtonBarProvider' -import Allergies from 'patients/allergies/Allergies' -import Diagnoses from 'patients/diagnoses/Diagnoses' -import NotesTab from 'patients/notes/NoteTab' -import Patient from '../../../model/Patient' +import { mocked } from 'ts-jest/utils' + +import LabRepository from '../../../clients/db/LabRepository' import PatientRepository from '../../../clients/db/PatientRepository' -import * as titleUtil from '../../../page-header/useTitle' -import ViewPatient from '../../../patients/view/ViewPatient' -import * as patientSlice from '../../../patients/patient-slice' +import Patient from '../../../model/Patient' import Permissions from '../../../model/Permissions' +import * as ButtonBarProvider from '../../../page-header/ButtonBarProvider' +import * as titleUtil from '../../../page-header/useTitle' +import Allergies from '../../../patients/allergies/Allergies' +import Diagnoses from '../../../patients/diagnoses/Diagnoses' +import GeneralInformation from '../../../patients/GeneralInformation' import LabsTab from '../../../patients/labs/LabsTab' -import LabRepository from '../../../clients/db/LabRepository' +import NotesTab from '../../../patients/notes/NoteTab' +import * as patientSlice from '../../../patients/patient-slice' +import RelatedPersonTab from '../../../patients/related-persons/RelatedPersonTab' +import ViewPatient from '../../../patients/view/ViewPatient' import { RootState } from '../../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/scheduling/appointments/AppointmentDetailForm.test.tsx b/src/__tests__/scheduling/appointments/AppointmentDetailForm.test.tsx index 27828f2ce3..3b57080793 100644 --- a/src/__tests__/scheduling/appointments/AppointmentDetailForm.test.tsx +++ b/src/__tests__/scheduling/appointments/AppointmentDetailForm.test.tsx @@ -1,13 +1,15 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' -import { mount, ReactWrapper } from 'enzyme' -import AppointmentDetailForm from 'scheduling/appointments/AppointmentDetailForm' -import Appointment from 'model/Appointment' -import { roundToNearestMinutes, addMinutes } from 'date-fns' + import { Typeahead, Alert } from '@hospitalrun/components' -import PatientRepository from 'clients/db/PatientRepository' -import Patient from 'model/Patient' import { act } from '@testing-library/react' +import { roundToNearestMinutes, addMinutes } from 'date-fns' +import { mount, ReactWrapper } from 'enzyme' +import React from 'react' + +import PatientRepository from '../../../clients/db/PatientRepository' +import Appointment from '../../../model/Appointment' +import Patient from '../../../model/Patient' +import AppointmentDetailForm from '../../../scheduling/appointments/AppointmentDetailForm' describe('AppointmentDetailForm', () => { describe('Error handling', () => { diff --git a/src/__tests__/scheduling/appointments/Appointments.test.tsx b/src/__tests__/scheduling/appointments/Appointments.test.tsx index c9c1fadf72..02d42fd37f 100644 --- a/src/__tests__/scheduling/appointments/Appointments.test.tsx +++ b/src/__tests__/scheduling/appointments/Appointments.test.tsx @@ -1,22 +1,24 @@ import '../../../__mocks__/matchMediaMock' + +import { mount } from 'enzyme' import React from 'react' +import { act } from 'react-dom/test-utils' import { Provider } from 'react-redux' -import { MemoryRouter } from 'react-router' +import { MemoryRouter } from 'react-router-dom' import createMockStore from 'redux-mock-store' -import { mount } from 'enzyme' import thunk from 'redux-thunk' -import { act } from 'react-dom/test-utils' -import NewAppointment from 'scheduling/appointments/new/NewAppointment' -import EditAppointment from 'scheduling/appointments/edit/EditAppointment' -import ViewAppointments from 'scheduling/appointments/ViewAppointments' -import Permissions from '../../../model/Permissions' -import HospitalRun from '../../../HospitalRun' + import { addBreadcrumbs } from '../../../breadcrumbs/breadcrumbs-slice' -import Dashboard from '../../../dashboard/Dashboard' -import PatientRepository from '../../../clients/db/PatientRepository' import AppointmentRepository from '../../../clients/db/AppointmentRepository' -import Patient from '../../../model/Patient' +import PatientRepository from '../../../clients/db/PatientRepository' +import Dashboard from '../../../dashboard/Dashboard' +import HospitalRun from '../../../HospitalRun' import Appointment from '../../../model/Appointment' +import Patient from '../../../model/Patient' +import Permissions from '../../../model/Permissions' +import EditAppointment from '../../../scheduling/appointments/edit/EditAppointment' +import NewAppointment from '../../../scheduling/appointments/new/NewAppointment' +import ViewAppointments from '../../../scheduling/appointments/ViewAppointments' import { RootState } from '../../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/scheduling/appointments/ViewAppointments.test.tsx b/src/__tests__/scheduling/appointments/ViewAppointments.test.tsx index 597519aee7..57c1bbc1eb 100644 --- a/src/__tests__/scheduling/appointments/ViewAppointments.test.tsx +++ b/src/__tests__/scheduling/appointments/ViewAppointments.test.tsx @@ -1,20 +1,22 @@ import '../../../__mocks__/matchMediaMock' -import React from 'react' + +import { Calendar } from '@hospitalrun/components' +import { act } from '@testing-library/react' import { mount } from 'enzyme' -import { MemoryRouter } from 'react-router-dom' +import React from 'react' import { Provider } from 'react-redux' -import ViewAppointments from 'scheduling/appointments/ViewAppointments' +import { MemoryRouter } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import { Calendar } from '@hospitalrun/components' -import { act } from '@testing-library/react' -import PatientRepository from 'clients/db/PatientRepository' import { mocked } from 'ts-jest/utils' -import Patient from 'model/Patient' -import * as ButtonBarProvider from 'page-header/ButtonBarProvider' -import AppointmentRepository from 'clients/db/AppointmentRepository' -import Appointment from 'model/Appointment' + +import AppointmentRepository from '../../../clients/db/AppointmentRepository' +import PatientRepository from '../../../clients/db/PatientRepository' +import Appointment from '../../../model/Appointment' +import Patient from '../../../model/Patient' +import * as ButtonBarProvider from '../../../page-header/ButtonBarProvider' import * as titleUtil from '../../../page-header/useTitle' +import ViewAppointments from '../../../scheduling/appointments/ViewAppointments' import { RootState } from '../../../store' describe('ViewAppointments', () => { diff --git a/src/__tests__/scheduling/appointments/appointment-slice.test.ts b/src/__tests__/scheduling/appointments/appointment-slice.test.ts index 50c8ecedbd..428c95be1e 100644 --- a/src/__tests__/scheduling/appointments/appointment-slice.test.ts +++ b/src/__tests__/scheduling/appointments/appointment-slice.test.ts @@ -1,12 +1,13 @@ import '../../../__mocks__/matchMediaMock' + +import { subDays } from 'date-fns' import { AnyAction } from 'redux' -import Appointment from 'model/Appointment' -import AppointmentRepository from 'clients/db/AppointmentRepository' import { mocked } from 'ts-jest/utils' -import PatientRepository from 'clients/db/PatientRepository' -import Patient from 'model/Patient' -import { subDays } from 'date-fns' +import AppointmentRepository from '../../../clients/db/AppointmentRepository' +import PatientRepository from '../../../clients/db/PatientRepository' +import Appointment from '../../../model/Appointment' +import Patient from '../../../model/Patient' import appointment, { fetchAppointmentStart, fetchAppointmentSuccess, diff --git a/src/__tests__/scheduling/appointments/appointments-slice.test.ts b/src/__tests__/scheduling/appointments/appointments-slice.test.ts index bb40a08644..46272dd887 100644 --- a/src/__tests__/scheduling/appointments/appointments-slice.test.ts +++ b/src/__tests__/scheduling/appointments/appointments-slice.test.ts @@ -1,8 +1,8 @@ import { AnyAction } from 'redux' import { mocked } from 'ts-jest/utils' -import Appointment from 'model/Appointment' -import AppointmentRepository from 'clients/db/AppointmentRepository' +import AppointmentRepository from '../../../clients/db/AppointmentRepository' +import Appointment from '../../../model/Appointment' import appointments, { fetchAppointmentsStart, fetchAppointmentsSuccess, diff --git a/src/__tests__/scheduling/appointments/edit/EditAppointment.test.tsx b/src/__tests__/scheduling/appointments/edit/EditAppointment.test.tsx index 728b092ea7..c8a006b06f 100644 --- a/src/__tests__/scheduling/appointments/edit/EditAppointment.test.tsx +++ b/src/__tests__/scheduling/appointments/edit/EditAppointment.test.tsx @@ -1,23 +1,25 @@ import '../../../../__mocks__/matchMediaMock' -import React from 'react' + +import { Button } from '@hospitalrun/components' +import { roundToNearestMinutes, addMinutes } from 'date-fns' import { mount } from 'enzyme' -import { Router, Route } from 'react-router-dom' -import { Provider } from 'react-redux' -import { mocked } from 'ts-jest/utils' import { createMemoryHistory } from 'history' +import React from 'react' import { act } from 'react-dom/test-utils' +import { Provider } from 'react-redux' +import { Router, Route } from 'react-router-dom' import createMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' -import { roundToNearestMinutes, addMinutes } from 'date-fns' -import { Button } from '@hospitalrun/components' -import EditAppointment from '../../../../scheduling/appointments/edit/EditAppointment' -import AppointmentDetailForm from '../../../../scheduling/appointments/AppointmentDetailForm' +import { mocked } from 'ts-jest/utils' + +import AppointmentRepository from '../../../../clients/db/AppointmentRepository' +import PatientRepository from '../../../../clients/db/PatientRepository' import Appointment from '../../../../model/Appointment' import Patient from '../../../../model/Patient' import * as titleUtil from '../../../../page-header/useTitle' import * as appointmentSlice from '../../../../scheduling/appointments/appointment-slice' -import AppointmentRepository from '../../../../clients/db/AppointmentRepository' -import PatientRepository from '../../../../clients/db/PatientRepository' +import AppointmentDetailForm from '../../../../scheduling/appointments/AppointmentDetailForm' +import EditAppointment from '../../../../scheduling/appointments/edit/EditAppointment' import { RootState } from '../../../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/scheduling/appointments/new/NewAppointment.test.tsx b/src/__tests__/scheduling/appointments/new/NewAppointment.test.tsx index 6c08dcbde4..6da7e26ec1 100644 --- a/src/__tests__/scheduling/appointments/new/NewAppointment.test.tsx +++ b/src/__tests__/scheduling/appointments/new/NewAppointment.test.tsx @@ -1,24 +1,26 @@ import '../../../../__mocks__/matchMediaMock' -import React from 'react' -import NewAppointment from 'scheduling/appointments/new/NewAppointment' -import { Router, Route } from 'react-router-dom' -import { Provider } from 'react-redux' -import { mount } from 'enzyme' + +import * as components from '@hospitalrun/components' +import { act } from '@testing-library/react' import { roundToNearestMinutes, addMinutes } from 'date-fns' +import { mount } from 'enzyme' import { createMemoryHistory, MemoryHistory } from 'history' -import { act } from '@testing-library/react' -import AppointmentRepository from 'clients/db/AppointmentRepository' -import { mocked } from 'ts-jest/utils' +import React from 'react' +import { Provider } from 'react-redux' +import { Router, Route } from 'react-router-dom' import createMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' -import Appointment from 'model/Appointment' -import Patient from 'model/Patient' -import AppointmentDetailForm from 'scheduling/appointments/AppointmentDetailForm' -import * as components from '@hospitalrun/components' -import * as titleUtil from '../../../../page-header/useTitle' -import * as appointmentSlice from '../../../../scheduling/appointments/appointment-slice' +import { mocked } from 'ts-jest/utils' + +import AppointmentRepository from '../../../../clients/db/AppointmentRepository' import LabRepository from '../../../../clients/db/LabRepository' +import Appointment from '../../../../model/Appointment' import Lab from '../../../../model/Lab' +import Patient from '../../../../model/Patient' +import * as titleUtil from '../../../../page-header/useTitle' +import * as appointmentSlice from '../../../../scheduling/appointments/appointment-slice' +import AppointmentDetailForm from '../../../../scheduling/appointments/AppointmentDetailForm' +import NewAppointment from '../../../../scheduling/appointments/new/NewAppointment' import { RootState } from '../../../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/scheduling/appointments/util/scheduling-appointment.util.test.ts b/src/__tests__/scheduling/appointments/util/scheduling-appointment.util.test.ts index 292e71cd9d..9f248451f1 100644 --- a/src/__tests__/scheduling/appointments/util/scheduling-appointment.util.test.ts +++ b/src/__tests__/scheduling/appointments/util/scheduling-appointment.util.test.ts @@ -1,4 +1,4 @@ -import Appointment from 'model/Appointment' +import Appointment from '../../../../model/Appointment' import { getAppointmentLabel } from '../../../../scheduling/appointments/util/scheduling-appointment.util' describe('scheduling appointment util', () => { diff --git a/src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx b/src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx index 9e1cd8d7df..15de39ed57 100644 --- a/src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx +++ b/src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx @@ -1,24 +1,26 @@ import '../../../../__mocks__/matchMediaMock' -import React from 'react' + +import * as components from '@hospitalrun/components' import { mount } from 'enzyme' +import { createMemoryHistory } from 'history' +import React from 'react' +import { act } from 'react-dom/test-utils' import { Provider } from 'react-redux' +import { Router, Route } from 'react-router-dom' import createMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' -import Appointment from 'model/Appointment' -import ViewAppointment from 'scheduling/appointments/view/ViewAppointment' -import { Router, Route } from 'react-router-dom' -import { createMemoryHistory } from 'history' -import AppointmentRepository from 'clients/db/AppointmentRepository' import { mocked } from 'ts-jest/utils' -import { act } from 'react-dom/test-utils' -import * as components from '@hospitalrun/components' -import AppointmentDetailForm from 'scheduling/appointments/AppointmentDetailForm' -import PatientRepository from 'clients/db/PatientRepository' -import Patient from 'model/Patient' -import * as ButtonBarProvider from 'page-header/ButtonBarProvider' -import Permissions from 'model/Permissions' + +import AppointmentRepository from '../../../../clients/db/AppointmentRepository' +import PatientRepository from '../../../../clients/db/PatientRepository' +import Appointment from '../../../../model/Appointment' +import Patient from '../../../../model/Patient' +import Permissions from '../../../../model/Permissions' +import * as ButtonBarProvider from '../../../../page-header/ButtonBarProvider' import * as titleUtil from '../../../../page-header/useTitle' import * as appointmentSlice from '../../../../scheduling/appointments/appointment-slice' +import AppointmentDetailForm from '../../../../scheduling/appointments/AppointmentDetailForm' +import ViewAppointment from '../../../../scheduling/appointments/view/ViewAppointment' import { RootState } from '../../../../store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/user/user-slice.test.ts b/src/__tests__/user/user-slice.test.ts index 71ce829406..ec13b46bb4 100644 --- a/src/__tests__/user/user-slice.test.ts +++ b/src/__tests__/user/user-slice.test.ts @@ -1,5 +1,5 @@ -import user, { fetchPermissions } from '../../user/user-slice' import Permissions from '../../model/Permissions' +import user, { fetchPermissions } from '../../user/user-slice' describe('user slice', () => { it('should handle the FETCH_PERMISSIONS action', () => { diff --git a/src/breadcrumbs/Breadcrumbs.tsx b/src/breadcrumbs/Breadcrumbs.tsx index 17e5d7bc31..665c13fc5f 100644 --- a/src/breadcrumbs/Breadcrumbs.tsx +++ b/src/breadcrumbs/Breadcrumbs.tsx @@ -1,8 +1,9 @@ +import { Breadcrumb, BreadcrumbItem } from '@hospitalrun/components' import React from 'react' -import { useHistory } from 'react-router-dom' -import { useSelector } from 'react-redux' import { useTranslation } from 'react-i18next' -import { Breadcrumb, BreadcrumbItem } from '@hospitalrun/components' +import { useSelector } from 'react-redux' +import { useHistory } from 'react-router-dom' + import { RootState } from '../store' const Breadcrumbs = () => { diff --git a/src/breadcrumbs/breadcrumbs-slice.ts b/src/breadcrumbs/breadcrumbs-slice.ts index 86a689e0d8..5785326efd 100644 --- a/src/breadcrumbs/breadcrumbs-slice.ts +++ b/src/breadcrumbs/breadcrumbs-slice.ts @@ -1,5 +1,6 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' -import Breadcrumb from 'model/Breadcrumb' + +import Breadcrumb from '../model/Breadcrumb' interface BreadcrumbsState { breadcrumbs: Breadcrumb[] diff --git a/src/breadcrumbs/useAddBreadcrumbs.ts b/src/breadcrumbs/useAddBreadcrumbs.ts index 76d68e80ce..f3822cecf1 100644 --- a/src/breadcrumbs/useAddBreadcrumbs.ts +++ b/src/breadcrumbs/useAddBreadcrumbs.ts @@ -1,6 +1,7 @@ import { useEffect } from 'react' import { useDispatch } from 'react-redux' -import Breadcrumb from 'model/Breadcrumb' + +import Breadcrumb from '../model/Breadcrumb' import { addBreadcrumbs, removeBreadcrumbs } from './breadcrumbs-slice' export default function useAddBreadcrumbs(breadcrumbs: Breadcrumb[], withDashboard = false): void { diff --git a/src/clients/db/AppointmentRepository.ts b/src/clients/db/AppointmentRepository.ts index 42ba8dce42..0aebe2504e 100644 --- a/src/clients/db/AppointmentRepository.ts +++ b/src/clients/db/AppointmentRepository.ts @@ -1,9 +1,10 @@ import escapeStringRegexp from 'escape-string-regexp' -import Appointment from 'model/Appointment' -import { appointments } from 'config/pouchdb' + +import { appointments } from '../../config/pouchdb' +import Appointment from '../../model/Appointment' import Repository from './Repository' -export class AppointmentRepository extends Repository { +class AppointmentRepository extends Repository { constructor() { super(appointments) } diff --git a/src/clients/db/IncidentRepository.ts b/src/clients/db/IncidentRepository.ts index ca3cfd6894..204309a0c2 100644 --- a/src/clients/db/IncidentRepository.ts +++ b/src/clients/db/IncidentRepository.ts @@ -1,8 +1,8 @@ -import Repository from './Repository' import { incidents } from '../../config/pouchdb' import Incident from '../../model/Incident' +import Repository from './Repository' -export class IncidentRepository extends Repository { +class IncidentRepository extends Repository { constructor() { super(incidents) } diff --git a/src/clients/db/LabRepository.ts b/src/clients/db/LabRepository.ts index 3581c96e12..fd4aaf0fab 100644 --- a/src/clients/db/LabRepository.ts +++ b/src/clients/db/LabRepository.ts @@ -1,7 +1,7 @@ -import Lab from 'model/Lab' +import { labs } from '../../config/pouchdb' +import Lab from '../../model/Lab' import generateCode from '../../util/generateCode' import Repository from './Repository' -import { labs } from '../../config/pouchdb' import SortRequest from './SortRequest' interface SearchContainer { @@ -9,7 +9,7 @@ interface SearchContainer { status: 'requested' | 'completed' | 'canceled' | 'all' defaultSortRequest: SortRequest } -export class LabRepository extends Repository { +class LabRepository extends Repository { constructor() { super(labs) } diff --git a/src/clients/db/PatientRepository.ts b/src/clients/db/PatientRepository.ts index 172e380a7f..7bc53884ef 100644 --- a/src/clients/db/PatientRepository.ts +++ b/src/clients/db/PatientRepository.ts @@ -1,10 +1,11 @@ import escapeStringRegexp from 'escape-string-regexp' + +import { patients } from '../../config/pouchdb' import Patient from '../../model/Patient' import generateCode from '../../util/generateCode' import Repository from './Repository' -import { patients } from '../../config/pouchdb' -export class PatientRepository extends Repository { +class PatientRepository extends Repository { constructor() { super(patients) } diff --git a/src/clients/db/Repository.ts b/src/clients/db/Repository.ts index df56a1d3a9..895dcc0ffe 100644 --- a/src/clients/db/Repository.ts +++ b/src/clients/db/Repository.ts @@ -1,5 +1,6 @@ /* eslint "@typescript-eslint/camelcase": "off" */ import { v4 as uuidv4 } from 'uuid' + import AbstractDBModel from '../../model/AbstractDBModel' import SortRequest, { Unsorted } from './SortRequest' diff --git a/src/clients/db/SortRequest.ts b/src/clients/db/SortRequest.ts index 3079fd01c5..fde109b2cd 100644 --- a/src/clients/db/SortRequest.ts +++ b/src/clients/db/SortRequest.ts @@ -1,4 +1,4 @@ -import Sort from 'clients/Sort' +import Sort from '../Sort' export default interface SortRequest { sorts: Sort[] diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 01c69d9a65..ebf576ae79 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -1,7 +1,7 @@ -import React from 'react' -import { useHistory } from 'react-router-dom' import { Navbar as HospitalRunNavbar } from '@hospitalrun/components' +import React from 'react' import { useTranslation } from 'react-i18next' +import { useHistory } from 'react-router-dom' const Navbar = () => { const { t } = useTranslation() diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index ac46bde603..f6b6436f17 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -1,8 +1,9 @@ -import React, { useState, CSSProperties } from 'react' import { List, ListItem, Icon } from '@hospitalrun/components' +import React, { useState, CSSProperties } from 'react' import { useTranslation } from 'react-i18next' -import { useLocation, useHistory } from 'react-router-dom' import { useSelector, useDispatch } from 'react-redux' +import { useLocation, useHistory } from 'react-router-dom' + import { RootState } from '../store' import { updateSidebar } from './component-slice' diff --git a/src/components/component-slice.ts b/src/components/component-slice.ts index 62a6aeeefe..5eb7d61857 100644 --- a/src/components/component-slice.ts +++ b/src/components/component-slice.ts @@ -1,4 +1,5 @@ import { createSlice } from '@reduxjs/toolkit' + import { AppThunk } from '../store' interface ComponentState { diff --git a/src/components/input/DatePickerWithLabelFormGroup.tsx b/src/components/input/DatePickerWithLabelFormGroup.tsx index ea9b923fc0..a2b15d6b69 100644 --- a/src/components/input/DatePickerWithLabelFormGroup.tsx +++ b/src/components/input/DatePickerWithLabelFormGroup.tsx @@ -1,5 +1,5 @@ -import React from 'react' import { Label, DateTimePicker } from '@hospitalrun/components' +import React from 'react' interface Props { name: string diff --git a/src/components/input/DateTimePickerWithLabelFormGroup.tsx b/src/components/input/DateTimePickerWithLabelFormGroup.tsx index ea9d3896d3..d511144408 100644 --- a/src/components/input/DateTimePickerWithLabelFormGroup.tsx +++ b/src/components/input/DateTimePickerWithLabelFormGroup.tsx @@ -1,5 +1,5 @@ -import React from 'react' import { Label, DateTimePicker } from '@hospitalrun/components' +import React from 'react' interface Props { name: string diff --git a/src/components/input/SelectWithLableFormGroup.tsx b/src/components/input/SelectWithLableFormGroup.tsx index e7451d1e43..be9874aca1 100644 --- a/src/components/input/SelectWithLableFormGroup.tsx +++ b/src/components/input/SelectWithLableFormGroup.tsx @@ -1,5 +1,5 @@ -import React from 'react' import { Label, Select } from '@hospitalrun/components' +import React from 'react' interface Option { label: string diff --git a/src/components/input/TextFieldWithLabelFormGroup.tsx b/src/components/input/TextFieldWithLabelFormGroup.tsx index 3848ddf02a..5fcd4b4863 100644 --- a/src/components/input/TextFieldWithLabelFormGroup.tsx +++ b/src/components/input/TextFieldWithLabelFormGroup.tsx @@ -1,5 +1,5 @@ -import React from 'react' import { TextField, Label } from '@hospitalrun/components' +import React from 'react' interface Props { value: string diff --git a/src/components/input/TextInputWithLabelFormGroup.tsx b/src/components/input/TextInputWithLabelFormGroup.tsx index 2e68c196d6..0cb7efb972 100644 --- a/src/components/input/TextInputWithLabelFormGroup.tsx +++ b/src/components/input/TextInputWithLabelFormGroup.tsx @@ -1,5 +1,5 @@ -import React from 'react' import { TextInput, Label } from '@hospitalrun/components' +import React from 'react' interface Props { value: string diff --git a/src/dashboard/Dashboard.tsx b/src/dashboard/Dashboard.tsx index bf295875dc..8a26e4df9e 100644 --- a/src/dashboard/Dashboard.tsx +++ b/src/dashboard/Dashboard.tsx @@ -1,5 +1,6 @@ import React from 'react' import { useTranslation } from 'react-i18next' + import useTitle from '../page-header/useTitle' const Dashboard: React.FC = () => { diff --git a/src/i18n.ts b/src/i18n.ts index b237cb7da6..91e580f582 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -8,11 +8,11 @@ import translationEnUs from './locales/enUs/translations' import translationES from './locales/es/translations' import translationFR from './locales/fr/translations' import translationIN from './locales/in/translations' +import translationIT from './locales/it/translations' import translationJA from './locales/ja/translations' import translationPtBR from './locales/ptBr/translations' import translationRU from './locales/ru/translations' import translationZR from './locales/zr/translations' -import translationIT from './locales/it/translations' const resources = { it: { diff --git a/src/incidents/Incidents.tsx b/src/incidents/Incidents.tsx index fef38887e8..59d3a9cd0b 100644 --- a/src/incidents/Incidents.tsx +++ b/src/incidents/Incidents.tsx @@ -1,13 +1,14 @@ import React from 'react' -import { Switch } from 'react-router' import { useSelector } from 'react-redux' +import { Switch } from 'react-router-dom' + +import useAddBreadcrumbs from '../breadcrumbs/useAddBreadcrumbs' import PrivateRoute from '../components/PrivateRoute' -import { RootState } from '../store' import Permissions from '../model/Permissions' +import { RootState } from '../store' import ViewIncidents from './list/ViewIncidents' import ReportIncident from './report/ReportIncident' import ViewIncident from './view/ViewIncident' -import useAddBreadcrumbs from '../breadcrumbs/useAddBreadcrumbs' const Incidents = () => { const { permissions } = useSelector((state: RootState) => state.user) diff --git a/src/incidents/incident-slice.ts b/src/incidents/incident-slice.ts index dde9e43a18..dfb445c3d7 100644 --- a/src/incidents/incident-slice.ts +++ b/src/incidents/incident-slice.ts @@ -1,10 +1,11 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' -import { AppThunk } from 'store' import { isAfter } from 'date-fns' import { isEmpty } from 'lodash' import shortid from 'shortid' -import Incident from '../model/Incident' + import IncidentRepository from '../clients/db/IncidentRepository' +import Incident from '../model/Incident' +import { AppThunk } from '../store' interface Error { date?: string diff --git a/src/incidents/incidents-slice.ts b/src/incidents/incidents-slice.ts index 377af0faab..b83bef38a2 100644 --- a/src/incidents/incidents-slice.ts +++ b/src/incidents/incidents-slice.ts @@ -1,7 +1,8 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' -import { AppThunk } from 'store' -import Incident from '../model/Incident' + import IncidentRepository from '../clients/db/IncidentRepository' +import Incident from '../model/Incident' +import { AppThunk } from '../store' interface IncidentsState { incidents: Incident[] diff --git a/src/incidents/list/ViewIncidents.tsx b/src/incidents/list/ViewIncidents.tsx index 464e1f769d..4c97158ba8 100644 --- a/src/incidents/list/ViewIncidents.tsx +++ b/src/incidents/list/ViewIncidents.tsx @@ -1,12 +1,13 @@ +import format from 'date-fns/format' import React, { useEffect } from 'react' import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' -import format from 'date-fns/format' -import { useHistory } from 'react-router' +import { useHistory } from 'react-router-dom' + +import Incident from '../../model/Incident' import useTitle from '../../page-header/useTitle' import { RootState } from '../../store' import { fetchIncidents } from '../incidents-slice' -import Incident from '../../model/Incident' const ViewIncidents = () => { const { t } = useTranslation() diff --git a/src/incidents/report/ReportIncident.tsx b/src/incidents/report/ReportIncident.tsx index a80b984af3..d7eeb35f45 100644 --- a/src/incidents/report/ReportIncident.tsx +++ b/src/incidents/report/ReportIncident.tsx @@ -1,16 +1,17 @@ +import { Button, Row, Column } from '@hospitalrun/components' import React, { useState } from 'react' import { useTranslation } from 'react-i18next' -import { Button, Row, Column } from '@hospitalrun/components' -import { useHistory } from 'react-router' import { useDispatch, useSelector } from 'react-redux' -import useTitle from '../../page-header/useTitle' +import { useHistory } from 'react-router-dom' + import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' import DateTimePickerWithLabelFormGroup from '../../components/input/DateTimePickerWithLabelFormGroup' import TextFieldWithLabelFormGroup from '../../components/input/TextFieldWithLabelFormGroup' import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup' -import { reportIncident } from '../incident-slice' import Incident from '../../model/Incident' +import useTitle from '../../page-header/useTitle' import { RootState } from '../../store' +import { reportIncident } from '../incident-slice' const ReportIncident = () => { const dispatch = useDispatch() diff --git a/src/incidents/view/ViewIncident.tsx b/src/incidents/view/ViewIncident.tsx index 87484dc841..fae2e0c7ec 100644 --- a/src/incidents/view/ViewIncident.tsx +++ b/src/incidents/view/ViewIncident.tsx @@ -1,15 +1,16 @@ +import { Column, Row } from '@hospitalrun/components' +import format from 'date-fns/format' import React, { useEffect } from 'react' import { useTranslation } from 'react-i18next' -import { useParams } from 'react-router' import { useDispatch, useSelector } from 'react-redux' -import { Column, Row } from '@hospitalrun/components' -import format from 'date-fns/format' +import { useParams } from 'react-router-dom' + import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' +import TextFieldWithLabelFormGroup from '../../components/input/TextFieldWithLabelFormGroup' +import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup' import useTitle from '../../page-header/useTitle' import { RootState } from '../../store' import { fetchIncident } from '../incident-slice' -import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup' -import TextFieldWithLabelFormGroup from '../../components/input/TextFieldWithLabelFormGroup' const ViewIncident = () => { const dispatch = useDispatch() diff --git a/src/index.tsx b/src/index.tsx index 71b2ba1135..f9549cac06 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,5 +1,6 @@ import React from 'react' import ReactDOM from 'react-dom' + import '@hospitalrun/components/scss/main.scss' import './index.css' import App from './App' diff --git a/src/labs/Labs.tsx b/src/labs/Labs.tsx index 241a75fb59..11252b0383 100644 --- a/src/labs/Labs.tsx +++ b/src/labs/Labs.tsx @@ -1,13 +1,14 @@ import React from 'react' -import PrivateRoute from 'components/PrivateRoute' -import { Switch } from 'react-router-dom' -import useAddBreadcrumbs from 'breadcrumbs/useAddBreadcrumbs' import { useSelector } from 'react-redux' -import Permissions from 'model/Permissions' -import LabRequests from './ViewLabs' +import { Switch } from 'react-router-dom' + +import useAddBreadcrumbs from '../breadcrumbs/useAddBreadcrumbs' +import PrivateRoute from '../components/PrivateRoute' +import Permissions from '../model/Permissions' +import { RootState } from '../store' import NewLabRequest from './requests/NewLabRequest' import ViewLab from './ViewLab' -import { RootState } from '../store' +import LabRequests from './ViewLabs' const Labs = () => { const { permissions } = useSelector((state: RootState) => state.user) diff --git a/src/labs/ViewLab.tsx b/src/labs/ViewLab.tsx index 5768576007..0f654a0dde 100644 --- a/src/labs/ViewLab.tsx +++ b/src/labs/ViewLab.tsx @@ -1,15 +1,16 @@ -import React, { useEffect, useState } from 'react' -import { useParams, useHistory } from 'react-router-dom' +import { Row, Column, Badge, Button, Alert } from '@hospitalrun/components' import format from 'date-fns/format' -import Lab from 'model/Lab' -import Patient from 'model/Patient' -import useTitle from 'page-header/useTitle' +import React, { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' -import { Row, Column, Badge, Button, Alert } from '@hospitalrun/components' -import TextFieldWithLabelFormGroup from 'components/input/TextFieldWithLabelFormGroup' -import useAddBreadcrumbs from 'breadcrumbs/useAddBreadcrumbs' import { useSelector, useDispatch } from 'react-redux' -import Permissions from 'model/Permissions' +import { useParams, useHistory } from 'react-router-dom' + +import useAddBreadcrumbs from '../breadcrumbs/useAddBreadcrumbs' +import TextFieldWithLabelFormGroup from '../components/input/TextFieldWithLabelFormGroup' +import Lab from '../model/Lab' +import Patient from '../model/Patient' +import Permissions from '../model/Permissions' +import useTitle from '../page-header/useTitle' import { RootState } from '../store' import { cancelLab, completeLab, updateLab, fetchLab } from './lab-slice' diff --git a/src/labs/ViewLabs.tsx b/src/labs/ViewLabs.tsx index 70a042d6f8..8587ae4739 100644 --- a/src/labs/ViewLabs.tsx +++ b/src/labs/ViewLabs.tsx @@ -1,18 +1,19 @@ +import { Spinner, Button } from '@hospitalrun/components' +import format from 'date-fns/format' import React, { useState, useEffect, useCallback } from 'react' -import { useSelector, useDispatch } from 'react-redux' -import useTitle from 'page-header/useTitle' import { useTranslation } from 'react-i18next' -import format from 'date-fns/format' -import { useButtonToolbarSetter } from 'page-header/ButtonBarProvider' -import { Spinner, Button } from '@hospitalrun/components' +import { useSelector, useDispatch } from 'react-redux' import { useHistory } from 'react-router-dom' -import Lab from 'model/Lab' -import Permissions from 'model/Permissions' -import SelectWithLabelFormGroup from 'components/input/SelectWithLableFormGroup' -import TextInputWithLabelFormGroup from 'components/input/TextInputWithLabelFormGroup' + +import SelectWithLabelFormGroup from '../components/input/SelectWithLableFormGroup' +import TextInputWithLabelFormGroup from '../components/input/TextInputWithLabelFormGroup' +import useDebounce from '../hooks/debounce' +import Lab from '../model/Lab' +import Permissions from '../model/Permissions' +import { useButtonToolbarSetter } from '../page-header/ButtonBarProvider' +import useTitle from '../page-header/useTitle' import { RootState } from '../store' import { searchLabs } from './labs-slice' -import useDebounce from '../hooks/debounce' type filter = 'requested' | 'completed' | 'canceled' | 'all' diff --git a/src/labs/lab-slice.ts b/src/labs/lab-slice.ts index 224ffbd722..4294448a87 100644 --- a/src/labs/lab-slice.ts +++ b/src/labs/lab-slice.ts @@ -1,9 +1,10 @@ -import Lab from 'model/Lab' -import Patient from 'model/Patient' import { createSlice, PayloadAction } from '@reduxjs/toolkit' -import { AppThunk } from 'store' -import LabRepository from 'clients/db/LabRepository' -import PatientRepository from 'clients/db/PatientRepository' + +import LabRepository from '../clients/db/LabRepository' +import PatientRepository from '../clients/db/PatientRepository' +import Lab from '../model/Lab' +import Patient from '../model/Patient' +import { AppThunk } from '../store' interface Error { result?: string @@ -104,6 +105,7 @@ const validateLabRequest = (newLab: Lab): Error => { export const requestLab = (newLab: Lab, onSuccess?: (lab: Lab) => void): AppThunk => async ( dispatch, + getState, ) => { dispatch(requestLabStart()) @@ -114,6 +116,7 @@ export const requestLab = (newLab: Lab, onSuccess?: (lab: Lab) => void): AppThun } else { newLab.status = 'requested' newLab.requestedOn = new Date(Date.now().valueOf()).toISOString() + newLab.requestedBy = getState().user.user.id const requestedLab = await LabRepository.save(newLab) dispatch(requestLabSuccess(requestedLab)) diff --git a/src/labs/labs-slice.ts b/src/labs/labs-slice.ts index db956992da..2951d739b6 100644 --- a/src/labs/labs-slice.ts +++ b/src/labs/labs-slice.ts @@ -1,7 +1,8 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' -import Lab from '../model/Lab' + import LabRepository from '../clients/db/LabRepository' import SortRequest from '../clients/db/SortRequest' +import Lab from '../model/Lab' import { AppThunk } from '../store' interface LabsState { diff --git a/src/labs/requests/NewLabRequest.tsx b/src/labs/requests/NewLabRequest.tsx index d681a11422..5c34ec865d 100644 --- a/src/labs/requests/NewLabRequest.tsx +++ b/src/labs/requests/NewLabRequest.tsx @@ -1,17 +1,18 @@ +import { Typeahead, Label, Button, Alert } from '@hospitalrun/components' import React, { useState } from 'react' -import useTitle from 'page-header/useTitle' import { useTranslation } from 'react-i18next' -import { Typeahead, Label, Button, Alert } from '@hospitalrun/components' -import PatientRepository from 'clients/db/PatientRepository' -import Patient from 'model/Patient' -import TextInputWithLabelFormGroup from 'components/input/TextInputWithLabelFormGroup' -import { useHistory } from 'react-router-dom' -import Lab from 'model/Lab' -import TextFieldWithLabelFormGroup from 'components/input/TextFieldWithLabelFormGroup' -import useAddBreadcrumbs from 'breadcrumbs/useAddBreadcrumbs' import { useDispatch, useSelector } from 'react-redux' -import { requestLab } from 'labs/lab-slice' -import { RootState } from 'store' +import { useHistory } from 'react-router-dom' + +import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' +import PatientRepository from '../../clients/db/PatientRepository' +import TextFieldWithLabelFormGroup from '../../components/input/TextFieldWithLabelFormGroup' +import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup' +import Lab from '../../model/Lab' +import Patient from '../../model/Patient' +import useTitle from '../../page-header/useTitle' +import { RootState } from '../../store' +import { requestLab } from '../lab-slice' const NewLabRequest = () => { const { t } = useTranslation() diff --git a/src/locales/enUs/translations/index.ts b/src/locales/enUs/translations/index.ts index 674001f887..6afd27431e 100644 --- a/src/locales/enUs/translations/index.ts +++ b/src/locales/enUs/translations/index.ts @@ -1,12 +1,12 @@ import actions from './actions' import dashboard from './dashboard' +import incidents from './incidents' +import labs from './labs' import patient from './patient' import patients from './patients' import scheduling from './scheduling' -import states from './states' import sex from './sex' -import labs from './labs' -import incidents from './incidents' +import states from './states' export default { ...actions, diff --git a/src/locales/enUs/translations/patients/index.ts b/src/locales/enUs/translations/patients/index.ts index b936a2846f..3be64bf9d0 100644 --- a/src/locales/enUs/translations/patients/index.ts +++ b/src/locales/enUs/translations/patients/index.ts @@ -5,6 +5,7 @@ export default { viewPatients: 'View Patients', viewPatient: 'View Patient', newPatient: 'New Patient', + editPatient: 'Edit Patient', successfullyCreated: 'Successfully created patient', successfullyAddedNote: 'Successfully added the new note', successfullyAddedRelatedPerson: 'Successfully added a new related person', diff --git a/src/locales/es/translations/index.ts b/src/locales/es/translations/index.ts index e948f4340c..5307ce625c 100644 --- a/src/locales/es/translations/index.ts +++ b/src/locales/es/translations/index.ts @@ -1,11 +1,13 @@ import actions from './actions' import dashboard from './dashboard' +import labs from './labs' import patient from './patient' import patients from './patients' export default { ...actions, ...dashboard, + ...labs, ...patient, ...patients, } diff --git a/src/locales/fr/translations/index.ts b/src/locales/fr/translations/index.ts index d6bf2a1db2..5235352afc 100644 --- a/src/locales/fr/translations/index.ts +++ b/src/locales/fr/translations/index.ts @@ -1,11 +1,11 @@ import actions from './actions' import dashboard from './dashboard' +import labs from './labs' import patient from './patient' import patients from './patients' import scheduling from './scheduling' -import states from './states' import sex from './sex' -import labs from './labs' +import states from './states' export default { ...actions, diff --git a/src/locales/in/translations/index.ts b/src/locales/in/translations/index.ts index e948f4340c..5307ce625c 100644 --- a/src/locales/in/translations/index.ts +++ b/src/locales/in/translations/index.ts @@ -1,11 +1,13 @@ import actions from './actions' import dashboard from './dashboard' +import labs from './labs' import patient from './patient' import patients from './patients' export default { ...actions, ...dashboard, + ...labs, ...patient, ...patients, } diff --git a/src/locales/it/translations/index.ts b/src/locales/it/translations/index.ts index d6bf2a1db2..5235352afc 100644 --- a/src/locales/it/translations/index.ts +++ b/src/locales/it/translations/index.ts @@ -1,11 +1,11 @@ import actions from './actions' import dashboard from './dashboard' +import labs from './labs' import patient from './patient' import patients from './patients' import scheduling from './scheduling' -import states from './states' import sex from './sex' -import labs from './labs' +import states from './states' export default { ...actions, diff --git a/src/locales/ja/translations/index.ts b/src/locales/ja/translations/index.ts index e948f4340c..5307ce625c 100644 --- a/src/locales/ja/translations/index.ts +++ b/src/locales/ja/translations/index.ts @@ -1,11 +1,13 @@ import actions from './actions' import dashboard from './dashboard' +import labs from './labs' import patient from './patient' import patients from './patients' export default { ...actions, ...dashboard, + ...labs, ...patient, ...patients, } diff --git a/src/locales/ptBr/translations/index.ts b/src/locales/ptBr/translations/index.ts index d6bf2a1db2..5235352afc 100644 --- a/src/locales/ptBr/translations/index.ts +++ b/src/locales/ptBr/translations/index.ts @@ -1,11 +1,11 @@ import actions from './actions' import dashboard from './dashboard' +import labs from './labs' import patient from './patient' import patients from './patients' import scheduling from './scheduling' -import states from './states' import sex from './sex' -import labs from './labs' +import states from './states' export default { ...actions, diff --git a/src/locales/ru/translations/index.ts b/src/locales/ru/translations/index.ts index e948f4340c..5307ce625c 100644 --- a/src/locales/ru/translations/index.ts +++ b/src/locales/ru/translations/index.ts @@ -1,11 +1,13 @@ import actions from './actions' import dashboard from './dashboard' +import labs from './labs' import patient from './patient' import patients from './patients' export default { ...actions, ...dashboard, + ...labs, ...patient, ...patients, } diff --git a/src/locales/zr/translations/index.ts b/src/locales/zr/translations/index.ts index e948f4340c..5307ce625c 100644 --- a/src/locales/zr/translations/index.ts +++ b/src/locales/zr/translations/index.ts @@ -1,11 +1,13 @@ import actions from './actions' import dashboard from './dashboard' +import labs from './labs' import patient from './patient' import patients from './patients' export default { ...actions, ...dashboard, + ...labs, ...patient, ...patients, } diff --git a/src/model/Lab.ts b/src/model/Lab.ts index 64b17ce431..1a53d67542 100644 --- a/src/model/Lab.ts +++ b/src/model/Lab.ts @@ -4,6 +4,7 @@ export default interface Lab extends AbstractDBModel { code: string patientId: string type: string + requestedBy: string notes?: string result?: string status: 'requested' | 'completed' | 'canceled' diff --git a/src/model/Patient.ts b/src/model/Patient.ts index 27fde51a46..56b33def3f 100644 --- a/src/model/Patient.ts +++ b/src/model/Patient.ts @@ -1,10 +1,10 @@ import AbstractDBModel from './AbstractDBModel' -import Name from './Name' -import ContactInformation from './ContactInformation' -import RelatedPerson from './RelatedPerson' import Allergy from './Allergy' +import ContactInformation from './ContactInformation' import Diagnosis from './Diagnosis' +import Name from './Name' import Note from './Note' +import RelatedPerson from './RelatedPerson' export default interface Patient extends AbstractDBModel, Name, ContactInformation { sex: string diff --git a/src/page-header/ButtonToolBar.tsx b/src/page-header/ButtonToolBar.tsx index 72eec7b627..b8a5097c98 100644 --- a/src/page-header/ButtonToolBar.tsx +++ b/src/page-header/ButtonToolBar.tsx @@ -1,4 +1,5 @@ import React from 'react' + import { useButtons } from './ButtonBarProvider' const ButtonToolBar = () => { diff --git a/src/page-header/title-slice.ts b/src/page-header/title-slice.ts index 09f548684a..1025ed4456 100644 --- a/src/page-header/title-slice.ts +++ b/src/page-header/title-slice.ts @@ -1,4 +1,5 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' + import { AppThunk } from '../store' interface TitleState { diff --git a/src/page-header/useTitle.tsx b/src/page-header/useTitle.tsx index f8cd1b4a32..ff2382457f 100644 --- a/src/page-header/useTitle.tsx +++ b/src/page-header/useTitle.tsx @@ -1,5 +1,6 @@ import { useEffect } from 'react' import { useDispatch } from 'react-redux' + import { updateTitle } from './title-slice' export default function useTitle(title: string): void { diff --git a/src/patients/GeneralInformation.tsx b/src/patients/GeneralInformation.tsx index e945ea996d..94cdcede91 100644 --- a/src/patients/GeneralInformation.tsx +++ b/src/patients/GeneralInformation.tsx @@ -1,13 +1,13 @@ -import React from 'react' import { Panel, Checkbox, Alert } from '@hospitalrun/components' -import { useTranslation } from 'react-i18next' import { startOfDay, subYears, differenceInYears } from 'date-fns' +import React from 'react' +import { useTranslation } from 'react-i18next' -import Patient from '../model/Patient' +import DatePickerWithLabelFormGroup from '../components/input/DatePickerWithLabelFormGroup' +import SelectWithLabelFormGroup from '../components/input/SelectWithLableFormGroup' import TextFieldWithLabelFormGroup from '../components/input/TextFieldWithLabelFormGroup' import TextInputWithLabelFormGroup from '../components/input/TextInputWithLabelFormGroup' -import SelectWithLabelFormGroup from '../components/input/SelectWithLableFormGroup' -import DatePickerWithLabelFormGroup from '../components/input/DatePickerWithLabelFormGroup' +import Patient from '../model/Patient' interface Props { patient: Patient diff --git a/src/patients/Patients.tsx b/src/patients/Patients.tsx index 57a089fc61..be40c699df 100644 --- a/src/patients/Patients.tsx +++ b/src/patients/Patients.tsx @@ -1,13 +1,14 @@ import React from 'react' import { useSelector } from 'react-redux' import { Switch } from 'react-router-dom' + import PrivateRoute from '../components/PrivateRoute' import Permissions from '../model/Permissions' +import { RootState } from '../store' +import EditPatient from './edit/EditPatient' import ViewPatients from './list/ViewPatients' import NewPatient from './new/NewPatient' -import EditPatient from './edit/EditPatient' import ViewPatient from './view/ViewPatient' -import { RootState } from '../store' const Patients = () => { const permissions = useSelector((state: RootState) => state.user.permissions) diff --git a/src/patients/allergies/Allergies.tsx b/src/patients/allergies/Allergies.tsx index 5ae17c3704..9a8d9d5cc6 100644 --- a/src/patients/allergies/Allergies.tsx +++ b/src/patients/allergies/Allergies.tsx @@ -1,12 +1,13 @@ -import React, { useState } from 'react' -import useAddBreadcrumbs from 'breadcrumbs/useAddBreadcrumbs' -import Patient from 'model/Patient' import { Button, List, ListItem, Alert } from '@hospitalrun/components' -import { useSelector } from 'react-redux' -import { RootState } from 'store' -import Permissions from 'model/Permissions' +import React, { useState } from 'react' import { useTranslation } from 'react-i18next' -import Allergy from 'model/Allergy' +import { useSelector } from 'react-redux' + +import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' +import Allergy from '../../model/Allergy' +import Patient from '../../model/Patient' +import Permissions from '../../model/Permissions' +import { RootState } from '../../store' import NewAllergyModal from './NewAllergyModal' interface AllergiesProps { diff --git a/src/patients/allergies/NewAllergyModal.tsx b/src/patients/allergies/NewAllergyModal.tsx index d335f2fb92..9ea5374bf3 100644 --- a/src/patients/allergies/NewAllergyModal.tsx +++ b/src/patients/allergies/NewAllergyModal.tsx @@ -1,9 +1,10 @@ -import React, { useState, useEffect } from 'react' import { Modal, Alert } from '@hospitalrun/components' +import React, { useState, useEffect } from 'react' import { useTranslation } from 'react-i18next' -import Allergy from 'model/Allergy' -import TextInputWithLabelFormGroup from 'components/input/TextInputWithLabelFormGroup' import { useDispatch, useSelector } from 'react-redux' + +import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup' +import Allergy from '../../model/Allergy' import { RootState } from '../../store' import { addAllergy } from '../patient-slice' diff --git a/src/patients/appointments/AppointmentsList.tsx b/src/patients/appointments/AppointmentsList.tsx index 9a512f91a4..af13b72e87 100644 --- a/src/patients/appointments/AppointmentsList.tsx +++ b/src/patients/appointments/AppointmentsList.tsx @@ -1,11 +1,12 @@ +import { TextInput, Button, List, ListItem, Container, Row, Column } from '@hospitalrun/components' import React, { useEffect, useState } from 'react' +import { useTranslation } from 'react-i18next' import { useSelector, useDispatch } from 'react-redux' import { useHistory } from 'react-router-dom' -import { useTranslation } from 'react-i18next' -import { TextInput, Button, List, ListItem, Container, Row, Column } from '@hospitalrun/components' -import { RootState } from '../../store' -import { fetchPatientAppointments } from '../../scheduling/appointments/appointments-slice' + import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' +import { fetchPatientAppointments } from '../../scheduling/appointments/appointments-slice' +import { RootState } from '../../store' interface Props { patientId: string diff --git a/src/patients/diagnoses/AddDiagnosisModal.tsx b/src/patients/diagnoses/AddDiagnosisModal.tsx index 7706c1b632..110dab5f68 100644 --- a/src/patients/diagnoses/AddDiagnosisModal.tsx +++ b/src/patients/diagnoses/AddDiagnosisModal.tsx @@ -1,10 +1,11 @@ -import React, { useState, useEffect } from 'react' import { Modal, Alert } from '@hospitalrun/components' +import React, { useState, useEffect } from 'react' import { useTranslation } from 'react-i18next' -import Diagnosis from 'model/Diagnosis' -import TextInputWithLabelFormGroup from 'components/input/TextInputWithLabelFormGroup' -import DatePickerWithLabelFormGroup from 'components/input/DatePickerWithLabelFormGroup' import { useDispatch, useSelector } from 'react-redux' + +import DatePickerWithLabelFormGroup from '../../components/input/DatePickerWithLabelFormGroup' +import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup' +import Diagnosis from '../../model/Diagnosis' import { RootState } from '../../store' import { addDiagnosis } from '../patient-slice' diff --git a/src/patients/diagnoses/Diagnoses.tsx b/src/patients/diagnoses/Diagnoses.tsx index af774eda7e..78dd595e44 100644 --- a/src/patients/diagnoses/Diagnoses.tsx +++ b/src/patients/diagnoses/Diagnoses.tsx @@ -1,12 +1,13 @@ -import React, { useState } from 'react' -import { RootState } from 'store' -import Patient from 'model/Patient' -import useAddBreadcrumbs from 'breadcrumbs/useAddBreadcrumbs' -import { useSelector } from 'react-redux' -import Permissions from 'model/Permissions' import { Button, List, ListItem, Alert } from '@hospitalrun/components' +import React, { useState } from 'react' import { useTranslation } from 'react-i18next' -import Diagnosis from 'model/Diagnosis' +import { useSelector } from 'react-redux' + +import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' +import Diagnosis from '../../model/Diagnosis' +import Patient from '../../model/Patient' +import Permissions from '../../model/Permissions' +import { RootState } from '../../store' import AddDiagnosisModal from './AddDiagnosisModal' interface Props { diff --git a/src/patients/edit/EditPatient.tsx b/src/patients/edit/EditPatient.tsx index 350a3f2bdd..a707fc532f 100644 --- a/src/patients/edit/EditPatient.tsx +++ b/src/patients/edit/EditPatient.tsx @@ -1,15 +1,16 @@ +import { Spinner, Button, Toast } from '@hospitalrun/components' import React, { useEffect, useState } from 'react' -import { useHistory, useParams } from 'react-router-dom' import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' -import { Spinner, Button, Toast } from '@hospitalrun/components' -import GeneralInformation from '../GeneralInformation' -import useTitle from '../../page-header/useTitle' +import { useHistory, useParams } from 'react-router-dom' + +import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' import Patient from '../../model/Patient' -import { updatePatient, fetchPatient } from '../patient-slice' +import useTitle from '../../page-header/useTitle' import { RootState } from '../../store' +import GeneralInformation from '../GeneralInformation' +import { updatePatient, fetchPatient } from '../patient-slice' import { getPatientFullName, getPatientName } from '../util/patient-name-util' -import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' const getPatientCode = (p: Patient): string => { if (p) { diff --git a/src/patients/labs/LabsTab.tsx b/src/patients/labs/LabsTab.tsx index a3d2a0fedb..b6111146a2 100644 --- a/src/patients/labs/LabsTab.tsx +++ b/src/patients/labs/LabsTab.tsx @@ -1,10 +1,11 @@ -import React, { useEffect, useState } from 'react' import { Alert } from '@hospitalrun/components' -import { useTranslation } from 'react-i18next' import format from 'date-fns/format' +import React, { useEffect, useState } from 'react' +import { useTranslation } from 'react-i18next' import { useHistory } from 'react-router-dom' -import Lab from '../../model/Lab' + import LabRepository from '../../clients/db/LabRepository' +import Lab from '../../model/Lab' interface Props { patientId: string diff --git a/src/patients/list/ViewPatients.tsx b/src/patients/list/ViewPatients.tsx index 8f22083aa8..7b0ad305ef 100644 --- a/src/patients/list/ViewPatients.tsx +++ b/src/patients/list/ViewPatients.tsx @@ -1,15 +1,16 @@ +import { Spinner, Button, Container, Row, TextInput, Column } from '@hospitalrun/components' +import format from 'date-fns/format' import React, { useEffect, useState } from 'react' +import { useTranslation } from 'react-i18next' import { useSelector, useDispatch } from 'react-redux' import { useHistory } from 'react-router-dom' -import { useTranslation } from 'react-i18next' -import { Spinner, Button, Container, Row, TextInput, Column } from '@hospitalrun/components' -import { useButtonToolbarSetter } from 'page-header/ButtonBarProvider' -import format from 'date-fns/format' -import { RootState } from '../../store' -import { searchPatients } from '../patients-slice' -import useTitle from '../../page-header/useTitle' + import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' import useDebounce from '../../hooks/debounce' +import { useButtonToolbarSetter } from '../../page-header/ButtonBarProvider' +import useTitle from '../../page-header/useTitle' +import { RootState } from '../../store' +import { searchPatients } from '../patients-slice' const breadcrumbs = [{ i18nKey: 'patients.label', location: '/patients' }] diff --git a/src/patients/new/NewPatient.tsx b/src/patients/new/NewPatient.tsx index e820b3e471..b7b7c827ea 100644 --- a/src/patients/new/NewPatient.tsx +++ b/src/patients/new/NewPatient.tsx @@ -1,15 +1,16 @@ +import { Button, Toast } from '@hospitalrun/components' import React, { useState } from 'react' -import { useHistory } from 'react-router-dom' import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' -import { Button, Toast } from '@hospitalrun/components' -import GeneralInformation from '../GeneralInformation' -import useTitle from '../../page-header/useTitle' +import { useHistory } from 'react-router-dom' + +import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' import Patient from '../../model/Patient' +import useTitle from '../../page-header/useTitle' +import { RootState } from '../../store' +import GeneralInformation from '../GeneralInformation' import { createPatient } from '../patient-slice' import { getPatientName } from '../util/patient-name-util' -import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' -import { RootState } from '../../store' const breadcrumbs = [ { i18nKey: 'patients.label', location: '/patients' }, diff --git a/src/patients/notes/NewNoteModal.tsx b/src/patients/notes/NewNoteModal.tsx index e8b9d3a5cd..4363d45ee3 100644 --- a/src/patients/notes/NewNoteModal.tsx +++ b/src/patients/notes/NewNoteModal.tsx @@ -1,11 +1,12 @@ -import React, { useState } from 'react' import { Modal, Alert } from '@hospitalrun/components' +import React, { useState } from 'react' import { useTranslation } from 'react-i18next' -import TextFieldWithLabelFormGroup from 'components/input/TextFieldWithLabelFormGroup' -import { addNote } from 'patients/patient-slice' import { useDispatch, useSelector } from 'react-redux' + +import TextFieldWithLabelFormGroup from '../../components/input/TextFieldWithLabelFormGroup' import Note from '../../model/Note' import { RootState } from '../../store' +import { addNote } from '../patient-slice' interface Props { show: boolean diff --git a/src/patients/notes/NoteTab.tsx b/src/patients/notes/NoteTab.tsx index e4be1c76bc..ead93598fc 100644 --- a/src/patients/notes/NoteTab.tsx +++ b/src/patients/notes/NoteTab.tsx @@ -1,13 +1,13 @@ -/* eslint-disable react/no-danger */ +import { Button, List, ListItem, Alert } from '@hospitalrun/components' import React, { useState } from 'react' -import { useSelector } from 'react-redux' import { useTranslation } from 'react-i18next' -import { Button, List, ListItem, Alert } from '@hospitalrun/components' -import NewNoteModal from 'patients/notes/NewNoteModal' -import Note from 'model/Note' -import Patient from 'model/Patient' -import { RootState } from '../../store' +import { useSelector } from 'react-redux' + +import Note from '../../model/Note' +import Patient from '../../model/Patient' import Permissions from '../../model/Permissions' +import { RootState } from '../../store' +import NewNoteModal from './NewNoteModal' interface Props { patient: Patient diff --git a/src/patients/patient-slice.ts b/src/patients/patient-slice.ts index f106abb18e..1e3b25dbad 100644 --- a/src/patients/patient-slice.ts +++ b/src/patients/patient-slice.ts @@ -2,14 +2,15 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' import { isAfter, parseISO } from 'date-fns' import _ from 'lodash' import validator from 'validator' -import { uuid } from '../util/uuid' -import Patient from '../model/Patient' + import PatientRepository from '../clients/db/PatientRepository' -import { AppThunk } from '../store' -import RelatedPerson from '../model/RelatedPerson' -import Diagnosis from '../model/Diagnosis' import Allergy from '../model/Allergy' +import Diagnosis from '../model/Diagnosis' import Note from '../model/Note' +import Patient from '../model/Patient' +import RelatedPerson from '../model/RelatedPerson' +import { AppThunk } from '../store' +import { uuid } from '../util/uuid' interface PatientState { status: 'loading' | 'error' | 'completed' diff --git a/src/patients/patients-slice.ts b/src/patients/patients-slice.ts index 73cb93f3e6..37029bd1ad 100644 --- a/src/patients/patients-slice.ts +++ b/src/patients/patients-slice.ts @@ -1,6 +1,7 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' -import Patient from '../model/Patient' + import PatientRepository from '../clients/db/PatientRepository' +import Patient from '../model/Patient' import { AppThunk } from '../store' interface PatientsState { diff --git a/src/patients/related-persons/AddRelatedPersonModal.tsx b/src/patients/related-persons/AddRelatedPersonModal.tsx index f39cf4331d..3c1ccf906a 100644 --- a/src/patients/related-persons/AddRelatedPersonModal.tsx +++ b/src/patients/related-persons/AddRelatedPersonModal.tsx @@ -1,11 +1,12 @@ -import React, { useState } from 'react' import { Modal, Alert, Typeahead, Label } from '@hospitalrun/components' +import React, { useState } from 'react' import { useTranslation } from 'react-i18next' -import TextInputWithLabelFormGroup from 'components/input/TextInputWithLabelFormGroup' -import RelatedPerson from 'model/RelatedPerson' -import PatientRepository from 'clients/db/PatientRepository' -import Patient from 'model/Patient' import { useDispatch, useSelector } from 'react-redux' + +import PatientRepository from '../../clients/db/PatientRepository' +import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup' +import Patient from '../../model/Patient' +import RelatedPerson from '../../model/RelatedPerson' import { RootState } from '../../store' import { addRelatedPerson } from '../patient-slice' diff --git a/src/patients/related-persons/RelatedPersonTab.tsx b/src/patients/related-persons/RelatedPersonTab.tsx index 1ea24a4648..526abe4097 100644 --- a/src/patients/related-persons/RelatedPersonTab.tsx +++ b/src/patients/related-persons/RelatedPersonTab.tsx @@ -1,15 +1,16 @@ -import React, { useState, useEffect } from 'react' import { Button, Alert, Spinner } from '@hospitalrun/components' -import AddRelatedPersonModal from 'patients/related-persons/AddRelatedPersonModal' +import React, { useState, useEffect } from 'react' import { useTranslation } from 'react-i18next' -import { useHistory } from 'react-router-dom' -import Patient from 'model/Patient' -import { removeRelatedPerson } from 'patients/patient-slice' import { useDispatch, useSelector } from 'react-redux' -import { RootState } from 'store' -import Permissions from 'model/Permissions' -import PatientRepository from 'clients/db/PatientRepository' +import { useHistory } from 'react-router-dom' + import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' +import PatientRepository from '../../clients/db/PatientRepository' +import Patient from '../../model/Patient' +import Permissions from '../../model/Permissions' +import { RootState } from '../../store' +import { removeRelatedPerson } from '../patient-slice' +import AddRelatedPersonModal from './AddRelatedPersonModal' interface Props { patient: Patient diff --git a/src/patients/view/ViewPatient.tsx b/src/patients/view/ViewPatient.tsx index 6119142e0b..f966a8b9b6 100644 --- a/src/patients/view/ViewPatient.tsx +++ b/src/patients/view/ViewPatient.tsx @@ -1,24 +1,24 @@ +import { Panel, Spinner, TabsHeader, Tab, Button } from '@hospitalrun/components' import React, { useEffect } from 'react' +import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' import { useParams, withRouter, Route, useHistory, useLocation } from 'react-router-dom' -import { Panel, Spinner, TabsHeader, Tab, Button } from '@hospitalrun/components' -import { useTranslation } from 'react-i18next' -import { useButtonToolbarSetter } from 'page-header/ButtonBarProvider' -import Allergies from 'patients/allergies/Allergies' -import Diagnoses from 'patients/diagnoses/Diagnoses' +import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' +import Patient from '../../model/Patient' +import Permissions from '../../model/Permissions' +import { useButtonToolbarSetter } from '../../page-header/ButtonBarProvider' import useTitle from '../../page-header/useTitle' -import { fetchPatient } from '../patient-slice' import { RootState } from '../../store' -import { getPatientFullName } from '../util/patient-name-util' -import Permissions from '../../model/Permissions' -import Patient from '../../model/Patient' -import GeneralInformation from '../GeneralInformation' -import RelatedPerson from '../related-persons/RelatedPersonTab' -import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' +import Allergies from '../allergies/Allergies' import AppointmentsList from '../appointments/AppointmentsList' -import Note from '../notes/NoteTab' +import Diagnoses from '../diagnoses/Diagnoses' +import GeneralInformation from '../GeneralInformation' import Labs from '../labs/LabsTab' +import Note from '../notes/NoteTab' +import { fetchPatient } from '../patient-slice' +import RelatedPerson from '../related-persons/RelatedPersonTab' +import { getPatientFullName } from '../util/patient-name-util' const getPatientCode = (p: Patient): string => { if (p) { diff --git a/src/scheduling/appointments/AppointmentDetailForm.tsx b/src/scheduling/appointments/AppointmentDetailForm.tsx index 6fe9837a3f..b00bd77841 100644 --- a/src/scheduling/appointments/AppointmentDetailForm.tsx +++ b/src/scheduling/appointments/AppointmentDetailForm.tsx @@ -1,14 +1,15 @@ -import React from 'react' -import Appointment from 'model/Appointment' -import DateTimePickerWithLabelFormGroup from 'components/input/DateTimePickerWithLabelFormGroup' import { Typeahead, Label, Alert } from '@hospitalrun/components' -import Patient from 'model/Patient' -import PatientRepository from 'clients/db/PatientRepository' -import TextInputWithLabelFormGroup from 'components/input/TextInputWithLabelFormGroup' -import TextFieldWithLabelFormGroup from 'components/input/TextFieldWithLabelFormGroup' -import SelectWithLabelFormGroup from 'components/input/SelectWithLableFormGroup' +import React from 'react' import { useTranslation } from 'react-i18next' +import PatientRepository from '../../clients/db/PatientRepository' +import DateTimePickerWithLabelFormGroup from '../../components/input/DateTimePickerWithLabelFormGroup' +import SelectWithLabelFormGroup from '../../components/input/SelectWithLableFormGroup' +import TextFieldWithLabelFormGroup from '../../components/input/TextFieldWithLabelFormGroup' +import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup' +import Appointment from '../../model/Appointment' +import Patient from '../../model/Patient' + interface Props { appointment: Appointment patient?: Patient diff --git a/src/scheduling/appointments/Appointments.tsx b/src/scheduling/appointments/Appointments.tsx index 22f2055624..2166722519 100644 --- a/src/scheduling/appointments/Appointments.tsx +++ b/src/scheduling/appointments/Appointments.tsx @@ -1,13 +1,14 @@ import React from 'react' import { useSelector } from 'react-redux' import { Switch } from 'react-router-dom' -import NewAppointment from 'scheduling/appointments/new/NewAppointment' -import EditAppointment from 'scheduling/appointments/edit/EditAppointment' -import ViewAppointment from 'scheduling/appointments/view/ViewAppointment' -import ViewAppointments from './ViewAppointments' + import PrivateRoute from '../../components/PrivateRoute' import Permissions from '../../model/Permissions' import { RootState } from '../../store' +import EditAppointment from './edit/EditAppointment' +import NewAppointment from './new/NewAppointment' +import ViewAppointment from './view/ViewAppointment' +import ViewAppointments from './ViewAppointments' const Appointments = () => { const permissions = useSelector((state: RootState) => state.user.permissions) diff --git a/src/scheduling/appointments/ViewAppointments.tsx b/src/scheduling/appointments/ViewAppointments.tsx index f7981353c9..824d2dd662 100644 --- a/src/scheduling/appointments/ViewAppointments.tsx +++ b/src/scheduling/appointments/ViewAppointments.tsx @@ -1,13 +1,14 @@ -import React, { useEffect, useState } from 'react' import { Calendar, Button } from '@hospitalrun/components' -import useTitle from 'page-header/useTitle' +import React, { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { useSelector, useDispatch } from 'react-redux' -import { RootState } from 'store' import { useHistory } from 'react-router-dom' -import PatientRepository from 'clients/db/PatientRepository' -import useAddBreadcrumbs from 'breadcrumbs/useAddBreadcrumbs' -import { useButtonToolbarSetter } from 'page-header/ButtonBarProvider' + +import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' +import PatientRepository from '../../clients/db/PatientRepository' +import { useButtonToolbarSetter } from '../../page-header/ButtonBarProvider' +import useTitle from '../../page-header/useTitle' +import { RootState } from '../../store' import { fetchAppointments } from './appointments-slice' interface Event { diff --git a/src/scheduling/appointments/appointment-slice.ts b/src/scheduling/appointments/appointment-slice.ts index af8732531d..2836775f12 100644 --- a/src/scheduling/appointments/appointment-slice.ts +++ b/src/scheduling/appointments/appointment-slice.ts @@ -1,12 +1,13 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' -import Appointment from 'model/Appointment' -import { AppThunk } from 'store' -import AppointmentRepository from 'clients/db/AppointmentRepository' -import Patient from 'model/Patient' -import PatientRepository from 'clients/db/PatientRepository' import { isBefore } from 'date-fns' import _ from 'lodash' +import AppointmentRepository from '../../clients/db/AppointmentRepository' +import PatientRepository from '../../clients/db/PatientRepository' +import Appointment from '../../model/Appointment' +import Patient from '../../model/Patient' +import { AppThunk } from '../../store' + function validateAppointment(appointment: Appointment) { const err: Error = {} diff --git a/src/scheduling/appointments/appointments-slice.ts b/src/scheduling/appointments/appointments-slice.ts index f902684d03..4a6f93f663 100644 --- a/src/scheduling/appointments/appointments-slice.ts +++ b/src/scheduling/appointments/appointments-slice.ts @@ -1,7 +1,8 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' -import Appointment from 'model/Appointment' -import { AppThunk } from 'store' -import AppointmentRepository from 'clients/db/AppointmentRepository' + +import AppointmentRepository from '../../clients/db/AppointmentRepository' +import Appointment from '../../model/Appointment' +import { AppThunk } from '../../store' interface AppointmentsState { isLoading: boolean diff --git a/src/scheduling/appointments/edit/EditAppointment.tsx b/src/scheduling/appointments/edit/EditAppointment.tsx index d52d757c46..765700f8f5 100644 --- a/src/scheduling/appointments/edit/EditAppointment.tsx +++ b/src/scheduling/appointments/edit/EditAppointment.tsx @@ -1,16 +1,16 @@ +import { Spinner, Button } from '@hospitalrun/components' import React, { useEffect, useState } from 'react' -import { useHistory, useParams } from 'react-router-dom' import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' -import { Spinner, Button } from '@hospitalrun/components' +import { useHistory, useParams } from 'react-router-dom' -import AppointmentDetailForm from '../AppointmentDetailForm' -import useTitle from '../../../page-header/useTitle' +import useAddBreadcrumbs from '../../../breadcrumbs/useAddBreadcrumbs' import Appointment from '../../../model/Appointment' -import { updateAppointment, fetchAppointment } from '../appointment-slice' +import useTitle from '../../../page-header/useTitle' import { RootState } from '../../../store' +import { updateAppointment, fetchAppointment } from '../appointment-slice' +import AppointmentDetailForm from '../AppointmentDetailForm' import { getAppointmentLabel } from '../util/scheduling-appointment.util' -import useAddBreadcrumbs from '../../../breadcrumbs/useAddBreadcrumbs' const EditAppointment = () => { const { t } = useTranslation() diff --git a/src/scheduling/appointments/new/NewAppointment.tsx b/src/scheduling/appointments/new/NewAppointment.tsx index 478d95bda0..3573a59367 100644 --- a/src/scheduling/appointments/new/NewAppointment.tsx +++ b/src/scheduling/appointments/new/NewAppointment.tsx @@ -1,16 +1,17 @@ +import { Button, Toast } from '@hospitalrun/components' +import addMinutes from 'date-fns/addMinutes' +import roundToNearestMinutes from 'date-fns/roundToNearestMinutes' import React, { useState } from 'react' -import useTitle from 'page-header/useTitle' import { useTranslation } from 'react-i18next' -import roundToNearestMinutes from 'date-fns/roundToNearestMinutes' -import { useHistory } from 'react-router-dom' import { useDispatch, useSelector } from 'react-redux' -import Appointment from 'model/Appointment' -import addMinutes from 'date-fns/addMinutes' -import { Button, Toast } from '@hospitalrun/components' +import { useHistory } from 'react-router-dom' + import useAddBreadcrumbs from '../../../breadcrumbs/useAddBreadcrumbs' +import Appointment from '../../../model/Appointment' +import useTitle from '../../../page-header/useTitle' +import { RootState } from '../../../store' import { createAppointment } from '../appointment-slice' import AppointmentDetailForm from '../AppointmentDetailForm' -import { RootState } from '../../../store' const breadcrumbs = [ { i18nKey: 'scheduling.appointments.label', location: '/appointments' }, diff --git a/src/scheduling/appointments/view/ViewAppointment.tsx b/src/scheduling/appointments/view/ViewAppointment.tsx index 0ac23b1512..cf3782ee93 100644 --- a/src/scheduling/appointments/view/ViewAppointment.tsx +++ b/src/scheduling/appointments/view/ViewAppointment.tsx @@ -1,16 +1,17 @@ +import { Spinner, Button, Modal, Toast } from '@hospitalrun/components' import React, { useEffect, useState } from 'react' -import useTitle from 'page-header/useTitle' +import { useTranslation } from 'react-i18next' import { useSelector, useDispatch } from 'react-redux' -import { RootState } from 'store' import { useParams, useHistory } from 'react-router-dom' -import { Spinner, Button, Modal, Toast } from '@hospitalrun/components' -import { useTranslation } from 'react-i18next' -import { useButtonToolbarSetter } from 'page-header/ButtonBarProvider' -import Permissions from 'model/Permissions' + +import useAddBreadcrumbs from '../../../breadcrumbs/useAddBreadcrumbs' +import Permissions from '../../../model/Permissions' +import { useButtonToolbarSetter } from '../../../page-header/ButtonBarProvider' +import useTitle from '../../../page-header/useTitle' +import { RootState } from '../../../store' import { fetchAppointment, deleteAppointment } from '../appointment-slice' import AppointmentDetailForm from '../AppointmentDetailForm' import { getAppointmentLabel } from '../util/scheduling-appointment.util' -import useAddBreadcrumbs from '../../../breadcrumbs/useAddBreadcrumbs' const ViewAppointment = () => { const { t } = useTranslation() diff --git a/src/store/index.ts b/src/store/index.ts index 3f16c4c176..e105cd7ad8 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,17 +1,18 @@ import { configureStore, combineReducers, Action } from '@reduxjs/toolkit' import ReduxThunk, { ThunkAction } from 'redux-thunk' + +import breadcrumbs from '../breadcrumbs/breadcrumbs-slice' +import components from '../components/component-slice' +import incident from '../incidents/incident-slice' +import incidents from '../incidents/incidents-slice' +import lab from '../labs/lab-slice' +import labs from '../labs/labs-slice' +import title from '../page-header/title-slice' import patient from '../patients/patient-slice' import patients from '../patients/patients-slice' import appointment from '../scheduling/appointments/appointment-slice' import appointments from '../scheduling/appointments/appointments-slice' -import title from '../page-header/title-slice' import user from '../user/user-slice' -import lab from '../labs/lab-slice' -import incident from '../incidents/incident-slice' -import incidents from '../incidents/incidents-slice' -import labs from '../labs/labs-slice' -import breadcrumbs from '../breadcrumbs/breadcrumbs-slice' -import components from '../components/component-slice' const reducer = combineReducers({ patient, diff --git a/src/user/user-slice.ts b/src/user/user-slice.ts index acf7c27201..afcb489b76 100644 --- a/src/user/user-slice.ts +++ b/src/user/user-slice.ts @@ -1,4 +1,5 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' + import Permissions from '../model/Permissions' import User from '../model/User' diff --git a/tsconfig.json b/tsconfig.json index 408f737883..f37b7e2b46 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -29,7 +29,7 @@ "resolveJsonModule": true, "importHelpers": true, "jsx": "react", - "baseUrl": "./src", + // "baseUrl": "./src", "allowJs": true, "skipLibCheck": true, "noEmit": true,