diff --git a/build.gradle b/build.gradle index 24b0663..effddd2 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ plugins { id 'com.adarshr.test-logger' version '4.0.0' id "com.github.ben-manes.versions" version "0.52.0" id 'org.sonatype.gradle.plugins.scan' version '3.1.1' - id "org.sonarqube" version "6.1.0.5360" + id "org.sonarqube" version "6.2.0.5505" id 'com.vanniktech.maven.publish' version '0.31.0' } @@ -37,6 +37,7 @@ dependencies { api 'com.squareup.retrofit2:retrofit:2.11.0' api 'com.squareup.retrofit2:converter-jackson:2.11.0' + api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.19.1' // retrofit will not update these dependencies to fix vulnerabilities api 'com.squareup.okhttp3:okhttp:4.12.0' diff --git a/src/main/java/com/imsweb/seerapi/client/SeerApi.java b/src/main/java/com/imsweb/seerapi/client/SeerApi.java index 3d33294..45712a1 100644 --- a/src/main/java/com/imsweb/seerapi/client/SeerApi.java +++ b/src/main/java/com/imsweb/seerapi/client/SeerApi.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.annotation.PropertyAccessor; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import okhttp3.OkHttpClient; import okhttp3.Request; @@ -110,6 +111,8 @@ static ObjectMapper getMapper() { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); mapper.setDateFormat(dateFormat); + mapper.registerModule(new JavaTimeModule()); + return mapper; } diff --git a/src/main/java/com/imsweb/seerapi/client/naaccr/AllowedCode.java b/src/main/java/com/imsweb/seerapi/client/naaccr/AllowedCode.java new file mode 100644 index 0000000..414b345 --- /dev/null +++ b/src/main/java/com/imsweb/seerapi/client/naaccr/AllowedCode.java @@ -0,0 +1,27 @@ +package com.imsweb.seerapi.client.naaccr; + +public class AllowedCode { + + private String code; + private String description; + + public AllowedCode() { + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + +} \ No newline at end of file diff --git a/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrFieldName.java b/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrFieldName.java deleted file mode 100644 index 73ff8f8..0000000 --- a/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrFieldName.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2011 Information Management Services, Inc. - */ -package com.imsweb.seerapi.client.naaccr; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class NaaccrFieldName { - - @JsonProperty("id") - protected String _id; - @JsonProperty("item") - protected Integer _item; - @JsonProperty("name") - protected String _name; - - public String getNaaccrId() { - return _id; - } - - public Integer getItemNum() { - return _item; - } - - public String getName() { - return _name; - } -} diff --git a/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrFlatField.java b/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrFlatField.java deleted file mode 100644 index 2eb9ed6..0000000 --- a/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrFlatField.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2011 Information Management Services, Inc. - */ -package com.imsweb.seerapi.client.naaccr; - -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonPropertyOrder({"item", "name", "section", "start_col", "end_col", "alignment", "padding_char", "default_value", "documentation", "subfield"}) -public class NaaccrFlatField { - - @JsonProperty("id") - protected String _id; - @JsonProperty("item") - protected Integer _item; - @JsonProperty("name") - protected String _name; - @JsonProperty("section") - protected String _section; - @JsonProperty("start_col") - protected Integer _start; - @JsonProperty("end_col") - protected Integer _end; - @JsonProperty("alignment") - protected String _align; - @JsonProperty("padding_char") - protected String _padChar; - @JsonProperty("default_value") - protected String _defaultValue; - @JsonProperty("documentation") - protected String _documentation; - @JsonProperty("subfield") - protected List _subFields; - - public String getNaaccrId() { - return _id; - } - - public Integer getItemNum() { - return _item; - } - - public String getName() { - return _name; - } - - public String getSection() { - return _section; - } - - public Integer getStart() { - return _start; - } - - public Integer getEnd() { - return _end; - } - - public String getAlign() { - return _align; - } - - public String getPadChar() { - return _padChar; - } - - public String getDefaultValue() { - return _defaultValue; - } - - public String getDocumentation() { - return _documentation; - } - - public List getSubFields() { - return _subFields; - } -} diff --git a/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrItem.java b/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrItem.java new file mode 100644 index 0000000..39c9683 --- /dev/null +++ b/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrItem.java @@ -0,0 +1,305 @@ +package com.imsweb.seerapi.client.naaccr; + +import java.time.OffsetDateTime; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class NaaccrItem { + + private NaaccrVersion version; + private String itemNumber; + private String itemName; + private String itemLength; + private String yearImplemented; + private String yearRetired; + private String versionImplemented; + private String versionRetired; + private String xmlNaaccrId; + private String xmlParentId; + private List recordTypes; + private String section; + private String sourceOfStandard; + private OffsetDateTime dateCreated; + private OffsetDateTime dateModified; + private String description; + private String rationale; + private String generalNotes; + private String clarification; + private String npcrCollect; + private String cocCollect; + private String seerCollect; + private String cccrCollect; + private List alternateNames; + private String format; + private String codeNote; + private String codeDescription; + private String itemDataType; + private String allowableValues; + private List allowedCodes; + + public NaaccrVersion getVersion() { + return version; + } + + public void setVersion(NaaccrVersion version) { + this.version = version; + } + + @JsonProperty("item_number") + public String getItemNumber() { + return itemNumber; + } + + public void setItemNumber(String itemNumber) { + this.itemNumber = itemNumber; + } + + @JsonProperty("item_name") + public String getItemName() { + return itemName; + } + + public void setItemName(String itemName) { + this.itemName = itemName; + } + + @JsonProperty("item_length") + public String getItemLength() { + return itemLength; + } + + public void setItemLength(String itemLength) { + this.itemLength = itemLength; + } + + @JsonProperty("year_implemented") + public String getYearImplemented() { + return yearImplemented; + } + + public void setYearImplemented(String yearImplemented) { + this.yearImplemented = yearImplemented; + } + + @JsonProperty("year_retired") + public String getYearRetired() { + return yearRetired; + } + + public void setYearRetired(String yearRetired) { + this.yearRetired = yearRetired; + } + + @JsonProperty("version_implemented") + public String getVersionImplemented() { + return versionImplemented; + } + + public void setVersionImplemented(String versionImplemented) { + this.versionImplemented = versionImplemented; + } + + @JsonProperty("version_retired") + public String getVersionRetired() { + return versionRetired; + } + + public void setVersionRetired(String versionRetired) { + this.versionRetired = versionRetired; + } + + @JsonProperty("xml_naaccr_id") + public String getXmlNaaccrId() { + return xmlNaaccrId; + } + + public void setXmlNaaccrId(String xmlNaaccrId) { + this.xmlNaaccrId = xmlNaaccrId; + } + + @JsonProperty("xml_parent_id") + public String getXmlParentId() { + return xmlParentId; + } + + public void setXmlParentId(String xmlParentId) { + this.xmlParentId = xmlParentId; + } + + @JsonProperty("record_types") + public List getRecordTypes() { + return recordTypes; + } + + public void setRecordTypes(List recordTypes) { + this.recordTypes = recordTypes; + } + + public String getSection() { + return section; + } + + public void setSection(String section) { + this.section = section; + } + + @JsonProperty("source_of_standard") + public String getSourceOfStandard() { + return sourceOfStandard; + } + + public void setSourceOfStandard(String sourceOfStandard) { + this.sourceOfStandard = sourceOfStandard; + } + + @JsonProperty("date_created") + public OffsetDateTime getDateCreated() { + return dateCreated; + } + + public void setDateCreated(OffsetDateTime dateCreated) { + this.dateCreated = dateCreated; + } + + @JsonProperty("date_modified") + public OffsetDateTime getDateModified() { + return dateModified; + } + + public void setDateModified(OffsetDateTime dateModified) { + this.dateModified = dateModified; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getRationale() { + return rationale; + } + + public void setRationale(String rationale) { + this.rationale = rationale; + } + + @JsonProperty("general_notes") + public String getGeneralNotes() { + return generalNotes; + } + + public void setGeneralNotes(String generalNotes) { + this.generalNotes = generalNotes; + } + + public String getClarification() { + return clarification; + } + + public void setClarification(String clarification) { + this.clarification = clarification; + } + + @JsonProperty("npcr_collect") + public String getNpcrCollect() { + return npcrCollect; + } + + public void setNpcrCollect(String npcrCollect) { + this.npcrCollect = npcrCollect; + } + + @JsonProperty("coc_collect") + public String getCocCollect() { + return cocCollect; + } + + public void setCocCollect(String cocCollect) { + this.cocCollect = cocCollect; + } + + @JsonProperty("seer_collect") + public String getSeerCollect() { + return seerCollect; + } + + public void setSeerCollect(String seerCollect) { + this.seerCollect = seerCollect; + } + + @JsonProperty("cccr_collect") + public String getCccrCollect() { + return cccrCollect; + } + + public void setCccrCollect(String cccrCollect) { + this.cccrCollect = cccrCollect; + } + + @JsonProperty("alternate_names") + public List getAlternateNames() { + return alternateNames; + } + + public void setAlternateNames(List alternateNames) { + this.alternateNames = alternateNames; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + @JsonProperty("code_note") + public String getCodeNote() { + return codeNote; + } + + public void setCodeNote(String codeNote) { + this.codeNote = codeNote; + } + + @JsonProperty("code_description") + public String getCodeDescription() { + return codeDescription; + } + + public void setCodeDescription(String codeDescription) { + this.codeDescription = codeDescription; + } + + @JsonProperty("item_data_type") + public String getItemDataType() { + return itemDataType; + } + + public void setItemDataType(String itemDataType) { + this.itemDataType = itemDataType; + } + + @JsonProperty("allowable_values") + public String getAllowableValues() { + return allowableValues; + } + + public void setAllowableValues(String allowableValues) { + this.allowableValues = allowableValues; + } + + @JsonProperty("allowed_codes") + public List getAllowedCodes() { + return allowedCodes; + } + + public void setAllowedCodes(List allowedCodes) { + this.allowedCodes = allowedCodes; + } + +} diff --git a/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrItemInfo.java b/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrItemInfo.java new file mode 100644 index 0000000..cefeee6 --- /dev/null +++ b/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrItemInfo.java @@ -0,0 +1,36 @@ +package com.imsweb.seerapi.client.naaccr; + +public class NaaccrItemInfo { + + private String id; + private String item; + private String name; + + public NaaccrItemInfo() { + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getItem() { + return item; + } + + public void setItem(String item) { + this.item = item; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} \ No newline at end of file diff --git a/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrService.java b/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrService.java index c155e4f..c2b9609 100644 --- a/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrService.java +++ b/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrService.java @@ -12,60 +12,27 @@ public interface NaaccrService { /** - * Return a collection of NaaccrVersion objects which descibe the available flat file versions + * Return a collection of NaaccrVersion objects which descibe the available versions * @return a list of the available NAACCR versions and information about each of them */ - @GET("naaccr/flat/versions") - Call> flatVersions(); + @GET("naaccr/versions") + Call> versions(); /** - * Return a collection of NaaccrVersion objects which descibe the available XML versions - * @return a list of the available NAACCR versions and information about each of them - */ - @GET("naaccr/xml/versions") - Call> xmlVersions(); - - /** - * Return a list of all the field identifiers and names from a specified NAACCR flat file version - * @param version NAACCR version - * @return a list of NaaccrFieldName objects - */ - @GET("naaccr/flat/{version}") - Call> flatFieldNames(@Path("version") String version); - - /** - * Return a list of all the field identifiers and names from a specified NAACCR XML version - * @param version NAACCR version - * @return a list of NaaccrFieldName objects - */ - @GET("naaccr/xml/{version}") - Call> xmlFieldNames(@Path("version") String version); - - /** - * Return a list of all the field identifiers and names from a specified NAACCR flat file version - * @param version NAACCR version - * @param item NAACCR item number - * @return a list of NaaccrFieldName objects - */ - @GET("naaccr/flat/{version}/item/{item}") - Call flatField(@Path("version") String version, @Path("item") Integer item); - - /** - * Return a list of all the field identifiers and names from a specified NAACCR XML version + * Return a list of all the field identifiers and names from a specified NAACCR version * @param version NAACCR version - * @param id NAACCR XML id * @return a list of NaaccrFieldName objects */ - @GET("naaccr/xml/{version}/id/{id}") - Call xmlField(@Path("version") String version, @Path("id") String id); + @GET("naaccr/{version}") + Call> fieldNames(@Path("version") String version); /** - * Return a list of all the field identifiers and names from a specified NAACCR XML version + * Return a single item from a NAACCR version * @param version NAACCR version - * @param item NAACCR item number - * @return a list of NaaccrFieldName objects + * @param item NAACCR item number or XML identifier + * @return a NaaccrItem */ - @GET("naaccr/xml/{version}/item/{item}") - Call xmlField(@Path("version") String version, @Path("item") Integer item); + @GET("naaccr/{version}/{item}") + Call item(@Path("version") String version, @Path("item") String item); } diff --git a/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrSubField.java b/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrSubField.java deleted file mode 100644 index f91e27a..0000000 --- a/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrSubField.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2011 Information Management Services, Inc. - */ -package com.imsweb.seerapi.client.naaccr; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class NaaccrSubField { - - @JsonProperty("item") - protected Integer _item; - @JsonProperty("name") - protected String _name; - @JsonProperty("start_col") - protected Integer _start; - @JsonProperty("end_col") - protected Integer _end; - @JsonProperty("alignment") - protected String _align; - @JsonProperty("padding_char") - protected String _padChar; - - public Integer getItem() { - return _item; - } - - public String getName() { - return _name; - } - - public Integer getStart() { - return _start; - } - - public Integer getEnd() { - return _end; - } - - public String getAlign() { - return _align; - } - - public String getPadChar() { - return _padChar; - } -} diff --git a/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrVersion.java b/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrVersion.java index ff918b8..c9be312 100644 --- a/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrVersion.java +++ b/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrVersion.java @@ -1,54 +1,41 @@ package com.imsweb.seerapi.client.naaccr; +import java.time.OffsetDateTime; + import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +@JsonPropertyOrder({"version", "year_implemented", "date_of_publication"}) public class NaaccrVersion { - @JsonProperty("version") - protected String _version; - @JsonProperty("name") - protected String _name; - @JsonProperty("length") - protected Integer _length; - @JsonProperty("description") - protected String _description; - @JsonProperty("style") - protected String _style; - @JsonProperty("dictionary_uri") - protected String dictionaryUri; - @JsonProperty("dictionary_description") - protected String dictionaryDescription; - @JsonProperty("specification_version") - protected String specificationVersion; + private String version; + private Integer yearImplemented; + private OffsetDateTime dateOfPublication; public String getVersion() { - return _version; + return version; } - public String getName() { - return _name; + public void setVersion(String version) { + this.version = version; } - public Integer getLength() { - return _length; + @JsonProperty("year_implemented") + public Integer getYearImplemented() { + return yearImplemented; } - public String getDescription() { - return _description; + public void setYearImplemented(Integer yearImplemented) { + this.yearImplemented = yearImplemented; } - public String getStyle() { - return _style; + @JsonProperty("date_of_publication") + public OffsetDateTime getDateOfPublication() { + return dateOfPublication; } - public String getDictionaryUri() { - return dictionaryUri; + public void setDateOfPublication(OffsetDateTime dateOfPublication) { + this.dateOfPublication = dateOfPublication; } - public String getDictionaryDescription() { - return dictionaryDescription; - } - public String getSpecificationVersion() { - return specificationVersion; - } -} +} \ No newline at end of file diff --git a/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrXmlField.java b/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrXmlField.java deleted file mode 100644 index f9ba8c7..0000000 --- a/src/main/java/com/imsweb/seerapi/client/naaccr/NaaccrXmlField.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2011 Information Management Services, Inc. - */ -package com.imsweb.seerapi.client.naaccr; - -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonPropertyOrder({"id", "item", "name", "section", "parent_xml_element", "record_types", "data_type", "length", "start_col", - "pad_type", "trim_type", "allow_unlimited_text", "documentation"}) -public class NaaccrXmlField { - - @JsonProperty("id") - protected String _naaccrId; - @JsonProperty("item") - protected Integer _naaccrItemNum; - @JsonProperty("name") - protected String _name; - @JsonProperty("section") - protected String _section; - @JsonProperty("start_col") - protected Integer _start; - @JsonProperty("record_types") - protected List _recordTypes; - @JsonProperty("length") - protected Integer _length; - @JsonProperty("pad_type") - protected String _padType; - @JsonProperty("data_type") - protected String _dataType; - @JsonProperty("trim_type") - protected String _trimType; - @JsonProperty("allow_unlimited_text") - protected Boolean _allowUnlimitedText; - @JsonProperty("parent_xml_element") - protected String _parentXmlElement; - @JsonProperty("documentation") - protected String _documentation; - - public String getNaaccrId() { - return _naaccrId; - } - - public Integer getItemNum() { - return _naaccrItemNum; - } - - public String getName() { - return _name; - } - - public String getSection() { - return _section; - } - - public Integer getStart() { - return _start; - } - - public List getRecordTypes() { - return _recordTypes; - } - - public Integer getLength() { - return _length; - } - - public String getPadType() { - return _padType; - } - - public String getDataType() { - return _dataType; - } - - public String getTrimType() { - return _trimType; - } - - public Boolean getAllowUnlimitedText() { - return _allowUnlimitedText; - } - - public String getParentXmlElement() { - return _parentXmlElement; - } - - public String getDocumentation() { - return _documentation; - } - -} diff --git a/src/test/java/com/imsweb/seerapi/client/naaccr/NaaccrTest.java b/src/test/java/com/imsweb/seerapi/client/naaccr/NaaccrTest.java index 4172f7d..3a80a40 100644 --- a/src/test/java/com/imsweb/seerapi/client/naaccr/NaaccrTest.java +++ b/src/test/java/com/imsweb/seerapi/client/naaccr/NaaccrTest.java @@ -5,10 +5,8 @@ import java.io.IOException; import java.util.List; -import java.util.Objects; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import com.imsweb.seerapi.client.SeerApi; @@ -25,128 +23,64 @@ public static void setup() { } @Test - void testNaaccrFlatVersions() throws IOException { - List versions = _NAACCR.flatVersions().execute().body(); + void testVersions() throws IOException { + List versions = _NAACCR.versions().execute().body(); assertThat(versions).isNotNull().isNotEmpty(); for (NaaccrVersion version : versions) { assertThat(version.getVersion()).isNotEmpty(); - assertThat(version.getName()).isNotEmpty(); - assertThat(version.getLength()).isGreaterThanOrEqualTo(22824); - assertThat(version.getDescription()).isNull(); - assertThat(version.getStyle()).isNotEmpty(); + assertThat(version.getYearImplemented()).isGreaterThan(2020); + assertThat(version.getDateOfPublication()).isNotNull(); } } @Test - void testNaaccrXmlVersions() throws IOException { - List versions = _NAACCR.xmlVersions().execute().body(); - - assertThat(versions).isNotNull().isNotEmpty(); - for (NaaccrVersion version : versions) { - assertThat(version.getVersion()).isNotEmpty(); - assertThat(version.getName()).isNotEmpty(); - assertThat(version.getLength()).isNull(); - assertThat(version.getDescription()).isNull(); - assertThat(version.getStyle()).isNotEmpty(); - assertThat(version.getDictionaryUri()).isNotEmpty(); - assertThat(version.getDictionaryDescription()).isNotEmpty(); - assertThat(version.getSpecificationVersion()).isNotEmpty(); - } - } - - @Test - void testNaaccrFlatFieldNames() throws IOException { - List names = _NAACCR.flatFieldNames("latest").execute().body(); + void testNaaccrFieldNames() throws IOException { + List names = _NAACCR.fieldNames("latest").execute().body(); assertThat(names).isNotNull(); - for (NaaccrFieldName name : names) { - assertThat(name.getItemNum()).isPositive(); + for (NaaccrItemInfo name : names) { + assertThat(name.getItem()).isNotEmpty(); assertThat(name.getName()).isNotEmpty(); } } @Test - void testNaaccrXmlFieldNames() throws IOException { - List names = _NAACCR.xmlFieldNames("latest").execute().body(); - - assertThat(names).isNotNull(); - for (NaaccrFieldName name : names) { - assertThat(name.getNaaccrId()).isNotEmpty(); - assertThat(name.getItemNum()).isPositive(); - assertThat(name.getName()).isNotEmpty(); - } + void testNaaccrItem() throws IOException { + validateItem(_NAACCR.item("25", "80").execute().body()); + validateItem(_NAACCR.item("25", "addrAtDxState").execute().body()); } - @Test - void testNaaccrFlatField() throws IOException { - NaaccrFlatField name = _NAACCR.flatField("16", 521).execute().body(); - - assertThat(name).isNotNull(); - assertThat(name.getItemNum()).isEqualTo(521); - assertThat(name.getNaaccrId()).isEqualTo("morphTypebehavIcdO3"); - assertThat(name.getName()).isEqualTo("Morph--Type&Behav ICD-O-3"); - assertThat(name.getSection()).isEqualTo("Cancer Identification"); - assertThat(name.getAlign()).isEqualTo("LEFT"); - assertThat(name.getPadChar()).isEqualTo(" "); - assertThat(name.getDocumentation()).startsWith(""); - assertThat(name.getStart()).isEqualTo(550); - assertThat(name.getEnd()).isEqualTo(554); - - assertThat(name.getSubFields()).hasSize(2); - assertThat(name.getSubFields()).extracting("item").contains(522, 523); - - NaaccrSubField sub = name.getSubFields().get(0); - assertThat(sub.getName()).isEqualTo("Histologic Type ICD-O-3"); - assertThat(sub.getStart()).isEqualTo(550); - assertThat(sub.getEnd()).isEqualTo(553); - assertThat(sub.getAlign()).isEqualTo("LEFT"); - assertThat(sub.getPadChar()).isEqualTo(" "); - - // test one with default value - NaaccrFlatField recordID = _NAACCR.flatField("18", 10).execute().body(); - assertThat(recordID).isNotNull(); - assertThat(recordID.getName()).isEqualTo("Record Type"); - assertThat(recordID.getSection()).isEqualTo("Record ID"); - assertThat(recordID.getDefaultValue()).isEqualTo("A"); - } - - @Test - void testNaaccrXmlField() throws IOException { - NaaccrXmlField name = _NAACCR.xmlField("21", "phase2RadiationExternalBeamTech").execute().body(); - - assertThat(name).isNotNull(); - assertThat(name.getNaaccrId()).isEqualTo("phase2RadiationExternalBeamTech"); - assertThat(name.getItemNum()).isEqualTo(1512); - assertThat(name.getName()).isEqualTo("Phase II Radiation External Beam Planning Tech"); - assertThat(name.getSection()).isEqualTo("Treatment-1st Course"); - assertThat(name.getParentXmlElement()).isEqualTo("Tumor"); - assertThat(name.getRecordTypes()).containsExactly("A", "M", "C", "I"); - assertThat(name.getDataType()).isEqualTo("digits"); - assertThat(name.getLength()).isEqualTo(2); - assertThat(name.getPadType()).isEqualTo("none"); - assertThat(name.getTrimType()).isEqualTo("all"); - assertThat(name.getAllowUnlimitedText()).isFalse(); - assertThat(name.getDocumentation()).isNotEmpty(); - } - - // these two tests are slow so don't run them all the time; they verify that all the items from flat and NAACR can be read without error - - @Disabled("Slow test so do not run all the time") - public void loadAllFlat() throws IOException { - for (NaaccrFieldName name : Objects.requireNonNull(_NAACCR.flatFieldNames("latest").execute().body())) { - NaaccrFlatField field = _NAACCR.flatField("latest", name.getItemNum()).execute().body(); - - assertThat(field).isNotNull(); - } + private void validateItem(NaaccrItem item) { + assertThat(item).isNotNull(); + assertThat(item.getItemNumber()).isEqualTo("80"); + assertThat(item.getItemName()).isEqualTo("Addr at DX--State"); + assertThat(item.getItemDataType()).isEqualTo("alpha"); + assertThat(item.getItemLength()).isEqualTo("2"); + assertThat(item.getYearImplemented()).isEqualTo("2011"); + assertThat(item.getVersionImplemented()).isEqualTo("12.2"); + assertThat(item.getXmlNaaccrId()).isEqualTo("addrAtDxState"); + assertThat(item.getXmlParentId()).isEqualTo("Tumor"); + assertThat(item.getRecordTypes()).containsExactlyInAnyOrder("A", "C", "I", "M"); + assertThat(item.getSection()).isEqualTo("Demographic"); + assertThat(item.getSourceOfStandard()).isEqualTo("CoC"); + assertThat(item.getDateCreated()).isInThePast(); + assertThat(item.getDateModified()).isInThePast(); + assertThat(item.getDescription()).isNotEmpty(); + assertThat(item.getRationale()).isNotEmpty(); + assertThat(item.getNpcrCollect()).isEqualTo("Required"); + assertThat(item.getCocCollect()).isEqualTo("Required"); + assertThat(item.getSeerCollect()).isEqualTo("Required"); + assertThat(item.getCccrCollect()).isEqualTo("No recommendation"); + assertThat(item.getAlternateNames()).containsExactlyInAnyOrder("State at Diagnosis (CoC)", "State (pre-96 CoC)"); + assertThat(item.getFormat()).isEqualTo("Upper case"); + assertThat(item.getCodeDescription()).isEqualTo("In addition to USPS abbreviations"); + assertThat(item.getAllowableValues()).isEqualTo("Refer to EDITS table STATE.DBF in Appendix B; CD, US, XX, YY, ZZ"); + assertThat(item.getAllowedCodes()) + .hasSize(5) + .allMatch(allowedCode -> allowedCode.getDescription() != null) + .extracting("code") + .containsExactlyInAnyOrder("CD", "US", "XX", "YY", "ZZ"); } - @Disabled("Slow test so do not run all the time") - public void loadAllXml() throws IOException { - for (NaaccrFieldName name : Objects.requireNonNull(_NAACCR.xmlFieldNames("latest").execute().body())) { - NaaccrXmlField field = _NAACCR.xmlField("latest", name.getNaaccrId()).execute().body(); - - assertThat(field).isNotNull(); - } - } }