"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

function _diagnosis() {
  const data = _interopRequireDefault(require("./diagnosis"));

  _diagnosis = function () {
    return data;
  };

  return data;
}

/*
  * Setting up block level variable to store class state
  * set's to null by default.
*/
let instance = null;

class DoctorRegistrar {
  constructor() {
    if (!instance) {
      instance = this;
    }

    return instance;
  }
  /**
   * Initialize the default diagnoses
   */


  static init(diagnoses = []) {
    const self = new DoctorRegistrar();
    self.diagnoses = diagnoses; // diagnoses.forEach(diagnosis => self.diagnoses.push(diagnosis));
  }
  /**
   * Get the instance of the DoctorRegistrar
   * @return {DoctorRegistrar} instance of the DoctorRegistrar
   *
   */


  static getInstance() {
    if (!instance) {
      DoctorRegistrar.init();
    } // $FlowFixMe


    return instance;
  }
  /**
   * Register a new diagnosis
   * @param {Diagnosis} diagnosis
   */


  registerDiagnosis(diagnosis) {
    this.diagnoses.push(diagnosis);
  }

  getDiagnosisByName(name) {
    return this.diagnoses.find(_checkName(name));
  }

}

exports.default = DoctorRegistrar;

const _checkName = name => diagnosis => {
  return diagnosis.name === name;
};