var url = require('url');
var yexpert = require('yexpert-js');

module.exports = {

  parse: function(ewd) {
    var path = ewd.query.rest_path.split('/');
    if (path[1] === 'initiate') {
      return yexpert.initiate(ewd);
    }
    if (path[1] === 'authenticate') {
      return yexpert.login(ewd);
    }
    if (path[1] === 'patientsByName') {
      return yexpert.getPatientsByNamePrefix(ewd);
    }
    if (path[1] === 'patientSummary') {
      return yexpert.getPatientSummary(ewd);
    }
    return {
      "error": {
        "text": "Unrecognized Service",
        "statusCode": 400
      }
    };
  }
};
