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

1597 remove jump to episode from search #1598

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions changelog.md
@@ -1,5 +1,17 @@
### 0.13.0 (Major Release)

#### Removes scope.jumpToEpisode and scope.getEpisodeId from Search and Extract

We no longer use these functions, instead we use a standard href to the patient detail.

#### Removes Patient.to_dict().active_episode_id

We no longer include a value for "active_episode_id" as part of the Patient to_dict serialisation.

This is effectively meaningless since we moved to an episode model that allows for multiple
concurrent episodes.


#### Removes CopyToCategory

Removes the entire CopyToCategory flow from Opal Core. If applications continue to rely on it,
Expand Down
5 changes: 0 additions & 5 deletions opal/core/search/static/js/search/controllers/extract.js
Expand Up @@ -343,9 +343,4 @@ angular.module('opal.controllers').controller(
$scope.filters.push(result);
});
};

$scope.jumpToEpisode = function(episode){
window.open('#/episode/'+episode.id, '_blank');
};

});
13 changes: 0 additions & 13 deletions opal/core/search/static/js/search/controllers/search.js
Expand Up @@ -108,17 +108,4 @@ angular.module('opal.controllers').controller(

$window.location.href = searchUrl + '/#/' + "?" + $.param(params);
};

$scope.getEpisodeID = function(patient){
var epid = patient.active_episode_id;
if(!epid){
epid = _.first(_.keys(patient.episodes));
}
return epid;
};

$scope.jumpToEpisode = function(patient){
$location.path('/episode/'+$scope.getEpisodeID(patient));
};

});
10 changes: 0 additions & 10 deletions opal/core/search/static/js/test/extract.controller.test.js
Expand Up @@ -768,16 +768,6 @@ describe('ExtractCtrl', function(){

});

describe('jumpToEpisode()', function() {

it('should open the tab', function() {
spyOn($window, 'open');
$scope.jumpToEpisode({id: 2});
expect($window.open).toHaveBeenCalledWith('#/episode/2', '_blank');
});

});

describe('Getting searchable columns', function(){
it('should only get the columns that are advanced searchable', function(){
expect($scope.columns).toEqual([
Expand Down
22 changes: 0 additions & 22 deletions opal/core/search/static/js/test/search.controller.test.js
Expand Up @@ -169,26 +169,4 @@ describe('SearchCtrl', function (){
$httpBackend.flush();
});
});

describe('getEpisodeId', function() {

it('should use the first episode if we have no active episode_id', function() {
var patient = {
episodes: {
42: {}, //dummy episode
8738: {} // another dummy episode
}
}
expect($scope.getEpisodeID(patient)).toEqual('42');
});

});

describe('jumpToEpisode()', function (){
it('Should call location.path()', function () {
$scope.jumpToEpisode({active_episode_id: 555});
expect(location.path).toHaveBeenCalledWith('/episode/555');
});
});

});
4 changes: 1 addition & 3 deletions opal/models.py
Expand Up @@ -577,12 +577,10 @@ def bulk_update(self, dict_of_list_of_upgrades, user,
force=force)

def to_dict(self, user):
active_episode = self.get_active_episode()
d = {
'id': self.id,
'episodes': {episode.id: episode.to_dict(user) for episode in
self.episode_set.all()},
'active_episode_id': active_episode.id if active_episode else None,
self.episode_set.all()}
}

for model in patient_subrecords():
Expand Down
28 changes: 23 additions & 5 deletions opal/static/js/opal/controllers/hospital_number.js
Expand Up @@ -67,19 +67,37 @@ angular.module('opal.controllers').controller(
addPatient(demographics);
};

$scope.newForPatient = function(patient){
if (patient.active_episode_id &&
$scope._active_episode_id = function(patient){
var active_ids = _.filter(
_.values(patient.episodes),
function(x){ return x.active == true }
);
if(active_ids.length){
return active_ids[0].id
}else{
return null;
}
}

$scope.newForPatient = function(patient){

var first_active_episode_id = $scope._active_episode_id(patient);

if (first_active_episode_id &&
// Check to see that this episode is not "Discharged"
patient.episodes[patient.active_episode_id].location[0].category != 'Discharged') {
patient.episodes[first_active_episode_id].location[0].category != 'Discharged') {
// This patient has an active episode
$scope.newForPatientWithActiveEpisode(patient);
} else { // This patient has no active episode
$scope.addForPatient(patient);
};
};

$scope.newForPatientWithActiveEpisode = function(patient){
episode = new Episode(patient.episodes[patient.active_episode_id])
$scope.newForPatientWithActiveEpisode = function(patient){

var first_active_episode_id = $scope._active_episode_id(patient);

episode = new Episode(patient.episodes[first_active_episode_id])

if(episode.category_name != 'Inpatient'){ // It's the wrong category - add new
return $scope.addForPatient(patient);
Expand Down
9 changes: 4 additions & 5 deletions opal/static/js/test/hospital_number.controller.test.js
Expand Up @@ -66,7 +66,6 @@ describe('HospitalNumberCtrl', function(){


_patientData = {
"active_episode_id": null,
"demographics": [
{
"consistency_token": "0beb0d46",
Expand Down Expand Up @@ -279,7 +278,7 @@ describe('HospitalNumberCtrl', function(){
var deferred, callArgs;
spyOn($scope, 'newForPatientWithActiveEpisode');

patientData.active_episode_id = 3;
patientData.episodes["3"].active = true;

deferred = $q.defer();
spyOn($modal, 'open').and.returnValue({result: deferred.promise});
Expand All @@ -299,7 +298,7 @@ describe('HospitalNumberCtrl', function(){

it('should call through if there is an active episode.', function(){
spyOn($scope, 'newForPatientWithActiveEpisode');
patientData.active_episode_id = 3;
patientData.episodes["3"].active = true;
patientData.episodes[3].location[0].category = 'Inpatient'

$scope.newForPatient(patientData);
Expand Down Expand Up @@ -372,8 +371,8 @@ describe('HospitalNumberCtrl', function(){
var activePatientData;

beforeEach(function(){
activePatientData = angular.copy(patientData);
activePatientData.active_episode_id = 3;
activePatientData = angular.copy(patientData);
activePatientData.episodes["3"].active = true;
})

describe('if not an inpatient', function(){
Expand Down
1 change: 0 additions & 1 deletion opal/static/js/test/test_helper.js
Expand Up @@ -49,7 +49,6 @@

var patientData = {
id: 1,
active_episode_id: "123",
demographics: demographics,
episodes: {
"123": episodeData
Expand Down