Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into fix_merge_conflicts_imagings_meds
Browse files Browse the repository at this point in the history
  • Loading branch information
blestab committed Aug 13, 2020
2 parents 45678a0 + 7ca79bc commit 5cf1307
Show file tree
Hide file tree
Showing 135 changed files with 5,545 additions and 1,849 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ jobs:
run: |
npm run lint
- name: Build
if: always()
run: |
npm run build
- name: Run tests
if: always()
run: |
npm run coveralls
- name: Coveralls
Expand Down
52 changes: 0 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,58 +36,6 @@ React frontend for [HospitalRun](http://hospitalrun.io/): free software for deve
- How do I submit my changes?
- etc.

# Behind HospitalRun

## Hosted by

[<img src="https://github.com/openjs-foundation/cross-project-council/blob/master/logos/openjsf-color.png?raw=true" width="120px;"/>](https://openjsf.org/projects/#atlarge)

## Sponsors

[![Sponsors](https://opencollective.com/hospitalrun/sponsors.svg?width=890)](https://opencollective.com/hospitalrun/contribute/sponsors-336/checkout)

## Backers

[![Backers](https://opencollective.com/hospitalrun/backers.svg?width=890)](https://opencollective.com/hospitalrun/contribute/backers-335/checkout)

## Big Thanks

Cross-browser Testing Platform and Open Source <3 Provided by [Sauce Labs](https://saucelabs.com)

## Lead Maintainer

[<img src="https://avatars2.githubusercontent.com/u/1620916?s=460&v=4" width="100px;"/><br /><sub><b>Maksim Sinik</b></sub>](https://github.com/fox1t)<br />

## [Core Maintainers](https://github.com/orgs/HospitalRun/teams/core-maintainers)

<!-- prettier-ignore -->
| [<img src="https://avatars3.githubusercontent.com/u/18731800?s=460&v=4" width="100px;"/><br /><sub><b>Jack Meyer</b></sub>](https://github.com/jackcmeyer) | [<img src="https://avatars0.githubusercontent.com/u/6388707?s=460&v=4" width="100px;"/><br /><sub><b>Matteo Vivona</b></sub>](https://github.com/tehKapa) |
|---|---|

## [Core Contributors](https://github.com/orgs/HospitalRun/teams/core-contributor)

<!-- prettier-ignore -->
| [<img src="https://avatars3.githubusercontent.com/u/25089405?s=460&v=4" width="100px;"/><br /><sub><b>Stefano Casasola</b></sub>](https://github.com/irvelervel) | [<img src="https://avatars2.githubusercontent.com/u/8810755?s=460&u=495b69e528066f88944d8ce487ce39afe01b9ccb&v=4" width="100px;"/><br /><sub><b>Kumiko Kashii</b></sub>](https://github.com/kumikokashii) | [<img src="https://avatars3.githubusercontent.com/u/603924?s=460&v=4" width="100px;"/><br /><sub><b>Grace Lau</b></sub>](https://github.com/lauggh) | [<img src="https://avatars2.githubusercontent.com/u/26657904?s=460&u=d960bf3d95ae0c9bb858f1f069fff03e51254ddb&v=4" width="100px;"/><br /><sub><b>Stefano Miceli</b></sub>](https://github.com/StefanoMiC) |
|---|---|---|---|

## Medical Supervisor

[<img src="https://avatars2.githubusercontent.com/u/24660474?s=460&v=4" width="100px;"/><br /><sub><b>M.D. Daniele Piccolo</b></sub>](https://it.linkedin.com/in/danielepiccolo)<br />

## Past Contributors

[<img src="https://avatars2.githubusercontent.com/u/8914893?s=460&v=4" width="100px;"/><br /><sub><b>Michael Daly</b></sub>](https://github.com/MichaelDalyDev)<br />

## Contributors

[![Contributors](https://opencollective.com/hospitalrun/contributors.svg?width=960&button=false)](https://github.com/HospitalRun/hospitalrun-frontend/graphs/contributors)

## Founders

<!-- prettier-ignore -->
| [<img src="https://avatars0.githubusercontent.com/u/609052?s=460&v=4" width="100px;"/><br /><sub><b>John Kleinschmidtr</b></sub>](https://github.com/jkleinsc) | [<img src="https://avatars0.githubusercontent.com/u/929261?s=400&v=4" width="100px;"/><br /><sub><b>Joel Worrall</b></sub>](https://github.com/tangollama) | [<img src="https://avatars0.githubusercontent.com/u/1319791?s=460&v=4" width="100px;"/><br /><sub><b>Joel Glovier</b></sub>](https://github.com/jglovier) |
|---|---|---|

# License

Released under the [MIT license](LICENSE).
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"react-bootstrap-typeahead": "~5.1.0",
"react-dom": "~16.13.0",
"react-i18next": "~11.7.0",
"react-query": "~2.5.13",
"react-query-devtools": "~2.4.2",
"react-redux": "~7.2.0",
"react-router": "~5.2.0",
"react-router-dom": "~5.2.0",
Expand Down Expand Up @@ -75,8 +77,8 @@
"@types/shortid": "^0.0.29",
"@types/uuid": "^8.0.0",
"@types/validator": "~13.1.0",
"@typescript-eslint/eslint-plugin": "~3.7.0",
"@typescript-eslint/parser": "~3.7.0",
"@typescript-eslint/eslint-plugin": "~3.9.0",
"@typescript-eslint/parser": "~3.9.0",
"chalk": "^4.0.0",
"commitizen": "~4.1.2",
"commitlint-config-cz": "~0.13.0",
Expand Down Expand Up @@ -105,7 +107,7 @@
"rimraf": "~3.0.2",
"source-map-explorer": "^2.2.2",
"standard-version": "~8.0.0",
"ts-jest": "~26.1.0"
"ts-jest": "~26.2.0"
},
"scripts": {
"analyze": "source-map-explorer 'build/static/js/*.js'",
Expand All @@ -114,8 +116,8 @@
"build": "react-scripts build",
"update": "npx npm-check -u",
"prepublishOnly": "npm run build",
"test": "npm run translation:check && react-scripts test --detectOpenHandles",
"test:ci": "cross-env CI=true react-scripts test --passWithNoTests",
"test": "npm run translation:check && react-scripts test --detectOpenHandles --testPathIgnorePatterns=src/__tests__/test-utils",
"test:ci": "cross-env CI=true react-scripts test --passWithNoTests --testPathIgnorePatterns=src/__tests__/test-utils",
"lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\" \"scripts/check-translations/**/*.{js,ts}\"",
"lint:fix": "eslint \"src/**/*.{js,jsx,ts,tsx}\" \"scripts/check-translations/**/*.{js,ts}\" --fix",
"lint-staged": "lint-staged",
Expand Down
20 changes: 12 additions & 8 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Spinner } from '@hospitalrun/components'
import React, { Suspense, useEffect, useState } from 'react'
import { ReactQueryDevtools } from 'react-query-devtools'
import { useDispatch } from 'react-redux'
import { BrowserRouter, Route, Switch } from 'react-router-dom'

Expand Down Expand Up @@ -33,14 +34,17 @@ const App: React.FC = () => {
}

return (
<BrowserRouter>
<Suspense fallback={<Spinner color="blue" loading size={[10, 25]} type="ScaleLoader" />}>
<Switch>
<Route exact path="/login" component={Login} />
<Route path="/" component={HospitalRun} />
</Switch>
</Suspense>
</BrowserRouter>
<>
<BrowserRouter>
<Suspense fallback={<Spinner color="blue" loading size={[10, 25]} type="ScaleLoader" />}>
<Switch>
<Route exact path="/login" component={Login} />
<Route path="/" component={HospitalRun} />
</Switch>
</Suspense>
</BrowserRouter>
<ReactQueryDevtools initialIsOpen={false} />
</>
)
}

Expand Down
2 changes: 2 additions & 0 deletions src/HospitalRun.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useSelector } from 'react-redux'
import { Redirect, Route, Switch } from 'react-router-dom'

import Dashboard from './dashboard/Dashboard'
import Imagings from './imagings/Imagings'
import Incidents from './incidents/Incidents'
import Labs from './labs/Labs'
import Medications from './medications/Medications'
Expand Down Expand Up @@ -55,6 +56,7 @@ const HospitalRun = () => {
<Route path="/medications" component={Medications} />
<Route path="/incidents" component={Incidents} />
<Route path="/settings" component={Settings} />
<Route path="/imaging" component={Imagings} />
</Switch>
</div>
<Toaster autoClose={5000} hideProgressBar draggable />
Expand Down
54 changes: 52 additions & 2 deletions src/__tests__/HospitalRun.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import thunk from 'redux-thunk'

import Dashboard from '../dashboard/Dashboard'
import HospitalRun from '../HospitalRun'
import ViewImagings from '../imagings/ViewImagings'
import Incidents from '../incidents/Incidents'
import ViewLabs from '../labs/ViewLabs'
import ViewMedications from '../medications/ViewMedications'
import { addBreadcrumbs } from '../page-header/breadcrumbs/breadcrumbs-slice'
import Appointments from '../scheduling/appointments/Appointments'
import Settings from '../settings/Settings'
import ImagingRepository from '../shared/db/ImagingRepository'
import IncidentRepository from '../shared/db/IncidentRepository'
import LabRepository from '../shared/db/LabRepository'
import MedicationRepository from '../shared/db/MedicationRepository'
import Permissions from '../shared/model/Permissions'
Expand All @@ -32,7 +35,6 @@ describe('HospitalRun', () => {
appointments: { appointments: [] },
breadcrumbs: { breadcrumbs: [] },
components: { sidebarCollapsed: false },
incidents: { incidents: [] },
} as any)

const wrapper = mount(
Expand Down Expand Up @@ -175,12 +177,12 @@ describe('HospitalRun', () => {

describe('/incidents', () => {
it('should render the Incidents component when /incidents is accessed', async () => {
jest.spyOn(IncidentRepository, 'search').mockResolvedValue([])
const store = mockStore({
title: 'test',
user: { user: { id: '123' }, permissions: [Permissions.ViewIncidents] },
breadcrumbs: { breadcrumbs: [] },
components: { sidebarCollapsed: false },
incidents: { incidents: [] },
} as any)

let wrapper: any
Expand Down Expand Up @@ -220,6 +222,54 @@ describe('HospitalRun', () => {
})
})

describe('/imaging', () => {
it('should render the Imagings component when /imaging is accessed', async () => {
jest.spyOn(ImagingRepository, 'findAll').mockResolvedValue([])
const store = mockStore({
title: 'test',
user: { user: { id: '123' }, permissions: [Permissions.ViewImagings] },
imagings: { imagings: [] },
breadcrumbs: { breadcrumbs: [] },
components: { sidebarCollapsed: false },
} as any)

let wrapper: any
await act(async () => {
wrapper = await mount(
<Provider store={store}>
<MemoryRouter initialEntries={['/imaging']}>
<HospitalRun />
</MemoryRouter>
</Provider>,
)
})
wrapper.update()

expect(wrapper.find(ViewImagings)).toHaveLength(1)
})

it('should render the dashboard if the user does not have permissions to view imagings', () => {
jest.spyOn(LabRepository, 'findAll').mockResolvedValue([])
const store = mockStore({
title: 'test',
user: { user: { id: '123' }, permissions: [] },
breadcrumbs: { breadcrumbs: [] },
components: { sidebarCollapsed: false },
} as any)

const wrapper = mount(
<Provider store={store}>
<MemoryRouter initialEntries={['/imaging']}>
<HospitalRun />
</MemoryRouter>
</Provider>,
)

expect(wrapper.find(ViewImagings)).toHaveLength(0)
expect(wrapper.find(Dashboard)).toHaveLength(1)
})
})

describe('/settings', () => {
it('should render the Settings component when /settings is accessed', async () => {
const store = mockStore({
Expand Down
74 changes: 74 additions & 0 deletions src/__tests__/imagings/Imagings.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { mount } from 'enzyme'
import React from 'react'
import { Provider } from 'react-redux'
import { MemoryRouter } from 'react-router-dom'
import createMockStore from 'redux-mock-store'
import thunk from 'redux-thunk'

import Imagings from '../../imagings/Imagings'
import NewImagingRequest from '../../imagings/requests/NewImagingRequest'
import ImagingRepository from '../../shared/db/ImagingRepository'
import PatientRepository from '../../shared/db/PatientRepository'
import Imaging from '../../shared/model/Imaging'
import Patient from '../../shared/model/Patient'
import Permissions from '../../shared/model/Permissions'
import { RootState } from '../../shared/store'

const mockStore = createMockStore<RootState, any>([thunk])

describe('Imagings', () => {
jest.spyOn(ImagingRepository, 'findAll').mockResolvedValue([])
jest
.spyOn(ImagingRepository, 'find')
.mockResolvedValue({ id: '1234', requestedOn: new Date().toISOString() } as Imaging)
jest
.spyOn(PatientRepository, 'find')
.mockResolvedValue({ id: '12345', fullName: 'test test' } as Patient)

describe('routing', () => {
describe('/imaging/new', () => {
it('should render the new imaging request screen when /imaging/new is accessed', () => {
const store = mockStore({
title: 'test',
user: { permissions: [Permissions.RequestImaging] },
breadcrumbs: { breadcrumbs: [] },
components: { sidebarCollapsed: false },
imaging: {
imaging: { id: 'imagingId', patient: 'patient' } as Imaging,
patient: { id: 'patientId', fullName: 'some name' },
error: {},
},
} as any)

const wrapper = mount(
<Provider store={store}>
<MemoryRouter initialEntries={['/imaging/new']}>
<Imagings />
</MemoryRouter>
</Provider>,
)

expect(wrapper.find(NewImagingRequest)).toHaveLength(1)
})

it('should not navigate to /imagings/new if the user does not have RequestLab permissions', () => {
const store = mockStore({
title: 'test',
user: { permissions: [] },
breadcrumbs: { breadcrumbs: [] },
components: { sidebarCollapsed: false },
} as any)

const wrapper = mount(
<Provider store={store}>
<MemoryRouter initialEntries={['/imagings/new']}>
<Imagings />
</MemoryRouter>
</Provider>,
)

expect(wrapper.find(NewImagingRequest)).toHaveLength(0)
})
})
})
})

0 comments on commit 5cf1307

Please sign in to comment.