From dbcba94057cbf1144649ca662da4d635acf56a11 Mon Sep 17 00:00:00 2001 From: Clint Beacock Date: Tue, 29 Mar 2022 14:05:01 -0400 Subject: [PATCH 1/4] [WEB-1495] Add clinician attestation to clinic patient creation form --- app/components/clinic/PatientForm.js | 23 +++++++++++++++++++++++ app/core/clinicUtils.js | 7 +++++++ test/unit/app/core/clinicUtils.test.js | 6 ++++-- test/unit/pages/ClinicPatients.test.js | 4 ++++ test/unit/pages/ClinicianPatients.test.js | 4 ++++ 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/app/components/clinic/PatientForm.js b/app/components/clinic/PatientForm.js index c1bd83c799..993b0df80f 100644 --- a/app/components/clinic/PatientForm.js +++ b/app/components/clinic/PatientForm.js @@ -11,10 +11,12 @@ import { Box, BoxProps } from 'rebass/styled-components'; import * as actions from '../../redux/actions'; import TextInput from '../../components/elements/TextInput'; +import Checkbox from '../../components/elements/Checkbox'; import { getCommonFormikFieldProps } from '../../core/forms'; import { dateRegex, patientSchema as validationSchema } from '../../core/clinicUtils'; import { accountInfoFromClinicPatient } from '../../core/personutils'; import { Body1 } from '../../components/elements/FontStyles'; +import baseTheme from '../../themes/baseTheme'; export const PatientForm = (props) => { const { t, api, onFormChange, patient, trackMetric, ...boxProps } = props; @@ -69,9 +71,11 @@ export const PatientForm = (props) => { function getFormValues(source) { return { + attestationConfirmed: get(source, 'attestationConfirmed', false), birthDate: get(source, 'birthDate', ''), email: get(source, 'email', ''), fullName: get(source, 'fullName', ''), + id: get(source, 'id'), mrn: get(source, 'mrn', ''), }; } @@ -149,6 +153,25 @@ export const PatientForm = (props) => { {t('If you want your patients to upload their data from home, you must include their email address.')} + + {!patient?.id && ( + + + + )} ); }; diff --git a/app/core/clinicUtils.js b/app/core/clinicUtils.js index 4012169b84..eaaa5d51e6 100644 --- a/app/core/clinicUtils.js +++ b/app/core/clinicUtils.js @@ -1,6 +1,7 @@ import * as yup from 'yup'; import get from 'lodash/get'; import includes from 'lodash/includes'; +import isEmpty from 'lodash/isEmpty'; import keys from 'lodash/keys'; import map from 'lodash/map'; import moment from 'moment'; @@ -126,6 +127,7 @@ export const clinicSchema = yup.object().shape({ }); export const patientSchema = yup.object().shape({ + id: yup.string(), fullName: yup.string().required(t('Please enter the patient\'s full name')), birthDate: yup.date() .min(moment().subtract(130, 'years').format(dateFormat), t('Please enter a date within the last 130 years')) @@ -133,4 +135,9 @@ export const patientSchema = yup.object().shape({ .required(t('Patient\'s birthday is required')), mrn: yup.string(), email: yup.string().email(t('Please enter a valid email address')), + attestationConfirmed: yup.mixed().notRequired().when('id', { + is: id => isEmpty(id), + then: yup.boolean() + .test('isTrue', t('Please confirm that you have obtained this permission'), value => (value === true)), + }), }); diff --git a/test/unit/app/core/clinicUtils.test.js b/test/unit/app/core/clinicUtils.test.js index 03ee0d5503..0ba495bc20 100644 --- a/test/unit/app/core/clinicUtils.test.js +++ b/test/unit/app/core/clinicUtils.test.js @@ -123,13 +123,15 @@ describe('clinicUtils', function() { }); describe('patientSchema', () => { - it('should return a yup schema for clinic fields', () => { + it('should return a yup schema for clinic patient fields', () => { expect(clinicUtils.patientSchema).to.be.an('object'); expect(clinicUtils.patientSchema._nodes).to.be.an('array').and.have.members([ - 'fullName', + 'attestationConfirmed', 'birthDate', 'email', + 'fullName', + 'id', 'mrn', ]); }); diff --git a/test/unit/pages/ClinicPatients.test.js b/test/unit/pages/ClinicPatients.test.js index 3a84596905..ca02ec834a 100644 --- a/test/unit/pages/ClinicPatients.test.js +++ b/test/unit/pages/ClinicPatients.test.js @@ -220,6 +220,10 @@ describe('ClinicPatients', () => { patientForm().find('input[name="email"]').simulate('change', { persist: noop, target: { name: 'email', value: 'patient@test.ca' } }); expect(patientForm().find('input[name="email"]').prop('value')).to.equal('patient@test.ca'); + expect(patientForm().find('input[name="attestationConfirmed"]').prop('checked')).to.be.false; + patientForm().find('input[name="attestationConfirmed"]').simulate('change', { persist: noop, target: { name: 'attestationConfirmed', value: true } }); + expect(patientForm().find('input[name="attestationConfirmed"]').prop('checked')).to.be.true; + store.clearActions(); dialog().find('Button#addPatientConfirm').simulate('click'); diff --git a/test/unit/pages/ClinicianPatients.test.js b/test/unit/pages/ClinicianPatients.test.js index a9c584f203..1a6a75a80a 100644 --- a/test/unit/pages/ClinicianPatients.test.js +++ b/test/unit/pages/ClinicianPatients.test.js @@ -190,6 +190,10 @@ describe('ClinicianPatients', () => { patientForm().find('input[name="email"]').simulate('change', { persist: noop, target: { name: 'email', value: 'patient@test.ca' } }); expect(patientForm().find('input[name="email"]').prop('value')).to.equal('patient@test.ca'); + expect(patientForm().find('input[name="attestationConfirmed"]').prop('checked')).to.be.false; + patientForm().find('input[name="attestationConfirmed"]').simulate('change', { persist: noop, target: { name: 'attestationConfirmed', value: true } }); + expect(patientForm().find('input[name="attestationConfirmed"]').prop('checked')).to.be.true; + store.clearActions(); dialog().find('Button#addPatientConfirm').simulate('click'); From d4b0563081443189be61f7e8fd9c7f0f29c48642 Mon Sep 17 00:00:00 2001 From: Clint Beacock Date: Tue, 29 Mar 2022 15:29:29 -0400 Subject: [PATCH 2/4] [WEB-1495] v1.53.0-web-1495-patient-form-attestation --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a50a81bb99..c3bb9bd2f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blip", - "version": "1.53.0-web-1078-daily-view-date-picker.1", + "version": "1.53.0-web-1495-patient-form-attestation", "private": true, "scripts": { "test": "TZ=UTC NODE_ENV=test ./node_modules/karma/bin/karma start", From 5063e82a8a20cdc1b7a1cbf96d11b7da91adc5bd Mon Sep 17 00:00:00 2001 From: Clint Beacock Date: Tue, 19 Apr 2022 11:19:05 -0400 Subject: [PATCH 3/4] [WEB-1495] Change attestationConfirmed to attestationSubmitted in patient form --- app/components/clinic/PatientForm.js | 4 ++-- app/core/clinicUtils.js | 2 +- test/unit/app/core/clinicUtils.test.js | 2 +- test/unit/pages/ClinicPatients.test.js | 6 +++--- test/unit/pages/ClinicianPatients.test.js | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/components/clinic/PatientForm.js b/app/components/clinic/PatientForm.js index 993b0df80f..366c6d8cb6 100644 --- a/app/components/clinic/PatientForm.js +++ b/app/components/clinic/PatientForm.js @@ -71,7 +71,7 @@ export const PatientForm = (props) => { function getFormValues(source) { return { - attestationConfirmed: get(source, 'attestationConfirmed', false), + attestationSubmitted: get(source, 'attestationSubmitted', false), birthDate: get(source, 'birthDate', ''), email: get(source, 'email', ''), fullName: get(source, 'fullName', ''), @@ -166,7 +166,7 @@ export const PatientForm = (props) => { }} > diff --git a/app/core/clinicUtils.js b/app/core/clinicUtils.js index eaaa5d51e6..c911f8f433 100644 --- a/app/core/clinicUtils.js +++ b/app/core/clinicUtils.js @@ -135,7 +135,7 @@ export const patientSchema = yup.object().shape({ .required(t('Patient\'s birthday is required')), mrn: yup.string(), email: yup.string().email(t('Please enter a valid email address')), - attestationConfirmed: yup.mixed().notRequired().when('id', { + attestationSubmitted: yup.mixed().notRequired().when('id', { is: id => isEmpty(id), then: yup.boolean() .test('isTrue', t('Please confirm that you have obtained this permission'), value => (value === true)), diff --git a/test/unit/app/core/clinicUtils.test.js b/test/unit/app/core/clinicUtils.test.js index 0ba495bc20..caf2c1a218 100644 --- a/test/unit/app/core/clinicUtils.test.js +++ b/test/unit/app/core/clinicUtils.test.js @@ -127,7 +127,7 @@ describe('clinicUtils', function() { expect(clinicUtils.patientSchema).to.be.an('object'); expect(clinicUtils.patientSchema._nodes).to.be.an('array').and.have.members([ - 'attestationConfirmed', + 'attestationSubmitted', 'birthDate', 'email', 'fullName', diff --git a/test/unit/pages/ClinicPatients.test.js b/test/unit/pages/ClinicPatients.test.js index ca02ec834a..1e4a4d4847 100644 --- a/test/unit/pages/ClinicPatients.test.js +++ b/test/unit/pages/ClinicPatients.test.js @@ -220,9 +220,9 @@ describe('ClinicPatients', () => { patientForm().find('input[name="email"]').simulate('change', { persist: noop, target: { name: 'email', value: 'patient@test.ca' } }); expect(patientForm().find('input[name="email"]').prop('value')).to.equal('patient@test.ca'); - expect(patientForm().find('input[name="attestationConfirmed"]').prop('checked')).to.be.false; - patientForm().find('input[name="attestationConfirmed"]').simulate('change', { persist: noop, target: { name: 'attestationConfirmed', value: true } }); - expect(patientForm().find('input[name="attestationConfirmed"]').prop('checked')).to.be.true; + expect(patientForm().find('input[name="attestationSubmitted"]').prop('checked')).to.be.false; + patientForm().find('input[name="attestationSubmitted"]').simulate('change', { persist: noop, target: { name: 'attestationSubmitted', value: true } }); + expect(patientForm().find('input[name="attestationSubmitted"]').prop('checked')).to.be.true; store.clearActions(); dialog().find('Button#addPatientConfirm').simulate('click'); diff --git a/test/unit/pages/ClinicianPatients.test.js b/test/unit/pages/ClinicianPatients.test.js index 1a6a75a80a..a816607891 100644 --- a/test/unit/pages/ClinicianPatients.test.js +++ b/test/unit/pages/ClinicianPatients.test.js @@ -190,9 +190,9 @@ describe('ClinicianPatients', () => { patientForm().find('input[name="email"]').simulate('change', { persist: noop, target: { name: 'email', value: 'patient@test.ca' } }); expect(patientForm().find('input[name="email"]').prop('value')).to.equal('patient@test.ca'); - expect(patientForm().find('input[name="attestationConfirmed"]').prop('checked')).to.be.false; - patientForm().find('input[name="attestationConfirmed"]').simulate('change', { persist: noop, target: { name: 'attestationConfirmed', value: true } }); - expect(patientForm().find('input[name="attestationConfirmed"]').prop('checked')).to.be.true; + expect(patientForm().find('input[name="attestationSubmitted"]').prop('checked')).to.be.false; + patientForm().find('input[name="attestationSubmitted"]').simulate('change', { persist: noop, target: { name: 'attestationSubmitted', value: true } }); + expect(patientForm().find('input[name="attestationSubmitted"]').prop('checked')).to.be.true; store.clearActions(); dialog().find('Button#addPatientConfirm').simulate('click'); From 21d23672299da4ed407c440a056c928c15ba5217 Mon Sep 17 00:00:00 2001 From: Clint Beacock Date: Mon, 30 May 2022 14:46:06 -0400 Subject: [PATCH 4/4] [WEB-1495] Fix unit tests --- test/unit/pages/ClinicPatients.test.js | 4 ++++ test/unit/pages/ClinicianPatients.test.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/test/unit/pages/ClinicPatients.test.js b/test/unit/pages/ClinicPatients.test.js index d434948598..acee05a68b 100644 --- a/test/unit/pages/ClinicPatients.test.js +++ b/test/unit/pages/ClinicPatients.test.js @@ -473,6 +473,10 @@ describe('ClinicPatients', () => { patientForm().find('input[name="email"]').simulate('change', { persist: noop, target: { name: 'email', value: 'patient@test.ca' } }); expect(patientForm().find('input[name="email"]').prop('value')).to.equal('patient@test.ca'); + expect(patientForm().find('input[name="attestationSubmitted"]').prop('checked')).to.be.false; + patientForm().find('input[name="attestationSubmitted"]').simulate('change', { persist: noop, target: { name: 'attestationSubmitted', value: true } }); + expect(patientForm().find('input[name="attestationSubmitted"]').prop('checked')).to.be.true; + expect(dialog().find('Button#addPatientConfirm').prop('disabled')).to.be.true; patientForm().find('input[name="birthDate"]').simulate('change', { persist: noop, target: { name: 'birthDate', value: '11/21/1999' } }); diff --git a/test/unit/pages/ClinicianPatients.test.js b/test/unit/pages/ClinicianPatients.test.js index 6904432330..5c86df65e2 100644 --- a/test/unit/pages/ClinicianPatients.test.js +++ b/test/unit/pages/ClinicianPatients.test.js @@ -264,6 +264,10 @@ describe('ClinicianPatients', () => { patientForm().find('input[name="email"]').simulate('change', { persist: noop, target: { name: 'email', value: 'patient@test.ca' } }); expect(patientForm().find('input[name="email"]').prop('value')).to.equal('patient@test.ca'); + expect(patientForm().find('input[name="attestationSubmitted"]').prop('checked')).to.be.false; + patientForm().find('input[name="attestationSubmitted"]').simulate('change', { persist: noop, target: { name: 'attestationSubmitted', value: true } }); + expect(patientForm().find('input[name="attestationSubmitted"]').prop('checked')).to.be.true; + expect(dialog().find('Button#addPatientConfirm').prop('disabled')).to.be.true; patientForm().find('input[name="birthDate"]').simulate('change', { persist: noop, target: { name: 'birthDate', value: '11/21/1999' } });