Exemplo n.º 1
0
import { get } from '@ember/object';
import RSVP from 'rsvp';
import AbstractDeleteController from 'hospitalrun/controllers/abstract-delete-controller';
import { translationMacro as t } from 'ember-i18n';

export default AbstractDeleteController.extend({
  title: t('incident.titles.deleteIncident'),

  _deleteChildObject(incident, childObject, destroyPromises) {
    incident.get(childObject).then(function(childObject) {
      childObject.forEach(function(child) {
        destroyPromises.push(child.destroyRecord());  // Add the destroy promise to the list
      });
    });
  },

  actions: {
    delete() {
      let destroyPromises = [];
      let incident = get(this, 'model');
      this._deleteChildObject(incident, 'notes', destroyPromises);
      RSVP.all(destroyPromises).then(function() {
        // fires when all the destroys have been completed.
        get(this, 'model').destroyRecord().then(function() { // delete incident
          this.send('closeModal');
        }.bind(this));
      }.bind(this));
    }
  }
});
Exemplo n.º 2
0
import AbstractDeleteController from 'hospitalrun/controllers/abstract-delete-controller';
export default AbstractDeleteController.extend({
  title: 'Delete Visit',

  afterDeleteAction: function() {
    var deleteFromPatient = this.get('model.deleteFromPatient');
    if (deleteFromPatient) {
      return 'visitDeleted';
    } else {
      return 'closeModal';
    }
  }.property('model.deleteFromPatient')
});
Exemplo n.º 3
0
import AbstractDeleteController from 'hospitalrun/controllers/abstract-delete-controller';
import { computed } from '@ember/object';

export default AbstractDeleteController.extend({
  title: 'Delete Appointment',

  afterDeleteAction: computed('model.deleteFromPatient', function() {
    let deleteFromPatient = this.get('model.deleteFromPatient');
    if (deleteFromPatient) {
      return 'appointmentDeleted';
    } else {
      return 'closeModal';
    }
  })
});
Exemplo n.º 4
0
import AbstractDeleteController from 'hospitalrun/controllers/abstract-delete-controller';
import PatientSubmodule from 'hospitalrun/mixins/patient-submodule';
import { translationMacro as t } from 'ember-i18n';

export default AbstractDeleteController.extend(PatientSubmodule, {
  title: t('labs.deleteTitle'),

  actions: {
    delete: function() {
      this.removeChildFromVisit(this.get('model'), 'labs').then(function() {
        this.get('model').destroyRecord().then(function() {
          this.send('closeModal');
        }.bind(this));
      }.bind(this));
    }
  }
});
Exemplo n.º 5
0
import AbstractDeleteController from 'hospitalrun/controllers/abstract-delete-controller';
import Ember from "ember";
export default AbstractDeleteController.extend({
    needs: 'visits/edit',
    
    afterDeleteAction: 'notifyProcedureDelete',
    editController: Ember.computed.alias('controllers.visits/edit'),
    title: 'Delete Procedure',
    
    actions: {
        notifyProcedureDelete: function() {
            this.send('closeModal');
            this.get('editController').send('deleteProcedure', this.get('model'));
        }
    }
});
Exemplo n.º 6
0
import AbstractDeleteController from 'hospitalrun/controllers/abstract-delete-controller';
export default AbstractDeleteController.extend({
  title: 'Delete Pricing Item'
});
import AbstractDeleteController from 'hospitalrun/controllers/abstract-delete-controller';
import PatientSubmodule from 'hospitalrun/mixins/patient-submodule';
export default AbstractDeleteController.extend(PatientSubmodule, {
  title: 'Delete Request',

  actions: {
    delete: function() {
      this.deleteChildFromVisit('imaging');
    }
  }
});
Exemplo n.º 8
0
import AbstractDeleteController from 'hospitalrun/controllers/abstract-delete-controller';
import PatientSubmodule from 'hospitalrun/mixins/patient-submodule';
import { t } from 'hospitalrun/macro';

export default AbstractDeleteController.extend(PatientSubmodule, {
  title: t('labs.deleteTitle'),

  actions: {
    delete() {
      this.deleteChildFromVisit('labs');
    }
  }
});
Exemplo n.º 9
0
import AbstractDeleteController from 'hospitalrun/controllers/abstract-delete-controller';
import { translationMacro as t } from 'ember-i18n';

export default AbstractDeleteController.extend({
  title: t('patients.titles.delete')
});
Exemplo n.º 10
0
export default AbstractDeleteController.extend(PatientVisitsMixin, PatientInvoicesMixin, PouchDbMixin, ProgressDialog, PatientAppointmentsMixin, {
  title: t('patients.titles.delete'),
  progressTitle: t('patients.titles.deletePatientRecord'),
  progressMessage: t('patients.messages.deletingPatient'),

  // Override delete action on controller; we must delete
  // all related records before deleting patient record
  // otherwise errors will occur
  deletePatient: function() {
    let controller = this;
    let patient = this.get('model');
    let visits = this.getPatientVisits(patient);
    let invoices = this.getPatientInvoices(patient);
    let appointments = this.getPatientAppointments(patient);
    let payments = patient.get('payments');
    // resolve all async models first since they reference each other, then delete
    return Ember.RSVP.all([visits, invoices, appointments, payments]).then(function(records) {
      let promises = [];
      promises.push(controller.deleteVisits(records[0]));
      promises.push(controller.deleteInvoices(records[1]));
      promises.push(deleteMany(records[2]));   // appointments
      promises.push(deleteMany(records[3]));   // payments
      return Ember.RSVP.all(promises)
        .then(function() {
          return patient.destroyRecord();
        });
    });
  },

  deleteVisits: function(visits) {
    let promises = [];
    visits.forEach(function(visit) {
      let labs = visit.get('labs');
      let procedures = visit.get('procedures');
      let imaging = visit.get('imaging');
      let procCharges = procedures.then(function(p) {
        return p.get('charges');
      });
      let labCharges = labs.then(function(l) {
        return l.get('charges');
      });
      let imagingCharges = imaging.then(function(i) {
        return i.get('charges');
      });
      let visitCharges = visit.get('charges');
      promises.push(deleteMany(labs));
      promises.push(deleteMany(labCharges));
      promises.push(deleteMany(visit.get('patientNotes')));
      promises.push(deleteMany(visit.get('vitals')));
      promises.push(deleteMany(procedures));
      promises.push(deleteMany(procCharges));
      promises.push(deleteMany(visit.get('medication')));
      promises.push(deleteMany(imaging));
      promises.push(deleteMany(imagingCharges));
      promises.push(deleteMany(visitCharges));
    });
    return Ember.RSVP.all(promises).then(function() {
      return deleteMany(visits);
    });
  },

  deleteInvoices: function(patientInvoices) {
    return Ember.RSVP.resolve(patientInvoices).then(function(invoices) {
      let lineItems = Ember.A();
      invoices.forEach(function(i) {
        lineItems.addObjects(i.get('lineItems'));
      });
      let lineItemDetails = Ember.A();
      lineItems.forEach(function(li) {
        lineItemDetails.addObjects(li.get('details'));
      });
      return Ember.RSVP.all([lineItems, lineItemDetails]).then(function() {
        return Ember.RSVP.all([deleteMany(invoices), deleteMany(lineItems), deleteMany(lineItemDetails)]);
      });
    });
  },

  actions: {
    // delete related records without modal dialogs
    delete: function(patient) {
      let controller = this;
      this.send('closeModal');
      this.showProgressModal();
      this.deletePatient(patient).then(function() {
        controller.closeProgressModal();
        controller.send(controller.get('afterDeleteAction'), patient);
      });
    }
  }
});
Exemplo n.º 11
0
export default AbstractDeleteController.extend(PatientVisitsMixin, PatientInvoicesMixin, PouchDbMixin, ProgressDialog, PatientAppointmentsMixin, {
  title: t('patients.titles.delete'),
  progressTitle: t('patients.titles.deletePatientRecord'),
  progressMessage: t('patients.messages.deletingPatient'),
  deleting: taskGroup(),

  deleteMany(manyArray) {
    return this.get('deleteManyTask').perform(manyArray);
  },

  deleteManyTask: task(function* (manyArray) {
    if (!manyArray) {
      return;
    }
    let resolvedArray = yield manyArray;
    if (isEmpty(resolvedArray)) {
      // empty array: no records to delete
      return;
    }
    let deleteRecordTask = this.get('deleteRecordTask');
    let archivePromises = [];
    resolvedArray.forEach((recordToDelete) => {
      archivePromises.push(deleteRecordTask.perform(recordToDelete));
    });
    return yield all(archivePromises, 'async array deletion');
  }).group('deleting'),

  deleteRecordTask: task(function* (recordToDelete) {
    recordToDelete.set('archived', true);
    yield recordToDelete.save();
    return yield recordToDelete.unloadRecord();
  }).group('deleting'),

  // Override delete action on controller; we must delete
  // all related records before deleting patient record
  // otherwise errors will occur
  deletePatient() {
    return this.get('deletePatientTask').perform();
  },

  deletePatientTask: task(function* () {
    let patient = this.get('model');
    let visits = yield this.getPatientVisits(patient);
    let invoices = yield this.getPatientInvoices(patient);
    let appointments = yield this.getPatientAppointments(patient);
    let payments = yield patient.get('payments');
    yield all([
      this.deleteVisits(visits),
      this.deleteInvoices(invoices),
      this.deleteMany(appointments),
      this.deleteMany(payments)
    ]);
    return yield patient.destroyRecord();
  }).group('deleting'),

  deleteVisits(visits) {
    return this.get('deleteVisitsTask').perform(visits);
  },

  deleteVisitsTask: task(function* (visits) {
    let pendingTasks = [];
    visits.forEach((visit) => {
      let labs = visit.get('labs');
      let procedures = visit.get('procedures');
      let imaging =  visit.get('imaging');
      let procCharges = procedures.get('charges');
      let labCharges = labs.get('charges');
      let imagingCharges = imaging.get('charges');
      let visitCharges = visit.get('charges');
      pendingTasks.push(this.deleteMany(labs));
      pendingTasks.push(this.deleteMany(labCharges));
      pendingTasks.push(this.deleteMany(visit.get('patientNotes')));
      pendingTasks.push(this.deleteMany(visit.get('vitals')));
      pendingTasks.push(this.deleteMany(procedures));
      pendingTasks.push(this.deleteMany(procCharges));
      pendingTasks.push(this.deleteMany(visit.get('medication')));
      pendingTasks.push(this.deleteMany(imaging));
      pendingTasks.push(this.deleteMany(imagingCharges));
      pendingTasks.push(this.deleteMany(visitCharges));
    });
    yield all(pendingTasks);
    return yield this.deleteMany(visits);
  }).group('deleting'),

  deleteInvoices(patientInvoices) {
    return this.get('deleteInvoicesTask').perform(patientInvoices);
  },

  deleteInvoicesTask: task(function* (patientInvoices) {
    let invoices = yield patientInvoices;
    let lineItems = yield all(invoices.mapBy('lineItems'));
    let lineItemDetails = yield all(lineItems.mapBy('details'));
    return yield all([
      this.deleteMany(invoices),
      this.deleteMany(lineItems),
      this.deleteMany(lineItemDetails)
    ]);
  }).group('deleting'),

  deleteActionTask: task(function* (patient) {
    // delete related records without modal dialogs
    this.send('closeModal');
    this.showProgressModal();
    yield this.deletePatient(patient);
    this.closeProgressModal();
    this.send(this.get('afterDeleteAction'), patient);
  }).drop(),

  actions: {
    delete(patient) {
      this.get('deleteActionTask').perform(patient);
    }
  }
});