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 @@ -138,7 +138,7 @@ public HospitalVisit updateOrCreateHospitalVisit(
Instant validFrom = msg.bestGuessAtValidFrom();
RowState<HospitalVisit, HospitalVisitAudit> visitState = getOrCreateHospitalVisit(
msg.getVisitNumber(), mrn, msg.getSourceSystem(), validFrom, storedFrom);

addAdmissionType(msg, visitState);
if (visitShouldBeUpdated(validFrom, msg.getSourceSystem(), visitState)) {
updateGenericData(msg, visitState);

Expand Down Expand Up @@ -219,6 +219,17 @@ private void addAdmissionDateTime(final AdmissionDateTime msg, RowState<Hospital
visitState.assignInterchangeValue(msg.getAdmissionDateTime(), visit.getAdmissionDatetime(), visit::setAdmissionDatetime);
}

/**
* Add admission type.
* @param msg AdmissionDateTime
* @param visitState visit wrapped in state class
*/
private void addAdmissionType(final AdtMessage msg, RowState<HospitalVisit, HospitalVisitAudit> visitState) {
HospitalVisit visit = visitState.getEntity();
visitState.assignInterchangeValue(msg.getAdmissionType(), visit.getAdmissionType(), visit::setAdmissionType);
}


/**
* Delete admission specific information.
* @param msg cancellation message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public void testCreateNewAdmit() throws Exception {

HospitalVisit visit = visits.get(0);
assertNotNull(visit.getAdmissionDatetime());
assertNotNull(visit.getAdmissionType());
assertNull(visit.getPresentationDatetime());
// no audit log should be added
assertTrue(getAllAuditHospitalVisits().isEmpty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
@ToString(callSuper = true)
public class AdmitPatient extends AdtMessage implements AdmissionDateTime {
private InterchangeValue<Instant> admissionDateTime = InterchangeValue.unknown();
private InterchangeValue<String> admissionType = InterchangeValue.unknown();


@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public abstract class AdtMessage extends EmapOperationMessage {
private String nhsNumber;
private String visitNumber;
private InterchangeValue<String> modeOfArrival = InterchangeValue.unknown();

private InterchangeValue<String> ethnicGroup = InterchangeValue.unknown();
private InterchangeValue<String> fullLocationString = InterchangeValue.unknown();
private InterchangeValue<String> previousLocationString = InterchangeValue.unknown();
Expand All @@ -44,6 +45,8 @@ public abstract class AdtMessage extends EmapOperationMessage {
private InterchangeValue<String> patientTitle = InterchangeValue.unknown();
private InterchangeValue<String> patientZipOrPostalCode = InterchangeValue.unknown();

private InterchangeValue<String> admissionType = InterchangeValue.unknown();


/**
* Ideally the time the event occurred, but uses the message date time as a backup.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ admissionDateTime:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
value: "2013-02-11T13:00:52Z"
admissionType:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
value: "Matern Ante"
fullLocationString:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ admissionDateTime:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
value: "2013-02-11T11:00:52Z"
admissionType:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
value: "Matern Ante"
fullLocationString:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ admissionDateTime:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
value: "2013-02-11T11:00:52Z"
admissionType:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
value: "Matern Ante"
fullLocationString:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ admissionDateTime:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
value: "2013-02-11T12:00:52Z"
admissionType:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
value: "Matern Ante"
fullLocationString:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ admissionDateTime:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
value: "2013-02-11T10:00:52Z"
admissionType:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
value: "Matern Ante"
fullLocationString:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ fullLocationString:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
value: "T42E^T42E BY02^BY02-17"
status: "SAVE"
admissionType:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
value: "Matern Ante"
status: "SAVE"
patientBirthDate:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ admissionDateTime:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
value: "2012-10-17T11:24:53Z"
admissionType:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
value: "Emerg Other"
fullLocationString:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ presentationDateTime:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
value: "2013-02-11T10:00:52Z"
admissionType:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
value: "Matern Ante"
fullLocationString:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ admissionDateTime:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
value: "2020-04-01T18:30:00Z"
admissionType:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
value: "Emergency"
modeOfArrival:
"@class": "uk.ac.ucl.rits.inform.interchange.InterchangeValue"
status: "SAVE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public class HospitalVisit extends TemporalCore<HospitalVisit, HospitalVisitAudi
@Column(columnDefinition = "timestamp with time zone")
private Instant admissionDatetime;

/**
* \brief the admission type for this hospitalVisit.
*/
private String admissionType;

/**
* \brief Date and time at which this hospitalVisit formally ended.
*
Expand Down Expand Up @@ -143,6 +148,7 @@ private HospitalVisit(HospitalVisit other) {
this.hospitalVisitId = other.hospitalVisitId;
this.encounter = other.encounter;
this.admissionDatetime = other.admissionDatetime;
this.admissionType = other.admissionType;
this.arrivalMethod = other.arrivalMethod;
this.dischargeDestination = other.dischargeDestination;
this.dischargeDisposition = other.dischargeDisposition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,21 @@ private AdtMessage buildAdtMessageSubclass(final PV1Wrap pv1Wrap, final Message
case "A01":
AdmitPatient admitPatient = new AdmitPatient();
admitPatient.setAdmissionDateTime(InterchangeValue.buildFromHl7(pv1Wrap.getAdmissionDateTime()));
admitPatient.setAdmissionType(InterchangeValue.buildFromHl7(pv1Wrap.getAdmissionType()));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we need to do this for all message types.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good question, if we only do it here then should remove from the generic ADT message.

msg = admitPatient;
break;
case "A02":
case "A06":
case "A07":
TransferPatient transferPatient = new TransferPatient();
transferPatient.setAdmissionDateTime(InterchangeValue.buildFromHl7(pv1Wrap.getAdmissionDateTime()));
transferPatient.setAdmissionType(InterchangeValue.buildFromHl7(pv1Wrap.getAdmissionType()));
msg = transferPatient;
break;
case "A03":
DischargePatient dischargeMsg = new DischargePatient();
dischargeMsg.setAdmissionDateTime(InterchangeValue.buildFromHl7(pv1Wrap.getAdmissionDateTime()));
dischargeMsg.setAdmissionType(InterchangeValue.buildFromHl7(pv1Wrap.getAdmissionType()));
dischargeMsg.setDischargeDateTime(pv1Wrap.getDischargeDateTime());
dischargeMsg.setDischargeDisposition(pv1Wrap.getDischargeDisposition());
dischargeMsg.setDischargeLocation(pv1Wrap.getDischargeLocation());
Expand All @@ -214,6 +217,7 @@ private AdtMessage buildAdtMessageSubclass(final PV1Wrap pv1Wrap, final Message
}
RegisterPatient registerPatient = new RegisterPatient();
registerPatient.setPresentationDateTime(InterchangeValue.buildFromHl7(pv1Wrap.getAdmissionDateTime()));
registerPatient.setAdmissionType(InterchangeValue.buildFromHl7(pv1Wrap.getAdmissionType()));
msg = registerPatient;
break;
case "A08":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ default String getFullLocationString() {
return createLocationString(currentLocation);
}

/**
* PV1-4: Admission type.
* @return the admission type string
*/
default String getAdmissionType() {
if (!pv1SegmentExists()) {
return null;
}
return getPV1().getAdmissionType().getValue();
}

/**
* PV1-6: Previous patient location concatenated together.
* @return the previous location string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,9 @@ public void testDeathIndicator() {
void testEthnicGroup() {
assertEquals(InterchangeValue.buildFromHl7("Not Yet Asked"), msg.getEthnicGroup());
}

@Test
void testAdmissionType() {
assertEquals(InterchangeValue.buildFromHl7("Elective"), msg.getAdmissionType());
}
}
2 changes: 1 addition & 1 deletion hl7-reader/src/test/resources/Adt/TestForJunit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ EVN|A01|201209211843|hello|ADM|U439966^WYYYY^CLLLL|201201011200\r
PID|||50032556^^^MRENTR^MEDREC~this is a test NHS number||INTERFACES^Amendadmission^Longforenamesecondfn^^LADY||194001010000|F|||42 Rooo Fooo^^Blorp^^ZZ1 0AB^^^^West Yorkshire|||||||||||Z1||||||||N
PD1|||HH|397982^LA^M^^^DR^^^^^^^^G9010000~B8^4 L H L^B^^^^^ZZ1 0AB^^01222 222222^^^^B8&1~404278^ME^AH^^^^^^^^^^^D2444444~V244444^DENTAL SURGERY^9 W^B^WEST YORKSHIRE^^^BD1 1AA^^^^^^V22222&3||14\r
NK1|1|NIECEOFTHEINTERFACETESTPATIENTDDDDD^Firstnameoftheneiceofthetestpatient|N|1 LINE OF VERY LONG ADDRESSWITHINFO&2 LINE OF VERY LONG ADDRESSWITHALLF^3 LINE OF VERYLONG ADDRESSWITH3DETA&4 LINE OF VERYLONGADDRESSWITH4DETAI^5 LINE FOR CITY OR TOWN ENTEREDINTO^^Z1 1AA^^^^6 LINE OF VERYLONGADDRESS FOR COUNT|02033333333|02033333333X888888|N\r
PV1||I|H2HH^H203^H203-11|1~I|||399999^IS^DAV^^^PROF|397982^LA^M^^^DR~399999^IS^DAV^J^^PROF||41008||||19|||||1234TESTVISITNUM|||PLS-1|||||||||||||||||HH||2|||201209211840\r
PV1||I|H2HH^H203^H203-11|Elective|||399999^IS^DAV^^^PROF|397982^LA^M^^^DR~399999^IS^DAV^J^^PROF||41008||||19|||||1234TESTVISITNUM|||PLS-1|||||||||||||||||HH||2|||201209211840\r
PV2||W|DETAILS FOR a08 AMEND aDMISSION MESSAGE||||||||||B\r
OBX|1|ST|^^^ABC^Assign Benefits^PLW-HL7||||||||N|||20120921\r
OBX|2|ST|^^^LRRF^Reg Required Flags^PLW-HL7||~~~~14~1||||||N\r
Expand Down
Loading