Skip to content

Commit

Permalink
Allow configurable validations for missing fields in HL7 messages' MS…
Browse files Browse the repository at this point in the history
…H segment required by IHE #4038
  • Loading branch information
vrindanayak committed Apr 26, 2023
1 parent f51bd22 commit 5846ded
Showing 1 changed file with 0 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public UnparsedHL7Message onMessage(HL7Application hl7App, Connection conn, Sock
static Patient updatePatient(HL7Application hl7App, Socket s, UnparsedHL7Message msg, PatientService patientService,
ArchiveHL7Message archiveHL7Message)
throws HL7Exception {
validateMSHIHERq(msg);
ArchiveHL7ApplicationExtension arcHL7App =
hl7App.getHL7ApplicationExtension(ArchiveHL7ApplicationExtension.class);

Expand Down Expand Up @@ -156,47 +155,6 @@ static Patient updatePatient(HL7Application hl7App, Socket s, UnparsedHL7Message
return changePIDOrMergePatient(patientService, ctx, archiveHL7Message, msg, arcHL7App);
}

private static void validateMSHIHERq(UnparsedHL7Message msg) throws HL7Exception {
HL7Segment msh = msg.msh();
if (msh.getField(2, null) == null)
throw new HL7Exception(
new ERRSegment(msh)
.setHL7ErrorCode(ERRSegment.REQUIRED_FIELD_MISSING)
.setErrorLocation(ERRSegment.SENDING_APPLICATION)
.setUserMessage("Missing Sending Application"));
if (msh.getField(3, null) == null)
throw new HL7Exception(
new ERRSegment(msh)
.setHL7ErrorCode(ERRSegment.REQUIRED_FIELD_MISSING)
.setErrorLocation(ERRSegment.SENDING_FACILITY)
.setUserMessage("Missing Sending Facility"));
if (msh.getField(4, null) == null)
throw new HL7Exception(
new ERRSegment(msh)
.setHL7ErrorCode(ERRSegment.REQUIRED_FIELD_MISSING)
.setErrorLocation(ERRSegment.RECEIVING_APPLICATION)
.setUserMessage("Missing Receiving Application"));
if (msh.getField(5, null) == null)
throw new HL7Exception(
new ERRSegment(msh)
.setHL7ErrorCode(ERRSegment.REQUIRED_FIELD_MISSING)
.setErrorLocation(ERRSegment.RECEIVING_FACILITY)
.setUserMessage("Missing Receiving Facility"));
if (msh.getField(6, null) == null)
throw new HL7Exception(
new ERRSegment(msh)
.setHL7ErrorCode(ERRSegment.REQUIRED_FIELD_MISSING)
.setErrorLocation(ERRSegment.MESSAGE_DATETIME)
.setUserMessage("Missing Date/Time of Message"));

if (msh.getMessageControlID() == null)
throw new HL7Exception(
new ERRSegment(msh)
.setHL7ErrorCode(ERRSegment.REQUIRED_FIELD_MISSING)
.setErrorLocation(ERRSegment.MESSAGE_CONTROL_ID)
.setUserMessage("Missing Message Control ID"));
}

private static Patient createOrUpdatePatient(
PatientService patientService, PatientMgtContext ctx, ArchiveHL7Message archiveHL7Message,
UnparsedHL7Message msg, ArchiveHL7ApplicationExtension arcHL7App) throws HL7Exception {
Expand Down

0 comments on commit 5846ded

Please sign in to comment.