...
 
Commits (3)
......@@ -23,6 +23,7 @@ import org.aktin.cda.etl.transform.Transformation;
import org.aktin.cda.etl.transform.TransformationFactory;
import org.aktin.dwh.Anonymizer;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import de.sekmi.histream.Observation;
import de.sekmi.histream.ObservationFactory;
......@@ -114,7 +115,8 @@ public abstract class AbstractCDAImporter implements CDAProcessor{
@Override
public final Path transform(Document document, String templateId) throws CDAException, UnsupportedTemplateException{
try {
Transformation t = cdaToDataWarehouse.getTransformation(templateId);
Element rootEl = (Element)document.getDocumentElement();
Transformation t = cdaToDataWarehouse.getTransformation(rootEl.getNamespaceURI(), rootEl.getLocalName(), templateId);
if( t == null ){
throw new UnsupportedTemplateException(templateId);
}
......
......@@ -113,7 +113,7 @@ public class TransformationFactory {
public Anonymizer getAnonymizer() {
return anonymizer;
}
public Transformation getTransformation(String templateId) throws IOException, TransformerConfigurationException, TransformerFactoryConfigurationError{
public Transformation getTransformation(String documentRootNS, String documentRootName, String templateId) throws IOException, TransformerConfigurationException, TransformerFactoryConfigurationError{
// look in cache
Transformation transform = cache.get(templateId);
if( transform == null ){
......
......@@ -53,7 +53,7 @@ public class TestTransformToEAV {
public void transformExample1() throws Exception{
CDAParser parser = new CDAParser();
CDAImporterMockUp t = new CDAImporterMockUp();
try( InputStream in = CDAParser.class.getResourceAsStream("/Additional Examples/basismodul-v2-beispiel-storyboard01-complete.xml") ){
try( InputStream in = CDAParser.class.getResourceAsStream("/basismodul-minimal.xml") ){
Document dom = parser.buildDOM(new StreamSource(in));
......@@ -65,7 +65,8 @@ public class TestTransformToEAV {
// verify patient birth date
Patient p = o.getExtension(Patient.class);
Assert.assertNotNull(p);
Assert.assertEquals(DateTimeAccuracy.parsePartialIso8601("1996-05-31", t.getDefaultZoneId()), p.getBirthDate());
// no birthdate should be available
Assert.assertNull(p.getBirthDate());
// verify visit start date
Visit v = o.getExtension(Visit.class);
Assert.assertNotNull(v);
......@@ -76,7 +77,7 @@ public class TestTransformToEAV {
Optional<Observation> opt = suppl.stream().filter(x -> x.getConceptId().equals("ICD10GM:S80.1")).findFirst();
Assert.assertTrue(opt.isPresent());
o = opt.get();
Assert.assertEquals(DateTimeAccuracy.parsePartialIso8601("2015-01-17T15:56+0100"), o.getStartTime());
Assert.assertEquals(DateTimeAccuracy.parsePartialIso8601("2015-01-17T16:03+0100"), o.getStartTime());
suppl.close();
}finally{
......
......@@ -13,7 +13,7 @@ public class TestTransformationLoader {
f.setAnonymizer(new ConcatAnonymizer());
//XMLStreamReader xsr = inputFactory.createXMLStreamReader(getClass().getResourceAsStream("/cda-eav.xsl"));
// InputSource input = new InputSource(getClass().getResourceAsStream("/cda-eav.xsl"));
Transformation t = f.getTransformation("1.2.276.0.76.10.1019");
Transformation t = f.getTransformation("...", "ClinicalDocument", "1.2.276.0.76.10.1019");
Assert.assertNotNull(t);
System.out.println("template="+t.getTemplateId());
System.out.println("module="+t.getModuleId());
......
This diff is collapsed.
......@@ -77,7 +77,7 @@
<dependency>
<groupId>org.aktin</groupId>
<artifactId>dwh-api</artifactId>
<version>0.4</version>
<version>0.5-SNAPSHOT</version>
</dependency>
<!-- dependency injection -->
......
......@@ -161,13 +161,13 @@ public class Binary implements ExternalInterface{
location = URI.create("Binary/"+stat.getDocumentId()+"/_history/0");
response = Response.created(location);
hallihallo2.addCreated();
hallihallo2.addCreated(templateId);
importSuccessful = true;
}else if( stat.getStatus() == Status.Updated ){
response = Response.ok();
location = URI.create("Binary/"+stat.getDocumentId());
// Location header not allowed for status 200
hallihallo2.addUpdated();
hallihallo2.addUpdated(templateId);
importSuccessful = true;
}else if( stat.getStatus() == Status.Rejected ) {
response = Response.status(409); // HTTP conflict
......@@ -211,7 +211,7 @@ public class Binary implements ExternalInterface{
// should add a Location header with the created id and version
// Location: [base]/Binary/[id]/_history/[vid]
if( false == importSuccessful ){
hallihallo2.addRejected(isValid, outcome.toString());
hallihallo2.addRejected(templateId, isValid, outcome.toString());
}
if( cda != null ){
tryDebugProcessing(cda, outcome);
......
......@@ -19,5 +19,9 @@ public class ValidationErrorsToOperationOutcome implements ValidationErrorHandle
public void error(String message, Throwable cause) {
outcome.addIssue(Severity.error, IssueType.exception, message);
}
@Override
public void info(String message) {
outcome.addIssue(Severity.information, IssueType.informational, message);
}
}
......@@ -17,7 +17,7 @@ public class ValidationErrorsToRegistryError implements ValidationErrorHandler{
e.setSeverity(XDSConstants.SEVERITY_WARNING);
e.setCodeContext(message); // free error message
e.setErrorCode(XDSConstants.ERR_DOC_INVALID_CONTENT);
rel.getRegistryError().add(e);
rel.getRegistryError().add(e);
}
@Override
......@@ -26,7 +26,15 @@ public class ValidationErrorsToRegistryError implements ValidationErrorHandler{
e.setSeverity(XDSConstants.SEVERITY_ERROR);
e.setCodeContext(message); // free error message
e.setErrorCode(XDSConstants.ERR_DOC_INVALID_CONTENT);
rel.getRegistryError().add(e);
rel.getRegistryError().add(e);
}
@Override
public void info(String message) {
RegistryError e = new RegistryError();
e.setSeverity(XDSConstants.SEVERITY_WARNING);
e.setCodeContext(message); // free error message
e.setErrorCode(XDSConstants.ERR_DOC_INVALID_CONTENT);
rel.getRegistryError().add(e);
}
}
......@@ -12,8 +12,8 @@
<version>0.13-SNAPSHOT</version>
</parent>
<properties>
<schematronVersion>20170302T140447</schematronVersion>
<examplesVersion>20170105T160149</examplesVersion>
<schematronVersion>20180323T201638</schematronVersion>
<examplesVersion>20180322T121703</examplesVersion>
<schematronArchive>aktin-runtime-${schematronVersion}</schematronArchive>
<examplesArchive>aktin-xml-${examplesVersion}</examplesArchive>
</properties>
......
......@@ -4,5 +4,6 @@ public interface ValidationErrorHandler {
void warning(String message, Throwable cause);
void error(String message, Throwable cause);
void info(String message);
}
......@@ -10,7 +10,8 @@ public class ValidationErrorPrinter implements ValidationErrorHandler {
private String systemId;
@Override
public void warning(String message, Throwable cause) {
System.err.println("Validation warning for "+systemId);
System.err.print("Validation WARNING for "+systemId+": ");
System.err.println(message);
if( cause != null ){
cause.printStackTrace();
}
......@@ -18,7 +19,8 @@ public class ValidationErrorPrinter implements ValidationErrorHandler {
@Override
public void error(String message, Throwable cause) {
System.err.println("Validation ERROR for "+systemId);
System.err.print("Validation ERROR for "+systemId+": ");
System.err.println(message);
if( cause != null ){
cause.printStackTrace();
}
......@@ -26,4 +28,10 @@ public class ValidationErrorPrinter implements ValidationErrorHandler {
public void setSystemId(String systemId){
this.systemId = systemId;
}
@Override
public void info(String message) {
System.err.print("Validation INFO for "+systemId+": ");
System.err.println(message);
}
}
......@@ -70,7 +70,7 @@ public class Validator implements NamespaceContext{
} catch (XPathExpressionException e) {
throw new IOException(e);
}
addTemplateValidator("1.2.276.0.76.10.1015", "/aktin-basism_svrl.xsl");
//addTemplateValidator("1.2.276.0.76.10.1015", "/aktin-basism_svrl.xsl");
addTemplateValidator("1.2.276.0.76.10.1019", "/aktin-basism20152b_svrl.xsl");
}
......@@ -112,11 +112,14 @@ public class Validator implements NamespaceContext{
errorCount ++;
handler.error(messageText, null);
break;
case "info":
handler.info(messageText);
break;
default:
log.warning("Unexpected failed-assert/@role="+role);
// fall through to warning
case "warning":
handler.error(messageText, null);
handler.warning(messageText, null);
}
}
return errorCount;
......
......@@ -12,4 +12,7 @@ public class SuppressValidationErrors implements ValidationErrorHandler{
@Override
public void error(String message, Throwable cause) {
}
@Override
public void info(String message) {
}
}
\ No newline at end of file
......@@ -15,6 +15,7 @@ public class TestValidator {
public static final String[] v2ExampleDocuments = new String[]{
"/Additional Examples/basismodul-v2-beispiel-storyboard01-complete.xml",
"/Additional Examples/basismodul-v2-beispiel-storyboard01-minimal.xml",
"/CDA Beispiele Basis-Modul v2/basismodul-v2-beispiel-storyboard01.xml",
"/CDA Beispiele Basis-Modul v2/basismodul-v2-beispiel-storyboard02.xml",
"/CDA Beispiele Basis-Modul v2/basismodul-v2-beispiel-storyboard04.xml",
......@@ -63,27 +64,29 @@ public class TestValidator {
Assert.assertFalse("Validation failure expected for "+example, isValid);
}
}
for( String example : v1InvalidExampleDocuments ){
p.setSystemId(example);
try( InputStream in = getClass().getResourceAsStream(example) ){
Assert.assertTrue(in.available() > 0);
boolean isValid = v.validate(parser.buildDOM(new StreamSource(in)), v1TemplateId, SuppressValidationErrors.staticInstance);
Assert.assertFalse("Validation failure expected for "+example, isValid);
}
}
for( String example : v1ExampleDocuments ){
p.setSystemId(example);
try( InputStream in = getClass().getResourceAsStream(example) ){
Assert.assertTrue(in.available() > 0);
boolean isValid = v.validate(parser.buildDOM(new StreamSource(in)), v1TemplateId, p);
if( !isValid ){
Assert.fail("Successful validation expected for "+example);
}
}
}
// v1 no longer supported
// for( String example : v1InvalidExampleDocuments ){
// p.setSystemId(example);
// try( InputStream in = getClass().getResourceAsStream(example) ){
// Assert.assertTrue(in.available() > 0);
// boolean isValid = v.validate(parser.buildDOM(new StreamSource(in)), v1TemplateId, SuppressValidationErrors.staticInstance);
// Assert.assertFalse("Validation failure expected for "+example, isValid);
// }
// }
// for( String example : v1ExampleDocuments ){
// p.setSystemId(example);
// try( InputStream in = getClass().getResourceAsStream(example) ){
// Assert.assertTrue(in.available() > 0);
// boolean isValid = v.validate(parser.buildDOM(new StreamSource(in)), v1TemplateId, p);
// if( !isValid ){
// Assert.fail("Successful validation expected for "+example);
// }
// }
// }
}
@Test
//@Test
public void validateErrorsForOtherDocuments() throws Exception{
Validator v = new Validator();
CDAParser parser = new CDAParser();
......
......@@ -59,5 +59,49 @@
<artifactId>cda-server</artifactId>
<version>0.13-SNAPSHOT</version>
</dependency>
<!-- dependencies accounting for java12 removal of javax.activation and jaxb -->
<dependency>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0.1</version>
</dependency>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>2.3.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>2.3.2</version>
<type>pom</type>
</dependency>
<!-- or
jaxws-rt and jaxws-tools?
-->
</dependencies>
</project>
\ No newline at end of file
......@@ -58,20 +58,21 @@ public class NoOpStatistics implements ImportSummary{
return null;
}
@Override
public void addRejected(boolean valid, String cause) {
public void addCreated(String templateId) {
// TODO Auto-generated method stub
}
@Override
public void addCreated() {
public void addRejected(String templateId, boolean valid, String cause) {
// TODO Auto-generated method stub
}
@Override
public void addUpdated() {
public void addUpdated(String templateId) {
// TODO Auto-generated method stub
}
......
......@@ -6,6 +6,7 @@ import java.net.InetSocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.Objects;
import java.util.logging.Logger;
import javax.xml.transform.TransformerConfigurationException;
......@@ -102,6 +103,7 @@ public class Server{
// publish XDS.b end point
Objects.requireNonNull(xdsService);
xdsEndpoint = Endpoint.create(SOAPBinding.SOAP11HTTP_MTOM_BINDING, xdsService);
xdsEndpoint.publish(server.createContext(XDS_CONTEXT_PATH));
// enable MTOM for efficient binary transfer
......