Skip to content
Snippets Groups Projects
Commit 7e853498 authored by Andre Hartig's avatar Andre Hartig
Browse files

Added the remaining classes and a ObjectTimestamp to track object modifications.

parent f606ec0e
No related branches found
No related tags found
No related merge requests found
public record OPStaff(
Id<OPStaff> opStaffId,
Role role,
String specialty,
ObjectTimestamp lastUpdate
) {
}
public enum ObjectModification {
CREATE,
UPDATE,
DELETE
}
import java.time.LocalDateTime;
public record ObjectTimestamp(
LocalDateTime timestamp,
ObjectModification objectModification
) {
}
......@@ -13,7 +13,8 @@ public record Operation(
Id<Operation> id,
LocalDate date,
LocalTime startTime,
LocalTime endTime
LocalTime endTime,
ObjectTimestamp lastUpdate
) {
/**
......
import java.util.List;
public record OperationTeam(
Id<OperationTeam> operationTeamId,
List<OPStaff> opStaffList,
ObjectTimestamp lastUpdate
) {
}
......@@ -4,26 +4,12 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.LocalDate;
public record Patient (
@JsonProperty
Id<Patient> id,
@JsonProperty
Gender gender,
@JsonProperty
String givenName,
@JsonProperty
String familyName,
@JsonProperty
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
LocalDate birthDate,
@JsonProperty
Address address,
@JsonProperty
String healthInsurance
) {
}
import java.time.LocalDateTime;
public record PreparationNote(
Id<PreparationNote> preparationNoteId,
String text,
Operation operationId,
ObjectTimestamp lastUpdate
) {
}
public enum Role {
SURGEON,
ASSISTANT
}
public record Room(
Id<Room> roomId,
String roomName,
ObjectTimestamp lastUpdate
) {
}
......@@ -331,11 +331,18 @@ class JDBCRepository implements Repository
@Override
public List<Operation> findOperations(Operation.Filter filter) {
var sql = "SELECT * FROM operations WHERE date = " +
sqlValue(filter.date()).
replace("Optional", "").
replace("[", "").
replace("]", "") + ";";
var sql = "";
if(filter.equals(Operation.Filter.NONE)) {
sql = "SELECT * FROM operations;";
} else {
sql = "SELECT * FROM operations WHERE date = " +
sqlValue(filter.date()).
replace("Optional", "").
replace("[", "").
replace("]", "") + ";";
}
try (
var resultSet =
......
......@@ -97,23 +97,33 @@ public final class Tests
@Test
public void testCreateOperation() throws Exception {
Operation.Command createCommand = new Operation.Create(
LocalDate.of(2025, 05, 11),
LocalTime.of(10, 30, 00),
LocalTime.of(11, 00, 00));
Operation operation = opService.process(createCommand);
Operation createOperation = opService.process(createCommand);
System.out.println(createOperation);
System.out.println(operation);
assertTrue(
repo.findOperation(createOperation.id()).isPresent()
);
}
@Test
public void testGetOperations() {
Operation.Filter filter = new Operation.Filter(Optional.of(LocalDate.of(2024, 05, 24)));
LocalDate testDate = LocalDate.of(2024, 05, 24);
Operation.Filter filter = new Operation.Filter(Optional.of(testDate));
// Operation.Filter filter = Operation.Filter.NONE;
List<Operation> operations = opService.getOperations(filter);
for (Operation operation : operations)
for (Operation operation : operations) {
System.out.println(operation);
assertEquals(operation.date(), testDate);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment