-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqualityapi.html
101 lines (83 loc) · 3.41 KB
/
qualityapi.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<html>
<head>
</head>
<body>
Test Quality API (example npi = 1003258930):
<br>
<input type="text" id="inputnpi"></input>
<br>
<button onclick="renderData()">Pro Quality API</button>
<br>
<div id="proqualityapiresults"></div>
<br>
<br>
<script>
async function renderData() {
// get api information and return the data
var thenpis = document.getElementById('inputnpi').value.split(',')
var fetchnpiurls = []
for (onenpi of thenpis) {
fetchnpiurls.push('https://data.cms.gov/provider-data/api/1/datastore/sql?query=%5BSELECT%20%2A%20FROM%2008fb9982-9b2a-5fd7-93a3-1ac028c5d46b%5D%5BWHERE%20NPI%20%3D%20%22' + onenpi + '%22%5D')
}
// get api data
// api iph data retrieve
var npiqualitydata
// This function just returns a promise
function getData(url) {
return fetch(url)
.then(response=>{
return response.json()
})
.then(data =>{
const responsedata = data // not doing anything with data here
// example manipulate data - const timeT = Math.round(data['routes'][0]['summary']['travelTimeInSeconds']/60);
return Promise.resolve(responsedata);
})
}// end getdata
await Promise.all(
// use the urls to create an array of promises
fetchnpiurls.map(getData)
).then((allnpireturns) => {
// When all the promises have been resolved, then this will be executed
//Here all the promises have been resolved, so you would have an array with the iphapireturn
npiqualitydata = allnpireturns
}) // end get dataurls functions after promises
console.log(npiqualitydata)
// end get api data
} // end renderData
// end get api information and return the data
/*
// get api information for one npi and return data
async function getqualitydata(npi) {
let url = 'https://data.cms.gov/provider-data/api/1/datastore/sql?query=%5BSELECT%20%2A%20FROM%2008fb9982-9b2a-5fd7-93a3-1ac028c5d46b%5D%5BWHERE%20NPI%20%3D%20%22' + npi + '%22%5D';
try {
let res = await fetch(url, {
method: 'GET',
crossorigin: true,
mode: 'no-cors'
});
return await res.json();
} catch (error) {
console.log(error);
}
} // end pro quality api access
// recieve input npi and put data in results
async function renderData() {
var inputnpi = document.getElementById('inputnpi').value
let qualityData = await getqualitydata(inputnpi);
let html = '';
console.log(qualityData)
let htmlSegment = `<div>
Provider NPI: ${qualityData[0].npi}
<br>
Provider Name: ${qualityData[0].frst_nm} ${qualityData[0].lst_nm}
<br>
Quality Score: ${qualityData[0].final_MIPS_score}
</div>`;
html += htmlSegment;
document.getElementById('proqualityapiresults').innerHTML = html;
}
*/
</script>
</body>
</html>