diff --git a/dcm4chee-arc-hl7/src/main/java/org/dcm4chee/arc/hl7/PatientUpdateService.java b/dcm4chee-arc-hl7/src/main/java/org/dcm4chee/arc/hl7/PatientUpdateService.java index 104ee5f884..03558cfe73 100644 --- a/dcm4chee-arc-hl7/src/main/java/org/dcm4chee/arc/hl7/PatientUpdateService.java +++ b/dcm4chee-arc-hl7/src/main/java/org/dcm4chee/arc/hl7/PatientUpdateService.java @@ -64,6 +64,7 @@ import org.slf4j.LoggerFactory; import java.net.Socket; +import java.util.Collection; import java.util.Iterator; /** @@ -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()) @@ -343,4 +345,19 @@ private void updateProcedure(HL7Application hl7App, Socket s, UnparsedHL7Message procedureService.updateMWLStatus(ctx, SPSStatus.SCHEDULED); } } + + private static Attributes exportPatientIDsWithIssuer(Attributes attrs, Collection 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 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; + } }