Commit 1f44cbb6 authored by R.W.Majeed's avatar R.W.Majeed

generalize xml transformation lookup to include root ns and element,

test case for no birthdate
parent fdc22f9b
......@@ -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);
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment