<commit_before>import templateUrl from './demographics-component.html';

function patientDemographicsPermissionFactory(PatientSystemObjectPermission) {
  return PatientSystemObjectPermission;
}

patientDemographicsPermissionFactory.$inject = ['PatientSystemObjectPermission'];

function patientDemographicsControllerFactory(
  ModelListDetailController,
  PatientDemographicsPermission,
  firstPromise,
  DenyPermission,
  $injector,
  store
) {
  /**
   * Each patient has a demographics record which includes PID like their name, date of birth
   * and ethnicity. A patient can have at most one demographics record per source (e.g. RADAR
   * and UKRDC).
   *
   * @class
   * @param {Object} $scope - angular scope.
   */
  function PatientDemographicsController($scope) {
    var self = this;

    // When a patient is recruited an entry is created in the demographics table with the
    // patient's name etc. This entry can be edited but not deleted. There should only be
    // one entry per patient (and source). Therefore users shouldn't be allowed to create new
    // entries.

    $injector.invoke(ModelListDetailController, self, {
      $scope: $scope,
      params: {
        createPermission: new DenyPermission(),
        editPermission: new PatientDemographicsPermission($scope.patient),
        removePermission: new DenyPermission()
      }
    });

    /**
     * Return id of the first found patient cohort.
     * We trust that patient can be in one and only one country,
     * so even if he/she belongs to multiple cohorts, it is enough
     * for us to find the first one.
     */
    function findCohortCountry() {
      var groups = $scope.patient.groups;
      for (var i = 0; i < groups.length; i++) {
        if (groups[i].group.type === 'COHORT') {
          return groups[i].group.countryCode;
        }
      }
      return 'GB';
    }

    self.load(firstPromise([
      store.findMany('patient-demographics', {patient: $scope.patient.id}),
      store.findMany('genders').then(function(genders) {
        $scope.genders = genders;
      }),
      store.findMany('ethnicities', {groupCountry: findCohortCountry()}).then(function(ethnicities) {
        $scope.ethnicities = ethnicities;
      }),
      store.findMany('nationalities', {groupCountry: findCohortCountry()}).then(function(nationalities) {
        $scope.nationalities = nationalities;
      }),
    ]));
  }

  PatientDemographicsController.$inject = ['$scope'];
  PatientDemographicsController.prototype = Object.create(ModelListDetailController.prototype);
<commit_msg>eslint<commit_after>import templateUrl from './demographics-component.html';

function patientDemographicsPermissionFactory(PatientSystemObjectPermission) {
  return PatientSystemObjectPermission;
}

patientDemographicsPermissionFactory.$inject = ['PatientSystemObjectPermission'];

function patientDemographicsControllerFactory(
  ModelListDetailController,
  PatientDemographicsPermission,
  firstPromise,
  DenyPermission,
  $injector,
  store
) {
  /**
   * Each patient has a demographics record which includes PID like their name, date of birth
   * and ethnicity. A patient can have at most one demographics record per source (e.g. RADAR
   * and UKRDC).
   *
   * @class
   * @param {Object} $scope - angular scope.
   */
  function PatientDemographicsController($scope) {
    var self = this;

    // When a patient is recruited an entry is created in the demographics table with the
    // patient's name etc. This entry can be edited but not deleted. There should only be
    // one entry per patient (and source). Therefore users shouldn't be allowed to create new
    // entries.

    $injector.invoke(ModelListDetailController, self, {
      $scope: $scope,
      params: {
        createPermission: new DenyPermission(),
        editPermission: new PatientDemographicsPermission($scope.patient),
        removePermission: new DenyPermission()
      }
    });

    /**
     * Return id of the first found patient cohort.
     * We trust that patient can be in one and only one country,
     * so even if he/she belongs to multiple cohorts, it is enough
     * for us to find the first one.
     *
     * @returns {string} Country code
     */
    function findCohortCountry() {
      var groups = $scope.patient.groups;
      for (var i = 0; i < groups.length; i++) {
        if (groups[i].group.type === 'COHORT') {
          return groups[i].group.countryCode;
        }
      }
      return 'GB';
    }

    self.load(firstPromise([
      store.findMany('patient-demographics', {patient: $scope.patient.id}),
      store.findMany('genders').then(function(genders) {
        $scope.genders = genders;
      }),
      store.findMany('ethnicities', {groupCountry: findCohortCountry()}).then(function(ethnicities) {
        $scope.ethnicities = ethnicities;
      }),
      store.findMany('nationalities', {groupCountry: findCohortCountry()}).then(function(nationalities) {
        $scope.nationalities = nationalities;
      }),
    ]));
  }

  PatientDemographicsController.$inject = ['$scope'];
  PatientDemographicsController.prototype = Object.create(ModelListDetailController.prototype);

{'fraction_non_alphanumeric': 0.10336166924265842, 'fraction_numerical': 0.0003863987635239567, 'mean_word_length': 3.3105745212323066, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3633179', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1370, 'n_words': 400}