-
Notifications
You must be signed in to change notification settings - Fork 87
/
patient_summary.js
48 lines (40 loc) · 1.49 KB
/
patient_summary.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
//
// This is the main PatientSummary class for OPAL.
//
angular.module('opal.services').factory('PatientSummary', function() {
"use strict";
var PatientSummary = function(jsonResponse){
this.data = jsonResponse;
var startYear, endYear
if(jsonResponse.start_date){
this.startDate = moment(jsonResponse.start_date, 'DD/MM/YYYY');
startYear= this.startDate.format("YYYY");
}
if(jsonResponse.end_date){
this.endDate = moment(jsonResponse.end_date, 'DD/MM/YYYY');
endYear = this.endDate.format("YYYY");
}
if(startYear && endYear && startYear !== endYear){
this.years = startYear + "-" + endYear;
}
else if(startYear){
this.years = startYear;
}
if(jsonResponse.date_of_birth){
this.dateOfBirth = moment(jsonResponse.date_of_birth, 'DD/MM/YYYY');
}
if(jsonResponse.patient_id){
this.link = "/#/patient/" + jsonResponse.patient_id;
this.patientId = jsonResponse.patient_id;
}
if(jsonResponse.categories){
this.categories = jsonResponse.categories.join(", ");
}
this.first_name = jsonResponse.first_name;
this.surname = jsonResponse.surname;
this.count = jsonResponse.count;
this.dateOfBirth = moment(jsonResponse.date_of_birth, 'DD/MM/YYYY');
this.hospitalNumber = jsonResponse.hospital_number;
};
return PatientSummary;
});