Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Cascading delete for patient record #380

Closed
tangollama opened this issue Mar 19, 2016 · 6 comments
Closed

Cascading delete for patient record #380

tangollama opened this issue Mar 19, 2016 · 6 comments
Labels
in progress indicates that issue/pull request is currently being worked on

Comments

@tangollama
Copy link
Member

When deleting a patient, we need to delete all visits, invoices, etc.

@aboma
Copy link
Contributor

aboma commented Apr 27, 2016

I am working on this.

@jkleinsc jkleinsc added in progress indicates that issue/pull request is currently being worked on and removed help wanted indicates that an issue is open for contributions labels Apr 27, 2016
@tangollama
Copy link
Member Author

Thanks @aboma. @jkleinsc you'll want to pay close attention to this issue to assist and look for the PR.

@aboma
Copy link
Contributor

aboma commented May 6, 2016

I have written code to delete all of a patient's visits and models related to visits. However, I am having trouble getting a list of invoices for the patient being deleted so that I can delete them. If someone could provide a snippet of how to search the store for invoices for a patient that would help me finish this. The various ways I have tried to implemented this have all turned up zero invoices even though I have entered one for the patient. My current attempt is the following:

   var maxValue = this.get('maxValue');
   var patientId = patient.get('id');
   return this.store.query('invoice', {
        options: {
          startkey: ['patientId', patientId, 'invoice_'],
          endkey: ['patientId', patientId, maxValue]
        },
        mapReduce: 'invoice_by_status'
      });

Thank you @tangollama

@jkleinsc
Copy link
Member

jkleinsc commented May 9, 2016

@aboma in order to find invoices by patient, a new view needs to be added to the pouch/couch views by defining it in app/utils/pouch-views.js before the 'invoice_by_status' view:

}, {
  name: 'invoice_by_patient',
  function: generateView('invoice',
    'emit(doc.data.patient);'
  ),
  version: 1
}.....

Then to find:

var patientId = patient.get('id');
return this.store.query('invoice', {
  options: {
    key: patientId
  },
  mapReduce: 'invoice_by_patient'
});

aboma added a commit to aboma/hospitalrun-frontend that referenced this issue May 11, 2016
…te related records first and then patient record
@tangollama
Copy link
Member Author

@jkleinsc @aboma thinking this still outstanding, yes?

@jkleinsc
Copy link
Member

jkleinsc commented Jul 7, 2016

@tangollama yes this is still outstanding.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
in progress indicates that issue/pull request is currently being worked on
Projects
None yet
Development

No branches or pull requests

3 participants