Skip to content

Commit 02c4923

Browse files
committed
Updated MPH API to reflect changes in SEER*API.
Still need more unit tests for histology match mode.
1 parent 8843b62 commit 02c4923

6 files changed

Lines changed: 196 additions & 36 deletions

File tree

src/main/java/com/imsweb/seerapi/client/mph/MphInput.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44

55
public class MphInput {
66

7+
/**
8+
* How to consider histology match, if it is strict 8000 is considered a different histology than 8010-9999
9+
* for rule : Do the tumors have ICD-O-3 histology codes that are different at the first (Xxxx), second (Xxxx), or third (xxXx) number?
10+
* If lenient mode is on 8000 is considered as NOS and be considered to match any 8nnn histologies.
11+
*/
12+
public enum MpHistologyMatchMode {
13+
STRICT,
14+
LENIENT
15+
}
16+
717
@JsonProperty("primary_site")
818
private String _primarySite;
919
@JsonProperty("histology_icd_o3")
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package com.imsweb.seerapi.client.mph;
2+
3+
import java.util.List;
4+
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
7+
public class MphOutput {
8+
9+
// The possible results of determining if two tumors are single or multiple primaries.
10+
public enum Result {
11+
// indicates the two tumors are the same primary
12+
SINGLE_PRIMARY,
13+
// indicates the two tumors are different primaries
14+
MULTIPLE_PRIMARIES,
15+
// indicates there is not enough information to make a proper determination
16+
QUESTIONABLE
17+
}
18+
19+
@JsonProperty("result")
20+
private Result _result;
21+
@JsonProperty("reason")
22+
private String _reason;
23+
@JsonProperty("applied_rules")
24+
private List<MphRule> _appliedRules;
25+
@JsonProperty("group_id")
26+
private String _groupId;
27+
@JsonProperty("step")
28+
private String _step;
29+
30+
public MphOutput() {
31+
}
32+
33+
public Result getResult() {
34+
return _result;
35+
}
36+
37+
public void setResult(Result result) {
38+
_result = result;
39+
}
40+
41+
public String getReason() {
42+
return _reason;
43+
}
44+
45+
public void setReason(String reason) {
46+
_reason = reason;
47+
}
48+
49+
public List<MphRule> getAppliedRules() {
50+
return _appliedRules;
51+
}
52+
53+
public void setAppliedRules(List<MphRule> appliedRules) {
54+
_appliedRules = appliedRules;
55+
}
56+
57+
public String getGroupId() {
58+
return _groupId;
59+
}
60+
61+
public void setGroupId(String groupId) {
62+
_groupId = groupId;
63+
}
64+
65+
public String getStep() {
66+
return _step;
67+
}
68+
69+
public void setStep(String step) {
70+
_step = step;
71+
}
72+
}

src/main/java/com/imsweb/seerapi/client/mph/MphResult.java

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright (C) 2013 Information Management Services, Inc.
3+
*/
4+
package com.imsweb.seerapi.client.mph;
5+
6+
import java.util.List;
7+
8+
import com.fasterxml.jackson.annotation.JsonProperty;
9+
10+
public class MphRule {
11+
12+
@JsonProperty("group_id")
13+
private String _groupId;
14+
@JsonProperty("step")
15+
private String _step;
16+
@JsonProperty("question")
17+
private String _question;
18+
@JsonProperty("reason")
19+
private String _reason;
20+
@JsonProperty("notes")
21+
private List<String> _notes;
22+
@JsonProperty("examples")
23+
private List<String> _examples;
24+
25+
public MphRule() {
26+
}
27+
28+
public String getGroupId() {
29+
return _groupId;
30+
}
31+
32+
public void setGroupId(String groupId) {
33+
_groupId = groupId;
34+
}
35+
36+
public String getStep() {
37+
return _step;
38+
}
39+
40+
public void setStep(String step) {
41+
_step = step;
42+
}
43+
44+
public String getQuestion() {
45+
return _question;
46+
}
47+
48+
public void setQuestion(String question) {
49+
_question = question;
50+
}
51+
52+
public String getReason() {
53+
return _reason;
54+
}
55+
56+
public void setReason(String reason) {
57+
_reason = reason;
58+
}
59+
60+
public List<String> getNotes() {
61+
return _notes;
62+
}
63+
64+
public void setNotes(List<String> notes) {
65+
_notes = notes;
66+
}
67+
68+
public List<String> getExamples() {
69+
return _examples;
70+
}
71+
72+
public void setExamples(List<String> examples) {
73+
_examples = examples;
74+
}
75+
}

src/main/java/com/imsweb/seerapi/client/mph/MphService.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,27 @@
66
import retrofit2.Call;
77
import retrofit2.http.Body;
88
import retrofit2.http.POST;
9+
import retrofit2.http.Query;
10+
11+
import com.imsweb.seerapi.client.mph.MphInput.MpHistologyMatchMode;
912

1013
public interface MphService {
1114

15+
/**
16+
* Uses multiple primary rules to compare two diseases using strict histology matching mode
17+
* @param pair a pair of diseases
18+
* @return a result indicating whether the two diseases are the same primary
19+
*/
20+
@POST("mph")
21+
Call<MphOutput> mph(@Body MphInputPair pair);
22+
1223
/**
1324
* Uses multiple primary rules to compare two diseases
1425
* @param pair a pair of diseases
26+
* @param matchMode
1527
* @return a result indicating whether the two diseases are the same primary
1628
*/
1729
@POST("mph")
18-
Call<MphResult> mph(@Body MphInputPair pair);
30+
Call<MphOutput> mph(@Body MphInputPair pair, @Query("histology-matching-mode") MpHistologyMatchMode matchMode);
1931

2032
}

src/test/java/com/imsweb/seerapi/client/mph/MphTest.java

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.imsweb.seerapi.client.SeerApi;
1010

1111
import static org.junit.Assert.assertEquals;
12+
import static org.junit.Assert.assertTrue;
1213

1314
public class MphTest {
1415

@@ -24,7 +25,7 @@ public void testMissingAllInput() throws IOException {
2425
_MPH.mph(new MphInputPair()).execute();
2526
}
2627

27-
@Test(expected = BadRequestException.class)
28+
@Test
2829
public void testMissingSite() throws IOException {
2930
MphInput input1 = new MphInput();
3031
// site is missing
@@ -40,7 +41,11 @@ public void testMissingSite() throws IOException {
4041
input2.setDateOfDiagnosisYear("2016");
4142
input2.setLaterality("1");
4243

43-
_MPH.mph(new MphInputPair(input1, input2)).execute();
44+
MphOutput result = _MPH.mph(new MphInputPair(input1, input2)).execute().body();
45+
assertEquals(MphOutput.Result.QUESTIONABLE, result.getResult());
46+
assertEquals(
47+
"Unable to identify cancer group for first set of parameters. Valid primary site (C000-C999 excluding C809), histology (8000-9999), behavior (0-3, 6) and diagnosis year are required.",
48+
result.getReason());
4449
}
4550

4651
@Test
@@ -60,13 +65,23 @@ public void testResults() throws IOException {
6065
input2.setLaterality("1");
6166

6267
// first test single primary (only differs by site code)
63-
MphResult result = _MPH.mph(new MphInputPair(input1, input2)).execute().body();
64-
assertEquals(MphResult.Result.SINGLE_PRIMARY, result.getResult());
68+
MphOutput result = _MPH.mph(new MphInputPair(input1, input2)).execute().body();
69+
assertEquals(MphOutput.Result.SINGLE_PRIMARY, result.getResult());
70+
assertEquals("mp_2007_breast", result.getGroupId());
71+
assertEquals("M13", result.getStep());
72+
assertEquals("Tumors that do not meet any of the criteria are abstracted as a single primary.", result.getReason());
73+
assertEquals(10, result.getAppliedRules().size());
74+
assertTrue(result.getAppliedRules().get(0).getQuestion().startsWith("Are there tumors in sites with ICD-O-3 topography codes"));
6575

6676
// next test questionable (setting laterality to unknown for one of the diseases)
6777
input2.setLaterality("9");
6878
result = _MPH.mph(new MphInputPair(input1, input2)).execute().body();
69-
assertEquals(MphResult.Result.QUESTIONABLE, result.getResult());
79+
assertEquals(MphOutput.Result.QUESTIONABLE, result.getResult());
80+
assertEquals("mp_2007_breast", result.getGroupId());
81+
assertEquals("M7", result.getStep());
82+
assertEquals("Unable to apply Rule M7 of mp_2007_breast. Valid and known laterality should be provided.", result.getReason());
83+
assertEquals(4, result.getAppliedRules().size());
84+
assertEquals("Is there a tumor(s) in each breast?", result.getAppliedRules().get(3).getQuestion());
7085

7186
// finally test difffernt diseases; set everything the same except for the DX year
7287
input1.setPrimarySite("C501");
@@ -80,7 +95,12 @@ public void testResults() throws IOException {
8095
input2.setDateOfDiagnosisYear("1998");
8196
input2.setLaterality("1");
8297
result = _MPH.mph(new MphInputPair(input1, input2)).execute().body();
83-
assertEquals(MphResult.Result.MULTIPLE_PRIMARIES, result.getResult());
98+
assertEquals(MphOutput.Result.MULTIPLE_PRIMARIES, result.getResult());
99+
assertEquals("mp_2007_breast", result.getGroupId());
100+
assertEquals("M5", result.getStep());
101+
assertEquals("Tumors diagnosed more than five (5) years apart are multiple primaries.", result.getReason());
102+
assertEquals(2, result.getAppliedRules().size());
103+
assertEquals("Are there tumors diagnosed more than five (5) years apart?", result.getAppliedRules().get(1).getQuestion());
84104
}
85105

86106
}

0 commit comments

Comments
 (0)