diff --git a/core/src/main/java/uk/ac/ucl/rits/inform/datasinks/emapstar/controllers/LocationController.java b/core/src/main/java/uk/ac/ucl/rits/inform/datasinks/emapstar/controllers/LocationController.java
index 482bf5a46..742847ad0 100644
--- a/core/src/main/java/uk/ac/ucl/rits/inform/datasinks/emapstar/controllers/LocationController.java
+++ b/core/src/main/java/uk/ac/ucl/rits/inform/datasinks/emapstar/controllers/LocationController.java
@@ -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
*/
@@ -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");
@@ -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));
diff --git a/emap-checker.xml b/emap-checker.xml
index 1e27d302e..a526209c9 100644
--- a/emap-checker.xml
+++ b/emap-checker.xml
@@ -107,8 +107,10 @@
-
-
+
+
+
+
diff --git a/emap-interchange/src/main/java/uk/ac/ucl/rits/inform/interchange/location/DepartmentMetadata.java b/emap-interchange/src/main/java/uk/ac/ucl/rits/inform/interchange/location/DepartmentMetadata.java
index ad6fb9c72..7a06350ca 100644
--- a/emap-interchange/src/main/java/uk/ac/ucl/rits/inform/interchange/location/DepartmentMetadata.java
+++ b/emap-interchange/src/main/java/uk/ac/ucl/rits/inform/interchange/location/DepartmentMetadata.java
@@ -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.
*/
diff --git a/emap-interchange/src/test/resources/DepartmentMetadata/acun_dept.yaml b/emap-interchange/src/test/resources/DepartmentMetadata/acun_dept.yaml
index ff889578d..b0e854559 100644
--- a/emap-interchange/src/test/resources/DepartmentMetadata/acun_dept.yaml
+++ b/emap-interchange/src/test/resources/DepartmentMetadata/acun_dept.yaml
@@ -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"
\ No newline at end of file
+departmentType: "2"
+isWardOrFlowArea: true
+isCoreInpatientArea: true
+siteLocation: "EMH"
+combinedUpdate: "2022-02-09T00:00:20Z"
diff --git a/emap-interchange/src/test/resources/DepartmentMetadata/local-only/dental_department_only.yaml b/emap-interchange/src/test/resources/DepartmentMetadata/local-only/dental_department_only.yaml
index f74c366b6..35c7eb22a 100644
--- a/emap-interchange/src/test/resources/DepartmentMetadata/local-only/dental_department_only.yaml
+++ b/emap-interchange/src/test/resources/DepartmentMetadata/local-only/dental_department_only.yaml
@@ -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"
+
diff --git a/emap-interchange/src/test/resources/DepartmentMetadata/local-only/medsurg_active_pool_bed.yaml b/emap-interchange/src/test/resources/DepartmentMetadata/local-only/medsurg_active_pool_bed.yaml
index 41cf2670a..99c5cbbfb 100644
--- a/emap-interchange/src/test/resources/DepartmentMetadata/local-only/medsurg_active_pool_bed.yaml
+++ b/emap-interchange/src/test/resources/DepartmentMetadata/local-only/medsurg_active_pool_bed.yaml
@@ -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"
diff --git a/emap-interchange/src/test/resources/DepartmentMetadata/local-only/no_department_history.yaml b/emap-interchange/src/test/resources/DepartmentMetadata/local-only/no_department_history.yaml
index bbe538032..d7b8c0436 100644
--- a/emap-interchange/src/test/resources/DepartmentMetadata/local-only/no_department_history.yaml
+++ b/emap-interchange/src/test/resources/DepartmentMetadata/local-only/no_department_history.yaml
@@ -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"
diff --git a/emap-interchange/src/test/resources/DepartmentMetadata/local-only/paediatric_department_only_1.yaml b/emap-interchange/src/test/resources/DepartmentMetadata/local-only/paediatric_department_only_1.yaml
index b396e601f..a7f1faa24 100644
--- a/emap-interchange/src/test/resources/DepartmentMetadata/local-only/paediatric_department_only_1.yaml
+++ b/emap-interchange/src/test/resources/DepartmentMetadata/local-only/paediatric_department_only_1.yaml
@@ -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"
\ No newline at end of file
+departmentType: "12"
+isWardOrFlowArea: true
+isCoreInpatientArea: false
+siteLocation: "UCLH"
+combinedUpdate: "2021-08-26T11:28:51Z"
+
diff --git a/emap-interchange/src/test/resources/DepartmentMetadata/local-only/paediatric_department_only_2.yaml b/emap-interchange/src/test/resources/DepartmentMetadata/local-only/paediatric_department_only_2.yaml
index 7872eae2e..351787ec3 100644
--- a/emap-interchange/src/test/resources/DepartmentMetadata/local-only/paediatric_department_only_2.yaml
+++ b/emap-interchange/src/test/resources/DepartmentMetadata/local-only/paediatric_department_only_2.yaml
@@ -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"
\ No newline at end of file
+departmentType: "12"
+isWardOrFlowArea: true
+isCoreInpatientArea: false
+siteLocation: "UCLH"
+combinedUpdate: "2021-09-06T06:42:26Z"
diff --git a/emap-interchange/src/test/resources/DepartmentMetadata/local-only/paediatric_department_only_3.yaml b/emap-interchange/src/test/resources/DepartmentMetadata/local-only/paediatric_department_only_3.yaml
index 1834085f7..0cd332acf 100644
--- a/emap-interchange/src/test/resources/DepartmentMetadata/local-only/paediatric_department_only_3.yaml
+++ b/emap-interchange/src/test/resources/DepartmentMetadata/local-only/paediatric_department_only_3.yaml
@@ -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"
\ No newline at end of file
+departmentType: "12"
+isWardOrFlowArea: true
+isCoreInpatientArea: false
+siteLocation: "UCLH"
+combinedUpdate: "2021-10-08T23:00:20Z"
diff --git a/emap-star/emap-star/src/main/java/uk/ac/ucl/rits/inform/informdb/movement/DepartmentState.java b/emap-star/emap-star/src/main/java/uk/ac/ucl/rits/inform/informdb/movement/DepartmentState.java
index ebc08edd5..46092781e 100644
--- a/emap-star/emap-star/src/main/java/uk/ac/ucl/rits/inform/informdb/movement/DepartmentState.java
+++ b/emap-star/emap-star/src/main/java/uk/ac/ucl/rits/inform/informdb/movement/DepartmentState.java
@@ -54,6 +54,27 @@ public class DepartmentState extends AuditCore {
* \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
@@ -61,11 +82,21 @@ public class DepartmentState extends AuditCore {
* @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);
}
@@ -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