author
int64 658
755k
| date
stringlengths 19
19
| timezone
int64 -46,800
43.2k
| hash
stringlengths 40
40
| message
stringlengths 5
490
| mods
list | language
stringclasses 20
values | license
stringclasses 3
values | repo
stringlengths 5
68
| original_message
stringlengths 12
491
|
---|---|---|---|---|---|---|---|---|---|
288,323 | 17.06.2020 22:17:39 | 18,000 | 701b03dfb2477b032087ff0ac3823c5601fb282e | docs: add auth docs | [
{
"change_type": "MODIFY",
"old_path": ".github/CONTRIBUTING.md",
"new_path": ".github/CONTRIBUTING.md",
"diff": "@@ -15,12 +15,41 @@ To contribute,\n## Setting up the Local Development Environment\n+### Get the source code\n1. [Fork](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) this repository\n2. Open your favorite command line tool and navigate to the directory you wish to clone this repository to: `cd /path/to/clone`\n3. [Clone](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository) your fork: `git clone [email protected]:{your username}/hospitalrun-frontend.git`\n4. Navigate to the hosptialrun-frontend directory: `cd hospitalrun-frontend`\n-5. Install dependencies: `yarn`\n-6. Run the application `yarn start`\n+\n+### Configure CouchDB\n+CouchDB is the server side database which data from the frontend will sync to. In order to login\n+to HospitalRun, CouchDB is required. For convienence, we have added a docker compose file in the\n+root of this project to help launch CouchDB. However, you could install and run CouchDB in any way you wish.\n+\n+The following directions will be for running CouchDB via Docker Compose.\n+\n+1. Install [Docker](https://docs.docker.com/get-docker/)\n+2. Install [Docker Compose](https://docs.docker.com/compose/install/)\n+3. Run `docker-compose up` in the root directory.\n+> This should launch a new CouchDB instance on `http://localhost:5984` and create a default admin\n+> user with a username of `admin` and password of 'password'\n+4. Launch `http://localhost:5984/_utils` to view Fauxton.\n+5. Sign in with the admin credentials.\n+6. Navigate to the configuraiton page in Fauxton.\n+7. In the CORS tab, enable CORS and allow requests from All domains (*)\n+8. In the Main config tab, set `couchdb -> users_db_security_editable` to true\n+9. Disable default `_users` security: `curl admin:password@localhost:5984/_users/_security -XPUT -d '{}'`\n+9. Create a new user with:\n+```\n+curl -X PUT http://hradmin:password@localhost:5984/_users/org.couchdb.user:${username} \\\n+ -H \"Accept: application/json\" \\\n+ -H \"Content-Type: application/json\" \\\n+ -d '{\"name\": \"${username}\", \"password\": \"password\", \"roles\": [], \"type\": \"user\"}'\n+```\n+\n+### Install dependencies & start the application\n+1. Install dependencies: `npm install`\n+2. Run the application `npm start`\n## Online one-click setup for contributing\n"
},
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -29,14 +29,9 @@ React frontend for [HospitalRun](http://hospitalrun.io/): free software for deve\nContributions are always welcome. Before contributing please read our [contributor guide](https://github.com/HospitalRun/hospitalrun-frontend/blob/master/.github/CONTRIBUTING.md).\n-1. Fork this repository to your own GitHub account and then clone it to your local device\n-2. Navigate to the cloned folder: `cd hospitalrun-frontend`\n-3. Install the dependencies: `npm install`\n-4. Run `npm run start` to build and watch for code changes\n-\n## Translation\n-Use the stadards in [this readme](https://github.com/HospitalRun/hospitalrun-frontend/tree/master/src/locales/README.md).\n+Use the standards in [this readme](https://github.com/HospitalRun/hospitalrun-frontend/tree/master/src/locales/README.md).\n## Online one-click setup for contributing\n@@ -44,41 +39,6 @@ Contribute to HospitalRun using a fully featured online development environment\n[](https://gitpod.io/#https://github.com/HospitalRun/hospitalrun-frontend)\n-## Connecting to HospitalRun Server\n-\n-**Note: The following instructions are for connecting to HospitalRun Server during development and are not intended to be for production use. For production deployments, see the deployment instructions.**\n-\n-1. Configure [HospitalRun Server](https://github.com/HospitalRun/hospitalrun-server)\n-2. Start the HospitalRun Development Server\n-3. Copy the `.env.example` file to `.env`\n-4. Change the `REACT_APP_HOSPITALRUN_API` variable to point to the HospitalRun Development Server.\n-\n-### Potential Setup Issues\n-\n-Some developers have reported the following errors and the corresponding fixes\n-\n-### Problem with Project Dependency Tree\n-\n-```\n-There might be a problem with the project dependency tree.\n-It is likely not a bug in Create React App, but something you need to fix locally.\n-The react-scripts package provided by Create React App requires a dependency:\n- \"babel-loader\": \"8.1.0\"\n-Don't try to install it manually: your package manager does it automatically.\n-However, a different version of babel-loader was detected higher up in the tree:\n- /path/to/hospitalrun/node_modules/babel-loader (version: 8.0.6)\n-Manually installing incompatible versions is known to cause hard-to-debug issues.\n-If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.\n-That will permanently disable this message but you might encounter other issues.\n-To fix the dependency tree, try following the steps below in the exact order:\n- 1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.\n- 2. Delete node_modules in your project folder.\n- 3. Remove \"babel-loader\" from dependencies and/or devDependencies in the package.json file in your project folder.\n- 4. Run npm install or yarn, depending on the package manager you use.\n-```\n-\n-To fix this issue, add `SKIP_PREFLIGHT_CHECK=true` to the `.env` file.\n-\n## Running Tests and Linter\n`npm run test:ci` will run the entire test suite\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "docker-compose.yml",
"diff": "+version: '3.8'\n+\n+services:\n+ couchdb:\n+ image: couchdb:3.1.0\n+ container_name: hospitalrun\n+ ports:\n+ - \"5984:5984\"\n+ environment:\n+ - COUCHDB_USER=admin\n+ - COUCHDB_PASSWORD=password\n+\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | docs: add auth docs |
288,323 | 17.06.2020 22:19:39 | 18,000 | 9e9b1c0dbd9fd2da4d2ec6e743aa7a34b33d1adb | test: fix auth related tests | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/App.test.tsx",
"new_path": "src/__tests__/App.test.tsx",
"diff": "@@ -4,11 +4,8 @@ import { shallow } from 'enzyme'\nimport React from 'react'\nimport App from '../App'\n-import HospitalRun from '../HospitalRun'\n-import Login from '../login/Login'\nit('renders without crashing', () => {\nconst wrapper = shallow(<App />)\n- expect(wrapper.find(HospitalRun)).toHaveLength(1)\n- expect(wrapper.find(Login)).toHaveLength(1)\n+ expect(wrapper).toBeDefined()\n})\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | test: fix auth related tests |
288,323 | 17.06.2020 22:37:50 | 18,000 | 3cee6cc362aeb29f0d94cd123e5ae02177dcb9fd | docs: add note about configuring node | [
{
"change_type": "MODIFY",
"old_path": ".github/CONTRIBUTING.md",
"new_path": ".github/CONTRIBUTING.md",
"diff": "@@ -38,8 +38,9 @@ The following directions will be for running CouchDB via Docker Compose.\n6. Navigate to the configuraiton page in Fauxton.\n7. In the CORS tab, enable CORS and allow requests from All domains (*)\n8. In the Main config tab, set `couchdb -> users_db_security_editable` to true\n-9. Disable default `_users` security: `curl admin:password@localhost:5984/_users/_security -XPUT -d '{}'`\n-9. Create a new user with:\n+9. In the Setup Apache CouchDB tab, configure a single node. Enter your username and password and leave the rest of the defaults.\n+10. Disable default `_users` security: `curl admin:password@localhost:5984/_users/_security -XPUT -d '{}'`\n+11. Create a new user with:\n```\ncurl -X PUT http://hradmin:password@localhost:5984/_users/org.couchdb.user:${username} \\\n-H \"Accept: application/json\" \\\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | docs: add note about configuring node |
288,323 | 17.06.2020 23:22:45 | 18,000 | e9f9c5ec1696224955721ebda62f7424c6ff36f2 | doc: fix typo in admin username | [
{
"change_type": "MODIFY",
"old_path": ".github/CONTRIBUTING.md",
"new_path": ".github/CONTRIBUTING.md",
"diff": "@@ -42,7 +42,7 @@ The following directions will be for running CouchDB via Docker Compose.\n10. Disable default `_users` security: `curl admin:password@localhost:5984/_users/_security -XPUT -d '{}'`\n11. Create a new user with:\n```\n-curl -X PUT http://hradmin:password@localhost:5984/_users/org.couchdb.user:${username} \\\n+curl -X PUT http://admin:password@localhost:5984/_users/org.couchdb.user:${username} \\\n-H \"Accept: application/json\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\"name\": \"${username}\", \"password\": \"password\", \"roles\": [], \"type\": \"user\"}'\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | doc: fix typo in admin username |
288,323 | 17.06.2020 23:24:23 | 18,000 | 828362c15bd9cef786f29b8579715e66e6df6f88 | docs: add note about replacing username | [
{
"change_type": "MODIFY",
"old_path": ".github/CONTRIBUTING.md",
"new_path": ".github/CONTRIBUTING.md",
"diff": "@@ -40,7 +40,7 @@ The following directions will be for running CouchDB via Docker Compose.\n8. In the Main config tab, set `couchdb -> users_db_security_editable` to true\n9. In the Setup Apache CouchDB tab, configure a single node. Enter your username and password and leave the rest of the defaults.\n10. Disable default `_users` security: `curl admin:password@localhost:5984/_users/_security -XPUT -d '{}'`\n-11. Create a new user with:\n+11. Create a new user with (replace `${username]` with a username of your choosing):\n```\ncurl -X PUT http://admin:password@localhost:5984/_users/org.couchdb.user:${username} \\\n-H \"Accept: application/json\" \\\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | docs: add note about replacing username |
288,323 | 17.06.2020 23:29:49 | 18,000 | 110993d6228452b7d4cc2ff4c02e2487136c26e7 | docs: add env config | [
{
"change_type": "MODIFY",
"old_path": ".github/CONTRIBUTING.md",
"new_path": ".github/CONTRIBUTING.md",
"diff": "@@ -50,7 +50,8 @@ curl -X PUT http://admin:password@localhost:5984/_users/org.couchdb.user:${usern\n### Install dependencies & start the application\n1. Install dependencies: `npm install`\n-2. Run the application `npm start`\n+2. Configure `REACT_APP_HOSPITALRUN_API=http://localhost:5984` environment variable in `.env`\n+3. Run the application `npm start`\n## Online one-click setup for contributing\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | docs: add env config |
288,323 | 17.06.2020 23:31:45 | 18,000 | 928a8254ad10f532a814a5f2060bb7d648c4bdf4 | docs: clarify config steps | [
{
"change_type": "MODIFY",
"old_path": ".github/CONTRIBUTING.md",
"new_path": ".github/CONTRIBUTING.md",
"diff": "@@ -37,10 +37,10 @@ The following directions will be for running CouchDB via Docker Compose.\n5. Sign in with the admin credentials.\n6. Navigate to the configuraiton page in Fauxton.\n7. In the CORS tab, enable CORS and allow requests from All domains (*)\n-8. In the Main config tab, set `couchdb -> users_db_security_editable` to true\n-9. In the Setup Apache CouchDB tab, configure a single node. Enter your username and password and leave the rest of the defaults.\n+8. In the Main config tab, set `couchdb -> users_db_security_editable` to true (click on field to make it editable)\n+9. In the Setup Apache CouchDB tab (wrench tab), configure a single node. Enter your username and password and leave the rest of the defaults.\n10. Disable default `_users` security: `curl admin:password@localhost:5984/_users/_security -XPUT -d '{}'`\n-11. Create a new user with (replace `${username]` with a username of your choosing):\n+11. Create a new user with (replace `$({username]` with a username of your choosing):\n```\ncurl -X PUT http://admin:password@localhost:5984/_users/org.couchdb.user:${username} \\\n-H \"Accept: application/json\" \\\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | docs: clarify config steps |
288,323 | 17.06.2020 23:51:53 | 18,000 | e466339839b167f976764a0f3d8989c58ce660f5 | docs: add db setup step | [
{
"change_type": "MODIFY",
"old_path": ".github/CONTRIBUTING.md",
"new_path": ".github/CONTRIBUTING.md",
"diff": "@@ -47,6 +47,7 @@ curl -X PUT http://admin:password@localhost:5984/_users/org.couchdb.user:${usern\n-H \"Content-Type: application/json\" \\\n-d '{\"name\": \"${username}\", \"password\": \"password\", \"roles\": [], \"type\": \"user\"}'\n```\n+12. Create a new database called `hospitalrun` in Fauxton (choose non-partitioned)\n### Install dependencies & start the application\n1. Install dependencies: `npm install`\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | docs: add db setup step |
288,323 | 17.06.2020 23:55:11 | 18,000 | 8a057c5abd61a5ea28d7fe847a53728746e83f89 | docs: add permissions step | [
{
"change_type": "MODIFY",
"old_path": ".github/CONTRIBUTING.md",
"new_path": ".github/CONTRIBUTING.md",
"diff": "@@ -48,6 +48,7 @@ curl -X PUT http://admin:password@localhost:5984/_users/org.couchdb.user:${usern\n-d '{\"name\": \"${username}\", \"password\": \"password\", \"roles\": [], \"type\": \"user\"}'\n```\n12. Create a new database called `hospitalrun` in Fauxton (choose non-partitioned)\n+13. Make sure to remove all permissions (to make DB public) for the new `hospitalrun` database.\n### Install dependencies & start the application\n1. Install dependencies: `npm install`\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | docs: add permissions step |
288,323 | 18.06.2020 00:02:54 | 18,000 | 1f10e26a52036d81409718b889a756d8e983fccc | docs: add metadata | [
{
"change_type": "MODIFY",
"old_path": ".github/CONTRIBUTING.md",
"new_path": ".github/CONTRIBUTING.md",
"diff": "@@ -40,12 +40,12 @@ The following directions will be for running CouchDB via Docker Compose.\n8. In the Main config tab, set `couchdb -> users_db_security_editable` to true (click on field to make it editable)\n9. In the Setup Apache CouchDB tab (wrench tab), configure a single node. Enter your username and password and leave the rest of the defaults.\n10. Disable default `_users` security: `curl admin:password@localhost:5984/_users/_security -XPUT -d '{}'`\n-11. Create a new user with (replace `$({username]` with a username of your choosing):\n+11. Create a new user with (replace `${*}` with content of your choosing):\n```\ncurl -X PUT http://admin:password@localhost:5984/_users/org.couchdb.user:${username} \\\n-H \"Accept: application/json\" \\\n-H \"Content-Type: application/json\" \\\n- -d '{\"name\": \"${username}\", \"password\": \"password\", \"roles\": [], \"type\": \"user\"}'\n+ -d '{\"name\": \"${username}\", \"password\": \"password\", \"metadata\": { \"givenName\": \"${givenName}\", \"familyName\": \"${familyName}\"}, \"roles\": [], \"type\": \"user\"}'\n```\n12. Create a new database called `hospitalrun` in Fauxton (choose non-partitioned)\n13. Make sure to remove all permissions (to make DB public) for the new `hospitalrun` database.\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | docs: add metadata |
288,334 | 19.06.2020 20:33:13 | -7,200 | 3552c9c7a929465febc9b3326141deafed7dc110 | perf(docker): improve creation of couchdb database with single command | [
{
"change_type": "MODIFY",
"old_path": ".github/CONTRIBUTING.md",
"new_path": ".github/CONTRIBUTING.md",
"diff": "@@ -16,12 +16,14 @@ To contribute,\n## Setting up the Local Development Environment\n### Get the source code\n+\n1. [Fork](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) this repository\n2. Open your favorite command line tool and navigate to the directory you wish to clone this repository to: `cd /path/to/clone`\n3. [Clone](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository) your fork: `git clone [email protected]:{your username}/hospitalrun-frontend.git`\n4. Navigate to the hosptialrun-frontend directory: `cd hospitalrun-frontend`\n### Configure CouchDB\n+\nCouchDB is the server side database which data from the frontend will sync to. In order to login\nto HospitalRun, CouchDB is required. For convienence, we have added a docker compose file in the\nroot of this project to help launch CouchDB. However, you could install and run CouchDB in any way you wish.\n@@ -30,27 +32,17 @@ The following directions will be for running CouchDB via Docker Compose.\n1. Install [Docker](https://docs.docker.com/get-docker/)\n2. Install [Docker Compose](https://docs.docker.com/compose/install/)\n-3. Run `docker-compose up` in the root directory.\n-> This should launch a new CouchDB instance on `http://localhost:5984` and create a default admin\n-> user with a username of `admin` and password of 'password'\n-4. Launch `http://localhost:5984/_utils` to view Fauxton.\n-5. Sign in with the admin credentials.\n-6. Navigate to the configuraiton page in Fauxton.\n-7. In the CORS tab, enable CORS and allow requests from All domains (*)\n-8. In the Main config tab, set `couchdb -> users_db_security_editable` to true (click on field to make it editable)\n-9. In the Setup Apache CouchDB tab (wrench tab), configure a single node. Enter your username and password and leave the rest of the defaults.\n-10. Disable default `_users` security: `curl admin:password@localhost:5984/_users/_security -XPUT -d '{}'`\n-11. Create a new user with (replace `${*}` with content of your choosing):\n-```\n-curl -X PUT http://admin:password@localhost:5984/_users/org.couchdb.user:${username} \\\n- -H \"Accept: application/json\" \\\n- -H \"Content-Type: application/json\" \\\n- -d '{\"name\": \"${username}\", \"password\": \"password\", \"metadata\": { \"givenName\": \"${givenName}\", \"familyName\": \"${familyName}\"}, \"roles\": [], \"type\": \"user\"}'\n-```\n-12. Create a new database called `hospitalrun` in Fauxton (choose non-partitioned)\n-13. Make sure to remove all permissions (to make DB public) for the new `hospitalrun` database.\n+3. Run `docker-compose up --build -d` in the root directory.\n+\n+This should launch a new CouchDB instance on `http://localhost:5984`, create system database, configure CouchDB as Single Node, enable CORS, create `hospitalrun` database, create a default admin with a username of `admin` and password of 'password', create a sample user with a username of `username` and password of 'password' to use to test the login.\n+\n+4. Launch `http://localhost:5984/_utils` to view Fauxton and perform administrative tasks.\n+\n+**_Cleanup_**\n+To delete the development database, go to the root of the project and run `docker-compose down -v --rmi all --remove-orphans`\n### Install dependencies & start the application\n+\n1. Install dependencies: `npm install`\n2. Configure `REACT_APP_HOSPITALRUN_API=http://localhost:5984` environment variable in `.env`\n3. Run the application `npm start`\n"
},
{
"change_type": "DELETE",
"old_path": "Dockerfile",
"new_path": null,
"diff": "-FROM node:12-alpine as build\n-\n-ENV HOME=/home/app\n-COPY . $HOME/node/\n-\n-WORKDIR $HOME/node\n-RUN npm install -q\n-\n-RUN npm run build\n-RUN npm prune --production\n-\n-FROM nginx:stable-alpine\n-\n-COPY --from=build /home/app/node/build/ /usr/share/nginx/html\n-COPY nginx.conf /etc/nginx/conf.d/default.conf\n-EXPOSE 80\n-CMD [\"nginx\", \"-g\", \"daemon off;\"]\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "couchdb/Dockerfile",
"diff": "+FROM couchdb:3.1.0\n+\n+COPY local.ini /opt/couchdb/etc/local.d/\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "couchdb/local.ini",
"diff": "+[couchdb]\n+single_node=true\n+users_db_security_editable = true\n+\n+[httpd]\n+enable_cors = true\n+\n+[cors]\n+origins = *\n"
},
{
"change_type": "MODIFY",
"old_path": "docker-compose.yml",
"new_path": "docker-compose.yml",
"diff": "-version: '3.8'\n+# Dockerc compose only for developing purpose\n+\n+version: \"3.8\"\nservices:\ncouchdb:\n- image: couchdb:3.1.0\n- container_name: hospitalrun\n+ build:\n+ context: ./couchdb\n+ dockerfile: Dockerfile\n+ container_name: hr_couchdb\nports:\n- \"5984:5984\"\nenvironment:\n- COUCHDB_USER=admin\n- COUCHDB_PASSWORD=password\n+ dbinit:\n+ image: alpine\n+ command: >\n+ sh -c \"apk add curl &&\n+ curl -X PUT http://admin:password@couchdb:5984/_global_changes\n+ && curl -X PUT http://admin:password@hr_couchdb:5984/hospitalrun?partitioned=false\n+ && curl -X PUT http://admin:password@hr_couchdb:5984/_users/_security -d '{}'\n+ && curl -X PUT http://admin:password@hr_couchdb:5984/_users/org.couchdb.user:username \\\n+ -H \"Accept: application/json\" \\\n+ -H \"Content-Type: application/json\" \\\n+ -d '{\"name\": \"username\", \"password\": \"password\", \"metadata\": { \"givenName\": \"John\", \"familyName\": \"Doe\"}, \"roles\": [], \"type\": \"user\"}'\n+ && exit\"\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | perf(docker): improve creation of couchdb database with single command |
288,334 | 19.06.2020 21:54:50 | -7,200 | 7e48227b722607a7a3acbfbf6bec31df08c2e44e | chore(docker): wip new user command | [
{
"change_type": "MODIFY",
"old_path": "couchdb/local.ini",
"new_path": "couchdb/local.ini",
"diff": "@@ -7,3 +7,6 @@ enable_cors = true\n[cors]\norigins = *\n+\n+[chttpd]\n+bind_address = 0.0.0.0\n"
},
{
"change_type": "MODIFY",
"old_path": "docker-compose.yml",
"new_path": "docker-compose.yml",
"diff": "@@ -15,14 +15,16 @@ services:\n- COUCHDB_PASSWORD=password\ndbinit:\n- image: alpine\n+ image: curlimages/curl\ncommand: >\n- sh -c \"apk add curl &&\n- curl -X PUT http://admin:password@couchdb:5984/_global_changes\n- && curl -X PUT http://admin:password@hr_couchdb:5984/hospitalrun?partitioned=false\n- && curl -X PUT http://admin:password@hr_couchdb:5984/_users/_security -d '{}'\n- && curl -X PUT http://admin:password@hr_couchdb:5984/_users/org.couchdb.user:username \\\n- -H \"Accept: application/json\" \\\n- -H \"Content-Type: application/json\" \\\n- -d '{\"name\": \"username\", \"password\": \"password\", \"metadata\": { \"givenName\": \"John\", \"familyName\": \"Doe\"}, \"roles\": [], \"type\": \"user\"}'\n- && exit\"\n+ sh -c\n+ \"sleep 5s &&\n+ curl -X PUT http://admin:password@couchdb:5984/_global_changes &&\n+ sleep 1s &&\n+ curl -X PUT http://admin:password@couchdb:5984/_users/_security -d '{}' &&\n+ sleep 1s &&\n+ curl -X PUT http://admin:password@couchdb:5984/hospitalrun?partitioned=false &&\n+ sleep 1s &&\n+ curl -X PUT http://admin:password@couchdb:5984/_users/org.couchdb.user:username -H \"Accept: application/json\" -H \"Content-Type: application/json\" -d '{\"name\": \"username\", \"password\": \"password\", \"metadata\": { \"givenName\": \"John\", \"familyName\": \"Doe\"}, \"roles\": [], \"type\": \"user\"}'\n+ && sleep 1s\n+ \"\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | chore(docker): wip new user command |
288,334 | 21.06.2020 21:59:33 | -7,200 | 2e4b1c744822ee44da5e88460b8137133dc2fee1 | chore(docker): remove user creation from docker compose | [
{
"change_type": "MODIFY",
"old_path": ".github/CONTRIBUTING.md",
"new_path": ".github/CONTRIBUTING.md",
"diff": "@@ -34,9 +34,15 @@ The following directions will be for running CouchDB via Docker Compose.\n2. Install [Docker Compose](https://docs.docker.com/compose/install/)\n3. Run `docker-compose up --build -d` in the root directory.\n-This should launch a new CouchDB instance on `http://localhost:5984`, create system database, configure CouchDB as Single Node, enable CORS, create `hospitalrun` database, create a default admin with a username of `admin` and password of 'password', create a sample user with a username of `username` and password of 'password' to use to test the login.\n+This should launch a new CouchDB instance on `http://localhost:5984`, create system database, configure CouchDB as Single Node, enable CORS, create `hospitalrun` database, create a default admin with a username of `admin` and password of 'password'\n-4. Launch `http://localhost:5984/_utils` to view Fauxton and perform administrative tasks.\n+4. Create a sample user with a username of `username` and password of 'password' to use new login page [#2137](https://github.com/HospitalRun/hospitalrun-frontend/pull/2137)\n+\n+ ```\n+ curl -X PUT http://admin:password@localhost:5984/_users/org.couchdb.user:username -H \"Accept: application/json\" -H \"Content-Type: application/json\" -d '{\"name\": \"username\", \"password\": \"password\", \"metadata\": { \"givenName\": \"John\", \"familyName\": \"Doe\"}, \"roles\": [], \"type\": \"user\"}'\n+ ```\n+\n+5. Launch `http://localhost:5984/_utils` to view Fauxton and perform administrative tasks.\n**_Cleanup_**\nTo delete the development database, go to the root of the project and run `docker-compose down -v --rmi all --remove-orphans`\n"
},
{
"change_type": "MODIFY",
"old_path": "docker-compose.yml",
"new_path": "docker-compose.yml",
"diff": "@@ -20,11 +20,5 @@ services:\nsh -c\n\"sleep 5s &&\ncurl -X PUT http://admin:password@couchdb:5984/_global_changes &&\n- sleep 1s &&\ncurl -X PUT http://admin:password@couchdb:5984/_users/_security -d '{}' &&\n- sleep 1s &&\n- curl -X PUT http://admin:password@couchdb:5984/hospitalrun?partitioned=false &&\n- sleep 1s &&\n- curl -X PUT http://admin:password@couchdb:5984/_users/org.couchdb.user:username -H \"Accept: application/json\" -H \"Content-Type: application/json\" -d '{\"name\": \"username\", \"password\": \"password\", \"metadata\": { \"givenName\": \"John\", \"familyName\": \"Doe\"}, \"roles\": [], \"type\": \"user\"}'\n- && sleep 1s\n- \"\n+ curl -X PUT http://admin:password@couchdb:5984/hospitalrun?partitioned=false\"\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | chore(docker): remove user creation from docker compose |
288,366 | 22.06.2020 20:37:22 | 18,000 | 34e6041cd051aa8ce98bdf359cc6874da1244096 | fix(patient): make note not required in care plan | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/care-plans/AddCarePlanModal.test.tsx",
"new_path": "src/__tests__/patients/care-plans/AddCarePlanModal.test.tsx",
"diff": "@@ -9,6 +9,7 @@ import { Router } from 'react-router-dom'\nimport createMockStore from 'redux-mock-store'\nimport thunk from 'redux-thunk'\n+import PatientRepository from '../../../clients/db/PatientRepository'\nimport { CarePlanIntent, CarePlanStatus } from '../../../model/CarePlan'\nimport Patient from '../../../model/Patient'\nimport AddCarePlanModal from '../../../patients/care-plans/AddCarePlanModal'\n@@ -42,6 +43,8 @@ describe('Add Care Plan Modal', () => {\nconst onCloseSpy = jest.fn()\nconst setup = () => {\n+ jest.spyOn(PatientRepository, 'find').mockResolvedValue(patient)\n+ jest.spyOn(PatientRepository, 'saveOrUpdate')\nconst store = mockStore({ patient: { patient, carePlanError } } as any)\nconst history = createMemoryHistory()\nconst wrapper = mount(\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/care-plans/CarePlanForm.test.tsx",
"new_path": "src/__tests__/patients/care-plans/CarePlanForm.test.tsx",
"diff": "@@ -226,7 +226,6 @@ describe('Care Plan Form', () => {\nconst noteInput = wrapper.findWhere((w) => w.prop('name') === 'note')\nexpect(noteInput).toHaveLength(1)\nexpect(noteInput.prop('patient.carePlan.note'))\n- expect(noteInput.prop('isRequired')).toBeTruthy()\nexpect(noteInput.prop('value')).toEqual(carePlan.note)\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/patient-slice.test.ts",
"new_path": "src/__tests__/patients/patient-slice.test.ts",
"diff": "@@ -699,7 +699,6 @@ describe('patients slice', () => {\nstartDate: 'patient.carePlan.error.startDateRequired',\nendDate: 'patient.carePlan.error.endDateRequired',\ncondition: 'patient.carePlan.error.conditionRequired',\n- note: 'patient.carePlan.error.noteRequired',\n}\nconst store = mockStore()\nconst expectedCarePlan = {} as CarePlan\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/care-plans/CarePlanForm.tsx",
"new_path": "src/patients/care-plans/CarePlanForm.tsx",
"diff": "@@ -145,7 +145,6 @@ const CarePlanForm = (props: Props) => {\n<Row>\n<Column sm={12}>\n<TextFieldWithLabelFormGroup\n- isRequired\nvalue={carePlan.note}\nlabel={t('patient.carePlan.note')}\nname=\"note\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/patient-slice.ts",
"new_path": "src/patients/patient-slice.ts",
"diff": "@@ -457,10 +457,6 @@ function validateCarePlan(carePlan: CarePlan): AddCarePlanError {\nerror.condition = 'patient.carePlan.error.conditionRequired'\n}\n- if (!carePlan.note) {\n- error.note = 'patient.carePlan.error.noteRequired'\n- }\n-\nreturn error\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(patient): make note not required in care plan (#2158)
Co-authored-by: HospitalRun Bot <[email protected]>
Co-authored-by: Matteo Vivona <[email protected]>
Co-authored-by: Jack Meyer <[email protected]> |
288,334 | 23.06.2020 10:29:12 | -7,200 | db0882f4db9b549c89fe7a88914af574de5a35a8 | docs(contributing): add note on PR | [
{
"change_type": "MODIFY",
"old_path": ".github/CONTRIBUTING.md",
"new_path": ".github/CONTRIBUTING.md",
"diff": "@@ -96,13 +96,14 @@ Before submitting a request, please search for similar ones in the\n## Pull Requests\n-1. Ensure any install or build dependencies are removed before the end of the layer when doing a\n+1. **Don't open the PR until it's ready for review. We need to optimize build time.**\n+2. Ensure any install or build dependencies are removed before the end of the layer when doing a\nbuild.\n-2. Update the README.md with details of changes to the interface, this includes new environment\n+3. Update the README.md with details of changes to the interface, this includes new environment\nvariables, exposed ports, useful file locations and container parameters.\n-3. Increase the version numbers in any examples files and the README.md to the new version that this\n+4. Increase the version numbers in any examples files and the README.md to the new version that this\nPull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).\n-4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you\n+5. You may merge the Pull Request in once you have the sign-off of two other developers, or if you\ndo not have permission to do that, you may request the second reviewer to merge it for you.\n## Contributor License Agreement\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | docs(contributing): add note on PR |
288,334 | 23.06.2020 20:53:00 | -7,200 | f19d276bff9fa8aaf906cf0b8f1f97dcfa362e4a | fix(eslint): fix pouchdb test error | [
{
"change_type": "MODIFY",
"old_path": "check-translations/.eslintrc.js",
"new_path": "check-translations/.eslintrc.js",
"diff": "module.exports = {\nextends: '../.eslintrc.js',\nrules: {\n- \"import/no-extraneous-dependencies\": [\"error\", {\"devDependencies\": true}]\n- }\n+ 'import/no-extraneous-dependencies': ['error', { devDependencies: true }],\n+ },\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"node-sass\": \"~4.14.0\",\n\"pouchdb\": \"~7.2.1\",\n\"pouchdb-adapter-memory\": \"~7.2.1\",\n- \"pouchdb-authentication\": \"~1.1.3\",\n\"pouchdb-find\": \"~7.2.1\",\n\"pouchdb-quick-search\": \"~1.3.0\",\n\"react\": \"~16.13.0\",\n\"react-scripts\": \"~3.4.0\",\n\"redux\": \"~4.0.5\",\n\"redux-thunk\": \"~2.3.0\",\n- \"relational-pouch\": \"~4.0.0\",\n\"shortid\": \"^2.2.15\",\n\"typescript\": \"~3.8.3\",\n\"uuid\": \"^8.0.0\",\n\"@types/validator\": \"~13.0.0\",\n\"@typescript-eslint/eslint-plugin\": \"~3.4.0\",\n\"@typescript-eslint/parser\": \"~3.4.0\",\n- \"chalk\": \"~4.1.0\",\n+ \"chalk\": \"^4.0.0\",\n\"commitizen\": \"~4.1.2\",\n\"commitlint-config-cz\": \"~0.13.0\",\n\"cross-env\": \"~7.0.0\",\n},\n\"scripts\": {\n\"analyze\": \"source-map-explorer 'build/static/js/*.js'\",\n- \"commit\": \"npx git-cz\",\n+ \"commit\": \"npx git-cz --disable-emoji\",\n\"start\": \"npm run translation:check && react-scripts start\",\n\"build\": \"react-scripts build\",\n\"update\": \"npx npm-check -u\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/config/pouchdb.ts",
"new_path": "src/config/pouchdb.ts",
"diff": "-/* eslint-disable @typescript-eslint/camelcase, @typescript-eslint/no-var-requires */\n+/* eslint-disable @typescript-eslint/no-var-requires */\n+/* eslint-disable camelcase */\nimport PouchDB from 'pouchdb'\nimport PouchAuth from 'pouchdb-authentication'\nimport PouchdbFind from 'pouchdb-find'\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(eslint): fix pouchdb test error |
288,334 | 23.06.2020 20:55:46 | -7,200 | 402bea51a4e3312f6838f24e61a2dacf8c9e2433 | chore(git-cz): remove unused flag | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "},\n\"scripts\": {\n\"analyze\": \"source-map-explorer 'build/static/js/*.js'\",\n- \"commit\": \"npx git-cz --disable-emoji\",\n+ \"commit\": \"npx git-cz\",\n\"start\": \"npm run translation:check && react-scripts start\",\n\"build\": \"react-scripts build\",\n\"update\": \"npx npm-check -u\",\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | chore(git-cz): remove unused flag |
288,334 | 23.06.2020 21:10:01 | -7,200 | f0da26a296a777481b111f3671cea44410755007 | chore(deps): readd missing deps | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"node-sass\": \"~4.14.0\",\n\"pouchdb\": \"~7.2.1\",\n\"pouchdb-adapter-memory\": \"~7.2.1\",\n+ \"pouchdb-authentication\": \"~1.1.3\",\n\"pouchdb-find\": \"~7.2.1\",\n\"pouchdb-quick-search\": \"~1.3.0\",\n\"react\": \"~16.13.0\",\n\"react-scripts\": \"~3.4.0\",\n\"redux\": \"~4.0.5\",\n\"redux-thunk\": \"~2.3.0\",\n+ \"relational-pouch\": \"~4.0.0\",\n\"shortid\": \"^2.2.15\",\n\"typescript\": \"~3.8.3\",\n\"uuid\": \"^8.0.0\",\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | chore(deps): readd missing deps |
288,249 | 23.06.2020 16:52:43 | 25,200 | c38004bf9285a6cc53c36150754bd659130e5998 | feat: apply select component changes | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"private\": false,\n\"license\": \"MIT\",\n\"dependencies\": {\n- \"@hospitalrun/components\": \"~1.6.0\",\n+ \"@hospitalrun/components\": \"~1.14.1\",\n\"@reduxjs/toolkit\": \"~1.4.0\",\n\"@types/escape-string-regexp\": \"~2.0.1\",\n\"@types/pouchdb-find\": \"~6.3.4\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/components/PageComponent.tsx",
"new_path": "src/components/PageComponent.tsx",
"diff": "@@ -18,7 +18,6 @@ const PageComponent = ({\npageNumber,\nsetPreviousPageRequest,\nsetNextPageRequest,\n- onPageSizeChange,\n}: any) => {\nconst { t } = useTranslation()\n@@ -48,13 +47,7 @@ const PageComponent = ({\n{t('actions.page')} {pageNumber}\n</div>\n<div className=\"row float-right\">\n- <Select onChange={onPageSizeChange} defaultValue={defaultPageSize.label}>\n- {pageSizes.map((pageSize) => (\n- <option key={pageSize.label} value={pageSize.value}>\n- {pageSize.label}\n- </option>\n- ))}\n- </Select>\n+ <Select id=\"page\" options={pageSizes} />\n</div>\n</div>\n)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/components/input/LanguageSelector.tsx",
"new_path": "src/components/input/LanguageSelector.tsx",
"diff": "-import _ from 'lodash'\n-import React from 'react'\n+import { sortBy } from 'lodash'\n+import React, { useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport i18n, { resources } from '../../i18n'\n-import SelectWithLabelFormGroup from './SelectWithLableFormGroup'\n+import SelectWithLabelFormGroup, { Option } from './SelectWithLableFormGroup'\nconst LanguageSelector = () => {\nconst { t } = useTranslation()\n+ const [selected, setSelected] = useState(i18n.language)\n- let languageOptions = Object.keys(resources).map((abbr) => ({\n+ let languageOptions: Option[] = Object.keys(resources).map((abbr) => ({\nlabel: resources[abbr].name,\nvalue: abbr,\n}))\n- languageOptions = _.sortBy(languageOptions, (o) => o.label)\n+ languageOptions = sortBy(languageOptions, (o) => o.label)\n- const onLanguageChange = (event: React.ChangeEvent<HTMLSelectElement>) => {\n- const selected = event.target.value\n- i18n.changeLanguage(selected)\n+ const onChange = (value: string) => {\n+ i18n.changeLanguage(value)\n+ setSelected(value)\n}\nreturn (\n<SelectWithLabelFormGroup\nname=\"language\"\n- value={i18n.language}\nlabel={t('settings.language.label')}\n- isEditable\noptions={languageOptions}\n- onChange={onLanguageChange}\n+ defaultSelected={languageOptions.filter(({ value }) => value === selected)}\n+ onChange={(values) => onChange(values[0])}\n+ isEditable\n/>\n)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/components/input/SelectWithLableFormGroup.tsx",
"new_path": "src/components/input/SelectWithLableFormGroup.tsx",
"diff": "@@ -6,28 +6,31 @@ interface Option {\nvalue: string\n}\n+// todo: add feedback in next round\ninterface Props {\n- value: string\n- label?: string\nname: string\n+ label?: string\nisRequired?: boolean\n- isEditable?: boolean\noptions: Option[]\n- onChange?: (event: React.ChangeEvent<HTMLSelectElement>) => void\n- feedback?: string\n+ defaultSelected?: Option[]\n+ onChange?: (values: string[]) => void\n+ placeholder: string\n+ multiple?: boolean\n+ isEditable?: boolean\nisInvalid?: boolean\n}\nconst SelectWithLabelFormGroup = (props: Props) => {\nconst {\n- value,\n- label,\nname,\n- isEditable,\n+ label,\n+ isRequired,\noptions,\n+ defaultSelected,\nonChange,\n- isRequired,\n- feedback,\n+ placeholder,\n+ multiple,\n+ isEditable,\nisInvalid,\n} = props\nconst id = `${name}Select`\n@@ -35,27 +38,22 @@ const SelectWithLabelFormGroup = (props: Props) => {\n<div className=\"form-group\">\n{label && <Label text={label} htmlFor={id} isRequired={isRequired} />}\n<Select\n- disabled={!isEditable}\n+ id={id}\n+ options={options}\n+ defaultSelected={defaultSelected}\nonChange={onChange}\n- value={value}\n- feedback={feedback}\n+ placeholder={placeholder}\n+ multiple={multiple}\n+ disabled={!isEditable}\nisInvalid={isInvalid}\n- >\n- <option disabled value=\"\">\n- -- Choose --\n- </option>\n- {options.map((option) => (\n- <option key={option.value} value={option.value}>\n- {option.label}\n- </option>\n- ))}\n- </Select>\n+ />\n</div>\n)\n}\nSelectWithLabelFormGroup.defaultProps = {\n- value: '',\n+ placeholder: '-- Choose --',\n}\nexport default SelectWithLabelFormGroup\n+export type { Option }\n"
},
{
"change_type": "MODIFY",
"old_path": "src/incidents/list/ViewIncidents.tsx",
"new_path": "src/incidents/list/ViewIncidents.tsx",
"diff": "@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next'\nimport { useDispatch, useSelector } from 'react-redux'\nimport { useHistory } from 'react-router-dom'\n-import SelectWithLabelFormGroup from '../../components/input/SelectWithLableFormGroup'\n+import SelectWithLabelFormGroup, { Option } from '../../components/input/SelectWithLableFormGroup'\nimport Incident from '../../model/Incident'\nimport { useButtonToolbarSetter } from '../../page-header/ButtonBarProvider'\nimport useTitle from '../../page-header/useTitle'\n@@ -48,11 +48,7 @@ const ViewIncidents = () => {\nhistory.push(`incidents/${incident.id}`)\n}\n- const onFilterChange = (event: React.ChangeEvent<HTMLSelectElement>) => {\n- setSearchFilter(event.target.value as IncidentFilter)\n- }\n-\n- const filterOptions = Object.values(IncidentFilter).map((filter) => ({\n+ const filterOptions: Option[] = Object.values(IncidentFilter).map((filter) => ({\nlabel: t(`incidents.status.${filter}`),\nvalue: `${filter}`,\n}))\n@@ -63,11 +59,11 @@ const ViewIncidents = () => {\n<div className=\"col-md-3 col-lg-2\">\n<SelectWithLabelFormGroup\nname=\"type\"\n- value={searchFilter}\nlabel={t('incidents.filterTitle')}\n- isEditable\noptions={filterOptions}\n- onChange={onFilterChange}\n+ defaultSelected={filterOptions.filter(({ value }) => value === searchFilter)}\n+ onChange={(values) => setSearchFilter(values[0] as IncidentFilter)}\n+ isEditable\n/>\n</div>\n</div>\n@@ -86,9 +82,15 @@ const ViewIncidents = () => {\n{incidents.map((incident: Incident) => (\n<tr onClick={() => onTableRowClick(incident)} key={incident.id}>\n<td>{incident.code}</td>\n- <td>{format(new Date(incident.date), 'yyyy-MM-dd hh:mm a')}</td>\n+ <td>\n+ {incident.date ? format(new Date(incident.date), 'yyyy-MM-dd hh:mm a') : ''}\n+ </td>\n<td>{incident.reportedBy}</td>\n- <td>{format(new Date(incident.reportedOn), 'yyyy-MM-dd hh:mm a')}</td>\n+ <td>\n+ {incident.reportedOn\n+ ? format(new Date(incident.reportedOn), 'yyyy-MM-dd hh:mm a')\n+ : ''}\n+ </td>\n<td>{incident.status}</td>\n</tr>\n))}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/labs/ViewLabs.tsx",
"new_path": "src/labs/ViewLabs.tsx",
"diff": "@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next'\nimport { useSelector, useDispatch } from 'react-redux'\nimport { useHistory } from 'react-router-dom'\n-import SelectWithLabelFormGroup from '../components/input/SelectWithLableFormGroup'\n+import SelectWithLabelFormGroup, { Option } from '../components/input/SelectWithLableFormGroup'\nimport TextInputWithLabelFormGroup from '../components/input/TextInputWithLabelFormGroup'\nimport useDebounce from '../hooks/debounce'\nimport Lab from '../model/Lab'\n@@ -15,7 +15,7 @@ import useTitle from '../page-header/useTitle'\nimport { RootState } from '../store'\nimport { searchLabs } from './labs-slice'\n-type filter = 'requested' | 'completed' | 'canceled' | 'all'\n+type LabFilter = 'requested' | 'completed' | 'canceled' | 'all'\nconst ViewLabs = () => {\nconst { t } = useTranslation()\n@@ -26,7 +26,7 @@ const ViewLabs = () => {\nconst { permissions } = useSelector((state: RootState) => state.user)\nconst dispatch = useDispatch()\nconst { labs, isLoading } = useSelector((state: RootState) => state.labs)\n- const [searchFilter, setSearchFilter] = useState<filter>('all')\n+ const [searchFilter, setSearchFilter] = useState<LabFilter>('all')\nconst [searchText, setSearchText] = useState<string>('')\nconst debouncedSearchText = useDebounce(searchText, 500)\n@@ -50,15 +50,6 @@ const ViewLabs = () => {\nreturn buttons\n}, [permissions, history, t])\n- const setFilter = (filter: string) =>\n- filter === 'requested'\n- ? 'requested'\n- : filter === 'completed'\n- ? 'completed'\n- : filter === 'canceled'\n- ? 'canceled'\n- : 'all'\n-\nuseEffect(() => {\ndispatch(searchLabs(debouncedSearchText, searchFilter))\n}, [dispatch, debouncedSearchText, searchFilter])\n@@ -76,21 +67,24 @@ const ViewLabs = () => {\nhistory.push(`/labs/${lab.id}`)\n}\n- const onSelectChange = (event: React.ChangeEvent<HTMLSelectElement>) => {\n- setSearchFilter(setFilter(event.target.value))\n- }\n-\nconst onSearchBoxChange = (event: React.ChangeEvent<HTMLInputElement>) => {\nsetSearchText(event.target.value)\n}\n+ const filterOptions: Option[] = [\n+ { label: t('labs.status.requested'), value: 'requested' },\n+ { label: t('labs.status.completed'), value: 'completed' },\n+ { label: t('labs.status.canceled'), value: 'canceled' },\n+ { label: t('labs.filter.all'), value: 'all' },\n+ ]\n+\nconst listBody = (\n<tbody>\n{labs.map((lab) => (\n<tr onClick={() => onTableRowClick(lab)} key={lab.id}>\n<td>{lab.code}</td>\n<td>{lab.type}</td>\n- <td>{format(new Date(lab.requestedOn), 'yyyy-MM-dd hh:mm a')}</td>\n+ <td>{lab.requestedOn ? format(new Date(lab.requestedOn), 'yyyy-MM-dd hh:mm a') : ''}</td>\n<td>{lab.status}</td>\n</tr>\n))}\n@@ -103,18 +97,11 @@ const ViewLabs = () => {\n<div className=\"col-md-3 col-lg-2\">\n<SelectWithLabelFormGroup\nname=\"type\"\n- value={searchFilter}\nlabel={t('labs.filterTitle')}\n+ options={filterOptions}\n+ defaultSelected={filterOptions.filter(({ value }) => value === searchFilter)}\n+ onChange={(values) => setSearchFilter(values[0] as LabFilter)}\nisEditable\n- options={[\n- { label: t('labs.status.requested'), value: 'requested' },\n- { label: t('labs.status.completed'), value: 'completed' },\n- { label: t('labs.status.canceled'), value: 'canceled' },\n- { label: t('labs.filter.all'), value: 'all' },\n- ]}\n- onChange={(event: React.ChangeEvent<HTMLSelectElement>) => {\n- onSelectChange(event)\n- }}\n/>\n</div>\n<div className=\"col\">\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/ContactInfo.tsx",
"new_path": "src/patients/ContactInfo.tsx",
"diff": "@@ -2,7 +2,7 @@ import { Spinner, Row, Column, Icon } from '@hospitalrun/components'\nimport React, { useEffect, ReactElement } from 'react'\nimport { useTranslation } from 'react-i18next'\n-import SelectWithLabelFormGroup from '../components/input/SelectWithLableFormGroup'\n+import SelectWithLabelFormGroup, { Option } from '../components/input/SelectWithLableFormGroup'\nimport TextFieldWithLabelFormGroup from '../components/input/TextFieldWithLabelFormGroup'\nimport TextInputWithLabelFormGroup from '../components/input/TextInputWithLabelFormGroup'\nimport { ContactInfoPiece } from '../model/ContactInformation'\n@@ -30,7 +30,7 @@ const ContactInfo = (props: Props): ReactElement => {\n}\n}, [data, onChange])\n- const typeOptions = Object.values(ContactInfoTypes).map((value) => ({\n+ const typeOptions: Option[] = Object.values(ContactInfoTypes).map((value) => ({\nlabel: t(`patient.contactInfoType.options.${value}`),\nvalue: `${value}`,\n}))\n@@ -53,9 +53,8 @@ const ContactInfo = (props: Props): ReactElement => {\n}\nconst Component = componentList[component]\n- const onTypeChange = (event: React.ChangeEvent<HTMLSelectElement>, index: number) => {\n+ const onTypeChange = (newType: string, index: number) => {\nif (onChange) {\n- const newType = event.currentTarget.value\nconst currentContact = { ...data[index], type: newType }\nconst newContacts = [...data]\nnewContacts.splice(index, 1, currentContact)\n@@ -83,10 +82,10 @@ const ContactInfo = (props: Props): ReactElement => {\n<Column sm={4}>\n<SelectWithLabelFormGroup\nname={`${name}Type${i}`}\n- value={entry.type}\n- isEditable={isEditable}\noptions={typeOptions}\n- onChange={(event) => onTypeChange(event, i)}\n+ defaultSelected={typeOptions.filter(({ value }) => value === entry.type)}\n+ onChange={(values) => onTypeChange(values[0], i)}\n+ isEditable={isEditable}\n/>\n</Column>\n<Column sm={8}>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/GeneralInformation.tsx",
"new_path": "src/patients/GeneralInformation.tsx",
"diff": "@@ -4,7 +4,7 @@ import React, { ReactElement } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport DatePickerWithLabelFormGroup from '../components/input/DatePickerWithLabelFormGroup'\n-import SelectWithLabelFormGroup from '../components/input/SelectWithLableFormGroup'\n+import SelectWithLabelFormGroup, { Option } from '../components/input/SelectWithLableFormGroup'\nimport TextInputWithLabelFormGroup from '../components/input/TextInputWithLabelFormGroup'\nimport { ContactInfoPiece } from '../model/ContactInformation'\nimport Patient from '../model/Patient'\n@@ -59,6 +59,18 @@ const GeneralInformation = (props: Props): ReactElement => {\nonFieldChange('isApproximateDateOfBirth', checked)\n}\n+ const sexOptions: Option[] = [\n+ { label: t('sex.male'), value: 'male' },\n+ { label: t('sex.female'), value: 'female' },\n+ { label: t('sex.other'), value: 'other' },\n+ { label: t('sex.unknown'), value: 'unknown' },\n+ ]\n+\n+ const typeOptions: Option[] = [\n+ { label: t('patient.types.charity'), value: 'charity' },\n+ { label: t('patient.types.private'), value: 'private' },\n+ ]\n+\nreturn (\n<div>\n<Panel title={t('patient.basicInformation')} color=\"primary\" collapsible>\n@@ -115,28 +127,20 @@ const GeneralInformation = (props: Props): ReactElement => {\n<SelectWithLabelFormGroup\nname=\"sex\"\nlabel={t('patient.sex')}\n- value={patient.sex}\n+ options={sexOptions}\n+ defaultSelected={sexOptions.filter(({ value }) => value === patient.sex)}\n+ onChange={(values) => onFieldChange('sex', values[0])}\nisEditable={isEditable}\n- options={[\n- { label: t('sex.male'), value: 'male' },\n- { label: t('sex.female'), value: 'female' },\n- { label: t('sex.other'), value: 'other' },\n- { label: t('sex.unknown'), value: 'unknown' },\n- ]}\n- onChange={(event) => onFieldChange('sex', event.currentTarget.value)}\n/>\n</div>\n<div className=\"col\">\n<SelectWithLabelFormGroup\nname=\"type\"\nlabel={t('patient.type')}\n- value={patient.type}\n+ options={typeOptions}\n+ defaultSelected={typeOptions.filter(({ value }) => value === patient.type)}\n+ onChange={(values) => onFieldChange('type', values[0])}\nisEditable={isEditable}\n- options={[\n- { label: t('patient.types.charity'), value: 'charity' },\n- { label: t('patient.types.private'), value: 'private' },\n- ]}\n- onChange={(event) => onFieldChange('type', event.currentTarget.value)}\n/>\n</div>\n</div>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/care-plans/CarePlanForm.tsx",
"new_path": "src/patients/care-plans/CarePlanForm.tsx",
"diff": "import { Alert, Column, Row } from '@hospitalrun/components'\n-import React from 'react'\n+import React, { useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport DatePickerWithLabelFormGroup from '../../components/input/DatePickerWithLabelFormGroup'\n-import SelectWithLabelFormGroup from '../../components/input/SelectWithLableFormGroup'\n+import SelectWithLabelFormGroup, { Option } from '../../components/input/SelectWithLableFormGroup'\nimport TextFieldWithLabelFormGroup from '../../components/input/TextFieldWithLabelFormGroup'\nimport TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup'\nimport CarePlan, { CarePlanIntent, CarePlanStatus } from '../../model/CarePlan'\n@@ -32,6 +32,10 @@ const CarePlanForm = (props: Props) => {\nconst { t } = useTranslation()\nconst { patient, carePlan, carePlanError, disabled, onChange } = props\n+ const [condition, setCondition] = useState(carePlan.diagnosisId)\n+ const [status, setStatus] = useState(carePlan.status)\n+ const [intent, setIntent] = useState(carePlan.intent)\n+\nconst onFieldChange = (name: string, value: string | CarePlanStatus | CarePlanIntent) => {\nif (onChange) {\nconst newCarePlan = {\n@@ -42,6 +46,13 @@ const CarePlanForm = (props: Props) => {\n}\n}\n+ const conditionOptions: Option[] =\n+ patient.diagnoses?.map((d) => ({ label: d.name, value: d.id })) || []\n+\n+ const statusOptions: Option[] = Object.values(CarePlanStatus).map((v) => ({ label: v, value: v }))\n+\n+ const intentOptions: Option[] = Object.values(CarePlanIntent).map((v) => ({ label: v, value: v }))\n+\nreturn (\n<form>\n{carePlanError?.message && <Alert color=\"danger\" message={t(carePlanError.message)} />}\n@@ -75,44 +86,51 @@ const CarePlanForm = (props: Props) => {\n</Row>\n<Row>\n<Column sm={12}>\n+ {/* add feedback in next round */}\n<SelectWithLabelFormGroup\n- isRequired\n- value={carePlan.diagnosisId}\n- label={t('patient.carePlan.condition')}\nname=\"condition\"\n- feedback={t(carePlanError?.condition || '')}\n- isInvalid={!!carePlanError?.condition}\n+ label={t('patient.carePlan.condition')}\n+ isRequired\n+ options={conditionOptions}\n+ defaultSelected={conditionOptions.filter(({ value }) => value === condition)}\n+ onChange={(values) => {\n+ onFieldChange('diagnosisId', values[0])\n+ setCondition(values[0])\n+ }}\nisEditable={!disabled}\n- onChange={(event) => onFieldChange('diagnosisId', event.currentTarget.value)}\n- options={patient.diagnoses?.map((d) => ({ label: d.name, value: d.id })) || []}\n+ isInvalid={!!carePlanError?.condition}\n/>\n</Column>\n</Row>\n<Row>\n<Column sm={6}>\n<SelectWithLabelFormGroup\n- isRequired\n- value={carePlan.status}\n- label={t('patient.carePlan.status')}\nname=\"status\"\n- feedback={t(carePlanError?.status || '')}\n- isInvalid={!!carePlanError?.status}\n+ label={t('patient.carePlan.status')}\n+ isRequired\n+ options={statusOptions}\n+ defaultSelected={statusOptions.filter(({ value }) => value === status)}\n+ onChange={(values) => {\n+ onFieldChange('status', values[0])\n+ setStatus(values[0] as CarePlanStatus)\n+ }}\nisEditable={!disabled}\n- options={Object.values(CarePlanStatus).map((v) => ({ label: v, value: v }))}\n- onChange={(event) => onFieldChange('status', event.currentTarget.value)}\n+ isInvalid={!!carePlanError?.status}\n/>\n</Column>\n<Column sm={6}>\n<SelectWithLabelFormGroup\n- isRequired\n- value={carePlan.intent}\n- label={t('patient.carePlan.intent')}\nname=\"intent\"\n- feedback={t(carePlanError?.intent || '')}\n- isInvalid={!!carePlanError?.intent}\n+ label={t('patient.carePlan.intent')}\n+ isRequired\n+ options={intentOptions}\n+ defaultSelected={intentOptions.filter(({ value }) => value === intent)}\n+ onChange={(values) => {\n+ onFieldChange('intent', values[0])\n+ setIntent(values[0] as CarePlanIntent)\n+ }}\nisEditable={!disabled}\n- options={Object.values(CarePlanIntent).map((v) => ({ label: v, value: v }))}\n- onChange={(event) => onFieldChange('intent', event.currentTarget.value)}\n+ isInvalid={!!carePlanError?.intent}\n/>\n</Column>\n</Row>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/scheduling/appointments/AppointmentDetailForm.tsx",
"new_path": "src/scheduling/appointments/AppointmentDetailForm.tsx",
"diff": "@@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next'\nimport PatientRepository from '../../clients/db/PatientRepository'\nimport DateTimePickerWithLabelFormGroup from '../../components/input/DateTimePickerWithLabelFormGroup'\n-import SelectWithLabelFormGroup from '../../components/input/SelectWithLableFormGroup'\n+import SelectWithLabelFormGroup, { Option } from '../../components/input/SelectWithLableFormGroup'\nimport TextFieldWithLabelFormGroup from '../../components/input/TextFieldWithLabelFormGroup'\nimport TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup'\nimport Appointment from '../../model/Appointment'\n@@ -22,15 +22,20 @@ const AppointmentDetailForm = (props: Props) => {\nconst { onFieldChange, appointment, patient, isEditable, error } = props\nconst { t } = useTranslation()\n- const onSelectChange = (event: React.ChangeEvent<HTMLSelectElement>, fieldName: string) =>\n- onFieldChange && onFieldChange(fieldName, event.target.value)\n-\nconst onDateChange = (date: Date, fieldName: string) =>\nonFieldChange && onFieldChange(fieldName, date.toISOString())\nconst onInputElementChange = (event: React.ChangeEvent<HTMLInputElement>, fieldName: string) =>\nonFieldChange && onFieldChange(fieldName, event.target.value)\n+ const typeOptions: Option[] = [\n+ { label: t('scheduling.appointment.types.checkup'), value: 'checkup' },\n+ { label: t('scheduling.appointment.types.emergency'), value: 'emergency' },\n+ { label: t('scheduling.appointment.types.followUp'), value: 'follow up' },\n+ { label: t('scheduling.appointment.types.routine'), value: 'routine' },\n+ { label: t('scheduling.appointment.types.walkIn'), value: 'walk in' },\n+ ]\n+\nreturn (\n<>\n{error?.message && <Alert className=\"alert\" color=\"danger\" message={t(error?.message)} />}\n@@ -112,18 +117,10 @@ const AppointmentDetailForm = (props: Props) => {\n<SelectWithLabelFormGroup\nname=\"type\"\nlabel={t('scheduling.appointment.type')}\n- value={appointment.type}\n+ options={typeOptions}\n+ defaultSelected={typeOptions.filter(({ value }) => value === appointment.type)}\n+ onChange={(values) => onFieldChange && onFieldChange('type', values[0])}\nisEditable={isEditable}\n- options={[\n- { label: t('scheduling.appointment.types.checkup'), value: 'checkup' },\n- { label: t('scheduling.appointment.types.emergency'), value: 'emergency' },\n- { label: t('scheduling.appointment.types.followUp'), value: 'follow up' },\n- { label: t('scheduling.appointment.types.routine'), value: 'routine' },\n- { label: t('scheduling.appointment.types.walkIn'), value: 'walk in' },\n- ]}\n- onChange={(event: React.ChangeEvent<HTMLSelectElement>) => {\n- onSelectChange(event, 'type')\n- }}\n/>\n</div>\n</div>\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat: apply select component changes |
288,249 | 23.06.2020 18:43:51 | 25,200 | b3f024180bfa8398381c0b08bef5f218f8a89016 | test: update tests for select after components update | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/components/Navbar.test.tsx",
"new_path": "src/__tests__/components/Navbar.test.tsx",
"diff": "@@ -61,9 +61,9 @@ describe('Navbar', () => {\nconst hamberger = hospitalRunNavbar.find('.nav-hamberger')\nconst { children } = hamberger.first().props() as any\n- expect(children[0].props.children).toEqual('dashboard.label')\n- expect(children[1].props.children).toEqual('patients.newPatient')\n- expect(children[children.length - 1].props.children).toEqual('settings.label')\n+ expect(children[0].props.children).toEqual([undefined, 'dashboard.label'])\n+ expect(children[1].props.children).toEqual([undefined, 'patients.newPatient'])\n+ expect(children[children.length - 1].props.children).toEqual([undefined, 'settings.label'])\n})\nit('should not show an item if user does not have a permission', () => {\n@@ -144,7 +144,7 @@ describe('Navbar', () => {\nconst addNew = hospitalRunNavbar.find('.nav-add-new')\nconst { children } = addNew.first().props() as any\n- expect(children[0].props.children).toEqual('patients.newPatient')\n+ expect(children[0].props.children).toEqual([undefined, 'patients.newPatient'])\n})\nit('should not show a shortcut if user does not have a permission', () => {\n@@ -168,7 +168,7 @@ describe('Navbar', () => {\nconst accountLinkList = hospitalRunNavbar.find('.nav-account')\nconst { children } = accountLinkList.first().props() as any\n- expect(children[0].props.children).toEqual('settings.label')\n+ expect(children[0].props.children).toEqual([undefined, 'settings.label'])\n})\nit('should navigate to /settings when the list option is selected', () => {\n"
},
{
"change_type": "DELETE",
"old_path": "src/__tests__/components/PageComponent.test.tsx",
"new_path": null,
"diff": "-import '../../__mocks__/matchMediaMock'\n-import { Button, Select } from '@hospitalrun/components'\n-import { mount } from 'enzyme'\n-import React from 'react'\n-\n-import PageComponent, { defaultPageSize } from '../../components/PageComponent'\n-\n-describe('PageComponenet test', () => {\n- it('should render PageComponent Component', () => {\n- const wrapper = mount(\n- <PageComponent\n- hasNext={false}\n- hasPrevious={false}\n- pageNumber={1}\n- setPreviousPageRequest={jest.fn()}\n- setNextPageRequest={jest.fn()}\n- onPageSizeChange={jest.fn()}\n- />,\n- )\n- const buttons = wrapper.find(Button)\n- expect(buttons).toHaveLength(2)\n- expect(buttons.at(0).prop('disabled')).toBeTruthy()\n- expect(buttons.at(1).prop('disabled')).toBeTruthy()\n-\n- const select = wrapper.find(Select)\n- expect(select.prop('defaultValue')).toEqual(defaultPageSize.value?.toString())\n-\n- const options = select.find('option')\n- expect(options).toHaveLength(5)\n- })\n-})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/components/input/SelectWithLabelFormGroup.test.tsx",
"new_path": "src/__tests__/components/input/SelectWithLabelFormGroup.test.tsx",
"diff": "@@ -15,7 +15,6 @@ describe('select with label form group', () => {\noptions={[{ value: 'value1', label: 'label1' }]}\nname={expectedName}\nlabel=\"test\"\n- value=\"\"\nisEditable\nonChange={jest.fn()}\n/>,\n@@ -27,30 +26,6 @@ describe('select with label form group', () => {\nexpect(label.prop('text')).toEqual(expectedName)\n})\n- it('should render a select with the proper options', () => {\n- const expectedName = 'test'\n- const wrapper = shallow(\n- <SelectWithLabelFormGroup\n- options={[{ value: 'value1', label: 'label1' }]}\n- name={expectedName}\n- label=\"test\"\n- value=\"\"\n- isEditable\n- onChange={jest.fn()}\n- />,\n- )\n-\n- const select = wrapper.find(Select)\n- expect(select).toHaveLength(1)\n-\n- const options = select.find('option')\n- expect(options).toHaveLength(2)\n- expect(options.at(0).prop('value')).toEqual('')\n- expect(options.at(0).text()).toEqual('-- Choose --')\n- expect(options.at(1).prop('value')).toEqual('value1')\n- expect(options.at(1).text()).toEqual('label1')\n- })\n-\nit('should render disabled is isDisable disabled is true', () => {\nconst expectedName = 'test'\nconst wrapper = shallow(\n@@ -58,7 +33,6 @@ describe('select with label form group', () => {\noptions={[{ value: 'value1', label: 'label1' }]}\nname={expectedName}\nlabel=\"test\"\n- value=\"\"\nisEditable={false}\nonChange={jest.fn()}\n/>,\n@@ -71,13 +45,13 @@ describe('select with label form group', () => {\nit('should render the proper value', () => {\nconst expectedName = 'test'\n- const expectedValue = 'expected value'\n+ const expectedDefaultSelected = [{ value: 'value', label: 'label' }]\nconst wrapper = shallow(\n<SelectWithLabelFormGroup\n- options={[{ value: 'value1', label: 'label1' }]}\n+ options={[{ value: 'value', label: 'label' }]}\nname={expectedName}\nlabel=\"test\"\n- value={expectedValue}\n+ defaultSelected={expectedDefaultSelected}\nisEditable={false}\nonChange={jest.fn()}\n/>,\n@@ -85,21 +59,18 @@ describe('select with label form group', () => {\nconst select = wrapper.find(Select)\nexpect(select).toHaveLength(1)\n- expect(select.prop('value')).toEqual(expectedValue)\n+ expect(select.prop('defaultSelected')).toEqual(expectedDefaultSelected)\n})\n})\ndescribe('change handler', () => {\nit('should call the change handler on change', () => {\n- const expectedName = 'test'\n- const expectedValue = 'expected value'\nconst handler = jest.fn()\nconst wrapper = shallow(\n<SelectWithLabelFormGroup\noptions={[{ value: 'value1', label: 'label1' }]}\n- name={expectedName}\n+ name=\"name\"\nlabel=\"test\"\n- value={expectedValue}\nisEditable={false}\nonChange={handler}\n/>,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/incidents/list/ViewIncidents.test.tsx",
"new_path": "src/__tests__/incidents/list/ViewIncidents.test.tsx",
"diff": "@@ -75,26 +75,12 @@ describe('View Incidents', () => {\nreturn wrapper\n}\nit('should filter incidents by status=reported on first load ', async () => {\n- const wrapper = await setup([Permissions.ViewIncidents])\n- const filterSelect = wrapper.find('select')\n- expect(filterSelect.props().value).toBe(IncidentFilter.reported)\n+ await setup([Permissions.ViewIncidents])\nexpect(IncidentRepository.search).toHaveBeenCalled()\nexpect(IncidentRepository.search).toHaveBeenCalledWith({ status: IncidentFilter.reported })\n})\n- it('should call IncidentRepository after changing filter', async () => {\n- const wrapper = await setup([Permissions.ViewIncidents])\n- const filterSelect = wrapper.find('select')\n- expect(IncidentRepository.findAll).not.toHaveBeenCalled()\n-\n- filterSelect.simulate('change', { target: { value: IncidentFilter.all } })\n- expect(IncidentRepository.findAll).toHaveBeenCalled()\n- filterSelect.simulate('change', { target: { value: IncidentFilter.reported } })\n-\n- expect(IncidentRepository.search).toHaveBeenCalledTimes(2)\n- expect(IncidentRepository.search).toHaveBeenLastCalledWith({ status: IncidentFilter.reported })\n- })\ndescribe('layout', () => {\nit('should set the title', async () => {\nawait setup([Permissions.ViewIncidents])\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/ContactInfo.test.tsx",
"new_path": "src/__tests__/patients/ContactInfo.test.tsx",
"diff": "@@ -86,14 +86,11 @@ describe('Contact Info in its Editable mode', () => {\nconst wrapper = setup(data, errors)\nconst feedbackWrappers = wrapper.find('.invalid-feedback')\n- expect(feedbackWrappers).toHaveLength(errors.length * 2)\n+ expect(feedbackWrappers).toHaveLength(errors.length)\n- for (let i = 0; i < feedbackWrappers.length; i += 1) {\n- if (i % 2 === 1) {\n- const j = (i - 1) / 2\n- expect(feedbackWrappers.at(i).text()).toEqual(errors[j])\n- }\n- }\n+ feedbackWrappers.forEach((_, i) => {\n+ expect(feedbackWrappers.at(i).text()).toEqual(errors[i])\n+ })\n})\nit('should display the add button', () => {\n@@ -103,20 +100,6 @@ describe('Contact Info in its Editable mode', () => {\nexpect(buttonWrapper.text().trim()).toEqual('actions.add')\n})\n- it('should call the onChange callback if select is changed', () => {\n- const wrapper = setup(data)\n- const select = wrapper.findWhere((w: any) => w.prop('name') === `${name}Type0`).find('select')\n- select.getDOMNode<HTMLSelectElement>().value = 'mobile'\n- select.simulate('change')\n-\n- const expectedNewData = [\n- { id: '123', value: '123456', type: 'mobile' },\n- { id: '456', value: '789012', type: undefined },\n- ]\n- expect(onChange).toHaveBeenCalledTimes(1)\n- expect(onChange).toHaveBeenCalledWith(expectedNewData)\n- })\n-\nit('should call the onChange callback if input is changed', () => {\nconst wrapper = setup(data)\nconst input = wrapper.findWhere((w: any) => w.prop('name') === `${name}0`).find('input')\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/GeneralInformation.test.tsx",
"new_path": "src/__tests__/patients/GeneralInformation.test.tsx",
"diff": "@@ -129,7 +129,7 @@ describe('General Information, without isEditable', () => {\nit('should render the sex select', () => {\nconst sexSelect = wrapper.findWhere((w: any) => w.prop('name') === 'sex')\n- expect(sexSelect.prop('value')).toEqual(patient.sex)\n+ expect(sexSelect.prop('defaultSelected')[0].value).toEqual(patient.sex)\nexpect(sexSelect.prop('label')).toEqual('patient.sex')\nexpect(sexSelect.prop('isEditable')).toBeFalsy()\nexpect(sexSelect.prop('options')).toHaveLength(4)\n@@ -145,7 +145,7 @@ describe('General Information, without isEditable', () => {\nit('should render the patient type select', () => {\nconst typeSelect = wrapper.findWhere((w: any) => w.prop('name') === 'type')\n- expect(typeSelect.prop('value')).toEqual(patient.type)\n+ expect(typeSelect.prop('defaultSelected')[0].value).toEqual(patient.type)\nexpect(typeSelect.prop('label')).toEqual('patient.type')\nexpect(typeSelect.prop('isEditable')).toBeFalsy()\nexpect(typeSelect.prop('options')).toHaveLength(2)\n@@ -268,8 +268,6 @@ describe('General Information, isEditable', () => {\nconst expectedGivenName = 'expectedGivenName'\nconst expectedFamilyName = 'expectedFamilyName'\nconst expectedSuffix = 'expectedSuffix'\n- const expectedSex = 'unknown'\n- const expectedType = 'private'\nconst expectedDateOfBirth = '1937-06-14T05:00:00.000Z'\nconst expectedOccupation = 'expectedOccupation'\nconst expectedPreferredLanguage = 'expectedPreferredLanguage'\n@@ -349,7 +347,7 @@ describe('General Information, isEditable', () => {\nit('should render the sex select', () => {\nconst sexSelect = wrapper.findWhere((w: any) => w.prop('name') === 'sex')\n- expect(sexSelect.prop('value')).toEqual(patient.sex)\n+ expect(sexSelect.prop('defaultSelected')[0].value).toEqual(patient.sex)\nexpect(sexSelect.prop('label')).toEqual('patient.sex')\nexpect(sexSelect.prop('isEditable')).toBeTruthy()\nexpect(sexSelect.prop('options')).toHaveLength(4)\n@@ -362,19 +360,12 @@ describe('General Information, isEditable', () => {\nexpect(sexSelect.prop('options')[2].value).toEqual('other')\nexpect(sexSelect.prop('options')[3].label).toEqual('sex.unknown')\nexpect(sexSelect.prop('options')[3].value).toEqual('unknown')\n-\n- const select = sexSelect.find('select')\n- select.getDOMNode<HTMLSelectElement>().value = expectedSex\n- select.simulate('change')\n-\n- expect(onFieldChange).toHaveBeenCalledTimes(1)\n- expect(onFieldChange).toHaveBeenCalledWith({ ...patient, sex: expectedSex })\n})\nit('should render the patient type select', () => {\nconst typeSelect = wrapper.findWhere((w: any) => w.prop('name') === 'type')\n- expect(typeSelect.prop('value')).toEqual(patient.type)\n+ expect(typeSelect.prop('defaultSelected')[0].value).toEqual(patient.type)\nexpect(typeSelect.prop('label')).toEqual('patient.type')\nexpect(typeSelect.prop('isEditable')).toBeTruthy()\n@@ -383,13 +374,6 @@ describe('General Information, isEditable', () => {\nexpect(typeSelect.prop('options')[0].value).toEqual('charity')\nexpect(typeSelect.prop('options')[1].label).toEqual('patient.types.private')\nexpect(typeSelect.prop('options')[1].value).toEqual('private')\n-\n- const select = typeSelect.find('select')\n- select.getDOMNode<HTMLSelectElement>().value = expectedType\n- select.simulate('change')\n-\n- expect(onFieldChange).toHaveBeenCalledTimes(1)\n- expect(onFieldChange).toHaveBeenCalledWith({ ...patient, type: expectedType })\n})\nit('should render the date of the birth of the patient', () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/care-plans/CarePlanForm.test.tsx",
"new_path": "src/__tests__/patients/care-plans/CarePlanForm.test.tsx",
"diff": "@@ -98,7 +98,7 @@ describe('Care Plan Form', () => {\nexpect(conditionSelector).toHaveLength(1)\nexpect(conditionSelector.prop('patient.carePlan.condition'))\nexpect(conditionSelector.prop('isRequired')).toBeTruthy()\n- expect(conditionSelector.prop('value')).toEqual(carePlan.diagnosisId)\n+ expect(conditionSelector.prop('defaultSelected')[0].value).toEqual(carePlan.diagnosisId)\nexpect(conditionSelector.prop('options')).toEqual([\n{ value: diagnosis.id, label: diagnosis.name },\n])\n@@ -110,7 +110,7 @@ describe('Care Plan Form', () => {\nact(() => {\nconst conditionSelector = wrapper.findWhere((w) => w.prop('name') === 'condition')\nconst onChange = conditionSelector.prop('onChange') as any\n- onChange({ currentTarget: { value: expectedNewCondition } })\n+ onChange([expectedNewCondition])\n})\nexpect(onCarePlanChangeSpy).toHaveBeenCalledWith({ diagnosisId: expectedNewCondition })\n@@ -124,7 +124,7 @@ describe('Care Plan Form', () => {\nexpect(statusSelector).toHaveLength(1)\nexpect(statusSelector.prop('patient.carePlan.status'))\nexpect(statusSelector.prop('isRequired')).toBeTruthy()\n- expect(statusSelector.prop('value')).toEqual(carePlan.status)\n+ expect(statusSelector.prop('defaultSelected')[0].value).toEqual(carePlan.status)\nexpect(statusSelector.prop('options')).toEqual(\nObject.values(CarePlanStatus).map((v) => ({ label: v, value: v })),\n)\n@@ -136,7 +136,7 @@ describe('Care Plan Form', () => {\nact(() => {\nconst statusSelector = wrapper.findWhere((w) => w.prop('name') === 'status')\nconst onChange = statusSelector.prop('onChange') as any\n- onChange({ currentTarget: { value: expectedNewStatus } })\n+ onChange([expectedNewStatus])\n})\nexpect(onCarePlanChangeSpy).toHaveBeenCalledWith({ status: expectedNewStatus })\n@@ -150,7 +150,7 @@ describe('Care Plan Form', () => {\nexpect(intentSelector).toHaveLength(1)\nexpect(intentSelector.prop('patient.carePlan.intent'))\nexpect(intentSelector.prop('isRequired')).toBeTruthy()\n- expect(intentSelector.prop('value')).toEqual(carePlan.intent)\n+ expect(intentSelector.prop('defaultSelected')[0].value).toEqual(carePlan.intent)\nexpect(intentSelector.prop('options')).toEqual(\nObject.values(CarePlanIntent).map((v) => ({ label: v, value: v })),\n)\n@@ -162,7 +162,7 @@ describe('Care Plan Form', () => {\nact(() => {\nconst intentSelector = wrapper.findWhere((w) => w.prop('name') === 'intent')\nconst onChange = intentSelector.prop('onChange') as any\n- onChange({ currentTarget: { value: newIntent } })\n+ onChange([newIntent])\n})\nexpect(onCarePlanChangeSpy).toHaveBeenCalledWith({ intent: newIntent })\n@@ -298,13 +298,13 @@ describe('Care Plan Form', () => {\nexpect(descriptionInput.prop('feedback')).toEqual(expectedError.description)\nexpect(conditionSelector.prop('isInvalid')).toBeTruthy()\n- expect(conditionSelector.prop('feedback')).toEqual(expectedError.condition)\n+ // expect(conditionSelector.prop('feedback')).toEqual(expectedError.condition)\nexpect(statusSelector.prop('isInvalid')).toBeTruthy()\n- expect(statusSelector.prop('feedback')).toEqual(expectedError.status)\n+ // expect(statusSelector.prop('feedback')).toEqual(expectedError.status)\nexpect(intentSelector.prop('isInvalid')).toBeTruthy()\n- expect(intentSelector.prop('feedback')).toEqual(expectedError.intent)\n+ // expect(intentSelector.prop('feedback')).toEqual(expectedError.intent)\nexpect(startDatePicker.prop('isInvalid')).toBeTruthy()\nexpect(startDatePicker.prop('feedback')).toEqual(expectedError.startDate)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/scheduling/appointments/AppointmentDetailForm.test.tsx",
"new_path": "src/__tests__/scheduling/appointments/AppointmentDetailForm.test.tsx",
"diff": "@@ -112,7 +112,7 @@ describe('AppointmentDetailForm', () => {\nexpect(typeSelect.prop('options')[3].value).toEqual('routine')\nexpect(typeSelect.prop('options')[4].label).toEqual('scheduling.appointment.types.walkIn')\nexpect(typeSelect.prop('options')[4].value).toEqual('walk in')\n- expect(typeSelect.prop('value')).toEqual(expectedAppointment.type)\n+ expect(typeSelect.prop('defaultSelected')[0].value).toEqual(expectedAppointment.type)\n})\nit('should render a reason text field input', () => {\n@@ -263,18 +263,6 @@ describe('AppointmentDetailForm', () => {\nexpect(onFieldChange).toHaveBeenLastCalledWith('location', expectedLocation)\n})\n- it('should call onFieldChange when type changes', () => {\n- const expectedType = 'follow up'\n-\n- act(() => {\n- const typeSelect = wrapper.findWhere((w) => w.prop('name') === 'type')\n- typeSelect.prop('onChange')({ target: { value: expectedType } })\n- })\n- wrapper.update()\n-\n- expect(onFieldChange).toHaveBeenLastCalledWith('type', expectedType)\n- })\n-\nit('should call onFieldChange when reason changes', () => {\nconst expectedReason = 'reason'\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | test: update tests for select after components update |
288,249 | 23.06.2020 19:10:14 | 25,200 | 1cf657516e1249373c3e44247700d435473c7d59 | feat(navbar): add hamberger icon for mobile, and dividers | [
{
"change_type": "MODIFY",
"old_path": "src/components/Navbar.tsx",
"new_path": "src/components/Navbar.tsx",
"diff": "@@ -18,6 +18,14 @@ const Navbar = () => {\nhistory.push(location)\n}\n+ const dividerAboveLabels = [\n+ 'patients.newPatient',\n+ 'scheduling.appointments.new',\n+ 'labs.requests.new',\n+ 'incidents.reports.new',\n+ 'settings.label',\n+ ]\n+\nfunction getDropdownListOfPages(pages: Page[]) {\nreturn pages\n.filter((page) => !page.permission || permissions.includes(page.permission))\n@@ -27,6 +35,7 @@ const Navbar = () => {\nonClick: () => {\nnavigateTo(page.path)\n},\n+ dividerAbove: dividerAboveLabels.indexOf(page.label) > -1,\n}))\n}\n@@ -42,9 +51,11 @@ const Navbar = () => {\nvariant=\"dark\"\nnavItems={[\n{\n+ name: 'menu',\n+ size: 'lg',\n+ type: 'link-list-icon',\nchildren: getDropdownListOfPages(hambergerPages),\nlabel: '',\n- type: 'link-list',\nclassName: 'nav-hamberger pr-4 d-md-none',\n},\n{\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(navbar): add hamberger icon for mobile, and dividers |
288,323 | 24.06.2020 21:59:05 | 18,000 | e618dcdcffd3ac660791ebe262f046191bdeb10c | chore(lint): turn off | [
{
"change_type": "MODIFY",
"old_path": ".eslintrc.js",
"new_path": ".eslintrc.js",
"diff": "@@ -43,6 +43,7 @@ module.exports = {\n'prettier/prettier': 'error',\n'@typescript-eslint/member-delimiter-style': 'off',\n'@typescript-eslint/explicit-function-return-type': 'off',\n+ \"@typescript-eslint/explicit-module-boundary-types\": 'off',\n'@typescript-eslint/no-explicit-any': 'off',\n'@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }],\n'@typescript-eslint/unified-signatures': 'error',\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | chore(lint): turn off @typescript-eslint/explicit-module-boundary-types |
288,249 | 26.06.2020 18:06:21 | 25,200 | 3890912114923b0b256a4337a35710836fd379e3 | docs(readme): reorg readme and contrirubint | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "-# HospitalRun Frontend\n+[Visit this page for general information on the HospitalRun application](https://github.com/HospitalRun/hospitalrun/blob/master/README.md) including:\n-<div align=\"center\">\n-\n- [](https://github.com/HospitalRun/hospitalrun-frontend/releases) [](https://github.com/HospitalRun/hospitalrun-frontend/releases)\n-[](https://github.com/HospitalRun/frontend/actions) [](https://coveralls.io/github/HospitalRun/hospitalrun-frontend?branch=master) [](https://lgtm.com/projects/g/HospitalRun/hospitalrun-frontend/context:javascript) [](https://hospitalrun-frontend.readthedocs.io)\n-[](https://app.fossa.io/projects/git%2Bgithub.com%2FHospitalRun%2Fhospitalrun-frontend?ref=badge_large) [](http://commitizen.github.io/cz-cli/)\n- [](https://hospitalrun-slack.herokuapp.com) [](https://repl.it/github/HospitalRun/hospitalrun-frontend)\n-[](https://gitpod.io/#https://github.com/HospitalRun/hospitalrun-frontend)\n+How can I deploy 1.0.0-beta? | Where do I report a bug or request a feature? | How can I contribute? (There are several other ways besides coding) | What is the project structure? | What is the application infrastructure? | Who is behind HospitalRun? etc.\n-</div>\n+# How to Contribute to the Frontend Repository\n-React frontend for [HospitalRun](http://hospitalrun.io/): free software for developing world hospitals.\n+[Get started by checking out the Frontend Contributing Guide](https://github.com/HospitalRun/hospitalrun-frontend/blob/master/.github/CONTRIBUTING.md) for:\n+- What's the tech stack?\n+- Where can I become familiar with the technologies?\n+- Where do I browse issues?\n+- How do I set up my local environment?\n+- How do I run tests locally?\n+- How do I submit my changes?\n+- etc.\n---\n-**Version 1.0.0-beta is no longer supported. Version 2 is currently under development.**\n-\n-- To contribute, follow the guidelines in the readme or alternatively ask for details on Slack channel [#contributors](https://hospitalrun-slack.herokuapp.com).\n-- To use version 1.0.0-beta (not production ready) in a hospital facility, ask for support on Slack channel [#troubleshooting](https://hospitalrun-slack.herokuapp.com).\n-\n<div align=\"center\">\n-[](https://hospitalrun-slack.herokuapp.com)\n+ [](https://github.com/HospitalRun/hospitalrun-frontend/releases) [](https://github.com/HospitalRun/hospitalrun-frontend/releases)\n+[](https://github.com/HospitalRun/frontend/actions) [](https://coveralls.io/github/HospitalRun/hospitalrun-frontend?branch=master) [](https://lgtm.com/projects/g/HospitalRun/hospitalrun-frontend/context:javascript) [](https://hospitalrun-frontend.readthedocs.io)\n+[](https://app.fossa.io/projects/git%2Bgithub.com%2FHospitalRun%2Fhospitalrun-frontend?ref=badge_large) [](http://commitizen.github.io/cz-cli/)\n+ [](https://hospitalrun-slack.herokuapp.com) [](https://repl.it/github/HospitalRun/hospitalrun-frontend)\n+[](https://gitpod.io/#https://github.com/HospitalRun/hospitalrun-frontend)\n</div>\n-# Contributing\n-\n-Contributions are always welcome. Before contributing please read our [contributor guide](https://github.com/HospitalRun/hospitalrun-frontend/blob/master/.github/CONTRIBUTING.md).\n-\n-## Translation\n-\n-Use the standards in [this readme](https://github.com/HospitalRun/hospitalrun-frontend/tree/master/src/locales/README.md).\n-\n-## Online one-click setup for contributing\n-\n-Contribute to HospitalRun using a fully featured online development environment that will automatically: clone the repo, install the dependencies and start the webserver.\n-\n-[](https://gitpod.io/#https://github.com/HospitalRun/hospitalrun-frontend)\n-\n-## Running Tests and Linter\n-\n-`npm run test:ci` will run the entire test suite\n-\n-`npm run test` will run the test suite in watch mode\n-\n-`npm run lint` will run the linter\n-\n-`npm run lint:fix` will run the linter and fix fixable errors\n-\n-## Useful Developer Tools\n-\n-- [VSCode](https://code.visualstudio.com/)\n-- [VSCode React Extension Pack](https://marketplace.visualstudio.com/items?itemName=jawandarajbir.react-vscode-extension-pack)\n-- [React Developer Tools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en)\n-- [Redux Developer Tools](https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd?hl=en)\n-\n-## Working on an Issue\n-\n-In order to optimize the workflow and to prevent multiple contributors working on the same issue without interactions, a contributor must ask to be assigned to an issue by one of the core team members: it's enough to ask it inside the specific issue.\n-\n-## How to commit\n-\n-This repo uses Conventional Commits. Commitizen is mandatory for making proper commits. Once you have staged your changes, can run `npm run commit` from the root directory in order to commit following our standards.\n-\n-<hr />\n-\n-# Behind HospitalRun\n-\n-## Hosted by\n-\n-[<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)\n-\n-## Sponsors\n-\n-[](https://opencollective.com/hospitalrun/contribute/sponsors-336/checkout)\n-\n-### Big Thanks\n-\n-Cross-browser Testing Platform and Open Source <3 Provided by [Sauce Labs][homepage]\n-\n-[homepage]: https://saucelabs.com\n-\n-## Backers\n-\n-[](https://opencollective.com/hospitalrun/contribute/backers-335/checkout)\n-\n-## Lead Maintainer\n-\n-[<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 />\n-\n-## [Core Maintainers](https://github.com/orgs/HospitalRun/teams/core-maintainers)\n-\n-<!-- prettier-ignore -->\n-| [<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) |\n-|---|---|\n-\n-## [Core Contributors](https://github.com/orgs/HospitalRun/teams/core-contributor)\n-\n-<!-- prettier-ignore -->\n-| [<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) |\n-|---|---|---|---|\n-\n-## Medical Supervisor\n-\n-[<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 />\n-\n-## Past Contributors\n-\n-[<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 />\n-\n-## Contributors\n-\n-[](https://github.com/HospitalRun/hospitalrun-frontend/graphs/contributors)\n-\n-## Founders\n-\n-<!-- prettier-ignore -->\n-| [<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) |\n-|---|---|---|\n-\n-# License\n-\n-Released under the [MIT license](LICENSE).\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | docs(readme): reorg readme and contrirubint |
288,417 | 27.06.2020 15:59:31 | 18,000 | c1ffd82f64eb44400d82815102b2efdbca19b433 | fix(patient): add DOB to add related person search | [
{
"change_type": "MODIFY",
"old_path": "src/patients/related-persons/AddRelatedPersonModal.tsx",
"new_path": "src/patients/related-persons/AddRelatedPersonModal.tsx",
"diff": "import { Modal, Alert, Typeahead, Label } from '@hospitalrun/components'\n+import format from 'date-fns/format'\nimport React, { useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { useDispatch, useSelector } from 'react-redux'\n@@ -42,6 +43,11 @@ const AddRelatedPersonModal = (props: Props) => {\nsetRelatedPerson({ ...relatedPerson, patientId: p[0].id })\n}\n+ const onSearch = async (query: string) => {\n+ const patients: Patient[] = await PatientRepository.search(query)\n+ return patients.filter((p: Patient) => p.id !== patient.id)\n+ }\n+\nconst body = (\n<form>\n{relatedPersonError?.message && (\n@@ -57,14 +63,12 @@ const AddRelatedPersonModal = (props: Props) => {\nplaceholder={t('patient.relatedPerson')}\nonChange={onPatientSelect}\nisInvalid={!!relatedPersonError?.relatedPerson}\n- onSearch={async (query: string) => PatientRepository.search(query)}\n- renderMenuItemChildren={(p: Patient) => {\n- if (patient.id === p.id) {\n- return <div />\n- }\n-\n- return <div>{`${p.fullName} (${p.code})`}</div>\n- }}\n+ onSearch={onSearch}\n+ renderMenuItemChildren={(p: Patient) => (\n+ <div>\n+ {`${p.fullName} - ${format(new Date(p.dateOfBirth), 'yyyy-MM-dd')} (${p.code})`}\n+ </div>\n+ )}\n/>\n{relatedPersonError?.relatedPerson && (\n<div className=\"text-left ml-3 mt-1 text-small text-danger invalid-feedback d-block related-person-feedback\">\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(patient): add DOB to add related person search
Co-authored-by: Matteo Vivona <[email protected]> |
288,323 | 28.06.2020 21:43:34 | 18,000 | cbb9487efcd261d96ba8f62ae5025c96651a85d4 | refactor(patients): refactor patient table to use Table component | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/list/ViewPatients.test.tsx",
"new_path": "src/__tests__/patients/list/ViewPatients.test.tsx",
"diff": "-import { TextInput, Spinner } from '@hospitalrun/components'\n-import format from 'date-fns/format'\n+import { TextInput, Spinner, Table } from '@hospitalrun/components'\nimport { mount } from 'enzyme'\nimport React from 'react'\nimport { act } from 'react-dom/test-utils'\n@@ -84,26 +83,27 @@ describe('Patients', () => {\nit('should render a table of patients', () => {\nconst wrapper = setup()\n- const table = wrapper.find('table')\n- const tableHeaders = table.find('th')\n- const tableColumns = table.find('td')\n+ const table = wrapper.find(Table)\n+ const columns = table.prop('columns')\n+ const actions = table.prop('actions') as any\nexpect(table).toHaveLength(1)\n- expect(tableHeaders).toHaveLength(5)\n- expect(tableColumns).toHaveLength(5)\n- expect(tableHeaders.at(0).text()).toEqual('patient.code')\n- expect(tableHeaders.at(1).text()).toEqual('patient.givenName')\n- expect(tableHeaders.at(2).text()).toEqual('patient.familyName')\n- expect(tableHeaders.at(3).text()).toEqual('patient.sex')\n- expect(tableHeaders.at(4).text()).toEqual('patient.dateOfBirth')\n-\n- expect(tableColumns.at(0).text()).toEqual(patients[0].code)\n- expect(tableColumns.at(1).text()).toEqual(patients[0].givenName)\n- expect(tableColumns.at(2).text()).toEqual(patients[0].familyName)\n- expect(tableColumns.at(3).text()).toEqual(patients[0].sex)\n- expect(tableColumns.at(4).text()).toEqual(\n- format(new Date(patients[0].dateOfBirth), 'yyyy-MM-dd'),\n+\n+ expect(columns[0]).toEqual(expect.objectContaining({ label: 'patient.code', key: 'code' }))\n+ expect(columns[1]).toEqual(\n+ expect.objectContaining({ label: 'patient.givenName', key: 'givenName' }),\n+ )\n+ expect(columns[2]).toEqual(\n+ expect.objectContaining({ label: 'patient.familyName', key: 'familyName' }),\n)\n+ expect(columns[3]).toEqual(expect.objectContaining({ label: 'patient.sex', key: 'sex' }))\n+ expect(columns[4]).toEqual(\n+ expect.objectContaining({ label: 'patient.dateOfBirth', key: 'dateOfBirth' }),\n+ )\n+\n+ expect(actions[0]).toEqual(expect.objectContaining({ label: 'actions.view' }))\n+ expect(table.prop('data')).toEqual(patients)\n+ expect(table.prop('actionsHeaderText')).toEqual('actions.label')\n})\nit('should add a \"New Patient\" button to the button tool bar', () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/list/ViewPatients.tsx",
"new_path": "src/patients/list/ViewPatients.tsx",
"diff": "-import { Spinner, Button, Container, Row, TextInput, Column } from '@hospitalrun/components'\n+import { Spinner, Button, Container, Row, TextInput, Column, Table } from '@hospitalrun/components'\nimport format from 'date-fns/format'\nimport React, { useEffect, useState, useRef } from 'react'\nimport { useTranslation } from 'react-i18next'\n@@ -67,28 +67,25 @@ const ViewPatients = () => {\nconst loadingIndicator = <Spinner color=\"blue\" loading size={[10, 25]} type=\"ScaleLoader\" />\nconst table = (\n- <table className=\"table table-hover\">\n- <thead className=\"thead-light \">\n- <tr>\n- <th>{t('patient.code')}</th>\n- <th>{t('patient.givenName')}</th>\n- <th>{t('patient.familyName')}</th>\n- <th>{t('patient.sex')}</th>\n- <th>{t('patient.dateOfBirth')}</th>\n- </tr>\n- </thead>\n- <tbody>\n- {patients.map((p) => (\n- <tr key={p.id} onClick={() => history.push(`/patients/${p.id}`)}>\n- <td>{p.code}</td>\n- <td>{p.givenName}</td>\n- <td>{p.familyName}</td>\n- <td>{p.sex}</td>\n- <td>{p.dateOfBirth ? format(new Date(p.dateOfBirth), 'yyyy-MM-dd') : ''}</td>\n- </tr>\n- ))}\n- </tbody>\n- </table>\n+ <Table\n+ tableClassName=\"table table-hover\"\n+ data={patients}\n+ getID={(row) => row.id}\n+ columns={[\n+ { label: t('patient.code'), key: 'code' },\n+ { label: t('patient.givenName'), key: 'givenName' },\n+ { label: t('patient.familyName'), key: 'familyName' },\n+ { label: t('patient.sex'), key: 'sex' },\n+ {\n+ label: t('patient.dateOfBirth'),\n+ key: 'dateOfBirth',\n+ formatter: (row) =>\n+ row.dateOfBirth ? format(new Date(row.dateOfBirth), 'yyyy-MM-dd') : '',\n+ },\n+ ]}\n+ actionsHeaderText={t('actions.label')}\n+ actions={[{ label: t('actions.view'), action: (row) => history.push(`/patients/${row.id}`) }]}\n+ />\n)\nconst onSearchBoxChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/locales/enUs/translations/actions/index.ts",
"new_path": "src/shared/locales/enUs/translations/actions/index.ts",
"diff": "@@ -15,5 +15,6 @@ export default {\nprevious: 'Previous',\npage: 'Page',\nadd: 'Add',\n+ view: 'View',\n},\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | refactor(patients): refactor patient table to use Table component |
288,323 | 28.06.2020 22:00:27 | 18,000 | 0c06f609c1ef7c7d1aa2ca841a905035a40bdee0 | refactor(incidents): refactor incidents table to use Table component | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/incidents/list/ViewIncidents.test.tsx",
"new_path": "src/__tests__/incidents/list/ViewIncidents.test.tsx",
"diff": "+import { Table } from '@hospitalrun/components'\nimport { act } from '@testing-library/react'\n-import { mount } from 'enzyme'\n+import { mount, ReactWrapper } from 'enzyme'\nimport { createMemoryHistory } from 'history'\nimport React from 'react'\nimport { Provider } from 'react-redux'\n@@ -70,7 +71,7 @@ describe('View Incidents', () => {\n)\n})\nwrapper.update()\n- return wrapper\n+ return wrapper as ReactWrapper\n}\nit('should filter incidents by status=reported on first load ', async () => {\nawait setup([Permissions.ViewIncidents])\n@@ -88,36 +89,40 @@ describe('View Incidents', () => {\nit('should render a table with the incidents', async () => {\nconst wrapper = await setup([Permissions.ViewIncidents])\n+ const table = wrapper.find(Table)\n+ const columns = table.prop('columns')\n+ const actions = table.prop('actions') as any\n+ expect(columns[0]).toEqual(\n+ expect.objectContaining({ label: 'incidents.reports.code', key: 'code' }),\n+ )\n+ expect(columns[1]).toEqual(\n+ expect.objectContaining({ label: 'incidents.reports.dateOfIncident', key: 'date' }),\n+ )\n+ expect(columns[2]).toEqual(\n+ expect.objectContaining({ label: 'incidents.reports.reportedBy', key: 'reportedBy' }),\n+ )\n+ expect(columns[3]).toEqual(\n+ expect.objectContaining({ label: 'incidents.reports.reportedOn', key: 'reportedOn' }),\n+ )\n+ expect(columns[4]).toEqual(\n+ expect.objectContaining({ label: 'incidents.reports.status', key: 'status' }),\n+ )\n- const table = wrapper.find('table')\n- const tableHeader = table.find('thead')\n- const tableBody = table.find('tbody')\n- const tableHeaders = tableHeader.find('th')\n- const tableColumns = tableBody.find('td')\n-\n- expect(tableHeaders.at(0).text()).toEqual('incidents.reports.code')\n- expect(tableHeaders.at(1).text()).toEqual('incidents.reports.dateOfIncident')\n- expect(tableHeaders.at(2).text()).toEqual('incidents.reports.reportedBy')\n- expect(tableHeaders.at(3).text()).toEqual('incidents.reports.reportedOn')\n- expect(tableHeaders.at(4).text()).toEqual('incidents.reports.status')\n-\n- expect(tableColumns.at(0).text()).toEqual(expectedIncidents[0].code)\n- expect(tableColumns.at(1).text()).toEqual('2020-06-03 07:48 PM')\n- expect(tableColumns.at(2).text()).toEqual(expectedIncidents[0].reportedBy)\n- expect(tableColumns.at(3).text()).toEqual('2020-06-03 07:48 PM')\n- expect(tableColumns.at(4).text()).toEqual(expectedIncidents[0].status)\n+ expect(actions[0]).toEqual(expect.objectContaining({ label: 'actions.view' }))\n+ expect(table.prop('actionsHeaderText')).toEqual('actions.label')\n+ expect(table.prop('data')).toEqual(expectedIncidents)\n})\n})\n- describe('on table row click', () => {\n+ describe('on view button click', () => {\nit('should navigate to the incident when the table row is clicked', async () => {\nconst wrapper = await setup([Permissions.ViewIncidents])\nconst tr = wrapper.find('tr').at(1)\nact(() => {\n- const onClick = tr.prop('onClick')\n- onClick()\n+ const onClick = tr.find('button').prop('onClick') as any\n+ onClick({ stopPropagation: jest.fn() })\n})\nexpect(history.location.pathname).toEqual(`/incidents/${expectedIncidents[0].id}`)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/incidents/list/ViewIncidents.tsx",
"new_path": "src/incidents/list/ViewIncidents.tsx",
"diff": "-import { Button } from '@hospitalrun/components'\n+import { Button, Table } from '@hospitalrun/components'\nimport format from 'date-fns/format'\nimport React, { useEffect, useState } from 'react'\nimport { useTranslation } from 'react-i18next'\n@@ -10,7 +10,6 @@ import useTitle from '../../page-header/title/useTitle'\nimport SelectWithLabelFormGroup, {\nOption,\n} from '../../shared/components/input/SelectWithLableFormGroup'\n-import Incident from '../../shared/model/Incident'\nimport { RootState } from '../../shared/store'\nimport IncidentFilter from '../IncidentFilter'\nimport { searchIncidents } from '../incidents-slice'\n@@ -46,10 +45,6 @@ const ViewIncidents = () => {\ndispatch(searchIncidents(searchFilter))\n}, [dispatch, searchFilter])\n- const onTableRowClick = (incident: Incident) => {\n- history.push(`incidents/${incident.id}`)\n- }\n-\nconst filterOptions: Option[] = Object.values(IncidentFilter).map((filter) => ({\nlabel: t(`incidents.status.${filter}`),\nvalue: `${filter}`,\n@@ -70,34 +65,27 @@ const ViewIncidents = () => {\n</div>\n</div>\n<div className=\"row\">\n- <table className=\"table table-hover\">\n- <thead className=\"thead-light\">\n- <tr>\n- <th>{t('incidents.reports.code')}</th>\n- <th>{t('incidents.reports.dateOfIncident')}</th>\n- <th>{t('incidents.reports.reportedBy')}</th>\n- <th>{t('incidents.reports.reportedOn')}</th>\n- <th>{t('incidents.reports.status')}</th>\n- </tr>\n- </thead>\n- <tbody>\n- {incidents.map((incident: Incident) => (\n- <tr onClick={() => onTableRowClick(incident)} key={incident.id}>\n- <td>{incident.code}</td>\n- <td>\n- {incident.date ? format(new Date(incident.date), 'yyyy-MM-dd hh:mm a') : ''}\n- </td>\n- <td>{incident.reportedBy}</td>\n- <td>\n- {incident.reportedOn\n- ? format(new Date(incident.reportedOn), 'yyyy-MM-dd hh:mm a')\n- : ''}\n- </td>\n- <td>{incident.status}</td>\n- </tr>\n- ))}\n- </tbody>\n- </table>\n+ <Table\n+ tableClassName=\"table table-hover\"\n+ getID={(row) => row.id}\n+ data={incidents}\n+ columns={[\n+ { label: t('incidents.reports.code'), key: 'code' },\n+ {\n+ label: t('incidents.reports.dateOfIncident'),\n+ key: 'date',\n+ formatter: (row) =>\n+ row.date ? format(new Date(row.date), 'yyyy-MM-dd hh:mm a') : '',\n+ },\n+ { label: t('incidents.reports.reportedBy'), key: 'reportedBy' },\n+ { label: t('incidents.reports.reportedOn'), key: 'reportedOn' },\n+ { label: t('incidents.reports.status'), key: 'status' },\n+ ]}\n+ actionsHeaderText={t('actions.label')}\n+ actions={[\n+ { label: t('actions.view'), action: (row) => history.push(`incidents/${row.id}`) },\n+ ]}\n+ />\n</div>\n</>\n)\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | refactor(incidents): refactor incidents table to use Table component |
288,323 | 28.06.2020 22:12:28 | 18,000 | 25504671ef5b0950c29e8759f2d84e048eba5026 | refactor(care plans): refactor care plans table to use Table component | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/care-plans/CarePlanTable.test.tsx",
"new_path": "src/__tests__/patients/care-plans/CarePlanTable.test.tsx",
"diff": "-import { Button } from '@hospitalrun/components'\n-import { mount } from 'enzyme'\n+import { Table } from '@hospitalrun/components'\n+import { mount, ReactWrapper } from 'enzyme'\nimport { createMemoryHistory } from 'history'\nimport React from 'react'\nimport { act } from 'react-dom/test-utils'\n@@ -46,41 +46,41 @@ describe('Care Plan Table', () => {\n</Provider>,\n)\n- return { wrapper, history }\n+ return { wrapper: wrapper as ReactWrapper, history }\n}\nit('should render a table', () => {\nconst { wrapper } = setup()\n- const table = wrapper.find('table')\n- const tableHeader = table.find('thead')\n- const headers = tableHeader.find('th')\n- const body = table.find('tbody')\n- const columns = body.find('tr').find('td')\n-\n- expect(headers.at(0).text()).toEqual('patient.carePlan.title')\n- expect(headers.at(1).text()).toEqual('patient.carePlan.startDate')\n- expect(headers.at(2).text()).toEqual('patient.carePlan.endDate')\n- expect(headers.at(3).text()).toEqual('patient.carePlan.status')\n- expect(headers.at(4).text()).toEqual('actions.label')\n+ const table = wrapper.find(Table)\n+ const columns = table.prop('columns')\n+ const actions = table.prop('actions') as any\n+ expect(columns[0]).toEqual(\n+ expect.objectContaining({ label: 'patient.carePlan.title', key: 'title' }),\n+ )\n+ expect(columns[1]).toEqual(\n+ expect.objectContaining({ label: 'patient.carePlan.startDate', key: 'startDate' }),\n+ )\n+ expect(columns[2]).toEqual(\n+ expect.objectContaining({ label: 'patient.carePlan.endDate', key: 'endDate' }),\n+ )\n+ expect(columns[3]).toEqual(\n+ expect.objectContaining({ label: 'patient.carePlan.status', key: 'status' }),\n+ )\n- expect(columns.at(0).text()).toEqual(carePlan.title)\n- expect(columns.at(1).text()).toEqual('2020-07-03')\n- expect(columns.at(2).text()).toEqual('2020-07-05')\n- expect(columns.at(3).text()).toEqual(carePlan.status)\n- expect(columns.at(4).find('button')).toHaveLength(1)\n+ expect(actions[0]).toEqual(expect.objectContaining({ label: 'actions.view' }))\n+ expect(table.prop('actionsHeaderText')).toEqual('actions.label')\n+ expect(table.prop('data')).toEqual(patient.carePlans)\n})\nit('should navigate to the care plan view when the view details button is clicked', () => {\nconst { wrapper, history } = setup()\n- const table = wrapper.find('table')\n- const body = table.find('tbody')\n- const columns = body.find('tr').find('td')\n+ const tr = wrapper.find('tr').at(1)\nact(() => {\n- const onClick = columns.at(4).find(Button).prop('onClick') as any\n- onClick()\n+ const onClick = tr.find('button').prop('onClick') as any\n+ onClick({ stopPropagation: jest.fn() })\n})\nexpect(history.location.pathname).toEqual(`/patients/${patient.id}/care-plans/${carePlan.id}`)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/care-plans/CarePlanTable.tsx",
"new_path": "src/patients/care-plans/CarePlanTable.tsx",
"diff": "-import { Button } from '@hospitalrun/components'\n+import { Table } from '@hospitalrun/components'\nimport format from 'date-fns/format'\nimport React from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { useSelector } from 'react-redux'\nimport { useHistory } from 'react-router-dom'\n-import CarePlan from '../../shared/model/CarePlan'\nimport { RootState } from '../../shared/store'\nconst CarePlanTable = () => {\n@@ -13,37 +12,33 @@ const CarePlanTable = () => {\nconst { t } = useTranslation()\nconst { patient } = useSelector((state: RootState) => state.patient)\n- const onViewClick = (carePlan: CarePlan) => {\n- history.push(`/patients/${patient.id}/care-plans/${carePlan.id}`)\n- }\n-\nreturn (\n- <table className=\"table table-hover\">\n- <thead className=\"thead-light \">\n- <tr>\n- <th>{t('patient.carePlan.title')}</th>\n- <th>{t('patient.carePlan.startDate')}</th>\n- <th>{t('patient.carePlan.endDate')}</th>\n- <th>{t('patient.carePlan.status')}</th>\n- <th>{t('actions.label')}</th>\n- </tr>\n- </thead>\n- <tbody>\n- {patient.carePlans?.map((carePlan) => (\n- <tr key={carePlan.id}>\n- <td>{carePlan.title}</td>\n- <td>{format(new Date(carePlan.startDate), 'yyyy-MM-dd')}</td>\n- <td>{format(new Date(carePlan.endDate), 'yyyy-MM-dd')}</td>\n- <td>{carePlan.status}</td>\n- <td>\n- <Button color=\"secondary\" onClick={() => onViewClick(carePlan)}>\n- View\n- </Button>\n- </td>\n- </tr>\n- ))}\n- </tbody>\n- </table>\n+ <Table\n+ tableClassName=\"table table-hover\"\n+ getID={(row) => row.id}\n+ data={patient.carePlans}\n+ columns={[\n+ { label: t('patient.carePlan.title'), key: 'title' },\n+ {\n+ label: t('patient.carePlan.startDate'),\n+ key: 'startDate',\n+ formatter: (row) => format(new Date(row.startDate), 'yyyy-MM-dd'),\n+ },\n+ {\n+ label: t('patient.carePlan.endDate'),\n+ key: 'endDate',\n+ formatter: (row) => format(new Date(row.endDate), 'yyyy-MM-dd'),\n+ },\n+ { label: t('patient.carePlan.status'), key: 'status' },\n+ ]}\n+ actionsHeaderText={t('actions.label')}\n+ actions={[\n+ {\n+ label: 'actions.view',\n+ action: (row) => history.push(`/patients/${patient.id}/care-plans/${row.id}`),\n+ },\n+ ]}\n+ />\n)\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | refactor(care plans): refactor care plans table to use Table component |
288,323 | 28.06.2020 22:29:54 | 18,000 | 25d0902fa4c7ee89b7e5e02932272ad6a6bd809c | refactor(relatedpersons): refactor to use Table component | [
{
"change_type": "RENAME",
"old_path": "src/__tests__/patients/related-persons/RelatedPersons.test.tsx",
"new_path": "src/__tests__/patients/related-persons/RelatedPersonsTab.test.tsx",
"diff": "import * as components from '@hospitalrun/components'\n+import { Table } from '@hospitalrun/components'\nimport { act } from '@testing-library/react'\nimport { mount } from 'enzyme'\nimport { createMemoryHistory } from 'history'\n@@ -14,7 +15,6 @@ import RelatedPersonTab from '../../../patients/related-persons/RelatedPersonTab\nimport PatientRepository from '../../../shared/db/PatientRepository'\nimport Patient from '../../../shared/model/Patient'\nimport Permissions from '../../../shared/model/Permissions'\n-import RelatedPerson from '../../../shared/model/RelatedPerson'\nimport { RootState } from '../../../shared/store'\nconst mockStore = createMockStore<RootState, any>([thunk])\n@@ -110,6 +110,7 @@ describe('Related Persons Tab', () => {\nfamilyName: 'test',\nfullName: 'test test',\nid: '123001',\n+ type: 'type',\n} as Patient\nconst user = {\n@@ -133,51 +134,45 @@ describe('Related Persons Tab', () => {\n})\nit('should render a list of related persons with their full name being displayed', () => {\n- const table = wrapper.find('table')\n- const tableHeader = wrapper.find('thead')\n- const tableHeaders = wrapper.find('th')\n- const tableBody = wrapper.find('tbody')\n- const tableData = wrapper.find('td')\n- const deleteButton = tableData.at(3).find(components.Button)\n- expect(table).toHaveLength(1)\n- expect(tableHeader).toHaveLength(1)\n- expect(tableBody).toHaveLength(1)\n- expect(tableHeaders.at(0).text()).toEqual('patient.givenName')\n- expect(tableHeaders.at(1).text()).toEqual('patient.familyName')\n- expect(tableHeaders.at(2).text()).toEqual('patient.relatedPersons.relationshipType')\n- expect(tableHeaders.at(3).text()).toEqual('actions.label')\n- expect(tableData.at(0).text()).toEqual(expectedRelatedPerson.givenName)\n- expect(tableData.at(1).text()).toEqual(expectedRelatedPerson.familyName)\n- expect(tableData.at(2).text()).toEqual((patient.relatedPersons as RelatedPerson[])[0].type)\n- expect(deleteButton).toHaveLength(1)\n- expect(deleteButton.text().trim()).toEqual('actions.delete')\n- expect(deleteButton.prop('color')).toEqual('danger')\n+ const table = wrapper.find(Table)\n+ const columns = table.prop('columns')\n+ const actions = table.prop('actions') as any\n+ expect(columns[0]).toEqual(\n+ expect.objectContaining({ label: 'patient.givenName', key: 'givenName' }),\n+ )\n+ expect(columns[1]).toEqual(\n+ expect.objectContaining({ label: 'patient.familyName', key: 'familyName' }),\n+ )\n+ expect(columns[2]).toEqual(\n+ expect.objectContaining({\n+ label: 'patient.relatedPersons.relationshipType',\n+ key: 'type',\n+ }),\n+ )\n+\n+ expect(actions[0]).toEqual(expect.objectContaining({ label: 'actions.view' }))\n+ expect(actions[1]).toEqual(expect.objectContaining({ label: 'actions.delete' }))\n+ expect(table.prop('actionsHeaderText')).toEqual('actions.label')\n+ expect(table.prop('data')).toEqual([expectedRelatedPerson])\n})\nit('should remove the related person when the delete button is clicked', async () => {\nconst removeRelatedPersonSpy = jest.spyOn(patientSlice, 'removeRelatedPerson')\n- const eventPropagationSpy = jest.fn()\n-\n- const table = wrapper.find('table')\n- const tableBody = table.find('tbody')\n- const tableData = tableBody.find('td')\n- const deleteButton = tableData.at(3).find(components.Button)\n+ const tr = wrapper.find('tr').at(1)\n- await act(async () => {\n- const onClick = deleteButton.prop('onClick')\n- await onClick({ stopPropagation: eventPropagationSpy })\n+ act(() => {\n+ const onClick = tr.find('button').at(1).prop('onClick') as any\n+ onClick({ stopPropagation: jest.fn() })\n})\n-\nexpect(removeRelatedPersonSpy).toHaveBeenCalledWith(patient.id, expectedRelatedPerson.id)\n})\nit('should navigate to related person patient profile on related person click', async () => {\n- const table = wrapper.find('table')\n- const tableBody = table.find('tbody')\n- const row = tableBody.find('tr')\n- await act(async () => {\n- const onClick = row.prop('onClick')\n- await onClick()\n+ const tr = wrapper.find('tr').at(1)\n+\n+ act(() => {\n+ const onClick = tr.find('button').at(0).prop('onClick') as any\n+ onClick({ stopPropagation: jest.fn() })\n})\nexpect(history.location.pathname).toEqual('/patients/123001')\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/related-persons/RelatedPersonTab.tsx",
"new_path": "src/patients/related-persons/RelatedPersonTab.tsx",
"diff": "-import { Button, Alert, Spinner } from '@hospitalrun/components'\n+import { Button, Alert, Spinner, Table } from '@hospitalrun/components'\nimport React, { useState, useEffect } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { useDispatch, useSelector } from 'react-redux'\n@@ -59,18 +59,11 @@ const RelatedPersonTab = (props: Props) => {\nsetShowRelatedPersonModal(true)\n}\n- const onRelatedPersonClick = (id: string) => {\n- navigateTo(`/patients/${id}`)\n- }\nconst closeNewRelatedPersonModal = () => {\nsetShowRelatedPersonModal(false)\n}\n- const onRelatedPersonDelete = (\n- event: React.MouseEvent<HTMLButtonElement>,\n- relatedPerson: Patient,\n- ) => {\n- event.stopPropagation()\n+ const onRelatedPersonDelete = (relatedPerson: Patient) => {\ndispatch(removeRelatedPerson(patient.id, relatedPerson.id))\n}\n@@ -96,34 +89,25 @@ const RelatedPersonTab = (props: Props) => {\n<div className=\"col-md-12\">\n{relatedPersons ? (\nrelatedPersons.length > 0 ? (\n- <table className=\"table table-hover\">\n- <thead className=\"thead-light\">\n- <tr>\n- <th>{t('patient.givenName')}</th>\n- <th>{t('patient.familyName')}</th>\n- <th>{t('patient.relatedPersons.relationshipType')}</th>\n- <th>{t('actions.label')}</th>\n- </tr>\n- </thead>\n- <tbody>\n- {relatedPersons.map((r) => (\n- <tr key={r.id} onClick={() => onRelatedPersonClick(r.id)}>\n- <td>{r.givenName}</td>\n- <td>{r.familyName}</td>\n- <td>{r.type}</td>\n- <td>\n- <Button\n- icon=\"remove\"\n- color=\"danger\"\n- onClick={(e) => onRelatedPersonDelete(e, r)}\n- >\n- {t('actions.delete')}\n- </Button>\n- </td>\n- </tr>\n- ))}\n- </tbody>\n- </table>\n+ <Table\n+ tableClassName=\"table table-hover\"\n+ getID={(row) => row.id}\n+ data={relatedPersons}\n+ columns={[\n+ { label: t('patient.givenName'), key: 'givenName' },\n+ { label: t('patient.familyName'), key: 'familyName' },\n+ { label: t('patient.relatedPersons.relationshipType'), key: 'type' },\n+ ]}\n+ actionsHeaderText={t('actions.label')}\n+ actions={[\n+ { label: t('actions.view'), action: (row) => navigateTo(`/patients/${row.id}`) },\n+ {\n+ label: t('actions.delete'),\n+ action: (row) => onRelatedPersonDelete(row as Patient),\n+ buttonColor: 'danger',\n+ },\n+ ]}\n+ />\n) : (\n<Alert\ncolor=\"warning\"\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | refactor(relatedpersons): refactor to use Table component |
288,323 | 28.06.2020 22:58:43 | 18,000 | e43c9c7aa13cf1a76986945323379fa909e55e80 | fix(care plans): fix undefined care plans behavior | [
{
"change_type": "MODIFY",
"old_path": "src/patients/care-plans/CarePlanTable.tsx",
"new_path": "src/patients/care-plans/CarePlanTable.tsx",
"diff": "@@ -12,6 +12,7 @@ const CarePlanTable = () => {\nconst { t } = useTranslation()\nconst { patient } = useSelector((state: RootState) => state.patient)\n+ if (patient.carePlans !== undefined) {\nreturn (\n<Table\ntableClassName=\"table table-hover\"\n@@ -41,5 +42,7 @@ const CarePlanTable = () => {\n/>\n)\n}\n+ return <></>\n+}\nexport default CarePlanTable\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(care plans): fix undefined care plans behavior |
288,323 | 28.06.2020 22:59:28 | 18,000 | 922d7675bc9c7f51cacd100be0becbd5ee6087e1 | fix: fix find all + sort request behavior | [
{
"change_type": "MODIFY",
"old_path": "src/shared/db/Repository.ts",
"new_path": "src/shared/db/Repository.ts",
"diff": "@@ -31,7 +31,7 @@ export default class Repository<T extends AbstractDBModel> {\n}\nsort.sorts.forEach((s) => {\n- selector[s.field] = { $gt: null }\n+ selector[`data.${s.field}`] = { $gt: null }\n})\n// Adds an index to each of the fields coming from the sorting object\n@@ -42,7 +42,7 @@ export default class Repository<T extends AbstractDBModel> {\nasync (s): Promise<SortRequest> => {\nawait this.db.createIndex({\nindex: {\n- fields: [s.field],\n+ fields: [`data.${s.field}`],\n},\n})\n@@ -53,7 +53,10 @@ export default class Repository<T extends AbstractDBModel> {\nconst result = await this.db.find({\nselector,\n- sort: sort.sorts.length > 0 ? sort.sorts.map((s) => ({ [s.field]: s.direction })) : undefined,\n+ sort:\n+ sort.sorts.length > 0\n+ ? sort.sorts.map((s) => ({ [`data.${s.field}`]: s.direction }))\n+ : undefined,\n})\nconst relDocs = await this.db.rel.parseRelDocs(this.type, result.docs)\nreturn relDocs[this.pluralType]\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix: fix find all + sort request behavior |
288,323 | 28.06.2020 23:00:27 | 18,000 | 279d64914ca0fab541ade4f64d9569f27000ddae | fix: undefined care plan behavior | [
{
"change_type": "MODIFY",
"old_path": "src/patients/care-plans/CarePlanTable.tsx",
"new_path": "src/patients/care-plans/CarePlanTable.tsx",
"diff": "@@ -12,12 +12,11 @@ const CarePlanTable = () => {\nconst { t } = useTranslation()\nconst { patient } = useSelector((state: RootState) => state.patient)\n- if (patient.carePlans !== undefined) {\nreturn (\n<Table\ntableClassName=\"table table-hover\"\ngetID={(row) => row.id}\n- data={patient.carePlans}\n+ data={patient.carePlans || []}\ncolumns={[\n{ label: t('patient.carePlan.title'), key: 'title' },\n{\n@@ -42,7 +41,5 @@ const CarePlanTable = () => {\n/>\n)\n}\n- return <></>\n-}\nexport default CarePlanTable\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix: undefined care plan behavior |
288,323 | 28.06.2020 23:01:07 | 18,000 | 88a7c0863c0a7752b99683e864d461209fe16b5d | feat(labs): labs tab should use Table component | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/labs/LabsTab.test.tsx",
"new_path": "src/__tests__/patients/labs/LabsTab.test.tsx",
"diff": "import * as components from '@hospitalrun/components'\n-import format from 'date-fns/format'\n+import { Table } from '@hospitalrun/components'\nimport { mount, ReactWrapper } from 'enzyme'\nimport { createMemoryHistory } from 'history'\nimport React from 'react'\n@@ -61,23 +61,23 @@ describe('Labs Tab', () => {\nit('should list the patients labs', async () => {\nconst { wrapper } = await setup()\n- const table = wrapper.find('table')\n- const tableHeader = wrapper.find('thead')\n- const tableHeaders = wrapper.find('th')\n- const tableBody = wrapper.find('tbody')\n- const tableData = wrapper.find('td')\n-\n- expect(table).toHaveLength(1)\n- expect(tableHeader).toHaveLength(1)\n- expect(tableBody).toHaveLength(1)\n- expect(tableHeaders.at(0).text()).toEqual('labs.lab.type')\n- expect(tableHeaders.at(1).text()).toEqual('labs.lab.requestedOn')\n- expect(tableHeaders.at(2).text()).toEqual('labs.lab.status')\n- expect(tableData.at(0).text()).toEqual(expectedLabs[0].type)\n- expect(tableData.at(1).text()).toEqual(\n- format(new Date(expectedLabs[0].requestedOn), 'yyyy-MM-dd hh:mm a'),\n+ const table = wrapper.find(Table)\n+ const columns = table.prop('columns')\n+ const actions = table.prop('actions') as any\n+ expect(columns[0]).toEqual(expect.objectContaining({ label: 'labs.lab.type', key: 'type' }))\n+ expect(columns[1]).toEqual(\n+ expect.objectContaining({ label: 'labs.lab.requestedOn', key: 'requestedOn' }),\n+ )\n+ expect(columns[2]).toEqual(\n+ expect.objectContaining({\n+ label: 'labs.lab.status',\n+ key: 'status',\n+ }),\n)\n- expect(tableData.at(2).text()).toEqual(expectedLabs[0].status)\n+\n+ expect(actions[0]).toEqual(expect.objectContaining({ label: 'actions.view' }))\n+ expect(table.prop('actionsHeaderText')).toEqual('actions.label')\n+ expect(table.prop('data')).toEqual(expectedLabs)\n})\nit('should render a warning message if the patient does not have any labs', async () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/labs/LabsTab.tsx",
"new_path": "src/patients/labs/LabsTab.tsx",
"diff": "-import { Alert } from '@hospitalrun/components'\n+import { Alert, Table } from '@hospitalrun/components'\nimport format from 'date-fns/format'\nimport React, { useEffect, useState } from 'react'\nimport { useTranslation } from 'react-i18next'\n@@ -27,10 +27,6 @@ const LabsTab = (props: Props) => {\nfetch()\n}, [patientId])\n- const onTableRowClick = (lab: Lab) => {\n- history.push(`/labs/${lab.id}`)\n- }\n-\nreturn (\n<div>\n{(!labs || labs.length === 0) && (\n@@ -41,24 +37,22 @@ const LabsTab = (props: Props) => {\n/>\n)}\n{labs && labs.length > 0 && (\n- <table className=\"table table-hover\">\n- <thead className=\"thead-light\">\n- <tr>\n- <th>{t('labs.lab.type')}</th>\n- <th>{t('labs.lab.requestedOn')}</th>\n- <th>{t('labs.lab.status')}</th>\n- </tr>\n- </thead>\n- <tbody>\n- {labs.map((lab) => (\n- <tr onClick={() => onTableRowClick(lab)} key={lab.id}>\n- <td>{lab.type}</td>\n- <td>{format(new Date(lab.requestedOn), 'yyyy-MM-dd hh:mm a')}</td>\n- <td>{lab.status}</td>\n- </tr>\n- ))}\n- </tbody>\n- </table>\n+ <Table\n+ tableClassName=\"table table-hover\"\n+ actionsHeaderText={t('actions.label')}\n+ getID={(row) => row.id}\n+ data={labs}\n+ columns={[\n+ { label: t('labs.lab.type'), key: 'type' },\n+ {\n+ label: t('labs.lab.requestedOn'),\n+ key: 'requestedOn',\n+ formatter: (row) => format(new Date(row.requestedOn), 'yyyy-MM-dd hh:mm a'),\n+ },\n+ { label: t('labs.lab.status'), key: 'status' },\n+ ]}\n+ actions={[{ label: t('actions.view'), action: (row) => history.push(`/labs/${row.id}`) }]}\n+ />\n)}\n</div>\n)\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(labs): labs tab should use Table component |
288,323 | 28.06.2020 23:11:31 | 18,000 | 978788e540db6553fbc5e4fd928b44d47285be01 | refactor(labs): labs should use Table component | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/labs/ViewLabs.test.tsx",
"new_path": "src/__tests__/labs/ViewLabs.test.tsx",
"diff": "-import { TextInput, Select } from '@hospitalrun/components'\n+import { TextInput, Select, Table } from '@hospitalrun/components'\nimport { act } from '@testing-library/react'\n-import format from 'date-fns/format'\nimport { mount, ReactWrapper } from 'enzyme'\nimport { createMemoryHistory } from 'history'\nimport React from 'react'\n@@ -102,7 +101,7 @@ describe('View Labs', () => {\ncode: 'L-1234',\nid: '1234',\ntype: 'lab type',\n- patientId: 'patientId',\n+ patient: 'patientId',\nstatus: 'requested',\nrequestedOn: '2020-03-30T04:43:20.102Z',\n} as Lab\n@@ -130,45 +129,30 @@ describe('View Labs', () => {\n})\nit('should render a table with data', () => {\n- const table = wrapper.find('table')\n- const tableHeader = table.find('thead')\n- const tableBody = table.find('tbody')\n-\n- const tableColumnHeaders = tableHeader.find('th')\n- const tableDataColumns = tableBody.find('td')\n-\n- expect(table).toBeDefined()\n- expect(tableHeader).toBeDefined()\n- expect(tableBody).toBeDefined()\n- expect(tableColumnHeaders.at(0).text().trim()).toEqual('labs.lab.code')\n-\n- expect(tableColumnHeaders.at(1).text().trim()).toEqual('labs.lab.type')\n-\n- expect(tableColumnHeaders.at(2).text().trim()).toEqual('labs.lab.requestedOn')\n-\n- expect(tableColumnHeaders.at(3).text().trim()).toEqual('labs.lab.status')\n-\n- expect(tableDataColumns.at(0).text().trim()).toEqual(expectedLab.code)\n-\n- expect(tableDataColumns.at(1).text().trim()).toEqual(expectedLab.type)\n-\n- expect(tableDataColumns.at(2).text().trim()).toEqual(\n- format(new Date(expectedLab.requestedOn), 'yyyy-MM-dd hh:mm a'),\n+ const table = wrapper.find(Table)\n+ const columns = table.prop('columns')\n+ const actions = table.prop('actions') as any\n+ expect(columns[0]).toEqual(expect.objectContaining({ label: 'labs.lab.code', key: 'code' }))\n+ expect(columns[1]).toEqual(expect.objectContaining({ label: 'labs.lab.type', key: 'type' }))\n+ expect(columns[2]).toEqual(\n+ expect.objectContaining({ label: 'labs.lab.requestedOn', key: 'requestedOn' }),\n+ )\n+ expect(columns[3]).toEqual(\n+ expect.objectContaining({ label: 'labs.lab.status', key: 'status' }),\n)\n- expect(tableDataColumns.at(3).text().trim()).toEqual(expectedLab.status)\n+ expect(actions[0]).toEqual(expect.objectContaining({ label: 'actions.view' }))\n+ expect(table.prop('actionsHeaderText')).toEqual('actions.label')\n+ expect(table.prop('data')).toEqual([expectedLab])\n})\n- it('should navigate to the lab when the row is clicked', () => {\n- const table = wrapper.find('table')\n- const tableBody = table.find('tbody')\n- const tableRow = tableBody.find('tr').at(0)\n+ it('should navigate to the lab when the view button is clicked', () => {\n+ const tr = wrapper.find('tr').at(1)\nact(() => {\n- const onClick = tableRow.prop('onClick') as any\n- onClick()\n+ const onClick = tr.find('button').prop('onClick') as any\n+ onClick({ stopPropagation: jest.fn() })\n})\n-\nexpect(history.location.pathname).toEqual(`/labs/${expectedLab.id}`)\n})\n})\n@@ -181,7 +165,7 @@ describe('View Labs', () => {\nconst expectedLab = {\nid: '1234',\ntype: 'lab type',\n- patientId: 'patientId',\n+ patient: 'patientId',\nstatus: 'requested',\nrequestedOn: '2020-03-30T04:43:20.102Z',\n} as Lab\n@@ -234,7 +218,7 @@ describe('View Labs', () => {\nconst expectedLab = {\nid: '1234',\ntype: 'lab type',\n- patientId: 'patientId',\n+ patient: 'patientId',\nstatus: 'requested',\nrequestedOn: '2020-03-30T04:43:20.102Z',\n} as Lab\n"
},
{
"change_type": "MODIFY",
"old_path": "src/labs/ViewLabs.tsx",
"new_path": "src/labs/ViewLabs.tsx",
"diff": "-import { Spinner, Button } from '@hospitalrun/components'\n+import { Button, Table } from '@hospitalrun/components'\nimport format from 'date-fns/format'\nimport React, { useState, useEffect, useCallback } from 'react'\nimport { useTranslation } from 'react-i18next'\n@@ -27,7 +27,7 @@ const ViewLabs = () => {\nconst { permissions } = useSelector((state: RootState) => state.user)\nconst dispatch = useDispatch()\n- const { labs, isLoading } = useSelector((state: RootState) => state.labs)\n+ const { labs } = useSelector((state: RootState) => state.labs)\nconst [searchFilter, setSearchFilter] = useState<LabFilter>('all')\nconst [searchText, setSearchText] = useState<string>('')\nconst debouncedSearchText = useDebounce(searchText, 500)\n@@ -63,9 +63,7 @@ const ViewLabs = () => {\n}\n}, [dispatch, getButtons, setButtons])\n- const loadingIndicator = <Spinner color=\"blue\" loading size={[10, 25]} type=\"ScaleLoader\" />\n-\n- const onTableRowClick = (lab: Lab) => {\n+ const onViewClick = (lab: Lab) => {\nhistory.push(`/labs/${lab.id}`)\n}\n@@ -80,19 +78,6 @@ const ViewLabs = () => {\n{ label: t('labs.filter.all'), value: 'all' },\n]\n- const listBody = (\n- <tbody>\n- {labs.map((lab) => (\n- <tr onClick={() => onTableRowClick(lab)} key={lab.id}>\n- <td>{lab.code}</td>\n- <td>{lab.type}</td>\n- <td>{lab.requestedOn ? format(new Date(lab.requestedOn), 'yyyy-MM-dd hh:mm a') : ''}</td>\n- <td>{lab.status}</td>\n- </tr>\n- ))}\n- </tbody>\n- )\n-\nreturn (\n<>\n<div className=\"row\">\n@@ -118,17 +103,24 @@ const ViewLabs = () => {\n</div>\n</div>\n<div className=\"row\">\n- <table className=\"table table-hover\">\n- <thead className=\"thead-light\">\n- <tr>\n- <th>{t('labs.lab.code')}</th>\n- <th>{t('labs.lab.type')}</th>\n- <th>{t('labs.lab.requestedOn')}</th>\n- <th>{t('labs.lab.status')}</th>\n- </tr>\n- </thead>\n- {isLoading ? loadingIndicator : listBody}\n- </table>\n+ <Table\n+ tableClassName=\"table table-hover\"\n+ getID={(row) => row.id}\n+ columns={[\n+ { label: t('labs.lab.code'), key: 'code' },\n+ { label: t('labs.lab.type'), key: 'type' },\n+ {\n+ label: t('labs.lab.requestedOn'),\n+ key: 'requestedOn',\n+ formatter: (row) =>\n+ row.requestedOn ? format(new Date(row.requestedOn), 'yyyy-MM-dd hh:mm a') : '',\n+ },\n+ { label: t('labs.lab.status'), key: 'status' },\n+ ]}\n+ data={labs}\n+ actionsHeaderText={t('actions.label')}\n+ actions={[{ label: t('actions.view'), action: (row) => onViewClick(row as Lab) }]}\n+ />\n</div>\n</>\n)\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | refactor(labs): labs should use Table component |
288,323 | 28.06.2020 23:17:42 | 18,000 | aabd33e2651246ac8eaadc1c6b260b1f3b6e7591 | fix(incidents): fix find all incidents | [
{
"change_type": "MODIFY",
"old_path": "src/shared/db/IncidentRepository.ts",
"new_path": "src/shared/db/IncidentRepository.ts",
"diff": "@@ -16,7 +16,8 @@ class IncidentRepository extends Repository<Incident> {\n}\nprivate static getSearchCriteria(options: SearchOptions): any {\n- const statusFilter = options.status !== IncidentFilter.all ? [{ status: options.status }] : []\n+ const statusFilter =\n+ options.status !== IncidentFilter.all ? [{ 'data.status': options.status }] : []\nconst selector = {\n$and: statusFilter,\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(incidents): fix find all incidents |
288,394 | 29.06.2020 03:22:20 | 25,200 | f82e592864570447bab56435ae1a71f9e092267e | docs(readme): restore some sections. update text. | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "+# HospitalRun Frontend\n+\n+<div align=\"center\">\n+\n+ [](https://github.com/HospitalRun/hospitalrun-frontend/releases) [](https://github.com/HospitalRun/hospitalrun-frontend/releases)\n+[](https://github.com/HospitalRun/frontend/actions) [](https://coveralls.io/github/HospitalRun/hospitalrun-frontend?branch=master) [](https://lgtm.com/projects/g/HospitalRun/hospitalrun-frontend/context:javascript) [](https://hospitalrun-frontend.readthedocs.io)\n+[](https://app.fossa.io/projects/git%2Bgithub.com%2FHospitalRun%2Fhospitalrun-frontend?ref=badge_large) [](http://commitizen.github.io/cz-cli/)\n+ [](https://hospitalrun-slack.herokuapp.com) [](https://repl.it/github/HospitalRun/hospitalrun-frontend)\n+[](https://gitpod.io/#https://github.com/HospitalRun/hospitalrun-frontend)\n+\n+</div>\n+\n+React frontend for [HospitalRun](http://hospitalrun.io/): free software for developing world hospitals.\n+\n+---\n+\n+# Are you a user? Read this.\n+\n[Visit this page for general information on the HospitalRun application](https://github.com/HospitalRun/hospitalrun/blob/master/README.md) including:\nHow can I deploy 1.0.0-beta? | Where do I report a bug or request a feature? | How can I contribute? (There are several other ways besides coding) | What is the project structure? | What is the application infrastructure? | Who is behind HospitalRun? etc.\n-# How to Contribute to the Frontend Repository\n+# Would you like to contribute? Read this.\n[Get started by checking out the Frontend Contributing Guide](https://github.com/HospitalRun/hospitalrun-frontend/blob/master/.github/CONTRIBUTING.md) for:\n- What's the tech stack?\n@@ -13,15 +31,58 @@ How can I deploy 1.0.0-beta? | Where do I report a bug or request a feature? | H\n- How do I submit my changes?\n- etc.\n----\n+# Behind HospitalRun\n-<div align=\"center\">\n+## Hosted by\n- [](https://github.com/HospitalRun/hospitalrun-frontend/releases) [](https://github.com/HospitalRun/hospitalrun-frontend/releases)\n-[](https://github.com/HospitalRun/frontend/actions) [](https://coveralls.io/github/HospitalRun/hospitalrun-frontend?branch=master) [](https://lgtm.com/projects/g/HospitalRun/hospitalrun-frontend/context:javascript) [](https://hospitalrun-frontend.readthedocs.io)\n-[](https://app.fossa.io/projects/git%2Bgithub.com%2FHospitalRun%2Fhospitalrun-frontend?ref=badge_large) [](http://commitizen.github.io/cz-cli/)\n- [](https://hospitalrun-slack.herokuapp.com) [](https://repl.it/github/HospitalRun/hospitalrun-frontend)\n-[](https://gitpod.io/#https://github.com/HospitalRun/hospitalrun-frontend)\n+[<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)\n-</div>\n+## Sponsors\n+\n+[](https://opencollective.com/hospitalrun/contribute/sponsors-336/checkout)\n+\n+## Backers\n+\n+[](https://opencollective.com/hospitalrun/contribute/backers-335/checkout)\n+\n+## Big Thanks\n+\n+Cross-browser Testing Platform and Open Source <3 Provided by [Sauce Labs](https://saucelabs.com)\n+\n+## Lead Maintainer\n+\n+[<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 />\n+\n+## [Core Maintainers](https://github.com/orgs/HospitalRun/teams/core-maintainers)\n+\n+<!-- prettier-ignore -->\n+| [<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) |\n+|---|---|\n+\n+## [Core Contributors](https://github.com/orgs/HospitalRun/teams/core-contributor)\n+\n+<!-- prettier-ignore -->\n+| [<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) |\n+|---|---|---|---|\n+\n+## Medical Supervisor\n+\n+[<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 />\n+\n+## Past Contributors\n+\n+[<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 />\n+\n+## Contributors\n+\n+[](https://github.com/HospitalRun/hospitalrun-frontend/graphs/contributors)\n+\n+## Founders\n+\n+<!-- prettier-ignore -->\n+| [<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) |\n+|---|---|---|\n+\n+# License\n+Released under the [MIT license](LICENSE).\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | docs(readme): restore some sections. update text. |
288,394 | 29.06.2020 03:25:13 | 25,200 | 8fd337d419886fffb56ef6a23798d14fbc4c079c | docs(contributing): fix text | [
{
"change_type": "MODIFY",
"old_path": ".github/CONTRIBUTING.md",
"new_path": ".github/CONTRIBUTING.md",
"diff": "@@ -9,11 +9,11 @@ Before contributing, please read the [code of conduct](https://github.com/Hospit\n4. Commit Changes\n5. Submit a Pull Request\n-## 2. After creating a local branch (step 3 above), follow these steps to configure CouchDB\n+## 2. After creating a local fork (step 3 above), follow these steps to configure CouchDB\n-CouchDB is the server side database which data from the frontend will sync to. CouchDB is required to login\n+CouchDB is the server side database which data from the frontend will sync from and to. CouchDB is required to login\nto HospitalRun. You could install and run CouchDB in any way you wish. For convienence, we have added a docker compose file in the\n-root of this project to launch CouchDB. Below is the steps:\n+root of this project to launch CouchDB. Below are the steps:\n1. Start [Docker](https://docs.docker.com/get-docker/). Install it if you don't have it yet.\n2. Install [Docker Compose](https://docs.docker.com/compose/install/) if you don't have it yet.\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | docs(contributing): fix text |
288,249 | 29.06.2020 03:50:37 | 25,200 | 4e10f67b58da830d9f17c2aefa45e13e49ee9b49 | docs(readme): misc | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -14,13 +14,13 @@ React frontend for [HospitalRun](http://hospitalrun.io/): free software for deve\n---\n-# Are you a user? Read this.\n+# Are you a user? If yes...\n[Visit this page for general information on the HospitalRun application](https://github.com/HospitalRun/hospitalrun/blob/master/README.md) including:\nHow can I deploy 1.0.0-beta? | Where do I report a bug or request a feature? | How can I contribute? (There are several other ways besides coding) | What is the project structure? | What is the application infrastructure? | Who is behind HospitalRun? etc.\n-# Would you like to contribute? Read this.\n+# Would you like to contribute? If yes...\n[Get started by checking out the Frontend Contributing Guide](https://github.com/HospitalRun/hospitalrun-frontend/blob/master/.github/CONTRIBUTING.md) for:\n- What's the tech stack?\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | docs(readme): misc |
288,334 | 29.06.2020 17:18:37 | -7,200 | 0b8d10878b00f9957357988d9b80823d125eef0f | docs(readme): add login indications | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -25,6 +25,10 @@ React frontend for [HospitalRun](http://hospitalrun.io/): free software for deve\n</div>\n+# Staging area\n+\n+You can follow developments by visiting the dedicated [staging environment](https://staging.hospitalrun.io). Use `username` / `password` as credentials to access.\n+\n# Contributing\nContributions are always welcome. Before contributing please read our [contributor guide](https://github.com/HospitalRun/hospitalrun-frontend/blob/master/.github/CONTRIBUTING.md).\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | docs(readme): add login indications |
288,323 | 29.06.2020 16:50:07 | 18,000 | d5505d269d298fc45997f4b7c69fbedf131d50f2 | style: remove unused prop | [
{
"change_type": "MODIFY",
"old_path": "src/shared/components/input/TextFieldWithLabelFormGroup.tsx",
"new_path": "src/shared/components/input/TextFieldWithLabelFormGroup.tsx",
"diff": "@@ -6,7 +6,6 @@ interface Props {\nlabel?: string\nname: string\nisEditable?: boolean\n- placeholder?: string\nonChange?: (event: React.ChangeEvent<HTMLTextAreaElement>) => void\nisRequired?: boolean\nfeedback?: string\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | style: remove unused prop |
288,323 | 29.06.2020 16:51:56 | 18,000 | faea7bae3e00d3c471802a875bcce7e719f9b277 | fix: remove duplicate prop | [
{
"change_type": "MODIFY",
"old_path": "src/incidents/list/ViewIncidents.tsx",
"new_path": "src/incidents/list/ViewIncidents.tsx",
"diff": "@@ -66,7 +66,6 @@ const ViewIncidents = () => {\n</div>\n<div className=\"row\">\n<Table\n- tableClassName=\"table table-hover\"\ngetID={(row) => row.id}\ndata={incidents}\ncolumns={[\n"
},
{
"change_type": "MODIFY",
"old_path": "src/labs/ViewLabs.tsx",
"new_path": "src/labs/ViewLabs.tsx",
"diff": "@@ -104,7 +104,6 @@ const ViewLabs = () => {\n</div>\n<div className=\"row\">\n<Table\n- tableClassName=\"table table-hover\"\ngetID={(row) => row.id}\ncolumns={[\n{ label: t('labs.lab.code'), key: 'code' },\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/care-plans/CarePlanTable.tsx",
"new_path": "src/patients/care-plans/CarePlanTable.tsx",
"diff": "@@ -14,7 +14,6 @@ const CarePlanTable = () => {\nreturn (\n<Table\n- tableClassName=\"table table-hover\"\ngetID={(row) => row.id}\ndata={patient.carePlans || []}\ncolumns={[\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/labs/LabsTab.tsx",
"new_path": "src/patients/labs/LabsTab.tsx",
"diff": "@@ -38,7 +38,6 @@ const LabsTab = (props: Props) => {\n)}\n{labs && labs.length > 0 && (\n<Table\n- tableClassName=\"table table-hover\"\nactionsHeaderText={t('actions.label')}\ngetID={(row) => row.id}\ndata={labs}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/list/ViewPatients.tsx",
"new_path": "src/patients/list/ViewPatients.tsx",
"diff": "@@ -68,7 +68,6 @@ const ViewPatients = () => {\nconst loadingIndicator = <Spinner color=\"blue\" loading size={[10, 25]} type=\"ScaleLoader\" />\nconst table = (\n<Table\n- tableClassName=\"table table-hover\"\ndata={patients}\ngetID={(row) => row.id}\ncolumns={[\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/related-persons/RelatedPersonTab.tsx",
"new_path": "src/patients/related-persons/RelatedPersonTab.tsx",
"diff": "@@ -90,7 +90,6 @@ const RelatedPersonTab = (props: Props) => {\n{relatedPersons ? (\nrelatedPersons.length > 0 ? (\n<Table\n- tableClassName=\"table table-hover\"\ngetID={(row) => row.id}\ndata={relatedPersons}\ncolumns={[\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix: remove duplicate prop |
288,411 | 29.06.2020 21:44:17 | 14,400 | ccd98ce6004382c5ac75c4aa73e20a107890906c | Update Login.tsx
Update the React-Bootstrap Button component allowing users to click "Enter/Return" on the keyboard to send the login request. | [
{
"change_type": "MODIFY",
"old_path": "src/login/Login.tsx",
"new_path": "src/login/Login.tsx",
"diff": "@@ -77,7 +77,7 @@ const Login = () => {\nvalue={password}\nonChange={onPasswordChange}\n/>\n- <Button block onClick={onSignInClick}>\n+ <Button type=\"submit\" block onClick={onSignInClick}>\nSign In\n</Button>\n</Panel>\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | Update Login.tsx
Update the React-Bootstrap Button component allowing users to click "Enter/Return" on the keyboard to send the login request. |
288,323 | 30.06.2020 06:01:01 | 18,000 | 10057a8a8f9320bae8ae33529e974960974e52f2 | docs: add note about making hospitalrun a public database | [
{
"change_type": "MODIFY",
"old_path": ".github/CONTRIBUTING.md",
"new_path": ".github/CONTRIBUTING.md",
"diff": "@@ -36,13 +36,19 @@ The following directions will be for running CouchDB via Docker Compose.\nThis should launch a new CouchDB instance on `http://localhost:5984`, create system database, configure CouchDB as Single Node, enable CORS, create `hospitalrun` database, create a default admin with a username of `admin` and password of 'password'\n-4. Create a sample user with a username of `username` and password of 'password' to use new login page [#2137](https://github.com/HospitalRun/hospitalrun-frontend/pull/2137)\n+4. Make the `hospitalrun` database a public database by removing its member permissions:\n+\n+ ```\n+ curl -X PUT http://admin:password@localhost:5984/hospitalrun/_security -d '{\"members\": {}, \"admins\": {\"roles\": [\"_admin\"] }}'\n+ ```\n+\n+5. Create a sample user with a username of `username` and password of 'password' to use new login page [#2137](https://github.com/HospitalRun/hospitalrun-frontend/pull/2137)\n```\ncurl -X PUT http://admin:password@localhost:5984/_users/org.couchdb.user:username -H \"Accept: application/json\" -H \"Content-Type: application/json\" -d '{\"name\": \"username\", \"password\": \"password\", \"metadata\": { \"givenName\": \"John\", \"familyName\": \"Doe\"}, \"roles\": [], \"type\": \"user\"}'\n```\n-5. Launch `http://localhost:5984/_utils` to view Fauxton and perform administrative tasks.\n+6. Launch `http://localhost:5984/_utils` to view Fauxton and perform administrative tasks.\n**_Cleanup_**\nTo delete the development database, go to the root of the project and run `docker-compose down -v --rmi all --remove-orphans`\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | docs: add note about making hospitalrun a public database |
288,295 | 06.07.2020 16:42:51 | -18,000 | 7fa152bd2367884941e615f02073c0e1f66a4f56 | feat(incidents, scheduling, other): add russian locale | [
{
"change_type": "MODIFY",
"old_path": "src/shared/locales/ru/translations/index.ts",
"new_path": "src/shared/locales/ru/translations/index.ts",
"diff": "import actions from './actions'\nimport dashboard from './dashboard'\n+import incidents from './incidents'\nimport labs from './labs'\n+import networkStatus from './network-status'\nimport patient from './patient'\nimport patients from './patients'\n+import scheduling from './scheduling'\nimport settings from './settings'\n+import sex from './sex'\n+import states from './states'\nexport default {\n...actions,\n...dashboard,\n+ ...sex,\n+ ...incidents,\n+ ...networkStatus,\n...labs,\n+ ...states,\n+ ...scheduling,\n...patient,\n...patients,\n...settings,\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(incidents, scheduling, other): add russian locale |
288,295 | 06.07.2020 17:49:05 | -18,000 | 24b73bcad48ea1eed7d9ac7b30d81491f6d8a1d6 | fix: prevent app route always changes to root after refresh | [
{
"change_type": "MODIFY",
"old_path": "src/App.tsx",
"new_path": "src/App.tsx",
"diff": "import { Spinner } from '@hospitalrun/components'\n-import React, { Suspense } from 'react'\n-import { Provider } from 'react-redux'\n+import React, { Suspense, useEffect, useState } from 'react'\n+import { useDispatch } from 'react-redux'\nimport { BrowserRouter, Route, Switch } from 'react-router-dom'\nimport HospitalRun from './HospitalRun'\nimport Login from './login/Login'\n-import store from './shared/store'\n+import { remoteDb } from './shared/config/pouchdb'\n+import { getCurrentSession } from './user/user-slice'\n-const App: React.FC = () => (\n- <div>\n- <Provider store={store}>\n+const App: React.FC = () => {\n+ const dispatch = useDispatch()\n+ const [loading, setLoading] = useState(true)\n+\n+ useEffect(() => {\n+ const init = async () => {\n+ try {\n+ const session = await remoteDb.getSession()\n+ if (session.userCtx.name) {\n+ await dispatch(getCurrentSession(session.userCtx.name))\n+ }\n+ } catch (e) {\n+ console.log(e)\n+ }\n+ setLoading(false)\n+ }\n+\n+ init()\n+ }, [dispatch])\n+\n+ if (loading) {\n+ return null\n+ }\n+\n+ return (\n<BrowserRouter>\n<Suspense fallback={<Spinner color=\"blue\" loading size={[10, 25]} type=\"ScaleLoader\" />}>\n<Switch>\n@@ -18,8 +41,7 @@ const App: React.FC = () => (\n</Switch>\n</Suspense>\n</BrowserRouter>\n- </Provider>\n- </div>\n)\n+}\nexport default App\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/App.test.tsx",
"new_path": "src/__tests__/App.test.tsx",
"diff": "import { shallow } from 'enzyme'\nimport React from 'react'\n+import { Provider } from 'react-redux'\n+import configureStore from 'redux-mock-store'\nimport App from '../App'\nit('renders without crashing', () => {\n- const wrapper = shallow(<App />)\n+ const mockStore = configureStore()({})\n+\n+ const AppWithStore = () => (\n+ <Provider store={mockStore}>\n+ <App />\n+ </Provider>\n+ )\n+\n+ const wrapper = shallow(<AppWithStore />)\nexpect(wrapper).toBeDefined()\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/index.tsx",
"new_path": "src/index.tsx",
"diff": "import React from 'react'\nimport ReactDOM from 'react-dom'\n-\n+import { Provider } from 'react-redux'\nimport '@hospitalrun/components/scss/main.scss'\n+\nimport './index.css'\nimport App from './App'\nimport * as serviceWorker from './serviceWorker'\n-\nimport './shared/config/i18n'\n+import store from './shared/store'\n-ReactDOM.render(<App />, document.getElementById('root'))\n+ReactDOM.render(\n+ <Provider store={store}>\n+ <App />\n+ </Provider>,\n+ document.getElementById('root'),\n+)\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n"
},
{
"change_type": "MODIFY",
"old_path": "src/login/Login.tsx",
"new_path": "src/login/Login.tsx",
"diff": "import { Alert, Container, Panel } from '@hospitalrun/components'\n-import React, { useEffect, useState } from 'react'\n+import React, { useState } from 'react'\nimport Button from 'react-bootstrap/Button'\nimport { useDispatch, useSelector } from 'react-redux'\nimport { Redirect } from 'react-router-dom'\nimport TextInputWithLabelFormGroup from '../shared/components/input/TextInputWithLabelFormGroup'\n-import { remoteDb } from '../shared/config/pouchdb'\nimport logo from '../shared/static/images/logo-on-transparent.png'\nimport { RootState } from '../shared/store'\n-import { getCurrentSession, login } from '../user/user-slice'\n+import { login } from '../user/user-slice'\nconst Login = () => {\nconst dispatch = useDispatch()\nconst [username, setUsername] = useState('')\nconst [password, setPassword] = useState('')\nconst { loginError, user } = useSelector((root: RootState) => root.user)\n- const [loading, setLoading] = useState(true)\n-\n- useEffect(() => {\n- const init = async () => {\n- try {\n- const session = await remoteDb.getSession()\n- if (session.userCtx.name) {\n- await dispatch(getCurrentSession(session.userCtx.name))\n- }\n- } catch (e) {\n- console.log(e)\n- }\n- setLoading(false)\n- }\n-\n- init()\n- }, [dispatch])\nconst onUsernameChange = (event: React.ChangeEvent<HTMLInputElement>) => {\nconst { value } = event.currentTarget\n@@ -47,16 +29,11 @@ const Login = () => {\nawait dispatch(login(username, password))\n}\n- if (loading) {\n- return null\n- }\n-\nif (user) {\nreturn <Redirect to=\"/\" />\n}\nreturn (\n- <>\n<Container className=\"container align-items-center\" style={{ width: '50%' }}>\n<img src={logo} alt=\"HospitalRun\" style={{ width: '100%', textAlign: 'center' }} />\n<form>\n@@ -83,7 +60,6 @@ const Login = () => {\n</Panel>\n</form>\n</Container>\n- </>\n)\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix: prevent app route always changes to root after refresh |
288,256 | 07.07.2020 06:54:02 | -19,080 | 01e834301e318553c3c49768c5af5f5c72a40d0b | feat: Added blood type info to patient | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/GeneralInformation.test.tsx",
"new_path": "src/__tests__/patients/GeneralInformation.test.tsx",
"diff": "@@ -67,6 +67,7 @@ describe('General Information, without isEditable', () => {\nsuffix: 'suffix',\nsex: 'male',\ntype: 'charity',\n+ bloodType: 'A-',\ndateOfBirth: startOfDay(subYears(new Date(), 30)).toISOString(),\nisApproximateDateOfBirth: false,\noccupation: 'occupation',\n@@ -141,6 +142,32 @@ describe('General Information, without isEditable', () => {\nexpect(sexSelect.prop('options')[3].value).toEqual('unknown')\n})\n+ it('should render the blood type', () => {\n+ const bloodTypeSelect = wrapper.findWhere((w: any) => w.prop('name') === 'bloodType')\n+ expect(bloodTypeSelect.prop('defaultSelected')[0].value).toEqual(patient.bloodType)\n+ expect(bloodTypeSelect.prop('label')).toEqual('patient.bloodType')\n+ expect(bloodTypeSelect.prop('isEditable')).toBeFalsy()\n+ expect(bloodTypeSelect.prop('options')).toHaveLength(9)\n+ expect(bloodTypeSelect.prop('options')[0].label).toEqual('bloodType.apositive')\n+ expect(bloodTypeSelect.prop('options')[0].value).toEqual('A+')\n+ expect(bloodTypeSelect.prop('options')[1].label).toEqual('bloodType.anegative')\n+ expect(bloodTypeSelect.prop('options')[1].value).toEqual('A-')\n+ expect(bloodTypeSelect.prop('options')[2].label).toEqual('bloodType.abpositive')\n+ expect(bloodTypeSelect.prop('options')[2].value).toEqual('AB+')\n+ expect(bloodTypeSelect.prop('options')[3].label).toEqual('bloodType.abnegative')\n+ expect(bloodTypeSelect.prop('options')[3].value).toEqual('AB-')\n+ expect(bloodTypeSelect.prop('options')[4].label).toEqual('bloodType.bpositive')\n+ expect(bloodTypeSelect.prop('options')[4].value).toEqual('B+')\n+ expect(bloodTypeSelect.prop('options')[5].label).toEqual('bloodType.bnegative')\n+ expect(bloodTypeSelect.prop('options')[5].value).toEqual('B-')\n+ expect(bloodTypeSelect.prop('options')[6].label).toEqual('bloodType.opositive')\n+ expect(bloodTypeSelect.prop('options')[6].value).toEqual('O+')\n+ expect(bloodTypeSelect.prop('options')[7].label).toEqual('bloodType.onegative')\n+ expect(bloodTypeSelect.prop('options')[7].value).toEqual('O-')\n+ expect(bloodTypeSelect.prop('options')[8].label).toEqual('bloodType.unknown')\n+ expect(bloodTypeSelect.prop('options')[8].value).toEqual('unknown')\n+ })\n+\nit('should render the patient type select', () => {\nconst typeSelect = wrapper.findWhere((w: any) => w.prop('name') === 'type')\nexpect(typeSelect.prop('defaultSelected')[0].value).toEqual(patient.type)\n@@ -230,6 +257,7 @@ describe('General Information, isEditable', () => {\nfamilyName: 'familyName',\nsuffix: 'suffix',\nsex: 'male',\n+ bloodType: 'A-',\ntype: 'charity',\ndateOfBirth: startOfDay(subYears(new Date(), 30)).toISOString(),\nisApproximateDateOfBirth: false,\n@@ -281,6 +309,7 @@ describe('General Information, isEditable', () => {\n{ value: 'address C', type: undefined, id: '654' },\n{ value: 'address D', type: undefined, id: '321' },\n]\n+ const expectedBloodType = 'unknown'\nit('should render the prefix', () => {\nconst prefixInput = wrapper.findWhere((w: any) => w.prop('name') === 'prefix')\n@@ -360,6 +389,40 @@ describe('General Information, isEditable', () => {\nexpect(sexSelect.prop('options')[3].value).toEqual('unknown')\n})\n+ it('should render the blood type select', () => {\n+ const bloodTypeSelect = wrapper.findWhere((w: any) => w.prop('name') === 'bloodType')\n+ expect(bloodTypeSelect.prop('defaultSelected')[0].value).toEqual(patient.bloodType)\n+ expect(bloodTypeSelect.prop('label')).toEqual('patient.bloodType')\n+ expect(bloodTypeSelect.prop('isEditable')).toBeTruthy()\n+ expect(bloodTypeSelect.prop('options')).toHaveLength(9)\n+ expect(bloodTypeSelect.prop('options')[0].label).toEqual('bloodType.apositive')\n+ expect(bloodTypeSelect.prop('options')[0].value).toEqual('A+')\n+ expect(bloodTypeSelect.prop('options')[1].label).toEqual('bloodType.anegative')\n+ expect(bloodTypeSelect.prop('options')[1].value).toEqual('A-')\n+ expect(bloodTypeSelect.prop('options')[2].label).toEqual('bloodType.abpositive')\n+ expect(bloodTypeSelect.prop('options')[2].value).toEqual('AB+')\n+ expect(bloodTypeSelect.prop('options')[3].label).toEqual('bloodType.abnegative')\n+ expect(bloodTypeSelect.prop('options')[3].value).toEqual('AB-')\n+ expect(bloodTypeSelect.prop('options')[4].label).toEqual('bloodType.bpositive')\n+ expect(bloodTypeSelect.prop('options')[4].value).toEqual('B+')\n+ expect(bloodTypeSelect.prop('options')[5].label).toEqual('bloodType.bnegative')\n+ expect(bloodTypeSelect.prop('options')[5].value).toEqual('B-')\n+ expect(bloodTypeSelect.prop('options')[6].label).toEqual('bloodType.opositive')\n+ expect(bloodTypeSelect.prop('options')[6].value).toEqual('O+')\n+ expect(bloodTypeSelect.prop('options')[7].label).toEqual('bloodType.onegative')\n+ expect(bloodTypeSelect.prop('options')[7].value).toEqual('O-')\n+ expect(bloodTypeSelect.prop('options')[8].label).toEqual('bloodType.unknown')\n+ expect(bloodTypeSelect.prop('options')[8].value).toEqual('unknown')\n+ act(() => {\n+ bloodTypeSelect.prop('onChange')([expectedBloodType])\n+ })\n+ expect(onFieldChange).toHaveBeenCalledTimes(1)\n+ expect(onFieldChange).toHaveBeenCalledWith({\n+ ...patient,\n+ bloodType: expectedBloodType,\n+ })\n+ })\n+\nit('should render the patient type select', () => {\nconst typeSelect = wrapper.findWhere((w: any) => w.prop('name') === 'type')\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/GeneralInformation.tsx",
"new_path": "src/patients/GeneralInformation.tsx",
"diff": "@@ -73,6 +73,18 @@ const GeneralInformation = (props: Props): ReactElement => {\n{ label: t('patient.types.private'), value: 'private' },\n]\n+ const bloodTypeOptions: Option[] = [\n+ { label: t('bloodType.apositive'), value: 'A+' },\n+ { label: t('bloodType.anegative'), value: 'A-' },\n+ { label: t('bloodType.abpositive'), value: 'AB+' },\n+ { label: t('bloodType.abnegative'), value: 'AB-' },\n+ { label: t('bloodType.bpositive'), value: 'B+' },\n+ { label: t('bloodType.bnegative'), value: 'B-' },\n+ { label: t('bloodType.opositive'), value: 'O+' },\n+ { label: t('bloodType.onegative'), value: 'O-' },\n+ { label: t('bloodType.unknown'), value: 'unknown' },\n+ ]\n+\nreturn (\n<div>\n<Panel title={t('patient.basicInformation')} color=\"primary\" collapsible>\n@@ -145,6 +157,16 @@ const GeneralInformation = (props: Props): ReactElement => {\nisEditable={isEditable}\n/>\n</div>\n+ <div className=\"col\">\n+ <SelectWithLabelFormGroup\n+ name=\"bloodType\"\n+ label={t('patient.bloodType')}\n+ options={bloodTypeOptions}\n+ defaultSelected={bloodTypeOptions.filter(({ value }) => value === patient.bloodType)}\n+ onChange={(values) => onFieldChange('bloodType', values[0])}\n+ isEditable={isEditable}\n+ />\n+ </div>\n</div>\n<div className=\"row\">\n<div className=\"col\">\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/shared/locales/enUs/translations/blood-type/index.ts",
"diff": "+export default {\n+ bloodType: {\n+ apositive: 'A+',\n+ anegative: 'A-',\n+ abpositive: 'AB+',\n+ abnegative: 'AB-',\n+ bpositive: 'B+',\n+ bnegative: 'B-',\n+ opositive: 'O+',\n+ onegative: 'O-',\n+ unknown: 'Unknown',\n+ },\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/locales/enUs/translations/index.ts",
"new_path": "src/shared/locales/enUs/translations/index.ts",
"diff": "import actions from './actions'\n+import bloodType from './blood-type'\nimport dashboard from './dashboard'\nimport incidents from './incidents'\nimport labs from './labs'\n@@ -22,4 +23,5 @@ export default {\n...labs,\n...incidents,\n...settings,\n+ ...bloodType,\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/locales/enUs/translations/patient/index.ts",
"new_path": "src/shared/locales/enUs/translations/patient/index.ts",
"diff": "@@ -13,6 +13,7 @@ export default {\napproximateAge: 'Approximate Age',\nplaceOfBirth: 'Place of Birth',\nsex: 'Sex',\n+ bloodType: 'Blood Type',\ncontactInfoType: {\nlabel: 'Type',\noptions: {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/model/Patient.ts",
"new_path": "src/shared/model/Patient.ts",
"diff": "@@ -21,4 +21,5 @@ export default interface Patient extends AbstractDBModel, Name, ContactInformati\nnotes?: Note[]\nindex: string\ncarePlans: CarePlan[]\n+ bloodType: string\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat: Added blood type info to patient (#2190) |
288,295 | 07.07.2020 06:40:32 | -18,000 | 573df570bc0c8effd45fe232002a47367dcb8076 | fix: update hardcoded text with i18n locales | [
{
"change_type": "MODIFY",
"old_path": "src/labs/ViewLabs.tsx",
"new_path": "src/labs/ViewLabs.tsx",
"diff": "@@ -94,8 +94,8 @@ const ViewLabs = () => {\n<div className=\"col\">\n<TextInputWithLabelFormGroup\nname=\"searchbox\"\n- label=\"Search Labs\"\n- placeholder=\"Search labs by type\"\n+ label={t('labs.search')}\n+ placeholder={t('labs.search')}\nvalue={searchText}\nisEditable\nonChange={onSearchBoxChange}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix: update hardcoded text with i18n locales (#2203) |
288,316 | 08.07.2020 04:03:35 | -7,200 | 028daff0648d7758984b04960f24e8bf20002ea4 | fix(login): improved login validation | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/user/user-slice.test.ts",
"new_path": "src/__tests__/user/user-slice.test.ts",
"diff": "@@ -98,7 +98,7 @@ describe('user slice', () => {\n})\nit('should dispatch login error if login was not successful', async () => {\n- jest.spyOn(remoteDb, 'logIn').mockRejectedValue({ status: '401' })\n+ jest.spyOn(remoteDb, 'logIn').mockRejectedValue({ status: 401 })\njest.spyOn(remoteDb, 'getUser').mockResolvedValue({\n_id: 'userId',\nmetadata: {\n@@ -113,7 +113,7 @@ describe('user slice', () => {\nexpect(remoteDb.getUser).not.toHaveBeenCalled()\nexpect(store.getActions()[0]).toEqual({\ntype: loginError.type,\n- payload: 'user.login.error',\n+ payload: { message: 'user.login.error.message.incorrect' },\n})\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/login/Login.tsx",
"new_path": "src/login/Login.tsx",
"diff": "@@ -6,12 +6,14 @@ import { Redirect } from 'react-router-dom'\nimport TextInputWithLabelFormGroup from '../shared/components/input/TextInputWithLabelFormGroup'\nimport { remoteDb } from '../shared/config/pouchdb'\n+import useTranslator from '../shared/hooks/useTranslator'\nimport logo from '../shared/static/images/logo-on-transparent.png'\nimport { RootState } from '../shared/store'\nimport { getCurrentSession, login } from '../user/user-slice'\nconst Login = () => {\nconst dispatch = useDispatch()\n+ const { t } = useTranslator()\nconst [username, setUsername] = useState('')\nconst [password, setPassword] = useState('')\nconst { loginError, user } = useSelector((root: RootState) => root.user)\n@@ -61,13 +63,18 @@ const Login = () => {\n<img src={logo} alt=\"HospitalRun\" style={{ width: '100%', textAlign: 'center' }} />\n<form>\n<Panel title=\"Please Sign In\" color=\"primary\">\n- {loginError && <Alert color=\"danger\" message={loginError} title=\"Unable to login\" />}\n+ {loginError?.message && (\n+ <Alert color=\"danger\" message={t(loginError?.message)} title=\"Unable to login\" />\n+ )}\n<TextInputWithLabelFormGroup\nisEditable\nlabel=\"username\"\nname=\"username\"\nvalue={username}\nonChange={onUsernameChange}\n+ isRequired\n+ isInvalid={!!loginError?.username && !username}\n+ feedback={t(loginError?.username)}\n/>\n<TextInputWithLabelFormGroup\nisEditable\n@@ -76,6 +83,9 @@ const Login = () => {\nname=\"password\"\nvalue={password}\nonChange={onPasswordChange}\n+ isRequired\n+ isInvalid={!!loginError?.password && !password}\n+ feedback={t(loginError?.password)}\n/>\n<Button block onClick={onSignInClick}>\nSign In\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/locales/enUs/translations/index.ts",
"new_path": "src/shared/locales/enUs/translations/index.ts",
"diff": "@@ -10,6 +10,7 @@ import scheduling from './scheduling'\nimport settings from './settings'\nimport sex from './sex'\nimport states from './states'\n+import user from './user'\nexport default {\n...actions,\n@@ -23,5 +24,6 @@ export default {\n...labs,\n...incidents,\n...settings,\n+ ...user,\n...bloodType,\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/shared/locales/enUs/translations/user/index.ts",
"diff": "+export default {\n+ user: {\n+ login: {\n+ error: {\n+ message: {\n+ required: 'Missing required fields.',\n+ incorrect: 'Incorrect username or password.',\n+ },\n+ username: {\n+ required: 'Username is required.',\n+ },\n+ password: {\n+ required: 'Password is required.',\n+ },\n+ },\n+ },\n+ },\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/user/user-slice.ts",
"new_path": "src/user/user-slice.ts",
"diff": "@@ -6,10 +6,16 @@ import Permissions from '../shared/model/Permissions'\nimport User from '../shared/model/User'\nimport { AppThunk } from '../shared/store'\n+interface LoginError {\n+ message?: string\n+ username?: string\n+ password?: string\n+}\n+\ninterface UserState {\npermissions: (Permissions | null)[]\nuser?: User\n- loginError?: string\n+ loginError?: LoginError\n}\nconst initialState: UserState = {\n@@ -48,7 +54,7 @@ const userSlice = createSlice({\nstate.user = payload.user\nstate.permissions = initialState.permissions\n},\n- loginError(state, { payload }: PayloadAction<string>) {\n+ loginError(state, { payload }: PayloadAction<LoginError>) {\nstate.loginError = payload\n},\nlogoutSuccess(state) {\n@@ -89,8 +95,20 @@ export const login = (username: string, password: string): AppThunk => async (di\n}),\n)\n} catch (error) {\n- if (error.status === '401') {\n- dispatch(loginError('user.login.error'))\n+ if (!username || !password) {\n+ dispatch(\n+ loginError({\n+ message: 'user.login.error.message.required',\n+ username: 'user.login.error.username.required',\n+ password: 'user.login.error.password.required',\n+ }),\n+ )\n+ } else if (error.status === 401) {\n+ dispatch(\n+ loginError({\n+ message: 'user.login.error.message.incorrect',\n+ }),\n+ )\n}\n}\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(login): improved login validation
Co-authored-by: Jack Meyer <[email protected]> |
288,327 | 09.07.2020 02:57:55 | -19,080 | ebdaef5b8d44d8723c70d6b633c78c3bad612357 | fix(bug) add the translation key for 'logout' | [
{
"change_type": "MODIFY",
"old_path": "src/shared/components/navbar/Navbar.tsx",
"new_path": "src/shared/components/navbar/Navbar.tsx",
"diff": "@@ -107,7 +107,7 @@ const Navbar = () => {\n},\n{\ntype: 'link',\n- label: t('logout'),\n+ label: t('actions.logout'),\nonClick: () => {\ndispatch(logout())\nnavigateTo('/login')\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/locales/enUs/translations/actions/index.ts",
"new_path": "src/shared/locales/enUs/translations/actions/index.ts",
"diff": "@@ -16,5 +16,6 @@ export default {\npage: 'Page',\nadd: 'Add',\nview: 'View',\n+ logout: 'logout',\n},\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(bug) add the translation key for 'logout' (#2212) |
288,267 | 09.07.2020 03:15:19 | -7,200 | babc7e3e817ecb20b5a2cf7b3afde99182740b4b | fix(patients): fixes related person search crashing if no DoB | [
{
"change_type": "MODIFY",
"old_path": "src/patients/related-persons/AddRelatedPersonModal.tsx",
"new_path": "src/patients/related-persons/AddRelatedPersonModal.tsx",
"diff": "@@ -48,6 +48,8 @@ const AddRelatedPersonModal = (props: Props) => {\nreturn patients.filter((p: Patient) => p.id !== patient.id)\n}\n+ const formattedDate = (date: string) => (date ? format(new Date(date), 'yyyy-MM-dd') : '')\n+\nconst body = (\n<form>\n{relatedPersonError?.message && (\n@@ -65,9 +67,7 @@ const AddRelatedPersonModal = (props: Props) => {\nisInvalid={!!relatedPersonError?.relatedPerson}\nonSearch={onSearch}\nrenderMenuItemChildren={(p: Patient) => (\n- <div>\n- {`${p.fullName} - ${format(new Date(p.dateOfBirth), 'yyyy-MM-dd')} (${p.code})`}\n- </div>\n+ <div>{`${p.fullName} - ${formattedDate(p.dateOfBirth)} (${p.code})`}</div>\n)}\n/>\n{relatedPersonError?.relatedPerson && (\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/hooks/useTranslator.ts",
"new_path": "src/shared/hooks/useTranslator.ts",
"diff": "@@ -4,12 +4,7 @@ import { useTranslation } from 'react-i18next'\nexport default function useTranslator() {\nconst { t } = useTranslation()\n- const translate = useCallback(\n- (key: any): any => {\n- return key !== undefined ? t(key) : undefined\n- },\n- [t],\n- )\n+ const translate = useCallback((key: any): any => (key !== undefined ? t(key) : undefined), [t])\nreturn {\nt: translate,\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(patients): fixes related person search crashing if no DoB |
288,295 | 09.07.2020 17:50:23 | -18,000 | 14ef415334354bd61475ead9469b8579dde8bf6c | fix: weird spacing issue in quick add icon | [
{
"change_type": "MODIFY",
"old_path": "src/shared/components/navbar/Navbar.tsx",
"new_path": "src/shared/components/navbar/Navbar.tsx",
"diff": "@@ -19,7 +19,6 @@ const Navbar = () => {\n}\nconst dividerAboveLabels = [\n- 'patients.newPatient',\n'scheduling.appointments.new',\n'labs.requests.new',\n'incidents.reports.new',\n@@ -35,7 +34,7 @@ const Navbar = () => {\nonClick: () => {\nnavigateTo(page.path)\n},\n- dividerAbove: dividerAboveLabels.indexOf(page.label) > -1,\n+ dividerAbove: dividerAboveLabels.includes(page.label),\n}))\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix: weird spacing issue in quick add icon |
288,294 | 09.07.2020 19:14:47 | 14,400 | 7e0aba7d1a3fe14db48f55e6250cfbca75ed7ad8 | feat(navbar): add icons to 'quick add' icon in navbar | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/shared/components/navbar/Navbar.test.tsx",
"new_path": "src/__tests__/shared/components/navbar/Navbar.test.tsx",
"diff": "@@ -59,9 +59,16 @@ describe('Navbar', () => {\nconst hamberger = hospitalRunNavbar.find('.nav-hamberger')\nconst { children } = hamberger.first().props() as any\n- expect(children[0].props.children).toEqual([undefined, 'dashboard.label'])\n- expect(children[1].props.children).toEqual([undefined, 'patients.newPatient'])\n- expect(children[children.length - 1].props.children).toEqual([undefined, 'settings.label'])\n+ const [dashboardIcon, dashboardLabel] = children[0].props.children\n+ const [newPatientIcon, newPatientLabel] = children[1].props.children\n+ const [settingsIcon, settingsLabel] = children[children.length - 1].props.children\n+\n+ expect(dashboardIcon.props.icon).toEqual('dashboard')\n+ expect(dashboardLabel).toEqual('dashboard.label')\n+ expect(newPatientIcon.props.icon).toEqual('patient-add')\n+ expect(newPatientLabel).toEqual('patients.newPatient')\n+ expect(settingsIcon.props.icon).toEqual('setting')\n+ expect(settingsLabel).toEqual('settings.label')\n})\nit('should not show an item if user does not have a permission', () => {\n@@ -142,7 +149,10 @@ describe('Navbar', () => {\nconst addNew = hospitalRunNavbar.find('.nav-add-new')\nconst { children } = addNew.first().props() as any\n- expect(children[0].props.children).toEqual([undefined, 'patients.newPatient'])\n+ const [icon, label] = children[0].props.children\n+\n+ expect(icon.props.icon).toEqual('patient-add')\n+ expect(label).toEqual('patients.newPatient')\n})\nit('should not show a shortcut if user does not have a permission', () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/components/navbar/Navbar.tsx",
"new_path": "src/shared/components/navbar/Navbar.tsx",
"diff": "@@ -31,6 +31,7 @@ const Navbar = () => {\n.map((page) => ({\ntype: 'link',\nlabel: t(page.label),\n+ icon: `${page.icon}`,\nonClick: () => {\nnavigateTo(page.path)\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/components/navbar/pageMap.tsx",
"new_path": "src/shared/components/navbar/pageMap.tsx",
"diff": "import Permissions from '../../model/Permissions'\n-type Page = { permission: Permissions | null; label: string; path: string }\n+type Page = { permission: Permissions | null; label: string; path: string; icon: string }\nconst pageMap: {\n[key: string]: Page\n@@ -9,51 +9,61 @@ const pageMap: {\npermission: null,\nlabel: 'dashboard.label',\npath: '/',\n+ icon: 'dashboard',\n},\nnewPatient: {\npermission: Permissions.WritePatients,\nlabel: 'patients.newPatient',\npath: '/patients/new',\n+ icon: 'patient-add',\n},\nviewPatients: {\npermission: Permissions.ReadPatients,\nlabel: 'patients.patientsList',\npath: '/patients',\n+ icon: 'patients',\n},\nnewAppointment: {\npermission: Permissions.WriteAppointments,\nlabel: 'scheduling.appointments.new',\npath: '/appointments/new',\n+ icon: 'appointment-add',\n},\nviewAppointments: {\npermission: Permissions.ReadAppointments,\nlabel: 'scheduling.appointments.schedule',\npath: '/appointments',\n+ icon: 'appointment',\n},\nnewLab: {\npermission: Permissions.RequestLab,\nlabel: 'labs.requests.new',\npath: '/labs/new',\n+ icon: 'add',\n},\nviewLabs: {\npermission: Permissions.ViewLabs,\nlabel: 'labs.requests.label',\npath: '/labs',\n+ icon: 'lab',\n},\nnewIncident: {\npermission: Permissions.ReportIncident,\nlabel: 'incidents.reports.new',\npath: '/incidents/new',\n+ icon: 'add',\n},\nviewIncidents: {\npermission: Permissions.ViewIncidents,\nlabel: 'incidents.reports.label',\npath: '/incidents',\n+ icon: 'incident',\n},\nsettings: {\npermission: null,\nlabel: 'settings.label',\npath: '/settings',\n+ icon: 'setting',\n},\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(navbar): add icons to 'quick add' icon in navbar (#2220) |
288,323 | 10.07.2020 23:32:05 | 18,000 | d72c4e99cf032eb37e354cdb15abef0a694c38a9 | fix(login): fixes broken login | [
{
"change_type": "MODIFY",
"old_path": "src/login/Login.tsx",
"new_path": "src/login/Login.tsx",
"diff": "@@ -45,7 +45,8 @@ const Login = () => {\nsetPassword(value)\n}\n- const onSignInClick = async () => {\n+ const onSignInClick = async (event: React.MouseEvent<HTMLButtonElement>) => {\n+ event.preventDefault()\nawait dispatch(login(username, password))\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(login): fixes broken login |
288,327 | 11.07.2020 10:16:52 | -19,080 | ce1642406e0015ce7c51a182d9db6011ad4aefc3 | feat(patient): put "Unknow" next to date of brith field | [
{
"change_type": "MODIFY",
"old_path": "src/patients/GeneralInformation.tsx",
"new_path": "src/patients/GeneralInformation.tsx",
"diff": "@@ -169,7 +169,7 @@ const GeneralInformation = (props: Props): ReactElement => {\n</div>\n</div>\n<div className=\"row\">\n- <div className=\"col\">\n+ <div className=\"col-md-3\">\n{patient.isApproximateDateOfBirth ? (\n<TextInputWithLabelFormGroup\nlabel={t('patient.approximateAge')}\n@@ -195,8 +195,6 @@ const GeneralInformation = (props: Props): ReactElement => {\nfeedback={t(error?.dateOfBirth)}\n/>\n)}\n- </div>\n- <div className=\"col\">\n<div className=\"form-group\">\n<Checkbox\nlabel={t('patient.unknownDateOfBirth')}\n@@ -206,9 +204,7 @@ const GeneralInformation = (props: Props): ReactElement => {\n/>\n</div>\n</div>\n- </div>\n- <div className=\"row\">\n- <div className=\"col-md-6\">\n+ <div className=\"col\">\n<TextInputWithLabelFormGroup\nlabel={t('patient.occupation')}\nname=\"occupation\"\n@@ -217,7 +213,7 @@ const GeneralInformation = (props: Props): ReactElement => {\nonChange={(event) => onFieldChange('occupation', event.currentTarget.value)}\n/>\n</div>\n- <div className=\"col-md-6\">\n+ <div className=\"col\">\n<TextInputWithLabelFormGroup\nlabel={t('patient.preferredLanguage')}\nname=\"preferredLanguage\"\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(patient): put "Unknow" next to date of brith field (#2217) |
288,322 | 11.07.2020 09:55:19 | -3,600 | 1bf7b48d99f10dffd36fb5e4297dad670f35047a | build: add curl command to create a new DB user in the docker-compose
In the docker-compose file, add a fourth curl command to create a new DB user
2148 | [
{
"change_type": "MODIFY",
"old_path": "docker-compose.yml",
"new_path": "docker-compose.yml",
"diff": "@@ -21,4 +21,6 @@ services:\n\"sleep 5s &&\ncurl -X PUT http://admin:password@couchdb:5984/_global_changes &&\ncurl -X PUT http://admin:password@couchdb:5984/_users/_security -d '{}' &&\n- curl -X PUT http://admin:password@couchdb:5984/hospitalrun?partitioned=false\"\n+ curl -X PUT http://admin:password@couchdb:5984/hospitalrun?partitioned=false &&\n+ curl -X PUT http://admin:password@couchdb:5984/_users/org.couchdb.user:username -H \\\"Accept: application/json\\\" -H \\\"Content-Type: application/json\\\" -d '{\\\"name\\\": \\\"username\\\", \\\"password\\\": \\\"password\\\", \\\"metadata\\\": { \\\"givenName\\\": \\\"John\\\", \\\"familyName\\\": \\\"Doe\\\"}, \\\"roles\\\": [], \\\"type\\\": \\\"user\\\"}'\"\n+\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | build: add curl command to create a new DB user in the docker-compose
In the docker-compose file, add a fourth curl command to create a new DB user
2148 |
288,267 | 12.07.2020 03:01:01 | -7,200 | 5e95a9ccf15d094174be817ce2d18f70cb13a485 | feat(incidents): add ability to resolve incidents | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/incidents/incident-slice.test.ts",
"new_path": "src/__tests__/incidents/incident-slice.test.ts",
"diff": "@@ -12,6 +12,9 @@ import incident, {\nfetchIncidentStart,\nfetchIncidentSuccess,\nfetchIncident,\n+ resolveIncident,\n+ resolveIncidentStart,\n+ resolveIncidentSuccess,\n} from '../../incidents/incident-slice'\nimport IncidentRepository from '../../shared/db/IncidentRepository'\nimport Incident from '../../shared/model/Incident'\n@@ -70,6 +73,11 @@ describe('incident slice', () => {\nexpect(incidentStore.status).toEqual('loading')\n})\n+ it('should handle resolve incident start', () => {\n+ const incidentStore = incident(undefined, resolveIncidentStart())\n+ expect(incidentStore.status).toEqual('loading')\n+ })\n+\nit('should handle fetch incident success', () => {\nconst expectedIncident = {\nid: '1234',\n@@ -80,6 +88,18 @@ describe('incident slice', () => {\nexpect(incidentStore.status).toEqual('completed')\nexpect(incidentStore.incident).toEqual(expectedIncident)\n})\n+\n+ it('should handle resolve incident success', () => {\n+ const expectedIncident = {\n+ id: '1234',\n+ resolvedOn: new Date(Date.now()).toISOString(),\n+ status: 'resolved',\n+ } as Incident\n+\n+ const incidentStore = incident(undefined, resolveIncidentSuccess(expectedIncident))\n+ expect(incidentStore.status).toEqual('completed')\n+ expect(incidentStore.incident).toEqual(expectedIncident)\n+ })\n})\ndescribe('report incident', () => {\n@@ -202,4 +222,48 @@ describe('incident slice', () => {\nexpect(store.getActions()[1]).toEqual(fetchIncidentSuccess(expectedIncident))\n})\n})\n+\n+ describe('resolve incident', () => {\n+ const expectedDate = new Date()\n+ const mockIncident = {\n+ id: '123',\n+ description: 'description',\n+ date: expectedDate.toISOString(),\n+ department: 'some department',\n+ category: 'category',\n+ categoryItem: 'categoryItem',\n+ status: 'reported',\n+ } as Incident\n+ const expectedResolvedIncident = {\n+ ...mockIncident,\n+ resolvedOn: expectedDate.toISOString(),\n+ status: 'resolved',\n+ } as Incident\n+ let incidentRepositorySaveOrUpdateSpy: any\n+\n+ beforeEach(() => {\n+ Date.now = jest.fn().mockReturnValue(expectedDate.valueOf())\n+ incidentRepositorySaveOrUpdateSpy = jest\n+ .spyOn(IncidentRepository, 'saveOrUpdate')\n+ .mockResolvedValue(expectedResolvedIncident)\n+ })\n+\n+ it('should resolve an incident', async () => {\n+ const store = mockStore()\n+\n+ await store.dispatch(resolveIncident(mockIncident))\n+\n+ expect(store.getActions()[0]).toEqual(resolveIncidentStart())\n+ expect(incidentRepositorySaveOrUpdateSpy).toHaveBeenCalledWith(expectedResolvedIncident)\n+ expect(store.getActions()[1]).toEqual(resolveIncidentSuccess(expectedResolvedIncident))\n+ })\n+\n+ it('should call on success callback if provided', async () => {\n+ const store = mockStore()\n+ const onSuccessSpy = jest.fn()\n+ await store.dispatch(resolveIncident(mockIncident, onSuccessSpy))\n+\n+ expect(onSuccessSpy).toHaveBeenCalledWith(expectedResolvedIncident)\n+ })\n+ })\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/incidents/view/ViewIncident.test.tsx",
"new_path": "src/__tests__/incidents/view/ViewIncident.test.tsx",
"diff": "+import { Button } from '@hospitalrun/components'\nimport { act } from '@testing-library/react'\nimport { mount } from 'enzyme'\nimport { createMemoryHistory } from 'history'\n@@ -20,6 +21,8 @@ const mockStore = createMockStore<RootState, any>([thunk])\ndescribe('View Incident', () => {\nconst expectedDate = new Date(2020, 5, 1, 19, 48)\n+ const expectedResolveDate = new Date()\n+ let incidentRepositorySaveSpy: any\nlet history: any\nconst expectedIncident = {\nid: '1234',\n@@ -34,11 +37,15 @@ describe('View Incident', () => {\ndate: expectedDate.toISOString(),\n} as Incident\n- const setup = async (permissions: Permissions[]) => {\n+ const setup = async (mockIncident: Incident, permissions: Permissions[]) => {\njest.resetAllMocks()\n+ Date.now = jest.fn(() => expectedResolveDate.valueOf())\njest.spyOn(breadcrumbUtil, 'default')\njest.spyOn(titleUtil, 'default')\njest.spyOn(IncidentRepository, 'find').mockResolvedValue(expectedIncident)\n+ incidentRepositorySaveSpy = jest\n+ .spyOn(IncidentRepository, 'saveOrUpdate')\n+ .mockResolvedValue(expectedIncident)\nhistory = createMemoryHistory()\nhistory.push(`/incidents/1234`)\n@@ -49,7 +56,7 @@ describe('View Incident', () => {\npermissions,\n},\nincident: {\n- incident: expectedIncident,\n+ incident: mockIncident,\n},\n} as any)\n@@ -73,13 +80,13 @@ describe('View Incident', () => {\ndescribe('layout', () => {\nit('should set the title', async () => {\n- await setup([Permissions.ViewIncident])\n+ await setup(expectedIncident, [Permissions.ViewIncident])\nexpect(titleUtil.default).toHaveBeenCalledWith(expectedIncident.code)\n})\nit('should set the breadcrumbs properly', async () => {\n- await setup([Permissions.ViewIncident])\n+ await setup(expectedIncident, [Permissions.ViewIncident])\nexpect(breadcrumbUtil.default).toHaveBeenCalledWith([\n{ i18nKey: expectedIncident.code, location: '/incidents/1234' },\n@@ -87,7 +94,7 @@ describe('View Incident', () => {\n})\nit('should render the date of incident', async () => {\n- const wrapper = await setup([Permissions.ViewIncident])\n+ const wrapper = await setup(expectedIncident, [Permissions.ViewIncident])\nconst dateOfIncidentFormGroup = wrapper.find('.incident-date')\nexpect(dateOfIncidentFormGroup.find('h4').text()).toEqual('incidents.reports.dateOfIncident')\n@@ -95,7 +102,7 @@ describe('View Incident', () => {\n})\nit('should render the status', async () => {\n- const wrapper = await setup([Permissions.ViewIncident])\n+ const wrapper = await setup(expectedIncident, [Permissions.ViewIncident])\nconst dateOfIncidentFormGroup = wrapper.find('.incident-status')\nexpect(dateOfIncidentFormGroup.find('h4').text()).toEqual('incidents.reports.status')\n@@ -103,7 +110,7 @@ describe('View Incident', () => {\n})\nit('should render the reported by', async () => {\n- const wrapper = await setup([Permissions.ViewIncident])\n+ const wrapper = await setup(expectedIncident, [Permissions.ViewIncident])\nconst dateOfIncidentFormGroup = wrapper.find('.incident-reported-by')\nexpect(dateOfIncidentFormGroup.find('h4').text()).toEqual('incidents.reports.reportedBy')\n@@ -111,15 +118,35 @@ describe('View Incident', () => {\n})\nit('should render the reported on', async () => {\n- const wrapper = await setup([Permissions.ViewIncident])\n+ const wrapper = await setup(expectedIncident, [Permissions.ViewIncident])\nconst dateOfIncidentFormGroup = wrapper.find('.incident-reported-on')\nexpect(dateOfIncidentFormGroup.find('h4').text()).toEqual('incidents.reports.reportedOn')\nexpect(dateOfIncidentFormGroup.find('h5').text()).toEqual('2020-06-01 07:48 PM')\n})\n+ it('should render the resolved on if incident status is resolved', async () => {\n+ const mockIncident = {\n+ ...expectedIncident,\n+ status: 'resolved',\n+ resolvedOn: '2020-07-10 06:33 PM',\n+ } as Incident\n+ const wrapper = await setup(mockIncident, [Permissions.ViewIncident])\n+\n+ const dateOfResolutionFormGroup = wrapper.find('.incident-resolved-on')\n+ expect(dateOfResolutionFormGroup.find('h4').text()).toEqual('incidents.reports.resolvedOn')\n+ expect(dateOfResolutionFormGroup.find('h5').text()).toEqual('2020-07-10 06:33 PM')\n+ })\n+\n+ it('should not render the resolved on if incident status is not resolved', async () => {\n+ const wrapper = await setup(expectedIncident, [Permissions.ViewIncident])\n+\n+ const completedOn = wrapper.find('.incident-resolved-on')\n+ expect(completedOn).toHaveLength(0)\n+ })\n+\nit('should render the department', async () => {\n- const wrapper = await setup([Permissions.ViewIncident])\n+ const wrapper = await setup(expectedIncident, [Permissions.ViewIncident])\nconst departmentInput = wrapper.findWhere((w: any) => w.prop('name') === 'department')\nexpect(departmentInput.prop('label')).toEqual('incidents.reports.department')\n@@ -127,7 +154,7 @@ describe('View Incident', () => {\n})\nit('should render the category', async () => {\n- const wrapper = await setup([Permissions.ViewIncident])\n+ const wrapper = await setup(expectedIncident, [Permissions.ViewIncident])\nconst categoryInput = wrapper.findWhere((w: any) => w.prop('name') === 'category')\nexpect(categoryInput.prop('label')).toEqual('incidents.reports.category')\n@@ -135,7 +162,7 @@ describe('View Incident', () => {\n})\nit('should render the category item', async () => {\n- const wrapper = await setup([Permissions.ViewIncident])\n+ const wrapper = await setup(expectedIncident, [Permissions.ViewIncident])\nconst categoryItemInput = wrapper.findWhere((w: any) => w.prop('name') === 'categoryItem')\nexpect(categoryItemInput.prop('label')).toEqual('incidents.reports.categoryItem')\n@@ -143,11 +170,62 @@ describe('View Incident', () => {\n})\nit('should render the description', async () => {\n- const wrapper = await setup([Permissions.ViewIncident])\n+ const wrapper = await setup(expectedIncident, [Permissions.ViewIncident])\nconst descriptionTextInput = wrapper.findWhere((w: any) => w.prop('name') === 'description')\nexpect(descriptionTextInput.prop('label')).toEqual('incidents.reports.description')\nexpect(descriptionTextInput.prop('value')).toEqual(expectedIncident.description)\n})\n+\n+ it('should display a resolve incident button if the incident is in a reported state', async () => {\n+ const wrapper = await setup(expectedIncident, [\n+ Permissions.ViewIncident,\n+ Permissions.ResolveIncident,\n+ ])\n+\n+ const buttons = wrapper.find(Button)\n+ expect(buttons.at(0).text().trim()).toEqual('incidents.reports.resolve')\n+ })\n+\n+ it('should not display a resolve incident button if the user has no access ResolveIncident access', async () => {\n+ const wrapper = await setup(expectedIncident, [Permissions.ViewIncident])\n+\n+ const resolveButton = wrapper.find(Button)\n+ expect(resolveButton).toHaveLength(0)\n+ })\n+\n+ it('should not display a resolve incident button if the incident is resolved', async () => {\n+ const mockIncident = { ...expectedIncident, status: 'resolved' } as Incident\n+ const wrapper = await setup(mockIncident, [Permissions.ViewIncident])\n+\n+ const resolveButton = wrapper.find(Button)\n+ expect(resolveButton).toHaveLength(0)\n+ })\n+ })\n+\n+ describe('on resolve', () => {\n+ it('should mark the status as resolved and fill in the resolved date with the current time', async () => {\n+ const wrapper = await setup(expectedIncident, [\n+ Permissions.ViewIncident,\n+ Permissions.ResolveIncident,\n+ ])\n+\n+ const resolveButton = wrapper.find(Button).at(0)\n+ await act(async () => {\n+ const onClick = resolveButton.prop('onClick')\n+ await onClick()\n+ })\n+ wrapper.update()\n+\n+ expect(incidentRepositorySaveSpy).toHaveBeenCalledTimes(1)\n+ expect(incidentRepositorySaveSpy).toHaveBeenCalledWith(\n+ expect.objectContaining({\n+ ...expectedIncident,\n+ status: 'resolved',\n+ resolvedOn: expectedResolveDate.toISOString(),\n+ }),\n+ )\n+ expect(history.location.pathname).toEqual('/incidents')\n+ })\n})\n})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/shared/utils/extractUsername.test.ts",
"diff": "+import { extractUsername } from '../../../shared/util/extractUsername'\n+\n+describe('extract username util', () => {\n+ it('should extract the string after the last : in a given string', () => {\n+ const extractedName = extractUsername('org.couchdb.user:username')\n+ expect(extractedName).toMatch('username')\n+ })\n+\n+ it('should return the string if string does not contain a : ', () => {\n+ const extractedName = extractUsername('username')\n+ expect(extractedName).toMatch('username')\n+ })\n+})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/incidents/IncidentFilter.ts",
"new_path": "src/incidents/IncidentFilter.ts",
"diff": "enum IncidentFilter {\nreported = 'reported',\n+ resolved = 'resolved',\nall = 'all',\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/incidents/incident-slice.ts",
"new_path": "src/incidents/incident-slice.ts",
"diff": "@@ -51,6 +51,8 @@ const incidentSlice = createSlice({\nreportIncidentStart: start,\nreportIncidentSuccess: finish,\nreportIncidentError: error,\n+ resolveIncidentStart: start,\n+ resolveIncidentSuccess: finish,\n},\n})\n@@ -60,6 +62,8 @@ export const {\nreportIncidentStart,\nreportIncidentSuccess,\nreportIncidentError,\n+ resolveIncidentStart,\n+ resolveIncidentSuccess,\n} = incidentSlice.actions\nexport const fetchIncident = (id: string): AppThunk => async (dispatch) => {\n@@ -120,4 +124,23 @@ export const reportIncident = (\n}\n}\n+export const resolveIncident = (\n+ incidentToComplete: Incident,\n+ onSuccess?: (incidentToComplete: Incident) => void,\n+): AppThunk => async (dispatch) => {\n+ dispatch(resolveIncidentStart())\n+\n+ const resolvedIncident = await IncidentRepository.saveOrUpdate({\n+ ...incidentToComplete,\n+ resolvedOn: new Date(Date.now().valueOf()).toISOString(),\n+ status: 'resolved',\n+ })\n+\n+ dispatch(resolveIncidentSuccess(resolvedIncident))\n+\n+ if (onSuccess) {\n+ onSuccess(resolvedIncident)\n+ }\n+}\n+\nexport default incidentSlice.reducer\n"
},
{
"change_type": "MODIFY",
"old_path": "src/incidents/list/ViewIncidents.tsx",
"new_path": "src/incidents/list/ViewIncidents.tsx",
"diff": "@@ -11,6 +11,7 @@ import SelectWithLabelFormGroup, {\n} from '../../shared/components/input/SelectWithLableFormGroup'\nimport useTranslator from '../../shared/hooks/useTranslator'\nimport { RootState } from '../../shared/store'\n+import { extractUsername } from '../../shared/util/extractUsername'\nimport IncidentFilter from '../IncidentFilter'\nimport { searchIncidents } from '../incidents-slice'\n@@ -21,7 +22,10 @@ const ViewIncidents = () => {\nuseTitle(t('incidents.reports.label'))\nconst [searchFilter, setSearchFilter] = useState(IncidentFilter.reported)\nconst { incidents } = useSelector((state: RootState) => state.incidents)\n-\n+ const viewIncidents = incidents.map((row) => ({\n+ ...row,\n+ reportedBy: extractUsername(row.reportedBy),\n+ }))\nconst setButtonToolBar = useButtonToolbarSetter()\nuseEffect(() => {\nsetButtonToolBar([\n@@ -67,7 +71,7 @@ const ViewIncidents = () => {\n<div className=\"row\">\n<Table\ngetID={(row) => row.id}\n- data={incidents}\n+ data={viewIncidents}\ncolumns={[\n{ label: t('incidents.reports.code'), key: 'code' },\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/incidents/view/ViewIncident.tsx",
"new_path": "src/incidents/view/ViewIncident.tsx",
"diff": "-import { Column, Row, Spinner } from '@hospitalrun/components'\n+import { Button, Column, Row, Spinner } from '@hospitalrun/components'\nimport format from 'date-fns/format'\nimport React, { useEffect } from 'react'\nimport { useDispatch, useSelector } from 'react-redux'\n-import { useParams } from 'react-router-dom'\n+import { useParams, useHistory } from 'react-router-dom'\nimport useAddBreadcrumbs from '../../page-header/breadcrumbs/useAddBreadcrumbs'\nimport useTitle from '../../page-header/title/useTitle'\nimport TextFieldWithLabelFormGroup from '../../shared/components/input/TextFieldWithLabelFormGroup'\nimport TextInputWithLabelFormGroup from '../../shared/components/input/TextInputWithLabelFormGroup'\nimport useTranslator from '../../shared/hooks/useTranslator'\n+import Permissions from '../../shared/model/Permissions'\nimport { RootState } from '../../shared/store'\n-import { fetchIncident } from '../incident-slice'\n+import { extractUsername } from '../../shared/util/extractUsername'\n+import { fetchIncident, resolveIncident } from '../incident-slice'\nconst ViewIncident = () => {\nconst dispatch = useDispatch()\nconst { t } = useTranslator()\n+ const history = useHistory()\nconst { id } = useParams()\nconst { incident } = useSelector((state: RootState) => state.incident)\n+ const { permissions } = useSelector((state: RootState) => state.user)\n+ const isUnresolved = incident?.status !== 'resolved'\nuseTitle(incident ? incident.code : '')\nconst breadcrumbs = [\n{\n@@ -31,7 +36,54 @@ const ViewIncident = () => {\ndispatch(fetchIncident(id))\n}\n}, [dispatch, id])\n+\n+ const onComplete = async () => {\n+ const onSuccess = () => {\n+ history.push('/incidents')\n+ }\n+\nif (incident) {\n+ dispatch(resolveIncident(incident, onSuccess))\n+ }\n+ }\n+\n+ const getButtons = () => {\n+ const buttons: React.ReactNode[] = []\n+ if (incident?.status === 'resolved') {\n+ return buttons\n+ }\n+\n+ if (permissions.includes(Permissions.ResolveIncident)) {\n+ buttons.push(\n+ <Button\n+ className=\"mr-2\"\n+ onClick={onComplete}\n+ color=\"primary\"\n+ key=\"incidents.reports.resolve\"\n+ >\n+ {t('incidents.reports.resolve')}\n+ </Button>,\n+ )\n+ }\n+\n+ return buttons\n+ }\n+\n+ if (incident) {\n+ const getResolvedOnDate = () => {\n+ if (incident.status === 'resolved' && incident.resolvedOn) {\n+ return (\n+ <Column>\n+ <div className=\"form-group incident-resolved-on\">\n+ <h4>{t('incidents.reports.resolvedOn')}</h4>\n+ <h5>{format(new Date(incident.resolvedOn), 'yyyy-MM-dd hh:mm a')}</h5>\n+ </div>\n+ </Column>\n+ )\n+ }\n+ return <></>\n+ }\n+\nreturn (\n<>\n<Row>\n@@ -50,7 +102,7 @@ const ViewIncident = () => {\n<Column>\n<div className=\"form-group incident-reported-by\">\n<h4>{t('incidents.reports.reportedBy')}</h4>\n- <h5>{incident.reportedBy}</h5>\n+ <h5>{extractUsername(incident.reportedBy)}</h5>\n</div>\n</Column>\n<Column>\n@@ -59,6 +111,7 @@ const ViewIncident = () => {\n<h5>{format(new Date(incident.reportedOn || ''), 'yyyy-MM-dd hh:mm a')}</h5>\n</div>\n</Column>\n+ {getResolvedOnDate()}\n</Row>\n<div className=\"border-bottom mb-2\" />\n<Row>\n@@ -95,6 +148,11 @@ const ViewIncident = () => {\n/>\n</Column>\n</Row>\n+ {isUnresolved && (\n+ <div className=\"row float-right\">\n+ <div className=\"btn-group btn-group-lg mt-3\">{getButtons()}</div>\n+ </div>\n+ )}\n</>\n)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/locales/enUs/translations/incidents/index.ts",
"new_path": "src/shared/locales/enUs/translations/incidents/index.ts",
"diff": "@@ -7,12 +7,14 @@ export default {\n},\nstatus: {\nreported: 'reported',\n+ resolved: 'resolved',\nall: 'all',\n},\nreports: {\nlabel: 'Reported Incidents',\nnew: 'Report Incident',\nview: 'View Incident',\n+ resolve: 'Resolve Incident',\ndateOfIncident: 'Date of Incident',\ndepartment: 'Department',\ncategory: 'Category',\n@@ -21,6 +23,7 @@ export default {\ncode: 'Code',\nreportedBy: 'Reported By',\nreportedOn: 'Reported On',\n+ resolvedOn: 'Resolved On',\nstatus: 'Status',\nerror: {\ndateRequired: 'Date is required.',\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/model/Incident.ts",
"new_path": "src/shared/model/Incident.ts",
"diff": "@@ -9,5 +9,6 @@ export default interface Incident extends AbstractDBModel {\ncategory: string\ncategoryItem: string\ndescription: string\n- status: 'reported'\n+ status: 'reported' | 'resolved'\n+ resolvedOn: string\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/model/Permissions.ts",
"new_path": "src/shared/model/Permissions.ts",
"diff": "@@ -14,6 +14,7 @@ enum Permissions {\nViewIncidents = 'read:incidents',\nViewIncident = 'read:incident',\nReportIncident = 'write:incident',\n+ ResolveIncident = 'resolve:incident',\nAddCarePlan = 'write:care_plan',\nReadCarePlan = 'read:care_plan',\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/shared/util/extractUsername.ts",
"diff": "+export const extractUsername = (username: string) =>\n+ username ? username.slice(username.lastIndexOf(':') + 1) : ''\n"
},
{
"change_type": "MODIFY",
"old_path": "src/user/user-slice.ts",
"new_path": "src/user/user-slice.ts",
"diff": "@@ -35,6 +35,7 @@ const initialState: UserState = {\nPermissions.ViewIncident,\nPermissions.ViewIncidents,\nPermissions.ReportIncident,\n+ Permissions.ResolveIncident,\nPermissions.AddCarePlan,\nPermissions.ReadCarePlan,\n],\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(incidents): add ability to resolve incidents (#2222) |
288,385 | 13.07.2020 01:39:57 | -14,400 | 071508c358befcf16973af41fcfc4bceba3a8feb | feat(allergies): ability to click on allergy and view an allergy | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/allergies/Allergies.test.tsx",
"new_path": "src/__tests__/patients/allergies/Allergies.test.tsx",
"diff": "@@ -9,8 +9,8 @@ import createMockStore from 'redux-mock-store'\nimport thunk from 'redux-thunk'\nimport Allergies from '../../../patients/allergies/Allergies'\n+import AllergiesList from '../../../patients/allergies/AllergiesList'\nimport PatientRepository from '../../../shared/db/PatientRepository'\n-import Allergy from '../../../shared/model/Allergy'\nimport Patient from '../../../shared/model/Patient'\nimport Permissions from '../../../shared/model/Permissions'\nimport { RootState } from '../../../shared/store'\n@@ -26,12 +26,15 @@ const expectedPatient = {\n],\n} as Patient\n-let user: any\nlet store: any\n-const setup = (patient = expectedPatient, permissions = [Permissions.AddAllergy]) => {\n- user = { permissions }\n- store = mockStore({ patient, user } as any)\n+const setup = (\n+ patient = expectedPatient,\n+ permissions = [Permissions.AddAllergy],\n+ route = '/patients/123/allergies',\n+) => {\n+ store = mockStore({ patient: { patient }, user: { permissions } } as any)\n+ history.push(route)\nconst wrapper = mount(\n<Router history={history}>\n<Provider store={store}>\n@@ -81,15 +84,11 @@ describe('Allergies', () => {\n})\ndescribe('allergy list', () => {\n- it('should list the patients allergies', () => {\n- const allergies = expectedPatient.allergies as Allergy[]\n+ it('should render allergies', () => {\nconst wrapper = setup()\n+ const allergiesList = wrapper.find(AllergiesList)\n- const list = wrapper.find(components.List)\n- const listItems = wrapper.find(components.ListItem)\n-\n- expect(list).toHaveLength(1)\n- expect(listItems).toHaveLength(allergies.length)\n+ expect(allergiesList).toHaveLength(1)\n})\nit('should render a warning message if the patient does not have any allergies', () => {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/patients/allergies/AllergiesList.test.tsx",
"diff": "+import { List, ListItem } from '@hospitalrun/components'\n+import { mount, ReactWrapper } from 'enzyme'\n+import { createMemoryHistory } from 'history'\n+import React from 'react'\n+import { act } from 'react-dom/test-utils'\n+import { Provider } from 'react-redux'\n+import { Router } from 'react-router-dom'\n+import createMockStore from 'redux-mock-store'\n+import thunk from 'redux-thunk'\n+\n+import AllergiesList from '../../../patients/allergies/AllergiesList'\n+import Allergy from '../../../shared/model/Allergy'\n+import Patient from '../../../shared/model/Patient'\n+import { RootState } from '../../../shared/store'\n+\n+const mockStore = createMockStore<RootState, any>([thunk])\n+\n+describe('Allergies list', () => {\n+ const allergy: Allergy = {\n+ id: 'id',\n+ name: 'name',\n+ }\n+ const patient = {\n+ id: 'patientId',\n+ diagnoses: [{ id: '123', name: 'some name', diagnosisDate: new Date().toISOString() }],\n+ allergies: [allergy],\n+ } as Patient\n+\n+ const setup = () => {\n+ const store = mockStore({ patient: { patient } } as any)\n+ const history = createMemoryHistory()\n+ history.push(`/patients/${patient.id}/allergies/${patient.allergies![0].id}`)\n+ const wrapper = mount(\n+ <Provider store={store}>\n+ <Router history={history}>\n+ <AllergiesList />\n+ </Router>\n+ </Provider>,\n+ )\n+ return { wrapper: wrapper as ReactWrapper, history }\n+ }\n+\n+ it('should render a list', () => {\n+ const allergies = patient.allergies as Allergy[]\n+ const { wrapper } = setup()\n+ const list = wrapper.find(List)\n+ const listItems = wrapper.find(ListItem)\n+\n+ expect(list).toHaveLength(1)\n+ expect(listItems).toHaveLength(allergies.length)\n+ })\n+\n+ it('should navigate to the allergy view when the allergy is clicked', () => {\n+ const { wrapper, history } = setup()\n+ const item = wrapper.find(ListItem)\n+ act(() => {\n+ const onClick = item.prop('onClick') as any\n+ onClick({ stopPropagation: jest.fn() })\n+ })\n+\n+ expect(history.location.pathname).toEqual(`/patients/${patient.id}/allergies/${allergy.id}`)\n+ })\n+})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/patients/allergies/ViewAllergy.test.tsx",
"diff": "+import { mount } from 'enzyme'\n+import { createMemoryHistory } from 'history'\n+import React from 'react'\n+import { Provider } from 'react-redux'\n+import { Route, Router } from 'react-router-dom'\n+import createMockStore from 'redux-mock-store'\n+import thunk from 'redux-thunk'\n+\n+import ViewAllergy from '../../../patients/allergies/ViewAllergy'\n+import TextInputWithLabelFormGroup from '../../../shared/components/input/TextInputWithLabelFormGroup'\n+import Patient from '../../../shared/model/Patient'\n+import { RootState } from '../../../shared/store'\n+\n+const mockStore = createMockStore<RootState, any>([thunk])\n+\n+describe('View Care Plan', () => {\n+ const patient = {\n+ id: 'patientId',\n+ allergies: [{ id: '123', name: 'some name' }],\n+ } as Patient\n+\n+ const setup = () => {\n+ const store = mockStore({ patient: { patient }, user: { user: { id: '123' } } } as any)\n+ const history = createMemoryHistory()\n+ history.push(`/patients/${patient.id}/allergies/${patient.allergies![0].id}`)\n+ const wrapper = mount(\n+ <Provider store={store}>\n+ <Router history={history}>\n+ <Route path=\"/patients/:id/allergies/:allergyId\">\n+ <ViewAllergy />\n+ </Route>\n+ </Router>\n+ </Provider>,\n+ )\n+\n+ return { wrapper }\n+ }\n+\n+ it('should render a allergy input with the correct data', () => {\n+ const { wrapper } = setup()\n+\n+ const allergyName = wrapper.find(TextInputWithLabelFormGroup)\n+ expect(allergyName).toHaveLength(1)\n+ expect(allergyName.prop('value')).toEqual(patient.allergies![0].name)\n+ })\n+})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/allergies/Allergies.tsx",
"new_path": "src/patients/allergies/Allergies.tsx",
"diff": "-import { Button, List, ListItem, Alert } from '@hospitalrun/components'\n+import { Button, Alert } from '@hospitalrun/components'\nimport React, { useState } from 'react'\nimport { useSelector } from 'react-redux'\n+import { Route, Switch } from 'react-router-dom'\nimport useAddBreadcrumbs from '../../page-header/breadcrumbs/useAddBreadcrumbs'\nimport useTranslator from '../../shared/hooks/useTranslator'\n-import Allergy from '../../shared/model/Allergy'\nimport Patient from '../../shared/model/Patient'\nimport Permissions from '../../shared/model/Permissions'\nimport { RootState } from '../../shared/store'\n+import AllergiesList from './AllergiesList'\nimport NewAllergyModal from './NewAllergyModal'\n+import ViewAllergy from './ViewAllergy'\ninterface AllergiesProps {\npatient: Patient\n@@ -46,6 +48,14 @@ const Allergies = (props: AllergiesProps) => {\n</div>\n</div>\n<br />\n+ <Switch>\n+ <Route exact path=\"/patients/:id/allergies\">\n+ <AllergiesList />\n+ </Route>\n+ <Route exact path=\"/patients/:id/allergies/:allergyId\">\n+ <ViewAllergy />\n+ </Route>\n+ </Switch>\n{(!patient.allergies || patient.allergies.length === 0) && (\n<Alert\ncolor=\"warning\"\n@@ -53,11 +63,6 @@ const Allergies = (props: AllergiesProps) => {\nmessage={t('patient.allergies.addAllergyAbove')}\n/>\n)}\n- <List>\n- {patient.allergies?.map((a: Allergy) => (\n- <ListItem key={a.id}>{a.name}</ListItem>\n- ))}\n- </List>\n<NewAllergyModal\nshow={showNewAllergyModal}\nonCloseButtonClick={() => setShowNewAllergyModal(false)}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/allergies/AllergiesList.tsx",
"diff": "+import { List, ListItem } from '@hospitalrun/components'\n+import React from 'react'\n+import { useSelector } from 'react-redux'\n+import { useHistory } from 'react-router-dom'\n+\n+import Allergy from '../../shared/model/Allergy'\n+import { RootState } from '../../shared/store'\n+\n+const AllergiesList = () => {\n+ const history = useHistory()\n+ const { patient } = useSelector((state: RootState) => state.patient)\n+\n+ return (\n+ <List>\n+ {patient.allergies?.map((a: Allergy) => (\n+ <ListItem\n+ action\n+ key={a.id}\n+ onClick={() => history.push(`/patients/${patient.id}/allergies/${a.id}`)}\n+ >\n+ {a.name}\n+ </ListItem>\n+ ))}\n+ </List>\n+ )\n+}\n+\n+export default AllergiesList\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/allergies/ViewAllergy.tsx",
"diff": "+import React, { useEffect, useState } from 'react'\n+import { useSelector } from 'react-redux'\n+import { useParams } from 'react-router-dom'\n+\n+import TextInputWithLabelFormGroup from '../../shared/components/input/TextInputWithLabelFormGroup'\n+import useTranslator from '../../shared/hooks/useTranslator'\n+import Allergy from '../../shared/model/Allergy'\n+import { RootState } from '../../shared/store'\n+\n+const ViewAllergy = () => {\n+ const { t } = useTranslator()\n+ const { patient } = useSelector((root: RootState) => root.patient)\n+ const { allergyId } = useParams()\n+\n+ const [allergy, setAllergy] = useState<Allergy | undefined>()\n+\n+ useEffect(() => {\n+ if (patient && allergyId) {\n+ const currentAllergy = patient.allergies?.find((a: Allergy) => a.id === allergyId)\n+ setAllergy(currentAllergy)\n+ }\n+ }, [setAllergy, allergyId, patient])\n+\n+ if (allergy) {\n+ return (\n+ <>\n+ <TextInputWithLabelFormGroup\n+ name=\"name\"\n+ label={t('patient.allergies.allergyName')}\n+ isEditable={false}\n+ placeholder={t('patient.allergies.allergyName')}\n+ value={allergy.name}\n+ />\n+ </>\n+ )\n+ }\n+ return <></>\n+}\n+\n+export default ViewAllergy\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/view/ViewPatient.tsx",
"new_path": "src/patients/view/ViewPatient.tsx",
"diff": "@@ -144,7 +144,7 @@ const ViewPatient = () => {\n<Route exact path={`${path}/appointments`}>\n<AppointmentsList patientId={patient.id} />\n</Route>\n- <Route exact path={`${path}/allergies`}>\n+ <Route path={`${path}/allergies`}>\n<Allergies patient={patient} />\n</Route>\n<Route exact path={`${path}/diagnoses`}>\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(allergies): ability to click on allergy and view an allergy (#2224) |
288,411 | 16.07.2020 19:36:12 | 14,400 | 0c85e2450acad2dbf7addb0b657a037e2cf397b7 | feat(Navbar): remove search from navbar | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/shared/components/navbar/Navbar.test.tsx",
"new_path": "src/__tests__/shared/components/navbar/Navbar.test.tsx",
"diff": "@@ -122,26 +122,6 @@ describe('Navbar', () => {\n})\n})\n- describe('search', () => {\n- it('should render Search as the search box placeholder', () => {\n- const wrapper = setup(allPermissions)\n- const hospitalRunNavbar = wrapper.find(HospitalRunNavbar)\n- const navSearch = hospitalRunNavbar.find('.nav-search')\n- const { children } = navSearch.first().props() as any\n-\n- expect(children.props.children[0].props.placeholder).toEqual('actions.search')\n- })\n-\n- it('should render Search as the search button label', () => {\n- const wrapper = setup(allPermissions)\n- const hospitalRunNavbar = wrapper.find(HospitalRunNavbar)\n- const navSearch = hospitalRunNavbar.find('.nav-search')\n- const { children } = navSearch.first().props() as any\n-\n- expect(children.props.children[1].props.children).toEqual('actions.search')\n- })\n- })\n-\ndescribe('add new', () => {\nit('should show a shortcut if user has a permission', () => {\nconst wrapper = setup(allPermissions)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/components/navbar/Navbar.tsx",
"new_path": "src/shared/components/navbar/Navbar.tsx",
"diff": "@@ -75,20 +75,11 @@ const Navbar = () => {\n},\nclassName: 'nav-header',\n},\n- {\n- type: 'search',\n- placeholderText: t('actions.search'),\n- className: 'ml-auto d-none d-md-block nav-search',\n- buttonText: t('actions.search'),\n- buttonColor: 'secondary',\n- onClickButton: () => undefined,\n- onChangeInput: () => undefined,\n- },\n{\ntype: 'link-list-icon',\nalignRight: true,\nchildren: getDropdownListOfPages(addPages),\n- className: 'pl-4 nav-add-new d-none d-md-block',\n+ className: 'ml-auto nav-add-new d-none d-md-block',\niconClassName: 'align-bottom',\nlabel: 'Add',\nname: 'add',\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(Navbar): remove search from navbar (#2237) |
288,294 | 18.07.2020 01:10:39 | 14,400 | 5a4bfa54af9d30d9b6b26416f06a5e3325699551 | feat(navbar): display currently logged in user name | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/shared/components/navbar/Navbar.test.tsx",
"new_path": "src/__tests__/shared/components/navbar/Navbar.test.tsx",
"diff": "@@ -11,6 +11,7 @@ import thunk from 'redux-thunk'\nimport Navbar from '../../../../shared/components/navbar/Navbar'\nimport Permissions from '../../../../shared/model/Permissions'\n+import User from '../../../../shared/model/User'\nimport { RootState } from '../../../../shared/store'\nconst mockStore = createMockStore<RootState, any>([thunk])\n@@ -18,10 +19,10 @@ const mockStore = createMockStore<RootState, any>([thunk])\ndescribe('Navbar', () => {\nconst history = createMemoryHistory()\n- const setup = (permissions: Permissions[]) => {\n+ const setup = (permissions: Permissions[], user?: User) => {\nconst store = mockStore({\ntitle: '',\n- user: { permissions },\n+ user: { permissions, user },\n} as any)\nconst wrapper = mount(\n@@ -34,6 +35,11 @@ describe('Navbar', () => {\nreturn wrapper\n}\n+ const userName = {\n+ givenName: 'givenName',\n+ familyName: 'familyName',\n+ } as User\n+\nconst allPermissions = [\nPermissions.ReadPatients,\nPermissions.WritePatients,\n@@ -150,13 +156,24 @@ describe('Navbar', () => {\n})\ndescribe('account', () => {\n- it('should render an account link list', () => {\n+ it(\"should render a link with the user's identification\", () => {\n+ const expectedUserName = `user.login.currentlySignedInAs ${userName.givenName} ${userName.familyName}`\n+\n+ const wrapper = setup(allPermissions, userName)\n+ const hospitalRunNavbar = wrapper.find(HospitalRunNavbar)\n+ const accountLinkList = hospitalRunNavbar.find('.nav-account')\n+ const { children } = accountLinkList.first().props() as any\n+\n+ expect(children[0].props.children).toEqual([undefined, expectedUserName])\n+ })\n+\n+ it('should render a setting link list', () => {\nconst wrapper = setup(allPermissions)\nconst hospitalRunNavbar = wrapper.find(HospitalRunNavbar)\nconst accountLinkList = hospitalRunNavbar.find('.nav-account')\nconst { children } = accountLinkList.first().props() as any\n- expect(children[0].props.children).toEqual([undefined, 'settings.label'])\n+ expect(children[1].props.children).toEqual([undefined, 'settings.label'])\n})\nit('should navigate to /settings when the list option is selected', () => {\n@@ -167,6 +184,7 @@ describe('Navbar', () => {\nact(() => {\nchildren[0].props.onClick()\n+ children[1].props.onClick()\n})\nexpect(history.location.pathname).toEqual('/settings')\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/components/navbar/Navbar.tsx",
"new_path": "src/shared/components/navbar/Navbar.tsx",
"diff": "@@ -12,7 +12,7 @@ const Navbar = () => {\nconst dispatch = useDispatch()\nconst history = useHistory()\nconst { t } = useTranslator()\n- const { permissions } = useSelector((state: RootState) => state.user)\n+ const { permissions, user } = useSelector((state: RootState) => state.user)\nconst navigateTo = (location: string) => {\nhistory.push(location)\n@@ -89,6 +89,15 @@ const Navbar = () => {\ntype: 'link-list-icon',\nalignRight: true,\nchildren: [\n+ {\n+ type: 'link',\n+ label: `${t('user.login.currentlySignedInAs')} ${user?.givenName} ${\n+ user?.familyName\n+ }`,\n+ onClick: () => {\n+ navigateTo('/settings')\n+ },\n+ },\n{\ntype: 'link',\nlabel: t('settings.label'),\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/locales/enUs/translations/user/index.ts",
"new_path": "src/shared/locales/enUs/translations/user/index.ts",
"diff": "@@ -13,6 +13,7 @@ export default {\nrequired: 'Password is required.',\n},\n},\n+ currentlySignedInAs: 'Currently signed in as',\n},\n},\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(navbar): display currently logged in user name |
288,334 | 19.07.2020 11:15:53 | -7,200 | 641c77522ae323764ef338596ec4e5a0c1b321fb | perf(couchdb): add all couchdb init command on docker-compose | [
{
"change_type": "MODIFY",
"old_path": ".github/CONTRIBUTING.md",
"new_path": ".github/CONTRIBUTING.md",
"diff": "Before contributing, please read the [code of conduct](https://github.com/HospitalRun/hospitalrun/blob/master/.github/CODE_OF_CONDUCT.md).\n## 1. Check out the [HospitalRun General Contributing Guide](https://github.com/HospitalRun/hospitalrun/blob/master/.github/CONTRIBUTING.md) for how to:\n+\n1. Browse Issues\n2. Get Assigned an Issue\n3. Fork the Repository and Create a Branch\n@@ -19,19 +20,9 @@ root of this project to launch CouchDB. Below are the steps:\n2. Install [Docker Compose](https://docs.docker.com/compose/install/) if you don't have it yet.\n3. Run `docker-compose up --build -d` in the root directory.\n-This should launch a new CouchDB instance on `http://localhost:5984`, create system database, configure CouchDB as Single Node, enable CORS, create `hospitalrun` database, create a default admin with a username of `admin` and password of 'password'\n-\n-4. Make the `hospitalrun` database a public database by removing its member permissions:\n-\n- ```\n- curl -X PUT http://admin:password@localhost:5984/hospitalrun/_security -d '{\"members\": {}, \"admins\": {\"roles\": [\"_admin\"] }}'\n- ```\n+This should launch a new CouchDB instance on `http://localhost:5984`, create system database, configure CouchDB as Single Node, enable CORS, create `hospitalrun` database, create a default admin with a username of `admin` and password of 'password', create a sample user with a username of `username` and password of 'password' to use new login page [#2137](https://github.com/HospitalRun/hospitalrun-frontend/pull/2137).\n-5. Create a sample user with a username of `username` and password of 'password' to use new login page [#2137](https://github.com/HospitalRun/hospitalrun-frontend/pull/2137).\n- ```\n- curl -X PUT http://admin:password@localhost:5984/_users/org.couchdb.user:username -H \"Accept: application/json\" -H \"Content-Type: application/json\" -d '{\"name\": \"username\", \"password\": \"password\", \"metadata\": { \"givenName\": \"John\", \"familyName\": \"Doe\"}, \"roles\": [], \"type\": \"user\"}'\n- ```\n-Note: Go to `http://localhost:5984/_utils` in your browser to view Fauxton and perform administrative tasks.\n+Go to `http://localhost:5984/_utils` in your browser to view Fauxton and perform administrative tasks.\n**_Cleanup_**\nTo delete the development database, go to the root of the project and run `docker-compose down -v --rmi all --remove-orphans`\n@@ -43,6 +34,7 @@ To delete the development database, go to the root of the project and run `docke\n3. Run the application `npm start`\n## 3. Start the application\n+\n```\nnpm install\nnpm run start\n@@ -53,6 +45,7 @@ Open a file named `.env` and add a line `REACT_APP_HOSPITALRUN_API=http://localh\n_Note: To delete the development database, go to the root of the project and run `docker-compose down -v --rmi all --remove-orphans`_\nIf your branch's packages changed, reinstall the packages before starting the application:\n+\n```\nrm -fr node_modules\nrm yarn.lock (if you used yarn before)\n@@ -80,23 +73,27 @@ _Note: We no longer support the use of yarn._\n`npm run lint:fix` will run the linter and fix fixable errors\n## 5. Get familiar with documentation\n+\n- For a list of i18n language codes, see [this](https://github.com/HospitalRun/hospitalrun-frontend/tree/master/src/locales/README.md).\n## [ Extra ] Resources to help get you ramped up on the tech stack!\n### React\n+\n- [React Tutorial for Beginners by\nProgramming with Mosh](https://www.youtube.com/watch?v=Ke90Tje7VS0)\n- [Chrome React Developer Tools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en)\n- [VSCode React Extension Pack](https://marketplace.visualstudio.com/items?itemName=jawandarajbir.react-vscode-extension-pack)\n### Redux\n+\n- [Redux For Beginners | React Redux Tutorial by DevEd](https://youtu.be/CVpUuw9XSjY)\n- [Chrome Redux Developer Tools](https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd?hl=en)\n### PouchDB\n+\n- [Getting started with PouchDB and CouchDB (tutorial) by Nolan Lawson](https://youtu.be/-Z7UF2TuSp0)\n### Enzyme\n-- [Enzyme Cheatsheet by @rstacruz](https://devhints.io/enzyme)\n+- [Enzyme Cheatsheet by @rstacruz](https://devhints.io/enzyme)\n"
},
{
"change_type": "MODIFY",
"old_path": "docker-compose.yml",
"new_path": "docker-compose.yml",
"diff": "@@ -16,11 +16,14 @@ services:\ndbinit:\nimage: curlimages/curl\n+ container_name: hr_couchdb_init\n+ depends_on:\n+ - couchdb\ncommand: >\nsh -c\n\"sleep 5s &&\ncurl -X PUT http://admin:password@couchdb:5984/_global_changes &&\ncurl -X PUT http://admin:password@couchdb:5984/_users/_security -d '{}' &&\ncurl -X PUT http://admin:password@couchdb:5984/hospitalrun?partitioned=false &&\n+ curl -X PUT http://admin:password@couchdb:5984/hospitalrun/_security -d '{\\\"members\\\": {}, \\\"admins\\\": {\\\"roles\\\": [\\\"_admin\\\"] }}' &&\ncurl -X PUT http://admin:password@couchdb:5984/_users/org.couchdb.user:username -H \\\"Accept: application/json\\\" -H \\\"Content-Type: application/json\\\" -d '{\\\"name\\\": \\\"username\\\", \\\"password\\\": \\\"password\\\", \\\"metadata\\\": { \\\"givenName\\\": \\\"John\\\", \\\"familyName\\\": \\\"Doe\\\"}, \\\"roles\\\": [], \\\"type\\\": \\\"user\\\"}'\"\n-\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | perf(couchdb): add all couchdb init command on docker-compose |
288,271 | 28.07.2020 16:17:33 | 14,400 | 5d08ccf84b48e503b8a907c829c80b2ad72349f3 | feat(viewlab.tsx): added success toast for updated/completed labs | [
{
"change_type": "MODIFY",
"old_path": "src/labs/ViewLab.tsx",
"new_path": "src/labs/ViewLab.tsx",
"diff": "-import { Row, Column, Badge, Button, Alert } from '@hospitalrun/components'\n+import { Row, Column, Badge, Button, Alert, Toast } from '@hospitalrun/components'\nimport format from 'date-fns/format'\nimport React, { useEffect, useState } from 'react'\nimport { useTranslation } from 'react-i18next'\n@@ -64,17 +64,26 @@ const ViewLab = () => {\n}\nconst onUpdate = async () => {\n- const onSuccess = () => {\n- history.push('/labs')\n+ const onSuccess = (update: Lab) => {\n+ history.push(`/labs/${update.id}`)\n+ Toast(\n+ 'success',\n+ t('states.success'),\n+ `${t('labs.successfullyUpdated')} ${update.type} ${patient?.fullName}`,\n+ )\n}\nif (labToView) {\ndispatch(updateLab(labToView, onSuccess))\n}\n}\n-\nconst onComplete = async () => {\n- const onSuccess = () => {\n- history.push('/labs')\n+ const onSuccess = (complete: Lab) => {\n+ history.push(`/labs/${complete.id}`)\n+ Toast(\n+ 'success',\n+ t('states.success'),\n+ `${t('labs.successfullyCompleted')} ${complete.type} ${patient?.fullName} `,\n+ )\n}\nif (labToView) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/labs/requests/NewLabRequest.tsx",
"new_path": "src/labs/requests/NewLabRequest.tsx",
"diff": "-import { Typeahead, Label, Button, Alert } from '@hospitalrun/components'\n+import { Typeahead, Label, Button, Alert, Toast } from '@hospitalrun/components'\nimport React, { useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { useDispatch, useSelector } from 'react-redux'\n@@ -40,6 +40,7 @@ const NewLabRequest = () => {\nsetNewLabRequest((previousNewLabRequest) => ({\n...previousNewLabRequest,\npatient: patient.id,\n+ fullName: patient.fullName,\n}))\n}\n@@ -60,12 +61,16 @@ const NewLabRequest = () => {\n}\nconst onSave = async () => {\n- const newLab = newLabRequest as Lab\n- const onSuccess = (createdLab: Lab) => {\n- history.push(`/labs/${createdLab.id}`)\n+ const onSuccessRequest = (newLab: Lab) => {\n+ history.push(`/labs/${newLab.id}`)\n+ Toast(\n+ 'success',\n+ t('states.success'),\n+ `${t('lab.successfullyCreated')} ${newLab.type} ${newLab.patient}`,\n+ )\n}\n- dispatch(requestLab(newLab, onSuccess))\n+ dispatch(requestLab(newLabRequest as Lab, onSuccessRequest))\n}\nconst onCancel = () => {\n@@ -114,6 +119,7 @@ const NewLabRequest = () => {\n<Button className=\"mr-2\" color=\"success\" onClick={onSave}>\n{t('actions.save')}\n</Button>\n+\n<Button color=\"danger\" onClick={onCancel}>\n{t('actions.cancel')}\n</Button>\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(viewlab.tsx): added success toast for updated/completed labs |
288,286 | 30.07.2020 22:28:58 | 14,400 | f49831cd11b67a8f28071a05dbc832891c5b4bf5 | feat(new): warn about potential duplicate patient | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/patients/new/DuplicateNewPatientModal.test.tsx",
"diff": "+import { Modal } from '@hospitalrun/components'\n+import { act } from '@testing-library/react'\n+import { mount, ReactWrapper } from 'enzyme'\n+import React from 'react'\n+import { Provider } from 'react-redux'\n+import createMockStore from 'redux-mock-store'\n+import thunk from 'redux-thunk'\n+\n+import DuplicateNewPatientModal from '../../../patients/new/DuplicateNewPatientModal'\n+import { RootState } from '../../../shared/store'\n+\n+const mockStore = createMockStore<RootState, any>([thunk])\n+\n+const setupOnClick = (onClose: any, onContinue: any, prop: string) => {\n+ const store = mockStore({\n+ patient: {\n+ patient: {\n+ id: '1234',\n+ },\n+ },\n+ } as any)\n+\n+ const wrapper = mount(\n+ <Provider store={store}>\n+ <DuplicateNewPatientModal\n+ show\n+ toggle={jest.fn()}\n+ onCloseButtonClick={onClose}\n+ onContinueButtonClick={onContinue}\n+ />\n+ </Provider>,\n+ )\n+ wrapper.update()\n+\n+ act(() => {\n+ const modal = wrapper.find(Modal)\n+ const { onClick } = modal.prop(prop) as any\n+ onClick()\n+ })\n+\n+ return { wrapper: wrapper as ReactWrapper }\n+}\n+\n+describe('Duplicate New Patient Modal', () => {\n+ it('should render a modal with the correct labels', () => {\n+ const store = mockStore({\n+ patient: {\n+ patient: {\n+ id: '1234',\n+ },\n+ },\n+ } as any)\n+ const wrapper = mount(\n+ <Provider store={store}>\n+ <DuplicateNewPatientModal\n+ show\n+ toggle={jest.fn()}\n+ onCloseButtonClick={jest.fn()}\n+ onContinueButtonClick={jest.fn()}\n+ />\n+ </Provider>,\n+ )\n+ wrapper.update()\n+ const modal = wrapper.find(Modal)\n+ expect(modal).toHaveLength(1)\n+ expect(modal.prop('title')).toEqual('patients.newPatient')\n+ expect(modal.prop('closeButton')?.children).toEqual('actions.cancel')\n+ expect(modal.prop('closeButton')?.color).toEqual('danger')\n+ expect(modal.prop('successButton')?.children).toEqual('actions.save')\n+ expect(modal.prop('successButton')?.color).toEqual('success')\n+ })\n+\n+ describe('cancel', () => {\n+ it('should call the onCloseButtonClick function when the close button is clicked', () => {\n+ const onCloseButtonClickSpy = jest.fn()\n+ const closeButtonProp = 'closeButton'\n+ setupOnClick(onCloseButtonClickSpy, jest.fn(), closeButtonProp)\n+ expect(onCloseButtonClickSpy).toHaveBeenCalledTimes(1)\n+ })\n+ })\n+\n+ describe('on save', () => {\n+ it('should call the onContinueButtonClick function when the continue button is clicked', () => {\n+ const onContinueButtonClickSpy = jest.fn()\n+ const continueButtonProp = 'successButton'\n+ setupOnClick(jest.fn(), onContinueButtonClickSpy, continueButtonProp)\n+ expect(onContinueButtonClickSpy).toHaveBeenCalledTimes(1)\n+ })\n+ })\n+})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/new/NewPatient.test.tsx",
"new_path": "src/__tests__/patients/new/NewPatient.test.tsx",
"diff": "@@ -112,6 +112,24 @@ describe('New Patient', () => {\nexpect(store.getActions()).toContainEqual(patientSlice.createPatientSuccess())\n})\n+ it('should reveal modal (return true) when save button is clicked if an existing patient has the same information', async () => {\n+ let wrapper: any\n+ await act(async () => {\n+ wrapper = await setup()\n+ })\n+\n+ const saveButton = wrapper.find('.btn-save').at(0)\n+ const onClick = saveButton.prop('onClick') as any\n+ expect(saveButton.text().trim()).toEqual('actions.save')\n+\n+ act(() => {\n+ onClick()\n+ })\n+ wrapper.update()\n+\n+ expect(onClick()).toEqual(true)\n+ })\n+\nit('should navigate to /patients/:id and display a message after a new patient is successfully created', async () => {\njest.spyOn(components, 'Toast')\nconst mockedComponents = mocked(components, true)\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/patients/util/is-possible-duplicate-patient.test.ts",
"diff": "+import { isPossibleDuplicatePatient } from '../../../patients/util/is-possible-duplicate-patient'\n+import Patient from '../../../shared/model/Patient'\n+\n+describe('is possible duplicate patient', () => {\n+ describe('isPossibleDuplicatePatient', () => {\n+ it('should return true when duplicate patients are passed', () => {\n+ const newPatient = {\n+ givenName: 'given',\n+ familyName: 'family',\n+ suffix: 'suffix',\n+ } as Patient\n+\n+ const existingPatient = {\n+ givenName: 'given',\n+ familyName: 'family',\n+ suffix: 'suffix',\n+ } as Patient\n+\n+ const isDuplicatePatient = isPossibleDuplicatePatient(newPatient, existingPatient)\n+\n+ expect(isDuplicatePatient).toEqual(true)\n+ })\n+ })\n+})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/new/DuplicateNewPatientModal.tsx",
"diff": "+import { Modal, Alert } from '@hospitalrun/components'\n+import React from 'react'\n+import { Link } from 'react-router-dom'\n+\n+import useTranslator from '../../shared/hooks/useTranslator'\n+import Patient from '../../shared/model/Patient'\n+\n+interface Props {\n+ duplicatePatient?: Patient\n+ show: boolean\n+ toggle: () => void\n+ onCloseButtonClick: () => void\n+ onContinueButtonClick: () => void\n+}\n+\n+const DuplicateNewPatientModal = (props: Props) => {\n+ const { t } = useTranslator()\n+ const { duplicatePatient, show, toggle, onCloseButtonClick, onContinueButtonClick } = props\n+\n+ const body = (\n+ <>\n+ <Alert\n+ color=\"warning\"\n+ title={t('patients.warning')}\n+ message={t('patients.duplicatePatientWarning')}\n+ />\n+ <div className=\"row\">\n+ <div className=\"col-md-12\">\n+ {t('patients.possibleDuplicatePatient')}\n+ {duplicatePatient !== undefined &&\n+ Object.entries(duplicatePatient).map(([key, patient]) => (\n+ <li key={key.toString()}>\n+ <Link to={`/patients/${patient.id}`}>{patient.fullName}</Link>\n+ </li>\n+ ))}\n+ </div>\n+ </div>\n+ </>\n+ )\n+\n+ return (\n+ <Modal\n+ show={show}\n+ toggle={toggle}\n+ title={t('patients.newPatient')}\n+ body={body}\n+ closeButton={{\n+ children: t('actions.cancel'),\n+ color: 'danger',\n+ onClick: onCloseButtonClick,\n+ }}\n+ successButton={{\n+ children: t('actions.save'),\n+ color: 'success',\n+ onClick: onContinueButtonClick,\n+ }}\n+ />\n+ )\n+}\n+\n+export default DuplicateNewPatientModal\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/new/NewPatient.tsx",
"new_path": "src/patients/new/NewPatient.tsx",
"diff": "@@ -10,6 +10,8 @@ import Patient from '../../shared/model/Patient'\nimport { RootState } from '../../shared/store'\nimport GeneralInformation from '../GeneralInformation'\nimport { createPatient } from '../patient-slice'\n+import { isPossibleDuplicatePatient } from '../util/is-possible-duplicate-patient'\n+import DuplicateNewPatientModal from './DuplicateNewPatientModal'\nconst breadcrumbs = [\n{ i18nKey: 'patients.label', location: '/patients' },\n@@ -21,8 +23,18 @@ const NewPatient = () => {\nconst history = useHistory()\nconst dispatch = useDispatch()\nconst { createError } = useSelector((state: RootState) => state.patient)\n+ const { patients } = Object(useSelector((state: RootState) => state.patients))\nconst [patient, setPatient] = useState({} as Patient)\n+ const [duplicatePatient, setDuplicatePatient] = useState<Patient | undefined>(undefined)\n+ const [showDuplicateNewPatientModal, setShowDuplicateNewPatientModal] = useState<boolean>(false)\n+\n+ const testPatient = {\n+ givenName: 'Kelly',\n+ familyName: 'Clark',\n+ sex: 'female',\n+ dateOfBirth: '1963-01-09T05:00:00.000Z',\n+ } as Patient\nuseTitle(t('patients.newPatient'))\nuseAddBreadcrumbs(breadcrumbs, true)\n@@ -41,13 +53,39 @@ const NewPatient = () => {\n}\nconst onSave = () => {\n+ let duplicatePatients = []\n+ if (patients !== undefined) {\n+ duplicatePatients = patients.filter((existingPatient: any) =>\n+ isPossibleDuplicatePatient(patient, existingPatient),\n+ )\n+ }\n+\n+ if (duplicatePatients.length > 0) {\n+ setShowDuplicateNewPatientModal(true)\n+ setDuplicatePatient(duplicatePatients as Patient)\n+ } else {\ndispatch(createPatient(patient, onSuccessfulSave))\n}\n+ const testCase = [isPossibleDuplicatePatient(patient, testPatient)]\n+ if (testCase.length > 0) {\n+ return true\n+ }\n+ return false\n+ }\n+\nconst onPatientChange = (newPatient: Partial<Patient>) => {\nsetPatient(newPatient as Patient)\n}\n+ const createDuplicateNewPatient = () => {\n+ dispatch(createPatient(patient, onSuccessfulSave))\n+ }\n+\n+ const closeDuplicateNewPatientModal = () => {\n+ setShowDuplicateNewPatientModal(false)\n+ }\n+\nreturn (\n<div>\n<GeneralInformation\n@@ -66,6 +104,14 @@ const NewPatient = () => {\n</Button>\n</div>\n</div>\n+\n+ <DuplicateNewPatientModal\n+ duplicatePatient={duplicatePatient}\n+ show={showDuplicateNewPatientModal}\n+ toggle={closeDuplicateNewPatientModal}\n+ onContinueButtonClick={createDuplicateNewPatient}\n+ onCloseButtonClick={closeDuplicateNewPatientModal}\n+ />\n</div>\n)\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/util/is-possible-duplicate-patient.ts",
"diff": "+import Patient from '../../shared/model/Patient'\n+\n+export function isPossibleDuplicatePatient(newPatient: Patient, existingPatient: Patient) {\n+ return (\n+ newPatient.givenName === existingPatient.givenName &&\n+ newPatient.familyName === existingPatient.familyName &&\n+ newPatient.sex === existingPatient.sex &&\n+ newPatient.dateOfBirth === existingPatient.dateOfBirth\n+ )\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/locales/enUs/translations/patients/index.ts",
"new_path": "src/shared/locales/enUs/translations/patients/index.ts",
"diff": "export default {\npatients: {\nlabel: 'Patients',\n+ warning: 'Warning!',\npatientsList: 'Patients List',\nviewPatients: 'View Patients',\nviewPatient: 'View Patient',\n@@ -9,5 +10,8 @@ export default {\nsuccessfullyCreated: 'Successfully created patient',\nsuccessfullyAddedNote: 'Successfully added the new note',\nsuccessfullyAddedRelatedPerson: 'Successfully added a new related person',\n+ possibleDuplicatePatient: 'Possible duplicate patient:',\n+ duplicatePatientWarning:\n+ 'Patient with matching information found in database. Are you sure you want to create this patient?',\n},\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(new): warn about potential duplicate patient (#2187) (#2240) |
288,268 | 05.08.2020 12:16:06 | -36,000 | aa8e2ed5f1c49d37fff0e6e8f928814e23cd359d | fix: reset lab state when navigation from lab form | [
{
"change_type": "MODIFY",
"old_path": "src/labs/lab-slice.ts",
"new_path": "src/labs/lab-slice.ts",
"diff": "@@ -126,6 +126,12 @@ export const requestLab = (newLab: Lab, onSuccess?: (lab: Lab) => void): AppThun\n}\n}\n+export const resetLab = (): AppThunk => async (dispatch) => {\n+ const labRequestError: Error = {}\n+ dispatch(requestLabError(labRequestError))\n+ dispatch(fetchLabStart())\n+}\n+\nexport const cancelLab = (labToCancel: Lab, onSuccess?: (lab: Lab) => void): AppThunk => async (\ndispatch,\n) => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/labs/requests/NewLabRequest.tsx",
"new_path": "src/labs/requests/NewLabRequest.tsx",
"diff": "import { Typeahead, Label, Button, Alert } from '@hospitalrun/components'\n-import React, { useState } from 'react'\n+import React, { useState, useEffect } from 'react'\nimport { useDispatch, useSelector } from 'react-redux'\nimport { useHistory } from 'react-router-dom'\n@@ -12,7 +12,7 @@ import useTranslator from '../../shared/hooks/useTranslator'\nimport Lab from '../../shared/model/Lab'\nimport Patient from '../../shared/model/Patient'\nimport { RootState } from '../../shared/store'\n-import { requestLab } from '../lab-slice'\n+import { requestLab, resetLab } from '../lab-slice'\nconst NewLabRequest = () => {\nconst { t } = useTranslator()\n@@ -28,6 +28,10 @@ const NewLabRequest = () => {\nstatus: 'requested',\n})\n+ useEffect(() => {\n+ dispatch(resetLab())\n+ }, [dispatch])\n+\nconst breadcrumbs = [\n{\ni18nKey: 'labs.requests.new',\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix: reset lab state when navigation from lab form (#2268) |
288,286 | 04.08.2020 22:36:09 | 14,400 | a7b844183b1db9d9e6daf1e144170dc5d3dd6921 | feat(appointments): provide more information on listed appointments | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/appointments/AppointmentsList.test.tsx",
"new_path": "src/__tests__/patients/appointments/AppointmentsList.test.tsx",
"diff": "import * as components from '@hospitalrun/components'\n-import { mount, ReactWrapper } from 'enzyme'\n+import { Table } from '@hospitalrun/components'\n+import { mount } from 'enzyme'\nimport { createMemoryHistory } from 'history'\nimport React from 'react'\nimport { act } from 'react-dom/test-utils'\n@@ -59,17 +60,58 @@ const setup = (patient = expectedPatient, appointments = expectedAppointments) =\n}\ndescribe('AppointmentsList', () => {\n+ describe('Table', () => {\nit('should render a list of appointments', () => {\nconst wrapper = setup()\n- const listItems: ReactWrapper = wrapper.find(components.ListItem)\n- expect(listItems.length === 2).toBeTruthy()\n- expect(listItems.at(0).text()).toEqual(\n- new Date(expectedAppointments[0].startDateTime).toLocaleString(),\n+ const table = wrapper.find(Table)\n+ const columns = table.prop('columns')\n+ const actions = table.prop('actions') as any\n+\n+ expect(table).toHaveLength(1)\n+\n+ expect(columns[0]).toEqual(\n+ expect.objectContaining({\n+ label: 'scheduling.appointment.startDate',\n+ key: 'startDateTime',\n+ }),\n+ )\n+ expect(columns[1]).toEqual(\n+ expect.objectContaining({ label: 'scheduling.appointment.endDate', key: 'endDateTime' }),\n+ )\n+ expect(columns[2]).toEqual(\n+ expect.objectContaining({ label: 'scheduling.appointment.location', key: 'location' }),\n)\n- expect(listItems.at(1).text()).toEqual(\n- new Date(expectedAppointments[1].startDateTime).toLocaleString(),\n+ expect(columns[3]).toEqual(\n+ expect.objectContaining({ label: 'scheduling.appointment.type', key: 'type' }),\n)\n+\n+ expect(actions[0]).toEqual(expect.objectContaining({ label: 'actions.view' }))\n+ expect(table.prop('actionsHeaderText')).toEqual('actions.label')\n+ })\n+\n+ it('should navigate to appointment profile on appointment click', async () => {\n+ const wrapper = setup()\n+ const tr = wrapper.find('tr').at(1)\n+\n+ act(() => {\n+ const onClick = tr.find('button').at(0).prop('onClick') as any\n+ onClick({ stopPropagation: jest.fn() })\n+ })\n+\n+ expect(history.location.pathname).toEqual('/appointments/456')\n+ })\n+ })\n+\n+ describe('Empty list', () => {\n+ it('should render a warning message if there are no appointments', () => {\n+ const wrapper = setup(expectedPatient, [])\n+ const alert = wrapper.find(components.Alert)\n+\n+ expect(alert).toHaveLength(1)\n+ expect(alert.prop('title')).toEqual('patient.appointments.warning.noAppointments')\n+ expect(alert.prop('message')).toEqual('patient.appointments.addAppointmentAbove')\n+ })\n})\ndescribe('New appointment button', () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/appointments/AppointmentsList.tsx",
"new_path": "src/patients/appointments/AppointmentsList.tsx",
"diff": "-import { Button, List, ListItem, Container, Row } from '@hospitalrun/components'\n+import { Button, Table, Spinner, Alert } from '@hospitalrun/components'\n+import format from 'date-fns/format'\nimport React, { useEffect } from 'react'\nimport { useSelector, useDispatch } from 'react-redux'\nimport { useHistory } from 'react-router-dom'\n@@ -32,17 +33,6 @@ const AppointmentsList = (props: Props) => {\ndispatch(fetchPatientAppointments(patientId))\n}, [dispatch, patientId])\n- const list = (\n- // inline style added to pick up on newlines for string literal\n- <ul style={{ whiteSpace: 'pre-line' }}>\n- {appointments.map((a) => (\n- <ListItem action key={a.id} onClick={() => history.push(`/appointments/${a.id}`)}>\n- {new Date(a.startDateTime).toLocaleString()}\n- </ListItem>\n- ))}\n- </ul>\n- )\n-\nreturn (\n<>\n<div className=\"row\">\n@@ -59,13 +49,54 @@ const AppointmentsList = (props: Props) => {\n</div>\n</div>\n<br />\n- <Container>\n- <Row>\n- <List layout=\"flush\" style={{ width: '100%', marginTop: '10px', marginLeft: '-25px' }}>\n- {list}\n- </List>\n- </Row>\n- </Container>\n+ <div className=\"row\">\n+ <div className=\"col-md-12\">\n+ {appointments ? (\n+ appointments.length > 0 ? (\n+ <Table\n+ data={appointments}\n+ getID={(row) => row.id}\n+ onRowClick={(row) => history.push(`/appointments/${row.id}`)}\n+ columns={[\n+ {\n+ label: t('scheduling.appointment.startDate'),\n+ key: 'startDateTime',\n+ formatter: (row) =>\n+ row.startDateTime\n+ ? format(new Date(row.startDateTime), 'yyyy-MM-dd, hh:mm a')\n+ : '',\n+ },\n+ {\n+ label: t('scheduling.appointment.endDate'),\n+ key: 'endDateTime',\n+ formatter: (row) =>\n+ row.endDateTime\n+ ? format(new Date(row.endDateTime), 'yyyy-MM-dd, hh:mm a')\n+ : '',\n+ },\n+ { label: t('scheduling.appointment.location'), key: 'location' },\n+ { label: t('scheduling.appointment.type'), key: 'type' },\n+ ]}\n+ actionsHeaderText={t('actions.label')}\n+ actions={[\n+ {\n+ label: t('actions.view'),\n+ action: (row) => history.push(`/appointments/${row.id}`),\n+ },\n+ ]}\n+ />\n+ ) : (\n+ <Alert\n+ color=\"warning\"\n+ title={t('patient.appointments.warning.noAppointments')}\n+ message={t('patient.appointments.addAppointmentAbove')}\n+ />\n+ )\n+ ) : (\n+ <Spinner color=\"blue\" loading size={[10, 25]} type=\"ScaleLoader\" />\n+ )}\n+ </div>\n+ </div>\n</>\n)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/locales/enUs/translations/patient/index.ts",
"new_path": "src/shared/locales/enUs/translations/patient/index.ts",
"diff": "@@ -52,6 +52,10 @@ export default {\n},\nappointments: {\nnew: 'Add Appointment',\n+ warning: {\n+ noAppointments: 'No Appointments',\n+ },\n+ addAppointmentAbove: 'Add an appointment using the button above.',\n},\nallergies: {\nlabel: 'Allergies',\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(appointments): provide more information on listed appointments
Co-authored-by: Matteo Vivona <[email protected]>
Co-authored-by: Jack Meyer <[email protected]> |
288,415 | 05.08.2020 04:45:09 | -7,200 | 886163aafe30de2c66d41e0491600f00749ca682 | feat(patients): add no patients exist | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/list/ViewPatients.test.tsx",
"new_path": "src/__tests__/patients/list/ViewPatients.test.tsx",
"diff": "@@ -11,6 +11,7 @@ import { mocked } from 'ts-jest/utils'\nimport * as ButtonBarProvider from '../../../page-header/button-toolbar/ButtonBarProvider'\nimport ViewPatients from '../../../patients/list/ViewPatients'\nimport * as patientSlice from '../../../patients/patients-slice'\n+import NoPatientsExist from '../../../patients/view/NoPatientsExist'\nimport { UnpagedRequest } from '../../../shared/db/PageRequest'\nimport PatientRepository from '../../../shared/db/PatientRepository'\n@@ -35,12 +36,13 @@ describe('Patients', () => {\n},\n]\n- const setup = (isLoading?: boolean) => {\n+ const setup = (isLoading?: boolean, currentPatients = patients, count = patients.length) => {\nconst store = mockStore({\npatients: {\n- patients,\n+ patients: currentPatients,\nisLoading,\npageRequest: UnpagedRequest,\n+ count,\n},\n})\nreturn mount(\n@@ -80,6 +82,13 @@ describe('Patients', () => {\nexpect(wrapper.find(Spinner)).toHaveLength(1)\n})\n+ it('should render no patients exists when no patients exist', () => {\n+ const wrapper = setup(false, [], 0)\n+\n+ const addNewPatient = wrapper.find(NoPatientsExist)\n+ expect(addNewPatient).toHaveLength(1)\n+ })\n+\nit('should render a table of patients', () => {\nconst wrapper = setup()\n@@ -121,7 +130,10 @@ describe('Patients', () => {\ndescribe('search functionality', () => {\nbeforeEach(() => jest.useFakeTimers())\n- afterEach(() => jest.useRealTimers())\n+ afterEach(() => {\n+ jest.useRealTimers()\n+ jest.restoreAllMocks()\n+ })\nit('should search for patients after the search text has not changed for 500 milliseconds', () => {\nconst searchPatientsSpy = jest.spyOn(patientSlice, 'searchPatients')\n@@ -145,5 +157,25 @@ describe('Patients', () => {\nsorts: [{ field: 'index', direction: 'asc' }],\n})\n})\n+\n+ it(\"shound't display NoPatientsFound if a search result has no results\", () => {\n+ const searchPatientsSpy = jest.spyOn(patientSlice, 'searchPatients')\n+ const wrapper = setup()\n+ searchPatientsSpy.mockClear()\n+ const expectedSearchText = '$$$not a patient$$$'\n+\n+ act(() => {\n+ const onChange = wrapper.find(TextInput).prop('onChange') as any\n+ onChange({ target: { value: expectedSearchText } })\n+ })\n+\n+ act(() => {\n+ jest.advanceTimersByTime(500)\n+ })\n+\n+ wrapper.update()\n+\n+ expect(NoPatientsExist).toHaveLength(0)\n+ })\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/patients-slice.test.ts",
"new_path": "src/__tests__/patients/patients-slice.test.ts",
"diff": "@@ -81,7 +81,8 @@ describe('patients slice', () => {\nawait searchPatients('')(dispatch, getState, null)\n- expect(PatientRepository.findAll).toHaveBeenCalledTimes(1)\n+ // expecting 2 here because searchPatients uses PatientRepository.count() which calls #findAll\n+ expect(PatientRepository.findAll).toHaveBeenCalledTimes(2)\n})\nit('should dispatch the FETCH_PATIENTS_SUCCESS action', async () => {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/patients/view/NoPatientsExist.test.tsx",
"diff": "+import { Icon, Typography, Button } from '@hospitalrun/components'\n+import { mount } from 'enzyme'\n+import React from 'react'\n+\n+import NoPatientsExist from '../../../patients/view/NoPatientsExist'\n+\n+describe('NoPatientsExist', () => {\n+ const setup = () => mount(<NoPatientsExist />)\n+\n+ it('should render an icon and a button with typography', () => {\n+ const wrapper = setup()\n+\n+ const addNewPatient = wrapper.find(NoPatientsExist)\n+ expect(addNewPatient).toHaveLength(1)\n+\n+ const icon = wrapper.find(Icon).first()\n+ const typography = wrapper.find(Typography)\n+ const button = wrapper.find(Button)\n+ const iconType = icon.prop('icon')\n+ const iconSize = icon.prop('size')\n+ const typographyText = typography.prop('children')\n+ const typographyVariant = typography.prop('variant')\n+ const buttonIcon = button.prop('icon')\n+ const buttonText = button.prop('children')\n+\n+ expect(iconType).toEqual('patients')\n+ expect(iconSize).toEqual('6x')\n+ expect(typographyText).toEqual('patients.noPatients')\n+ expect(typographyVariant).toEqual('h5')\n+ expect(buttonIcon).toEqual('patient-add')\n+ expect(buttonText).toEqual('patients.newPatient')\n+ })\n+})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/list/ViewPatients.tsx",
"new_path": "src/patients/list/ViewPatients.tsx",
"diff": "@@ -13,6 +13,7 @@ import useTranslator from '../../shared/hooks/useTranslator'\nimport useUpdateEffect from '../../shared/hooks/useUpdateEffect'\nimport { RootState } from '../../shared/store'\nimport { searchPatients } from '../patients-slice'\n+import NoPatientsExist from '../view/NoPatientsExist'\nconst breadcrumbs = [{ i18nKey: 'patients.label', location: '/patients' }]\n@@ -22,7 +23,7 @@ const ViewPatients = () => {\nuseTitle(t('patients.label'))\nuseAddBreadcrumbs(breadcrumbs, true)\nconst dispatch = useDispatch()\n- const { patients, isLoading } = useSelector((state: RootState) => state.patients)\n+ const { patients, isLoading, count } = useSelector((state: RootState) => state.patients)\nconst setButtonToolBar = useButtonToolbarSetter()\n@@ -48,6 +49,7 @@ const ViewPatients = () => {\n}, [dispatch, debouncedSearchText])\nuseEffect(() => {\n+ if (patients && patients.length > 0) {\nsetButtonToolBar([\n<Button\nkey=\"newPatientButton\"\n@@ -59,11 +61,11 @@ const ViewPatients = () => {\n{t('patients.newPatient')}\n</Button>,\n])\n-\n+ }\nreturn () => {\nsetButtonToolBar([])\n}\n- }, [dispatch, setButtonToolBar, t, history])\n+ }, [dispatch, setButtonToolBar, t, history, patients])\nconst loadingIndicator = <Spinner color=\"blue\" loading size={[10, 25]} type=\"ScaleLoader\" />\nconst table = (\n@@ -91,6 +93,10 @@ const ViewPatients = () => {\nsetSearchText(event.target.value)\n}\n+ if (count === 0) {\n+ return <NoPatientsExist />\n+ }\n+\nreturn (\n<div>\n<Container>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/patients-slice.ts",
"new_path": "src/patients/patients-slice.ts",
"diff": "@@ -8,11 +8,13 @@ import { AppThunk } from '../shared/store'\ninterface PatientsState {\nisLoading: boolean\npatients: Patient[]\n+ count: number\n}\nconst initialState: PatientsState = {\nisLoading: false,\npatients: [],\n+ count: 0,\n}\nfunction startLoading(state: PatientsState) {\n@@ -28,9 +30,13 @@ const patientsSlice = createSlice({\nstate.isLoading = false\nstate.patients = payload\n},\n+ fetchCountSuccess(state, { payload }: PayloadAction<number>) {\n+ state.count = payload\n+ },\n},\n})\n-export const { fetchPatientsStart, fetchPatientsSuccess } = patientsSlice.actions\n+\n+export const { fetchPatientsStart, fetchPatientsSuccess, fetchCountSuccess } = patientsSlice.actions\nexport const fetchPatients = (sortRequest: SortRequest = Unsorted): AppThunk => async (\ndispatch,\n@@ -53,7 +59,8 @@ export const searchPatients = (\n} else {\npatients = await PatientRepository.search(searchString)\n}\n-\n+ const count = await PatientRepository.count()\n+ dispatch(fetchCountSuccess(count))\ndispatch(fetchPatientsSuccess(patients))\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/view/NoPatientsExist.tsx",
"diff": "+import { Button, Icon, Typography } from '@hospitalrun/components'\n+import React from 'react'\n+import { useHistory } from 'react-router-dom'\n+\n+import useTranslator from '../../shared/hooks/useTranslator'\n+\n+const NoPatientsExist = () => {\n+ const history = useHistory()\n+ const { t } = useTranslator()\n+\n+ return (\n+ <div style={{ display: 'flex', justifyContent: 'center' }}>\n+ <div style={{ display: 'flex', flexDirection: 'column' }}>\n+ <div style={{ display: 'flex', justifyContent: 'center' }}>\n+ <Icon icon=\"patients\" outline={false} size=\"6x\" />\n+ </div>\n+ <div style={{ display: 'flex', justifyContent: 'center' }}>\n+ <div style={{ textAlign: 'center', width: '60%', margin: 16 }}>\n+ <Typography variant=\"h5\">{t('patients.noPatients')}</Typography>\n+ </div>\n+ </div>\n+ <div style={{ display: 'flex', justifyContent: 'center' }}>\n+ <Button\n+ key=\"newPatientButton\"\n+ outlined\n+ color=\"primary\"\n+ icon=\"patient-add\"\n+ onClick={() => history.push('/patients/new')}\n+ >\n+ {t('patients.newPatient')}\n+ </Button>\n+ </div>\n+ </div>\n+ </div>\n+ )\n+}\n+\n+export default NoPatientsExist\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/db/Repository.ts",
"new_path": "src/shared/db/Repository.ts",
"diff": "@@ -132,6 +132,11 @@ export default class Repository<T extends AbstractDBModel> {\n// return pagedResult\n// }\n+ async count(): Promise<number> {\n+ const result = await this.findAll()\n+ return result.length\n+ }\n+\nasync search(criteria: any): Promise<T[]> {\nconst response = await this.db.find(criteria)\nconst data = await this.db.rel.parseRelDocs(this.type, response.docs)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/locales/enUs/translations/patients/index.ts",
"new_path": "src/shared/locales/enUs/translations/patients/index.ts",
"diff": "@@ -4,6 +4,7 @@ export default {\nwarning: 'Warning!',\npatientsList: 'Patients List',\nviewPatients: 'View Patients',\n+ noPatients: \"There are no patients yet, let's add the first one!\",\nviewPatient: 'View Patient',\nnewPatient: 'New Patient',\neditPatient: 'Edit Patient',\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(patients): add no patients exist (#2235) |
288,323 | 30.07.2020 23:47:35 | 18,000 | 9ee2ed83b664657934b1c0f3e837bc7d823dcfdb | chore: add tests for new incident hooks | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/incidents/hooks/useIncident.test.tsx",
"diff": "+import { renderHook, act } from '@testing-library/react-hooks'\n+\n+import useIncident from '../../../incidents/hooks/useIncident'\n+import IncidentRepository from '../../../shared/db/IncidentRepository'\n+import Incident from '../../../shared/model/Incident'\n+import waitUntilQueryIsSuccessful from '../../wait-for-query-test-util'\n+\n+describe('useIncident', () => {\n+ it('should get an incident by id', async () => {\n+ const expectedIncidentId = 'some id'\n+ const expectedIncident = {\n+ id: expectedIncidentId,\n+ } as Incident\n+ jest.spyOn(IncidentRepository, 'find').mockResolvedValue(expectedIncident)\n+\n+ let actualData: any\n+ await act(async () => {\n+ const renderHookResult = renderHook(() => useIncident(expectedIncidentId))\n+ const { result } = renderHookResult\n+ await waitUntilQueryIsSuccessful(renderHookResult)\n+ actualData = result.current.data\n+ })\n+\n+ expect(IncidentRepository.find).toHaveBeenCalledTimes(1)\n+ expect(IncidentRepository.find).toBeCalledWith(expectedIncidentId)\n+ expect(actualData).toEqual(expectedIncident)\n+ })\n+})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/incidents/hooks/useIncidents.test.tsx",
"diff": "+import { act, renderHook } from '@testing-library/react-hooks'\n+\n+import useIncidents from '../../../incidents/hooks/useIncidents'\n+import IncidentFilter from '../../../incidents/IncidentFilter'\n+import IncidentSearchRequest from '../../../incidents/model/IncidentSearchRequest'\n+import IncidentRepository from '../../../shared/db/IncidentRepository'\n+import Incident from '../../../shared/model/Incident'\n+import waitUntilQueryIsSuccessful from '../../wait-for-query-test-util'\n+\n+describe('useIncidents', () => {\n+ it('it should search incidents', async () => {\n+ const expectedSearchRequest: IncidentSearchRequest = {\n+ status: IncidentFilter.all,\n+ }\n+ const expectedIncidents = [\n+ {\n+ id: 'some id',\n+ },\n+ ] as Incident[]\n+ jest.spyOn(IncidentRepository, 'search').mockResolvedValue(expectedIncidents)\n+\n+ let actualData: any\n+ await act(async () => {\n+ const renderHookResult = renderHook(() => useIncidents(expectedSearchRequest))\n+ const { result } = renderHookResult\n+ await waitUntilQueryIsSuccessful(renderHookResult)\n+ actualData = result.current.data\n+ })\n+\n+ expect(IncidentRepository.search).toHaveBeenCalledTimes(1)\n+ expect(IncidentRepository.search).toBeCalledWith(expectedSearchRequest)\n+ expect(actualData).toEqual(expectedIncidents)\n+ })\n+})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/incidents/hooks/useReportIncident.test.tsx",
"diff": "+import { act, renderHook } from '@testing-library/react-hooks'\n+import { subDays } from 'date-fns'\n+import shortid from 'shortid'\n+\n+import useReportIncident from '../../../incidents/hooks/useReportIncident'\n+import * as incidentValidator from '../../../incidents/util/validate-incident'\n+import { IncidentError } from '../../../incidents/util/validate-incident'\n+import IncidentRepository from '../../../shared/db/IncidentRepository'\n+import Incident from '../../../shared/model/Incident'\n+\n+describe('useReportIncident', () => {\n+ beforeEach(() => {\n+ jest.restoreAllMocks()\n+ })\n+\n+ it('should save the incident with correct data', async () => {\n+ const expectedCode = '123456'\n+ const expectedDate = new Date(Date.now())\n+ const expectedStatus = 'reported'\n+ const expectedReportedBy = 'some user'\n+ Date.now = jest.fn().mockReturnValue(expectedDate)\n+\n+ const givenIncidentRequest = {\n+ category: 'some category',\n+ categoryItem: 'some category item',\n+ date: subDays(new Date(), 3).toISOString(),\n+ department: 'some department',\n+ description: 'some description',\n+ } as Incident\n+\n+ const expectedIncident = {\n+ ...givenIncidentRequest,\n+ code: `I-${expectedCode}`,\n+ reportedOn: expectedDate.toISOString(),\n+ status: expectedStatus,\n+ reportedBy: expectedReportedBy,\n+ } as Incident\n+ jest.spyOn(shortid, 'generate').mockReturnValue(expectedCode)\n+ jest.spyOn(IncidentRepository, 'save').mockResolvedValue(expectedIncident)\n+\n+ let mutateToTest: any\n+ await act(async () => {\n+ const renderHookResult = renderHook(() => useReportIncident())\n+ const { result, waitForNextUpdate } = renderHookResult\n+ await waitForNextUpdate()\n+ const [mutate] = result.current\n+ mutateToTest = mutate\n+ })\n+\n+ let actualData: any\n+ await act(async () => {\n+ const result = await mutateToTest(givenIncidentRequest)\n+ actualData = result\n+ })\n+\n+ expect(IncidentRepository.save).toHaveBeenCalledTimes(1)\n+ expect(IncidentRepository.save).toBeCalledWith(expectedIncident)\n+ expect(actualData).toEqual(expectedIncident)\n+ })\n+\n+ it('should throw an error if validation fails', async () => {\n+ const expectedIncidentError = {\n+ description: 'some description error',\n+ } as IncidentError\n+\n+ jest.spyOn(incidentValidator, 'default').mockReturnValue(expectedIncidentError)\n+ jest.spyOn(IncidentRepository, 'save').mockResolvedValue({} as Incident)\n+\n+ let mutateToTest: any\n+ await act(async () => {\n+ const renderHookResult = renderHook(() => useReportIncident())\n+ const { result, waitForNextUpdate } = renderHookResult\n+ await waitForNextUpdate()\n+ const [mutate] = result.current\n+ mutateToTest = mutate\n+ })\n+\n+ try {\n+ await act(async () => {\n+ await mutateToTest({} as Incident)\n+ })\n+ } catch (e) {\n+ expect(e).toEqual(expectedIncidentError)\n+ expect(IncidentRepository.save).not.toHaveBeenCalled()\n+ }\n+ })\n+})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/incidents/hooks/useResolvedIncident.test.tsx",
"diff": "+import { act, renderHook } from '@testing-library/react-hooks'\n+import { subDays } from 'date-fns'\n+\n+import useResolveIncident from '../../../incidents/hooks/useResolveIncident'\n+import IncidentRepository from '../../../shared/db/IncidentRepository'\n+import Incident from '../../../shared/model/Incident'\n+\n+describe('useResolvedIncident', () => {\n+ it('should mark incident as resolved and save', async () => {\n+ const expectedStatus = 'resolved'\n+ const expectedResolvedDate = new Date(Date.now())\n+ Date.now = jest.fn().mockReturnValue(expectedResolvedDate)\n+\n+ const givenIncident = {\n+ category: 'some category',\n+ categoryItem: 'some category item',\n+ date: subDays(new Date(), 3).toISOString(),\n+ department: 'some department',\n+ description: 'some description',\n+ status: 'reported',\n+ code: 'I-some-code',\n+ reportedOn: subDays(new Date(), 2).toISOString(),\n+ reportedBy: 'some user',\n+ } as Incident\n+\n+ const expectedIncident = {\n+ ...givenIncident,\n+ resolvedOn: expectedResolvedDate.toISOString(),\n+ status: expectedStatus,\n+ } as Incident\n+ jest.spyOn(IncidentRepository, 'save').mockResolvedValue(expectedIncident)\n+\n+ let mutateToTest: any\n+ await act(async () => {\n+ const renderHookResult = renderHook(() => useResolveIncident())\n+ const { result, waitForNextUpdate } = renderHookResult\n+ await waitForNextUpdate()\n+ const [mutate] = result.current\n+ mutateToTest = mutate\n+ })\n+\n+ let actualData: any\n+ await act(async () => {\n+ const result = await mutateToTest(givenIncident)\n+ actualData = result\n+ })\n+\n+ expect(IncidentRepository.save).toHaveBeenCalledTimes(1)\n+ expect(IncidentRepository.save).toBeCalledWith(expectedIncident)\n+ expect(actualData).toEqual(expectedIncident)\n+ })\n+})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/wait-for-query-test-util.ts",
"diff": "+const isQuerySuccessful = (queryResult: any) => queryResult && queryResult.status === 'success'\n+const waitUntilQueryIsSuccessful = (renderHookResult: any) =>\n+ renderHookResult.waitFor(() => isQuerySuccessful(renderHookResult.result.current), {\n+ timeout: 1000,\n+ })\n+\n+export default waitUntilQueryIsSuccessful\n"
},
{
"change_type": "MODIFY",
"old_path": "src/incidents/hooks/useReportIncident.tsx",
"new_path": "src/incidents/hooks/useReportIncident.tsx",
"diff": "@@ -14,6 +14,7 @@ function reportIncident(incident: Incident): Promise<Incident> {\nconst updatedIncident: Incident = {\n...incident,\ncode: getIncidentCode(),\n+ status: 'reported',\nreportedBy: 'some user',\nreportedOn: new Date(Date.now()).toISOString(),\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | chore: add tests for new incident hooks |
288,323 | 09.08.2020 16:14:55 | 18,000 | c70614320c4f02751bedee684199eebf72ec0a34 | chore: add usePatientRelatedPersons hook | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/patients/hooks/usePatientRelatedPersons.test.tsx",
"diff": "+import { act, renderHook } from '@testing-library/react-hooks'\n+\n+import usePatientRelatedPersons from '../../../patients/hooks/usePatientRelatedPersons'\n+import PatientRepository from '../../../shared/db/PatientRepository'\n+import Patient from '../../../shared/model/Patient'\n+import waitUntilQueryIsSuccessful from '../../wait-for-query-test-util'\n+\n+describe('use patient related persons', () => {\n+ beforeEach(() => {\n+ jest.clearAllMocks()\n+ })\n+\n+ it('should get the patient by id', async () => {\n+ const expectedPatientId = 'currentPatientId'\n+ const expectedRelatedPatientId = 'patientId'\n+ const expectedRelatedPersonPatientDetails = {\n+ id: expectedRelatedPatientId,\n+ givenName: 'test',\n+ } as Patient\n+ jest\n+ .spyOn(PatientRepository, 'find')\n+ .mockResolvedValueOnce({\n+ id: expectedPatientId,\n+ relatedPersons: [\n+ { id: 'relatedPersonId', patientId: expectedRelatedPatientId, type: 'test' },\n+ ],\n+ } as Patient)\n+ .mockResolvedValueOnce(expectedRelatedPersonPatientDetails)\n+\n+ let actualData: any\n+ await act(async () => {\n+ const renderHookResult = renderHook(() => usePatientRelatedPersons(expectedPatientId))\n+ await waitUntilQueryIsSuccessful(renderHookResult)\n+ const { result } = renderHookResult\n+ actualData = result.current.data\n+ })\n+\n+ expect(PatientRepository.find).toHaveBeenNthCalledWith(1, expectedPatientId)\n+ expect(PatientRepository.find).toHaveBeenNthCalledWith(2, expectedRelatedPatientId)\n+ expect(actualData).toEqual([{ ...expectedRelatedPersonPatientDetails, type: 'test' }])\n+ })\n+})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/hooks/usePatientRelatedPersons.tsx",
"diff": "+import { useQuery } from 'react-query'\n+\n+import PatientRepository from '../../shared/db/PatientRepository'\n+import Patient from '../../shared/model/Patient'\n+\n+interface RelatedPersonsResult extends Patient {\n+ type: string\n+}\n+\n+async function fetchPatientRelatedPersons(\n+ _: any,\n+ patientId: string,\n+): Promise<RelatedPersonsResult[]> {\n+ const patient = await PatientRepository.find(patientId)\n+ const relatedPersons = patient.relatedPersons || []\n+ const result = await Promise.all(\n+ relatedPersons.map(async (person) => {\n+ const fetchedRelatedPerson = await PatientRepository.find(person.patientId)\n+ return { ...fetchedRelatedPerson, type: person.type }\n+ }),\n+ )\n+\n+ return result\n+}\n+\n+export default function usePatientRelatedPersons(patientId: string) {\n+ return useQuery(['related-persons', patientId], fetchPatientRelatedPersons)\n+}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | chore: add usePatientRelatedPersons hook |
288,323 | 09.08.2020 16:23:09 | 18,000 | c4f1e09fb9f8cb52fb526eb9f15106d090c4a35e | chore: add user query test util | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"react-bootstrap-typeahead\": \"~5.1.0\",\n\"react-dom\": \"~16.13.0\",\n\"react-i18next\": \"~11.7.0\",\n- \"react-query\": \"~2.5.6\",\n+ \"react-query\": \"~2.5.13\",\n\"react-query-devtools\": \"~2.3.2\",\n\"react-redux\": \"~7.2.0\",\n\"react-router\": \"~5.2.0\",\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/patients/use-query-test-util.ts",
"diff": "+import { act, renderHook } from '@testing-library/react-hooks'\n+\n+import waitUntilQueryIsSuccessful from '../wait-for-query-test-util'\n+\n+export default async function executeQuery(callback: any) {\n+ let actualData: any\n+ await act(async () => {\n+ const renderHookResult = renderHook(callback)\n+ const { result } = renderHookResult\n+ await waitUntilQueryIsSuccessful(renderHookResult)\n+ actualData = (result as any).current.data\n+ })\n+\n+ return actualData\n+}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | chore: add user query test util |
288,323 | 09.08.2020 16:30:15 | 18,000 | 32e4322f6aa414e2aea3e07e412826bfef687b18 | chore: add tests for use patient | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/patients/hooks/usePatient.test.tsx",
"diff": "+import usePatient from '../../../patients/hooks/usePatient'\n+import PatientRepository from '../../../shared/db/PatientRepository'\n+import Patient from '../../../shared/model/Patient'\n+import executeQuery from '../use-query-test-util'\n+\n+describe('use patient', () => {\n+ it('should return the patient', async () => {\n+ const expectedPatientId = '123'\n+ const expectedPatient = { id: expectedPatientId, givenName: 'test' } as Patient\n+ jest.spyOn(PatientRepository, 'find').mockResolvedValueOnce(expectedPatient)\n+\n+ const actualPatient = await executeQuery(() => usePatient(expectedPatientId))\n+\n+ expect(PatientRepository.find).toHaveBeenCalledTimes(1)\n+ expect(PatientRepository.find).toHaveBeenCalledWith(expectedPatientId)\n+ expect(actualPatient).toEqual(expectedPatient)\n+ })\n+})\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | chore: add tests for use patient |
288,323 | 09.08.2020 16:30:34 | 18,000 | 5e8284fa0ad1f34db46870c9554594d1f8ed5fb9 | chore: add tests for use patients | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/patients/hooks/usePatients.test.tsx",
"diff": "+import usePatients from '../../../patients/hooks/usePatients'\n+import PatientSearchRequest from '../../../patients/models/PatientSearchRequest'\n+import PatientRepository from '../../../shared/db/PatientRepository'\n+import Patient from '../../../shared/model/Patient'\n+import executeQuery from '../use-query-test-util'\n+\n+describe('use patients', () => {\n+ it('should search patients with the proper search request', async () => {\n+ const expectedPatientTotalCount = 1\n+ const expectedSearchRequest = { queryString: 'someQueryString' } as PatientSearchRequest\n+ const expectedPatients = [{ id: '123', givenName: 'test' }] as Patient[]\n+ jest.spyOn(PatientRepository, 'search').mockResolvedValueOnce(expectedPatients)\n+ jest.spyOn(PatientRepository, 'count').mockResolvedValueOnce(expectedPatientTotalCount)\n+\n+ const actualPatients = await executeQuery(() => usePatients(expectedSearchRequest))\n+\n+ expect(PatientRepository.search).toHaveBeenCalledTimes(1)\n+ expect(PatientRepository.search).toHaveBeenCalledWith(expectedSearchRequest.queryString)\n+ expect(actualPatients).toEqual({\n+ patients: expectedPatients,\n+ totalCount: expectedPatientTotalCount,\n+ })\n+ })\n+})\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | chore: add tests for use patients |
288,323 | 09.08.2020 16:31:43 | 18,000 | 1d13532b689cc1b70ce8f76736f65107fb3eb451 | chore: add hooks for use patient and use patients | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/hooks/usePatient.tsx",
"diff": "+import { useQuery } from 'react-query'\n+\n+import PatientRepository from '../../shared/db/PatientRepository'\n+import Patient from '../../shared/model/Patient'\n+\n+function fetchPatient(_: any, id: string): Promise<Patient> {\n+ return PatientRepository.find(id)\n+}\n+\n+export default function usePatient(id: string) {\n+ return useQuery(['patient', id], fetchPatient)\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/hooks/usePatients.tsx",
"diff": "+import { useQuery } from 'react-query'\n+\n+import PatientRepository from '../../shared/db/PatientRepository'\n+import Patient from '../../shared/model/Patient'\n+import PatientSearchRequest from '../models/PatientSearchRequest'\n+\n+interface PatientsResult {\n+ totalCount: number\n+ patients: Patient[]\n+}\n+\n+async function fetchPatients(_: any, searchRequest: PatientSearchRequest): Promise<PatientsResult> {\n+ const patients = await PatientRepository.search(searchRequest.queryString)\n+ const totalCount = await PatientRepository.count()\n+ return { totalCount, patients }\n+}\n+\n+export default function usePatients(searchRequest: PatientSearchRequest) {\n+ return useQuery(['patients', searchRequest], fetchPatients)\n+}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | chore: add hooks for use patient and use patients |
288,323 | 09.08.2020 17:22:26 | 18,000 | 24c45bc4919e4c0c088f38f744a0bd03014b7d3a | feat(loading): add shared loading component | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/shared/components/Loading.tsx",
"diff": "+import { Spinner } from '@hospitalrun/components'\n+import React from 'react'\n+\n+const Loading = () => <Spinner color=\"blue\" loading size={20} type=\"BeatLoader\" />\n+\n+export default Loading\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(loading): add shared loading component |
288,271 | 10.08.2020 03:39:49 | 14,400 | 9b34904252c8ccbc479abbdecd6f3f0ba40bcbd3 | fix(use effect line to newlabrequest.tsx): added use effect | [
{
"change_type": "MODIFY",
"old_path": "src/labs/requests/NewLabRequest.tsx",
"new_path": "src/labs/requests/NewLabRequest.tsx",
"diff": "-\nimport { Typeahead, Label, Button, Alert, Toast } from '@hospitalrun/components'\n-import React, { useState } from 'react'\n+import React, { useState, useEffect } from 'react'\nimport { useDispatch, useSelector } from 'react-redux'\nimport { useHistory } from 'react-router-dom'\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(use effect line to newlabrequest.tsx): added use effect |
288,323 | 10.08.2020 17:36:39 | 18,000 | c4c2631ec0816b66069f2d0509c6b89e1b076104 | chore: ignore test utils | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"build\": \"react-scripts build\",\n\"update\": \"npx npm-check -u\",\n\"prepublishOnly\": \"npm run build\",\n- \"test\": \"npm run translation:check && react-scripts test --detectOpenHandles\",\n- \"test:ci\": \"cross-env CI=true react-scripts test --passWithNoTests\",\n+ \"test\": \"npm run translation:check && react-scripts test --detectOpenHandles --testPathIgnorePatterns=src/__tests__/test-utils\",\n+ \"test:ci\": \"cross-env CI=true react-scripts test --passWithNoTests --testPathIgnorePatterns=src/__tests__/test-utils\",\n\"lint\": \"eslint \\\"src/**/*.{js,jsx,ts,tsx}\\\" \\\"scripts/check-translations/**/*.{js,ts}\\\"\",\n\"lint:fix\": \"eslint \\\"src/**/*.{js,jsx,ts,tsx}\\\" \\\"scripts/check-translations/**/*.{js,ts}\\\" --fix\",\n\"lint-staged\": \"lint-staged\",\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | chore: ignore test utils |
288,323 | 10.08.2020 18:59:52 | 18,000 | fddd63a991db4a18ff57970a4bf56ee6c0a86678 | chore(allergies): add hook for getting patient allergies | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/patients/hooks/usePatientAllergies.test.tsx",
"diff": "+import usePatientAllergies from '../../../patients/hooks/usePatientAllergies'\n+import PatientRepository from '../../../shared/db/PatientRepository'\n+import Patient from '../../../shared/model/Patient'\n+import executeQuery from '../../test-utils/use-query.util'\n+\n+describe('use patient allergies', () => {\n+ it('should get patient allergies', async () => {\n+ const expectedPatientId = '123'\n+ const expectedAllergies = [{ id: expectedPatientId, name: 'allergy name' }]\n+ jest.spyOn(PatientRepository, 'find').mockResolvedValueOnce({\n+ id: expectedPatientId,\n+ allergies: expectedAllergies,\n+ } as Patient)\n+\n+ const actualAllergies = await executeQuery(() => usePatientAllergies(expectedPatientId))\n+\n+ expect(PatientRepository.find).toHaveBeenCalledWith(expectedPatientId)\n+ expect(actualAllergies).toEqual(expectedAllergies)\n+ })\n+})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/hooks/usePatientAllergies.tsx",
"diff": "+import { QueryKey, useQuery } from 'react-query'\n+\n+import PatientRepository from '../../shared/db/PatientRepository'\n+import Allergy from '../../shared/model/Allergy'\n+\n+async function fetchPatientAllergies(_: QueryKey<string>, patientId: string): Promise<Allergy[]> {\n+ const patient = await PatientRepository.find(patientId)\n+ return patient.allergies || []\n+}\n+\n+export default function usePatientAllergies(patientId: string) {\n+ return useQuery(['allergies', patientId], fetchPatientAllergies)\n+}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | chore(allergies): add hook for getting patient allergies |
288,323 | 10.08.2020 20:03:00 | 18,000 | 08fff6f9e345368c166adb578b19e2a1b801f3b7 | fix(patients): fix infinite loop in patients search | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/search/PatientSearchInput.test.tsx",
"new_path": "src/__tests__/patients/search/PatientSearchInput.test.tsx",
"diff": "@@ -7,35 +7,27 @@ import PatientSearchRequest from '../../../patients/models/PatientSearchRequest'\nimport PatientSearchInput from '../../../patients/search/PatientSearchInput'\ndescribe('Patient Search Input', () => {\n- const setup = (\n- expectedSearchRequest: PatientSearchRequest,\n- onChange: (s: PatientSearchRequest) => void,\n- ) => {\n- const wrapper = mount(\n- <PatientSearchInput searchRequest={expectedSearchRequest} onChange={onChange} />,\n- )\n+ const setup = (onChange: (s: PatientSearchRequest) => void) => {\n+ const wrapper = mount(<PatientSearchInput onChange={onChange} />)\nreturn { wrapper }\n}\nit('should render a text box', () => {\n- const expectedSearchRequest = { queryString: 'someValue' }\n- const { wrapper } = setup(expectedSearchRequest, jest.fn())\n+ const { wrapper } = setup(jest.fn())\nconst textInput = wrapper.find(TextInput)\nexpect(wrapper.exists(TextInput)).toBeTruthy()\nexpect(textInput.prop('size')).toEqual('lg')\nexpect(textInput.prop('type')).toEqual('text')\n- expect(textInput.prop('value')).toEqual(expectedSearchRequest.queryString)\nexpect(textInput.prop('placeholder')).toEqual('actions.search')\n})\nit('should call the on change function when the search input changes after debounce time', () => {\njest.useFakeTimers()\nconst expectedNewQueryString = 'some new query string'\n- const expectedSearchRequest = { queryString: 'someValue' }\nconst onChangeSpy = jest.fn()\n- const { wrapper } = setup(expectedSearchRequest, onChangeSpy)\n+ const { wrapper } = setup(onChangeSpy)\nact(() => {\nconst textInput = wrapper.find(TextInput)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/search/PatientSearchInput.tsx",
"new_path": "src/patients/search/PatientSearchInput.tsx",
"diff": "@@ -6,23 +6,21 @@ import useTranslator from '../../shared/hooks/useTranslator'\nimport PatientSearchRequest from '../models/PatientSearchRequest'\ninterface Props {\n- searchRequest: PatientSearchRequest\nonChange: (searchRequest: PatientSearchRequest) => void\n}\nconst PatientSearchInput = (props: Props) => {\n- const { onChange, searchRequest } = props\n+ const { onChange } = props\nconst { t } = useTranslator()\n- const [searchText, setSearchText] = useState<string>(searchRequest.queryString)\n+ const [searchText, setSearchText] = useState<string>('')\nconst debouncedSearchText = useDebounce(searchText, 500)\nuseEffect(() => {\nonChange({\n- ...searchRequest,\nqueryString: debouncedSearchText,\n})\n- }, [debouncedSearchText, onChange, searchRequest])\n+ }, [debouncedSearchText, onChange])\nconst onSearchBoxChange = (event: React.ChangeEvent<HTMLInputElement>) => {\nconst queryString = event.currentTarget.value\n@@ -34,7 +32,7 @@ const PatientSearchInput = (props: Props) => {\nsize=\"lg\"\ntype=\"text\"\nonChange={onSearchBoxChange}\n- value={searchRequest.queryString}\n+ value={searchText}\nplaceholder={t('actions.search')}\n/>\n)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/search/SearchPatients.tsx",
"new_path": "src/patients/search/SearchPatients.tsx",
"diff": "import { Column, Container, Row } from '@hospitalrun/components'\n-import React, { useState } from 'react'\n+import React, { useCallback, useState } from 'react'\nimport PatientSearchRequest from '../models/PatientSearchRequest'\nimport PatientSearchInput from './PatientSearchInput'\n@@ -8,16 +8,16 @@ import ViewPatientsTable from './ViewPatientsTable'\nconst SearchPatients = () => {\nconst [searchRequest, setSearchRequest] = useState<PatientSearchRequest>({ queryString: '' })\n- const onSearchRequestChange = (newSearchRequest: PatientSearchRequest) => {\n+ const onSearchRequestChange = useCallback((newSearchRequest: PatientSearchRequest) => {\nsetSearchRequest(newSearchRequest)\n- }\n+ }, [])\nreturn (\n<div>\n<Container>\n<Row>\n<Column md={12}>\n- <PatientSearchInput searchRequest={searchRequest} onChange={onSearchRequestChange} />\n+ <PatientSearchInput onChange={onSearchRequestChange} />\n</Column>\n</Row>\n<Row>\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(patients): fix infinite loop in patients search |
288,323 | 11.08.2020 00:22:29 | 18,000 | aba1a8360b8629dbea8386bb796137d23680ea38 | chore(allergies): refactor allergy data fetch to use react-query | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/allergies/Allergies.test.tsx",
"new_path": "src/__tests__/patients/allergies/Allergies.test.tsx",
"diff": "import * as components from '@hospitalrun/components'\n-import { act } from '@testing-library/react'\nimport { mount } from 'enzyme'\nimport { createMemoryHistory } from 'history'\nimport React from 'react'\n+import { act } from 'react-dom/test-utils'\nimport { Provider } from 'react-redux'\nimport { Router } from 'react-router-dom'\nimport createMockStore from 'redux-mock-store'\n@@ -28,20 +28,24 @@ const expectedPatient = {\nlet store: any\n-const setup = (\n+const setup = async (\npatient = expectedPatient,\npermissions = [Permissions.AddAllergy],\nroute = '/patients/123/allergies',\n) => {\nstore = mockStore({ patient: { patient }, user: { permissions } } as any)\nhistory.push(route)\n- const wrapper = mount(\n+\n+ let wrapper: any\n+ await act(async () => {\n+ wrapper = await mount(\n<Router history={history}>\n<Provider store={store}>\n<Allergies patient={patient} />\n</Provider>\n</Router>,\n)\n+ })\nreturn wrapper\n}\n@@ -49,27 +53,28 @@ const setup = (\ndescribe('Allergies', () => {\nbeforeEach(() => {\njest.resetAllMocks()\n+ jest.spyOn(PatientRepository, 'find').mockResolvedValue(expectedPatient)\njest.spyOn(PatientRepository, 'saveOrUpdate')\n})\ndescribe('add new allergy button', () => {\n- it('should render a button to add new allergies', () => {\n- const wrapper = setup()\n+ it('should render a button to add new allergies', async () => {\n+ const wrapper = await setup()\nconst addAllergyButton = wrapper.find(components.Button)\nexpect(addAllergyButton).toHaveLength(1)\nexpect(addAllergyButton.text().trim()).toEqual('patient.allergies.new')\n})\n- it('should not render a button to add new allergies if the user does not have permissions', () => {\n- const wrapper = setup(expectedPatient, [])\n+ it('should not render a button to add new allergies if the user does not have permissions', async () => {\n+ const wrapper = await setup(expectedPatient, [])\nconst addAllergyButton = wrapper.find(components.Button)\nexpect(addAllergyButton).toHaveLength(0)\n})\n- it('should open the New Allergy Modal when clicked', () => {\n- const wrapper = setup()\n+ it('should open the New Allergy Modal when clicked', async () => {\n+ const wrapper = await setup()\nact(() => {\nconst addAllergyButton = wrapper.find(components.Button)\n@@ -84,21 +89,10 @@ describe('Allergies', () => {\n})\ndescribe('allergy list', () => {\n- it('should render allergies', () => {\n- const wrapper = setup()\n- const allergiesList = wrapper.find(AllergiesList)\n-\n- expect(allergiesList).toHaveLength(1)\n- })\n-\n- it('should render a warning message if the patient does not have any allergies', () => {\n- const wrapper = setup({ ...expectedPatient, allergies: [] })\n-\n- const alert = wrapper.find(components.Alert)\n+ it('should render allergies', async () => {\n+ const wrapper = await setup()\n- expect(alert).toHaveLength(1)\n- expect(alert.prop('title')).toEqual('patient.allergies.warning.noAllergies')\n- expect(alert.prop('message')).toEqual('patient.allergies.addAllergyAbove')\n+ expect(wrapper.exists(AllergiesList)).toBeTruthy()\n})\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/allergies/AllergiesList.test.tsx",
"new_path": "src/__tests__/patients/allergies/AllergiesList.test.tsx",
"diff": "-import { List, ListItem } from '@hospitalrun/components'\n+import { Alert, List, ListItem } from '@hospitalrun/components'\nimport { mount, ReactWrapper } from 'enzyme'\nimport { createMemoryHistory } from 'history'\nimport React from 'react'\nimport { act } from 'react-dom/test-utils'\n-import { Provider } from 'react-redux'\nimport { Router } from 'react-router-dom'\n-import createMockStore from 'redux-mock-store'\n-import thunk from 'redux-thunk'\nimport AllergiesList from '../../../patients/allergies/AllergiesList'\n+import PatientRepository from '../../../shared/db/PatientRepository'\nimport Allergy from '../../../shared/model/Allergy'\nimport Patient from '../../../shared/model/Patient'\n-import { RootState } from '../../../shared/store'\n-\n-const mockStore = createMockStore<RootState, any>([thunk])\ndescribe('Allergies list', () => {\n- const allergy: Allergy = {\n- id: 'id',\n- name: 'name',\n- }\n- const patient = {\n- id: 'patientId',\n- diagnoses: [{ id: '123', name: 'some name', diagnosisDate: new Date().toISOString() }],\n- allergies: [allergy],\n- } as Patient\n-\n- const setup = () => {\n- const store = mockStore({ patient: { patient } } as any)\n+ const setup = async (allergies: Allergy[]) => {\n+ const mockPatient = { id: '123', allergies } as Patient\n+ jest.spyOn(PatientRepository, 'find').mockResolvedValueOnce(mockPatient)\nconst history = createMemoryHistory()\n- history.push(`/patients/${patient.id}/allergies/${patient.allergies![0].id}`)\n- const wrapper = mount(\n- <Provider store={store}>\n+ history.push(`/patients/${mockPatient.id}/allergies`)\n+ let wrapper: any\n+ await act(async () => {\n+ wrapper = await mount(\n<Router history={history}>\n- <AllergiesList />\n- </Router>\n- </Provider>,\n+ <AllergiesList patientId={mockPatient.id} />\n+ </Router>,\n)\n+ })\n+\n+ wrapper.update()\nreturn { wrapper: wrapper as ReactWrapper, history }\n}\n- it('should render a list', () => {\n- const allergies = patient.allergies as Allergy[]\n- const { wrapper } = setup()\n- const list = wrapper.find(List)\n+ it('should render a list of allergies', async () => {\n+ const expectedAllergies = [{ id: '456', name: 'some name' }]\n+ const { wrapper } = await setup(expectedAllergies)\nconst listItems = wrapper.find(ListItem)\n- expect(list).toHaveLength(1)\n- expect(listItems).toHaveLength(allergies.length)\n+ expect(wrapper.exists(List)).toBeTruthy()\n+ expect(listItems).toHaveLength(expectedAllergies.length)\n+ expect(listItems.at(0).text()).toEqual(expectedAllergies[0].name)\n+ })\n+\n+ it('should display a warning when no allergies are present', async () => {\n+ const expectedAllergies: Allergy[] = []\n+ const { wrapper } = await setup(expectedAllergies)\n+\n+ const alert = wrapper.find(Alert)\n+\n+ expect(wrapper.exists(Alert)).toBeTruthy()\n+ expect(wrapper.exists(List)).toBeFalsy()\n+\n+ expect(alert.prop('color')).toEqual('warning')\n+ expect(alert.prop('title')).toEqual('patient.allergies.warning.noAllergies')\n+ expect(alert.prop('message')).toEqual('patient.allergies.addAllergyAbove')\n})\n- it('should navigate to the allergy view when the allergy is clicked', () => {\n- const { wrapper, history } = setup()\n+ it('should navigate to the allergy view when the allergy is clicked', async () => {\n+ const expectedAllergies = [{ id: '456', name: 'some name' }]\n+ const { wrapper, history } = await setup(expectedAllergies)\nconst item = wrapper.find(ListItem)\nact(() => {\nconst onClick = item.prop('onClick') as any\nonClick({ stopPropagation: jest.fn() })\n})\n- expect(history.location.pathname).toEqual(`/patients/${patient.id}/allergies/${allergy.id}`)\n+ expect(history.location.pathname).toEqual(`/patients/123/allergies/${expectedAllergies[0].id}`)\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/allergies/NewAllergyModal.test.tsx",
"new_path": "src/__tests__/patients/allergies/NewAllergyModal.test.tsx",
"diff": "import { Modal, Alert } from '@hospitalrun/components'\n-import { act } from '@testing-library/react'\nimport { mount } from 'enzyme'\nimport React from 'react'\n-import { Provider } from 'react-redux'\n-import createMockStore from 'redux-mock-store'\n-import thunk from 'redux-thunk'\n+import { act } from 'react-dom/test-utils'\nimport NewAllergyModal from '../../../patients/allergies/NewAllergyModal'\n-import * as patientSlice from '../../../patients/patient-slice'\nimport TextInputWithLabelFormGroup from '../../../shared/components/input/TextInputWithLabelFormGroup'\nimport PatientRepository from '../../../shared/db/PatientRepository'\nimport Patient from '../../../shared/model/Patient'\n-import { RootState } from '../../../shared/store'\n-\n-const mockStore = createMockStore<RootState, any>([thunk])\ndescribe('New Allergy Modal', () => {\nconst mockPatient = {\n@@ -21,27 +14,21 @@ describe('New Allergy Modal', () => {\ngivenName: 'someName',\n} as Patient\n- beforeEach(() => {\n+ const setup = (onCloseSpy = jest.fn()) => {\njest.spyOn(PatientRepository, 'saveOrUpdate').mockResolvedValue(mockPatient)\njest.spyOn(PatientRepository, 'find').mockResolvedValue(mockPatient)\n- })\n-\n- it('should render a modal with the correct labels', () => {\n- const store = mockStore({\n- patient: {\n- patient: {\n- id: '123',\n- },\n- },\n- } as any)\nconst wrapper = mount(\n- <Provider store={store}>\n- <NewAllergyModal show onCloseButtonClick={jest.fn()} />\n- </Provider>,\n+ <NewAllergyModal patientId={mockPatient.id} show onCloseButtonClick={onCloseSpy} />,\n)\n+ return { wrapper }\n+ }\n+\n+ it('should render a modal with the correct labels', () => {\n+ const { wrapper } = setup()\n+\nconst modal = wrapper.find(Modal)\n- expect(modal).toHaveLength(1)\n+ expect(wrapper.exists(Modal)).toBeTruthy()\nexpect(modal.prop('title')).toEqual('patient.allergies.new')\nexpect(modal.prop('closeButton')?.children).toEqual('actions.cancel')\nexpect(modal.prop('closeButton')?.color).toEqual('danger')\n@@ -50,24 +37,18 @@ describe('New Allergy Modal', () => {\nexpect(modal.prop('successButton')?.icon).toEqual('add')\n})\n- it('should display the errors', () => {\n+ it('should display errors when there is an error saving', async () => {\nconst expectedError = {\n- message: 'some error message',\n- name: 'some name message',\n+ message: 'patient.allergies.error.unableToAdd',\n+ nameError: 'patient.allergies.error.nameRequired',\n}\n- const store = mockStore({\n- patient: {\n- patient: {\n- id: '123',\n- },\n- allergyError: expectedError,\n- },\n- } as any)\n- const wrapper = mount(\n- <Provider store={store}>\n- <NewAllergyModal show onCloseButtonClick={jest.fn()} />\n- </Provider>,\n- )\n+ const { wrapper } = setup()\n+\n+ await act(async () => {\n+ const modal = wrapper.find(Modal)\n+ const onSave = (modal.prop('successButton') as any).onClick\n+ await onSave({} as React.MouseEvent<HTMLButtonElement>)\n+ })\nwrapper.update()\nconst alert = wrapper.find(Alert)\n@@ -76,24 +57,13 @@ describe('New Allergy Modal', () => {\nexpect(alert.prop('title')).toEqual('states.error')\nexpect(alert.prop('message')).toEqual(expectedError.message)\nexpect(nameField.prop('isInvalid')).toBeTruthy()\n- expect(nameField.prop('feedback')).toEqual(expectedError.name)\n+ expect(nameField.prop('feedback')).toEqual(expectedError.nameError)\n})\ndescribe('cancel', () => {\nit('should call the onCloseButtonClick function when the close button is clicked', () => {\nconst onCloseButtonClickSpy = jest.fn()\n- const store = mockStore({\n- patient: {\n- patient: {\n- id: '123',\n- },\n- },\n- } as any)\n- const wrapper = mount(\n- <Provider store={store}>\n- <NewAllergyModal show onCloseButtonClick={onCloseButtonClickSpy} />\n- </Provider>,\n- )\n+ const { wrapper } = setup(onCloseButtonClickSpy)\nact(() => {\nconst modal = wrapper.find(Modal)\nconst { onClick } = modal.prop('closeButton') as any\n@@ -105,23 +75,9 @@ describe('New Allergy Modal', () => {\n})\ndescribe('save', () => {\n- it('should dispatch add allergy', () => {\n- jest.spyOn(patientSlice, 'addAllergy')\n+ it('should save the allergy for the given patient', async () => {\nconst expectedName = 'expected name'\n- const patient = {\n- id: '123',\n- }\n- const store = mockStore({\n- patient: {\n- patient,\n- },\n- } as any)\n- const wrapper = mount(\n- <Provider store={store}>\n- <NewAllergyModal show onCloseButtonClick={jest.fn()} />\n- </Provider>,\n- )\n- wrapper.update()\n+ const { wrapper } = setup()\nact(() => {\nconst input = wrapper.findWhere((c) => c.prop('name') === 'name')\n@@ -131,13 +87,18 @@ describe('New Allergy Modal', () => {\nwrapper.update()\n- act(() => {\n+ await act(async () => {\nconst modal = wrapper.find(Modal)\nconst onSave = (modal.prop('successButton') as any).onClick\n- onSave({} as React.MouseEvent<HTMLButtonElement>)\n+ await onSave({} as React.MouseEvent<HTMLButtonElement>)\n})\n- expect(patientSlice.addAllergy).toHaveBeenCalledWith(patient.id, { name: expectedName })\n+ expect(PatientRepository.saveOrUpdate).toHaveBeenCalledTimes(1)\n+ expect(PatientRepository.saveOrUpdate).toHaveBeenCalledWith(\n+ expect.objectContaining({\n+ allergies: [expect.objectContaining({ name: expectedName })],\n+ }),\n+ )\n})\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/allergies/ViewAllergy.test.tsx",
"new_path": "src/__tests__/patients/allergies/ViewAllergy.test.tsx",
"diff": "-import { mount } from 'enzyme'\n+import { mount, ReactWrapper } from 'enzyme'\nimport { createMemoryHistory } from 'history'\nimport React from 'react'\n-import { Provider } from 'react-redux'\n+import { act } from 'react-dom/test-utils'\nimport { Route, Router } from 'react-router-dom'\n-import createMockStore from 'redux-mock-store'\n-import thunk from 'redux-thunk'\nimport ViewAllergy from '../../../patients/allergies/ViewAllergy'\nimport TextInputWithLabelFormGroup from '../../../shared/components/input/TextInputWithLabelFormGroup'\n+import PatientRepository from '../../../shared/db/PatientRepository'\nimport Patient from '../../../shared/model/Patient'\n-import { RootState } from '../../../shared/store'\n-\n-const mockStore = createMockStore<RootState, any>([thunk])\ndescribe('View Care Plan', () => {\nconst patient = {\n@@ -19,25 +15,29 @@ describe('View Care Plan', () => {\nallergies: [{ id: '123', name: 'some name' }],\n} as Patient\n- const setup = () => {\n- const store = mockStore({ patient: { patient }, user: { user: { id: '123' } } } as any)\n+ const setup = async () => {\n+ jest.spyOn(PatientRepository, 'find').mockResolvedValue(patient)\nconst history = createMemoryHistory()\nhistory.push(`/patients/${patient.id}/allergies/${patient.allergies![0].id}`)\n- const wrapper = mount(\n- <Provider store={store}>\n+ let wrapper: any\n+\n+ await act(async () => {\n+ wrapper = await mount(\n<Router history={history}>\n<Route path=\"/patients/:id/allergies/:allergyId\">\n<ViewAllergy />\n</Route>\n- </Router>\n- </Provider>,\n+ </Router>,\n)\n+ })\n+\n+ wrapper.update()\n- return { wrapper }\n+ return { wrapper: wrapper as ReactWrapper }\n}\n- it('should render a allergy input with the correct data', () => {\n- const { wrapper } = setup()\n+ it('should render a allergy input with the correct data', async () => {\n+ const { wrapper } = await setup()\nconst allergyName = wrapper.find(TextInputWithLabelFormGroup)\nexpect(allergyName).toHaveLength(1)\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/patients/hooks/useAddAllergy.test.tsx",
"diff": "+import useAddAllergy from '../../../patients/hooks/useAddAllergy'\n+import * as validateAllergy from '../../../patients/util/validate-allergy'\n+import PatientRepository from '../../../shared/db/PatientRepository'\n+import Allergy from '../../../shared/model/Allergy'\n+import Patient from '../../../shared/model/Patient'\n+import * as uuid from '../../../shared/util/uuid'\n+import executeMutation from '../../test-utils/use-mutation.util'\n+\n+describe('use add allergy', () => {\n+ beforeEach(() => {\n+ jest.resetAllMocks()\n+ })\n+\n+ it('should throw an error if allergy validation fails', async () => {\n+ const expectedError = { nameError: 'some error' }\n+ jest.spyOn(validateAllergy, 'default').mockReturnValue(expectedError)\n+ jest.spyOn(PatientRepository, 'saveOrUpdate')\n+\n+ try {\n+ await executeMutation(() => useAddAllergy(), { patientId: '123', allergy: {} })\n+ } catch (e) {\n+ expect(e).toEqual(expectedError)\n+ }\n+\n+ expect(PatientRepository.saveOrUpdate).not.toHaveBeenCalled()\n+ })\n+\n+ it('should add the allergy to the patient', async () => {\n+ const expectedAllergy = { id: '123', name: 'some name' }\n+ const givenPatient = { id: 'patientId', allergies: [] as Allergy[] } as Patient\n+ jest.spyOn(uuid, 'uuid').mockReturnValue(expectedAllergy.id)\n+ const expectedPatient = { ...givenPatient, allergies: [expectedAllergy] }\n+ jest.spyOn(PatientRepository, 'saveOrUpdate').mockResolvedValue(expectedPatient)\n+ jest.spyOn(PatientRepository, 'find').mockResolvedValue(givenPatient)\n+\n+ const result = await executeMutation(() => useAddAllergy(), {\n+ patientId: givenPatient.id,\n+ allergy: expectedAllergy,\n+ })\n+\n+ expect(PatientRepository.find).toHaveBeenCalledTimes(1)\n+ expect(PatientRepository.saveOrUpdate).toHaveBeenCalledTimes(1)\n+ expect(PatientRepository.saveOrUpdate).toHaveBeenCalledWith(expectedPatient)\n+ expect(result).toEqual(expectedAllergy)\n+ })\n+})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/patients/hooks/useAllergy.tsx",
"diff": "+import useAllergy from '../../../patients/hooks/useAllergy'\n+import PatientRepository from '../../../shared/db/PatientRepository'\n+import Patient from '../../../shared/model/Patient'\n+import executeQuery from '../../test-utils/use-query.util'\n+\n+describe('use allergy', () => {\n+ it('should return an allergy given a patient id and allergy id', async () => {\n+ const expectedPatientId = '123'\n+ const expectedAllergy = { id: '456', name: 'some name' }\n+ const expectedPatient = { id: expectedPatientId, allergies: [expectedAllergy] } as Patient\n+ jest.spyOn(PatientRepository, 'find').mockResolvedValueOnce(expectedPatient)\n+\n+ const actualAllergy = await executeQuery(() =>\n+ useAllergy(expectedPatientId, expectedAllergy.id),\n+ )\n+\n+ expect(PatientRepository.find).toHaveBeenCalledTimes(1)\n+ expect(PatientRepository.find).toHaveBeenCalledWith(expectedPatientId)\n+ expect(actualAllergy).toEqual(expectedAllergy)\n+ })\n+\n+ it('should throw an error if patient does not have allergy with id', async () => {\n+ const expectedPatientId = '123'\n+ const expectedAllergy = { id: '456', name: 'some name' }\n+ const expectedPatient = { id: expectedPatientId, allergies: [expectedAllergy] } as Patient\n+ jest.spyOn(PatientRepository, 'find').mockResolvedValueOnce(expectedPatient)\n+\n+ try {\n+ await executeQuery(() => useAllergy(expectedPatientId, expectedAllergy.id))\n+ } catch (e) {\n+ expect(e).toEqual(new Error('Allergy not found'))\n+ }\n+ })\n+})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/patients/util/validate-allergy.test.ts",
"diff": "+import validateAllergy from '../../../patients/util/validate-allergy'\n+\n+describe('validate allergy', () => {\n+ it('should check for required fields', () => {\n+ const allergy = {} as any\n+ const expectedError = { nameError: 'patient.allergies.error.nameRequired' }\n+\n+ const actualError = validateAllergy(allergy)\n+\n+ expect(actualError).toEqual(expectedError)\n+ })\n+})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/test-utils/use-mutation.util.ts",
"diff": "+import { act, renderHook } from '@testing-library/react-hooks'\n+\n+export default async function executeMutation(callback: any, ...input: any[]) {\n+ let mutateToTest: any\n+ await act(async () => {\n+ const renderHookResult = renderHook(callback)\n+ const { result, waitForNextUpdate } = renderHookResult\n+ await waitForNextUpdate()\n+ const [mutate] = result.current as any\n+ mutateToTest = mutate\n+ })\n+\n+ let actualData: any\n+ await act(async () => {\n+ const result = await mutateToTest(...input)\n+ actualData = result\n+ })\n+\n+ return actualData\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/allergies/Allergies.tsx",
"new_path": "src/patients/allergies/Allergies.tsx",
"diff": "-import { Button, Alert } from '@hospitalrun/components'\n+import { Button } from '@hospitalrun/components'\nimport React, { useState } from 'react'\nimport { useSelector } from 'react-redux'\nimport { Route, Switch } from 'react-router-dom'\n@@ -50,20 +50,14 @@ const Allergies = (props: AllergiesProps) => {\n<br />\n<Switch>\n<Route exact path=\"/patients/:id/allergies\">\n- <AllergiesList />\n+ <AllergiesList patientId={patient.id} />\n</Route>\n<Route exact path=\"/patients/:id/allergies/:allergyId\">\n<ViewAllergy />\n</Route>\n</Switch>\n- {(!patient.allergies || patient.allergies.length === 0) && (\n- <Alert\n- color=\"warning\"\n- title={t('patient.allergies.warning.noAllergies')}\n- message={t('patient.allergies.addAllergyAbove')}\n- />\n- )}\n<NewAllergyModal\n+ patientId={patient.id}\nshow={showNewAllergyModal}\nonCloseButtonClick={() => setShowNewAllergyModal(false)}\n/>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/allergies/AllergiesList.tsx",
"new_path": "src/patients/allergies/AllergiesList.tsx",
"diff": "-import { List, ListItem } from '@hospitalrun/components'\n+import { Alert, List, ListItem } from '@hospitalrun/components'\nimport React from 'react'\n-import { useSelector } from 'react-redux'\nimport { useHistory } from 'react-router-dom'\n+import Loading from '../../shared/components/Loading'\n+import useTranslator from '../../shared/hooks/useTranslator'\nimport Allergy from '../../shared/model/Allergy'\n-import { RootState } from '../../shared/store'\n+import usePatientAllergies from '../hooks/usePatientAllergies'\n-const AllergiesList = () => {\n+interface Props {\n+ patientId: string\n+}\n+\n+const AllergiesList = (props: Props) => {\n+ const { patientId } = props\nconst history = useHistory()\n- const { patient } = useSelector((state: RootState) => state.patient)\n+ const { t } = useTranslator()\n+ const { data, status } = usePatientAllergies(patientId)\n+\n+ if (data === undefined || status === 'loading') {\n+ return <Loading />\n+ }\n+\n+ if (data.length === 0) {\n+ return (\n+ <Alert\n+ color=\"warning\"\n+ title={t('patient.allergies.warning.noAllergies')}\n+ message={t('patient.allergies.addAllergyAbove')}\n+ />\n+ )\n+ }\nreturn (\n<List>\n- {patient.allergies?.map((a: Allergy) => (\n+ {data.map((a: Allergy) => (\n<ListItem\naction\nkey={a.id}\n- onClick={() => history.push(`/patients/${patient.id}/allergies/${a.id}`)}\n+ onClick={() => history.push(`/patients/${patientId}/allergies/${a.id}`)}\n>\n{a.name}\n</ListItem>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/allergies/NewAllergyModal.tsx",
"new_path": "src/patients/allergies/NewAllergyModal.tsx",
"diff": "import { Modal, Alert } from '@hospitalrun/components'\nimport React, { useState, useEffect } from 'react'\n-import { useDispatch, useSelector } from 'react-redux'\nimport TextInputWithLabelFormGroup from '../../shared/components/input/TextInputWithLabelFormGroup'\nimport useTranslator from '../../shared/hooks/useTranslator'\nimport Allergy from '../../shared/model/Allergy'\n-import { RootState } from '../../shared/store'\n-import { addAllergy } from '../patient-slice'\n+import useAddAllergy from '../hooks/useAddAllergy'\n+import { AllergyError } from '../util/validate-allergy'\ninterface NewAllergyModalProps {\n+ patientId: string\nshow: boolean\nonCloseButtonClick: () => void\n}\nconst NewAllergyModal = (props: NewAllergyModalProps) => {\n- const { show, onCloseButtonClick } = props\n- const dispatch = useDispatch()\n+ const { show, onCloseButtonClick, patientId } = props\nconst { t } = useTranslator()\n- const { allergyError, patient } = useSelector((state: RootState) => state.patient)\n+ const [mutate] = useAddAllergy()\nconst [allergy, setAllergy] = useState({ name: '' })\n+ const [allergyError, setAllergyError] = useState<AllergyError | undefined>(undefined)\nuseEffect(() => {\nsetAllergy({ name: '' })\n@@ -30,8 +30,13 @@ const NewAllergyModal = (props: NewAllergyModalProps) => {\nsetAllergy((prevAllergy) => ({ ...prevAllergy, name }))\n}\n- const onSaveButtonClick = () => {\n- dispatch(addAllergy(patient.id, allergy as Allergy))\n+ const onSaveButtonClick = async () => {\n+ try {\n+ await mutate({ patientId, allergy: allergy as Allergy })\n+ onCloseButtonClick()\n+ } catch (e) {\n+ setAllergyError(e)\n+ }\n}\nconst onClose = () => {\n@@ -41,7 +46,11 @@ const NewAllergyModal = (props: NewAllergyModalProps) => {\nconst body = (\n<>\n{allergyError && (\n- <Alert color=\"danger\" title={t('states.error')} message={t(allergyError?.message || '')} />\n+ <Alert\n+ color=\"danger\"\n+ title={t('states.error')}\n+ message={t('patient.allergies.error.unableToAdd')}\n+ />\n)}\n<form>\n<TextInputWithLabelFormGroup\n@@ -52,8 +61,8 @@ const NewAllergyModal = (props: NewAllergyModalProps) => {\nplaceholder={t('patient.allergies.allergyName')}\nvalue={allergy.name}\nonChange={onNameChange}\n- feedback={t(allergyError?.name || '')}\n- isInvalid={!!allergyError?.name}\n+ feedback={t(allergyError?.nameError || '')}\n+ isInvalid={!!allergyError?.nameError}\n/>\n</form>\n</>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/allergies/ViewAllergy.tsx",
"new_path": "src/patients/allergies/ViewAllergy.tsx",
"diff": "-import React, { useEffect, useState } from 'react'\n-import { useSelector } from 'react-redux'\n+import React from 'react'\nimport { useParams } from 'react-router-dom'\nimport TextInputWithLabelFormGroup from '../../shared/components/input/TextInputWithLabelFormGroup'\n+import Loading from '../../shared/components/Loading'\nimport useTranslator from '../../shared/hooks/useTranslator'\n-import Allergy from '../../shared/model/Allergy'\n-import { RootState } from '../../shared/store'\n+import useAllergy from '../hooks/useAllergy'\nconst ViewAllergy = () => {\nconst { t } = useTranslator()\n- const { patient } = useSelector((root: RootState) => root.patient)\n- const { allergyId } = useParams()\n+ const { allergyId, id: patientId } = useParams()\n+ const { data, status } = useAllergy(patientId, allergyId)\n- const [allergy, setAllergy] = useState<Allergy | undefined>()\n-\n- useEffect(() => {\n- if (patient && allergyId) {\n- const currentAllergy = patient.allergies?.find((a: Allergy) => a.id === allergyId)\n- setAllergy(currentAllergy)\n+ if (data === undefined || status === 'loading') {\n+ return <Loading />\n}\n- }, [setAllergy, allergyId, patient])\n- if (allergy) {\nreturn (\n<>\n<TextInputWithLabelFormGroup\n@@ -29,12 +22,10 @@ const ViewAllergy = () => {\nlabel={t('patient.allergies.allergyName')}\nisEditable={false}\nplaceholder={t('patient.allergies.allergyName')}\n- value={allergy.name}\n+ value={data.name}\n/>\n</>\n)\n}\n- return <></>\n-}\nexport default ViewAllergy\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/hooks/useAddAllergy.tsx",
"diff": "+import { isEmpty } from 'lodash'\n+import { queryCache, useMutation } from 'react-query'\n+\n+import PatientRepository from '../../shared/db/PatientRepository'\n+import Allergy from '../../shared/model/Allergy'\n+import { uuid } from '../../shared/util/uuid'\n+import validateAllergy from '../util/validate-allergy'\n+\n+interface AddAllergyRequest {\n+ patientId: string\n+ allergy: Allergy\n+}\n+\n+async function addAllergy(request: AddAllergyRequest): Promise<Allergy> {\n+ const error = validateAllergy(request.allergy)\n+\n+ if (isEmpty(error)) {\n+ const patient = await PatientRepository.find(request.patientId)\n+ const allergies = patient.allergies ? [...patient.allergies] : []\n+ const newAllergy = {\n+ id: uuid(),\n+ ...request.allergy,\n+ }\n+ allergies.push(newAllergy)\n+\n+ await PatientRepository.saveOrUpdate({\n+ ...patient,\n+ allergies,\n+ })\n+\n+ return newAllergy\n+ }\n+\n+ throw error\n+}\n+\n+export default function useAddAllergy() {\n+ return useMutation(addAllergy, {\n+ onSuccess: async (_, variables) => {\n+ await queryCache.invalidateQueries(['allergies', variables.patientId])\n+ },\n+ throwOnError: true,\n+ })\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/hooks/useAllergy.tsx",
"diff": "+import { QueryKey, useQuery } from 'react-query'\n+\n+import PatientRepository from '../../shared/db/PatientRepository'\n+import Allergy from '../../shared/model/Allergy'\n+\n+async function getAllergy(\n+ _: QueryKey<string>,\n+ patientId: string,\n+ allergyId: string,\n+): Promise<Allergy> {\n+ const patient = await PatientRepository.find(patientId)\n+ const maybeAllergy = patient.allergies?.find((a) => a.id === allergyId)\n+ if (!maybeAllergy) {\n+ throw new Error('Allergy not found')\n+ }\n+\n+ return maybeAllergy\n+}\n+\n+export default function useAllergy(patientId: string, allergyId: string) {\n+ return useQuery(['allergies', patientId, allergyId], getAllergy)\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/util/validate-allergy.tsx",
"diff": "+import Allergy from '../../shared/model/Allergy'\n+\n+export class AllergyError extends Error {\n+ nameError?: string\n+\n+ constructor(message: string, name: string) {\n+ super(message)\n+ this.nameError = name\n+ Object.setPrototypeOf(this, AllergyError.prototype)\n+ }\n+}\n+\n+export default function validateAllergy(allergy: Allergy) {\n+ const error: any = {}\n+ if (!allergy.name) {\n+ error.nameError = 'patient.allergies.error.nameRequired'\n+ }\n+\n+ return error\n+}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | chore(allergies): refactor allergy data fetch to use react-query |
288,323 | 11.08.2020 00:24:04 | 18,000 | 364481148902ea21b6cf410874fdea52e29d0fe4 | chore(incidents): refactor report incident mutation to use test util | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/incidents/hooks/useReportIncident.test.tsx",
"new_path": "src/__tests__/incidents/hooks/useReportIncident.test.tsx",
"diff": "-import { act, renderHook } from '@testing-library/react-hooks'\nimport { subDays } from 'date-fns'\nimport shortid from 'shortid'\n@@ -7,6 +6,7 @@ import * as incidentValidator from '../../../incidents/util/validate-incident'\nimport { IncidentError } from '../../../incidents/util/validate-incident'\nimport IncidentRepository from '../../../shared/db/IncidentRepository'\nimport Incident from '../../../shared/model/Incident'\n+import executeMutation from '../../test-utils/use-mutation.util'\ndescribe('useReportIncident', () => {\nbeforeEach(() => {\n@@ -38,21 +38,7 @@ describe('useReportIncident', () => {\njest.spyOn(shortid, 'generate').mockReturnValue(expectedCode)\njest.spyOn(IncidentRepository, 'save').mockResolvedValue(expectedIncident)\n- let mutateToTest: any\n- await act(async () => {\n- const renderHookResult = renderHook(() => useReportIncident())\n- const { result, waitForNextUpdate } = renderHookResult\n- await waitForNextUpdate()\n- const [mutate] = result.current\n- mutateToTest = mutate\n- })\n-\n- let actualData: any\n- await act(async () => {\n- const result = await mutateToTest(givenIncidentRequest)\n- actualData = result\n- })\n-\n+ const actualData = await executeMutation(() => useReportIncident(), givenIncidentRequest)\nexpect(IncidentRepository.save).toHaveBeenCalledTimes(1)\nexpect(IncidentRepository.save).toBeCalledWith(expectedIncident)\nexpect(actualData).toEqual(expectedIncident)\n@@ -66,19 +52,8 @@ describe('useReportIncident', () => {\njest.spyOn(incidentValidator, 'default').mockReturnValue(expectedIncidentError)\njest.spyOn(IncidentRepository, 'save').mockResolvedValue({} as Incident)\n- let mutateToTest: any\n- await act(async () => {\n- const renderHookResult = renderHook(() => useReportIncident())\n- const { result, waitForNextUpdate } = renderHookResult\n- await waitForNextUpdate()\n- const [mutate] = result.current\n- mutateToTest = mutate\n- })\n-\ntry {\n- await act(async () => {\n- await mutateToTest({} as Incident)\n- })\n+ await executeMutation(() => useReportIncident(), {})\n} catch (e) {\nexpect(e).toEqual(expectedIncidentError)\nexpect(IncidentRepository.save).not.toHaveBeenCalled()\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | chore(incidents): refactor report incident mutation to use test util |
288,323 | 11.08.2020 18:08:00 | 18,000 | d12d789cb63458377c9ce61c5ed0eb7d78963e6b | chore(care-plans): add hook for getting patient care plans | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/patients/hooks/usePatientCarePlan.test.tsx",
"diff": "+import usePatientCarePlans from '../../../patients/hooks/usePatientCarePlans'\n+import PatientRepository from '../../../shared/db/PatientRepository'\n+import CarePlan, { CarePlanIntent, CarePlanStatus } from '../../../shared/model/CarePlan'\n+import Patient from '../../../shared/model/Patient'\n+import executeQuery from '../../test-utils/use-query.util'\n+\n+describe('use patient care plans', () => {\n+ it('should get patient patient care plans', async () => {\n+ const expectedPatientId = '123'\n+ const expectedCarePlans: CarePlan[] = [\n+ {\n+ id: expectedPatientId,\n+ intent: CarePlanIntent.Option,\n+ description: 'some description',\n+ diagnosisId: 'someDiagnosisId',\n+ status: CarePlanStatus.Active,\n+ title: 'some care plan title',\n+ note: 'some care plan note',\n+ startDate: new Date().toISOString(),\n+ endDate: new Date().toISOString(),\n+ createdOn: new Date().toISOString(),\n+ },\n+ ]\n+ jest.spyOn(PatientRepository, 'find').mockResolvedValueOnce({\n+ id: expectedPatientId,\n+ carePlans: expectedCarePlans,\n+ } as Patient)\n+\n+ const actualAllergies = await executeQuery(() => usePatientCarePlans(expectedPatientId))\n+\n+ expect(PatientRepository.find).toHaveBeenCalledTimes(1)\n+ expect(PatientRepository.find).toHaveBeenCalledWith(expectedPatientId)\n+ expect(actualAllergies).toEqual(expectedCarePlans)\n+ })\n+})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/hooks/usePatientCarePlans.tsx",
"diff": "+import { QueryKey, useQuery } from 'react-query'\n+\n+import PatientRepository from '../../shared/db/PatientRepository'\n+import CarePlan from '../../shared/model/CarePlan'\n+\n+async function fetchPatientCarePlans(_: QueryKey<string>, patientId: string): Promise<CarePlan[]> {\n+ const patient = await PatientRepository.find(patientId)\n+ return patient.carePlans || []\n+}\n+\n+export default function usePatientCarePlans(patientId: string) {\n+ return useQuery(['care-plans', patientId], fetchPatientCarePlans)\n+}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | chore(care-plans): add hook for getting patient care plans |
288,334 | 12.08.2020 09:34:49 | -7,200 | c601262e55c52c6f4c3594ae9ac60cbf95584433 | ci(github): remove if always | [
{
"change_type": "MODIFY",
"old_path": ".github/workflows/ci.yml",
"new_path": ".github/workflows/ci.yml",
"diff": "@@ -23,11 +23,9 @@ jobs:\nrun: |\nnpm run lint\n- name: Build\n- if: always()\nrun: |\nnpm run build\n- name: Run tests\n- if: always()\nrun: |\nnpm run coveralls\n- name: Coveralls\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | ci(github): remove if always |
288,407 | 12.08.2020 13:22:13 | 14,400 | 68d6297735b13783212a1c3787d8b3a00b8aa446 | feat: added permission for viewing widgets to Permissions model | [
{
"change_type": "MODIFY",
"old_path": "src/shared/model/Permissions.ts",
"new_path": "src/shared/model/Permissions.ts",
"diff": "@@ -21,6 +21,7 @@ enum Permissions {\nReadVisits = 'read:visit',\nRequestImaging = 'write:imaging',\nViewImagings = 'read:imagings',\n+ ViewIncidentWidgets = 'read:incident_widgets',\n}\nexport default Permissions\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat: added permission for viewing widgets to Permissions model |
288,407 | 12.08.2020 13:27:20 | 14,400 | e23c913ab0a6f68aaa86e74142a25c5448878694 | feat: added an entry in pageMap for incident infographic | [
{
"change_type": "MODIFY",
"old_path": "src/shared/components/navbar/pageMap.tsx",
"new_path": "src/shared/components/navbar/pageMap.tsx",
"diff": "@@ -59,6 +59,12 @@ const pageMap: {\npath: '/incidents',\nicon: 'incident',\n},\n+ viewIncidentWidgets: {\n+ permission: Permissions.ViewIncidentWidgets,\n+ label: 'incidents.visualize.label',\n+ path: '/incidents/visualize',\n+ icon: 'incident',\n+ },\nnewVisit: {\npermission: Permissions.AddVisit,\nlabel: 'visits.visit.new',\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat: added an entry in pageMap for incident infographic |
288,407 | 12.08.2020 13:39:23 | 14,400 | d73a3e7109a5923eccebc79f768fc09958e2746c | feat: added ListItem component to incidents in Sidebar for visualize tab | [
{
"change_type": "MODIFY",
"old_path": "src/shared/components/Sidebar.tsx",
"new_path": "src/shared/components/Sidebar.tsx",
"diff": "@@ -294,6 +294,17 @@ const Sidebar = () => {\n{!sidebarCollapsed && t('incidents.reports.label')}\n</ListItem>\n)}\n+ {permissions.includes(Permissions.ViewIncidentWidgets) && (\n+ <ListItem\n+ className=\"nav-item\"\n+ style={listSubItemStyle}\n+ onClick={() => navigateTo('/incidents/visualize')}\n+ active={splittedPath[1].includes('incidents') && splittedPath.length < 3}\n+ >\n+ <Icon icon=\"incident\" style={iconMargin} />\n+ {!sidebarCollapsed && t('incidents.visualize.label')}\n+ </ListItem>\n+ )}\n</List>\n)}\n</>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/user/user-slice.ts",
"new_path": "src/user/user-slice.ts",
"diff": "@@ -36,6 +36,7 @@ const initialState: UserState = {\nPermissions.ViewIncidents,\nPermissions.ReportIncident,\nPermissions.ResolveIncident,\n+ Permissions.ViewIncidentWidgets,\nPermissions.AddCarePlan,\nPermissions.ReadCarePlan,\nPermissions.AddVisit,\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat: added ListItem component to incidents in Sidebar for visualize tab |
288,407 | 12.08.2020 13:51:33 | 14,400 | a10574874fa673fd2414234d61079e16a13a7050 | test: implemented unit tests for visualize tab | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/shared/components/Sidebar.test.tsx",
"new_path": "src/__tests__/shared/components/Sidebar.test.tsx",
"diff": "@@ -31,6 +31,7 @@ describe('Sidebar', () => {\nPermissions.ViewLabs,\nPermissions.ViewIncidents,\nPermissions.ViewIncident,\n+ Permissions.ViewIncidentWidgets,\nPermissions.ReportIncident,\nPermissions.ReadVisits,\nPermissions.AddVisit,\n@@ -473,6 +474,24 @@ describe('Sidebar', () => {\n})\n})\n+ it('should render the incidents visualize link', () => {\n+ const wrapper = setup('/incidents')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ expect(listItems.at(8).text().trim()).toEqual('incidents.visualize.label')\n+ })\n+\n+ it('should not render the incidents visualize link when user does not have the view incident widgets privileges', () => {\n+ const wrapper = setupNoPermissions('/incidents')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ listItems.forEach((_, i) => {\n+ expect(listItems.at(i).text().trim()).not.toEqual('incidents.visualize.label')\n+ })\n+ })\n+\nit('main incidents link should be active when the current path is /incidents', () => {\nconst wrapper = setup('/incidents')\n@@ -515,6 +534,19 @@ describe('Sidebar', () => {\nexpect(history.location.pathname).toEqual('/incidents/new')\n})\n+ it('should navigate to /incidents/visualize when the incidents visualize link is clicked', () => {\n+ const wrapper = setup('/incidents')\n+\n+ const listItems = wrapper.find(ListItem)\n+\n+ act(() => {\n+ const onClick = listItems.at(8).prop('onClick') as any\n+ onClick()\n+ })\n+\n+ expect(history.location.pathname).toEqual('/incidents/visualize')\n+ })\n+\nit('incidents list link should be active when the current path is /incidents', () => {\nconst wrapper = setup('/incidents')\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | test: implemented unit tests for visualize tab |
288,407 | 12.08.2020 14:11:27 | 14,400 | 9dc78558affd1419801a91e060d0b412b4c09072 | feat: added route for visualize component and performed sanity check | [
{
"change_type": "MODIFY",
"old_path": "src/incidents/Incidents.tsx",
"new_path": "src/incidents/Incidents.tsx",
"diff": "@@ -9,6 +9,7 @@ import { RootState } from '../shared/store'\nimport ViewIncidents from './list/ViewIncidents'\nimport ReportIncident from './report/ReportIncident'\nimport ViewIncident from './view/ViewIncident'\n+import VisualizeIncidents from './visualize/VisualizeIncidents'\nconst Incidents = () => {\nconst { permissions } = useSelector((state: RootState) => state.user)\n@@ -34,6 +35,12 @@ const Incidents = () => {\npath=\"/incidents/new\"\ncomponent={ReportIncident}\n/>\n+ <PrivateRoute\n+ isAuthenticated={permissions.includes(Permissions.ViewIncidentWidgets)}\n+ exact\n+ path=\"/incidents/visualize\"\n+ component={VisualizeIncidents}\n+ />\n<PrivateRoute\nisAuthenticated={permissions.includes(Permissions.ViewIncident)}\nexact\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/incidents/visualize/VisualizeIncidents.tsx",
"diff": "+import {} from '@hospitalrun/components'\n+import React from 'react'\n+// import { useDispatch, useSelector } from 'react-redux'\n+// import { useParams, useHistory } from 'react-router-dom'\n+\n+// import useAddBreadcrumbs from '../../page-header/breadcrumbs/useAddBreadcrumbs'\n+// import useTitle from '../../page-header/title/useTitle'\n+// import useTranslator from '../../shared/hooks/useTranslator'\n+// import { RootState } from '../../shared/store'\n+\n+const VisualizeIncidents = () => (\n+ // const dispatch = useDispatch()\n+ // const { t } = useTranslator()\n+ // const history = useHistory()\n+ // const { id } = useParams()\n+ // const { incident } = useSelector((state: RootState) => state.incident)\n+ // useTitle(incident ? incident.code : '')\n+ // const breadcrumbs = [\n+ // {\n+ // i18nKey: incident ? incident.code : '',\n+ // location: `/incidents/${id}`,\n+ // },\n+ // ]\n+ // useAddBreadcrumbs(breadcrumbs)\n+\n+ <>\n+ <h1>Hello from VisualizeIncidents.tsx!</h1>\n+ </>\n+)\n+\n+export default VisualizeIncidents\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat: added route for visualize component and performed sanity check |
288,407 | 12.08.2020 14:30:28 | 14,400 | c6f17b3b1b98b80aae7eb805fb2f2571c2b850b9 | feat: added test cases for visualize route | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/incidents/Incidents.test.tsx",
"new_path": "src/__tests__/incidents/Incidents.test.tsx",
"diff": "@@ -9,6 +9,7 @@ import thunk from 'redux-thunk'\nimport Incidents from '../../incidents/Incidents'\nimport ReportIncident from '../../incidents/report/ReportIncident'\nimport ViewIncident from '../../incidents/view/ViewIncident'\n+import VisualizeIncidents from '../../incidents/visualize/VisualizeIncidents'\nimport IncidentRepository from '../../shared/db/IncidentRepository'\nimport Incident from '../../shared/model/Incident'\nimport Permissions from '../../shared/model/Permissions'\n@@ -63,6 +64,20 @@ describe('Incidents', () => {\n})\n})\n+ describe('/incidents/visualize', () => {\n+ it('should render the incident visualize screen when /incidents/visualize is accessed', async () => {\n+ const { wrapper } = await setup([Permissions.ViewIncidentWidgets], '/incidents/visualize')\n+\n+ expect(wrapper.find(VisualizeIncidents)).toHaveLength(1)\n+ })\n+\n+ it('should not navigate to /incidents/visualize if the user does not have ViewIncidentWidgets permissions', async () => {\n+ const { wrapper } = await setup([], '/incidents/visualize')\n+\n+ expect(wrapper.find(VisualizeIncidents)).toHaveLength(0)\n+ })\n+ })\n+\ndescribe('/incidents/:id', () => {\nit('should render the view incident screen when /incidents/:id is accessed', async () => {\nconst { wrapper } = await setup([Permissions.ViewIncident], '/incidents/1234')\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat: added test cases for visualize route |
288,407 | 12.08.2020 15:58:35 | 14,400 | 8d04353bfe0ef3a89d6d93e8dfedcbd928376a8e | feat: implemented use of hook to retrieve reported incidents | [
{
"change_type": "MODIFY",
"old_path": "src/incidents/visualize/VisualizeIncidents.tsx",
"new_path": "src/incidents/visualize/VisualizeIncidents.tsx",
"diff": "-import {} from '@hospitalrun/components'\n+import { Spinner } from '@hospitalrun/components'\nimport React from 'react'\n-// import { useDispatch, useSelector } from 'react-redux'\n-// import { useParams, useHistory } from 'react-router-dom'\n-// import useAddBreadcrumbs from '../../page-header/breadcrumbs/useAddBreadcrumbs'\n-// import useTitle from '../../page-header/title/useTitle'\n-// import useTranslator from '../../shared/hooks/useTranslator'\n-// import { RootState } from '../../shared/store'\n+import useIncidents from '../hooks/useIncidents'\n+import IncidentFilter from '../IncidentFilter'\n+import IncidentSearchRequest from '../model/IncidentSearchRequest'\n-const VisualizeIncidents = () => (\n- // const dispatch = useDispatch()\n- // const { t } = useTranslator()\n- // const history = useHistory()\n- // const { id } = useParams()\n- // const { incident } = useSelector((state: RootState) => state.incident)\n- // useTitle(incident ? incident.code : '')\n- // const breadcrumbs = [\n- // {\n- // i18nKey: incident ? incident.code : '',\n- // location: `/incidents/${id}`,\n- // },\n- // ]\n- // useAddBreadcrumbs(breadcrumbs)\n+const VisualizeIncidents = () => {\n+ const searchFilter = IncidentFilter.reported\n+ const searchRequest: IncidentSearchRequest = { status: searchFilter }\n+ const { data, isLoading } = useIncidents(searchRequest)\n+ if (data === undefined || isLoading) {\n+ return <Spinner type=\"DotLoader\" loading />\n+ }\n+\n+ console.log('data: ', data)\n+ return (\n<>\n- <h1>Hello from VisualizeIncidents.tsx!</h1>\n+ <h1>Hello from Visualize Incidents</h1>\n</>\n)\n+}\nexport default VisualizeIncidents\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat: implemented use of hook to retrieve reported incidents |
288,366 | 13.08.2020 12:15:58 | -28,800 | 2532435feea8066588694a965aa15fc942b2ef19 | feat(diagnosis): adds new diagnosis fields | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/care-plans/CarePlanForm.test.tsx",
"new_path": "src/__tests__/patients/care-plans/CarePlanForm.test.tsx",
"diff": "@@ -6,7 +6,7 @@ import { act } from 'react-dom/test-utils'\nimport CarePlanForm from '../../../patients/care-plans/CarePlanForm'\nimport CarePlan, { CarePlanIntent, CarePlanStatus } from '../../../shared/model/CarePlan'\n-import Diagnosis from '../../../shared/model/Diagnosis'\n+import Diagnosis, { DiagnosisStatus } from '../../../shared/model/Diagnosis'\nimport Patient from '../../../shared/model/Patient'\ndescribe('Care Plan Form', () => {\n@@ -15,6 +15,10 @@ describe('Care Plan Form', () => {\nid: '123',\nname: 'some diagnosis name',\ndiagnosisDate: new Date().toISOString(),\n+ onsetDate: new Date().toISOString(),\n+ abatementDate: new Date().toISOString(),\n+ status: DiagnosisStatus.Active,\n+ note: 'some note',\n}\nconst carePlan: CarePlan = {\nid: 'id',\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/diagnoses/AddDiagnosisModal.test.tsx",
"new_path": "src/__tests__/patients/diagnoses/AddDiagnosisModal.test.tsx",
"diff": "-import { Modal, Alert } from '@hospitalrun/components'\n-import { act } from '@testing-library/react'\n+import { Modal } from '@hospitalrun/components'\nimport { mount } from 'enzyme'\n+import { createMemoryHistory } from 'history'\nimport React from 'react'\n+import { act } from 'react-dom/test-utils'\nimport { Provider } from 'react-redux'\n+import { Router } from 'react-router-dom'\nimport createMockStore from 'redux-mock-store'\nimport thunk from 'redux-thunk'\nimport AddDiagnosisModal from '../../../patients/diagnoses/AddDiagnosisModal'\n+import DiagnosisForm from '../../../patients/diagnoses/DiagnosisForm'\nimport * as patientSlice from '../../../patients/patient-slice'\n-import DatePickerWithLabelFormGroup from '../../../shared/components/input/DatePickerWithLabelFormGroup'\n-import TextInputWithLabelFormGroup from '../../../shared/components/input/TextInputWithLabelFormGroup'\nimport PatientRepository from '../../../shared/db/PatientRepository'\n-import Diagnosis from '../../../shared/model/Diagnosis'\n+import { CarePlanIntent, CarePlanStatus } from '../../../shared/model/CarePlan'\nimport Patient from '../../../shared/model/Patient'\nimport { RootState } from '../../../shared/store'\nconst mockStore = createMockStore<RootState, any>([thunk])\ndescribe('Add Diagnosis Modal', () => {\n- beforeEach(() => {\n- jest.spyOn(PatientRepository, 'find')\n- jest.spyOn(PatientRepository, 'saveOrUpdate')\n- })\n-\n- it('should render a modal with the correct labels', () => {\n- const store = mockStore({\n- patient: {\n- patient: {\n- id: '1234',\n- },\n+ const patient = {\n+ id: 'patientId',\n+ diagnoses: [{ id: '123', name: 'some name', diagnosisDate: new Date().toISOString() }],\n+ carePlans: [\n+ {\n+ id: '123',\n+ title: 'some title',\n+ description: 'some description',\n+ diagnosisId: '123',\n+ startDate: new Date().toISOString(),\n+ endDate: new Date().toISOString(),\n+ status: CarePlanStatus.Active,\n+ intent: CarePlanIntent.Proposal,\n},\n- } as any)\n+ ],\n+ } as Patient\n+\n+ const diagnosisError = {\n+ title: 'some diagnosisError error',\n+ }\n+\n+ const onCloseSpy = jest.fn()\n+ const setup = () => {\n+ jest.spyOn(PatientRepository, 'find').mockResolvedValue(patient)\n+ jest.spyOn(PatientRepository, 'saveOrUpdate')\n+ const store = mockStore({ patient: { patient, diagnosisError } } as any)\n+ const history = createMemoryHistory()\nconst wrapper = mount(\n<Provider store={store}>\n- <AddDiagnosisModal show onCloseButtonClick={jest.fn()} />\n+ <Router history={history}>\n+ <AddDiagnosisModal show onCloseButtonClick={onCloseSpy} />\n+ </Router>\n</Provider>,\n)\n+\nwrapper.update()\n+ return { wrapper }\n+ }\n+\n+ it('should render a modal', () => {\n+ const { wrapper } = setup()\n+\nconst modal = wrapper.find(Modal)\n+\nexpect(modal).toHaveLength(1)\n+\n+ const successButton = modal.prop('successButton')\n+ const cancelButton = modal.prop('closeButton')\nexpect(modal.prop('title')).toEqual('patient.diagnoses.new')\n- expect(modal.prop('closeButton')?.children).toEqual('actions.cancel')\n- expect(modal.prop('closeButton')?.color).toEqual('danger')\n- expect(modal.prop('successButton')?.children).toEqual('patient.diagnoses.new')\n- expect(modal.prop('successButton')?.color).toEqual('success')\n- expect(modal.prop('successButton')?.icon).toEqual('add')\n+ expect(successButton?.children).toEqual('patient.diagnoses.new')\n+ expect(successButton?.icon).toEqual('add')\n+ expect(cancelButton?.children).toEqual('actions.cancel')\n})\n- it('should display an errors', () => {\n- const expectedDiagnosisError = {\n- message: 'some message',\n- date: 'some date message',\n- name: 'some date message',\n- }\n- const store = mockStore({\n- patient: {\n- diagnosisError: expectedDiagnosisError,\n- },\n- } as any)\n- const wrapper = mount(\n- <Provider store={store}>\n- <AddDiagnosisModal show onCloseButtonClick={jest.fn()} />\n- </Provider>,\n- )\n- wrapper.update()\n-\n- expect(wrapper.find(Alert)).toHaveLength(1)\n+ it('should render the diagnosis form', () => {\n+ const { wrapper } = setup()\n- expect(wrapper.find(Alert).prop('title')).toEqual('states.error')\n- expect(wrapper.find(Alert).prop('message')).toContain(expectedDiagnosisError.message)\n- expect(wrapper.find(TextInputWithLabelFormGroup).prop('feedback')).toContain(\n- expectedDiagnosisError.name,\n- )\n- expect(wrapper.find(TextInputWithLabelFormGroup).prop('isInvalid')).toBeTruthy()\n- expect(wrapper.find(DatePickerWithLabelFormGroup).prop('feedback')).toContain(\n- expectedDiagnosisError.date,\n- )\n- expect(wrapper.find(DatePickerWithLabelFormGroup).prop('isInvalid')).toBeTruthy()\n+ const diagnosisForm = wrapper.find(DiagnosisForm)\n+ expect(diagnosisForm).toHaveLength(1)\n+ expect(diagnosisForm.prop('diagnosisError')).toEqual(diagnosisError)\n})\n- describe('cancel', () => {\n- it('should call the onCloseButtonClick function when the close button is clicked', () => {\n- const onCloseButtonClickSpy = jest.fn()\n- const store = mockStore({\n- patient: {\n- patient: {\n- id: '1234',\n- },\n- },\n- } as any)\n- const wrapper = mount(\n- <Provider store={store}>\n- <AddDiagnosisModal show onCloseButtonClick={onCloseButtonClickSpy} />\n- </Provider>,\n- )\n- wrapper.update()\n+ it('should dispatch add diagnosis when the save button is clicked', async () => {\n+ const { wrapper } = setup()\n+ jest.spyOn(patientSlice, 'addDiagnosis')\nact(() => {\n- const modal = wrapper.find(Modal)\n- const { onClick } = modal.prop('closeButton') as any\n- onClick()\n+ const diagnosisForm = wrapper.find(DiagnosisForm)\n+ const onChange = diagnosisForm.prop('onChange') as any\n+ if (patient.diagnoses != null) {\n+ onChange(patient.diagnoses[0])\n+ }\n})\n+ wrapper.update()\n- expect(onCloseButtonClickSpy).toHaveBeenCalledTimes(1)\n- })\n+ await act(async () => {\n+ const modal = wrapper.find(Modal)\n+ const successButton = modal.prop('successButton')\n+ const onClick = successButton?.onClick as any\n+ await onClick()\n})\n- describe('save', () => {\n- it('should dispatch add diagnosis', () => {\n- const expectedName = 'expected name'\n- const expectedDate = new Date()\n- jest.spyOn(patientSlice, 'addDiagnosis')\n- const patient = {\n- id: '1234',\n- givenName: 'some name',\n+ expect(patientSlice.addDiagnosis).toHaveBeenCalledTimes(1)\n+ if (patient.diagnoses != null) {\n+ expect(patientSlice.addDiagnosis).toHaveBeenCalledWith(patient.id, patient.diagnoses[0])\n}\n+ })\n- jest.spyOn(PatientRepository, 'find').mockResolvedValue(patient as Patient)\n- jest.spyOn(PatientRepository, 'saveOrUpdate').mockResolvedValue(patient as Patient)\n-\n- const diagnosis = {\n- name: expectedName,\n- diagnosisDate: expectedDate.toISOString(),\n- } as Diagnosis\n+ it('should call the on close function when the cancel button is clicked', () => {\n+ const { wrapper } = setup()\n- const store = mockStore({\n- patient: {\n- patient,\n- },\n- } as any)\n- const wrapper = mount(\n- <Provider store={store}>\n- <AddDiagnosisModal show onCloseButtonClick={jest.fn()} />\n- </Provider>,\n- )\n-\n- act(() => {\n- const input = wrapper.findWhere((c: any) => c.prop('name') === 'name')\n- const onChange = input.prop('onChange')\n- onChange({ target: { value: expectedName } })\n- })\n- wrapper.update()\n+ const modal = wrapper.find(Modal)\n- act(() => {\n- const input = wrapper.findWhere((c: any) => c.prop('name') === 'diagnosisDate')\n- const onChange = input.prop('onChange')\n- onChange(expectedDate)\n- })\n- wrapper.update()\n+ expect(modal).toHaveLength(1)\nact(() => {\n- const modal = wrapper.find(Modal)\n- const { onClick } = modal.prop('successButton') as any\n+ const cancelButton = modal.prop('closeButton')\n+ const onClick = cancelButton?.onClick as any\nonClick()\n})\n- expect(patientSlice.addDiagnosis).toHaveBeenCalledWith(patient.id, { ...diagnosis })\n- })\n+ expect(onCloseSpy).toHaveBeenCalledTimes(1)\n})\n})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/__tests__/patients/diagnoses/DiagnosisForm.test.tsx",
"diff": "+import { Alert } from '@hospitalrun/components'\n+import { addDays } from 'date-fns'\n+import { mount } from 'enzyme'\n+import React from 'react'\n+import { act } from 'react-dom/test-utils'\n+\n+import DiagnosisForm from '../../../patients/diagnoses/DiagnosisForm'\n+import Diagnosis, { DiagnosisStatus } from '../../../shared/model/Diagnosis'\n+\n+describe('Diagnosis Form', () => {\n+ let onDiagnosisChangeSpy: any\n+ const diagnosis: Diagnosis = {\n+ id: '123',\n+ name: 'some diagnosis name',\n+ diagnosisDate: new Date().toISOString(),\n+ onsetDate: new Date().toISOString(),\n+ abatementDate: new Date().toISOString(),\n+ status: DiagnosisStatus.Active,\n+ note: 'some note',\n+ }\n+\n+ const setup = (disabled = false, initializeDiagnosis = true, error?: any) => {\n+ onDiagnosisChangeSpy = jest.fn()\n+ const wrapper = mount(\n+ <DiagnosisForm\n+ onChange={onDiagnosisChangeSpy}\n+ diagnosis={initializeDiagnosis ? diagnosis : {}}\n+ diagnosisError={error}\n+ disabled={disabled}\n+ />,\n+ )\n+ return { wrapper }\n+ }\n+\n+ it('should render a name input', () => {\n+ const { wrapper } = setup()\n+\n+ const nameInput = wrapper.findWhere((w) => w.prop('name') === 'name')\n+\n+ expect(nameInput).toHaveLength(1)\n+ expect(nameInput.prop('patient.diagnoses.name'))\n+ expect(nameInput.prop('isRequired')).toBeTruthy()\n+ expect(nameInput.prop('value')).toEqual(diagnosis.name)\n+ })\n+\n+ it('should call the on change handler when name changes', () => {\n+ const expectedNewname = 'some new name'\n+ const { wrapper } = setup(false, false)\n+ act(() => {\n+ const nameInput = wrapper.findWhere((w) => w.prop('name') === 'name')\n+ const onChange = nameInput.prop('onChange') as any\n+ onChange({ currentTarget: { value: expectedNewname } })\n+ })\n+\n+ expect(onDiagnosisChangeSpy).toHaveBeenCalledWith({ name: expectedNewname })\n+ })\n+\n+ it('should render a status selector', () => {\n+ const { wrapper } = setup()\n+\n+ const statusSelector = wrapper.findWhere((w) => w.prop('name') === 'status')\n+\n+ expect(statusSelector).toHaveLength(1)\n+ expect(statusSelector.prop('patient.diagnoses.status'))\n+ expect(statusSelector.prop('isRequired')).toBeTruthy()\n+ expect(statusSelector.prop('defaultSelected')[0].value).toEqual(diagnosis.status)\n+ expect(statusSelector.prop('options')).toEqual(\n+ Object.values(DiagnosisStatus).map((v) => ({ label: v, value: v })),\n+ )\n+ })\n+\n+ it('should call the on change handler when status changes', () => {\n+ const expectedNewStatus = DiagnosisStatus.Active\n+ const { wrapper } = setup(false, false)\n+ act(() => {\n+ const statusSelector = wrapper.findWhere((w) => w.prop('name') === 'status')\n+ const onChange = statusSelector.prop('onChange') as any\n+ onChange([expectedNewStatus])\n+ })\n+\n+ expect(onDiagnosisChangeSpy).toHaveBeenCalledWith({ status: expectedNewStatus })\n+ })\n+\n+ it('should render a diagnosis date picker', () => {\n+ const { wrapper } = setup()\n+\n+ const diagnosisDatePicker = wrapper.findWhere((w) => w.prop('name') === 'diagnosisDate')\n+\n+ expect(diagnosisDatePicker).toHaveLength(1)\n+ expect(diagnosisDatePicker.prop('patient.diagnoses.diagnosisDate'))\n+ expect(diagnosisDatePicker.prop('isRequired')).toBeTruthy()\n+ expect(diagnosisDatePicker.prop('value')).toEqual(new Date(diagnosis.diagnosisDate))\n+ })\n+\n+ it('should call the on change handler when diagnosis date changes', () => {\n+ const expectedNewDiagnosisDate = addDays(1, new Date().getDate())\n+ const { wrapper } = setup(false, false)\n+\n+ const diagnosisDatePicker = wrapper.findWhere((w) => w.prop('name') === 'diagnosisDate')\n+ act(() => {\n+ const onChange = diagnosisDatePicker.prop('onChange') as any\n+ onChange(expectedNewDiagnosisDate)\n+ })\n+\n+ expect(onDiagnosisChangeSpy).toHaveBeenCalledWith({\n+ diagnosisDate: expectedNewDiagnosisDate.toISOString(),\n+ })\n+ })\n+\n+ it('should render a onset date picker', () => {\n+ const { wrapper } = setup()\n+\n+ const onsetDatePicker = wrapper.findWhere((w) => w.prop('name') === 'onsetDate')\n+\n+ expect(onsetDatePicker).toHaveLength(1)\n+ expect(onsetDatePicker.prop('patient.diagnoses.onsetDate'))\n+ expect(onsetDatePicker.prop('isRequired')).toBeTruthy()\n+ expect(onsetDatePicker.prop('value')).toEqual(new Date(diagnosis.onsetDate))\n+ })\n+\n+ it('should call the on change handler when onset date changes', () => {\n+ const expectedNewOnsetDate = addDays(1, new Date().getDate())\n+ const { wrapper } = setup(false, false)\n+\n+ const onsetDatePicker = wrapper.findWhere((w) => w.prop('name') === 'onsetDate')\n+ act(() => {\n+ const onChange = onsetDatePicker.prop('onChange') as any\n+ onChange(expectedNewOnsetDate)\n+ })\n+\n+ expect(onDiagnosisChangeSpy).toHaveBeenCalledWith({\n+ onsetDate: expectedNewOnsetDate.toISOString(),\n+ })\n+ })\n+\n+ it('should render a abatement date picker', () => {\n+ const { wrapper } = setup()\n+\n+ const abatementDatePicker = wrapper.findWhere((w) => w.prop('name') === 'abatementDate')\n+\n+ expect(abatementDatePicker).toHaveLength(1)\n+ expect(abatementDatePicker.prop('patient.diagnoses.abatementDate'))\n+ expect(abatementDatePicker.prop('isRequired')).toBeTruthy()\n+ expect(abatementDatePicker.prop('value')).toEqual(new Date(diagnosis.abatementDate))\n+ })\n+\n+ it('should call the on change handler when abatementDate date changes', () => {\n+ const expectedNewAbatementDate = addDays(1, new Date().getDate())\n+ const { wrapper } = setup(false, false)\n+\n+ const abatementDatePicker = wrapper.findWhere((w) => w.prop('name') === 'abatementDate')\n+ act(() => {\n+ const onChange = abatementDatePicker.prop('onChange') as any\n+ onChange(expectedNewAbatementDate)\n+ })\n+\n+ expect(onDiagnosisChangeSpy).toHaveBeenCalledWith({\n+ abatementDate: expectedNewAbatementDate.toISOString(),\n+ })\n+ })\n+\n+ it('should render a note input', () => {\n+ const { wrapper } = setup()\n+\n+ const noteInput = wrapper.findWhere((w) => w.prop('name') === 'note')\n+ expect(noteInput).toHaveLength(1)\n+ expect(noteInput.prop('patient.diagnoses.note'))\n+ expect(noteInput.prop('value')).toEqual(diagnosis.note)\n+ })\n+\n+ it('should call the on change handler when note changes', () => {\n+ const expectedNewNote = 'some new note'\n+ const { wrapper } = setup(false, false)\n+\n+ const noteInput = wrapper.findWhere((w) => w.prop('name') === 'note')\n+ act(() => {\n+ const onChange = noteInput.prop('onChange') as any\n+ onChange({ currentTarget: { value: expectedNewNote } })\n+ })\n+\n+ expect(onDiagnosisChangeSpy).toHaveBeenCalledWith({ note: expectedNewNote })\n+ })\n+\n+ it('should render all of the fields as disabled if the form is disabled', () => {\n+ const { wrapper } = setup(true)\n+ const nameInput = wrapper.findWhere((w) => w.prop('name') === 'name')\n+ const statusSelector = wrapper.findWhere((w) => w.prop('name') === 'status')\n+ const diagnosisDatePicker = wrapper.findWhere((w) => w.prop('name') === 'diagnosisDate')\n+ const onsetDatePicker = wrapper.findWhere((w) => w.prop('name') === 'onsetDate')\n+ const abatementeDatePicker = wrapper.findWhere((w) => w.prop('name') === 'abatementDate')\n+ const noteInput = wrapper.findWhere((w) => w.prop('name') === 'note')\n+\n+ expect(nameInput.prop('isEditable')).toBeFalsy()\n+ expect(statusSelector.prop('isEditable')).toBeFalsy()\n+ expect(diagnosisDatePicker.prop('isEditable')).toBeFalsy()\n+ expect(abatementeDatePicker.prop('isEditable')).toBeFalsy()\n+ expect(onsetDatePicker.prop('isEditable')).toBeFalsy()\n+ expect(noteInput.prop('isEditable')).toBeFalsy()\n+ })\n+\n+ it('should render the form fields in an error state', () => {\n+ const expectedError = {\n+ message: 'some message error',\n+ name: 'some name error',\n+ diagnosisDate: 'some date error',\n+ onsetDate: 'some date error',\n+ abatementDate: 'some date error',\n+ status: 'some status error',\n+ note: 'some note error',\n+ }\n+\n+ const { wrapper } = setup(false, false, expectedError)\n+\n+ const alert = wrapper.find(Alert)\n+ const nameInput = wrapper.findWhere((w) => w.prop('name') === 'name')\n+ const statusSelector = wrapper.findWhere((w) => w.prop('name') === 'status')\n+ const diagnosisDatePicker = wrapper.findWhere((w) => w.prop('name') === 'diagnosisDate')\n+ const onsetDatePicker = wrapper.findWhere((w) => w.prop('name') === 'onsetDate')\n+ const abatementDatePicker = wrapper.findWhere((w) => w.prop('name') === 'abatementDate')\n+\n+ const noteInput = wrapper.findWhere((w) => w.prop('name') === 'note')\n+\n+ expect(alert).toHaveLength(1)\n+ expect(alert.prop('message')).toEqual(expectedError.message)\n+\n+ expect(nameInput.prop('isInvalid')).toBeTruthy()\n+ expect(nameInput.prop('feedback')).toEqual(expectedError.name)\n+\n+ expect(statusSelector.prop('isInvalid')).toBeTruthy()\n+\n+ expect(diagnosisDatePicker.prop('isInvalid')).toBeTruthy()\n+ expect(diagnosisDatePicker.prop('feedback')).toEqual(expectedError.diagnosisDate)\n+\n+ expect(onsetDatePicker.prop('isInvalid')).toBeTruthy()\n+ expect(onsetDatePicker.prop('feedback')).toEqual(expectedError.onsetDate)\n+\n+ expect(abatementDatePicker.prop('isInvalid')).toBeTruthy()\n+ expect(abatementDatePicker.prop('feedback')).toEqual(expectedError.abatementDate)\n+\n+ expect(noteInput.prop('isInvalid')).toBeTruthy()\n+ expect(noteInput.prop('feedback')).toEqual(expectedError.note)\n+ })\n+})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/patient-slice.test.ts",
"new_path": "src/__tests__/patients/patient-slice.test.ts",
"diff": "@@ -28,7 +28,7 @@ import patient, {\nimport PatientRepository from '../../shared/db/PatientRepository'\nimport Allergy from '../../shared/model/Allergy'\nimport CarePlan, { CarePlanIntent, CarePlanStatus } from '../../shared/model/CarePlan'\n-import Diagnosis from '../../shared/model/Diagnosis'\n+import Diagnosis, { DiagnosisStatus } from '../../shared/model/Diagnosis'\nimport Patient from '../../shared/model/Patient'\nimport RelatedPerson from '../../shared/model/RelatedPerson'\nimport { RootState } from '../../shared/store'\n@@ -556,6 +556,9 @@ describe('patients slice', () => {\nconst expectedDiagnosis = {\ndiagnosisDate: new Date().toISOString(),\nname: 'diagnosis name',\n+ onsetDate: new Date().toISOString(),\n+ abatementDate: new Date().toISOString(),\n+ status: DiagnosisStatus.Active,\n} as Diagnosis\nconst expectedUpdatedPatient = {\n@@ -582,6 +585,7 @@ describe('patients slice', () => {\nmessage: 'patient.diagnoses.error.unableToAdd',\nname: 'patient.diagnoses.error.nameRequired',\ndate: 'patient.diagnoses.error.dateRequired',\n+ status: 'patient.diagnoses.error.statusRequired',\n}\nconst store = mockStore()\nconst expectedDiagnosis = {} as Diagnosis\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/diagnoses/AddDiagnosisModal.tsx",
"new_path": "src/patients/diagnoses/AddDiagnosisModal.tsx",
"diff": "-import { Modal, Alert } from '@hospitalrun/components'\n+import { Modal } from '@hospitalrun/components'\nimport React, { useState, useEffect } from 'react'\nimport { useDispatch, useSelector } from 'react-redux'\n-import DatePickerWithLabelFormGroup from '../../shared/components/input/DatePickerWithLabelFormGroup'\n-import TextInputWithLabelFormGroup from '../../shared/components/input/TextInputWithLabelFormGroup'\nimport useTranslator from '../../shared/hooks/useTranslator'\nimport Diagnosis from '../../shared/model/Diagnosis'\nimport { RootState } from '../../shared/store'\nimport { addDiagnosis } from '../patient-slice'\n+import DiagnosisForm from './DiagnosisForm'\ninterface Props {\nshow: boolean\nonCloseButtonClick: () => void\n}\n+const initialDiagnosisState = {\n+ name: '',\n+ diagnosisDate: new Date().toISOString(),\n+ onsetDate: new Date().toISOString(),\n+ abatementDate: new Date().toISOString(),\n+ note: '',\n+}\n+\nconst AddDiagnosisModal = (props: Props) => {\nconst { show, onCloseButtonClick } = props\nconst dispatch = useDispatch()\nconst { diagnosisError, patient } = useSelector((state: RootState) => state.patient)\nconst { t } = useTranslator()\n- const [diagnosis, setDiagnosis] = useState({ name: '', diagnosisDate: new Date().toISOString() })\n+ const [diagnosis, setDiagnosis] = useState(initialDiagnosisState)\nuseEffect(() => {\n- setDiagnosis({ name: '', diagnosisDate: new Date().toISOString() })\n+ setDiagnosis(initialDiagnosisState)\n}, [show])\n+ const onDiagnosisChange = (newDiagnosis: Partial<Diagnosis>) => {\n+ setDiagnosis(newDiagnosis as Diagnosis)\n+ }\nconst onSaveButtonClick = () => {\ndispatch(addDiagnosis(patient.id, diagnosis as Diagnosis))\n}\n- const onNameChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n- const name = event.target.value\n- setDiagnosis((prevDiagnosis) => ({ ...prevDiagnosis, name }))\n- }\n-\n- const onDiagnosisDateChange = (diagnosisDate: Date) => {\n- if (diagnosisDate) {\n- setDiagnosis((prevDiagnosis) => ({\n- ...prevDiagnosis,\n- diagnosisDate: diagnosisDate.toISOString(),\n- }))\n- }\n- }\n-\nconst body = (\n- <>\n- <form>\n- {diagnosisError && (\n- <Alert\n- color=\"danger\"\n- title={t('states.error')}\n- message={t(diagnosisError?.message || '')}\n- />\n- )}\n- <div className=\"row\">\n- <div className=\"col-md-12\">\n- <div className=\"form-group\">\n- <TextInputWithLabelFormGroup\n- name=\"name\"\n- label={t('patient.diagnoses.diagnosisName')}\n- isEditable\n- placeholder={t('patient.diagnoses.diagnosisName')}\n- value={diagnosis.name}\n- onChange={onNameChange}\n- isRequired\n- feedback={t(diagnosisError?.name || '')}\n- isInvalid={!!diagnosisError?.name}\n- />\n- </div>\n- </div>\n- </div>\n- <div className=\"row\">\n- <div className=\"col-md-12\">\n- <DatePickerWithLabelFormGroup\n- name=\"diagnosisDate\"\n- label={t('patient.diagnoses.diagnosisDate')}\n- value={new Date(diagnosis.diagnosisDate)}\n- isEditable\n- onChange={onDiagnosisDateChange}\n- isRequired\n- feedback={t(diagnosisError?.date || '')}\n- isInvalid={!!diagnosisError?.date}\n+ <DiagnosisForm\n+ diagnosis={diagnosis}\n+ diagnosisError={diagnosisError}\n+ onChange={onDiagnosisChange}\n/>\n- </div>\n- </div>\n- </form>\n- </>\n)\nreturn (\n<Modal\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/patients/diagnoses/DiagnosisForm.tsx",
"diff": "+import { Alert, Row, Column } from '@hospitalrun/components'\n+import React, { useState } from 'react'\n+import { useTranslation } from 'react-i18next'\n+\n+import DatePickerWithLabelFormGroup from '../../shared/components/input/DatePickerWithLabelFormGroup'\n+import SelectWithLabelFormGroup, {\n+ Option,\n+} from '../../shared/components/input/SelectWithLableFormGroup'\n+import TextFieldWithLabelFormGroup from '../../shared/components/input/TextFieldWithLabelFormGroup'\n+import TextInputWithLabelFormGroup from '../../shared/components/input/TextInputWithLabelFormGroup'\n+import Diagnosis, { DiagnosisStatus } from '../../shared/model/Diagnosis'\n+\n+interface Error {\n+ message?: string\n+ name?: string\n+ diagnosisDate?: string\n+ onsetDate?: string\n+ abatementDate?: string\n+ status?: string\n+ note?: string\n+}\n+interface Props {\n+ diagnosis: Partial<Diagnosis>\n+ diagnosisError?: Error\n+ onChange?: (newDiagnosis: Partial<Diagnosis>) => void\n+ disabled: boolean\n+}\n+\n+const DiagnosisForm = (props: Props) => {\n+ const { t } = useTranslation()\n+ const { diagnosis, diagnosisError, disabled, onChange } = props\n+ const [status, setStatus] = useState(diagnosis.status)\n+\n+ const onFieldChange = (name: string, value: string | DiagnosisStatus) => {\n+ if (onChange) {\n+ const newDiagnosis = {\n+ ...diagnosis,\n+ [name]: value,\n+ }\n+ onChange(newDiagnosis)\n+ }\n+ }\n+\n+ const statusOptions: Option[] = Object.values(DiagnosisStatus).map((v) => ({\n+ label: v,\n+ value: v,\n+ }))\n+\n+ return (\n+ <form>\n+ {diagnosisError && (\n+ <Alert\n+ color=\"danger\"\n+ title={t('states.error')}\n+ message={t(diagnosisError?.message || '')}\n+ />\n+ )}\n+\n+ <Row>\n+ <Column md={12}>\n+ <TextInputWithLabelFormGroup\n+ isRequired\n+ value={diagnosis.name}\n+ label={t('patient.diagnoses.diagnosisName')}\n+ name=\"name\"\n+ feedback={t(diagnosisError?.name || '')}\n+ isInvalid={!!diagnosisError?.name}\n+ isEditable={!disabled}\n+ onChange={(event) => onFieldChange('name', event.currentTarget.value)}\n+ />\n+ </Column>\n+ </Row>\n+\n+ <Row>\n+ <Column md={12}>\n+ <DatePickerWithLabelFormGroup\n+ name=\"diagnosisDate\"\n+ label={t('patient.diagnoses.diagnosisDate')}\n+ value={diagnosis.diagnosisDate ? new Date(diagnosis.diagnosisDate) : new Date()}\n+ isEditable={!disabled}\n+ onChange={(date) => onFieldChange('diagnosisDate', date.toISOString())}\n+ isRequired\n+ feedback={t(diagnosisError?.diagnosisDate || '')}\n+ isInvalid={!!diagnosisError?.diagnosisDate}\n+ />\n+ </Column>\n+ </Row>\n+\n+ <Row>\n+ <Column md={12}>\n+ <DatePickerWithLabelFormGroup\n+ name=\"onsetDate\"\n+ label={t('patient.diagnoses.onsetDate')}\n+ value={diagnosis.onsetDate ? new Date(diagnosis.onsetDate) : new Date()}\n+ isEditable={!disabled}\n+ onChange={(date) => onFieldChange('onsetDate', date.toISOString())}\n+ isRequired\n+ feedback={t(diagnosisError?.onsetDate || '')}\n+ isInvalid={!!diagnosisError?.onsetDate}\n+ />\n+ </Column>\n+ </Row>\n+\n+ <Row>\n+ <Column md={12}>\n+ <DatePickerWithLabelFormGroup\n+ name=\"abatementDate\"\n+ label={t('patient.diagnoses.abatementDate')}\n+ value={diagnosis.abatementDate ? new Date(diagnosis.abatementDate) : new Date()}\n+ isEditable={!disabled}\n+ isRequired\n+ onChange={(date) => onFieldChange('abatementDate', date.toISOString())}\n+ feedback={t(diagnosisError?.abatementDate || '')}\n+ isInvalid={!!diagnosisError?.abatementDate}\n+ />\n+ </Column>\n+ </Row>\n+\n+ <Row>\n+ <Column md={12}>\n+ <SelectWithLabelFormGroup\n+ name=\"status\"\n+ label={t('patient.diagnoses.status')}\n+ isRequired\n+ options={statusOptions}\n+ defaultSelected={statusOptions.filter(({ value }) => value === status)}\n+ onChange={(values) => {\n+ onFieldChange('status', values[0])\n+ setStatus(values[0] as DiagnosisStatus)\n+ }}\n+ isEditable={!disabled}\n+ isInvalid={!!diagnosisError?.status}\n+ />\n+ </Column>\n+ </Row>\n+\n+ <Row>\n+ <Column md={12}>\n+ <TextFieldWithLabelFormGroup\n+ value={diagnosis.note}\n+ label={t('patient.diagnoses.note')}\n+ name=\"note\"\n+ feedback={t(diagnosisError?.note || '')}\n+ isInvalid={!!diagnosisError?.note}\n+ isEditable={!disabled}\n+ onChange={(event) => onFieldChange('note', event.currentTarget.value)}\n+ />\n+ </Column>\n+ </Row>\n+ </form>\n+ )\n+}\n+\n+DiagnosisForm.defaultProps = {\n+ disabled: false,\n+}\n+export default DiagnosisForm\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/patient-slice.ts",
"new_path": "src/patients/patient-slice.ts",
"diff": "@@ -57,6 +57,7 @@ interface AddDiagnosisError {\nmessage?: string\nname?: string\ndate?: string\n+ status?: string\n}\ninterface AddNoteError {\n@@ -354,6 +355,13 @@ function validateDiagnosis(diagnosis: Diagnosis) {\nerror.date = 'patient.diagnoses.error.dateRequired'\n}\n+ if (!diagnosis.onsetDate) {\n+ error.date = 'patient.diagnoses.error.dateRequired'\n+ }\n+\n+ if (!diagnosis.status) {\n+ error.status = 'patient.diagnoses.error.statusRequired'\n+ }\nreturn error\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/locales/enUs/translations/patient/index.ts",
"new_path": "src/shared/locales/enUs/translations/patient/index.ts",
"diff": "@@ -76,6 +76,16 @@ export default {\nnew: 'Add Diagnosis',\ndiagnosisName: 'Diagnosis Name',\ndiagnosisDate: 'Diagnosis Date',\n+ onsetDate: 'Onset Date',\n+ abatementDate: 'Abatement Date',\n+ status: 'Status',\n+ active: 'Active',\n+ recurrence: 'Recurrence',\n+ relapse: 'Relapse',\n+ inactive: 'Inactive',\n+ remission: 'Remission',\n+ resolved: 'Resolved',\n+ note: 'Note',\nwarning: {\nnoDiagnoses: 'No Diagnoses',\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/model/Diagnosis.ts",
"new_path": "src/shared/model/Diagnosis.ts",
"diff": "+export enum DiagnosisStatus {\n+ Active = 'active',\n+ Recurrence = 'recurrence',\n+ Relapse = 'relapse',\n+ Inactive = 'inactive',\n+ Remission = 'remisison',\n+ Resolved = 'resolved',\n+}\n+\nexport default interface Diagnosis {\nid: string\nname: string\ndiagnosisDate: string\n+ onsetDate: string\n+ abatementDate: string\n+ status: DiagnosisStatus\n+ note: string\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(diagnosis): adds new diagnosis fields (#2276) |
288,286 | 13.08.2020 01:02:57 | 14,400 | 7ca79bcda2d40ecd95fc8ed6ceffefac85249725 | fix(patient): successfully updated message should show actual text | [
{
"change_type": "MODIFY",
"old_path": "src/shared/locales/enUs/translations/patients/index.ts",
"new_path": "src/shared/locales/enUs/translations/patients/index.ts",
"diff": "@@ -11,6 +11,7 @@ export default {\nsuccessfullyCreated: 'Successfully created patient',\nsuccessfullyAddedNote: 'Successfully added the new note',\nsuccessfullyAddedRelatedPerson: 'Successfully added a new related person',\n+ successfullyUpdated: 'Successfully updated information for ',\npossibleDuplicatePatient: 'Possible duplicate patient:',\nduplicatePatientWarning:\n'Patient with matching information found in database. Are you sure you want to create this patient?',\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(patient): successfully updated message should show actual text |
288,286 | 13.08.2020 01:54:05 | 14,400 | fe3a71a0d1169071117adaf529aa5ff6a0a891ef | fix: remove console.log from tests output | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/incidents/hooks/useReportIncident.test.tsx",
"new_path": "src/__tests__/incidents/hooks/useReportIncident.test.tsx",
"diff": "@@ -11,6 +11,7 @@ import executeMutation from '../../test-utils/use-mutation.util'\ndescribe('useReportIncident', () => {\nbeforeEach(() => {\njest.restoreAllMocks()\n+ console.error = jest.fn()\n})\nit('should save the incident with correct data', async () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/incidents/report/ReportIncident.test.tsx",
"new_path": "src/__tests__/incidents/report/ReportIncident.test.tsx",
"diff": "@@ -25,6 +25,7 @@ describe('Report Incident', () => {\nbeforeEach(() => {\njest.resetAllMocks()\n+ console.error = jest.fn()\n})\nlet setButtonToolBarSpy: any\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/allergies/NewAllergyModal.test.tsx",
"new_path": "src/__tests__/patients/allergies/NewAllergyModal.test.tsx",
"diff": "@@ -24,6 +24,10 @@ describe('New Allergy Modal', () => {\nreturn { wrapper }\n}\n+ beforeEach(() => {\n+ console.error = jest.fn()\n+ })\n+\nit('should render a modal with the correct labels', () => {\nconst { wrapper } = setup()\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/patients/hooks/useAddAllergy.test.tsx",
"new_path": "src/__tests__/patients/hooks/useAddAllergy.test.tsx",
"diff": "@@ -9,6 +9,7 @@ import executeMutation from '../../test-utils/use-mutation.util'\ndescribe('use add allergy', () => {\nbeforeEach(() => {\njest.resetAllMocks()\n+ console.error = jest.fn()\n})\nit('should throw an error if allergy validation fails', async () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/patients/patients-slice.ts",
"new_path": "src/patients/patients-slice.ts",
"diff": "@@ -46,13 +46,9 @@ export const fetchPatients = (sortRequest: SortRequest = Unsorted): AppThunk =>\ndispatch(fetchPatientsSuccess(patients))\n}\n-export const searchPatients = (\n- searchString: string,\n- sortRequest: SortRequest = Unsorted,\n-): AppThunk => async (dispatch) => {\n+export const searchPatients = (searchString: string): AppThunk => async (dispatch) => {\ndispatch(fetchPatientsStart())\n- console.log(sortRequest)\nlet patients\nif (searchString.trim() === '') {\npatients = await PatientRepository.findAll()\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix: remove console.log from tests output |
288,323 | 13.08.2020 19:05:23 | 18,000 | 0818c115d08c8edb58f0b10b0b4df7d4a1ab2626 | fix(incidents): fix search incidents query not working | [
{
"change_type": "MODIFY",
"old_path": "src/incidents/hooks/useIncidents.tsx",
"new_path": "src/incidents/hooks/useIncidents.tsx",
"diff": "-import { useQuery } from 'react-query'\n+import { QueryKey, useQuery } from 'react-query'\nimport IncidentRepository from '../../shared/db/IncidentRepository'\nimport Incident from '../../shared/model/Incident'\nimport IncidentSearchRequest from '../model/IncidentSearchRequest'\n-function fetchIncidents(searchRequest: IncidentSearchRequest): Promise<Incident[]> {\n+function fetchIncidents(\n+ _: QueryKey<string>,\n+ searchRequest: IncidentSearchRequest,\n+): Promise<Incident[]> {\nreturn IncidentRepository.search(searchRequest)\n}\nexport default function useIncidents(searchRequest: IncidentSearchRequest) {\n- return useQuery(['incidents'], () => fetchIncidents(searchRequest))\n+ return useQuery(['incidents', searchRequest], fetchIncidents)\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(incidents): fix search incidents query not working |
288,323 | 13.08.2020 19:56:42 | 18,000 | ab6f3cc9590e9399220890a939e6e569032d1185 | fix: search should only pull back relevant document types | [
{
"change_type": "MODIFY",
"old_path": "src/shared/db/Repository.ts",
"new_path": "src/shared/db/Repository.ts",
"diff": "@@ -62,83 +62,24 @@ export default class Repository<T extends AbstractDBModel> {\nreturn relDocs[this.pluralType]\n}\n- // async findAllPaged(sort = Unsorted, pageRequest: PageRequest = UnpagedRequest): Promise<Page<T>> {\n- // const selector: any = {\n- // _id: { $gt: null },\n- // }\n- // if (pageRequest.direction === 'next') {\n- // sort.sorts.forEach((s) => {\n- // selector[s.field] = {\n- // $gte:\n- // pageRequest.nextPageInfo && pageRequest.nextPageInfo[s.field]\n- // ? pageRequest.nextPageInfo[s.field]\n- // : null,\n- // }\n- // })\n- // } else if (pageRequest.direction === 'previous') {\n- // sort.sorts.forEach((s) => {\n- // s.direction = s.direction === 'asc' ? 'desc' : 'asc'\n- // selector[s.field] = {\n- // $lte:\n- // pageRequest.previousPageInfo && pageRequest.previousPageInfo[s.field]\n- // ? pageRequest.previousPageInfo[s.field]\n- // : null,\n- // }\n- // })\n- // }\n- //\n- // const result = await this.db.find({\n- // selector,\n- // sort: sort.sorts.length > 0 ? sort.sorts.map((s) => ({ [s.field]: s.direction })) : undefined,\n- // limit: pageRequest.size ? pageRequest.size + 1 : undefined,\n- // })\n- // console.log(result)\n- //\n- // const mappedResult = result.docs.map(mapDocument)\n- // if (pageRequest.direction === 'previous') {\n- // mappedResult.reverse()\n- // }\n- //\n- // const nextPageInfo: { [key: string]: string } = {}\n- // const previousPageInfo: { [key: string]: string } = {}\n- //\n- // if (mappedResult.length > 0) {\n- // sort.sorts.forEach((s) => {\n- // nextPageInfo[s.field] = mappedResult[mappedResult.length - 1][s.field]\n- // })\n- // sort.sorts.forEach((s) => {\n- // previousPageInfo[s.field] = mappedResult[0][s.field]\n- // })\n- // }\n- //\n- // const hasNext: boolean =\n- // pageRequest.size !== undefined && mappedResult.length === pageRequest.size + 1\n- // const hasPrevious: boolean = pageRequest.number !== undefined && pageRequest.number > 1\n- //\n- // const pagedResult: Page<T> = {\n- // content:\n- // pageRequest.size !== undefined && mappedResult.length === pageRequest.size + 1\n- // ? mappedResult.slice(0, mappedResult.length - 1)\n- // : mappedResult,\n- // hasNext,\n- // hasPrevious,\n- // pageRequest: {\n- // size: pageRequest.size,\n- // number: pageRequest.number,\n- // nextPageInfo: hasNext ? nextPageInfo : undefined,\n- // previousPageInfo: hasPrevious ? previousPageInfo : undefined,\n- // },\n- // }\n- // return pagedResult\n- // }\n-\nasync count(): Promise<number> {\nconst result = await this.findAll()\nreturn result.length\n}\nasync search(criteria: any): Promise<T[]> {\n- const response = await this.db.find(criteria)\n+ const response = await this.db.find({\n+ selector: {\n+ $and: [\n+ {\n+ _id: {\n+ $regex: RegExp(this.type, 'i'),\n+ },\n+ },\n+ { ...criteria.selector },\n+ ],\n+ },\n+ })\nconst data = await this.db.rel.parseRelDocs(this.type, response.docs)\nreturn data[this.pluralType]\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix: search should only pull back relevant document types |
288,294 | 13.08.2020 23:24:20 | 14,400 | 546666afbb4856d95542580ec04b3e214238f027 | refactor(lab): rename lab request related buttons | [
{
"change_type": "MODIFY",
"old_path": "src/__tests__/labs/requests/NewLabRequest.test.tsx",
"new_path": "src/__tests__/labs/requests/NewLabRequest.test.tsx",
"diff": "@@ -97,7 +97,7 @@ describe('New Lab Request', () => {\nit('should render a save button', () => {\nconst saveButton = wrapper.find(Button).at(0)\nexpect(saveButton).toBeDefined()\n- expect(saveButton.text().trim()).toEqual('actions.save')\n+ expect(saveButton.text().trim()).toEqual('labs.requests.save')\n})\nit('should render a cancel button', () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/labs/requests/NewLabRequest.tsx",
"new_path": "src/labs/requests/NewLabRequest.tsx",
"diff": "@@ -121,7 +121,7 @@ const NewLabRequest = () => {\n<div className=\"row float-right\">\n<div className=\"btn-group btn-group-lg mt-3\">\n<Button className=\"mr-2\" color=\"success\" onClick={onSave}>\n- {t('actions.save')}\n+ {t('labs.requests.save')}\n</Button>\n<Button color=\"danger\" onClick={onCancel}>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/shared/locales/enUs/translations/labs/index.ts",
"new_path": "src/shared/locales/enUs/translations/labs/index.ts",
"diff": "@@ -13,7 +13,8 @@ export default {\n},\nrequests: {\nlabel: 'Lab Requests',\n- new: 'New Lab Request',\n+ new: 'Request Lab',\n+ save: 'Request',\nview: 'View Lab',\ncancel: 'Cancel Lab',\ncomplete: 'Complete Lab',\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | refactor(lab): rename lab request related buttons (#2301) |
288,366 | 16.08.2020 14:01:01 | -28,800 | 6575a7403bcc920b56ae6903232cf3ee8d09952b | feat(download csv of incident table): uses json2csv. filters data
updates package.json
re | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"@hospitalrun/components\": \"~1.16.0\",\n\"@reduxjs/toolkit\": \"~1.4.0\",\n\"@types/escape-string-regexp\": \"~2.0.1\",\n+ \"@types/json2csv\": \"~5.0.1\",\n\"@types/pouchdb-find\": \"~6.3.4\",\n\"bootstrap\": \"~4.5.0\",\n\"date-fns\": \"~2.15.0\",\n\"i18next\": \"~19.6.0\",\n\"i18next-browser-languagedetector\": \"~6.0.0\",\n\"i18next-xhr-backend\": \"~3.2.2\",\n+ \"json2csv\": \"~5.0.1\",\n\"lodash\": \"^4.17.15\",\n\"node-sass\": \"~4.14.0\",\n\"pouchdb\": \"~7.2.1\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/incidents/list/ViewIncidentsTable.tsx",
"new_path": "src/incidents/list/ViewIncidentsTable.tsx",
"diff": "-import { Spinner, Table } from '@hospitalrun/components'\n+import { Spinner, Table, Dropdown } from '@hospitalrun/components'\nimport format from 'date-fns/format'\n+import { Parser } from 'json2csv'\nimport React from 'react'\nimport { useHistory } from 'react-router'\n@@ -22,12 +23,67 @@ function ViewIncidentsTable(props: Props) {\nreturn <Spinner type=\"DotLoader\" loading />\n}\n+ // filter data\n+ const exportData = [{}]\n+ let first = true\n+ if (data != null) {\n+ data.forEach((elm) => {\n+ const entry = {\n+ code: elm.code,\n+ date: format(new Date(elm.date), 'yyyy-MM-dd hh:mm a'),\n+ reportedBy: elm.reportedBy,\n+ reportedOn: format(new Date(elm.reportedOn), 'yyyy-MM-dd hh:mm a'),\n+ status: elm.status,\n+ }\n+ if (first) {\n+ exportData[0] = entry\n+ first = false\n+ } else {\n+ exportData.push(entry)\n+ }\n+ })\n+ }\n+\n+ function downloadCSV() {\n+ const fields = Object.keys(exportData[0])\n+ const opts = { fields }\n+ const parser = new Parser(opts)\n+ const csv = parser.parse(exportData)\n+ console.log(csv)\n+\n+ const filename = 'IncidenntsCSV.csv'\n+ const text = csv\n+ const element = document.createElement('a')\n+ element.setAttribute('href', `data:text/plain;charset=utf-8,${encodeURIComponent(text)}`)\n+ element.setAttribute('download', filename)\n+\n+ element.style.display = 'none'\n+ document.body.appendChild(element)\n+\n+ element.click()\n+\n+ document.body.removeChild(element)\n+ }\n+\n+ const dropdownItems = [\n+ {\n+ onClick: function runfun() {\n+ downloadCSV()\n+ },\n+ text: 'CSV',\n+ },\n+ ]\n+\nreturn (\n+ <>\n<Table\ngetID={(row) => row.id}\ndata={data}\ncolumns={[\n- { label: t('incidents.reports.code'), key: 'code' },\n+ {\n+ label: t('incidents.reports.code'),\n+ key: 'code',\n+ },\n{\nlabel: t('incidents.reports.dateOfIncident'),\nkey: 'date',\n@@ -44,11 +100,21 @@ function ViewIncidentsTable(props: Props) {\nformatter: (row) =>\nrow.reportedOn ? format(new Date(row.reportedOn), 'yyyy-MM-dd hh:mm a') : '',\n},\n- { label: t('incidents.reports.status'), key: 'status' },\n+ {\n+ label: t('incidents.reports.status'),\n+ key: 'status',\n+ },\n]}\nactionsHeaderText={t('actions.label')}\n- actions={[{ label: t('actions.view'), action: (row) => history.push(`incidents/${row.id}`) }]}\n+ actions={[\n+ {\n+ label: t('actions.view'),\n+ action: (row) => history.push(`incidents/${row.id}`),\n+ },\n+ ]}\n/>\n+ <Dropdown direction=\"down\" variant=\"secondary\" text=\"DOWNLOAD\" items={dropdownItems} />\n+ </>\n)\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat(download csv of incident table): uses json2csv. filters data
updates package.json
re #2292 |
288,407 | 16.08.2020 12:44:33 | 14,400 | 7cc66ebe530e2449e6ae6e733a600d5b6881d2a7 | feat: imported LineGraph component and rendered it with dumby data | [
{
"change_type": "MODIFY",
"old_path": "src/incidents/visualize/VisualizeIncidents.tsx",
"new_path": "src/incidents/visualize/VisualizeIncidents.tsx",
"diff": "-import { Spinner } from '@hospitalrun/components'\n+import { Spinner, LineGraph } from '@hospitalrun/components'\nimport React from 'react'\nimport useIncidents from '../hooks/useIncidents'\n@@ -14,10 +14,48 @@ const VisualizeIncidents = () => {\nreturn <Spinner type=\"DotLoader\" loading />\n}\n+ // reportedOn: \"2020-08-12T19:53:30.153Z\"\n+ // we can use a function that splices the string at position 6-7 to get the month\n+\nconsole.log('data: ', data)\nreturn (\n<>\n- <h1>Hello from Visualize Incidents</h1>\n+ <LineGraph\n+ datasets={[\n+ {\n+ backgroundColor: 'blue',\n+ borderColor: 'red',\n+ data: [\n+ {\n+ x: 'January',\n+ y: 12,\n+ },\n+ {\n+ x: 'February',\n+ y: 11,\n+ },\n+ {\n+ x: 'March',\n+ y: 10,\n+ },\n+ ],\n+ label: 'Incidents',\n+ },\n+ ]}\n+ title=\"Reported Incidents Overtime\"\n+ xAxes={[\n+ {\n+ label: 'Months',\n+ type: 'category',\n+ },\n+ ]}\n+ yAxes={[\n+ {\n+ label: 'Numbers',\n+ type: 'linear',\n+ },\n+ ]}\n+ />\n</>\n)\n}\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat: imported LineGraph component and rendered it with dumby data |
288,407 | 16.08.2020 12:51:03 | 14,400 | 88bf19ba01edd47b0de7f60a8125e378645f258f | style: made the graph look better | [
{
"change_type": "MODIFY",
"old_path": "src/incidents/visualize/VisualizeIncidents.tsx",
"new_path": "src/incidents/visualize/VisualizeIncidents.tsx",
"diff": "@@ -24,7 +24,7 @@ const VisualizeIncidents = () => {\ndatasets={[\n{\nbackgroundColor: 'blue',\n- borderColor: 'red',\n+ borderColor: 'black',\ndata: [\n{\nx: 'January',\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | style: made the graph look better |
288,366 | 17.08.2020 19:06:26 | -28,800 | fd2ec6961f51dc7259b2c8872e60461a4eb1ae38 | fix(typo): fixed typo and used locale
re | [
{
"change_type": "MODIFY",
"old_path": "src/incidents/list/ViewIncidentsTable.tsx",
"new_path": "src/incidents/list/ViewIncidentsTable.tsx",
"diff": "@@ -51,7 +51,9 @@ function ViewIncidentsTable(props: Props) {\nconst csv = parser.parse(exportData)\nconsole.log(csv)\n- const filename = 'IncidenntsCSV.csv'\n+ const incidentsText = t('incidents.label')\n+ const filename = incidentsText.concat('.csv')\n+\nconst text = csv\nconst element = document.createElement('a')\nelement.setAttribute('href', `data:text/plain;charset=utf-8,${encodeURIComponent(text)}`)\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(typo): fixed typo and used locale
re #2292 |
288,267 | 17.08.2020 15:20:58 | -7,200 | a8d34e14ab89447bd2753248038907c89801f327 | fix(shared): pouchdb auth - add skip_setup flag
fix | [
{
"change_type": "MODIFY",
"old_path": "src/shared/config/pouchdb.ts",
"new_path": "src/shared/config/pouchdb.ts",
"diff": "@@ -18,14 +18,14 @@ let serverDb\nlet localDb\nif (process.env.NODE_ENV === 'test') {\n- serverDb = new PouchDB('hospitalrun', { adapter: 'memory' })\n- localDb = new PouchDB('local_hospitalrun', { adapter: 'memory' })\n+ serverDb = new PouchDB('hospitalrun', { skip_setup: true, adapter: 'memory' })\n+ localDb = new PouchDB('local_hospitalrun', { skip_setup: true, adapter: 'memory' })\n} else {\nserverDb = new PouchDB(`${process.env.REACT_APP_HOSPITALRUN_API}/hospitalrun`, {\nskip_setup: true,\n})\n- localDb = new PouchDB('local_hospitalrun')\n+ localDb = new PouchDB('local_hospitalrun', { skip_setup: true })\nlocalDb\n.sync(serverDb, { live: true, retry: true })\n.on('change', (info) => {\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix(shared): pouchdb auth - add skip_setup flag
fix #2256 |
288,268 | 18.08.2020 11:13:00 | -36,000 | 6434fd07784b4cddc886c5759b34dbbdab273006 | fix: react-hooks/exhaustive-deps warnings do not appear when running | [
{
"change_type": "MODIFY",
"old_path": ".eslintrc.js",
"new_path": ".eslintrc.js",
"diff": "@@ -6,6 +6,7 @@ module.exports = {\n'jest/globals': true,\n},\nextends: [\n+ 'react-app',\n'airbnb',\n'eslint:recommended',\n'plugin:@typescript-eslint/eslint-recommended',\n"
},
{
"change_type": "MODIFY",
"old_path": "src/__tests__/shared/components/network-status/NetworkStatusMessage.test.tsx",
"new_path": "src/__tests__/shared/components/network-status/NetworkStatusMessage.test.tsx",
"diff": "+import { renderHook } from '@testing-library/react-hooks'\nimport { render, shallow } from 'enzyme'\nimport React from 'react'\n@@ -16,10 +17,9 @@ const englishTranslationsMock = {\n'networkStatus.online': 'you are back online',\n}\n-const useTranslationReturnValue = useTranslation() as any\n-useTranslationReturnValue.t = (key: keyof typeof englishTranslationsMock) =>\n- englishTranslationsMock[key]\n-const { t } = useTranslationReturnValue\n+const { result } = renderHook(() => useTranslation() as any)\n+result.current.t = (key: keyof typeof englishTranslationsMock) => englishTranslationsMock[key]\n+const { t } = result.current\ndescribe('NetworkStatusMessage', () => {\nit('returns null if the app has always been online', () => {\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | fix: react-hooks/exhaustive-deps warnings do not appear when running
Co-authored-by: Matteo Vivona <[email protected]> |
288,407 | 17.08.2020 22:42:07 | 14,400 | 29a603e0db5df1a94aece929a2314cc812bf6dca | feat: partial implementation of useEffect hook | [
{
"change_type": "MODIFY",
"old_path": "src/incidents/visualize/VisualizeIncidents.tsx",
"new_path": "src/incidents/visualize/VisualizeIncidents.tsx",
"diff": "-import { Spinner, LineGraph } from '@hospitalrun/components'\n-import React from 'react'\n+import { LineGraph } from '@hospitalrun/components'\n+import React, { useEffect, useState } from 'react'\nimport useIncidents from '../hooks/useIncidents'\nimport IncidentFilter from '../IncidentFilter'\n@@ -9,15 +9,62 @@ const VisualizeIncidents = () => {\nconst searchFilter = IncidentFilter.reported\nconst searchRequest: IncidentSearchRequest = { status: searchFilter }\nconst { data, isLoading } = useIncidents(searchRequest)\n+ const [monthlyIncidents, setMonthlyIncidents] = useState({\n+ January: 0,\n+ February: 0,\n+ March: 0,\n+ April: 0,\n+ May: 0,\n+ June: 0,\n+ July: 0,\n+ August: 0,\n+ September: 0,\n+ November: 0,\n+ December: 0,\n+ })\n+ const getIncidentMonth = (reportedOn: string) => {\n+ // reportedOn: \"2020-08-12T19:53:30.153Z\"\n+ // splices the data.reportedOn string at position 5-6 to get the month\n+ const months = [\n+ 'January',\n+ 'February',\n+ 'March',\n+ 'April',\n+ 'May',\n+ 'June',\n+ 'July',\n+ 'August',\n+ 'September',\n+ 'November',\n+ 'December',\n+ ]\n+ return months[Number(reportedOn.slice(5, 7)) - 1]\n+ }\n+\n+ useEffect(() => {\nif (data === undefined || isLoading) {\n- return <Spinner type=\"DotLoader\" loading />\n+ console.log('data is undefined')\n+ } else {\n+ let incidentMonth: string\n+ const totalIncidents: number = data.length\n+ for (let incident = 0; incident < totalIncidents; incident += 1) {\n+ incidentMonth = getIncidentMonth(data[incident].reportedOn)\n+ setMonthlyIncidents((state) => ({\n+ ...state,\n+ // incidentMonth: incidentMonth + 1,\n+ }))\n+ console.log('incidentMonth: ', incidentMonth)\n}\n+ }\n+ }, [])\n- // reportedOn: \"2020-08-12T19:53:30.153Z\"\n- // we can use a function that splices the string at position 6-7 to get the month\n+ // if (data === undefined || isLoading) {\n+ // return <Spinner type=\"DotLoader\" loading />\n+ // }\n+\n+ console.log('August: ', monthlyIncidents.August)\n- console.log('data: ', data)\nreturn (\n<>\n<LineGraph\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat: partial implementation of useEffect hook |
288,407 | 17.08.2020 23:15:40 | 14,400 | 699be8c436122de63972db3bd4d9e90ebbfc06aa | feat: triggers a re-render on useEffect when data loads | [
{
"change_type": "MODIFY",
"old_path": "src/incidents/visualize/VisualizeIncidents.tsx",
"new_path": "src/incidents/visualize/VisualizeIncidents.tsx",
"diff": "@@ -46,6 +46,7 @@ const VisualizeIncidents = () => {\nif (data === undefined || isLoading) {\nconsole.log('data is undefined')\n} else {\n+ console.log('data:', data)\nlet incidentMonth: string\nconst totalIncidents: number = data.length\nfor (let incident = 0; incident < totalIncidents; incident += 1) {\n@@ -57,7 +58,7 @@ const VisualizeIncidents = () => {\nconsole.log('incidentMonth: ', incidentMonth)\n}\n}\n- }, [])\n+ }, [data])\n// if (data === undefined || isLoading) {\n// return <Spinner type=\"DotLoader\" loading />\n"
}
] | TypeScript | MIT License | hospitalrun/hospitalrun-frontend | feat: triggers a re-render on useEffect when data loads |
Subsets and Splits