Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class DepartmentController {
}

/**
* Get or create minomal department entity.
* Get or create minimal department entity.
* @param msg minimal department message
* @return saved department entity
*/
Expand Down Expand Up @@ -257,7 +257,10 @@ private static boolean updateFieldIfNull(String currentData, String newdata, Con
void processDepartmentStates(DepartmentMetadata msg, Department department, Instant storedFrom) throws IncompatibleDatabaseStateException {
Instant validFrom = msg.getSpecialityUpdate() == null ? msg.getDepartmentContactDate() : msg.getSpecialityUpdate();
DepartmentState currentState = new DepartmentState(
department, msg.getDepartmentRecordStatus().toString(), msg.getDepartmentSpeciality(), validFrom, storedFrom);
department, msg.getDepartmentRecordStatus().toString(),
msg.getDepartmentSpeciality(), msg.getDepartmentType(),
msg.getIsWardOrFlowArea(), msg.getIsCoreInpatientArea(),
msg.getSiteLocation(), validFrom, storedFrom);

if (departmentStateRepo.existsByDepartmentIdAndSpecialityAndValidFrom(department, msg.getDepartmentSpeciality(), validFrom)) {
logger.debug("Department State already exists in the database, no need to process further");
Expand All @@ -274,9 +277,11 @@ void processDepartmentStates(DepartmentMetadata msg, Department department, Inst
invalidatePreviousStateIfChanged(msg.getPreviousDepartmentSpeciality(), currentState, possiblePreviousState.get());
} else if (msg.getPreviousDepartmentSpeciality() != null) {
// if the previous department speciality is not in the database
DepartmentState previousState = new DepartmentState(
department, msg.getDepartmentRecordStatus().toString(), msg.getPreviousDepartmentSpeciality(),
msg.getDepartmentContactDate(), storedFrom);
DepartmentState previousState = new DepartmentState(department,
msg.getDepartmentRecordStatus().toString(),
msg.getPreviousDepartmentSpeciality(), msg.getDepartmentType(),
msg.getIsWardOrFlowArea(), msg.getIsCoreInpatientArea(),
msg.getSiteLocation(), msg.getDepartmentContactDate(), storedFrom);
previousState.setStoredUntil(currentState.getStoredFrom());
previousState.setValidUntil(currentState.getValidFrom());
departmentStateRepo.saveAll(List.of(previousState, currentState));
Expand Down
6 changes: 4 additions & 2 deletions emap-checker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@
<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="MethodLength"/>
<module name="ParameterNumber"/>

<module name="ParameterNumber">
<property name="max" value="10"/>
<property name="tokens" value="METHOD_DEF"/>
</module>
<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="EmptyForIteratorPad"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ public class DepartmentMetadata extends EmapOperationMessage implements MinimalD
private String departmentSpeciality;
private Instant specialityUpdate;
private String previousDepartmentSpeciality;

/**
* Variables added to make location processing more robust.
*/
private String departmentType;
private Boolean isWardOrFlowArea;
private Boolean isCoreInpatientArea;
private String siteLocation;

/**
* Not used in processing, but useful to debugging ordering.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ departmentRecordStatus: "ACTIVE"
previousDepartmentSpeciality: "Dental - Oral Medicine"
departmentContactDate: "2012-02-09T00:00:00Z"
specialityUpdate: "2022-02-09T00:00:20Z"
combinedUpdate: "2022-02-09T00:00:20Z"
departmentType: "2"
isWardOrFlowArea: true
isCoreInpatientArea: true
siteLocation: "EMH"
combinedUpdate: "2022-02-09T00:00:20Z"
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ departmentRecordStatus: "ACTIVE"
departmentContactDate: "2018-08-22T00:00:00Z"
departmentSpeciality: "Dental - Oral Medicine"
specialityUpdate: "2020-09-22T13:47:56Z"
departmentType: "2"
isWardOrFlowArea: true
isCoreInpatientArea: true
siteLocation: "UCLH"
combinedUpdate: "2020-09-22T13:47:56Z"

Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ departmentId: "1"
departmentSpeciality: null
departmentRecordStatus: "DELETED_AND_HIDDEN"
departmentContactDate: "2005-12-08T00:00:00Z"
departmentType: "2"
isWardOrFlowArea: true
isCoreInpatientArea: true
siteLocation: "UCLH"
combinedUpdate: "2021-04-23T09:00:00Z"

Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ departmentId: "1020100002"
departmentSpeciality: null
departmentRecordStatus: "ACTIVE"
departmentContactDate: "2022-12-08T00:00:00Z"
departmentType: "12"
isWardOrFlowArea: true
isCoreInpatientArea: false
siteLocation: "UCLH"
combinedUpdate: "2022-12-08T00:00:00Z"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ departmentRecordStatus: "ACTIVE"
departmentContactDate: "2021-08-25T23:00:00Z"
# missing previous department will be null
specialityUpdate: "2021-08-26T11:28:51Z"
combinedUpdate: "2021-08-26T11:28:51Z"
departmentType: "12"
isWardOrFlowArea: true
isCoreInpatientArea: false
siteLocation: "UCLH"
combinedUpdate: "2021-08-26T11:28:51Z"

Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ previousDepartmentSpeciality: "Paediatric - Respiratory Medicine"
departmentRecordStatus: "ACTIVE"
departmentContactDate: "2021-08-25T23:00:00Z"
specialityUpdate: "2021-09-06T06:42:26Z"
combinedUpdate: "2021-09-06T06:42:26Z"
departmentType: "12"
isWardOrFlowArea: true
isCoreInpatientArea: false
siteLocation: "UCLH"
combinedUpdate: "2021-09-06T06:42:26Z"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ previousDepartmentSpeciality: "Paediatric - Infectious Diseases"
departmentRecordStatus: "ACTIVE"
departmentContactDate: "2021-08-25T23:00:00Z"
specialityUpdate: "2021-10-08T23:00:20Z"
combinedUpdate: "2021-10-08T23:00:20Z"
departmentType: "12"
isWardOrFlowArea: true
isCoreInpatientArea: false
siteLocation: "UCLH"
combinedUpdate: "2021-10-08T23:00:20Z"
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,49 @@ public class DepartmentState extends AuditCore<DepartmentState> {
* \brief Current speciality of the department.
*/
private String speciality;

/**
* \brief Report Group Nine (departmentType) value associated with this department.
*/
private String departmentType;

/**
* \brief Predicate determining whether the Department is a ward or flow area.
*/
private Boolean isWardOrFlowArea;

/**
* \brief Predicate determining whether the Department is a core inpatient area.
*/
private Boolean isCoreInpatientArea;

/**
* \brief hospital location where this department is situated.
*/
private String siteLocation;

/**
* Create valid department state.
* @param department parent department
* @param status status of department
* @param validFrom time that the message was valid from
* @param storedFrom time that emap core stared processing the message
* @param speciality name of the current speciality of this department
* @param departmentType Report Group Nine value associated with this department
* @param isWardOrFlowArea is this department a ward or flow area
* @param isCoreInpatientArea is this department a core inpatient area
* @param siteLocation hospital location where this department is situated.
*/
public DepartmentState(Department department, String status, String speciality, Instant validFrom, Instant storedFrom) {
public DepartmentState(Department department, String status,
String speciality, String departmentType, Boolean isWardOrFlowArea,
Boolean isCoreInpatientArea, String siteLocation, Instant validFrom, Instant storedFrom) {
departmentId = department;
this.status = status;
this.speciality = speciality;
this.departmentType = departmentType;
this.isWardOrFlowArea = isWardOrFlowArea;
this.isCoreInpatientArea = isCoreInpatientArea;
this.siteLocation = siteLocation;
setValidFrom(validFrom);
setStoredFrom(storedFrom);
}
Expand All @@ -78,6 +109,10 @@ private DepartmentState(DepartmentState other) {
departmentId = other.departmentId;
status = other.status;
speciality = other.speciality;
departmentType = other.departmentType;
isWardOrFlowArea = other.isWardOrFlowArea;
isCoreInpatientArea = other.isCoreInpatientArea;
siteLocation = other.siteLocation;
}

@Override
Expand Down
Loading