diff --git a/dcm4chee-arc-study/src/main/java/org/dcm4chee/arc/study/impl/StudyServiceEJB.java b/dcm4chee-arc-study/src/main/java/org/dcm4chee/arc/study/impl/StudyServiceEJB.java index 27f4c488d3..1528e22d9d 100644 --- a/dcm4chee-arc-study/src/main/java/org/dcm4chee/arc/study/impl/StudyServiceEJB.java +++ b/dcm4chee-arc-study/src/main/java/org/dcm4chee/arc/study/impl/StudyServiceEJB.java @@ -174,16 +174,25 @@ public void updateInstance(StudyMgtContext ctx) throws StudyMissingException, Pa if (attrs.diff(newAttrs, filter.getSelection(false), modified, true) == 0) return; + ctx.setEventActionCode(AuditMessages.EventActionCode.Update); + ctx.setStudy(instance.getSeries().getStudy()); + if (ctx.getPatient() == null) + ctx.setPatient(instance.getSeries().getStudy().getPatient()); + else if (instance.getSeries().getStudy().getPatient().getPk() != ctx.getPatient().getPk()) + throw new PatientMismatchException(ctx.getPatient() + + " found using patient identifiers sent in request payload does not match with " + + instance.getSeries().getStudy().getPatient() + " of " + instance); + Attributes.unifyCharacterSets(newAttrs, attrs); newAttrs.addSelected(attrs, null, Tag.OriginalAttributesSequence); attrs = newAttrs; instance.setAttributes(ctx.getReasonForModification() != null ? attrs.addOriginalAttributes( - ctx.getSourceOfPreviousValues(), - new Date(), - ctx.getReasonForModification(), - device.getDeviceName(), - modified) + ctx.getSourceOfPreviousValues(), + new Date(), + ctx.getReasonForModification(), + device.getDeviceName(), + modified) : attrs, filter, true, ctx.getFuzzyStr()); em.createNamedQuery(Series.SCHEDULE_METADATA_UPDATE_FOR_SERIES)