diff --git a/src/main/java/org/projecthusky/codegenerator/CdaAtEmsCodeGenerator.java b/src/main/java/org/projecthusky/codegenerator/CdaAtEmsCodeGenerator.java new file mode 100644 index 0000000..eabfdce --- /dev/null +++ b/src/main/java/org/projecthusky/codegenerator/CdaAtEmsCodeGenerator.java @@ -0,0 +1,90 @@ +/* + * This code is made available under the terms of the Eclipse Public License v1.0 + * in the github project https://github.com/project-husky/husky there you also + * find a list of the contributors and the license information. + * + * This project has been developed further and modified by the joined working group Husky + * on the basis of the eHealth Connector opensource project from June 28, 2021, + * whereas medshare GmbH is the initial and main contributor/author of the eHealth Connector. + */ +package org.projecthusky.codegenerator; + +import java.io.File; + +import org.projecthusky.codegenerator.cda.ArtDecor2JavaGenerator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Entry point of the CDA-EMS code generator. + * + * @author Quentin Ligier + * @author Anna Jungwirth + */ +public class CdaAtEmsCodeGenerator { + + /** + * CDA-EMS package config, v2020 + */ + private static final String CDAEMS_PACKAGE_CONFIG = "src/main/resources/cda/ContentProfilePackageConfigCdaAtEmsV2020.yml"; + + /** + * The logger. + */ + protected static final Logger LOG = LoggerFactory.getLogger(CdaAtEmsCodeGenerator.class); + + /** + * The main entry for the ART-DECOR to Java Code Generator. + * + * @param args Command line arguments. A single value is expected. + */ + public static void main(final String[] args) { + LOG.info("Update CDA-EMS classes and enums"); + + if (args.length != 1) { + printUsage(null); + return; + } + + final String javaSourceDirString = args[0]; + final File javaSourceDir = new File(javaSourceDirString); + if (!javaSourceDir.exists()) { + LOG.error("Java source directory does not exist ({})", javaSourceDirString); + printUsage(javaSourceDirString); + return; + } else if (!javaSourceDir.isDirectory()) { + LOG.error("Java source is not a directory ({})", javaSourceDirString); + printUsage(javaSourceDirString); + return; + } + final var cdaSourceDirString = javaSourceDirString + "/husky-cda/husky-elga/"; + final File cdaSourceDir = new File(cdaSourceDirString); + if (!cdaSourceDir.exists()) { + LOG.error("Java source directory does not exist ({})", cdaSourceDirString); + printUsage(javaSourceDirString); + return; + } else if (!cdaSourceDir.isDirectory()) { + LOG.error("Java source is not a directory ({})", cdaSourceDirString); + printUsage(javaSourceDirString); + return; + } + + final File packageConfig = new File(CDAEMS_PACKAGE_CONFIG); + if (!packageConfig.exists() || !packageConfig.isFile()) { + LOG.error("The package config file doesn't exist ({})", packageConfig.getAbsolutePath()); + printUsage(javaSourceDirString); + } + + ArtDecor2JavaGenerator.generate(cdaSourceDir, packageConfig); + } + + /** + * Prints the application usage. + */ + private static void printUsage(String javaSourceDir) { + LOG.info("Usage:"); + LOG.info("CdaAtEmsCodeGenerator "); + LOG.info(" javaSourceDir: This parameter must be the path to the Husky project " + + "directory: {}", javaSourceDir); + } +} diff --git a/src/main/java/org/projecthusky/codegenerator/CdaElgaEMedCodeGenerator.java b/src/main/java/org/projecthusky/codegenerator/CdaElgaEMedCodeGenerator.java new file mode 100644 index 0000000..35e59da --- /dev/null +++ b/src/main/java/org/projecthusky/codegenerator/CdaElgaEMedCodeGenerator.java @@ -0,0 +1,90 @@ +/* + * This code is made available under the terms of the Eclipse Public License v1.0 + * in the github project https://github.com/project-husky/husky there you also + * find a list of the contributors and the license information. + * + * This project has been developed further and modified by the joined working group Husky + * on the basis of the eHealth Connector opensource project from June 28, 2021, + * whereas medshare GmbH is the initial and main contributor/author of the eHealth Connector. + */ +package org.projecthusky.codegenerator; + +import java.io.File; + +import org.projecthusky.codegenerator.cda.ArtDecor2JavaGenerator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Entry point of the CDA-ELGA code generator. + * + * @author Quentin Ligier + * @author Anna Jungwirth + */ +public class CdaElgaEMedCodeGenerator { + + /** + * CDA-ELGA package config, v2020 + */ + private static final String CDAELGAMED_PACKAGE_CONFIG = "src/main/resources/cda/ContentProfilePackageConfigCdaElgaEMedV2014.yml"; + + /** + * The logger. + */ + protected static final Logger LOG = LoggerFactory.getLogger(CdaElgaEMedCodeGenerator.class); + + /** + * The main entry for the ART-DECOR to Java Code Generator. + * + * @param args Command line arguments. A single value is expected. + */ + public static void main(final String[] args) { + LOG.info("Update CDA-ELGA classes and enums"); + + if (args.length != 1) { + printUsage(null); + return; + } + + final String javaSourceDirString = args[0]; + final File javaSourceDir = new File(javaSourceDirString); + if (!javaSourceDir.exists()) { + LOG.error("Java source directory does not exist ({})", javaSourceDirString); + printUsage(javaSourceDirString); + return; + } else if (!javaSourceDir.isDirectory()) { + LOG.error("Java source is not a directory ({})", javaSourceDirString); + printUsage(javaSourceDirString); + return; + } + final var cdaSourceDirString = javaSourceDirString + "/husky-cda/husky-elga/"; + final File cdaSourceDir = new File(cdaSourceDirString); + if (!cdaSourceDir.exists()) { + LOG.error("Java source directory does not exist ({})", cdaSourceDirString); + printUsage(javaSourceDirString); + return; + } else if (!cdaSourceDir.isDirectory()) { + LOG.error("Java source is not a directory ({})", cdaSourceDirString); + printUsage(javaSourceDirString); + return; + } + + final File packageConfig = new File(CDAELGAMED_PACKAGE_CONFIG); + if (!packageConfig.exists() || !packageConfig.isFile()) { + LOG.error("The package config file doesn't exist ({})", packageConfig.getAbsolutePath()); + printUsage(javaSourceDirString); + } + + ArtDecor2JavaGenerator.generate(cdaSourceDir, packageConfig); + } + + /** + * Prints the application usage. + */ + private static void printUsage(String javaSourceDir) { + LOG.info("Usage:"); + LOG.info("CdaElgaEMedCodeGenerator "); + LOG.info(" javaSourceDir: This parameter must be the path to the Husky project " + + "directory: {}", javaSourceDir); + } +} diff --git a/src/main/java/org/projecthusky/codegenerator/CdaElgaImpfCodeGenerator.java b/src/main/java/org/projecthusky/codegenerator/CdaElgaImpfCodeGenerator.java new file mode 100644 index 0000000..40307d2 --- /dev/null +++ b/src/main/java/org/projecthusky/codegenerator/CdaElgaImpfCodeGenerator.java @@ -0,0 +1,90 @@ +/* + * This code is made available under the terms of the Eclipse Public License v1.0 + * in the github project https://github.com/project-husky/husky there you also + * find a list of the contributors and the license information. + * + * This project has been developed further and modified by the joined working group Husky + * on the basis of the eHealth Connector opensource project from June 28, 2021, + * whereas medshare GmbH is the initial and main contributor/author of the eHealth Connector. + */ +package org.projecthusky.codegenerator; + +import java.io.File; + +import org.projecthusky.codegenerator.cda.ArtDecor2JavaGenerator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Entry point of the CDA-ELGA-IMPF code generator. + * + * @author Quentin Ligier + * @author Anna Jungwirth + */ +public class CdaElgaImpfCodeGenerator { + + /** + * CDA-ELGA-IMPF package config, v2020 + */ + private static final String CDAELGAIMPF_PACKAGE_CONFIG = "src/main/resources/cda/ContentProfilePackageConfigCdaElgaImpfV2022.yml"; + + /** + * The logger. + */ + protected static final Logger LOG = LoggerFactory.getLogger(CdaElgaImpfCodeGenerator.class); + + /** + * The main entry for the ART-DECOR to Java Code Generator. + * + * @param args Command line arguments. A single value is expected. + */ + public static void main(final String[] args) { + LOG.info("Update CDA-ELGA classes and enums"); + + if (args.length != 1) { + printUsage(null); + return; + } + + final String javaSourceDirString = args[0]; + final File javaSourceDir = new File(javaSourceDirString); + if (!javaSourceDir.exists()) { + LOG.error("Java source directory does not exist ({})", javaSourceDirString); + printUsage(javaSourceDirString); + return; + } else if (!javaSourceDir.isDirectory()) { + LOG.error("Java source is not a directory ({})", javaSourceDirString); + printUsage(javaSourceDirString); + return; + } + final var cdaSourceDirString = javaSourceDirString + "/husky-cda/husky-elga/"; + final File cdaSourceDir = new File(cdaSourceDirString); + if (!cdaSourceDir.exists()) { + LOG.error("Java source directory does not exist ({})", cdaSourceDirString); + printUsage(javaSourceDirString); + return; + } else if (!cdaSourceDir.isDirectory()) { + LOG.error("Java source is not a directory ({})", cdaSourceDirString); + printUsage(javaSourceDirString); + return; + } + + final File packageConfig = new File(CDAELGAIMPF_PACKAGE_CONFIG); + if (!packageConfig.exists() || !packageConfig.isFile()) { + LOG.error("The package config file doesn't exist ({})", packageConfig.getAbsolutePath()); + printUsage(javaSourceDirString); + } + + ArtDecor2JavaGenerator.generate(cdaSourceDir, packageConfig); + } + + /** + * Prints the application usage. + */ + private static void printUsage(String javaSourceDir) { + LOG.info("Usage:"); + LOG.info("CdaElgaImpfCodeGenerator "); + LOG.info(" javaSourceDir: This parameter must be the path to the Husky project " + + "directory: {}", javaSourceDir); + } +} diff --git a/src/main/java/org/projecthusky/codegenerator/CdaElgaLabCodeGenerator.java b/src/main/java/org/projecthusky/codegenerator/CdaElgaLabCodeGenerator.java new file mode 100644 index 0000000..a1677c0 --- /dev/null +++ b/src/main/java/org/projecthusky/codegenerator/CdaElgaLabCodeGenerator.java @@ -0,0 +1,90 @@ +/* + * This code is made available under the terms of the Eclipse Public License v1.0 + * in the github project https://github.com/project-husky/husky there you also + * find a list of the contributors and the license information. + * + * This project has been developed further and modified by the joined working group Husky + * on the basis of the eHealth Connector opensource project from June 28, 2021, + * whereas medshare GmbH is the initial and main contributor/author of the eHealth Connector. + */ +package org.projecthusky.codegenerator; + +import java.io.File; + +import org.projecthusky.codegenerator.cda.ArtDecor2JavaGenerator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Entry point of the CDA-ELGA code generator. + * + * @author Quentin Ligier + * @author Anna Jungwirth + */ +public class CdaElgaLabCodeGenerator { + + /** + * CDA-ELGA package config, v2020 + */ + private static final String CDAELGALAB_PACKAGE_CONFIG = "src/main/resources/cda/ContentProfilePackageConfigCdaElgaLabV2013.yml"; + + /** + * The logger. + */ + protected static final Logger LOG = LoggerFactory.getLogger(CdaElgaLabCodeGenerator.class); + + /** + * The main entry for the ART-DECOR to Java Code Generator. + * + * @param args Command line arguments. A single value is expected. + */ + public static void main(final String[] args) { + LOG.info("Update CDA-ELGA classes and enums"); + + if (args.length != 1) { + printUsage(null); + return; + } + + final String javaSourceDirString = args[0]; + final File javaSourceDir = new File(javaSourceDirString); + if (!javaSourceDir.exists()) { + LOG.error("Java source directory does not exist ({})", javaSourceDirString); + printUsage(javaSourceDirString); + return; + } else if (!javaSourceDir.isDirectory()) { + LOG.error("Java source is not a directory ({})", javaSourceDirString); + printUsage(javaSourceDirString); + return; + } + final var cdaSourceDirString = javaSourceDirString + "/husky-cda/husky-elga/"; + final File cdaSourceDir = new File(cdaSourceDirString); + if (!cdaSourceDir.exists()) { + LOG.error("Java source directory does not exist ({})", cdaSourceDirString); + printUsage(javaSourceDirString); + return; + } else if (!cdaSourceDir.isDirectory()) { + LOG.error("Java source is not a directory ({})", cdaSourceDirString); + printUsage(javaSourceDirString); + return; + } + + final File packageConfig = new File(CDAELGALAB_PACKAGE_CONFIG); + if (!packageConfig.exists() || !packageConfig.isFile()) { + LOG.error("The package config file doesn't exist ({})", packageConfig.getAbsolutePath()); + printUsage(javaSourceDirString); + } + + ArtDecor2JavaGenerator.generate(cdaSourceDir, packageConfig); + } + + /** + * Prints the application usage. + */ + private static void printUsage(String javaSourceDir) { + LOG.info("Usage:"); + LOG.info("CdaElgaLabCodeGenerator "); + LOG.info(" javaSourceDir: This parameter must be the path to the Husky project " + + "directory: {}", javaSourceDir); + } +} diff --git a/src/main/java/org/projecthusky/codegenerator/CdaElgaPatientSummaryCodeGenerator.java b/src/main/java/org/projecthusky/codegenerator/CdaElgaPatientSummaryCodeGenerator.java new file mode 100644 index 0000000..de625fd --- /dev/null +++ b/src/main/java/org/projecthusky/codegenerator/CdaElgaPatientSummaryCodeGenerator.java @@ -0,0 +1,90 @@ +/* + * This code is made available under the terms of the Eclipse Public License v1.0 + * in the github project https://github.com/project-husky/husky there you also + * find a list of the contributors and the license information. + * + * This project has been developed further and modified by the joined working group Husky + * on the basis of the eHealth Connector opensource project from June 28, 2021, + * whereas medshare GmbH is the initial and main contributor/author of the eHealth Connector. + */ +package org.projecthusky.codegenerator; + +import java.io.File; + +import org.projecthusky.codegenerator.cda.ArtDecor2JavaGenerator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Entry point of the CDA-ELGA code generator. + * + * @author Quentin Ligier + * @author Anna Jungwirth + */ +public class CdaElgaPatientSummaryCodeGenerator { + + /** + * CDA-ELGA package config, v2020 + */ + private static final String CDAELGAPATSUMMARY_PACKAGE_CONFIG = "src/main/resources/cda/ContentProfilePackageConfigCdaElgaPatientSummaryV2016.yml"; + + /** + * The logger. + */ + protected static final Logger LOG = LoggerFactory.getLogger(CdaElgaPatientSummaryCodeGenerator.class); + + /** + * The main entry for the ART-DECOR to Java Code Generator. + * + * @param args Command line arguments. A single value is expected. + */ + public static void main(final String[] args) { + LOG.info("Update CDA-ELGA classes and enums"); + + if (args.length != 1) { + printUsage(null); + return; + } + + final String javaSourceDirString = args[0]; + final File javaSourceDir = new File(javaSourceDirString); + if (!javaSourceDir.exists()) { + LOG.error("Java source directory does not exist ({})", javaSourceDirString); + printUsage(javaSourceDirString); + return; + } else if (!javaSourceDir.isDirectory()) { + LOG.error("Java source is not a directory ({})", javaSourceDirString); + printUsage(javaSourceDirString); + return; + } + final var cdaSourceDirString = javaSourceDirString + "/husky-cda/husky-elga/"; + final File cdaSourceDir = new File(cdaSourceDirString); + if (!cdaSourceDir.exists()) { + LOG.error("Java source directory does not exist ({})", cdaSourceDirString); + printUsage(javaSourceDirString); + return; + } else if (!cdaSourceDir.isDirectory()) { + LOG.error("Java source is not a directory ({})", cdaSourceDirString); + printUsage(javaSourceDirString); + return; + } + + final File packageConfig = new File(CDAELGAPATSUMMARY_PACKAGE_CONFIG); + if (!packageConfig.exists() || !packageConfig.isFile()) { + LOG.error("The package config file doesn't exist ({})", packageConfig.getAbsolutePath()); + printUsage(javaSourceDirString); + } + + ArtDecor2JavaGenerator.generate(cdaSourceDir, packageConfig); + } + + /** + * Prints the application usage. + */ + private static void printUsage(String javaSourceDir) { + LOG.info("Usage:"); + LOG.info("CdaElgaPatientSummaryCodeGenerator "); + LOG.info(" javaSourceDir: This parameter must be the path to the Husky project " + + "directory: {}", javaSourceDir); + } +} diff --git a/src/main/java/org/projecthusky/codegenerator/cda/ArtDecor2JavaGenerator.java b/src/main/java/org/projecthusky/codegenerator/cda/ArtDecor2JavaGenerator.java index 004b568..a8bb0bb 100644 --- a/src/main/java/org/projecthusky/codegenerator/cda/ArtDecor2JavaGenerator.java +++ b/src/main/java/org/projecthusky/codegenerator/cda/ArtDecor2JavaGenerator.java @@ -9,22 +9,38 @@ */ package org.projecthusky.codegenerator.cda; -import com.github.javaparser.ParseProblemException; -import com.github.javaparser.ast.CompilationUnit; -import com.github.javaparser.ast.NodeList; -import com.github.javaparser.ast.body.Parameter; -import com.github.javaparser.ast.body.*; -import com.github.javaparser.ast.comments.Comment; -import com.github.javaparser.ast.comments.JavadocComment; -import com.github.javaparser.ast.comments.LineComment; -import com.github.javaparser.ast.expr.Name; -import com.github.javaparser.ast.expr.NormalAnnotationExpr; -import com.github.javaparser.ast.expr.StringLiteralExpr; -import com.github.javaparser.ast.stmt.BlockStmt; -import com.github.javaparser.ast.stmt.Statement; -import com.github.javaparser.ast.type.ClassOrInterfaceType; -import com.github.javaparser.javadoc.Javadoc; -import net.sf.saxon.s9api.SaxonApiException; +import static com.github.javaparser.ast.Modifier.privateModifier; +import static com.github.javaparser.ast.Modifier.publicModifier; +import static com.github.javaparser.ast.Modifier.staticModifier; + +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +import javax.annotation.processing.Generated; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.ParserConfigurationException; + import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.CommonTokenStream; import org.antlr.v4.runtime.misc.Interval; @@ -43,13 +59,13 @@ import org.projecthusky.codegenerator.cda.model.CdaTemplate; import org.projecthusky.codegenerator.cda.rest.ArtDecorRestClient; import org.projecthusky.codegenerator.cda.xslt.Hl7Its2HuskyTransformer; -import org.projecthusky.codegenerator.java.JavadocUtils; import org.projecthusky.codegenerator.java.JavaCodeGenerator; +import org.projecthusky.codegenerator.java.JavadocUtils; import org.projecthusky.codegenerator.valuesets.UpdateValueSets; import org.projecthusky.codegenerator.valuesets.ValueSetUtil; -import org.projecthusky.common.model.Code; import org.projecthusky.common.basetypes.CodeBaseType; import org.projecthusky.common.hl7cdar2.ObjectFactory; +import org.projecthusky.common.model.Code; import org.projecthusky.valueset.api.ValueSetManager; import org.projecthusky.valueset.config.ValueSetConfig; import org.projecthusky.valueset.enums.SourceFormatType; @@ -60,24 +76,26 @@ import org.slf4j.LoggerFactory; import org.xml.sax.SAXException; -import javax.annotation.processing.Generated; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlType; -import javax.xml.parsers.ParserConfigurationException; -import java.io.File; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.lang.reflect.*; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.time.LocalDate; -import java.util.*; +import com.github.javaparser.ParseProblemException; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.NodeList; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +import com.github.javaparser.ast.body.FieldDeclaration; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.comments.Comment; +import com.github.javaparser.ast.comments.JavadocComment; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.expr.Name; +import com.github.javaparser.ast.expr.NormalAnnotationExpr; +import com.github.javaparser.ast.expr.StringLiteralExpr; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.Statement; +import com.github.javaparser.ast.type.ClassOrInterfaceType; +import com.github.javaparser.javadoc.Javadoc; -import static com.github.javaparser.ast.Modifier.*; +import net.sf.saxon.s9api.SaxonApiException; /** *
This is the main class of the ART-DECOR to Java Code Generator. It orchestrates @@ -1228,22 +1246,45 @@ private String adjustDataType(final String dataType, final String containingClas if (retVal.startsWith("IVL_TS")) { retVal = "IVLTS"; } + if (retVal.startsWith("PIVL_TS")) { + retVal = "PIVLTS"; + } if (retVal.startsWith("TS.")) { retVal = "TS"; } if (retVal.startsWith("SXPR_TS")) { retVal = "SXPRTS"; } - if (retVal.startsWith("SD.TEXT")) { + if (retVal.startsWith("SD.TEXT") || retVal.startsWith("ED")) { retVal = "ED"; if (containingClassName != null) if (containingClassName.endsWith("Section")) { retVal = "StrucDocText"; } } + if (retVal.startsWith("INT.NONNEG")) { retVal = "INT"; } + if (retVal.startsWith("CS.LANG")) { + retVal = "CS"; + } + + if (retVal.startsWith("IVL_INT")) { + retVal = "IVLINT"; + } + + if (retVal.startsWith("RTO_QTY_QTY")) { + retVal = "RTOQTYQTY"; + } + + if (retVal.startsWith("RTO_PQ_PQ")) { + retVal = "RTOPQPQ"; + } + + if (retVal.startsWith("TEL.AT")) { + retVal = "TEL"; + } if (!templateIndex.containsKey(dataType) && !retVal.contains(".")) { retVal = "org.projecthusky.common.hl7cdar2." + retVal; @@ -1324,7 +1365,11 @@ private MethodDeclaration createCreatorForFixedContentsElement( String enPartU = toUpperFirstChar(name); compilationUnit.addImport("org.projecthusky.common.hl7cdar2.En" + enPartU); body.addStatement("En" + enPartU + " retVal = new En" + enPartU + "();"); - } else + } else if (cdaElement.getDataType().startsWith("org.projecthusky.common.hl7cdar2.")) { + method.setType(dataType); + compilationUnit.addImport(cdaElement.getDataType()); + body.addStatement(cdaElement.getDataType() + " retVal = new " + cdaElement.getDataType() + "();"); + } else throw new RuntimeException( name + " is neither an accessible field nor an accessible getter"); } else { @@ -1520,16 +1565,19 @@ private void createFixedAttributeValues( } catch (ClassNotFoundException | NoSuchFieldException | SecurityException e) { - throw new RuntimeException( - "Unhandled exception while getting Datatype for " - + attrName - + "(" - + cdaElement.getFullXmlName() - + ")"); + LOG.error("{}{}{}", cdaElement.getDataType(), attrName, e.getMessage(), e); + throw new RuntimeException("Unhandled exception while getting Datatype for " + + attrName + "(" + cdaElement.getFullXmlName() + ")"); } boolean isEnum = false; - if (dataType != null) isEnum = (!"java.lang.String".contentEquals(dataType)); + if (dataType != null) { + if ("java.lang.Boolean".equalsIgnoreCase(dataType)) { + cdaAttribute.setValue(cdaAttribute.getValue().toUpperCase()); + } else { + isEnum = (!"java.lang.String".contentEquals(dataType)); + } + } if (isEnum) { String enumName = memberType.getName(); statement = @@ -1583,19 +1631,24 @@ private void createFixedAttributeValues( addBodyStatement(constructor, statement); } statement = null; - } else - statement = - "super.set" - + toUpperFirstChar(attrName) - + "(" - + "\"" - + cdaAttribute.getValue() - + "\"" - + ");"; + } else if ("java.lang.Boolean".equalsIgnoreCase(dataType)) { + statement = "super.set" + toUpperFirstChar(attrName) + "(" + + cdaAttribute.getValue().toLowerCase() + ");"; + } else { + statement = "super.set" + toUpperFirstChar(attrName) + "(" + "\"" + + cdaAttribute.getValue() + "\"" + ");"; + } + } } } - if (statement != null) addBodyStatement(constructor, statement); + try { + if (statement != null) + addBodyStatement(constructor, statement); + } catch (Exception e) { + LOG.error(e.getMessage(), e); + } + } } if (cdaAttribute.getValueSetId() != null) { @@ -1655,10 +1708,12 @@ private void createFixedAttributeValues( String myDisplayName = code.getDisplayName(); final var codeStatement = new StringBuilder(); - if ("CS".equals(fieldDataClass.getName())) - codeComplete = (myCode != null); - else - codeComplete = ((myCode != null) && (myCodeSystem != null)); + if (fieldDataClass != null && fieldDataClass.getName() != null) { + if (fieldDataClass.getName().endsWith(".CS")) + codeComplete = (myCode != null); + else + codeComplete = ((myCode != null) && (myCodeSystem != null)); + } codeStatement.append("new Code(CodeBaseType.builder()"); if (myCode != null){ @@ -2710,8 +2765,10 @@ public void enterTemplate(final Hl7ItsParser.TemplateContext ctx) { if (id == null && name == null) { throw new RuntimeException("id and name are null for template " + ctx.getText().substring(0, 500) + "..."); } - if (id == null) { - throw new RuntimeException("id is null for template " + name); + if (id == null) { + id = "no id"; + LOG.error("id is null for template {}", name); + throw new RuntimeException("id is null for template " + name); } if (name == null) { throw new RuntimeException("name is null for template " + id); @@ -3133,12 +3190,12 @@ private String getDataType(final CdaElement cdaElement, final Map();"); - body.addStatement("retVal.nullFlavor.add(nullFlavor);"); + body.addStatement("retVal.getNullFlavor().add(nullFlavor);"); } else if (isClassCollection(memberType)) { String temp = cdaAttribute diff --git a/src/main/java/org/projecthusky/codegenerator/cda/rest/ArtDecorRestClient.java b/src/main/java/org/projecthusky/codegenerator/cda/rest/ArtDecorRestClient.java index 9035ed1..0249ff4 100644 --- a/src/main/java/org/projecthusky/codegenerator/cda/rest/ArtDecorRestClient.java +++ b/src/main/java/org/projecthusky/codegenerator/cda/rest/ArtDecorRestClient.java @@ -9,7 +9,10 @@ */ package org.projecthusky.codegenerator.cda.rest; -import java.io.*; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.nio.charset.StandardCharsets; @@ -298,7 +301,7 @@ public InputStream getArtDecorTemplate(final String documentTemplateId, log.debug(prefix + " : " + templateId); return getArtDecorXml( new URL(baseUrl + "RetrieveTemplate?prefix=" + prefix + "&id=" - + templateId + "&effectiveDate=" + effectiveDate + "&format=xmlnowrapper")); + + templateId + "&effectiveDate=" + effectiveDate + "&format=xmlnowrapper")); } /** diff --git a/src/main/resources/cda/ContentProfilePackageConfigCdaAtEmsV2020.yml b/src/main/resources/cda/ContentProfilePackageConfigCdaAtEmsV2020.yml new file mode 100644 index 0000000..c378688 --- /dev/null +++ b/src/main/resources/cda/ContentProfilePackageConfigCdaAtEmsV2020.yml @@ -0,0 +1,14 @@ +contentProfileConfigList: +- artDecorBaseUrl: https://art-decor.org/decor/services/ + artDecorDocTemplateMap: + 1.2.40.0.34.11.6.0.1: '2020-02-25T14:46:58' + 1.2.40.0.34.11.6.0.2: '2020-02-20T08:35:37' + artDecorMainBaseUrl: https://art-decor.org/decor/services/ + artDecorMainPrefix: epims- + artDecorProjectMap: + epims-: https://art-decor.org/decor/services/ + at-cda-bbr-: https://art-decor.org/decor/services/ + elgabbr-: https://art-decor.org/decor/services/ + targetDir: husky/husky-cda/husky-elga + targetNamespace: org.projecthusky.cda.elga.generated.artdecor.ems +description: Epidemiologisches Meldesystem - version of February, 2020 diff --git a/src/main/resources/cda/ContentProfilePackageConfigCdaElgaEMedV2014.yml b/src/main/resources/cda/ContentProfilePackageConfigCdaElgaEMedV2014.yml new file mode 100644 index 0000000..ad8178e --- /dev/null +++ b/src/main/resources/cda/ContentProfilePackageConfigCdaElgaEMedV2014.yml @@ -0,0 +1,15 @@ +contentProfileConfigList: +- artDecorBaseUrl: https://art-decor.org/decor/services/ + artDecorDocTemplateMap: + 1.2.40.0.34.11.10005: '2014-01-31T00:00:00' + 1.2.40.0.34.11.10006: '2014-01-31T00:00:00' + 1.2.40.0.34.11.10007: '2014-01-31T00:00:00' + 1.2.40.0.34.11.10008: '2014-01-31T00:00:00' + artDecorMainBaseUrl: https://art-decor.org/decor/services/ + artDecorMainPrefix: elga- + artDecorProjectMap: + elga-: https://art-decor.org/decor/services/ + elgabbr-: https://art-decor.org/decor/services/ + targetDir: husky/husky-cda/husky-elga + targetNamespace: org.projecthusky.cda.elga.generated.artdecor.emed +description: ELGA eMedikation - version of January, 2014 diff --git a/src/main/resources/cda/ContentProfilePackageConfigCdaElgaImpfV2022.yml b/src/main/resources/cda/ContentProfilePackageConfigCdaElgaImpfV2022.yml new file mode 100644 index 0000000..8b31929 --- /dev/null +++ b/src/main/resources/cda/ContentProfilePackageConfigCdaElgaImpfV2022.yml @@ -0,0 +1,16 @@ +contentProfileConfigList: +- artDecorBaseUrl: https://art-decor.org/decor/services/ + artDecorDocTemplateMap: + 1.2.40.0.34.6.0.11.0.2: '2022-01-25T12:15:38' + 1.2.40.0.34.6.0.11.0.4: '2022-01-25T12:13:30' + artDecorMainBaseUrl: https://art-decor.org/decor/services/ + artDecorMainPrefix: elgaimpf- + artDecorProjectMap: + elgaimpf-: https://art-decor.org/decor/services/ + at-cda-bbr-: https://art-decor.org/decor/services/ + elgabbr-: https://art-decor.org/decor/services/ + ad2bbr-: https://art-decor.org/decor/services/ + ad1bbr-: https://art-decor.org/decor/services/ + targetDir: husky/husky-cda/husky-elga + targetNamespace: org.projecthusky.cda.elga.generated.artdecor +description: ELGA e-Impfpass - version of January, 2022 diff --git a/src/main/resources/cda/ContentProfilePackageConfigCdaElgaLabV2013.yml b/src/main/resources/cda/ContentProfilePackageConfigCdaElgaLabV2013.yml new file mode 100644 index 0000000..34aaf94 --- /dev/null +++ b/src/main/resources/cda/ContentProfilePackageConfigCdaElgaLabV2013.yml @@ -0,0 +1,12 @@ +contentProfileConfigList: +- artDecorBaseUrl: https://art-decor.org/decor/services/ + artDecorDocTemplateMap: + 1.2.40.0.34.11.10003: '2013-11-07T00:00:00' + artDecorMainBaseUrl: https://art-decor.org/decor/services/ + artDecorMainPrefix: elga- + artDecorProjectMap: + elga-: https://art-decor.org/decor/services/ + elgabbr-: https://art-decor.org/decor/services/ + targetDir: husky/husky-cda/husky-elga + targetNamespace: org.projecthusky.cda.elga.generated.artdecor.base +description: ELGA laboratory report - version of November, 2013 diff --git a/src/main/resources/cda/ContentProfilePackageConfigCdaElgaPatientSummaryV2016.yml b/src/main/resources/cda/ContentProfilePackageConfigCdaElgaPatientSummaryV2016.yml new file mode 100644 index 0000000..a8a6517 --- /dev/null +++ b/src/main/resources/cda/ContentProfilePackageConfigCdaElgaPatientSummaryV2016.yml @@ -0,0 +1,15 @@ +contentProfileConfigList: +- artDecorBaseUrl: https://art-decor.org/decor/services/ + artDecorDocTemplateMap: + 1.2.40.0.34.11.13: '2016-08-30T16:19:25' + artDecorMainBaseUrl: https://art-decor.org/decor/services/ + artDecorMainPrefix: elgaps- + artDecorProjectMap: + elgaps-: https://art-decor.org/decor/services/ + elgabbr-: https://art-decor.org/decor/services/ + ad1bbr-: https://art-decor.org/decor/services/ + at-cda-bbr-: https://art-decor.org/decor/services/ + ccd1-: https://art-decor.org/decor/services/ + targetDir: husky/husky-cda/husky-elga + targetNamespace: org.projecthusky.cda.elga.generated.artdecor.ps +description: ELGA Patient Summary - version of August, 2016 diff --git a/src/main/resources/stylesheets/Hl7Its2HuskyCdaGen.xsl b/src/main/resources/stylesheets/Hl7Its2HuskyCdaGen.xsl index 81bb8fb..acf1275 100644 --- a/src/main/resources/stylesheets/Hl7Its2HuskyCdaGen.xsl +++ b/src/main/resources/stylesheets/Hl7Its2HuskyCdaGen.xsl @@ -28,13 +28,15 @@ History: may overwrite this default behavior. **************************************************************************** --> + + - + @@ -42,7 +44,7 @@ History: - +