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

Date query builder uses name instead of xpath #51

Merged
merged 2 commits into from
Aug 21, 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
4 changes: 2 additions & 2 deletions src/util/exportToNDJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ const buildSearchParamList = resourceType => {
try {
const searchParameterList = getSearchParameters(resourceType, '4_0_1');
searchParameterList.forEach(paramDef => {
// map xpath to parameter description
// map name to parameter description
{
searchParams[paramDef.xpath.substring(paramDef.xpath.indexOf('.') + 1)] = paramDef;
searchParams[paramDef.name] = paramDef;
}
});
return searchParams;
Expand Down
23 changes: 11 additions & 12 deletions test/util/exportToNDJson.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ describe('check export logic', () => {

test('returns empty record of valid search params for invalid resource type', () => {
const results = buildSearchParamList('BiologicallyDerivedProduct');
console.log(results);
expect(results).toBeDefined();
});
});
Expand Down Expand Up @@ -108,9 +107,9 @@ describe('check export logic', () => {

describe('getDocuments', () => {
describe('_typeFilter tests', () => {
test('returns Condition document when _typeFilter=Condition?recordedDate=gt2019-01-03T00:00:00Z', async () => {
test('returns Condition document when _typeFilter=Condition?recorded-date=gt2019-01-03T00:00:00Z', async () => {
const property = {
recordedDate: 'gt2019-01-03T00:00:00Z'
'recorded-date': 'gt2019-01-03T00:00:00Z'
};
const searchParams = buildSearchParamList('Condition');
const filter = qb.buildSearchQuery({
Expand All @@ -122,11 +121,11 @@ describe('check export logic', () => {
expect(docObj.document.length).toEqual(1);
});

test('returns Condition document when _typeFilter=Condition?recordedDate=gt2019-01-03T00:00:00Z&onsetDateTime=gt2019-01-03T00:00:00Z', async () => {
test('returns Condition document when _typeFilter=Condition?recorded-date=gt2019-01-03T00:00:00Z&onset-date=gt2019-01-03T00:00:00Z', async () => {
// test for the "&" operator within the query
const properties = {
recordedDate: 'gt2019-01-03T00:00:00Z',
onsetDateTime: 'gt2019-01-03T00:00:00Z'
'recorded-date': 'gt2019-01-03T00:00:00Z',
'onset-date': 'gt2019-01-03T00:00:00Z'
};
const searchParams = buildSearchParamList('Condition');
const filter = qb.buildSearchQuery({
Expand All @@ -138,10 +137,10 @@ describe('check export logic', () => {
expect(docObj.document.length).toEqual(1);
});

test('returns no documents when _typeFilter filters out all documents (_typeFilter=Condition?recordedDate=gt2019-01-03T00:00:00Z&onsetDateTime=lt2019-01-03T00:00:00Z', async () => {
test('returns no documents when _typeFilter filters out all documents (_typeFilter=Condition?recorded-date=gt2019-01-03T00:00:00Z&onset-date=lt2019-01-03T00:00:00Z', async () => {
const properties = {
recordedDate: 'gt2019-01-03T00:00:00Z',
onsetDateTime: 'lt2019-01-03T00:00:00Z'
'recorded-date': 'gt2019-01-03T00:00:00Z',
'onset-date': 'lt2019-01-03T00:00:00Z'
};
const searchParams = buildSearchParamList('Condition');
const filter = qb.buildSearchQuery({
Expand All @@ -153,12 +152,12 @@ describe('check export logic', () => {
expect(docObj.document.length).toEqual(0);
});

test('returns Condition document when _typeFilter has "or" condition (_typeFilter=Condition?recordedDate=gt2019-01-03T00:00:00Z,onsetDateTime=lt2019-01-03T00:00:00Z', async () => {
test('returns Condition document when _typeFilter has "or" condition (_typeFilter=Condition?recorded-date=gt2019-01-03T00:00:00Z,onset-date=lt2019-01-03T00:00:00Z', async () => {
const recordedDateProperty = {
recordedDate: 'gt2019-01-03T00:00:00Z'
'recorded-date': 'gt2019-01-03T00:00:00Z'
};
const onsetDateTimeProperty = {
onsetDateTime: 'lt2019-01-03T00:00:00Z'
'onset-date': 'lt2019-01-03T00:00:00Z'
};
const searchParams = buildSearchParamList('Condition');
const recordedDateFilter = qb.buildSearchQuery({
Expand Down
Loading