Skip to content

Commit 43ac7cd

Browse files
committed
Support new NDC information
This will fail unit tests until production SEER*API includes changes.
1 parent 0f0bd06 commit 43ac7cd

9 files changed

Lines changed: 148 additions & 62 deletions

File tree

build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ repositories {
2828
}
2929

3030
dependencies {
31-
compile 'com.squareup.retrofit2:retrofit:2.3.0'
32-
compile 'com.squareup.retrofit2:converter-jackson:2.3.0'
31+
compile 'com.squareup.retrofit2:retrofit:2.4.0'
32+
compile 'com.squareup.retrofit2:converter-jackson:2.4.0'
3333

3434
testCompile 'junit:junit:4.11'
35-
testCompile 'org.assertj:assertj-core:3.9.0'
35+
testCompile 'org.assertj:assertj-core:3.9.1'
3636
}
3737

3838
jar {
@@ -66,7 +66,7 @@ findbugs {
6666

6767
// Gradle wrapper, this allows to build the project without having to install Gradle!
6868
task wrapper(type: Wrapper) {
69-
gradleVersion = '4.1'
69+
gradleVersion = '4.7'
7070
}
7171

7272
modifyPom {

gradle/wrapper/gradle-wrapper.jar

-295 Bytes
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Fri Aug 18 11:34:44 EDT 2017
1+
#Wed Apr 18 09:06:34 EDT 2018
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip

src/main/java/com/imsweb/seerapi/client/SeerApi.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import java.util.Properties;
1212

1313
import com.fasterxml.jackson.annotation.JsonAutoDetect;
14-
import com.fasterxml.jackson.annotation.JsonInclude;
14+
import com.fasterxml.jackson.annotation.JsonInclude.Include;
1515
import com.fasterxml.jackson.annotation.PropertyAccessor;
1616
import com.fasterxml.jackson.databind.ObjectMapper;
1717
import com.fasterxml.jackson.databind.SerializationFeature;
@@ -91,15 +91,13 @@ private SeerApi(String baseUrl, final String apiKey) {
9191

9292
/**
9393
* Return the internal ObjectMapper
94-
* @return
94+
* @return an Objectmapper
9595
*/
9696
static ObjectMapper getMapper() {
9797
ObjectMapper mapper = new ObjectMapper();
9898

9999
// do not write null values
100-
mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
101-
mapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false);
102-
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
100+
mapper.setSerializationInclusion(Include.NON_NULL);
103101

104102
mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
105103
mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);

src/main/java/com/imsweb/seerapi/client/ndc/NdcPackage.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,16 @@ public String getCode() {
2222
return _code;
2323
}
2424

25-
public void setCode(String code) {
26-
_code = code;
27-
}
28-
2925
public String getDescription() {
3026
return _description;
3127
}
3228

33-
public void setDescription(String description) {
34-
_description = description;
35-
}
36-
3729
public String getStartMarketingDate() {
3830
return _startMarketingDate;
3931
}
4032

41-
public void setStartMarketingDate(String startMarketingDate) {
42-
_startMarketingDate = startMarketingDate;
43-
}
44-
4533
public String getEndMarketingDate() {
4634
return _endMarketingDate;
4735
}
4836

49-
public void setEndMarketingDate(String endMarketingDate) {
50-
_endMarketingDate = endMarketingDate;
51-
}
5237
}

src/main/java/com/imsweb/seerapi/client/ndc/NdcProduct.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public class NdcProduct {
5252
private Date _dateModified;
5353
@JsonProperty("date_removed")
5454
private Date _dateRemoved;
55+
@JsonProperty("seer")
56+
private NdcSeerInfo _seerInfo;
5557

5658
public String getNdc() {
5759
return _ndc;
@@ -129,4 +131,7 @@ public Date getDateRemoved() {
129131
return _dateRemoved;
130132
}
131133

134+
public NdcSeerInfo getSeerInfo() {
135+
return _seerInfo;
136+
}
132137
}

src/main/java/com/imsweb/seerapi/client/ndc/NdcSearch.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
import java.util.HashMap;
77
import java.util.Map;
88

9+
import com.imsweb.seerapi.client.ndc.NdcSeerInfo.Category;
10+
911
public class NdcSearch {
1012

1113
private String _query;
14+
private Category _category;
1215
private Boolean _includeRemoved;
1316
private String _addedSince;
1417
private String _modifiedSince;
@@ -25,6 +28,14 @@ public void setQuery(String query) {
2528
_query = query;
2629
}
2730

31+
public Category getCategory() {
32+
return _category;
33+
}
34+
35+
public void setCategory(Category category) {
36+
_category = category;
37+
}
38+
2839
public Boolean getIncludeRemoved() {
2940
return _includeRemoved;
3041
}
@@ -90,6 +101,8 @@ public Map<String, String> paramMap() {
90101

91102
if (getQuery() != null)
92103
params.put("q", getQuery());
104+
if (getCategory() != null)
105+
params.put("category", getCategory().toString());
93106
if (getIncludeRemoved() != null)
94107
params.put("include_removed", getIncludeRemoved() ? "true" : "false");
95108
if (getAddedSince() != null)
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright (C) 2018 Information Management Services, Inc.
3+
*/
4+
package com.imsweb.seerapi.client.ndc;
5+
6+
import java.util.Date;
7+
import java.util.List;
8+
9+
import com.fasterxml.jackson.annotation.JsonProperty;
10+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
11+
12+
@JsonPropertyOrder({"seer_rx_id", "categories", "subcategory", "major_drug_class", "minor_drug_class", "orphan_drug", "date_modified"})
13+
public class NdcSeerInfo {
14+
15+
@JsonProperty("seer_rx_id")
16+
private String _seerRxId;
17+
@JsonProperty("categories")
18+
private List<Category> _categories;
19+
@JsonProperty("subcategory")
20+
private String _subcategory;
21+
@JsonProperty("major_drug_class")
22+
private String _majorDrugClass;
23+
@JsonProperty("minor_drug_class")
24+
private String _minorDrugClass;
25+
@JsonProperty("orphan_drug")
26+
private Boolean _orphanDrug;
27+
@JsonProperty("date_modified")
28+
private Date _dateModified;
29+
30+
public String getSeerRxId() {
31+
return _seerRxId;
32+
}
33+
34+
public List<Category> getCategories() {
35+
return _categories;
36+
}
37+
38+
public String getSubcategory() {
39+
return _subcategory;
40+
}
41+
42+
public String getMajorDrugClass() {
43+
return _majorDrugClass;
44+
}
45+
46+
public String getMinorDrugClass() {
47+
return _minorDrugClass;
48+
}
49+
50+
public Boolean getOrphanDrug() {
51+
return _orphanDrug;
52+
}
53+
54+
public Date getDateModified() {
55+
return _dateModified;
56+
}
57+
58+
// drug categories
59+
public enum Category {
60+
HORMONAL_THERAPY,
61+
ANCILLARY,
62+
CHEMOTHERAPY,
63+
IMMUNOTHERAPY,
64+
RADIOPHARMACEUTICAL
65+
}
66+
}

src/test/java/com/imsweb/seerapi/client/ndc/NdcTest.java

Lines changed: 55 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
package com.imsweb.seerapi.client.ndc;
55

66
import java.io.IOException;
7-
import java.util.Arrays;
8-
import java.util.Collections;
97
import java.util.List;
108

119
import org.junit.BeforeClass;
@@ -14,11 +12,9 @@
1412
import retrofit2.Response;
1513

1614
import com.imsweb.seerapi.client.SeerApi;
15+
import com.imsweb.seerapi.client.ndc.NdcSeerInfo.Category;
1716

18-
import static org.junit.Assert.assertEquals;
19-
import static org.junit.Assert.assertNotNull;
20-
import static org.junit.Assert.assertNull;
21-
import static org.junit.Assert.assertTrue;
17+
import static org.assertj.core.api.Assertions.assertThat;
2218

2319
public class NdcTest {
2420

@@ -33,36 +29,42 @@ public static void setup() {
3329
public void testNdcByCode() throws IOException {
3430
NdcProduct product = _NDC.getByCode("0002-3227").execute().body();
3531

36-
assertNotNull(product);
37-
assertEquals("0002-3227", product.getNdc());
38-
assertEquals("HUMAN PRESCRIPTION DRUG", product.getTypeName());
39-
assertEquals("Strattera", product.getProprietaryName());
40-
assertNull(product.getProprietaryNameSuffix());
41-
assertEquals(Collections.singletonList("Atomoxetine hydrochloride"), product.getNonProprietaryName());
42-
assertEquals("CAPSULE", product.getDosageFormName());
43-
assertEquals(Collections.singletonList("ORAL"), product.getRouteName());
44-
assertEquals("20021126", product.getStartMarketingDate());
45-
assertNull(product.getEndMarketingDate());
46-
assertEquals("NDA", product.getMarketingCategoryName());
47-
assertEquals("NDA021411", product.getApplicationNumber());
48-
assertEquals("Eli Lilly and Company", product.getLabelerName());
49-
assertNull(product.getDeaSchedule());
50-
assertEquals(1, product.getSubstances().size());
32+
assertThat(product).isNotNull();
33+
assertThat(product.getNdc()).isEqualTo("0002-3227");
34+
assertThat(product.getTypeName()).isEqualTo("HUMAN PRESCRIPTION DRUG");
35+
assertThat(product.getProprietaryName()).isEqualTo("Strattera");
36+
assertThat(product.getProprietaryNameSuffix()).isNull();
37+
assertThat(product.getNonProprietaryName()).containsExactly("Atomoxetine hydrochloride");
38+
assertThat(product.getDosageFormName()).isEqualTo("CAPSULE");
39+
assertThat(product.getRouteName()).containsExactly("ORAL");
40+
assertThat(product.getStartMarketingDate()).isEqualTo("20021126");
41+
assertThat(product.getEndMarketingDate()).isNull();
42+
assertThat(product.getMarketingCategoryName()).isEqualTo("NDA");
43+
assertThat(product.getApplicationNumber()).isEqualTo("NDA021411");
44+
assertThat(product.getLabelerName()).isEqualTo("Eli Lilly and Company");
45+
assertThat(product.getDeaSchedule()).isNull();
46+
assertThat(product.getSubstances()).hasSize(1);
5147

5248
NdcSubstance substance = product.getSubstances().get(0);
53-
assertEquals("ATOMOXETINE HYDROCHLORIDE", substance.getName());
54-
assertEquals("10", substance.getStrengthNumber());
55-
assertEquals("mg/1", substance.getStrengthUnit());
49+
assertThat(substance.getName()).isEqualTo("ATOMOXETINE HYDROCHLORIDE");
50+
assertThat(substance.getStrengthNumber()).isEqualTo("10");
51+
assertThat(substance.getStrengthUnit()).isEqualTo("mg/1");
5652

57-
assertEquals(Arrays.asList("Norepinephrine Reuptake Inhibitor [EPC]", "Norepinephrine Uptake Inhibitors [MoA]"), product.getPharmClass());
53+
assertThat(product.getPharmClass()).containsExactly("Norepinephrine Reuptake Inhibitor [EPC]", "Norepinephrine Uptake Inhibitors [MoA]");
5854

59-
assertEquals(2, product.getPackages().size());
60-
assertEquals("30", product.getPackages().get(0).getCode());
61-
assertEquals("30 CAPSULE in 1 BOTTLE (0002-3227-30)", product.getPackages().get(0).getDescription().trim());
55+
assertThat(product.getPackages()).isNotEmpty();
56+
assertThat(product.getPackages().get(0).getCode()).isEqualTo("30");
57+
assertThat(product.getPackages().get(0).getDescription()).isEqualToIgnoringWhitespace("30 CAPSULE in 1 BOTTLE (0002-3227-30)");
6258

63-
assertNotNull(product.getDateAdded());
64-
assertNotNull(product.getDateModified());
65-
assertNull(product.getDateRemoved());
59+
assertThat(product.getDateAdded()).isNotNull();
60+
assertThat(product.getDateModified()).isNotNull();
61+
assertThat(product.getDateRemoved()).isNull();
62+
63+
// test one with "seer" added information (0002-4483)
64+
product = _NDC.getByCode("0002-4483").execute().body();
65+
assertThat(product.getNdc()).isEqualTo("0002-4483");
66+
assertThat(product.getProprietaryName()).isEqualTo("Verzenio");
67+
assertThat(product.getSeerInfo().getCategories()).containsExactly(Category.CHEMOTHERAPY);
6668
}
6769

6870
@Test
@@ -74,26 +76,43 @@ public void testNdcSearch() throws IOException {
7476

7577
// hold onto total number (including "removed")
7678
Integer totalIncludingRemoved = Integer.valueOf(response.headers().get("X-Total-Count"));
77-
assertTrue(totalIncludingRemoved > 100000);
79+
assertThat(totalIncludingRemoved).isGreaterThan(100000);
7880

7981
List<NdcProduct> products = response.body();
80-
assertEquals(25, products.size());
82+
assertThat(products).hasSize(25);
8183

8284
search.setQuery("daklinza");
8385
products = _NDC.search(search.paramMap()).execute().body();
84-
assertTrue(products.size() > 1);
86+
assertThat(products.size()).isGreaterThan(1);
8587

8688
search.setRemovedSince("2016-07-21");
8789
products = _NDC.search(search.paramMap()).execute().body();
88-
assertEquals(0, products.size());
90+
assertThat(products).isEmpty();
8991

9092
// test removed
9193
search = new NdcSearch();
9294
search.setIncludeRemoved(false);
9395
response = _NDC.search(search.paramMap()).execute();
9496
Integer totalExcludingRemoved = Integer.valueOf(response.headers().get("X-Total-Count"));
9597

96-
assertTrue(totalIncludingRemoved > totalExcludingRemoved);
98+
assertThat(totalIncludingRemoved).isGreaterThan(totalExcludingRemoved);
99+
}
100+
101+
@Test
102+
public void testNdcSearchByCategory() throws IOException {
103+
NdcSearch search = new NdcSearch();
104+
search.setCategory(Category.CHEMOTHERAPY);
105+
106+
Response<List<NdcProduct>> response = _NDC.search(search.paramMap()).execute();
107+
108+
assertThat(Integer.valueOf(response.headers().get("X-Total-Count"))).isGreaterThan(0);
109+
110+
List<NdcProduct> products = response.body();
111+
assertThat(products).isNotEmpty();
112+
113+
NdcProduct product = products.get(0);
114+
assertThat(product.getSeerInfo()).as("must have 'seerinfo'").isNotNull();
115+
assertThat(product.getSeerInfo().getCategories()).contains(Category.CHEMOTHERAPY);
97116
}
98117

99118
}

0 commit comments

Comments
 (0)