Skip to content

Commit fff62cf

Browse files
authored
Merge pull request #255 from imsweb/sas-param-specs-250
SAS param specs (#250)
2 parents c9ca011 + e1e4187 commit fff62cf

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Changed data level errors from an exception to a validation error reported on the item.
66
- Fixed behavior of the reading SAS macro when it deals with fields that have a value too long in the XML file.
7+
- Added nw 'specs' parameter to allow writing a provided specifications version instead of the default library one.
78

89
**Version 10.1**
910

docs/sas/macro/write_naaccr_xml_macro.sas

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
%MACRO writeNaaccrXml(libpath, targetfile, naaccrversion="", recordtype="", dataset=alldata, items="", dictfile="", dictUri="", writenum="no", cleanuptempfiles="yes", grouptumors="yes");
1+
%MACRO writeNaaccrXml(libpath, targetfile, naaccrversion="", recordtype="", dataset=alldata, items="", dictfile="", dictUri="", writenum="no", cleanuptempfiles="yes", grouptumors="yes", specs="");
22

33
/************************************************************************************************************;
44
This macro writes a given data fileset into a NAACCR XML data file.
@@ -43,6 +43,8 @@
4343
- grouptumors should be "yes" or "no" (defaults to "yes"); if "yes" then the tumors that have the same
4444
patient ID number (and appearing together in the observations) will be grouped under one Patient tag;
4545
if "no", each tumor will appear under its own Patient tag (and every Patient will contain exactly one Tumor).
46+
- specs is the specifications version to write to the data file (typically something like X.X); it's optional
47+
and the library default value is used if not provided.
4648
4749
4850
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 @@
7577
12/14/2021 - Fabian Depry - Added new optional grouptumors parameter to allow not grouping the tumors.
7678
06/04/2023 - Fabian Depry - Re-wrote the macro to use a temp fixed-column file instead of a temp CSV file.
7779
06/22/2023 - Fabian Depry - Renamed cleanupcsv parameter to cleanuptempfiles
80+
08/09/2024 - Fabian Depry - Added new optional specs parameter to allow forcing a specific version to be written.
7881
************************************************************************************************************/;
7982

8083
/*
@@ -131,6 +134,7 @@ data _null_;
131134
j1.callVoidMethod('setDictionary', &dictfile, &dicturi);
132135
j1.callVoidMethod('setWriteNumbers', &writenum);
133136
j1.callVoidMethod('setGroupTumors', &grouptumors);
137+
j1.callVoidMethod('setSpecificationsVersion', &specs);
134138
j1.callVoidMethod('convert', &items);
135139
j1.callVoidMethod('cleanup', &cleanuptempfiles);
136140
j1.delete();

src/main/java/com/imsweb/naaccrxml/sas/SasCsvToXml.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public class SasCsvToXml {
4242

4343
private boolean _groupTumors;
4444

45+
private String _specificationsVersion;
46+
4547
public SasCsvToXml(String xmlPath, String naaccrVersion, String recordType) {
4648
this(SasUtils.computeCsvPathFromXmlPath(xmlPath), xmlPath, naaccrVersion, recordType);
4749
}
@@ -116,6 +118,14 @@ public void setDictionary(String dictionaryPath, String dictionaryUri) {
116118
}
117119
}
118120

121+
/**
122+
* The specificatoins version to use when writting the XML data.
123+
*/
124+
public void setSpecificationsVersion(String specificationsVersion) {
125+
if (specificationsVersion != null && !specificationsVersion.trim().isEmpty())
126+
_specificationsVersion = specificationsVersion;
127+
}
128+
119129
public String getCsvPath() {
120130
return _csvFile.getAbsolutePath();
121131
}
@@ -231,7 +241,10 @@ else if ("Tumor".equals(field.getParentTag()))
231241
if (!_dictionaryFiles.isEmpty() && _dictionaryUris != null && !_dictionaryUris.trim().isEmpty())
232242
writer.write("\n userDictionaryUri=\"" + _dictionaryUris + "\"");
233243
writer.write("\n recordType=\"" + _recordType + "\"");
234-
writer.write("\n specificationVersion=\"1.7\"");
244+
if (_specificationsVersion != null)
245+
writer.write("\n specificationVersion=\"" + _specificationsVersion + "\"");
246+
else
247+
writer.write("\n specificationVersion=\"1.7\"");
235248
writer.write("\n xmlns=\"http://naaccr.org/naaccrxml\"");
236249
writer.write(">\n");
237250
for (Entry<String, String> entry : rootFields.entrySet()) {

src/main/java/com/imsweb/naaccrxml/sas/SasFlatToXml.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ public class SasFlatToXml {
6363
// the CSV list of fields contained in the data set
6464
private String _dataSetFields;
6565

66+
// the (optional) specifications verison to use (uses the default library one if not provided)
67+
private String _specificationsVersion;
68+
6669
/**
6770
* Constructor.
6871
*/
@@ -164,6 +167,14 @@ public void setDictionary(String dictionaryPath, String dictionaryUri) {
164167
}
165168
}
166169

170+
/**
171+
* The specificatoins version to use when writting the XML data.
172+
*/
173+
public void setSpecificationsVersion(String specificationsVersion) {
174+
if (specificationsVersion != null && !specificationsVersion.trim().isEmpty())
175+
_specificationsVersion = specificationsVersion;
176+
}
177+
167178
/**
168179
* Returns the user-defined dictionaries.
169180
*/
@@ -415,7 +426,10 @@ else if (line.length() < expectedLineLength) {
415426
if (!_dictionaryFiles.isEmpty() && _dictionaryUris != null && !_dictionaryUris.trim().isEmpty())
416427
writer.write("\n userDictionaryUri=\"" + _dictionaryUris + "\"");
417428
writer.write("\n recordType=\"" + _recordType + "\"");
418-
writer.write("\n specificationVersion=\"1.7\"");
429+
if (_specificationsVersion != null)
430+
writer.write("\n specificationVersion=\"" + _specificationsVersion + "\"");
431+
else
432+
writer.write("\n specificationVersion=\"1.7\"");
419433
writer.write("\n xmlns=\"http://naaccr.org/naaccrxml\"");
420434
writer.write(">\n");
421435
for (Entry<String, SasFieldInfo> entry : rootFields.entrySet()) {

0 commit comments

Comments
 (0)