jesseokeya / infermedica

Node interface to the infermedica REST API

Home Page:https://www.npmjs.com/package/infermedica

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Infermedica (unofficial)

Node Interface To The Infermedica Rest Api. Npm Package

Description

This is a Node interface to the Infermedica Rest Api.

Installation

npm install infermedica --save

Usage examples

Estimate triage level based on provided patient information

const Infermedica = require('infermedica')
/** 
 * Provide credentials
 * This reference can help you explore the Infermedica API with your own data. 
 * Make sure that your application id and application key are correct and get started. 
 * Below they are passed in as environment variables
 */
const infermedica = new Infermedica({ 
    appId: process.env.APP_ID, 
    appKey: process.env.APP_KEY 
})

const context = {
    sex: "male",
    age: 70,
    evidence: [
        {
            "id": "s_1193",
            "choice_id": "present"
        },
        {
            "id": "s_488",
            "choice_id": "present"
        },
        {
            "id": "s_418",
            "choice_id": "present"
        }
    ]
}

infermedica.postTriage(context).then(res => {
    console.log(res)
})

Infermedica Methods

// Returns a list of all available conditions
infermedica.getConditions()

// Returns details of a single condition specified by id parameter 
infermedica.getCondition(conditionId)

// Suggests possible diagnoses and relevant observations
infermedica.postDiagnosis({ 
    sex, 
    age, 
    evidence, 
    extras, 
    target, 
    evaluated_at 
}) 

// Explains which evidence impact probability of selected condition
infermedica.postExplain({ 
    sex, 
    age, 
    evidence, 
    extras, 
    target, 
    evaluated_at 
})

// Returns information about data used by diagnostic engine
infermedica.getInfo() 

// Returns a list of all available lab tests
infermedica.getLabTests()

// Returns details of a single lab test specified by id parameter
infermedica.getLabTest(labTestId)

// Returns a single observation matching given phrase
infermedica.getLookUp({ phrase, sex })

// Returns list of mentions of observation found in given text
infermedica.postParse({ 
    text, 
    context, 
    concept_types, 
    correct_spelling, 
    include_tokens 
})

// Returns a list of all available risk factors
infermedica.getRiskFactors()

// Returns details of a single risk factor specified by id parameter
infermedica.getRiskFactor(riskFactorId) 

// Returns list of observations matching the given phrase
infermedica.getSearch({ 
    phrase, 
    sex, 
    maxResults, 
    type 
})

// Suggests possible symptoms based on provided patient information
infermedica.postSuggest({ 
    sex, 
    age, 
    evidence, 
    extras, 
    evaluated_at }, max_results)

// Returns a list of all available symptoms
infermedica.getSymptoms()

// Returns details of a single symptom specified by id parameter
infermedica.getSymptom(symptomId)

// Estimates triage level based on provided patient information
infermedica.postTriage({ 
    sex, 
    age, 
    evidence, 
    extras, 
    evaluated_at
})

Actions

getConditions

Returns a list of all available conditions.

const Infermedica = require('infermedica')

const infermedica = new Infermedica({ 
    appId: process.env.APP_ID, 
    appKey: process.env.APP_KEY 
})

infermedica.getConditions().then(conditions => {
    console.log(conditions)
})

getCondition

Returns details of a single condition specified by id parameter

const Infermedica = require('infermedica')

const infermedica = new Infermedica({ 
    appId: process.env.APP_ID, 
    appKey: process.env.APP_KEY 
})

infermedica.getCondition('c_522').then(condition => {
    console.log(condition)
})

postDiagnosis

Suggests possible diagnoses and relevant observations

const Infermedica = require('infermedica')

const infermedica = new Infermedica({ 
    appId: process.env.APP_ID, 
    appKey: process.env.APP_KEY 
})

const context = {
    sex: "male",
    age: 70,
    evidence: [
        {
            "id": "s_1193",
            "choice_id": "present"
        },
        {
            "id": "s_488",
            "choice_id": "present"
        },
        {
            "id": "s_418",
            "choice_id": "present"
        }
    ]
}

infermedica.postDiagnosis(context).then(diagnosis => {
    console.log(diagnosis)
})

postExplain

Explains which evidence impact probability of selected condition

const Infermedica = require('infermedica')

const infermedica = new Infermedica({ 
    appId: process.env.APP_ID, 
    appKey: process.env.APP_KEY 
})

const context = {
    sex: "male",
    age: 70,
    target: "c_49",
    evidence: [
        {
            "id": "s_1193",
            "choice_id": "present"
        },
        {
            "id": "s_488",
            "choice_id": "present"
        },
        {
            "id": "s_418",
            "choice_id": "present"
        }
    ]
}

infermedica.postExplain(context).then(explain => {
    console.log(explain)
})

getInfo

Returns information about data used by diagnostic engine

const Infermedica = require('infermedica')

const infermedica = new Infermedica({ 
    appId: process.env.APP_ID, 
    appKey: process.env.APP_KEY 
})

infermedica.getInfo().then(info => {
    console.log(info)
})

getLabTests

Returns a list of all available lab tests

const Infermedica = require('infermedica')

const infermedica = new Infermedica({ 
    appId: process.env.APP_ID, 
    appKey: process.env.APP_KEY 
})

infermedica.getLabTests().then(labTests => {
    console.log(labTests)
})

getLabTest

Returns details of a single lab test specified by id parameter

const Infermedica = require('infermedica')

const infermedica = new Infermedica({ 
    appId: process.env.APP_ID, 
    appKey: process.env.APP_KEY 
})

infermedica.getLabTest('lt_350').then(labTest => {
    console.log(labTest)
})

getLookUp

Returns a single observation matching given phrase

const Infermedica = require('infermedica')

const infermedica = new Infermedica({ 
    appId: process.env.APP_ID, 
    appKey: process.env.APP_KEY
})

const context = {
    sex: "female",
    phrase: "headache"
}

infermedica.getLookUp(context).then(lookUp => {
    console.log(lookUp)
})

postParse

Returns list of mentions of observation found in given text

const Infermedica = require('infermedica')

const infermedica = new Infermedica({ 
    appId: process.env.APP_ID, 
    appKey: process.env.APP_KEY 
})

const context = {
    "text": "I feel smoach pain but no couoghing today",
}

infermedica.postParse(context).then(parse => {
    console.log(parse)
})

getRiskFactors

Returns a list of all available risk factors

const Infermedica = require('infermedica')

const infermedica = new Infermedica({ 
    appId: process.env.APP_ID, 
    appKey: process.env.APP_KEY 
})

infermedica.getRiskFactors().then(riskFactors => {
    console.log(riskFactors)
})

getRiskFactor

Returns details of a single risk factor specified by id parameter

const Infermedica = require('infermedica')

const infermedica = new Infermedica({ 
    appId: process.env.APP_ID, 
    appKey: process.env.APP_KEY 
})

infermedica.getRiskFactor('p_28').then(riskFactor => {
    console.log(riskFactor)
})

getSearch

Returns list of observations matching the given phrase

const Infermedica = require('infermedica')

const infermedica = new Infermedica({ 
    appId: process.env.APP_ID, 
    appKey: process.env.APP_KEY 
})

const context = {
    sex: "male",
    phrase: "stomache pain",
    type: "symptom",
    maxResults: 8
}

infermedica.getSearch(context).then(search => {
    console.log(search)
})

postSuggest

Suggests possible symptoms based on provided patient information

const Infermedica = require('infermedica')

const infermedica = new Infermedica({ 
    appId: process.env.APP_ID, 
    appKey: process.env.APP_KEY 
})

const context = {
    sex: "male",
    age: 70,
    evidence: [
        {
            "id": "s_1193",
            "choice_id": "present"
        },
        {
            "id": "s_488",
            "choice_id": "present"
        },
        {
            "id": "s_418",
            "choice_id": "present"
        }
    ]
}

const maxResults = 8

infermedica.postSuggest(context, maxResults).then(suggest => {
    console.log(suggest)
})

getSymptoms

Returns a list of all available symptoms

const Infermedica = require('infermedica')

const infermedica = new Infermedica({ 
    appId: process.env.APP_ID, 
    appKey: process.env.APP_KEY 
})

infermedica.getSymptoms().then(symptoms => {
    console.log(symptoms)
})

getSymptom

Returns details of a single symptom specified by id parameter

const Infermedica = require('infermedica')

const infermedica = new Infermedica({ 
    appId: process.env.APP_ID, 
    appKey: process.env.APP_KEY 
})

infermedica.getSymptom('s_1190').then(symptom => {
    console.log(symptom)
})

postTriage

Estimates triage level based on provided patient information

const Infermedica = require('infermedica')

const infermedica = new Infermedica({ 
    appId: process.env.APP_ID, 
    appKey: process.env.APP_KEY 
})

 const context = {
    sex: "male",
    age: 70,
    evidence: [
        {
            "id": "s_1193",
            "choice_id": "present"
        },
        {
            "id": "s_488",
            "choice_id": "present"
        },
        {
            "id": "s_418",
            "choice_id": "present"
        }
    ]
}

infermedica.postTriage(context).then(triage => {
    console.log(triage)
})