diff --git a/import/src/main/java/com/google/cloud/healthcare/imaging/dicomadapter/CFindService.java b/import/src/main/java/com/google/cloud/healthcare/imaging/dicomadapter/CFindService.java index 1fdf5bb9..262a990e 100644 --- a/import/src/main/java/com/google/cloud/healthcare/imaging/dicomadapter/CFindService.java +++ b/import/src/main/java/com/google/cloud/healthcare/imaging/dicomadapter/CFindService.java @@ -45,10 +45,12 @@ public class CFindService extends BasicCFindSCP { private static Logger log = LoggerFactory.getLogger(CFindService.class); private final IDicomWebClient dicomWebClient; + private final Flags cFINDFlags; - CFindService(IDicomWebClient dicomWebClient) { + CFindService(IDicomWebClient dicomWebClient, Flags flags) { super(UID.StudyRootQueryRetrieveInformationModelFIND); this.dicomWebClient = dicomWebClient; + this.cFINDFlags = flags; } private static HashMap uniqueResults(List responses) { @@ -115,6 +117,9 @@ public void run() { if (canceled) { throw new CancellationException(); } + if (cFINDFlags != null && cFINDFlags.fuzzyMatching) { + qidoPath += "fuzzymatching=true" + "&"; + } log.info("CFind QidoPath: " + qidoPath); MonitoringService.addEvent(Event.CFIND_QIDORS_REQUEST); JSONArray qidoResult = dicomWebClient.qidoRs(qidoPath); @@ -157,4 +162,4 @@ private void sendErrorResponse(int status, String message) { as.tryWriteDimseRSP(pc, cmdAttr); } } -} \ No newline at end of file +} diff --git a/import/src/main/java/com/google/cloud/healthcare/imaging/dicomadapter/Flags.java b/import/src/main/java/com/google/cloud/healthcare/imaging/dicomadapter/Flags.java index 818df926..825caa75 100644 --- a/import/src/main/java/com/google/cloud/healthcare/imaging/dicomadapter/Flags.java +++ b/import/src/main/java/com/google/cloud/healthcare/imaging/dicomadapter/Flags.java @@ -142,6 +142,12 @@ public class Flags { description = "Transfer Syntax to convert instances to during C-STORE upload. See Readme for list of supported syntaxes." ) String transcodeToSyntax = ""; + + @Parameter( + names = {"--fuzzy_matching"}, + description = "negotiate fuzzy semantic person name attribute matching. False by default." + ) + Boolean fuzzyMatching = false; public Flags() { } diff --git a/import/src/main/java/com/google/cloud/healthcare/imaging/dicomadapter/ImportAdapter.java b/import/src/main/java/com/google/cloud/healthcare/imaging/dicomadapter/ImportAdapter.java index 790b5e62..53bf9454 100644 --- a/import/src/main/java/com/google/cloud/healthcare/imaging/dicomadapter/ImportAdapter.java +++ b/import/src/main/java/com/google/cloud/healthcare/imaging/dicomadapter/ImportAdapter.java @@ -113,7 +113,7 @@ public static void main(String[] args) throws IOException, GeneralSecurityExcept // Handle C-FIND IDicomWebClient dicomWebClient = new DicomWebClient(requestFactory, dicomwebAddress, STUDIES); - CFindService cFindService = new CFindService(dicomWebClient); + CFindService cFindService = new CFindService(dicomWebClient, flags); serviceRegistry.addDicomService(cFindService); // Handle C-MOVE diff --git a/import/src/test/java/com/google/cloud/healthcare/imaging/dicomadapter/CFindServiceTest.java b/import/src/test/java/com/google/cloud/healthcare/imaging/dicomadapter/CFindServiceTest.java index 13250af7..52c79a5a 100644 --- a/import/src/test/java/com/google/cloud/healthcare/imaging/dicomadapter/CFindServiceTest.java +++ b/import/src/test/java/com/google/cloud/healthcare/imaging/dicomadapter/CFindServiceTest.java @@ -14,6 +14,8 @@ package com.google.cloud.healthcare.imaging.dicomadapter; +import static com.google.common.truth.Truth.assertThat; + import com.google.cloud.healthcare.IDicomWebClient; import com.google.cloud.healthcare.LogUtil; import com.google.cloud.healthcare.imaging.dicomadapter.util.DimseRSPAssert; @@ -47,6 +49,9 @@ public final class CFindServiceTest { final static String serverHostname = "localhost"; final static String clientAET = "CLIENT"; + + // Flags + Flags cFINDFlags = new Flags(); // Client properties. ApplicationEntity clientAE; @@ -117,6 +122,34 @@ public JSONArray qidoRs(String path) throws DicomWebException { } }, Status.NotAuthorized); } + + @Test + public void testCFindService_withFuzzyMatching() throws Exception { + cFINDFlags.fuzzyMatching = true; + basicCFindServiceTest(new TestUtils.DicomWebClientTestBase() { + @Override + public JSONArray qidoRs(String path) throws DicomWebException { + assertThat(path).contains("fuzzymatching=true"); + JSONArray instances = new JSONArray(); + instances.put(TestUtils.dummyQidorsInstance()); + return instances; + } + }, Status.Success); + } + + @Test + public void testCFindService_withoutFuzzyMatching() throws Exception { + cFINDFlags.fuzzyMatching = false; + basicCFindServiceTest(new TestUtils.DicomWebClientTestBase() { + @Override + public JSONArray qidoRs(String path) throws DicomWebException { + assertThat(path).doesNotContain("fuzzymatching"); + JSONArray instances = new JSONArray(); + instances.put(TestUtils.dummyQidorsInstance()); + return instances; + } + }, Status.Success); + } public void basicCFindServiceTest(IDicomWebClient serverDicomWebClient, int expectedStatus) throws Exception { @@ -166,8 +199,7 @@ private int createDicomServer(IDicomWebClient dicomWebClient) throws Exception { int serverPort = PortUtil.getFreePort(); DicomServiceRegistry serviceRegistry = new DicomServiceRegistry(); serviceRegistry.addDicomService(new BasicCEchoSCP()); - - CFindService cFindService = new CFindService(dicomWebClient); + CFindService cFindService = new CFindService(dicomWebClient, cFINDFlags); serviceRegistry.addDicomService(cFindService); Device serverDevice = DeviceUtil.createServerDevice(serverAET, serverPort, serviceRegistry); serverDevice.bindConnections();