Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAS param specs (#250) #255

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand Down
6 changes: 5 additions & 1 deletion docs/sas/macro/write_naaccr_xml_macro.sas
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
************************************************************************************************************/;

/*
Expand Down Expand Up @@ -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();
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/com/imsweb/naaccrxml/sas/SasCsvToXml.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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<String, String> entry : rootFields.entrySet()) {
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/com/imsweb/naaccrxml/sas/SasFlatToXml.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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<String, SasFieldInfo> entry : rootFields.entrySet()) {
Expand Down
Loading