Skip to content

Commit

Permalink
58745 VAMC updates (#24549)
Browse files Browse the repository at this point in the history
* 58745 Switch to optional fields for va-medical-records page

* 58745 Add const for empty facility name, unit test, fix tests

* 58745 Revert changes for optional fields, content updates
  • Loading branch information
christinec-fftc authored Jun 20, 2023
1 parent 301ca2d commit c3e9b17
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export const summaryOfEvidenceDescription = ({ formData }) => {
);

if (vaEvidence.length && vaEvidenceSelected) {
const facilitiesList = vaEvidence.map(facility => (
<li key={facility.treatmentCenterName}>{facility.treatmentCenterName}</li>
const facilitiesList = vaEvidence.map((facility, index) => (
<li key={index}>{facility.treatmentCenterName}</li>
));
vaContent = (
<div>
Expand Down Expand Up @@ -122,7 +122,7 @@ export const summaryOfEvidenceDescription = ({ formData }) => {
);
serviceTreatmentRecordsContent = (
<div>
<p>We'll submit the below service treatment records you uploaded:</p>
<p>Well submit the below service treatment records you uploaded:</p>
<ul>{serviceTreatmentRecordsUploadsList}</ul>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const replaceDay = date => date.replace('XX', '01');
export const treatmentView = ({ formData }) => {
const { from } = formData.treatmentDateRange;

const name = formData.treatmentCenterName || '';
const name = formData.treatmentCenterName;
let treatmentPeriod = '';
if (from) {
treatmentPeriod = formatDate(replaceDay(from), MONTH_YEAR);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import fullSchema from 'vets-json-schema/dist/21-526EZ-ALLCLAIMS-schema.json';
import { uiSchema as autoSuggestUiSchema } from 'platform/forms-system/src/js/definitions/autosuggest';
import dateUI from 'platform/forms-system/src/js/definitions/monthYear';

import { treatmentView } from '../content/vaMedicalRecords';
import { queryForFacilities, hasVAEvidence } from '../utils';
import { hasVAEvidence } from '../utils';
import { makeSchemaForAllDisabilities } from '../utils/schemas';

import {
Expand All @@ -17,12 +15,10 @@ import { USA } from '../constants';
const { vaTreatmentFacilities } = fullSchema.properties;

export const uiSchema = {
'ui:description':
'First we’ll ask you about your VA medical records for your claimed disability.',
'view:vaMedicalRecordsIntro': {
'ui:title': 'VA medical records',
'ui:description':
'Please tell us where VA treated you for your disability.',
'Tell us where VA has treated you for your disability. We’ll use the information you provide to help us locate your records and make decisions on your claim.',
},
vaTreatmentFacilities: {
'ui:options': {
Expand All @@ -45,17 +41,9 @@ export const uiSchema = {
'ui:options': {
itemAriaLabel: data => data.treatmentCenterName,
},
treatmentCenterName: autoSuggestUiSchema(
'Name of VA medical facility',
queryForFacilities,
{
'ui:options': { queryForResults: true, freeInput: true },
'ui:errorMessages': {
maxLength: 'Please enter a name with fewer than 100 characters.',
pattern: 'Please enter a valid name.',
},
},
),
treatmentCenterName: {
'ui:title': 'Name of VA medical facility',
},
treatedDisabilityNames: {
'ui:title':
'Please choose the conditions for which you received treatment at this facility.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('VA Medical Records', () => {
},
];

it('should render ', () => {
it('should render', () => {
const form = mount(
<DefinitionTester
definitions={formConfig.defaultDefinitions}
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('VA Medical Records', () => {
);

form.find('form').simulate('submit');
// Required fields: Facility name and related disability

expect(form.find('.usa-input-error-message').length).to.equal(0);
expect(onSubmit.called).to.be.true;
form.unmount();
Expand Down Expand Up @@ -199,7 +199,7 @@ describe('VA Medical Records', () => {
ratedDisabilities,
vaTreatmentFacilities: [
{
treatmentCenterName: 'Sommerset VA Clinic',
treatmentCenterName: 'Test clinic',
treatedDisabilityNames: {
diabetesmelitus: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { expect } from 'chai';
import { shallow } from 'enzyme';
import moment from 'moment';
import { minYear, maxYear } from 'platform/forms-system/src/js/helpers';
import { mockFetch, setFetchJSONResponse } from 'platform/testing/unit/helpers';

import {
SAVED_SEPARATION_DATE,
Expand All @@ -27,7 +26,6 @@ import {
needsToEnter781a,
needsToEnterUnemployability,
newConditionsOnly,
queryForFacilities,
ReservesGuardDescription,
servedAfter911,
viewifyFields,
Expand Down Expand Up @@ -182,56 +180,6 @@ describe('526 helpers', () => {
});
});

describe('queryForFacilities', () => {
beforeEach(() => {
mockFetch();
const response = [
{ id: 0, attributes: { name: 'first' } },
{ id: 1, attributes: { name: 'second' } },
];
setFetchJSONResponse(global.fetch.onCall(0), response);
});

/* un-skip these once we get a new enpoint in place; see #14028 */
it.skip('should not call the api if the input length is < 3', () => {
queryForFacilities('12');
expect(global.fetch.called).to.be.false;
});

it.skip('should call the api if the input length is >= 3', () => {
queryForFacilities('123');
expect(global.fetch.called).to.be.true;
});

it.skip('should call the api with the input', () => {
queryForFacilities('asdf');
expect(global.fetch.firstCall.args[0]).to.contain(
'/facilities/suggested?type%5B%5D=health&type%5B%5D=dod_health&name_part=asdf',
);
});

it.skip('should return the mapped data for autosuggest if successful', () => {
// Doesn't matter what we call this with since our stub will always return the same thing
const requestPromise = queryForFacilities('asdf');
return requestPromise.then(result => {
expect(result).to.eql([
{ id: 0, label: 'first' },
{ id: 1, label: 'second' },
]);
});
});

it('should return an empty array if unsuccessful', () => {
global.fetch.resolves({ ok: false });
// Doesn't matter what we call this with since our stub will always return the same thing
const requestPromise = queryForFacilities('asdf');
return requestPromise.then(result => {
// This .then() fires after the apiRequest failure callback returns []
expect(result).to.eql([]);
});
});
});

describe('hasotherEvidence', () => {
it('should return false if additional evidence type is not selected', () => {
const formData = {
Expand Down
36 changes: 0 additions & 36 deletions src/applications/disability-benefits/all-claims/utils/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import React from 'react';
import moment from 'moment';
import * as Sentry from '@sentry/browser';
// import appendQuery from 'append-query';
import { createSelector } from 'reselect';
import fastLevenshtein from 'fast-levenshtein';

Expand Down Expand Up @@ -212,41 +211,6 @@ export const hasForwardingAddress = formData =>
export const forwardingCountryIsUSA = formData =>
_.get('forwardingAddress.country', formData, '') === USA;

export function queryForFacilities(input = '') {
// Only search if the input has a length >= 3, otherwise, return an empty array
if (input.length < 3) {
return Promise.resolve([]);
}

/**
* Facilities endpoint removed for now, but we may be able to use EVSS's
* endpoint /referencedata/v1/treatmentcenter
* See https://github.com/department-of-veterans-affairs/va.gov-team/issues/14028#issuecomment-765717797
* /
const url = appendQuery('/facilities/suggested', {
type: ['health', 'dod_health'],
name_part: input, // eslint-disable-line camelcase
});
return apiRequest(url)
.then(response =>
response.data.map(facility => ({
id: facility.id,
label: facility.attributes.name,
})),
)
.catch(error => {
Sentry.withScope(scope => {
scope.setExtra('input', input);
scope.setExtra('error', error);
Sentry.captureMessage('Error querying for facilities');
});
return [];
});
/* */
return Promise.resolve([]);
}

export function getSeparationLocations() {
return apiRequest('/disability_compensation_form/separation_locations')
.then(({ separationLocations }) =>
Expand Down

0 comments on commit c3e9b17

Please sign in to comment.