This commit is contained in:
Sasank Vishnubhatla 2017-06-16 14:29:16 -04:00
commit b1c383abaf
7 changed files with 64 additions and 18 deletions

View file

@ -27,7 +27,7 @@ The purpose of KidClinic is to simulate the building of an enterprise applicatio
| Calendar Scheduling | Research | Long Term | Sasank |
# Login System
In order to create a login system, we need to create a subfolder for the login controller. This follows [DotorController.java](/src/main/java/org/springframework/samples/kidclinic/doctor/DoctorController.java) for the methods.
In order to create a login system, we need to create a subfolder for the login controller. This follows [DoctorController.java](/src/main/java/org/springframework/samples/kidclinic/doctor/DoctorController.java) for the methods.
# Reviews section for Doctors
Nicely enough, this also follows the login system.

View file

@ -64,6 +64,12 @@ public class Kid extends NamedEntity {
@JoinColumn(name = "parent_id")
private Parent parent;
@Column(name = "allergies")
private String allergies;
@Column(name = "medications")
private String medications;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "kidId", fetch = FetchType.EAGER)
private Set<Visit> visits = new LinkedHashSet<>();
@ -91,6 +97,22 @@ public class Kid extends NamedEntity {
this.parent = parent;
}
public String getAllergies(){
return this.allergies;
}
public void setAllergies(String allergies){
this.allergies = allergies;
}
public String getMedications(){
return this.medications;
}
public void setMedications(String medications){
this.medications = medications;
}
protected Set<Visit> getVisitsInternal() {
if (this.visits == null) {
this.visits = new HashSet<>();

View file

@ -36,12 +36,24 @@ public class KidValidator implements Validator {
public void validate(Object obj, Errors errors) {
Kid kid = (Kid) obj;
String name = kid.getName();
String medications = kid.getMedications();
String allergies = kid.getAllergies();
// name validation
if (!StringUtils.hasLength(name)) {
errors.rejectValue("name", REQUIRED, REQUIRED);
}
// gender validation
// allergies validation
if (!StringUtils.hasLength(allergies)) {
errors.rejectValue("allergies", REQUIRED, REQUIRED);
}
// medications validation
if (!StringUtils.hasLength(medications)) {
errors.rejectValue("medications", REQUIRED, REQUIRED);
}
if (kid.isNew() && kid.getGender() == null) {
errors.rejectValue("gender", REQUIRED, REQUIRED);
}

View file

@ -15,8 +15,8 @@ INSERT INTO doctor_specialties VALUES (3, 3);
INSERT INTO doctor_specialties VALUES (4, 2);
INSERT INTO doctor_specialties VALUES (5, 1);
INSERT INTO gender VALUES (1, 'male');
INSERT INTO gender VALUES (2, 'female');
INSERT INTO gender VALUES (1, 'Male');
INSERT INTO gender VALUES (2, 'Female');
INSERT INTO parents VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023');
@ -30,19 +30,19 @@ INSERT INTO parents VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison',
INSERT INTO parents VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435');
INSERT INTO parents VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487');
INSERT INTO kids VALUES (1, 'Alyssa', '2000-09-07', 2, 1);
INSERT INTO kids VALUES (2, 'Joe', '2002-08-06', 1, 2);
INSERT INTO kids VALUES (3, 'Lauren', '2001-04-17', 2, 3);
INSERT INTO kids VALUES (4, 'Nicole', '2000-03-07', 2, 3);
INSERT INTO kids VALUES (5, 'Thomas', '2000-11-30', 1, 4);
INSERT INTO kids VALUES (6, 'Samantha', '2000-01-20', 2, 5);
INSERT INTO kids VALUES (7, 'George', '1995-09-04', 1, 6);
INSERT INTO kids VALUES (8, 'Max', '1995-09-04', 1, 6);
INSERT INTO kids VALUES (9, 'Brendan', '1999-08-06', 1, 7);
INSERT INTO kids VALUES (10, 'Elizabeth', '1997-02-24', 2, 8);
INSERT INTO kids VALUES (11, 'Lucy', '2000-03-09', 2, 9);
INSERT INTO kids VALUES (12, 'Sunny', '2000-06-24', 2, 10);
INSERT INTO kids VALUES (13, 'Conner', '2002-06-08', 1, 10);
INSERT INTO kids VALUES (1, 'Alyssa', '2000-09-07', 2, 1, 'Claritin', 'None');
INSERT INTO kids VALUES (2, 'Joe', '2002-08-06', 1, 2, 'None', 'Lipitor');
INSERT INTO kids VALUES (3, 'Lauren', '2001-04-17', 2, 3, 'None', 'None');
INSERT INTO kids VALUES (4, 'Nicole', '2000-03-07', 2, 3, 'Penicilin', 'None');
INSERT INTO kids VALUES (5, 'Thomas', '2000-11-30', 1, 4, 'None', 'Plavix');
INSERT INTO kids VALUES (6, 'Samantha', '2000-01-20', 2, 5, 'Latex', 'Advair Diskus');
INSERT INTO kids VALUES (7, 'George', '1995-09-04', 1, 6, 'Insulin', 'None');
INSERT INTO kids VALUES (8, 'Max', '1995-09-04', 1, 6, 'None', 'Singulair');
INSERT INTO kids VALUES (9, 'Brendan', '1999-08-06', 1, 7, 'None', 'Actos');
INSERT INTO kids VALUES (10, 'Elizabeth', '1997-02-24', 2, 8, 'None', 'None');
INSERT INTO kids VALUES (11, 'Lucy', '2000-03-09', 2, 9, 'Iodine', 'None');
INSERT INTO kids VALUES (12, 'Sunny', '2000-06-24', 2, 10, 'None', 'None');
INSERT INTO kids VALUES (13, 'Conner', '2002-06-08', 1, 10, 'None', 'Epogen');
INSERT INTO visits VALUES (1, 7, '2013-01-01', 'rabies shot');
INSERT INTO visits VALUES (2, 8, '2013-01-02', 'rabies shot');

View file

@ -48,7 +48,9 @@ CREATE TABLE kids (
name VARCHAR(30),
birth_date DATE,
gender_id INTEGER NOT NULL,
parent_id INTEGER NOT NULL
parent_id INTEGER NOT NULL,
allergies VARCHAR(255),
medications VARCHAR(255)
);
ALTER TABLE kids ADD CONSTRAINT fk_kids_parents FOREIGN KEY (parent_id) REFERENCES parents (id);
ALTER TABLE kids ADD CONSTRAINT fk_kids_gender FOREIGN KEY (gender_id) REFERENCES gender (id);

View file

@ -22,6 +22,11 @@
th:replace="~{fragments/inputField :: input ('Birth Date', 'birthDate')}" />
<input
th:replace="~{fragments/selectField :: select ('Gender', 'gender', ${gender})}" />
<input
th:replace="~{fragments/inputField :: input ('Allergies', 'allergies')}" />
<input
th:replace="~{fragments/inputField :: input ('Medications', 'medications')}" />
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">

View file

@ -50,6 +50,11 @@
th:text="${#calendars.format(kid.birthDate, 'yyyy-MM-dd')}" /></dd>
<dt>Gender</dt>
<dd th:text="${kid.gender}" /></dd>
<dt>Allergies</dt>
<dd th:text="${kid.allergies}" /></dd>
<dt>Medications</dt>
<dd th:text="${kid.medications}" /></dd>
</dl>
</td>
<td valign="top">