Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ spring.datasource.url=jdbc:postgresql://localhost:5432/arende
spring.datasource.username=arende
spring.datasource.password=arende

spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.ddl-auto=create-drop
spring.sql.init.mode=always
spring.jpa.defer-datasource-initialization=true
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect

Expand Down
34 changes: 34 additions & 0 deletions src/main/resources/data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
-- Seed Patients
INSERT INTO patients (id, first_name, last_name, personal_identity_number, created_at)
VALUES ('550e8400-e29b-41d4-a716-446655440000', 'John', 'Doe', '19850512-1234', CURRENT_TIMESTAMP)
ON CONFLICT (id) DO NOTHING;

INSERT INTO patients (id, first_name, last_name, personal_identity_number, created_at)
VALUES ('550e8400-e29b-41d4-a716-446655440001', 'Jane', 'Smith', '19920824-5678', CURRENT_TIMESTAMP)
ON CONFLICT (id) DO NOTHING;

INSERT INTO patients (id, first_name, last_name, personal_identity_number, created_at)
VALUES ('550e8400-e29b-41d4-a716-446655440002', 'Anders', 'Andersson', '19780315-9012', CURRENT_TIMESTAMP)
ON CONFLICT (id) DO NOTHING;

-- Seed Employees
INSERT INTO employees (id, display_name, role, created_at)
VALUES ('770e8400-e29b-41d4-a716-446655440000', 'Admin User', 'ADMIN', CURRENT_TIMESTAMP)
ON CONFLICT (id) DO NOTHING;

INSERT INTO employees (id, display_name, role, created_at)
VALUES ('770e8400-e29b-41d4-a716-446655440001', 'Dr. Alice Roberts', 'CASE_OWNER', CURRENT_TIMESTAMP)
ON CONFLICT (id) DO NOTHING;

INSERT INTO employees (id, display_name, role, created_at)
VALUES ('770e8400-e29b-41d4-a716-446655440002', 'Nurse Bob Jones', 'HANDLER', CURRENT_TIMESTAMP)
ON CONFLICT (id) DO NOTHING;

-- Seed Cases
INSERT INTO cases (id, title, description, status, patient_id, owner_id, handler_id, created_at)
VALUES ('990e8400-e29b-41d4-a716-446655440000', 'Acute Chest Pain', 'Patient arrived with severe chest pain and shortness of breath.', 'OPEN', '550e8400-e29b-41d4-a716-446655440000', '770e8400-e29b-41d4-a716-446655440001', '770e8400-e29b-41d4-a716-446655440002', CURRENT_TIMESTAMP)
ON CONFLICT (id) DO NOTHING;

INSERT INTO cases (id, title, description, status, patient_id, owner_id, handler_id, created_at)
VALUES ('990e8400-e29b-41d4-a716-446655440001', 'Follow-up: Fracture', 'Routine follow-up for a healed radial fracture.', 'OPEN', '550e8400-e29b-41d4-a716-446655440001', '770e8400-e29b-41d4-a716-446655440001', '770e8400-e29b-41d4-a716-446655440002', CURRENT_TIMESTAMP)
ON CONFLICT (id) DO NOTHING;
8 changes: 8 additions & 0 deletions src/main/resources/templates/cases/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ <h1>Create case</h1>
</div>

<form class="form" th:action="@{/ui/cases/new}" th:object="${createCaseForm}" method="post">
<label class="field">
<span class="label">Patient</span>
<select class="input" th:field="*{patientId}">
<option value="">-- Select Patient --</option>
<option th:each="p : ${patients}" th:value="${p.id}" th:text="${p.firstName + ' ' + p.lastName}"></option>
</select>
<span class="muted" th:if="${#fields.hasErrors('patientId')}" th:errors="*{patientId}" style="color: var(--danger)">Error</span>
</label>
<label class="field">
<span class="label">Title</span>
<input class="input" th:field="*{title}" maxlength="200"/>
Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ spring.jpa.database-platform=org.hibernate.dialect.H2Dialect

# Create schema on startup
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.defer-datasource-initialization=true
spring.sql.init.data-locations=classpath:data-test.sql

# Show SQL in logs for easier debugging during tests
spring.jpa.show-sql=true
Expand Down
26 changes: 26 additions & 0 deletions src/test/resources/data-test.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- Seed Patients
INSERT INTO patients (id, first_name, last_name, personal_identity_number, created_at)
VALUES ('550e8400-e29b-41d4-a716-446655440000', 'John', 'Doe', '19850512-1234', CURRENT_TIMESTAMP);

INSERT INTO patients (id, first_name, last_name, personal_identity_number, created_at)
VALUES ('550e8400-e29b-41d4-a716-446655440001', 'Jane', 'Smith', '19920824-5678', CURRENT_TIMESTAMP);

INSERT INTO patients (id, first_name, last_name, personal_identity_number, created_at)
VALUES ('550e8400-e29b-41d4-a716-446655440002', 'Anders', 'Andersson', '19780315-9012', CURRENT_TIMESTAMP);

-- Seed Employees
INSERT INTO employees (id, display_name, role, created_at)
VALUES ('770e8400-e29b-41d4-a716-446655440000', 'Admin User', 'ADMIN', CURRENT_TIMESTAMP);

INSERT INTO employees (id, display_name, role, created_at)
VALUES ('770e8400-e29b-41d4-a716-446655440001', 'Dr. Alice Roberts', 'CASE_OWNER', CURRENT_TIMESTAMP);

INSERT INTO employees (id, display_name, role, created_at)
VALUES ('770e8400-e29b-41d4-a716-446655440002', 'Nurse Bob Jones', 'HANDLER', CURRENT_TIMESTAMP);

-- Seed Cases
INSERT INTO cases (id, title, description, status, patient_id, owner_id, handler_id, created_at)
VALUES ('990e8400-e29b-41d4-a716-446655440000', 'Acute Chest Pain', 'Patient arrived with severe chest pain and shortness of breath.', 'OPEN', '550e8400-e29b-41d4-a716-446655440000', '770e8400-e29b-41d4-a716-446655440001', '770e8400-e29b-41d4-a716-446655440002', CURRENT_TIMESTAMP);

INSERT INTO cases (id, title, description, status, patient_id, owner_id, handler_id, created_at)
VALUES ('990e8400-e29b-41d4-a716-446655440001', 'Follow-up: Fracture', 'Routine follow-up for a healed radial fracture.', 'OPEN', '550e8400-e29b-41d4-a716-446655440001', '770e8400-e29b-41d4-a716-446655440001', '770e8400-e29b-41d4-a716-446655440002', CURRENT_TIMESTAMP);