-
Notifications
You must be signed in to change notification settings - Fork 4
/
find_patient.js
51 lines (43 loc) · 1.46 KB
/
find_patient.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
controllers.controller('FindPatientCtrl',
function(Episode, $controller, $location) {
"use strict";
var parentCtrl = $controller("MultistageDefault");
var vm = this;
_.extend(vm, parentCtrl);
vm.state = 'initial';
var params = $location.search();
vm.demographics = {
hospital_number: undefined
};
if(params.hospital_number){
vm.hospital_number = params.hospital_number;
vm.state = 'editing_demographics';
vm.demographics.hospital_number = vm.hospital_number;
}
vm.lookup_hospital_number = function() {
Episode.findByHospitalNumber(
vm.hospital_number,
{
newPatient: vm.new_patient,
newForPatient: vm.new_for_patient,
error : function(){
// this shouldn't happen, but we should probably handle it better
alert('ERROR: More than one patient found with hospital number');
}
});
};
vm.new_patient = function(result){
vm.state = 'editing_demographics';
vm.demographics.hospital_number = vm.hospital_number;
};
vm.new_for_patient = function(patient){
vm.demographics = patient.demographics[0];
vm.state = 'has_demographics';
};
vm.showNext = function(editing){
return vm.demographics.hospital_number;
};
vm.toSave = function(editing){
editing.demographics = vm.demographics;
};
});