Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating new episodes #1847

Closed
WoutV opened this issue Apr 14, 2020 · 8 comments
Closed

Creating new episodes #1847

WoutV opened this issue Apr 14, 2020 · 8 comments

Comments

@WoutV
Copy link

WoutV commented Apr 14, 2020

Apart from the one paragraph in the docs/guides I cannot find anything about creating new episodes from the front-end. I am in the dark on how to implement this functionality (e.g. adding a new episode to an existing patient, without just doing it in the admin console). When I create a "normal" pathway, and add the patient id at the end of the URL, a new patient is created anyway.

Possibly related to this #1537

@fredkingham
Copy link
Contributor

I think there could be issues with using a pathway to create a new episode.

So is your usecase that you have a patient that is connected to a different episode and want to add an additional episode to a patient?

@WoutV
Copy link
Author

WoutV commented Apr 14, 2020

I am just looking for a straightforward way to create new episodes for patients. The referenced piece of documentation was the only thing that came close to it, as far as I could find.

@davidmiller
Copy link
Member

Hi @WoutV You will be pleased to hear that creating new episodes for patients is a thing that frequently happens within Opal applications via various different strategies - sometimes based on a direct user action, sometimes as the side effect of a user action, sometimes based on some external interface etc etc.

I've never had to do it via the Admin console.

In order to best advise you, I wonder if you could explain what your application is and what the context of the episode you want to create is ?

@WoutV
Copy link
Author

WoutV commented Apr 14, 2020

I want to store different lines of chemotherapy treatment as separate episodes, to make sure that we can keep the linked adverse events, responses, ... (modeled as subrecords) linked to the right line of treatment, instead of having just one episode per patient where we put all the subrecords for that one patient.

Ideally this would happen through the click of a button, which would then prompt to create a new episode with some metadata (number of the line of treatment, start date, ...)

I feel like I am missing a key part of knowledge on how to do this.

@WoutV WoutV changed the title Pathways - Loading Data From Existing Episodes Creating new episodes Apr 15, 2020
@davidmiller
Copy link
Member

davidmiller commented Apr 15, 2020

Hi @WoutV

One of the interesting things here is that we largely don't do this in practice - it's happened but not regularly.

Creating an episode on the client, method 1: with other data entry

If I needed to, I'd do it in a custom controller, rather than with a Pathway.

Episodes and subrecords have their own API endpoint.
There's a .refresh() method on the detail controller scope that will re-load the data into the detail page.

Something like:

$scope.editing = {}; // Form data will point at this

var episode = new Episode({'demographics':[patient.demographics[0]]});
var episode_data = {
  'category_name = 'Your Name',
  'start': = new Date()
}
// You can also save individual extra data fields here if you need to.
var treatment_line = episode.newItem('treatment_line');

$q.all([
  episode.save(episode_data),
  treatment_line.save({'number': editing.number}),
]).then(function(){
  refresh().then(function(){
    $modalInstance.close(episode);
  })
})

(This isn't tested, and it's been a while.)

To load in a modal, something like:

ng-click="open_modal('YourController', '/your/template.html', {'patient': patient, 'refresh': refresh})">

Creating an episode method 2, single press

Another way would be to add a + button to creates the new episode and calls the refresh() method on the patient detail page. Something like

// Markup
<div class="btn btn-default" ng-controller="AddEpisodeCtrl" ng-click="add()">+</div>
// controller
$scope.add = function(){
  var episode = new Episode({'demographics':[$scope.patient.demographics[0]]});

  episode.category_name = 'Your Name';
  episode.start = moment();
  episode.save().then(function(){ $scope.refresh() })
}

Other considerations

If I understand what a line of chemotherapy is (entirely possible I don't !) then I'm not sure I would definitely model that as a separate episode however - in general, we have moved towards having as few episodes per patient as possible - particularly not multiple concurrent episodes per patient for a single team.

Hard to say definitively without reviewing your code or understanding the context further.

You're doing this because it's possible to have 0-n instances of multiple other subrecords per line of chemotherapy and it links them neatly?

@WoutV
Copy link
Author

WoutV commented Apr 16, 2020

Your final consideration is indeed what I am trying to model. The different lines of treatment are sequential in time (not overlapping or active at the same time), but they consist of different drug administrations, they contain the response of the patient to that specific treatment line, possible adverse events, ... and all these subrecords only relate to one specific treatment line. To me it made the most sense to model them as episodes (treatment lines) with subrecords (AE, drug administration, response, ...).

I will take a look at the two options you described, and see how it fits. Thanks!

@davidmiller
Copy link
Member

davidmiller commented Apr 16, 2020

OK, so if they don't ever overlap, then another option, which does allow you to use the Pathway code to add initial data in other subrecords rather than have to wire form data yourself, is to create the 'next' treatment line episode before it's used but only display it when it becomes active.

In this application, an 'FP17' is conceptually analogous to your treatment line. (Specifically It's more or less a visit to the dentist)

The Register / Add patient pathway is overriden to create some empty episodes https://github.com/odonto/odonto/blob/v0.32/odonto/pathways.py#L67

When these 'New' episodes are first edited via a pathway, their stage is changed, and another empty episode is created to be used next time: https://github.com/odonto/odonto/blob/v0.32/odonto/pathways.py#L117

Meanwhile the button in the UI says something like "Open a new FP17" (Or Treatment Line) in your case.

@WoutV
Copy link
Author

WoutV commented Apr 17, 2020

@davidmiller it seems I am having more trouble building this than I initially expected. Would it be an option to collaborate with Open Health Care to develop a solution that fits our need? I am open to discuss this over a different medium as well.

@WoutV WoutV closed this as completed Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants