From 1f19bb861164e41bbeb72f23979e65fe0b96efdc Mon Sep 17 00:00:00 2001
From: JohnD <52716187+JDarke@users.noreply.github.com>
Date: Tue, 21 Apr 2020 10:38:18 +0100
Subject: [PATCH 01/11] npm yarn install
---
package.json | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/package.json b/package.json
index eb7b4e0d18..f3ef11b5b6 100644
--- a/package.json
+++ b/package.json
@@ -31,7 +31,8 @@
"redux-thunk": "~2.3.0",
"shortid": "^2.2.15",
"typescript": "~3.8.2",
- "uuid": "^7.0.1"
+ "uuid": "^7.0.1",
+ "yarn": "~1.22.4"
},
"repository": {
"type": "git",
From 1d922c7c0dfa0537d3910c8ca2c4d9568c89190e Mon Sep 17 00:00:00 2001
From: JohnD <52716187+JDarke@users.noreply.github.com>
Date: Tue, 21 Apr 2020 12:31:19 +0100
Subject: [PATCH 02/11]
fix(src/components/input/textfieldwithlabelformgroup.tsx): update Label
Reason field on new appointment screen no longer a required field. Line 21, Label element now takes
isRequired attr from interface Props.
fix #1997
---
src/components/input/TextFieldWithLabelFormGroup.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/components/input/TextFieldWithLabelFormGroup.tsx b/src/components/input/TextFieldWithLabelFormGroup.tsx
index 86948b5760..3848ddf02a 100644
--- a/src/components/input/TextFieldWithLabelFormGroup.tsx
+++ b/src/components/input/TextFieldWithLabelFormGroup.tsx
@@ -14,11 +14,11 @@ interface Props {
}
const TextFieldWithLabelFormGroup = (props: Props) => {
- const { value, label, name, isEditable, isInvalid, feedback, onChange } = props
+ const { value, label, name, isEditable, isInvalid, isRequired, feedback, onChange } = props
const id = `${name}TextField`
return (
-
+
Date: Tue, 21 Apr 2020 18:35:26 +0100
Subject: [PATCH 03/11] revert(package.json): remove yarn listing
Previously added a listing for yarn in the dependencies in package.json. This commit undoes that.
re |
---
package.json | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/package.json b/package.json
index f3ef11b5b6..eb7b4e0d18 100644
--- a/package.json
+++ b/package.json
@@ -31,8 +31,7 @@
"redux-thunk": "~2.3.0",
"shortid": "^2.2.15",
"typescript": "~3.8.2",
- "uuid": "^7.0.1",
- "yarn": "~1.22.4"
+ "uuid": "^7.0.1"
},
"repository": {
"type": "git",
From 36b889eaec3e8542b21b5bfb7a42ccabfb33b28e Mon Sep 17 00:00:00 2001
From: JohnD <52716187+JDarke@users.noreply.github.com>
Date: Wed, 22 Apr 2020 19:14:38 +0100
Subject: [PATCH 04/11] test(textfieldwithlabelformgroup.test.tsx): add test to
Label isRequired
Added a test case to test if the Label receives the isRequired prop on required fields
re #2003
---
.../input/TextFieldWithLabelFormGroup.test.tsx | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/__tests__/components/input/TextFieldWithLabelFormGroup.test.tsx b/src/__tests__/components/input/TextFieldWithLabelFormGroup.test.tsx
index 8583fefdbc..f12db261e3 100644
--- a/src/__tests__/components/input/TextFieldWithLabelFormGroup.test.tsx
+++ b/src/__tests__/components/input/TextFieldWithLabelFormGroup.test.tsx
@@ -24,6 +24,24 @@ describe('text field with label form group', () => {
expect(label.prop('text')).toEqual(expectedName)
})
+ it('should render label as required if isRequired is true', () => {
+ const expectedName = 'test'
+ const wrapper = shallow(
+ ,
+ )
+
+ const label = wrapper.find(Label)
+ expect(label).toHaveLength(1)
+ expect(label.prop('isRequired')).toBeTruthy()
+ })
+
it('should render a text field', () => {
const expectedName = 'test'
const wrapper = shallow(
From add9c02dcbba19a7cb9cd95c25293e0ff62c3420 Mon Sep 17 00:00:00 2001
From: JohnD <52716187+JDarke@users.noreply.github.com>
Date: Thu, 23 Apr 2020 19:54:54 +0100
Subject: [PATCH 05/11] fix(patientrepository.ts): clean the search string of
illegal chars
Added a step to take the search string and remove all non-letter/whitespace characters. Line 16 and
22
fix #1999
---
src/clients/db/PatientRepository.ts | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/clients/db/PatientRepository.ts b/src/clients/db/PatientRepository.ts
index 5fb5937ed0..1ca2f17262 100644
--- a/src/clients/db/PatientRepository.ts
+++ b/src/clients/db/PatientRepository.ts
@@ -13,12 +13,13 @@ export class PatientRepository extends Repository {
}
async search(text: string): Promise {
+ const cleanText = text.replace(/\\/g, '')
return super.search({
selector: {
$or: [
{
fullName: {
- $regex: RegExp(text, 'i'),
+ $regex: RegExp(cleanText, 'i'),
},
},
{
From 57144a248a0ac909b400bb7dba482af9d5439d73 Mon Sep 17 00:00:00 2001
From: JohnD <52716187+JDarke@users.noreply.github.com>
Date: Thu, 23 Apr 2020 19:59:51 +0100
Subject: [PATCH 06/11] fix(patientrepository.ts): clean search string of
illegal chars
Added a step to remove all non-alphabetical and whitespace characters from search string regex
fix #1999
---
src/clients/db/PatientRepository.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/clients/db/PatientRepository.ts b/src/clients/db/PatientRepository.ts
index 1ca2f17262..30d2b7bd7c 100644
--- a/src/clients/db/PatientRepository.ts
+++ b/src/clients/db/PatientRepository.ts
@@ -13,7 +13,7 @@ export class PatientRepository extends Repository {
}
async search(text: string): Promise {
- const cleanText = text.replace(/\\/g, '')
+ const cleanText = text.replace(/\\[^a-zA-Z ]/g, '')
return super.search({
selector: {
$or: [
From 0ffef66d15a70954cddd25ff9caa7720c4966e34 Mon Sep 17 00:00:00 2001
From: JohnD <52716187+JDarke@users.noreply.github.com>
Date: Fri, 24 Apr 2020 10:55:59 +0100
Subject: [PATCH 07/11] fix(patientrepository.ts): clean search string of
special chars
Removed special chars that interfered with RegExp in search strings
re #1999
---
src/clients/db/PatientRepository.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/clients/db/PatientRepository.ts b/src/clients/db/PatientRepository.ts
index 30d2b7bd7c..e20ce62e95 100644
--- a/src/clients/db/PatientRepository.ts
+++ b/src/clients/db/PatientRepository.ts
@@ -13,7 +13,7 @@ export class PatientRepository extends Repository {
}
async search(text: string): Promise {
- const cleanText = text.replace(/\\[^a-zA-Z ]/g, '')
+ const cleanText = text.replace(/[\\[()?*]+/g, '')
return super.search({
selector: {
$or: [
From fccc1451fd0c25f394444f4dfe4f94655cf019ef Mon Sep 17 00:00:00 2001
From: JohnD <52716187+JDarke@users.noreply.github.com>
Date: Sat, 25 Apr 2020 15:40:12 +0100
Subject: [PATCH 08/11] test(patientrepository.test.ts): add test for search
string clean regex
Added a test to pass a search string including all prohibited chars, expects cleaned version of
string to be used for search.
re #1999
---
package.json | 1 +
src/__tests__/clients/db/PatientRepository.test.ts | 9 +++++++++
src/clients/db/PatientRepository.ts | 2 +-
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 15353500bd..5ef3edd137 100644
--- a/package.json
+++ b/package.json
@@ -13,6 +13,7 @@
"i18next": "~19.4.0",
"i18next-browser-languagedetector": "~4.1.0",
"i18next-xhr-backend": "~3.2.2",
+ "mocha": "~7.1.1",
"node-sass": "~4.13.0",
"pouchdb": "~7.2.1",
"pouchdb-adapter-memory": "~7.2.1",
diff --git a/src/__tests__/clients/db/PatientRepository.test.ts b/src/__tests__/clients/db/PatientRepository.test.ts
index 1aa405e332..a5ae942af1 100644
--- a/src/__tests__/clients/db/PatientRepository.test.ts
+++ b/src/__tests__/clients/db/PatientRepository.test.ts
@@ -39,6 +39,15 @@ describe('patient repository', () => {
await removeAllDocs()
})
+ it('should remove all breaking special chars from search text', async () => {
+ await patients.put({ _id: 'id9999', code: 'P00001', fullName: 'test test' })
+
+ const result = await PatientRepository.search(']?t}e(s){t** te[\\st')
+
+ expect(result).toHaveLength(1)
+ expect(result[0].id).toEqual('id9999')
+ })
+
it('should return all records that patient code matches search text', async () => {
// same full name to prove that it is finding by patient code
const expectedPatientCode = 'P00001'
diff --git a/src/clients/db/PatientRepository.ts b/src/clients/db/PatientRepository.ts
index e20ce62e95..2b849364f8 100644
--- a/src/clients/db/PatientRepository.ts
+++ b/src/clients/db/PatientRepository.ts
@@ -13,7 +13,7 @@ export class PatientRepository extends Repository {
}
async search(text: string): Promise {
- const cleanText = text.replace(/[\\[()?*]+/g, '')
+ const cleanText = text.replace(/[\\[\](){}?*]+/g, '')
return super.search({
selector: {
$or: [
From 7347207c96cbd8c2ef1189575aaf6d7df191ba2f Mon Sep 17 00:00:00 2001
From: JohnD <52716187+JDarke@users.noreply.github.com>
Date: Sat, 25 Apr 2020 17:07:39 +0100
Subject: [PATCH 09/11] revert(package.json): undo mocha dependency in
package.json
Removing mocha listed dependency added in error
re #1999
---
package.json | 1 -
1 file changed, 1 deletion(-)
diff --git a/package.json b/package.json
index 5ef3edd137..15353500bd 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,6 @@
"i18next": "~19.4.0",
"i18next-browser-languagedetector": "~4.1.0",
"i18next-xhr-backend": "~3.2.2",
- "mocha": "~7.1.1",
"node-sass": "~4.13.0",
"pouchdb": "~7.2.1",
"pouchdb-adapter-memory": "~7.2.1",
From b603dd14de32ee291ec342041e2faa98a01f7e84 Mon Sep 17 00:00:00 2001
From: JohnD <52716187+JDarke@users.noreply.github.com>
Date: Tue, 28 Apr 2020 18:07:09 +0100
Subject: [PATCH 10/11] fix(src/clients/db/patientrepository.ts): add
escapeStringRegex package
Added escapeStringRegexp package to escape special chars in search string for p
fix #1999
---
package.json | 1 +
.../clients/db/PatientRepository.test.ts | 6 +++---
src/clients/db/PatientRepository.ts | 5 +++--
src/components/Sidebar.tsx | 18 ++++++++----------
4 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/package.json b/package.json
index 15353500bd..6152646a8f 100644
--- a/package.json
+++ b/package.json
@@ -10,6 +10,7 @@
"@types/pouchdb-find": "~6.3.4",
"bootstrap": "~4.4.1",
"date-fns": "~2.12.0",
+ "escape-string-regexp": "~4.0.0",
"i18next": "~19.4.0",
"i18next-browser-languagedetector": "~4.1.0",
"i18next-xhr-backend": "~3.2.2",
diff --git a/src/__tests__/clients/db/PatientRepository.test.ts b/src/__tests__/clients/db/PatientRepository.test.ts
index a5ae942af1..e45cd7262b 100644
--- a/src/__tests__/clients/db/PatientRepository.test.ts
+++ b/src/__tests__/clients/db/PatientRepository.test.ts
@@ -39,10 +39,10 @@ describe('patient repository', () => {
await removeAllDocs()
})
- it('should remove all breaking special chars from search text', async () => {
- await patients.put({ _id: 'id9999', code: 'P00001', fullName: 'test test' })
+ it('should escape all special chars from search text', async () => {
+ await patients.put({ _id: 'id9999', code: 'P00001', fullName: 'test -]?}(){*[\\$+.^test' })
- const result = await PatientRepository.search(']?t}e(s){t** te[\\st')
+ const result = await PatientRepository.search('test -]?}(){*[\\$+.^test')
expect(result).toHaveLength(1)
expect(result[0].id).toEqual('id9999')
diff --git a/src/clients/db/PatientRepository.ts b/src/clients/db/PatientRepository.ts
index 2b849364f8..99a239685e 100644
--- a/src/clients/db/PatientRepository.ts
+++ b/src/clients/db/PatientRepository.ts
@@ -1,3 +1,4 @@
+import escapeStringRegexp from 'escape-string-regexp'
import shortid from 'shortid'
import Patient from '../../model/Patient'
import Repository from './Repository'
@@ -13,13 +14,13 @@ export class PatientRepository extends Repository {
}
async search(text: string): Promise {
- const cleanText = text.replace(/[\\[\](){}?*]+/g, '')
+ const escapedString = escapeStringRegexp(text)
return super.search({
selector: {
$or: [
{
fullName: {
- $regex: RegExp(cleanText, 'i'),
+ $regex: RegExp(escapedString, 'i'),
},
},
{
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index d4ed204d4f..e70dfcd5e3 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -55,22 +55,20 @@ const Sidebar = () => {
cursor: 'pointer',
fontSize: 'small',
borderBottomWidth: 0,
- color:
- (splittedPath[1].includes('patients') || splittedPath[1].includes('appointments')) &&
- splittedPath.length > 2
- ? 'white'
- : 'black',
+ borderTopWidth: 0,
+ color: 'black',
+ padding: '.6rem 1.25rem',
+ backgroundColor: 'rgba(245,245,245,1)',
}
const listSubItemStyle: CSSProperties = {
cursor: 'pointer',
fontSize: 'small',
borderBottomWidth: 0,
- color:
- (splittedPath[1].includes('patients') || splittedPath[1].includes('appointments')) &&
- splittedPath.length < 3
- ? 'white'
- : 'black',
+ borderTopWidth: 0,
+ color: 'black',
+ padding: '.6rem 1.25rem',
+ backgroundColor: 'rgba(245,245,245,1)',
}
const getDashboardLink = () => (
From f4dccc8c274d3534f4ef9b1d04544dcbdcc5d071 Mon Sep 17 00:00:00 2001
From: JohnD <52716187+JDarke@users.noreply.github.com>
Date: Fri, 1 May 2020 14:57:27 +0100
Subject: [PATCH 11/11] fix(appointmentrepository.ts): add escapeStringRegex to
appointment srch
Added escapeStringRegexp to AppointmentRepository.ts to escape regex chars in appointment search
feild in patient info area.
fix #2029
---
.../clients/db/AppointmentRepository.test.ts | 17 ++++++++++++++++-
src/clients/db/AppointmentRepository.ts | 8 +++++---
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/src/__tests__/clients/db/AppointmentRepository.test.ts b/src/__tests__/clients/db/AppointmentRepository.test.ts
index f05e4d4ebb..042b4e8c96 100644
--- a/src/__tests__/clients/db/AppointmentRepository.test.ts
+++ b/src/__tests__/clients/db/AppointmentRepository.test.ts
@@ -1,5 +1,5 @@
import AppointmentRepository from 'clients/db/AppointmentRepository'
-import { appointments } from 'config/pouchdb'
+import { appointments, patients } from 'config/pouchdb'
import Appointment from 'model/Appointment'
const uuidV4Regex = /^[A-F\d]{8}-[A-F\d]{4}-4[A-F\d]{3}-[89AB][A-F\d]{3}-[A-F\d]{12}$/i
@@ -24,6 +24,21 @@ describe('Appointment Repository', () => {
})
})
+ describe('searchPatientAppointments', () => {
+ it('should escape all special chars from search text', async () => {
+ await patients.put({ _id: 'id2222' })
+ await appointments.put({ _id: 'id3333', patientId: 'id2222', location: 'id-]?}(){*[$+.^\\' })
+
+ const result = await AppointmentRepository.searchPatientAppointments(
+ 'id2222',
+ 'id-]?}(){*[$+.^\\',
+ )
+
+ expect(result).toHaveLength(1)
+ expect(result[0].id).toEqual('id3333')
+ })
+ })
+
describe('save', () => {
it('should create an id that is a uuid', async () => {
const newAppointment = await AppointmentRepository.save({
diff --git a/src/clients/db/AppointmentRepository.ts b/src/clients/db/AppointmentRepository.ts
index 7fe1433af5..42ba8dce42 100644
--- a/src/clients/db/AppointmentRepository.ts
+++ b/src/clients/db/AppointmentRepository.ts
@@ -1,3 +1,4 @@
+import escapeStringRegexp from 'escape-string-regexp'
import Appointment from 'model/Appointment'
import { appointments } from 'config/pouchdb'
import Repository from './Repository'
@@ -9,6 +10,7 @@ export class AppointmentRepository extends Repository {
// Fuzzy search for patient appointments. Used for patient appointment search bar
async searchPatientAppointments(patientId: string, text: string): Promise {
+ const escapedString = escapeStringRegexp(text)
return super.search({
selector: {
$and: [
@@ -19,17 +21,17 @@ export class AppointmentRepository extends Repository {
$or: [
{
location: {
- $regex: RegExp(text, 'i'),
+ $regex: RegExp(escapedString, 'i'),
},
},
{
reason: {
- $regex: RegExp(text, 'i'),
+ $regex: RegExp(escapedString, 'i'),
},
},
{
type: {
- $regex: RegExp(text, 'i'),
+ $regex: RegExp(escapedString, 'i'),
},
},
],