Skip to content
This repository has been archived by the owner on Jan 29, 2022. It is now read-only.

Commit

Permalink
[#758] Eliminate registration filter
Browse files Browse the repository at this point in the history
  • Loading branch information
nightsh committed Apr 19, 2017
1 parent 3f78328 commit a13693c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 90 deletions.
6 changes: 0 additions & 6 deletions handlers/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ function getFilters(query) {
filters.gender = `${gender} OR both`;
}

const isRegistered = (query.is_registered !== undefined);
if (isRegistered) {
filters.is_registered = query.is_registered;
}

const hasPublishedResults = (query.has_published_results !== undefined);
if (hasPublishedResults) {
filters.has_published_results = query.has_published_results;
Expand Down Expand Up @@ -142,7 +137,6 @@ module.exports = {
organisation: Joi.string().empty(''),
gender: Joi.valid(['male', 'female']).empty(''),
has_published_results: Joi.boolean().empty(''),
is_registered: Joi.boolean().empty(''),
has_publications: Joi.boolean().empty(''),
has_discrepancies: Joi.boolean().empty(''),
sample_size_start: Joi.number().integer().empty(''),
Expand Down
17 changes: 8 additions & 9 deletions test/fixtures/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ paths:
tags:
- search
description: Autocomplete search feature for supported database entities
(`condition`, `intervention`, `location`, `person`, `organisation`).
(`location`).
It has the same options as a regular `search` operation, with an extra **required**
`in` parameter indicating the entity type to search.
operationId: autocomplete
Expand All @@ -72,11 +72,7 @@ paths:
description: The entity to search for
type: string
enum:
- condition
- intervention
- location
- person
- organisation
- name: q
in: query
description: The search query
Expand Down Expand Up @@ -414,7 +410,7 @@ paths:
description: Error
schema:
$ref: "#/definitions/ErrorResponse"

/documents:
x-swagger-router-controller: documents
get:
Expand Down Expand Up @@ -536,9 +532,6 @@ definitions:
has_published_results:
type: boolean
description: Trial has its results published (true/false)
is_registered:
type: boolean
description: Whether the trial is registered in a clinical trial registry
registration_date:
type: string
description: Date the trial was registered
Expand All @@ -551,6 +544,11 @@ definitions:
type: string
description: Date when a certification of exemption has been filed for the trial
format: date-time
study_phase:
type: array
description: Phases of the study (e.g. `["Phase 2"]` or `["Phase 1", "Phase 2"]`)
items:
type: string
status:
type: string
description: Completion status of the trial
Expand Down Expand Up @@ -1208,6 +1206,7 @@ definitions:
type: string
enum:
- register
- journal
- other

FDADocumentSearchResults:
Expand Down
54 changes: 0 additions & 54 deletions test/handlers/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,6 @@ describe('search handler', () => {
}));
});

describe('is_registered', () => {
it('rejects values other than "true" and "false"', () => server.inject('/search?is_registered=maybe')
.then((_response) => {
_response.statusCode.should.equal(400);
}));
});

describe('has_published_results', () => {
it('rejects values other than "true" and "false"', () => server.inject('/search?has_published_results=maybe')
.then((_response) => {
Expand Down Expand Up @@ -281,53 +274,6 @@ describe('search handler', () => {
});
});

describe('GET /search?is_registered={is_registered}', () => {
it('doesnt filter if is_registered is empty', () => {
mockApiResponses({
search: {
query: {
q: undefined,
},
},
});

return server.inject('/search?is_registered=')
.then((_response) => {
_response.statusCode.should.equal(200);
});
});

it('filter by trials with published results if is_registered is true', () => {
mockApiResponses({
search: {
query: {
q: 'is_registered:(true)',
},
},
});

return server.inject('/search?is_registered=true')
.then((_response) => {
_response.statusCode.should.equal(200);
});
});

it('filter by trials without published results if is_registered is false', () => {
mockApiResponses({
search: {
query: {
q: 'is_registered:(false)',
},
},
});

return server.inject('/search?is_registered=false')
.then((_response) => {
_response.statusCode.should.equal(200);
});
});
});

describe('GET /search?has_published_results={has_published_results}', () => {
it('doesnt filter if has_published_results is empty', () => {
mockApiResponses({
Expand Down
21 changes: 0 additions & 21 deletions views/partials/search-form-fields.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,27 +137,6 @@
</div>
</div>

<div class="filter">
<label for="is_registered">Registration</label>
<div class="select">
<select name="is_registered" id="is_registered">
<option value="">All</option>
<option
value="true"
{% if query.is_registered %}selected{% endif %}
>
Registered trials
</option>
<option
value="false"
{% if query.is_registered == false %}selected{% endif %}
>
Unregistered trials
</option>
</select>
</div>
</div>

<div class="filter">
<label for="has_discrepancies">Discrepancies</label>
<div class="select">
Expand Down

0 comments on commit a13693c

Please sign in to comment.