<commit_before><commit_msg>Add mixin unit test for patient-diagnosis (#885)<commit_after>import PatientDiagnosis from 'hospitalrun/mixins/patient-diagnosis';
import { moduleFor, test } from 'ember-qunit';
import Ember from 'ember';

moduleFor('mixin:patient-diagnosis', 'Unit | Mixin | patient-diagnosis', {
  needs: [
    'model:visit',
    'model:proc-charge',
    'model:patient',
    'model:vital',
    'model:imaging',
    'model:lab',
    'model:medication',
    'model:patient-note',
    'model:procedure'
  ],
  store() {
    return this.container.lookup('service:store');
  },
  getVisitsData() {
    return Ember.run(() => {
      return [
        {
          startDate: new Date(1393822800000),
          primaryDiagnosis: 'primary one',
          primaryBillingDiagnosis: 'primary billing one',
          additionalDiagnoses: [
            { description: 'additional diag one a' },
            { description: 'additional diag one b' }
          ]
        },
        {
          startDate: new Date(1372822800000),
          primaryDiagnosis: 'primary two',
          primaryBillingDiagnosis: 'primary billing two',
          additionalDiagnoses: [
            { description: 'additional diag two' }
          ]
        }
      ].map((visit) => this.store().createRecord('visit', visit));
    });
  }
});

test('getPrimaryDiagnoses', function(assert) {
  let patientDiagnosis = Ember.Object.extend(PatientDiagnosis).create();
  let visits = this.getVisitsData();
  let diagnosesList = patientDiagnosis.getPrimaryDiagnoses(visits);

  assert.deepEqual(diagnosesList, [
    {
      date: new Date('Mon Mar 03 2014 00:00:00 GMT-0500 (EST)'),
      description: 'primary one',
      first: true
    },
    {
      date: new Date('Mon Mar 03 2014 00:00:00 GMT-0500 (EST)'),
      description: 'primary billing one'
    },
    {
      date: new Date('Tue Jul 02 2013 23:40:00 GMT-0400 (EDT)'),
      description: 'primary two'
    },
    {
      date: new Date('Tue Jul 02 2013 23:40:00 GMT-0400 (EDT)'),
      description: 'primary billing two'
    }
  ]);
});

test('getSecondaryDiagnosis', function(assert) {
  let patientDiagnosis = Ember.Object.extend(PatientDiagnosis).create();
  let visits = this.getVisitsData();
  let diagnosesList = patientDiagnosis.getSecondaryDiagnoses(visits);

  assert.deepEqual(diagnosesList, [
    {
      description: 'additional diag one a',
      first: true
    },
    {
      description: 'additional diag one b'
    },
    {
      description: 'additional diag two'
    }
  ]);
});
{'fraction_non_alphanumeric': 0.13454689354966362, 'fraction_numerical': 0.036802532647407994, 'mean_word_length': 2.83030303030303, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7140005', 'n_tokens_mistral': 880, 'n_tokens_neox': 752, 'n_words': 171}