Skip to content

Commit

Permalink
Merge pull request #91 from satheesh09/master
Browse files Browse the repository at this point in the history
Added fuzzymatching to AttributesUtil.java
  • Loading branch information
danielbeaudreau authored Jul 9, 2020
2 parents e72628b + fb20575 commit be7ae71
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, JSONObject> uniqueResults(List<JSONArray> responses) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -157,4 +162,4 @@ private void sendErrorResponse(int status, String message) {
as.tryWriteDimseRSP(pc, cmdAttr);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit be7ae71

Please sign in to comment.