Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VAMC system/facilities selectors, connectors, and tests #27557

Merged
merged 5 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { connectDrupalStaticDataFile } from '../../../connect';
import { preProcessSystemData } from './preProcess';

export const connectDrupalStaticDataFileVamcSystem = dispatch => {
connectDrupalStaticDataFile(dispatch, {
fileName: 'vamc-system.json',
preProcess: preProcessSystemData,
statePropName: 'vamcSystemData',
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Structure of vamcSystemData:
*
* {
* "data": {
* "systems": {
* "VAMC System name": {
* "vhaId": "Facility name",
* }
* }
* }
* }
* vhaId is used to lookup the facility in whatever other source it's needed (e.g. police data is id'ed by facility vhaId)
*/

export const preProcessSystemData = vamcSystemData => {
return vamcSystemData;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// breaks unit tests if we use the workspace import
// eslint-disable-next-line @department-of-veterans-affairs/use-workspace-imports
eselkin marked this conversation as resolved.
Show resolved Hide resolved
import { selectDrupalStaticData } from 'platform/site-wide/drupal-static-data/selectors';

export const selectVamcSystemData = state =>
selectDrupalStaticData(state)?.vamcSystemData?.data.systems || {};

// Returns an array of [vhaId, facilityName] tuples
export const selectFacilitiesForSystem = (state, systemName) =>
Object.entries(selectVamcSystemData(state)?.[systemName] || {}) || [];
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* eslint-disable camelcase */
eselkin marked this conversation as resolved.
Show resolved Hide resolved
import { expect } from 'chai';
import { preProcessSystemData } from '../connect/preProcess';

describe('does nothing, output format is same as source', () => {
const vamcSystemData = {
data: {
systems: {
'VA Pittsburgh health care': {
vha_646GC: 'Beaver County VA Clinic',
vha_646GA: 'Belmont County VA Clinic',
vha_646GE: 'Fayette County VA Clinic',
vha_646A4:
'H. John Heinz III Department of Veterans Affairs Medical Center',
vha_646GF: 'Monroeville VA Clinic',
vha_646: 'Pittsburgh VA Medical Center-University Drive',
vha_646GD: 'Washington County VA Clinic',
vha_646GB: 'Westmoreland County VA Clinic',
},
'VA Altoona health care': {
vha_503GB: 'DuBois VA Clinic',
vha_503GD: 'Huntingdon County VA Clinic',
vha_503GE: 'Indiana County VA Clinic',
vha_503: "James E. Van Zandt Veterans' Administration Medical Center",
vha_503GA: 'Johnstown VA Clinic',
vha_503GC: 'State College VA Clinic',
},
},
},
};

it('returns empty objects when no data present', () => {
const emptyVamcSystemData = {};
expect(preProcessSystemData(emptyVamcSystemData)).to.deep.equal({});
});

it('does not change input', () => {
expect(preProcessSystemData(vamcSystemData)).to.deep.equal(vamcSystemData);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* eslint-disable camelcase */
eselkin marked this conversation as resolved.
Show resolved Hide resolved
import { expect } from 'chai';
import { selectFacilitiesForSystem, selectVamcSystemData } from '../selectors';

describe('getVamcSystemNameFromVhaId', () => {
const drupalStaticData = {
drupalStaticData: {
vamcSystemData: {
data: {
systems: {
'VA Pittsburgh health care': {
vha_646GC: 'Beaver County VA Clinic',
vha_646GA: 'Belmont County VA Clinic',
vha_646GE: 'Fayette County VA Clinic',
vha_646A4:
'H. John Heinz III Department of Veterans Affairs Medical Center',
vha_646GF: 'Monroeville VA Clinic',
vha_646: 'Pittsburgh VA Medical Center-University Drive',
vha_646GD: 'Washington County VA Clinic',
vha_646GB: 'Westmoreland County VA Clinic',
},
'VA Altoona health care': {
vha_503GB: 'DuBois VA Clinic',
vha_503GD: 'Huntingdon County VA Clinic',
vha_503GE: 'Indiana County VA Clinic',
vha_503:
"James E. Van Zandt Veterans' Administration Medical Center",
vha_503GA: 'Johnstown VA Clinic',
vha_503GC: 'State College VA Clinic',
},
},
},
},
},
};

it('selects VAMC facility id name tuples', () => {
expect(selectVamcSystemData(drupalStaticData)).to.deep.equal(
drupalStaticData.drupalStaticData.vamcSystemData.data.systems,
);
expect(
selectFacilitiesForSystem(drupalStaticData, 'VA Altoona health care'),
).to.deep.equal([
['vha_503GB', 'DuBois VA Clinic'],
['vha_503GD', 'Huntingdon County VA Clinic'],
['vha_503GE', 'Indiana County VA Clinic'],
['vha_503', "James E. Van Zandt Veterans' Administration Medical Center"],
['vha_503GA', 'Johnstown VA Clinic'],
['vha_503GC', 'State College VA Clinic'],
]);
});
});
Loading