Skip to content

Commit

Permalink
Merge pull request #829 from openhealthcare/metadata-in-template-scope
Browse files Browse the repository at this point in the history
Metadata in template scope
  • Loading branch information
davidmiller authored Aug 17, 2016
2 parents 74f02b9 + 350cb98 commit 2f91f07
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Adds the `clipboard` directive to give the user one click copy to clipboard.

Adds a `tag-select` directive that renders a widget for editing the tags for an episode.

Adds metadata to the scope for patient detail views

#### Updates to the Dependency Graph

* Django Axes 1.4.0 -> 1.7.0
Expand Down
3 changes: 3 additions & 0 deletions doc/docs/guides/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ data about a patient or episode of care, or coded [reference data](referencedata
OPAL provides a simple API for working with such data via the `opal.core.metadata.Metadata`
[discoverable](discoverable.md).

metadata is made available on the scopes for patient lists and
patient details

### Defining Metadata

Defining metadata uses the same pattern as all [discoverable](discoverable.md) features, we
Expand Down
3 changes: 2 additions & 1 deletion opal/static/js/opal/controllers/patient_detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ angular.module('opal.controllers').controller(
'PatientDetailCtrl',
function(
$rootScope, $scope, $modal, $location, $routeParams,
Flow, Item, patient, profile
Flow, Item, patient, profile, metadata
){
$scope.profile = profile;
$scope.patient = patient;
Expand All @@ -26,6 +26,7 @@ angular.module('opal.controllers').controller(
}
}
}
$scope.metadata = metadata;
}

$scope.switch_to_episode = function(index, $event){
Expand Down
7 changes: 4 additions & 3 deletions opal/static/js/opal/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ app.config(
resolve: {
episodedata: function(patientListLoader) { return patientListLoader(); },
metadata : function(Metadata){ return Metadata },
profile : function(UserProfile){ return UserProfile; },
profile : function(UserProfile){ return UserProfile; }
},
templateUrl: function(params){
var target = '/templates/patient_list.html';
Expand All @@ -32,8 +32,9 @@ app.config(
.when('/patient/:patient_id/:view?', {
controller: 'PatientDetailCtrl',
resolve: {
patient: function(patientLoader) { return patientLoader(); },
profile: function(UserProfile){ return UserProfile; }
patient: function(patientLoader) { return patientLoader(); },
profile: function(UserProfile){ return UserProfile; },
metadata: function(Metadata){ return Metadata; }
},
templateUrl: function(params){ return '/templates/patient_detail.html' }
})
Expand Down
7 changes: 6 additions & 1 deletion opal/static/js/opaltest/patient_detail.controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('PatientDetailCtrl', function(){
provisional: false,
}]
};
var metadata = {some: "metadata"};

var columns = {
"default": [
Expand Down Expand Up @@ -105,7 +106,8 @@ describe('PatientDetailCtrl', function(){
Flow : Flow,
patient : patient,
options : options,
profile : profile
profile : profile,
metadata : metadata
});

});
Expand All @@ -130,6 +132,9 @@ describe('PatientDetailCtrl', function(){
expect($scope.switch_to_episode).toHaveBeenCalledWith(0);
});

it('should hoist the metaddata', function(){
expect($scope.metadata.some).toBe('metadata');
});
});

describe('switch_to_episode()', function() {
Expand Down
3 changes: 2 additions & 1 deletion opal/static/js/opaltest/test_routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ describe('Routes', function() {

it('should resolve injected things', function() {
var resolve = $route.routes['/patient/:patient_id/:view?'].resolve;
expect(resolve.patient(function(){return {}})).toEqual({});
expect(resolve.patient(function(){return {};})).toEqual({});
expect(resolve.profile('Profile')).toEqual('Profile');
expect(resolve.metadata('Metadata')).toBe('Metadata');
});

it('should know the template', function() {
Expand Down

0 comments on commit 2f91f07

Please sign in to comment.