public class DicomSRValidator extends Object
The DicomSRValidator
class is
for validating SR instances against the standard IOD for the corresponding SOP Class,
as well as validating recognized templates and context groups.
The following IODs and SOP Classes are currently supported:
The following standard root Templates are currently supported:
In addition, some private non-standard templates are supported, such as the IHE Additional Teaching File Information template.
Template recognition is either by the Root Template that is specified for an IOD and SOP Class, or the presence of an encoded TemplateIdentifier Attribute Value on the Root CONTAINER Content Item.
Content Item constraints checks are also performed on the permissible Value Types and Relationship Types for the IOD.
The following command line options are supported by the main
method (if used as a command line utility):
describe
- turns on description of the details of the validation procedure step by stepdonotcheckcodemeaning
- turns off checking code meanings against the expected values in context groups and templatesdonotmatchcase
- turns off matching the case of code meanings when validating them against the expected values in context groups and templatesdonotcheckdeprecatedcodingscheme
- turns off warnings about use deprecated coding schemes (e.g., SRT instead of SCT)checkambiguoustemplate
- turns on warnings about ambiguous inclusion of templates (different templates match same content)checkcontentitemorder
- check if content item order does not match order in templates and report error if order significant for that template or warning otherwisechecktemplateid
- check if encoded Template ID on CONTAINERs match expected templatedonotcheckcontentitemsnotintemplate
- turns off warnings about content items not recognized as being in a templateThese command line options correspond to the parameters of the validate(String filename,boolean,boolean,boolean,boolean,boolean,boolean,boolean)
method.
The class is typically used by reading the list of attributes that comprise an object, validating them
and displaying the resulting string results to the user on the standard output, in a dialog
box or whatever. The basic implementation of the main
method is as follows:
AttributeList list = new AttributeList(); list.read(arg[0],null,true,true); DicomSRValidator validator = new DicomSRValidator(); System.err.print(validator.validate(list));
AttributeList
Constructor and Description |
---|
DicomSRValidator()
Create an instance of validator.
|
Modifier and Type | Method and Description |
---|---|
static void |
main(String[] arg)
Read the DICOM file specified on the command line and validate it against the standard IOD for the appropriate storage SOP Class.
|
void |
setOptionCheckAmbiguousTemplate(boolean option)
Whether or not to check and warn about ambiguous inclusion of templates (different templates match same content).
|
void |
setOptionCheckCodeMeaning(boolean option)
Whether or not to check the code meanings against the expected values in context groups and templates.
|
void |
setOptionCheckContentItemOrder(boolean option)
Whether or not to check and warn about content item order not matching order in templates.
|
void |
setOptionCheckDeprecatedCodingScheme(boolean option)
Whether or not to warn about the use of deprecated coding schemes.
|
void |
setOptionCheckTemplateID(boolean option)
Whether or not to check if encoded Template ID on CONTAINERs match expected template.
|
void |
setOptionDescribeChecking(boolean option)
Whether or not to describe the details of the validation procedure step by step.
|
void |
setOptionMatchCaseOfCodeMeaning(boolean option)
Whether or not to match the case of code meanings when validating them against the expected values in context groups and templates.
|
void |
setOptionReportContentItemsNotInTemplate(boolean option)
Whether or not to check and warn about content items not recognized as being in a template.
|
String |
validate(AttributeList list)
Validate a DICOM SR instance against the standard IOD for the appropriate SOP Class and templates.
|
String |
validate(AttributeList list,
boolean describe,
boolean checkCodeMeaning,
boolean checkMatchingCaseOfCodeMeaning,
boolean checkDeprecatedCodingScheme,
boolean checkAmbiguousTemplate,
boolean checkContentItemOrder,
boolean checkTemplateID,
boolean checkContentItemsNotInTemplate)
Validate a DICOM SR instance against the standard IOD for the appropriate SOP Class and templates.
|
String |
validate(String filename)
Validate a DICOM SR instance against the standard IOD for the appropriate SOP Class and templates.
|
String |
validate(String filename,
boolean describe,
boolean checkCodeMeaning,
boolean checkMatchingCaseOfCodeMeaning,
boolean checkDeprecatedCodingScheme,
boolean checkAmbiguousTemplate,
boolean checkContentItemOrder,
boolean checkTemplateID,
boolean checkContentItemsNotInTemplate)
Validate a DICOM SR instance against the standard IOD for the appropriate SOP Class and templates.
|
protected String |
validateFirstPass(Document inputDocument)
Perform the first pass of the validation.
|
protected String |
validateSecondPass(Document inputDocument,
String firstOutputString)
Perform the second pass of the validation.
|
public DicomSRValidator() throws TransformerConfigurationException
Create an instance of validator.
Once created, a validator may be reused for as many validations as desired.
public static void main(String[] arg)
Read the DICOM file specified on the command line and validate it against the standard IOD for the appropriate storage SOP Class.
The result of the validation is printed to the standard output.
arg
- optionally -describe, -donotcheckcodemeaning, -donotmatchcase, -donotcheckdeprecatedcodingscheme, -checkambiguoustemplate, -checkcontentitemorder, -checktemplateid, then the name of the file containing the DICOM SR instance to be validatedpublic void setOptionCheckAmbiguousTemplate(boolean option)
Whether or not to check and warn about ambiguous inclusion of templates (different templates match same content).
Default after construction is false, i.e., not to check.
option
- true if checkingpublic void setOptionCheckCodeMeaning(boolean option)
Whether or not to check the code meanings against the expected values in context groups and templates.
Default after construction is true, i.e., to check.
option
- true if matching is to be case sensitivepublic void setOptionCheckContentItemOrder(boolean option)
Whether or not to check and warn about content item order not matching order in templates.
The check reports errors if order deemed significant in template definition otherwise warnings.
May emit spurious warnings if template invocation is ambiguous (different templates match same content) and content item order is different in any of the matching templates.
Default after construction is false, i.e., not to check.
option
- true if checkingpublic void setOptionCheckDeprecatedCodingScheme(boolean option)
Whether or not to warn about the use of deprecated coding schemes.
Default after construction is true, i.e., to check.
option
- true if checkingpublic void setOptionCheckTemplateID(boolean option)
Whether or not to check if encoded Template ID on CONTAINERs match expected template.
May emit spurious warnings if template invocation is ambiguous (different templates match same content).
The explicitly encoded Template ID is NOT used to constrain template matching.
Default after construction is false, i.e., not to check.
option
- true if checkingpublic void setOptionDescribeChecking(boolean option)
Whether or not to describe the details of the validation procedure step by step.
Default after construction is not to.
option
- true if the steps are to be describedpublic void setOptionMatchCaseOfCodeMeaning(boolean option)
Whether or not to match the case of code meanings when validating them against the expected values in context groups and templates.
Default after construction is true, i.e., to be case sensitive.
option
- true if matching is to be case sensitivepublic void setOptionReportContentItemsNotInTemplate(boolean option)
Whether or not to check and warn about content items not recognized as being in a template.
Default after construction is true, i.e., to report.
option
- true if reportingpublic String validate(AttributeList list) throws ParserConfigurationException, TransformerException, UnsupportedEncodingException, IOException
Validate a DICOM SR instance against the standard IOD for the appropriate SOP Class and templates.
Does not describe the details of the validation procedure step by step, and does match the case of code meanings when validating them against the expected values in context groups and templates.
list
- the list of attributes comprising the DICOM SR instance to be validatedParserConfigurationException
TransformerException
UnsupportedEncodingException
IOException
public String validate(AttributeList list, boolean describe, boolean checkCodeMeaning, boolean checkMatchingCaseOfCodeMeaning, boolean checkDeprecatedCodingScheme, boolean checkAmbiguousTemplate, boolean checkContentItemOrder, boolean checkTemplateID, boolean checkContentItemsNotInTemplate) throws ParserConfigurationException, TransformerException, UnsupportedEncodingException, IOException
Validate a DICOM SR instance against the standard IOD for the appropriate SOP Class and templates.
list
- the list of attributes comprising the DICOM SR instance to be validateddescribe
- whether or not to describe the details of the validation procedure step by stepcheckCodeMeaning
- whether or not to check the code meanings against the expected values in context groups and templatescheckMatchingCaseOfCodeMeaning
- whether or not to match the case of code meanings when validating them against the expected values in context groups and templatescheckDeprecatedCodingScheme
- whether or not to warn about the use of deprecated coding schemescheckAmbiguousTemplate
- whether or not to check and warn about ambiguous inclusion of templates (different templates match same content)checkContentItemOrder
- whether or not to check and report content item order not matching order in templatescheckTemplateID
- whether or not to check if encoded Template ID on CONTAINERs match expected templatecheckContentItemsNotInTemplate
- whether or not to warn about content items not recognized as being in a templateParserConfigurationException
TransformerException
UnsupportedEncodingException
IOException
public String validate(String filename) throws ParserConfigurationException, TransformerException, UnsupportedEncodingException, IOException, DicomException
Validate a DICOM SR instance against the standard IOD for the appropriate SOP Class and templates.
Does not describe the details of the validation procedure step by step, and does match the case of code meanings when validating them against the expected values in context groups and templates.
filename
- the DICOM SR instance to be validatedParserConfigurationException
TransformerException
UnsupportedEncodingException
IOException
DicomException
public String validate(String filename, boolean describe, boolean checkCodeMeaning, boolean checkMatchingCaseOfCodeMeaning, boolean checkDeprecatedCodingScheme, boolean checkAmbiguousTemplate, boolean checkContentItemOrder, boolean checkTemplateID, boolean checkContentItemsNotInTemplate) throws ParserConfigurationException, TransformerException, UnsupportedEncodingException, IOException, DicomException
Validate a DICOM SR instance against the standard IOD for the appropriate SOP Class and templates.
filename
- the DICOM SR instance to be validateddescribe
- whether or not to describe the details of the validation procedure step by stepcheckCodeMeaning
- whether or not to check the code meanings gainst the expected values in context groups and templatescheckMatchingCaseOfCodeMeaning
- whether or not to match the case of code meanings when validating them against the expected values in context groups and templatescheckDeprecatedCodingScheme
- whether or not to warn about the use of deprecated coding schemescheckAmbiguousTemplate
- whether or not to check and warn about ambiguous inclusion of templates (different templates match same content)checkContentItemOrder
- whether or not to check and report content item order not matching order in templatescheckTemplateID
- whether or not to check if encoded Template ID on CONTAINERs match expected templatecheckContentItemsNotInTemplate
- whether or not to warn about content items not recognized as being in a templateParserConfigurationException
TransformerException
UnsupportedEncodingException
IOException
DicomException
protected String validateFirstPass(Document inputDocument) throws ParserConfigurationException, TransformerException, UnsupportedEncodingException
Perform the first pass of the validation.
Checks the document against the stylesheet and tracks which nodes matched templates.
inputDocument
- the XML representation of the DICOM SR instance to be validatedParserConfigurationException
TransformerException
UnsupportedEncodingException
protected String validateSecondPass(Document inputDocument, String firstOutputString) throws ParserConfigurationException, TransformerException, UnsupportedEncodingException, IOException
Perform the second pass of the validation.
Checks for unused content items.
inputDocument
- the XML representation of the DICOM SR instance to be validatedfirstOutputString
- the text output of the first validation pass that contains a list of items found in the first passParserConfigurationException
TransformerException
UnsupportedEncodingException
IOException