Skip to content

Commit 5cc81ec

Browse files
committed
Added 'getNonDefaultSchemas' method.
1 parent c7e5eb2 commit 5cc81ec

2 files changed

Lines changed: 48 additions & 25 deletions

File tree

‎src/main/java/com/imsweb/algorithms/neoadjuvant/NeoAdjuvantTherapyTxEffectUtils.java‎

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*/
44
package com.imsweb.algorithms.neoadjuvant;
55

6-
import java.util.Arrays;
76
import java.util.Collections;
87
import java.util.HashSet;
98
import java.util.LinkedHashMap;
@@ -12,22 +11,27 @@
1211

1312
import org.apache.commons.lang3.StringUtils;
1413

14+
/**
15+
* This utility class provides schema-specific lookups for the "Neoadjuvant Therapy – Treatment Effect" field (#1634).
16+
*/
1517
public final class NeoAdjuvantTherapyTxEffectUtils {
1618

17-
private static final Set<String> _A_SCHEMA = new HashSet<>(Arrays.asList("00350", "09350", "00360", "09360", "00381", "00382", "00383", "00400", "00410", "00421", "00422", "00430", "00440", "00450"));
18-
private static final Set<String> _B_SCHEMA = new HashSet<>(Collections.singletonList("00480"));
19-
private static final Set<String> _C_SCHEMA = new HashSet<>(Arrays.asList("00161", "00169", "00170", "00200", "00210", "09210", "00280"));
20-
private static final Set<String> _D_SCHEMA = new HashSet<>(Arrays.asList("00551", "00552", "00553"));
21-
private static final Set<String> _E_SCHEMA = new HashSet<>(Collections.singletonList("00580"));
22-
private static final Set<String> _G_SCHEMA = new HashSet<>(Arrays.asList("00790", "00795", "00811", "00812", "00821", "00822", "00830", "99999"));
19+
// any schema not explicitly defined here will use a "default" lookup
20+
private static final Set<String> _A_SCHEMA = Set.of("00350", "09350", "00360", "09360", "00381", "00382", "00383", "00400", "00410", "00421", "00422", "00430", "00440", "00450");
21+
private static final Set<String> _B_SCHEMA = Set.of("00480");
22+
private static final Set<String> _C_SCHEMA = Set.of("00161", "00169", "00170", "00200", "00210", "09210", "00280");
23+
private static final Set<String> _D_SCHEMA = Set.of("00551", "00552", "00553");
24+
private static final Set<String> _E_SCHEMA = Set.of("00580");
25+
private static final Set<String> _F_SCHEMA = Set.of("00790", "00795", "00811", "00812", "00821", "00822", "00830", "99999");
2326

2427
private static final Map<String, String> _A = new LinkedHashMap<>();
2528
private static final Map<String, String> _B = new LinkedHashMap<>();
2629
private static final Map<String, String> _C = new LinkedHashMap<>();
2730
private static final Map<String, String> _D = new LinkedHashMap<>();
2831
private static final Map<String, String> _E = new LinkedHashMap<>();
2932
private static final Map<String, String> _F = new LinkedHashMap<>();
30-
private static final Map<String, String> _G = new LinkedHashMap<>();
33+
34+
private static final Map<String, String> _DEFAULT = new LinkedHashMap<>();
3135

3236
// Commonly used entries - fixing SonarQube warning
3337
private static final String ENTRY_0 = "Neoadjuvant therapy not given/no known presurgical therapy";
@@ -81,17 +85,17 @@ public final class NeoAdjuvantTherapyTxEffectUtils {
8185
_E.put("7", ENTRY_7);
8286
_E.put("9", ENTRY_9);
8387

84-
_F.put("0", ENTRY_0);
85-
_F.put("1", "Complete pathological response\nPresent: No viable cancer cells/no residual invasive carcinoma identified\nResidual in situ carcinoma only");
86-
_F.put("2", "Near complete pathological response Present: Single cells or rare small groups of invasive cancer cells");
87-
_F.put("3", "Partial or minimal pathological response Present: Residual invasive cancer with evident tumor regression, but more than single cells or rare small groups of cancer cells");
88-
_F.put("4", "Poor or no pathological response\nAbsent: Extensive residual cancer with no evident tumor regression");
89-
_F.put("6", ENTRY_6);
90-
_F.put("7", ENTRY_7);
91-
_F.put("9", ENTRY_9);
92-
93-
_G.put("0", "No Neoadjuvant therapy (not applicable)");
94-
_G.put("9", "Death certificate only (DCO)");
88+
_F.put("0", "No Neoadjuvant therapy (not applicable)");
89+
_F.put("9", "Death certificate only (DCO)");
90+
91+
_DEFAULT.put("0", ENTRY_0);
92+
_DEFAULT.put("1", "Complete pathological response\nPresent: No viable cancer cells/no residual invasive carcinoma identified\nResidual in situ carcinoma only");
93+
_DEFAULT.put("2", "Near complete pathological response Present: Single cells or rare small groups of invasive cancer cells");
94+
_DEFAULT.put("3", "Partial or minimal pathological response Present: Residual invasive cancer with evident tumor regression, but more than single cells or rare small groups of cancer cells");
95+
_DEFAULT.put("4", "Poor or no pathological response\nAbsent: Extensive residual cancer with no evident tumor regression");
96+
_DEFAULT.put("6", ENTRY_6);
97+
_DEFAULT.put("7", ENTRY_7);
98+
_DEFAULT.put("9", ENTRY_9);
9599
}
96100

97101
private static final Set<String> _ALL_ALLOWED_VALUES = new HashSet<>();
@@ -103,15 +107,15 @@ public final class NeoAdjuvantTherapyTxEffectUtils {
103107
_ALL_ALLOWED_VALUES.addAll(_D.keySet());
104108
_ALL_ALLOWED_VALUES.addAll(_E.keySet());
105109
_ALL_ALLOWED_VALUES.addAll(_F.keySet());
106-
_ALL_ALLOWED_VALUES.addAll(_G.keySet());
110+
_ALL_ALLOWED_VALUES.addAll(_DEFAULT.keySet());
107111
}
108112

109113
private NeoAdjuvantTherapyTxEffectUtils() {
110114
// utility class
111115
}
112116

113117
/**
114-
* Returns the lookup for neoadjuvTherapyTreatmentEffect (#1634) corresponding to the provided schemaId (#3800).
118+
* Returns the lookup for the "Neoadjuvant Therapy – Treatment Effect" field (#1634) corresponding to the provided schema ID (#3800).
115119
*/
116120
@SuppressWarnings("java:S1168")
117121
public static Map<String, String> getLookup(String schemaId) {
@@ -129,18 +133,32 @@ else if (_D_SCHEMA.contains(schemaId))
129133
result = _D;
130134
else if (_E_SCHEMA.contains(schemaId))
131135
result = _E;
132-
else if (_G_SCHEMA.contains(schemaId))
133-
result = _G;
134-
else
136+
else if (_F_SCHEMA.contains(schemaId))
135137
result = _F;
138+
else
139+
result = _DEFAULT;
136140

137141
return Collections.unmodifiableMap(result);
138142
}
139143

140144
/**
141-
* Returns all the possible values for neoadjuvTherapyTreatmentEffect (#1634) in the different lookups.
145+
* Returns all the possible values for the "Neoadjuvant Therapy – Treatment Effect" field (#1634) in the different lookups.
142146
*/
143147
public static Set<String> getAllAllowedValues() {
144148
return Collections.unmodifiableSet(_ALL_ALLOWED_VALUES);
145149
}
150+
151+
/**
152+
* Returns the set of schema IDs that don't use the "default" lookup.
153+
*/
154+
public static Set<String> getNonDefaultSchemas() {
155+
Set<String> result = new HashSet<>();
156+
result.addAll(_A_SCHEMA);
157+
result.addAll(_B_SCHEMA);
158+
result.addAll(_C_SCHEMA);
159+
result.addAll(_D_SCHEMA);
160+
result.addAll(_E_SCHEMA);
161+
result.addAll(_F_SCHEMA);
162+
return result;
163+
}
146164
}

‎src/test/java/com/imsweb/algorithms/neoadjuvant/NeoAdjuvantTherapyTxEffectUtilsTest.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,9 @@ public void testGetAllAllowedValues() {
3535
Assert.assertFalse(NeoAdjuvantTherapyTxEffectUtils.getAllAllowedValues().contains("5"));
3636
}
3737

38+
@Test
39+
public void testGetNonDefaultSchemas() {
40+
Assert.assertTrue(NeoAdjuvantTherapyTxEffectUtils.getNonDefaultSchemas().contains("00350"));
41+
Assert.assertFalse(NeoAdjuvantTherapyTxEffectUtils.getNonDefaultSchemas().contains("00000"));
42+
}
3843
}

0 commit comments

Comments
 (0)