Skip to content

Commit

Permalink
Fix #4229 : HL7 Patient Update Service : Patient attributes contain O…
Browse files Browse the repository at this point in the history
…ther Patient IDs Sequence even after Trusted Issuer Patient ID check is applied
  • Loading branch information
vrindanayak committed Sep 20, 2023
1 parent b5b70a9 commit f3ffe48
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import org.slf4j.LoggerFactory;

import java.net.Socket;
import java.util.Collection;
import java.util.Iterator;

/**
Expand Down Expand Up @@ -141,6 +142,7 @@ static Patient updatePatient(HL7Application hl7App, Socket s, UnparsedHL7Message

ArchiveDeviceExtension arcdev = hl7App.getDevice().getDeviceExtensionNotNull(ArchiveDeviceExtension.class);
ctx.setPatientIDs(arcdev.withTrustedIssuerOfPatientID(ctx.getPatientIDs()));
ctx.setAttributes(exportPatientIDsWithIssuer(attrs, ctx.getPatientIDs()));
if (ctx.getPatientIDs().isEmpty()) {
throw new HL7Exception(
new ERRSegment(msg.msh())
Expand Down Expand Up @@ -343,4 +345,19 @@ private void updateProcedure(HL7Application hl7App, Socket s, UnparsedHL7Message
procedureService.updateMWLStatus(ctx, SPSStatus.SCHEDULED);
}
}

private static Attributes exportPatientIDsWithIssuer(Attributes attrs, Collection<IDWithIssuer> idWithIssuers) {
attrs.setNull(Tag.PatientID, VR.LO);
attrs.setNull(Tag.IssuerOfPatientID, VR.LO);
attrs.setNull(Tag.IssuerOfPatientIDQualifiersSequence, VR.SQ);
attrs.setNull(Tag.OtherPatientIDsSequence, VR.SQ);
Iterator<IDWithIssuer> iter = idWithIssuers.iterator();
attrs = iter.next().exportPatientIDWithIssuer(attrs);
Sequence otherPatientIDsSequence = attrs.ensureSequence(
Tag.OtherPatientIDsSequence,
idWithIssuers.size() - 1);
while (iter.hasNext())
otherPatientIDsSequence.add(iter.next().exportPatientIDWithIssuer(null));
return attrs;
}
}

0 comments on commit f3ffe48

Please sign in to comment.