'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _regenerator;

function _load_regenerator() {
  return _regenerator = _interopRequireDefault(require('babel-runtime/regenerator'));
}

var _bluebird;

function _load_bluebird() {
  return _bluebird = require('bluebird');
}

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Diagnosis = function () {
  function Diagnosis() {
    _classCallCheck(this, Diagnosis);
  }

  _createClass(Diagnosis, [{
    key: '_runExamine',


    /**
     * A function that actually runs the examination
     */
    value: function () {
      var _ref = (0, (_bluebird || _load_bluebird()).coroutine)( /*#__PURE__*/(_regenerator || _load_regenerator()).default.mark(function _callee() {
        return (_regenerator || _load_regenerator()).default.wrap(function _callee$(_context) {
          while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                throw new Error('You must implement this method');

              case 1:
              case 'end':
                return _context.stop();
            }
          }
        }, _callee, this);
      }));

      function _runExamine() {
        return _ref.apply(this, arguments);
      }

      return _runExamine;
    }()

    /**
     * Returns a descriptive symptoms message which might include specific data from the examination
     * @param bareResult ExamineBareResult
     */
    // eslint-disable-next-line no-unused-vars

  }, {
    key: '_formatSymptoms',
    value: function _formatSymptoms(bareResult) {
      throw new Error('You must implement this method');
    }

    /**
     * Returns a descriptive instruction to handle the issue (might include specific data from the examination)
     * @param bareResult ExamineBareResult
     */
    // eslint-disable-next-line no-unused-vars

  }, {
    key: '_formatManualTreat',
    value: function _formatManualTreat(bareResult) {
      throw new Error('You must implement this method');
    }
  }, {
    key: 'getMeta',
    value: function getMeta() {
      return {
        category: this.category,
        name: this.name,
        description: this.description
      };
    }
  }, {
    key: 'examine',
    value: function () {
      var _ref2 = (0, (_bluebird || _load_bluebird()).coroutine)( /*#__PURE__*/(_regenerator || _load_regenerator()).default.mark(function _callee2() {
        var bareResult, formattedSymptoms, formattedManualTreat;
        return (_regenerator || _load_regenerator()).default.wrap(function _callee2$(_context2) {
          while (1) {
            switch (_context2.prev = _context2.next) {
              case 0:
                _context2.next = 2;
                return this._runExamine();

              case 2:
                bareResult = _context2.sent;

                if (!bareResult.valid) {
                  _context2.next = 5;
                  break;
                }

                return _context2.abrupt('return', {
                  diagnosisMetaData: this.getMeta(),
                  bareResult,
                  formattedSymptoms: '',
                  formattedManualTreat: ''
                });

              case 5:
                formattedSymptoms = this._formatSymptoms(bareResult);
                formattedManualTreat = this._formatManualTreat(bareResult);
                return _context2.abrupt('return', {
                  diagnosisMetaData: this.getMeta(),
                  bareResult,
                  formattedSymptoms,
                  formattedManualTreat
                });

              case 8:
              case 'end':
                return _context2.stop();
            }
          }
        }, _callee2, this);
      }));

      function examine() {
        return _ref2.apply(this, arguments);
      }

      return examine;
    }()
  }]);

  return Diagnosis;
}();

exports.default = Diagnosis;