Skip to content

Commit

Permalink
edit
Browse files Browse the repository at this point in the history
  • Loading branch information
zxmeng committed Mar 30, 2018
1 parent 13029e2 commit 9f8b36a
Show file tree
Hide file tree
Showing 12 changed files with 212 additions and 431 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package hello;
package KW;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand Down
46 changes: 46 additions & 0 deletions initial/src/main/java/KW/LabTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package KW;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.Date;

@Entity
@Table(name = "LabTest")
public class LabTest {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="id")
private Long id;

@Column(name="pid")
private String pid;
@Column(name="labName")
private String labName;
@Column(name="labValue")
private Double labValue;
@Column(name="labUnit")
private String labUnit;
@Column(name="testDate")
private String testDate;

public Long getId() return this.id;
public void setId(Long id) this.id = id;

public String getPid() return this.pid;
public void setPid(String pid) this.pid = pid;

public String getLabName() return this.labName;
public void setLabName(String labName) this.labName = labName;

public Double getLabValue() return this.labValue;
public void setLabValue(Double labValue) this.labValue = labValue;

public String getLabUnit() return this.labUnit;
public void setLabUnit(String labUnit) this.labUnit = labUnit;

public String getTestDate() return this.testDate;
public void setTestDate(String testDate) this.testDate = testDate;

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package hello;
package KW;

import org.springframework.data.repository.CrudRepository;

import hello.LabTest;
import KW.LabTest;

// This will be AUTO IMPLEMENTED by Spring into a Bean called userRepository
// CRUD refers Create, Read, Update, Delete
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package hello;
package KW;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
Expand All @@ -9,24 +9,19 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.ui.Model;

import java.util.List;
import java.util.ArrayList;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.text.DateFormat;
import java.lang.Integer;
import java.util.*;
import java.text.*;
import java.lang.*;

import hello.Patient;
import hello.PatientRepository;
import hello.LabTest;
import hello.LabTestRepository;
import KW.Patient;
import KW.PatientRepository;
import KW.LabTest;
import KW.LabTestRepository;


@Controller // This means that this class is a Controller
// @RequestMapping(path="/demo") // This means URL's start with /demo (after Application path)
@Controller
public class MainController {
@Autowired // This means to get the bean called userRepository
// Which is auto-generated by Spring, we will use it to handle the data
@Autowired
private PatientRepository patientRepository;
@Autowired
private LabTestRepository labTestRepository;
Expand All @@ -35,7 +30,6 @@ public class MainController {
public String home(Model model) {
List<Patient> patients = new ArrayList<>();
patientRepository.findAll().forEach(patients::add);
// model.addAttribute("patients", patients);
model.addAttribute("total", patients.size());

int better = getBetterPatients();
Expand Down Expand Up @@ -220,19 +214,12 @@ public List<LabTest> getLabTestsByPidWithDate(Long id, Date sdate, Date edate) {
return labTests;
}

// @GetMapping("/patients/{id}")
// public Patient getPatientById(@PathVariable(value = "id") Long patientId) {
// return patientRepository.findById(patientId);
// }

@GetMapping(path="/add") // Map ONLY GET Requests
@GetMapping(path="/add")
public @ResponseBody String addNewPatient (@RequestParam String name
, @RequestParam String gender, @RequestParam Integer age
, @RequestParam Double egfr, @RequestParam Integer date
, @RequestParam Double rate, @RequestParam String category
, @RequestParam String smoking, @RequestParam String cancer) {
// @ResponseBody means the returned String is the response, not a view name
// @RequestParam means it is a parameter from the GET or POST request

Patient n = new Patient();
n.setName(name);
Expand All @@ -246,21 +233,20 @@ public List<LabTest> getLabTestsByPidWithDate(Long id, Date sdate, Date edate) {
} catch (Exception e) {

}

n.setCategory(category);
n.setTestDate(testDate);
n.setTestDate(new SimpleDateFormat("yyyy-MM-dd").format(testDate));
n.setRate(rate);
n.setSmoking(smoking);
n.setCancer(cancer);
patientRepository.save(n);
return "Saved";
}

@GetMapping(path="/lab") // Map ONLY GET Requests
@GetMapping(path="/lab")
public @ResponseBody String addNewLabTest (@RequestParam Long pid
, @RequestParam String labName, @RequestParam String labUnit
, @RequestParam Double labValue, @RequestParam Integer date) {
// @ResponseBody means the returned String is the response, not a view name
// @RequestParam means it is a parameter from the GET or POST request

LabTest n = new LabTest();
n.setPid(pid);
Expand Down
143 changes: 143 additions & 0 deletions initial/src/main/java/KW/Patient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
package KW;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.*;
import java.lang.*;

@Entity // This tells Hibernate to make a table out of this class
@Table(name = "Patient")
public class Patient {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="id")
private Long id;

@Column(name="pid")
private String pid;
@Column(name="firstName")
private String firstName;
@Column(name="lastName")
private String lastName;
@Column(name="gender")
private String gender; // M; F
@Column(name="dob")
private String dob;
@Column(name="category")
private String category; // MKCK, PD, HD, AHD
@Column(name="score")
private Integer score;

@Column(name="egfr")
private Double egfr;
@Column(name="testDate")
private String testDate;
@Column(name="changeRate")
private Double changeRate;

// Yes or No
@Column(name="cancer")
private String cancer;
@Column(name="cancerNotes")
private String cancerNotes;
@Column(name="smoking")
private String smoking;
@Column(name="smokingNotes")
private String smokingNotes;
@Column(name="htn")
private String htn;
@Column(name="htnNotes")
private String htnNotes;
@Column(name="diabetes")
private String diabetes;
@Column(name="diabetesNotes")
private String diabetesNotes;
@Column(name="depression")
private String depression;
@Column(name="depressionNotes")
private String depressionNotes;

// Yes or No
@Column(name="asprin")
private String asprin;
@Column(name="amitriptyline")
private String amitriptyline;
@Column(name="metformin")
private String metformin;
@Column(name="furosemide")
private String furosemide;


public Long getId() return this.id;
public void setId(Long id) this.id = id;

public String getPid() return this.pid;
public void setPid(String pid) this.pid = pid;
public String getFirstName() return this.firstName;
public void setFirstName(String firstName) this.firstName = firstName;
public String getLastName() return this.lastName;
public void setLastName(String lastName) this.lastName = lastName;
public String getGender() return this.gender;
public void setGender(String gender) this.gender = gender;
public String getDob() return this.dob;
public void setDob(String dob) this.dob = dob;
public String getCategory() return this.category;
public void setCategory(String category) this.category = category;

public Integer getScore() return this.score;
public void setScore() {
int score = 0;

if (this.changeRate < 0) score += 3;
if (this.cancer.equals("Yes")) score +=1;
if (this.smoking.equals("Yes")) score +=1;
if (this.htn.equals("Yes")) score +=1;
if (this.diabetes.equals("Yes")) score +=1;
if (this.depression.equals("Yes")) score +=1;

this.score = new Integer(score);
}

public Double getEgfr() return this.egfr;
public void setEgfr(Double egfr) this.egfr = egfr;
public String getTestDate() return this.testDate;
public void setTestDate(String testDate) this.testDate = testDate;
public Double getChangeRate() return this.changeRate;
public void setChangeRate(Double changeRate) this.changeRate = changeRate;

public String getCancer() return this.cancer;
public void setCancer(String cancer) this.cancer = cancer;
public String getSmoking() return this.smoking;
public void setSmoking(String smoking) this.smoking = smoking;
public String getHtn() return this.htn;
public void setHtn(String htn) this.htn = htn;
public String getDiabetes() return this.diabetes;
public void setDiabetes(String diabetes) this.diabetes = diabetes;
public String getDepression() return this.depression;
public void setDepression(String depression) this.depression = depression;

public String getCancerNotes() return this.cancerNotes;
public void setCancerNotes(String cancerNotes) this.cancerNotes = cancerNotes;
public String getSmokingNotes() return this.smokingNotes;
public void setSmokingNotes(String smokingNotes) this.smokingNotes = smokingNotes;
public String getHtnNotes() return this.htnNotes;
public void setHtnNotes(String htnNotes) this.htnNotes = htnNotes;
public String getDiabetesNotes() return this.diabetesNotes;
public void setDiabetesNotes(String diabetesNotes) this.diabetesNotes = diabetesNotes;
public String getDepressionNotes() return this.depressionNotes;
public void setDepressionNotes(String depressionNotes) this.depressionNotes = depressionNotes;

public String getAsprin() return this.asprin;
public void setAsprin(String asprin) this.asprin = asprin;
public String getAmitriptyline() return this.amitriptyline;
public void setAmitriptyline(String amitriptyline) this.amitriptyline = amitriptyline;
public String getMetformin() return this.metformin;
public void setMetformin(String metformin) this.metformin = metformin;
public String getFurosemide() return this.furosemide;
public void setFurosemide(String furosemide) this.furosemide = furosemide;

}


Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package hello;
package KW;

import org.springframework.data.repository.CrudRepository;

import hello.Patient;
import KW.Patient;

// This will be AUTO IMPLEMENTED by Spring into a Bean called userRepository
// CRUD refers Create, Read, Update, Delete
Expand Down
35 changes: 0 additions & 35 deletions initial/src/main/java/hello/GreetingController.java

This file was deleted.

Loading

0 comments on commit 9f8b36a

Please sign in to comment.