Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var hashCode = function (s) {
- return String(s).split("").reduce(function (a, b) { a = ((a << 5) - a) + b.charCodeAt(0); return a & a }, 0);
- }
- class Patient {
- constructor(name) {
- this.name = name;
- this.id = hashCode(name);
- this.positive = true;
- }
- }
- class CovidPositive extends Patient {
- constructor(name, date, gender, age, municipality, symptoms, respiratory_problem,hyperglycaemia) {
- super(name);
- this.gender = gender;
- this.age = age;
- this.date = date;
- this.municipality = municipality;
- this.symptoms = symptoms;
- this.respiratory_problem = respiratory_problem;
- this.hyperglycaemia = hyperglycaemia;
- }
- riskCalc() {
- if (!this.symptoms && this.test && this.diabetes && this.respiratory_problem)
- return "Patient: " + this.id + " " + this.name + " is with high risk";
- if (this.symptoms && this.positive && (this.hyperglycaemia || this.respiratory_problem))
- return "Patient: " + this.id + " " + this.name + " is with average risk";
- if (this.symptoms && this.positive && !this.hyperglycaemia && !this.respiratory_problem)
- return "Patient: " + this.id + " " + this.name + " is with low risk";
- if (!this.symptoms && this.positive && !this.hyperglycaemia && !this.respiratory_problem)
- return "Patient: " + this.id + " " + this.name + " is with low risk (resistant to covid)";
- if (this.symptoms && this.hyperglycaemia && this.respiratory_problem && this.age > 75 || this.age > 50 && this.gender == "male")
- return "Patient: " + this.id + " " + this.name + " is with high risk";
- else return "Patient: " + this.id + " " + this.name + " is with average risk";
- }
- toString() {
- var s = "Patient " + this.id.toString() + " " + this.name.toString() + " is positive/negative";
- return s;
- }
- }
- class EHospital {
- constructor() {
- this.lista = [];
- }
- add_patient(pacient) {
- this.lista.push(pacient);
- }
- test_patient(pacient) {
- //console.log(pacient.date + " datumot ni treba odnosno denot 15 dena unazad ni trebat");
- var help = pacient.date+"";
- if(help.substring(4,7)=="Dec"){
- pacient.positive = false;
- }
- else pacient.positive=true;
- console.log(pacient.riskCalc());
- } // 23 dekemvri - 9 dekemvri = 14 dena
- // else if(23 - parseInt(pacient.date.substring(8,9) < 14))
- //pacient.positive = false;
- check() {
- for (var i = 0; i < this.lista.length; i++) {
- this.test_patient(this.lista[i]);
- }
- }
- safe_zone(opstina) {
- var negativnicounter = 0;
- var pozitivnicounter = 0;
- for (var i in this.lista) {
- if(this.lista[i].municipality == opstina) {
- if(this.lista[i].positive)
- pozitivnicounter++;
- else negativnicounter++;
- }
- }
- let res = (negativnicounter / (negativnicounter + pozitivnicounter)) * 100;
- console.log("You are in a " + res.toFixed(2) + "% zone.");
- }
- print() {
- for(var i=0;i<this.lista.length;i++){
- var att = this.lista[i];
- console.log("CovidPositive {");
- for(var j in att) {
- if(j == "name" || j == "municipality" || j == "gender") {
- console.log(j + ": " + "'" + att[j] + "',");
- continue;
- }
- if (j==="hyperglycaemia") {
- console.log(j + ": " + att[j] + " }");
- }
- else {
- console.log(j + ": " + att[j] + ",");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement