The following examples demonstrate how an external application could execute some of the commonly used workflows within the VisualDx API. All of the following examples are written in Node.js.
This code block searches findings for the term “itchy”. Then, it builds a differential with the top 3 results and returns the top 3 diagnosis matches.
const searchResults = await axios.get(`${config.host}/${config.version}/libraries/clinical/findings/search?q=itchy`,
{
headers: {
'Authorization': `Bearer ${token}`
}
})
const topMatches = searchResults.data.data.slice(0, 3).map(result => ({id: result.id}))
const requestBody = {
age: {
value: 29,
unit: 'year'
},
sex: 'M',
findings: topMatches
}
return axios.post(`${config.host}/${config.version}/differentials/clinical/workup`, requestBody, {
headers: {
'Authorization': `Bearer ${token}`
}
}
).then(response => response.data.data.slice(0, 3))
This code retrieves all findings in the “lesion” category and extracts the name for the top 3 results.
const lesionFindings = await axios.get(`${config.host}/${config.version}/libraries/clinical/findings/categories/lesion`,
{
headers: {
'Authorization': `Bearer ${token}`
}
})
return lesionFindings.data.data
.slice(0, 3)
.map(result => result.classification.split(':'))
.map(classification => classification[classification.length - 1])
The following code demonstrates how to search for diagnoses and save 3 images from the top result.
For proper performance, make sure your images are loading asynchronously and not blocking.
const searchResults = await axios.get(`${config.host}/${config.version}/libraries/clinical/diagnoses/search?q=psoriasis`,
{
headers: {
'Authorization': `Bearer ${token}`
}
})
const topMatchImageRequests = searchResults.data.data[0]
.images
.slice(0, 3)
.map(image => axios
.get(`${config.host}/${config.version}/libraries/images/${image.id}`,
{
responseType: 'arraybuffer',
headers: {
'Authorization': `Bearer ${token}`,
}
}
)
)
return Promise.all(topMatchImageRequests)
.then(responses =>
mkdir(`${__dirname}/images`, {recursive: true})
.then(() => responses.forEach((response, index) => writeFile(`${__dirname}/images/image${index}.jpg`, response.data)))
)
This example shows how to send an image for analysis and use the results to build a differential.
const imagePath = path.join(__dirname, '..', 'resources', '1x1red.jpg')
const image = await readFile(imagePath)
const inferenceResults = await axios.post(`${config.host}/${config.version}/inferences/clinical/image`, image, {
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'image/jpeg'
}
})
const requestBody = {
age: {
value: 29,
unit: 'year'
},
sex: 'M',
findings: inferenceResults.data.data.findings,
diagnoses: inferenceResults.data.data.diagnoses
}
return axios.post(`${config.host}/${config.version}/differentials/clinical/workup`, requestBody, {
headers: {
'Authorization': `Bearer ${token}`
}
}
)
.then(response => response.data.data.slice(0, 3))
This example searches diagnoses for the term “psoriasis” and fetches detailed write-ups for the top 3 results.
const searchResults = await axios.get(`${config.host}/${config.version}/libraries/clinical/diagnoses/search?q=psoriasis`,
{
headers: {
'Authorization': `Bearer ${token}`
}
})
const topMatchRequests = searchResults.data.data
.slice(0, 3)
.map(result => axios
.get(`${config.host}/${config.version}/libraries/clinical/diagnoses/${result.id}`,
{
headers: {
'Authorization': `Bearer ${token}`
}
}
)
)
return Promise.all(topMatchRequests)
.then(responses => responses.map(response => response.data))