Skip to content

Commit

Permalink
#506 : Optionally validate Patient ID of received instances against t…
Browse files Browse the repository at this point in the history
…he Patient ID in previous received instances of the Study
  • Loading branch information
gunterze committed Jan 11, 2017
1 parent 4626bef commit 8883507
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Apache Directory Studio on January 10, 2017 3:08:35 PM
# Generated by Apache Directory Studio on January 11, 2017 11:31:54 AM

# SCHEMA "DCM4CHEE-ARCHIVE"
dn: cn=dcm4chee-archive, ou=schema
Expand Down Expand Up @@ -2020,6 +2020,21 @@ m-equality: booleanMatch
m-syntax: 1.3.6.1.4.1.1466.115.121.1.7
m-singleValue: TRUE

dn: m-oid=1.2.40.0.13.1.15.110.3.154, ou=attributetypes, cn=dcm4chee-archive, ou
=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 1.2.40.0.13.1.15.110.3.154
m-name: dcmAcceptConflictingPatientID
m-description: Indicates if objects with a Patient IDs which differs from the Pa
tient ID in previous received objects of the Study shall be accepted. Enumerate
d values: YES, NO, MERGED(= accept prior Patient IDs). If absent, MERGED will b
e applied.
m-equality: caseExactIA5Match
m-syntax: 1.3.6.1.4.1.1466.115.121.1.26
m-singleValue: TRUE

dn: ou=comparators, cn=dcm4chee-archive, ou=schema
objectclass: organizationalUnit
objectclass: top
Expand Down Expand Up @@ -2371,6 +2386,7 @@ m-may: dcmPurgeInstanceRecordsPollingInterval
m-may: dcmPurgeInstanceRecordsFetchSize
m-may: dcmOverwritePolicy
m-may: dcmAcceptMissingPatientID
m-may: dcmAcceptConflictingPatientID
m-may: dcmBulkDataSpoolDirectory
m-may: dcmQueryMatchUnknown
m-may: dcmHideSPSWithStatusFromMWL
Expand Down Expand Up @@ -2475,6 +2491,7 @@ m-may: dcmAccessControlID
m-may: dcmAcceptedMoveDestination
m-may: dcmOverwritePolicy
m-may: dcmAcceptMissingPatientID
m-may: dcmAcceptConflictingPatientID
m-may: dcmQueryRetrieveViewID
m-may: dcmBulkDataSpoolDirectory
m-may: dcmQueryMatchUnknown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,11 @@ attributeTypes: ( 1.2.40.0.13.1.15.110.3.153 NAME 'dcmExportPreviousEntity'
EQUALITY booleanMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
SINGLE-VALUE )
attributeTypes: ( 1.2.40.0.13.1.15.110.3.154 NAME 'dcmAcceptConflictingPatientID'
DESC 'Indicates if objects with a Patient IDs which differs from the Patient ID in previous received objects of the Study shall be accepted. Enumerated values: YES, NO, MERGED(= accept prior Patient IDs). If absent, MERGED will be applied.'
EQUALITY caseExactIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
SINGLE-VALUE )
objectClasses: ( 1.2.40.0.13.1.15.110.4.4 NAME 'dcmArchiveDevice'
DESC 'DICOM Archive Device related information'
SUP top AUXILIARY
Expand All @@ -784,6 +789,7 @@ objectClasses: ( 1.2.40.0.13.1.15.110.4.4 NAME 'dcmArchiveDevice'
dcmPurgeInstanceRecordsFetchSize $
dcmOverwritePolicy $
dcmAcceptMissingPatientID $
dcmAcceptConflictingPatientID $
dcmBulkDataSpoolDirectory $
dcmQueryMatchUnknown $
dcmHideSPSWithStatusFromMWL $
Expand Down Expand Up @@ -881,6 +887,7 @@ objectClasses: ( 1.2.40.0.13.1.15.110.4.5 NAME 'dcmArchiveNetworkAE'
dcmAcceptedMoveDestination $
dcmOverwritePolicy $
dcmAcceptMissingPatientID $
dcmAcceptConflictingPatientID $
dcmQueryRetrieveViewID $
dcmBulkDataSpoolDirectory $
dcmQueryMatchUnknown $
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ objectclass ( 1.2.40.0.13.1.15.110.4.4 NAME 'dcmArchiveDevice'
dcmPurgeInstanceRecordsFetchSize $
dcmOverwritePolicy $
dcmAcceptMissingPatientID $
dcmAcceptConflictingPatientID $
dcmBulkDataSpoolDirectory $
dcmQueryMatchUnknown $
dcmHideSPSWithStatusFromMWL $
Expand Down Expand Up @@ -1022,8 +1023,7 @@ objectclass ( 1.2.40.0.13.1.15.110.4.4 NAME 'dcmArchiveDevice'
hl7PSUTimeout $
hl7PSUOnTimeout $
hl7PSUTaskPollingInterval $
hl7PSUTaskFetchSize $
dcmAcceptConflictingPatientID ))
hl7PSUTaskFetchSize ))

objectclass ( 1.2.40.0.13.1.15.110.4.5 NAME 'dcmArchiveNetworkAE'
DESC 'DICOM Archive Network AE related information'
Expand All @@ -1040,6 +1040,7 @@ objectclass ( 1.2.40.0.13.1.15.110.4.5 NAME 'dcmArchiveNetworkAE'
dcmAcceptedMoveDestination $
dcmOverwritePolicy $
dcmAcceptMissingPatientID $
dcmAcceptConflictingPatientID $
dcmQueryRetrieveViewID $
dcmBulkDataSpoolDirectory $
dcmQueryMatchUnknown $
Expand Down Expand Up @@ -1077,8 +1078,7 @@ objectclass ( 1.2.40.0.13.1.15.110.4.5 NAME 'dcmArchiveNetworkAE'
hl7PSUTimeout $
hl7PSUOnTimeout $
hl7PSUReceivingApplication $
hl7PSUSendingApplication $
dcmAcceptConflictingPatientID ))
hl7PSUSendingApplication ))

objectclass ( 1.2.40.0.13.1.15.110.4.10 NAME 'dcmAttributeFilter'
DESC 'Attributes stored in the database'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,11 @@ olcAttributeTypes: ( 1.2.40.0.13.1.15.110.3.153 NAME 'dcmExportPreviousEntity'
EQUALITY booleanMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
SINGLE-VALUE )
olcAttributeTypes: ( 1.2.40.0.13.1.15.110.3.154 NAME 'dcmAcceptConflictingPatientID'
DESC 'Indicates if objects with a Patient IDs which differs from the Patient ID in previous received objects of the Study shall be accepted. Enumerated values: YES, NO, MERGED(= accept prior Patient IDs). If absent, MERGED will be applied.'
EQUALITY caseExactIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
SINGLE-VALUE )
olcObjectClasses: ( 1.2.40.0.13.1.15.110.4.4 NAME 'dcmArchiveDevice'
DESC 'DICOM Archive Device related information'
SUP top AUXILIARY
Expand All @@ -783,6 +788,7 @@ olcObjectClasses: ( 1.2.40.0.13.1.15.110.4.4 NAME 'dcmArchiveDevice'
dcmPurgeInstanceRecordsFetchSize $
dcmOverwritePolicy $
dcmAcceptMissingPatientID $
dcmAcceptConflictingPatientID $
dcmBulkDataSpoolDirectory $
dcmQueryMatchUnknown $
dcmHideSPSWithStatusFromMWL $
Expand Down Expand Up @@ -880,6 +886,7 @@ olcObjectClasses: ( 1.2.40.0.13.1.15.110.4.5 NAME 'dcmArchiveNetworkAE'
dcmAcceptedMoveDestination $
dcmOverwritePolicy $
dcmAcceptMissingPatientID $
dcmAcceptConflictingPatientID $
dcmQueryRetrieveViewID $
dcmBulkDataSpoolDirectory $
dcmQueryMatchUnknown $
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public MPPS createMPPS(MPPSContext ctx) throws DicomServiceException {
Attributes attrs = ctx.getAttributes();
MPPS mpps = new MPPS();
mpps.setSopInstanceUID(ctx.getSopInstanceUID());
PatientMgtContext patMgtCtx = patientService.createPatientMgtContextWEB(ctx.getAssociation());
PatientMgtContext patMgtCtx = patientService.createPatientMgtContextDIMSE(ctx.getAssociation());
patMgtCtx.setAttributes(attrs);
Patient pat = patientService.findPatient(patMgtCtx);
if (pat == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
*/
public interface PatientService {

PatientMgtContext createPatientMgtContextWEB(Association as);
PatientMgtContext createPatientMgtContextDIMSE(Association as);

PatientMgtContext createPatientMgtContextWEB(HttpServletRequest httpRequest, ApplicationEntity ae);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class PatientServiceImpl implements PatientService {
private Event<PatientMgtContext> patientMgtEvent;

@Override
public PatientMgtContext createPatientMgtContextWEB(Association as) {
public PatientMgtContext createPatientMgtContextDIMSE(Association as) {
return new PatientMgtContextImpl(device, null, as, as.getApplicationEntity(), as.getSocket(), null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,8 @@ private Instance createInstance(StoreContext ctx, CodeEntity conceptNameCode, Up
StoreSession session = ctx.getStoreSession();
HttpServletRequest httpRequest = session.getHttpRequest();
Association as = session.getAssociation();
PatientMgtContext patMgtCtx = as != null ? patientService.createPatientMgtContextWEB(as)
PatientMgtContext patMgtCtx = as != null
? patientService.createPatientMgtContextDIMSE(as)
: httpRequest != null
? patientService.createPatientMgtContextWEB(httpRequest, session.getLocalApplicationEntity())
: patientService.createPatientMgtContextHL7(session.getSocket(), session.getHL7MessageHeader());
Expand All @@ -510,17 +511,17 @@ private Instance createInstance(StoreContext ctx, CodeEntity conceptNameCode, Up
study.setExpirationDate(ctx.getExpirationDate());
result.setCreatedStudy(study);
} else {
acceptConflictingPID(patMgtCtx, ctx, study.getPatient());
checkStorePermission(ctx, study.getPatient());
study = updateStudy(ctx, study);
acceptConflictingPID(patMgtCtx, ctx, study.getPatient());
updatePatient(ctx, study.getPatient());
}
series = createSeries(ctx, study, result);
} else {
acceptConflictingPID(patMgtCtx, ctx, series.getStudy().getPatient());
checkStorePermission(ctx, series.getStudy().getPatient());
series = updateSeries(ctx, series);
updateStudy(ctx, series.getStudy());
acceptConflictingPID(patMgtCtx, ctx, series.getStudy().getPatient());
updatePatient(ctx, series.getStudy().getPatient());
}
Instance instance = createInstance(ctx, series, conceptNameCode);
Expand Down Expand Up @@ -548,22 +549,20 @@ private void acceptConflictingPID(PatientMgtContext patMgtCtx, StoreContext ctx,
StoreSession session = ctx.getStoreSession();
ArchiveAEExtension arcAE = session.getArchiveAEExtension();
AcceptConflictingPatientID acceptConflictingPID = arcAE.acceptConflictingPatientID();
switch (acceptConflictingPID) {
case YES:
break;
case NO:
if (!ctx.getAttributes().getString(Tag.PatientID).equals(associatedPat.getPatientID().getID()))
throw new DicomServiceException(StoreService.CONFLICTING_PID_NOT_ACCEPTED,
StoreService.CONFLICTING_PID_NOT_ACCEPTED_MSG);
break;
case MERGED:
Patient p = patientService.findPatient(patMgtCtx);
if (p == null || (p.getPk() != associatedPat.getPk()))
throw new DicomServiceException(StoreService.CONFLICTING_PID_NOT_ACCEPTED,
StoreService.CONFLICTING_PID_NOT_ACCEPTED_MSG);
break;
if (acceptConflictingPID == AcceptConflictingPatientID.YES)
return;

IDWithIssuer idWithIssuer = IDWithIssuer.pidOf(associatedPat.getAttributes());
if (idWithIssuer.matches(patMgtCtx.getPatientID()))
return;

if (acceptConflictingPID == AcceptConflictingPatientID.MERGED) {
Patient p = patientService.findPatient(patMgtCtx);
if (p != null && p.getPk() == associatedPat.getPk())
return;
}
return;
throw new DicomServiceException(StoreService.CONFLICTING_PID_NOT_ACCEPTED,
StoreService.CONFLICTING_PID_NOT_ACCEPTED_MSG);
}

private Patient updatePatient(StoreContext ctx, Patient pat) {
Expand Down
20 changes: 10 additions & 10 deletions dcm4chee-arc-ui/src/main/webapp/schema/archiveNetworkAE.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@
"CREATE"
]
},
"dcmAcceptConflictingPatientID": {
"title": "Accept Conflicting Patient ID",
"description": "Indicates if objects with a Patient IDs which differs from the Patient ID in previous received objects of the Study shall be accepted. Enumerated values: YES, NO, MERGED(= accept prior Patient IDs). If absent, MERGED will be applied.",
"type": "string",
"enum": [
"YES",
"NO",
"MERGED"
]
},
"dcmQueryRetrieveViewID": {
"title": "Query/Retrieve View ID",
"description": "Query/Retrieve View Identifier",
Expand Down Expand Up @@ -294,16 +304,6 @@
"description": "Specifies if the HL7 Procedure Status Update is sent if the timeout for waiting on receive of instances referenced is exceeded; just stop check for completeness on timeout if absent.",
"type": "boolean"
},
"dcmAcceptConflictingPatientID": {
"title": "Accept Conflicting Patient ID",
"description": "Indicates if objects with a Patient IDs which differs from the Patient ID in previous received objects of the Study shall be accepted. Enumerated values: YES, NO, MERGED(= accept prior Patient IDs). If absent, MERGED will be applied.",
"type": "string",
"enum": [
"YES",
"NO",
"MERGED"
]
},
"dcmExportRule": {
"title": "Export Rule",
"description": "Export Rule",
Expand Down

0 comments on commit 8883507

Please sign in to comment.