Node - API Examples

Node.js examples to query the 1upHealth FHIR Analytics server

Bulk Data Analytics APIs are currently available in the 1up development environment. View the examples below to test in dev.

NPM Dependency

You need to install the node module athena-client to run the examples.


Code


////////////////////////////////////////////////////////////////////////
//
// List the FHIR Resources
//

// npm install required
var athena = require("athena-client");

// 1upHealth development area
var awsConfig = {
  region: 'us-east-1'
};

// Output bucket & IAM credentials
var clientConfig = {
  bucketUri: 's3://1uphealth-bulkdata-analytics-dev-output/',
  aws_access_key_id: '**CONTACT-1UPHEALTH-FOR-ACCESS"**',
  aws_secret_access_key: '**CONTACT-1UPHEALTH-FOR-ACCESS"**'
};

// Create Athena client
var client = athena.createClient(clientConfig, awsConfig);

var query = "SHOW TABLES FROM 1uphealthbulkdataanalytics";

client.execute(
    query,
    function(err, data) { if (err) {return console.error(err)}
  console.log(data)
});


Note: Same connection code - Different SQL statement (& output processing)

////////////////////////////////////////////////////////////////////////
//
// Immunization Report
// Query: 13 year old children in Boston who have been immunized for chickenpox
// (Varicella vaccine Code: 21)
//

// npm install required
var athena = require("athena-client");

// 1upHealth development area
var awsConfig = {
  region: 'us-east-1'
};

// Output bucket & IAM credentials
var clientConfig = {
  bucketUri: 's3://1uphealth-bulkdata-analytics-dev-output/',
  aws_access_key_id: '**CONTACT-1UPHEALTH-FOR-ACCESS"**',
  aws_secret_access_key: '**CONTACT-1UPHEALTH-FOR-ACCESS"**'
};

var client = athena.createClient(clientConfig, awsConfig);

var sql = "SELECT p.id AS PID, " +
    "p.name[1].family[1] AS LastName, " +
    "p.name[1].given[1] AS FirstName, " +
    "p.birthdate AS DOB, " +
    "i.vaccineCode.coding[1].code AS iCode, " +
    "i.vaccineCode.coding[1].display AS iType, " +
    "split_part(i.date,'T',1) AS iDate " +
    "FROM 1uphealthbulkdataanalytics.patient p, 1uphealthbulkdataanalytics.immunization i " +
    "WHERE p.id = (split_part(i.patient.reference, ':', 3)) " +
    " AND i.vaccineCode.coding[1].code = '21' " +
    " AND p.birthdate > '2015-01-01' " +
    " AND p.birthdate < '2015-12-31' " +
    " AND p.address[1].city = 'Boston' " +
    "ORDER BY LastName, FirstName";

client.execute(
    sql,
    function(err, data) { if (err) {return console.error(err)}
  console.log(data)
});