Allergy and Medication Field Added

This commit is contained in:
Daniel.ryan@glowtouch.com 2017-06-16 09:11:09 -04:00
parent bcc66bd187
commit c8f4706582
6 changed files with 59 additions and 14 deletions

View file

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

View file

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

View file

@ -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 (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435');
INSERT INTO parents VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487'); 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 (1, 'Alyssa', '2000-09-07', 2, 1, 'Claritin', 'None');
INSERT INTO kids VALUES (2, 'Joe', '2002-08-06', 1, 2); INSERT INTO kids VALUES (2, 'Joe', '2002-08-06', 1, 2, 'None', 'Lipitor');
INSERT INTO kids VALUES (3, 'Lauren', '2001-04-17', 2, 3); INSERT INTO kids VALUES (3, 'Lauren', '2001-04-17', 2, 3, 'None', 'None');
INSERT INTO kids VALUES (4, 'Nicole', '2000-03-07', 2, 3); INSERT INTO kids VALUES (4, 'Nicole', '2000-03-07', 2, 3, 'Penicilin', 'None');
INSERT INTO kids VALUES (5, 'Thomas', '2000-11-30', 1, 4); INSERT INTO kids VALUES (5, 'Thomas', '2000-11-30', 1, 4, 'None', 'Plavix');
INSERT INTO kids VALUES (6, 'Samantha', '2000-01-20', 2, 5); 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); INSERT INTO kids VALUES (7, 'George', '1995-09-04', 1, 6, 'Insulin', 'None');
INSERT INTO kids VALUES (8, 'Max', '1995-09-04', 1, 6); INSERT INTO kids VALUES (8, 'Max', '1995-09-04', 1, 6, 'None', 'Singulair');
INSERT INTO kids VALUES (9, 'Brendan', '1999-08-06', 1, 7); INSERT INTO kids VALUES (9, 'Brendan', '1999-08-06', 1, 7, 'None', 'Actos');
INSERT INTO kids VALUES (10, 'Elizabeth', '1997-02-24', 2, 8); INSERT INTO kids VALUES (10, 'Elizabeth', '1997-02-24', 2, 8, 'None', 'None');
INSERT INTO kids VALUES (11, 'Lucy', '2000-03-09', 2, 9); INSERT INTO kids VALUES (11, 'Lucy', '2000-03-09', 2, 9, 'Iodine', 'None');
INSERT INTO kids VALUES (12, 'Sunny', '2000-06-24', 2, 10); INSERT INTO kids VALUES (12, 'Sunny', '2000-06-24', 2, 10, 'None', 'None');
INSERT INTO kids VALUES (13, 'Conner', '2002-06-08', 1, 10); 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 (1, 7, '2013-01-01', 'rabies shot');
INSERT INTO visits VALUES (2, 8, '2013-01-02', '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), name VARCHAR(30),
birth_date DATE, birth_date DATE,
gender_id INTEGER NOT NULL, 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_parents FOREIGN KEY (parent_id) REFERENCES parents (id);
ALTER TABLE kids ADD CONSTRAINT fk_kids_gender FOREIGN KEY (gender_id) REFERENCES gender (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')}" /> th:replace="~{fragments/inputField :: input ('Birth Date', 'birthDate')}" />
<input <input
th:replace="~{fragments/selectField :: select ('Gender', 'gender', ${gender})}" /> 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>
<div class="form-group"> <div class="form-group">
<div class="col-sm-offset-2 col-sm-10"> <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> th:text="${#calendars.format(kid.birthDate, 'yyyy-MM-dd')}" /></dd>
<dt>Gender</dt> <dt>Gender</dt>
<dd th:text="${kid.gender}" /></dd> <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> </dl>
</td> </td>
<td valign="top"> <td valign="top">