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

(#636) Accomodate gender vs sex in trial structured eligibility data. #638

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions cypress/e2e/SearchResultsPage/GeneralPageComponents.feature
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,19 @@ Feature: Clinical Trials Search Results Page Components
| og:url | https://www.cancer.gov/about-cancer/treatment/clinical-trials/search/r?a=50&d=C798&i=C15313&in=Benjamin%20David%20Smith&lo=M%20D%20Anderson%20Cancer%20Center&loc=1&q=Breast&rl=2&st=C2924&stg=C94774&t=C4872&tid=NCI-2017-00476&tp=iii&tt=treatment&z=30309&zp=100 |
| og:description | Find an NCI-supported clinical trial - Search results |
And there is a canonical link with the href "https://www.cancer.gov/about-cancer/treatment/clinical-trials/search/r?a=50&d=C798&i=C15313&in=Benjamin%20David%20Smith&lo=M%20D%20Anderson%20Cancer%20Center&loc=1&q=Breast&rl=2&st=C2924&stg=C94774&t=C4872&tid=NCI-2017-00476&tp=iii&tt=treatment&z=30309&zp=100"


Scenario Outline: As a user, I expect the sex-based eligibility display to function regardless of the API's data structure.
Given the user navigates to "<path>"
Then trial info displayes "Results 1-1 of 1 for your search "
And the trial's sex-based eligibility displays "<sex>"
Examples:
| path | sex |
# These three return eligibility.structured.gender
| /r?loc=0&rl=2&tid=NCI-2021-08397 | Male or Female |
| /r?loc=0&rl=2&tid=NCI-2023-04529 | Female |
| /r?loc=0&rl=2&tid=NCI-2020-04705 | Male |
# These three return eligibility.structured.sex
| /r?loc=0&rl=2&tid=NCI-2014-02674 | Male or Female |
| /r?loc=0&rl=2&tid=NCI-2017-02047 | Female |
| /r?loc=0&rl=2&tid=NCI-2024-04336 | Male |
11 changes: 11 additions & 0 deletions cypress/e2e/SearchResultsPage/GeneralPageComponents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,14 @@ When('user clicks on chat online button', () => {
Then('the chat is opened', () => {
expect(stub).to.be.calledOnce;
});

And("the trial's sex-based eligibility displays {string}", (sex) => {
// Look for the existence of a span containing the text "Sex:",
// followed by sex.
cy.get('.results-list-item')
.find('.results-list-item__category')
.filter(':contains("Sex:")')
.each(($el) => {
expect($el.text()).to.include(sex);
});
});
2 changes: 1 addition & 1 deletion src/hooks/ctsApiSupport/__tests__/useCtsApi.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ describe('tests for useCtsApi', () => {
],
eligibility: {
structured: {
gender: 'BOTH',
max_age: '999 Years',
max_age_number: 999,
max_age_unit: 'Years',
Expand All @@ -400,6 +399,7 @@ describe('tests for useCtsApi', () => {
min_age_unit: 'Years',
max_age_in_years: 999,
min_age_in_years: 18,
sex: 'ALL',
},
unstructured: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8055,7 +8055,6 @@ describe('getClinicalTrialDescription', () => {
minimum_target_accrual_number: 33000,
eligibility: {
structured: {
gender: 'BOTH',
max_age: '25 Years',
max_age_number: 25,
max_age_unit: 'Years',
Expand All @@ -8064,6 +8063,7 @@ describe('getClinicalTrialDescription', () => {
min_age_unit: 'Years',
max_age_in_years: 25,
min_age_in_years: 0,
sex: 'ALL',
},
unstructured: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('searchTrialInvestigators', () => {
min_age_unit: 'Years',
max_age_unit: 'Years',
max_age_in_years: 999,
gender: 'BOTH',
sex: 'ALL',
min_age: '18 Years',
min_age_number: 18,
min_age_in_years: 18,
Expand Down
8 changes: 6 additions & 2 deletions src/views/ResultsPage/ResultsListItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const ResultsListItem = ({
const displays = {
MALE: 'Male',
FEMALE: 'Female',
ALL: 'Male or Female',
BOTH: 'Male or Female',
};
return displays[genderVal];
Expand Down Expand Up @@ -293,9 +294,12 @@ const ResultsListItem = ({
{getAgeDisplay()}
</div>
<div className="results-list-item__category">
<span>Gender:</span>
<span>Sex:</span>
{item.eligibility &&
getGenderDisplay(item.eligibility.structured.gender)}
getGenderDisplay(
item.eligibility.structured.sex ||
item.eligibility.structured.gender
)}
</div>
<div className="results-list-item__category">
<span>Location:</span>
Expand Down
110 changes: 110 additions & 0 deletions support/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Clinical Trial Search API Proxy

The Clinical Trial Search API doesn't support running against arbitrary URLs, including `localhost`.

These are support files to proxy the Clinical Trials API for local development. It also supports a mock proxy for use when running tests.

## `src` directory

Files under `src` are the actual proxy. The main entry point is `setupProxy.js` which sets up the various routes. The additional files contain the logic for supporting individual routes as well as the mock API.

## `mock-data` directory

These files support the returns on the various endpoints.

### `mock-data/clinical-trial`

<details>
Data files for the `/cts/mock-api/v2/trials/:id` endpoint.

File names are of the format `<trial_id>.json`, where `<trial_id>` is the trial ID. (e.g. The data file for trial `NCI-2020-08118` would be `NCI-2020-08118.json`). The file contents are the body of the API's response.
</details>

### `mock-data/clinical-trials`

<details>
Data files for the `/cts/mock-api/v2/trials` endpoint

These are pairs of files.

`<descriptive>-request.json` and<br>
`<descriptive>-response.json`

where `<descriptive>` is a very brief (2 or 3 word) description of the request.

The `-request` file contains the body of the HTTP **request** that is sent to the API.

The `-response` files contains the body of the HTTP **response** the API sends back.

To add new data files to this collection:

1. Launch the clinical trials search app.
2. Open the browser's Developer Tools and switch to the network tab.
3. Perform a search.
4. Find the request going to the Clinical Trials API.
5. Switch to the `Payload` tab, go to the "view source" or "raw" sub-tab and copy its contents to `<descriptive>-request.json`.
6. Switch to the `Response` tab and copy its contents to the `<descriptive>-response.json`.

Alternatively:

1. Launch the clinical trials search app.
2. Open the browser's Developer Tools and switch to the network tab.
3. Perform a search.
4. Find the request going to the Clinical Trials API.
5. Right-click and choose "Copy as curl"
6. Save the `--data-raw` value (minus the surrounding single-quotes) as `<descriptive>-request.json`.
7. Paste the command in a terminal window and add the arguments `--compressed --output '<descriptive>-response.json'`.
- Be sure to include the `--compressed` switch, the API doesn't send back the proper header to signal that the response is gzip'ped.
</details>

### `mock-data/diseases`

<details>

Data files for the `/cts/mock-api/v2/diseases` endpoint.

</details>

### `mock-data/interventions`

<details>

Data files for the `/cts/mock-api/v2/interventions` endpoint.

</details>

### `mock-data/terms`

<details>

Data files for the `/cts/mock-api/v2/organizations` endpoint.

</details>

### `mock-data/v2/organizations`

<details>

Data files for the `/cts/mock-api/v2/organizations` endpoint.

</details>

### `mock-data/v2/trials`

<details>

Data files for the `/v1/term/:term_key` and `/v1/terms` endpoints.

</details>

### `mock-data/zip_code_lookup`

<details>

Data files for the `/zip_code_lookup` endpoint.

These are simple JSON files containing the latitude and longitude for a given ZIP code.

File names match the ZIP code.

<details>
2 changes: 1 addition & 1 deletion support/mock-data/clinical-trial/NCI-2020-08118.json
Original file line number Diff line number Diff line change
Expand Up @@ -2426,7 +2426,7 @@
"brief_title": "Flotetuzumab for the Treatment of Relapsed or Refractory Advanced CD123-Positive Hematological Malignancies",
"eligibility": {
"structured": {
"gender": "BOTH",
"sex": "ALL",
"max_age": "999 Years",
"min_age": "12 Years",
"max_age_unit": "Years",
Expand Down
20 changes: 10 additions & 10 deletions support/mock-data/clinical-trials/20165-100miles-response.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"min_age_unit": "Years",
"max_age_unit": "Years",
"max_age_in_years": 999,
"gender": "BOTH",
"sex":"ALL",
"min_age": "18 Years",
"min_age_number": 18,
"min_age_in_years": 18
Expand Down Expand Up @@ -21263,7 +21263,7 @@
"min_age_unit": "Years",
"max_age_unit": "Years",
"max_age_in_years": 999,
"gender": "BOTH",
"sex":"ALL",
"min_age": "18 Years",
"min_age_number": 18,
"min_age_in_years": 18
Expand Down Expand Up @@ -39979,7 +39979,7 @@
"min_age_unit": "Years",
"max_age_unit": "Years",
"max_age_in_years": 999,
"gender": "FEMALE",
"sex": "FEMALE",
"min_age": "18 Years",
"min_age_number": 18,
"min_age_in_years": 18
Expand Down Expand Up @@ -54980,7 +54980,7 @@
"min_age_unit": "Years",
"max_age_unit": "Years",
"max_age_in_years": 999,
"gender": "BOTH",
"sex":"ALL",
"min_age": "18 Years",
"min_age_number": 18,
"min_age_in_years": 18
Expand Down Expand Up @@ -70096,7 +70096,7 @@
"min_age_unit": "Years",
"max_age_unit": "Years",
"max_age_in_years": 999,
"gender": "BOTH",
"sex":"ALL",
"min_age": "18 Years",
"min_age_number": 18,
"min_age_in_years": 18
Expand Down Expand Up @@ -82554,7 +82554,7 @@
"min_age_unit": "Years",
"max_age_unit": "Years",
"max_age_in_years": 999,
"gender": "BOTH",
"sex":"ALL",
"min_age": "18 Years",
"min_age_number": 18,
"min_age_in_years": 18
Expand Down Expand Up @@ -106489,7 +106489,7 @@
"min_age_unit": "Years",
"max_age_unit": "Years",
"max_age_in_years": 999,
"gender": "BOTH",
"sex":"ALL",
"min_age": "18 Years",
"min_age_number": 18,
"min_age_in_years": 18
Expand Down Expand Up @@ -123522,7 +123522,7 @@
"min_age_unit": "Years",
"max_age_unit": "Years",
"max_age_in_years": 999,
"gender": "BOTH",
"sex":"ALL",
"min_age": "18 Years",
"min_age_number": 18,
"min_age_in_years": 18
Expand Down Expand Up @@ -129264,7 +129264,7 @@
"min_age_unit": "Years",
"max_age_unit": "Years",
"max_age_in_years": 999,
"gender": "BOTH",
"sex":"ALL",
"min_age": "18 Years",
"min_age_number": 18,
"min_age_in_years": 18
Expand Down Expand Up @@ -136011,7 +136011,7 @@
"min_age_unit": "Years",
"max_age_unit": "Years",
"max_age_in_years": 999,
"gender": "BOTH",
"sex":"ALL",
"min_age": "70 Years",
"min_age_number": 70,
"min_age_in_years": 70
Expand Down
20 changes: 10 additions & 10 deletions support/mock-data/clinical-trials/22180-response.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"min_age_unit": "Years",
"max_age_unit": "Years",
"max_age_in_years": 999,
"gender": "BOTH",
"sex": "ALL",
"min_age": "18 Years",
"min_age_number": 18,
"min_age_in_years": 18
Expand Down Expand Up @@ -21263,7 +21263,7 @@
"min_age_unit": "Years",
"max_age_unit": "Years",
"max_age_in_years": 999,
"gender": "BOTH",
"sex": "ALL",
"min_age": "18 Years",
"min_age_number": 18,
"min_age_in_years": 18
Expand Down Expand Up @@ -45198,7 +45198,7 @@
"min_age_unit": "Years",
"max_age_unit": "Years",
"max_age_in_years": 999,
"gender": "BOTH",
"sex": "ALL",
"min_age": "18 Years",
"min_age_number": 18,
"min_age_in_years": 18
Expand Down Expand Up @@ -63914,7 +63914,7 @@
"min_age_unit": "Years",
"max_age_unit": "Years",
"max_age_in_years": 999,
"gender": "FEMALE",
"sex": "FEMALE",
"min_age": "18 Years",
"min_age_number": 18,
"min_age_in_years": 18
Expand Down Expand Up @@ -78993,7 +78993,7 @@
"min_age_unit": "Years",
"max_age_unit": "Years",
"max_age_in_years": 999,
"gender": "BOTH",
"sex": "ALL",
"min_age": "70 Years",
"min_age_number": 70,
"min_age_in_years": 70
Expand Down Expand Up @@ -88392,7 +88392,7 @@
"min_age_unit": "Years",
"max_age_unit": "Years",
"max_age_in_years": 999,
"gender": "BOTH",
"sex": "ALL",
"min_age": "18 Years",
"min_age_number": 18,
"min_age_in_years": 18
Expand Down Expand Up @@ -97617,7 +97617,7 @@
"min_age_unit": "Years",
"max_age_unit": "Years",
"max_age_in_years": 999,
"gender": "BOTH",
"sex": "ALL",
"min_age": "18 Years",
"min_age_number": 18,
"min_age_in_years": 18
Expand Down Expand Up @@ -105706,7 +105706,7 @@
"min_age_unit": "Years",
"max_age_unit": "Years",
"max_age_in_years": 999,
"gender": "BOTH",
"sex": "ALL",
"min_age": "18 Years",
"min_age_number": 18,
"min_age_in_years": 18
Expand Down Expand Up @@ -118164,7 +118164,7 @@
"min_age_unit": "Years",
"max_age_unit": "Years",
"max_age_in_years": 999,
"gender": "BOTH",
"sex": "ALL",
"min_age": "18 Years",
"min_age_number": 18,
"min_age_in_years": 18
Expand Down Expand Up @@ -127803,7 +127803,7 @@
"min_age_unit": "Years",
"max_age_unit": "Years",
"max_age_in_years": 39,
"gender": "BOTH",
"sex": "ALL",
"min_age": "18 Years",
"min_age_number": 18,
"min_age_in_years": 18
Expand Down
Loading
Loading