diff --git a/CHANGELOG.md b/CHANGELOG.md index 89b93d0..b988e81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Changed data level errors from an exception to a validation error reported on the item. - Fixed behavior of the reading SAS macro when it deals with fields that have a value too long in the XML file. +- Added nw 'specs' parameter to allow writing a provided specifications version instead of the default library one. **Version 10.1** diff --git a/docs/sas/macro/write_naaccr_xml_macro.sas b/docs/sas/macro/write_naaccr_xml_macro.sas index 3728634..b6ef91c 100644 --- a/docs/sas/macro/write_naaccr_xml_macro.sas +++ b/docs/sas/macro/write_naaccr_xml_macro.sas @@ -1,4 +1,4 @@ -%MACRO writeNaaccrXml(libpath, targetfile, naaccrversion="", recordtype="", dataset=alldata, items="", dictfile="", dictUri="", writenum="no", cleanuptempfiles="yes", grouptumors="yes"); +%MACRO writeNaaccrXml(libpath, targetfile, naaccrversion="", recordtype="", dataset=alldata, items="", dictfile="", dictUri="", writenum="no", cleanuptempfiles="yes", grouptumors="yes", specs=""); /************************************************************************************************************; This macro writes a given data fileset into a NAACCR XML data file. @@ -43,6 +43,8 @@ - grouptumors should be "yes" or "no" (defaults to "yes"); if "yes" then the tumors that have the same patient ID number (and appearing together in the observations) will be grouped under one Patient tag; if "no", each tumor will appear under its own Patient tag (and every Patient will contain exactly one Tumor). + - specs is the specifications version to write to the data file (typically something like X.X); it's optional + and the library default value is used if not provided. Note that the macro creates a temp fixed-column and input SAS format file in the same folder as the target file; @@ -75,6 +77,7 @@ 12/14/2021 - Fabian Depry - Added new optional grouptumors parameter to allow not grouping the tumors. 06/04/2023 - Fabian Depry - Re-wrote the macro to use a temp fixed-column file instead of a temp CSV file. 06/22/2023 - Fabian Depry - Renamed cleanupcsv parameter to cleanuptempfiles + 08/09/2024 - Fabian Depry - Added new optional specs parameter to allow forcing a specific version to be written. ************************************************************************************************************/; /* @@ -131,6 +134,7 @@ data _null_; j1.callVoidMethod('setDictionary', &dictfile, &dicturi); j1.callVoidMethod('setWriteNumbers', &writenum); j1.callVoidMethod('setGroupTumors', &grouptumors); + j1.callVoidMethod('setSpecificationsVersion', &specs); j1.callVoidMethod('convert', &items); j1.callVoidMethod('cleanup', &cleanuptempfiles); j1.delete(); diff --git a/src/main/java/com/imsweb/naaccrxml/sas/SasCsvToXml.java b/src/main/java/com/imsweb/naaccrxml/sas/SasCsvToXml.java index 9da9395..69c2ddc 100644 --- a/src/main/java/com/imsweb/naaccrxml/sas/SasCsvToXml.java +++ b/src/main/java/com/imsweb/naaccrxml/sas/SasCsvToXml.java @@ -42,6 +42,8 @@ public class SasCsvToXml { private boolean _groupTumors; + private String _specificationsVersion; + public SasCsvToXml(String xmlPath, String naaccrVersion, String recordType) { this(SasUtils.computeCsvPathFromXmlPath(xmlPath), xmlPath, naaccrVersion, recordType); } @@ -116,6 +118,14 @@ public void setDictionary(String dictionaryPath, String dictionaryUri) { } } + /** + * The specificatoins version to use when writting the XML data. + */ + public void setSpecificationsVersion(String specificationsVersion) { + if (specificationsVersion != null && !specificationsVersion.trim().isEmpty()) + _specificationsVersion = specificationsVersion; + } + public String getCsvPath() { return _csvFile.getAbsolutePath(); } @@ -231,7 +241,10 @@ else if ("Tumor".equals(field.getParentTag())) if (!_dictionaryFiles.isEmpty() && _dictionaryUris != null && !_dictionaryUris.trim().isEmpty()) writer.write("\n userDictionaryUri=\"" + _dictionaryUris + "\""); writer.write("\n recordType=\"" + _recordType + "\""); - writer.write("\n specificationVersion=\"1.7\""); + if (_specificationsVersion != null) + writer.write("\n specificationVersion=\"" + _specificationsVersion + "\""); + else + writer.write("\n specificationVersion=\"1.7\""); writer.write("\n xmlns=\"http://naaccr.org/naaccrxml\""); writer.write(">\n"); for (Entry entry : rootFields.entrySet()) { diff --git a/src/main/java/com/imsweb/naaccrxml/sas/SasFlatToXml.java b/src/main/java/com/imsweb/naaccrxml/sas/SasFlatToXml.java index 27dda05..d2b7c34 100644 --- a/src/main/java/com/imsweb/naaccrxml/sas/SasFlatToXml.java +++ b/src/main/java/com/imsweb/naaccrxml/sas/SasFlatToXml.java @@ -63,6 +63,9 @@ public class SasFlatToXml { // the CSV list of fields contained in the data set private String _dataSetFields; + // the (optional) specifications verison to use (uses the default library one if not provided) + private String _specificationsVersion; + /** * Constructor. */ @@ -164,6 +167,14 @@ public void setDictionary(String dictionaryPath, String dictionaryUri) { } } + /** + * The specificatoins version to use when writting the XML data. + */ + public void setSpecificationsVersion(String specificationsVersion) { + if (specificationsVersion != null && !specificationsVersion.trim().isEmpty()) + _specificationsVersion = specificationsVersion; + } + /** * Returns the user-defined dictionaries. */ @@ -415,7 +426,10 @@ else if (line.length() < expectedLineLength) { if (!_dictionaryFiles.isEmpty() && _dictionaryUris != null && !_dictionaryUris.trim().isEmpty()) writer.write("\n userDictionaryUri=\"" + _dictionaryUris + "\""); writer.write("\n recordType=\"" + _recordType + "\""); - writer.write("\n specificationVersion=\"1.7\""); + if (_specificationsVersion != null) + writer.write("\n specificationVersion=\"" + _specificationsVersion + "\""); + else + writer.write("\n specificationVersion=\"1.7\""); writer.write("\n xmlns=\"http://naaccr.org/naaccrxml\""); writer.write(">\n"); for (Entry entry : rootFields.entrySet()) {