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
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public void processMsg(HospitalVisit visit, PendingTransfer msg, Instant validFr
RowState<PlannedMovement, PlannedMovementAudit> plannedState = getOrCreate(
allFromRequest, visit, plannedLocation, msg.getPendingEventType().toString(), msg.getEventOccurredDateTime(), validFrom, storedFrom
);
addHospitalService(msg, plannedState);
PlannedMovement plannedMovement = plannedState.getEntity();
// If we receive a cancelled message before the original request then add it in
if (plannedMovement.getEventDatetime() == null) {
Expand Down Expand Up @@ -159,6 +160,16 @@ private void deletePlannedMovement(PlannedMovement plannedMovement, Instant dele
plannedMovementAuditRepo.save(plannedMovement.createAuditEntity(deletionTime, storedUntil));
plannedMovementRepo.delete(plannedMovement);
}

/**
* Add hospital service.
* @param msg PendingTransfer
* @param movementState movement wrapped in state class
*/
private void addHospitalService(final PendingTransfer msg, RowState<PlannedMovement, PlannedMovementAudit> movementState) {
PlannedMovement movement = movementState.getEntity();
movementState.assignInterchangeValue(msg.getHospitalService(), movement.getHospitalService(), movement::setHospitalService);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ void testPendingCreatesPlannedMovement() throws Exception {
assertEquals(EVENT_TIME, plannedMovement.getEventDatetime());
assertEquals(PendingType.TRANSFER.toString(), plannedMovement.getEventType());
assertNull(plannedMovement.getCancelledDatetime());
assertEquals("Head and Neck - OMFS", plannedMovement.getHospitalService());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
public class CancelPendingTransfer extends AdtMessage implements PendingEvent, AdtCancellation {
private PendingType pendingEventType = PendingType.TRANSFER;
private InterchangeValue<String> pendingDestination = InterchangeValue.unknown();
private InterchangeValue<String> hospitalService = InterchangeValue.unknown();
private Instant cancelledDateTime;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,16 @@ public interface PendingEvent {
* @param location Concatenated location string
*/
void setPendingDestination(InterchangeValue<String> location);


/**
* @return Hospital service from PV1-10.
*/
InterchangeValue<String> getHospitalService();

/**
* @param hospitalService
*/
void setHospitalService(InterchangeValue<String> hospitalService);

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
public class PendingTransfer extends AdtMessage implements PendingEvent {
private PendingType pendingEventType = PendingType.TRANSFER;
private InterchangeValue<String> pendingDestination = InterchangeValue.unknown();
private InterchangeValue<String> hospitalService = InterchangeValue.unknown();

@Override
public void processMessage(EmapOperationMessageProcessor processor) throws EmapOperationMessageProcessingException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,7 @@ modeOfArrival:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
value: "Walk-in"

hospitalService:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
value: "Head and Neck - OMFS"
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ public class PlannedMovement extends TemporalCore<PlannedMovement, PlannedMoveme
@Column(columnDefinition = "timestamp with time zone")
private Instant cancelledDatetime;

/**
* \brief The hospital service associated with this planned movement.
*
* Also known as the subspeciality.
*/
private String hospitalService;

/**
* Minimal constructor.
* @param hospitalVisitId associated hospital visit
Expand All @@ -109,6 +116,7 @@ private PlannedMovement(PlannedMovement other) {
eventDatetime = other.eventDatetime;
cancelled = other.cancelled;
cancelledDatetime = other.cancelledDatetime;
hospitalService = other.hospitalService;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ private AdtMessage buildAdtMessageSubclass(final PV1Wrap pv1Wrap, final Message
case "A15":
PendingTransfer pendingTransfer = new PendingTransfer();
setPendingDestination(pv1Wrap, pendingTransfer);
setHospitalService(pv1Wrap, pendingTransfer);
msg = pendingTransfer;
break;
case "A17":
Expand Down Expand Up @@ -448,4 +449,9 @@ private void setPendingDestination(PV1Wrap pv1Wrap, PendingEvent pendingEvent) {
String pendingLocation = pv1Wrap.getPendingLocation();
pendingEvent.setPendingDestination(InterchangeValue.buildFromHl7(pendingLocation));
}

private void setHospitalService(PV1Wrap pv1Wrap, PendingEvent pendingEvent) throws HL7Exception {
String hospitalService = pv1Wrap.getHospitalService();
pendingEvent.setHospitalService(InterchangeValue.buildFromHl7(hospitalService));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void testPendingTransferSpecificFields() throws Exception {

assertEquals(PendingType.TRANSFER, msg.getPendingEventType());
assertEquals(InterchangeValue.buildFromHl7("1020100166^SDEC BY02^11 SDEC"), msg.getPendingDestination());
assertEquals(InterchangeValue.buildFromHl7("Head and Neck - OMFS"), msg.getHospitalService());
}

/**
Expand All @@ -48,6 +49,18 @@ void testPendingLocationUnknown() throws Exception {
assertTrue(msg.getPendingDestination().isUnknown());
}

/**
* Given a pending transfer message with no hospital service (PV1-10)
* When processed into an interchange message
* The hospital service should be unknown
* @throws Exception
*/
@Test
void testNoHospitalService() throws Exception {
PendingEvent msg = (PendingEvent) processSingleAdtMessage("Adt/pending/A15_no_hospital_service.txt");
assertTrue(msg.getHospitalService().isUnknown());
}

/**
* Given a cancel pending transfer message
* When processed
Expand Down
2 changes: 1 addition & 1 deletion hl7-reader/src/test/resources/Adt/pending/A15.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ PID|1||40800000^^^MRENTR^MEDREC~9999999999^^^NHS^HN||AGBTESTD^Satesta^^^MRS||198
ZPD||Email~MYCH||ACTIVATED|||N||N|||||||||||||||F
PD1|||GP AT HAND^^E85124~~
NTE|1||EP34C Patient|PatComments
PV1|1|E|ED^COVID MAJORS 16^16-COVID MAJORS^U^R^^^^^^DEPID|Emergency|||1236^BEAR^BLACK^^^^^^PROVID^^^^PROVID|||A\T\E|||||||||123412341234|SELF|||||||||||||||||||||Adm*Conf|1020100166^SDEC BY02^11 SDEC^U^D^^^^^^DEPID||20220421195000||||||123412341234
PV1|1|E|ED^COVID MAJORS 16^16-COVID MAJORS^U^R^^^^^^DEPID|Emergency|||1236^BEAR^BLACK^^^^^^PROVID^^^^PROVID|||Head and Neck - OMFS|||||||||123412341234|SELF|||||||||||||||||||||Adm*Conf|1020100166^SDEC BY02^11 SDEC^U^D^^^^^^DEPID||20220421195000||||||123412341234
PV2|||||||||||||||||||||n|N||||||||||||||||Walk-in
OBX|1|TX|AdminCode^ADMINISTRATIVE CATEGORY CODE|1|1|||||||||20220422
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MSH|^~\&|EPIC|UCLH|||20220422002300|10018372|ADT^A15|39278859|P|2.4|||AL|NE
EVN|A15|20220422002300||PNDTRANSFER|10018372^GIANT^PANDA^^^^^^UCLHS^^^^^UCHC|20220422002258
PID|1||40800000^^^MRENTR^MEDREC~9999999999^^^NHS^HN||AGBTESTD^Satesta^^^MRS||19800601|F||N|^^London^^T5 1TT||0200 000 0000~07777 000 000||BG|N||123412341234||||||||||||N
ZPD||Email~MYCH||ACTIVATED|||N||N|||||||||||||||F
PD1|||GP AT HAND^^E85124~~
NTE|1||EP34C Patient|PatComments
PV1|1|E|ED^COVID MAJORS 16^16-COVID MAJORS^U^R^^^^^^DEPID|Emergency|||1236^BEAR^BLACK^^^^^^PROVID^^^^PROVID||||||||||||123412341234|SELF|||||||||||||||||||||Adm*Conf|1020100166^SDEC BY02^11 SDEC^U^D^^^^^^DEPID||20220421195000||||||123412341234
PV2|||||||||||||||||||||n|N||||||||||||||||Walk-in
OBX|1|TX|AdminCode^ADMINISTRATIVE CATEGORY CODE|1|1|||||||||20220422
Loading