Skip to content

Commit

Permalink
listing articles and clinical trials by keyword (medicine)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoamaral committed Aug 14, 2021
1 parent 1df8df1 commit 3fbc1d9
Showing 1 changed file with 69 additions and 24 deletions.
93 changes: 69 additions & 24 deletions content/observatorio/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,75 @@ Esta página tem uma secção para cada uma das terapias listadas como relevante

Em cada secção, são listados os ensaios clínicos e artigos publicados em que o fármaco consta do título.

<ul></ul>

<h3 id="Ocrelizumab">Ocrelizumab</h3>
<ol class="articles Ocrelizumab"></ol>
<h4>Ensaios Clínicos</h4>

<ol class="trials Ocrelizumab"></ol>

<h3 id="Metformin">Metformin</h3>
<ol class="articles Metformin"></ol>
<h4>Ensaios Clínicos</h4>
<ol class="trials Metformin"></ol>

<script>
const myList = document.querySelector('ul');
const myRequest = new Request('https://api.brunoamaral.net/articles/relevant');

fetch(myRequest )
.then(response => response.json())
.then(data => {
for (const product of data.products) {
let listItem = document.createElement('li');
listItem.appendChild(
document.createElement('strong')
).textContent = product.Name;
listItem.append(
` can be found in ${
product.Location
}. Cost: `
);
listItem.appendChild(
document.createElement('strong')
).textContent = `£${product.Price}`;
myList.appendChild(listItem);
}
})
.catch(console.error);

const queries = document.querySelectorAll('h3')

function searchArticles(term){
// let list = document.querySelector('ol.articles.'+ term );
let articleRequest = new Request('https://api.brunoamaral.net/articles/keyword/'+ term );

fetch(articleRequest).then(response => response.json()).then(data => {console.log(data)})

fetch(articleRequest )
.then(response => response.json())
.then(data => {
let list = document.querySelector('ol.articles.'+term);
for (const item of data) {
let listItem = document.createElement('li');
listItem.appendChild(
document.createElement('strong')
).textContent = item.title;

let a = listItem.appendChild(document.createElement('a'));
a.textContent = `${item.source}`;
a.href = `${item.link}`;
list.appendChild(listItem);
}
})
.catch(console.error);
}

function searchTrials(term){
// let list = document.querySelector('ol.trials.'+ term );
let trialsRequest = new Request('https://api.brunoamaral.net/trials/keyword/'+ term );
fetch(trialsRequest).then(response => response.json()).then(data => {console.log(data)})

fetch(trialsRequest )
.then(response => response.json())
.then(data => {
let list = document.querySelector('ol.trials.'+term);
for (const item of data) {
let listItem = document.createElement('li');
listItem.appendChild(
document.createElement('strong')
).textContent = item.title;

let a = listItem.appendChild(document.createElement('a'));
a.textContent = `${item.source}`;
a.href = `${item.link}`;
list.appendChild(listItem);
}
})
.catch(console.error);
}


for (let i = 0; i < queries.length; i++) {
// console.log(queries[i].id)
searchArticles(queries[i].id)
searchTrials(queries[i].id)
}
</script>

0 comments on commit 3fbc1d9

Please sign in to comment.