Skip to content

Commit

Permalink
use new api for nct resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
nr23730 committed Oct 11, 2024
1 parent eb85be1 commit ddef70a
Showing 1 changed file with 13 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,37 +71,27 @@ const promiseOptions = (
// TODO better to separate this call to a configurable client
request
.get(
'https://www.clinicaltrials.gov/api/query/study_fields?expr=' +
'https://clinicaltrials.gov/api/v2/studies/' +
inputValue +
'&fields=NCTId%2CBriefTitle%2COfficialTitle&min_rnk=1&max_rnk=5&fmt=json'
'?format=json&fields=BriefTitle%7CNCTId'
)
.end((err, res) => {
if (!err && res.ok) {
const response = JSON.parse(res.text);
const result = response.StudyFieldsResponse;
const result =
response.protocolSection.identificationModule;
console.group('Result from ClinicalTrials.gov');
console.log(response);
console.groupEnd();
const trialResults = result.StudyFields;
const ret: MyOption[] = trialResults.map(
(trialResult: {
OfficialTitle: string[];
BriefTitle: string[];
NCTId: string[];
Rank: number;
}) => {
const trialName = trialResult.BriefTitle[0];
const trialId = trialResult.NCTId[0];
return {
value: {
name: trialName,
id: trialId,
},
label: trialId + ': ' + trialName,
} as MyOption;
}
);
return callback(ret);
return callback([
{
value: {
name: result.briefTitle,
id: result.nctId,
},
label: result.nctId + ': ' + result.briefTitle,
} as MyOption,
]);
} else {
const errClinicalTrial = {
id: '',
Expand Down

0 comments on commit ddef70a

Please sign in to comment.