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

Updated project with changes since 2015 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 1 addition & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,2 @@
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

target
/CDAGenerator/.jrebel_disabled
/CDAGenerator/src/main/resources/testCDA.xml
63 changes: 55 additions & 8 deletions CDAGenerator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,71 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.fhg.isst.ehealth.cda</groupId>
<artifactId>CDAGenerator</artifactId>
<version>1.1.4</version>
<version>1.2.0</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<com.sun.xml.version>2.3.0</com.sun.xml.version>
</properties>

<repositories>
<repository>
<id>isst-artifactory</id>
<name>artifactory.isst.fraunhofer.de-releases</name>
<url>https://artifactory.isst.fraunhofer.de:443/artifactory/oe220-rzv-external-maven/</url>
</repository>
</repositories>
<distributionManagement>
<snapshotRepository>
<id>isst-artifactory</id>
<name>artifactory.isst.fraunhofer.de-snapshots</name>
<url>https://artifactory.isst.fraunhofer.de:443/artifactory/oe220-rzv-external-maven/</url>
</snapshotRepository>
<repository>
<id>isst-artifactory</id>
<name>artifactory.isst.fraunhofer.de-releases</name>
<url>https://artifactory.isst.fraunhofer.de:443/artifactory/oe220-rzv-external-maven/</url>
</repository>
</distributionManagement>

<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<!--//Java10?-->
<!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-impl -->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${com.sun.xml.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-core -->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>${com.sun.xml.version}</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${com.sun.xml.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

import de.fhg.isst.cda.classes.ClinicalStatement;
import de.fhg.isst.cda.classes.Code;
Expand All @@ -25,6 +26,9 @@ public class Observation extends ClinicalStatement {

/** The ids. */
private ArrayList<ID> ids;

/** The template ids */
private List<ID> templateId;

/** The code. */
private Code code;
Expand Down Expand Up @@ -111,10 +115,10 @@ public XActMoodDocumentObservation getMoodCode() {
public void setMoodCode(XActMoodDocumentObservation moodCode) {
this.moodCode = moodCode;
}

/**
* Gets the ids.
*
*
* @return the ids
*/
public ArrayList<ID> getIds() {
Expand All @@ -123,6 +127,13 @@ public ArrayList<ID> getIds() {
}
return ids;
}

public List<ID> getTemplateId() {
if (templateId==null){
templateId = new ArrayList<>();
}
return templateId;
}

/**
* Sets the ids.
Expand Down
76 changes: 57 additions & 19 deletions CDAGenerator/src/main/java/de/fhg/isst/cda/services/CDAService.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.hl7.v3.cda.*;
import org.xml.sax.SAXException;

Expand Down Expand Up @@ -116,6 +113,10 @@
import de.fhg.isst.cda.classes.Telecom;
import de.fhg.isst.cda.exceptions.MissingAttributeException;
import de.fhg.isst.cda.exceptions.MissingNodeException;
import java.io.Serializable;
import java.io.StringWriter;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Element;

// TODO: Auto-generated Javadoc
/**
Expand All @@ -129,22 +130,13 @@ public class CDAService {
/** The factory. */
private ObjectFactory factory;

private Logger logger;

/**
* Instantiates a new CDA Service.
*/
public CDAService() {
this.logger = LogManager.getLogger(CDAService.class.getName());
this.log4j();
}

private void log4j() {

PropertyConfigurator.configureAndWatch("log4j.properties");
this.factory = new ObjectFactory();
}

/**
* Save.
*
Expand Down Expand Up @@ -175,6 +167,43 @@ public void save(String xmlPath, CDADocument mapDocument) throws MissingAttribut
marshaller.marshal(saveDoc, os);
os.close();
}
/**
* Save.
*
* @param file
* @param mapDocument
* @throws MissingAttributeException
* @throws MissingNodeException
* @throws FileNotFoundException
* @throws JAXBException
* @throws IOException
*/
public void save(File file, CDADocument mapDocument)throws MissingAttributeException, MissingNodeException, FileNotFoundException,
JAXBException, IOException {
POCDMT000040ClinicalDocument saveDoc = this.generate(mapDocument);

OutputStream os = new FileOutputStream(file);
JAXBContext jaxbcontext = JAXBContext.newInstance(POCDMT000040ClinicalDocument.class);
Marshaller marshaller = jaxbcontext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

marshaller.marshal(saveDoc, os);
os.close();
}

public String getCdaString(CDADocument mapDocument)throws MissingAttributeException, MissingNodeException, FileNotFoundException,
JAXBException, IOException {
POCDMT000040ClinicalDocument saveDoc = this.generate(mapDocument);

StringWriter writer = new StringWriter();
JAXBContext jaxbcontext = JAXBContext.newInstance(POCDMT000040ClinicalDocument.class);
Marshaller marshaller = jaxbcontext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

marshaller.marshal(saveDoc, writer);

return writer.toString();
}

/**
* Prints the.
Expand Down Expand Up @@ -212,7 +241,6 @@ public void print(CDADocument mapDocument) throws MissingAttributeException, Mis
* @return true, if successful
*/
public boolean validate(String xsdPath, String xmlPath) {
this.logger.trace("Entering CDA Validation");
boolean state = false;
try {
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Expand All @@ -221,10 +249,8 @@ public boolean validate(String xsdPath, String xmlPath) {
validator.validate(new StreamSource(new File(xmlPath)));
state = true;
} catch (SAXException | IOException e) {
this.logger.error("CDA Validation Error");
this.logger.error(e.getMessage());
e.printStackTrace();
}
this.logger.trace("Exiting CDA Validation");
return state;
}

Expand Down Expand Up @@ -3287,6 +3313,13 @@ private POCDMT000040Observation createCDAObservation(Observation mapObservation)
}
}

if (!mapObservation.getTemplateId().isEmpty()){
for (ID templateId : mapObservation.getTemplateId())
{
cdaObservation.getTemplateId().add(createCDAId(templateId));
}
}

if (mapObservation.getCode() != null) {
cdaObservation.setCode(this.createCDACE(mapObservation.getCode()));
}
Expand Down Expand Up @@ -3334,10 +3367,15 @@ private POCDMT000040Observation createCDAObservation(Observation mapObservation)
}

if (mapObservation.getValue()!=null) {

if (mapObservation.getValue() instanceof String) {
ED mapObservationValue = factory.createED();
mapObservationValue.getContent().add((String)mapObservation.getValue());
String value = (String) mapObservation.getValue();
if(value.equals("CDA_CONSENT_SAML"))
{
mapObservationValue.setMediaType("text/xml");
mapObservationValue.setRepresentation(BinaryDataEncoding.TXT);
}
mapObservationValue.getContent().add(value);
cdaObservation.getValue().add(mapObservationValue);
}
else if (mapObservation.getValue() instanceof Code) {
Expand Down