Commit dd72270e authored by Tony Schaller's avatar Tony Schaller

Update for CDA-CH V2 Support

git-svn-id: https://svn.code.sf.net/p/ehealthconnector/code/trunk@1661 e99adb7c-5e35-42fd-8d1b-cdb378af05e8
parent b17a2c7c
......@@ -37,6 +37,7 @@ import org.apache.log4j.LogManager;
import org.apache.log4j.xml.DOMConfigurator;
import org.ehealth_connector.common.utils.FileUtil;
import org.ehealth_connector.common.utils.Util;
import org.ehealth_connector.demo.cda.DemoCdaChV2;
import org.ehealth_connector.demo.cda.DemoEdes;
import org.ehealth_connector.demo.cda.DemoLrep;
import org.ehealth_connector.demo.cda.DemoLrph;
......@@ -78,7 +79,7 @@ public class Main {
*
*/
private static enum Demos {
DemoDocConsumer, DemoDocSource, DemoEdes, DemoLrep, DemoLrph, DemoLrqc, DemoLrtp, DemoMpiClientPdq, DemoMpiClientPix, DemoVacd, DemoValidation, DemoValidationBatch, DemoValidationRandom, DemoValidationInMemory, DemoMtps, DemoXua
DemoCdaChV2, DemoDocConsumer, DemoDocSource, DemoEdes, DemoLrep, DemoLrph, DemoLrqc, DemoLrtp, DemoMpiClientPdq, DemoMpiClientPix, DemoVacd, DemoValidation, DemoValidationBatch, DemoValidationRandom, DemoValidationInMemory, DemoMtps, DemoXua
}
/**
......@@ -96,6 +97,15 @@ public class Main {
public static final String IN_MEMORY_MODE_STREAM = "byStream";
public static final String IN_MEMORY_MODE_BYTE_ARRAY = "byByteArray";
/**
* Demonstration for CDA-CH V2 specification
*/
public static void DemoCdaChV2(String configFn) {
final String filePath = Util.getTempDirectory();
final DemoCdaChV2 demo = new DemoCdaChV2(configFn);
demo.doDemo(filePath);
}
/**
* Demonstration for Document Consumer actor (XDS and XDM)
*
......@@ -531,6 +541,8 @@ public class Main {
demo = Demos.DemoLrqc;
if (arg.equals("demolrep"))
demo = Demos.DemoLrep;
if (arg.equals("democdachv2"))
demo = Demos.DemoCdaChV2;
if (arg.equals("demodocsource"))
demo = Demos.DemoDocSource;
if (arg.equals("demodocconsumer"))
......@@ -742,6 +754,17 @@ public class Main {
} else
DemoLrqc();
break;
case DemoCdaChV2:
System.out.println("Executing DemoCdaChV2...");
if (args.clone().length > 1) {
String fn = args[1].toString();
final File configFile = new File(fn);
if (configFile.exists())
DemoCdaChV2(fn);
else
System.out.println("***ERROR: Config File does not exist '" + fn + "'");
}
break;
case DemoLrep:
System.out.println("Executing DemoLREP...");
if (args.clone().length > 1) {
......
......@@ -18,16 +18,19 @@ package org.ehealth_connector.demo.cda;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.text.SimpleDateFormat;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.apache.commons.io.FileUtils;
import org.ehealth_connector.cda.ch.CdaChV2StructuredBody;
import org.ehealth_connector.cda.ch.utils.CdaChUtil;
import org.ehealth_connector.cda.utils.Xml2Html;
import org.ehealth_connector.common.Author;
import org.ehealth_connector.common.Code;
import org.ehealth_connector.common.Identificator;
import org.ehealth_connector.common.Organization;
import org.ehealth_connector.common.Patient;
import org.ehealth_connector.common.enums.CodeSystems;
import org.ehealth_connector.common.enums.LanguageCode;
......@@ -55,14 +58,18 @@ public class DemoCdaChV2 {
private final String styleSheet = "../xsl/cda-ch.xsl";
private String configFn;
/**
* <div class="en">Empty constructor (default)</div><div class="de"></div>
* <div class="fr"></div>
*/
public DemoCdaChV2() {
public DemoCdaChV2(String configFn) {
this.configFn = configFn;
}
private CdaChV2StructuredBody<org.openhealthtools.mdht.uml.cda.ch.CdaChV2StructuredBody> createCompleteDemoDocument() {
// Create Header
final CdaChV2StructuredBody<org.openhealthtools.mdht.uml.cda.ch.CdaChV2StructuredBody> doc = new CdaChV2StructuredBody<org.openhealthtools.mdht.uml.cda.ch.CdaChV2StructuredBody>(
ChFactory.eINSTANCE.createCdaChV2StructuredBody().init(), LanguageCode.GERMAN,
......@@ -93,6 +100,11 @@ public class DemoCdaChV2 {
legalAuthenticator.setTime(DateUtil.parseDateyyyyMMdd("20171003"));
doc.setLegalAuthenticator(legalAuthenticator);
// doc.addAuthenticator(legalAuthenticator);
doc.addAuthorizationConsent("Mündliche Einwilligung während Konsultation vom 03.10.2017");
// Create Body
doc.addNarrativeTextSection("Gewünschte Untersuchung", "Demo only");
return doc;
}
......@@ -105,9 +117,9 @@ public class DemoCdaChV2 {
try {
String cdaFileName = outputPath + CDA_FN + CDA_EXT;
String pdfFileName = outputPath + CDA_FN + PDF_EXT;
CdaValidator cdaVali = new CdaValidator(
new File(new File(new File("").getAbsoluteFile().getAbsolutePath()
+ "/rsc/demoValidation/config_cda-ch-v2only.xml").getAbsolutePath()));
String htmlFileName = outputPath + CDA_FN + UPD + HTML_EXT;
CdaValidator cdaVali = new CdaValidator(new File(configFn));
System.out.print("outputPath: " + outputPath + "\n\n");
......@@ -133,17 +145,9 @@ public class DemoCdaChV2 {
DemoValidationHelper.doValidateOneCdaDocument(null, cdaVali,
new StreamSource(cdaFileName), new File(cdaFileName).getAbsolutePath(), true,
true, true, true);
System.out.print("Validation complete\n\n");
log.debug("PerformanceTimestamp: DemoCdaChV2.doDemo: Validation complete");
// Converting To PDF
System.out.print("===== Converting to PDF =====\n");
StreamResult html = Xml2Html.convertXMLToHTML(new StreamSource(cdaFileName));
ByteArrayOutputStream pdfStream = PdfCreator.convertHtml2PdfAStream(
html.getWriter().toString(), doc.getLanguageCode(),
doc.getAuthor().getCompleteName(), "rsc/xsl");
System.out.print("Done to '" + pdfFileName + "'\n\n");
log.debug("PerformanceTimestamp: DemoCdaChV2.doDemo: PDF conversion complete");
System.out.print("Validation of '" + cdaFileName + "' complete\n\n");
log.debug("PerformanceTimestamp: DemoCdaChV2.doDemo: Validation of '" + cdaFileName
+ "' complete");
// Deserializing
System.out.print("===== Loading Clinical Document from file =====\n");
......@@ -155,27 +159,66 @@ public class DemoCdaChV2 {
// Optional: Show on console
// doc2.printXmlToConsole();
doc2.addStylesheet(styleSheet);
doc2.addCss(css);
doc2.sortXmlHeader();
System.out.print("===== Extracting some header payload from Clinical Document =====\n");
System.out.print("Document author: " + doc2.getAuthor().getCompleteName() + "\n\n");
final SimpleDateFormat sdfDate = new SimpleDateFormat("dd.MM.yyyy");
final SimpleDateFormat sdfTime = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
System.out.print("Patient: " + doc2.getPatient().getCompleteName() + " - born: "
+ sdfDate.format(doc2.getPatient().getBirthday()) + "\n");
System.out.print("Document author: " + doc2.getAuthor().getCompleteName()
+ " - authored: " + sdfTime.format(doc2.getAuthor().getTimeAsDate()) + "\n");
System.out.print("Document data enterer: "
+ doc2.getDataEntererPerson().getCompleteName() + " - entered: "
+ sdfTime.format(doc2.getDataEnterer().getTimeAsDate()) + "\n");
System.out
.print("Custodian: "
+ new Organization(doc2.getCustodian().getAssignedCustodian()
.getRepresentedCustodianOrganization()).getCompleteName()
+ "\n");
System.out.print(
"Primary recipient: " + doc2.getPrimaryRecipient().getCompleteName() + "\n");
System.out.print("Other recipients: ");
if (doc2.getOtherRecipients().size() > 0) {
System.out.print("\n");
for (Organization recipient : doc2.getOtherRecipients()) {
System.out.print("- " + recipient.getCompleteName() + "\n");
}
} else {
System.out.print("None\n");
}
System.out.print("Legal authenticator: "
+ doc2.getLegalAuthenticatorAsAuthor().getCompleteName() + " - signed: "
+ sdfTime.format(doc2.getLegalAuthenticatorAsAuthor().getTimeAsDate()) + "\n");
System.out.print("Other authenticators: ");
if (doc2.getAuthenticators().size() > 0) {
System.out.print("\n");
for (Author authenticator : doc2.getAuthenticatorsAsAuthor()) {
System.out.print("- " + authenticator.getCompleteName() + " - signed: "
+ sdfTime.format(doc2.getLegalAuthenticatorAsAuthor().getTimeAsDate())
+ "\n");
}
} else {
System.out.print("None\n");
}
System.out.print("\n");
log.debug(
"PerformanceTimestamp: DemoCdaChV2.doDemo: Extracting some header payload from Clinical Document complete");
System.out.print("===== Adding some information =====\n");
System.out.print("- comment\n");
System.out.print("- new narrative section\n");
System.out.print("- original representation section\n");
// TODO
// doc2.addComment("Dieser Kommentar wurde zu einem geladenem
// Dokument hinzugefügt.");
doc2.addNarrativeTextSection("Ergänzung",
"Dieses Kapitel wurde zu einem geladenem Dokument hinzugefügt.");
doc2.setDocumentToReplaceIdentifier(doc.getId());
doc2.setOriginalRepresentationSection(pdfStream.toByteArray());
System.out.print("Done in memory\n\n");
System.out.print("===== Saving Clinical Document to file =====\n");
cdaFileName = outputPath + CDA_FN + UPD + CDA_EXT;
doc2.addStylesheet(styleSheet);
doc2.addCss(css);
doc2.saveToFile(cdaFileName);
System.out.print("Done to '" + cdaFileName + "'\n\n");
log.debug(
......@@ -183,9 +226,12 @@ public class DemoCdaChV2 {
// Converting To PDF
System.out.print("===== Converting to PDF =====\n");
html = Xml2Html.convertXMLToHTML(new StreamSource(cdaFileName));
pdfStream = PdfCreator.convertHtml2PdfAStream(html.getWriter().toString(),
doc.getLanguageCode(), doc.getAuthor().getCompleteName(), "rsc/xsl");
StreamResult html = Xml2Html.convertXMLToHTML(new StreamSource(cdaFileName));
ByteArrayOutputStream pdfStream = PdfCreator.convertHtml2PdfAStream(
html.getWriter().toString(), doc.getLanguageCode(),
doc.getAuthor().getCompleteName(), "rsc/xsl");
// This is for debugging purposes, only:
FileUtils.write(new File(htmlFileName), html.getWriter().toString(), "UTF-8");
System.out.print("Done to '" + pdfFileName + "'\n\n");
log.debug("PerformanceTimestamp: DemoCdaChV2.doDemo: PDF conversion complete");
......@@ -194,10 +240,13 @@ public class DemoCdaChV2 {
// Validation
System.out.print("===== Validation of the CDA =====\n");
// TODO
System.out.print("Validation TODO\n\n");
// System.out.print("Validation complete\n\n");
log.debug("PerformanceTimestamp: DemoCdaChV2.doDemo: Validation complete");
// Do all possible validation steps
DemoValidationHelper.doValidateOneCdaDocument(null, cdaVali,
new StreamSource(cdaFileName), new File(cdaFileName).getAbsolutePath(), true,
true, true, true);
System.out.print("Validation of '" + cdaFileName + "' complete\n\n");
log.debug("PerformanceTimestamp: DemoCdaChV2.doDemo: Validation of '" + cdaFileName
+ "' complete");
} catch (final Exception e) {
System.out.print("*** Exception: " + e.getMessage() + "\n");
......
......@@ -2269,8 +2269,6 @@ public class DemoLrep {
outputPath = outputPath + FileUtil.getPlatformSpecificPathSeparator();
try {
DemoCdaChV2 cdaV2Demo = new DemoCdaChV2();
cdaV2Demo.doDemo(outputPath);
// String LrepFileName = outputPath + LREP_FN + CDA_EXT;
// String pdfFileName = outputPath + LREP_FN + PDF_EXT;
// String htmlFileName = outputPath + LREP_FN + HTML_EXT;
......@@ -2330,6 +2328,9 @@ public class DemoLrep {
//
// // Optional: Show on console
// // doc2.printXmlToConsole();
// doc2.addStylesheet(styleSheet);
// doc2.addCss(css);
// doc.sortXmlHeader();
//
// System.out.print("===== Extracting some header payload from
// Clinical Document =====\n");
......@@ -2360,8 +2361,6 @@ public class DemoLrep {
// System.out.print("===== Saving Clinical Document to file
// =====\n");
// LrepFileName = outputPath + LREP_FN + UPD + CDA_EXT;
// doc2.addStylesheet(styleSheet);
// doc2.addCss(css);
// doc2.saveToFile(LrepFileName);
// System.out.print("Done to '" + LrepFileName + "'\n\n");
// log.debug(
......
......@@ -746,12 +746,12 @@ public class DemoMtps {
final CdaChMtpsDis docDis = new CdaChMtpsDis(LanguageCode.FRENCH, styleSheet, css);
docDis.createDisHeader(pharmacist, legalAuthenticator, pharmOrganization, patient,
mtpsDisId, new Date(), defaultLanguageCode);
docDis.setTimestamp(DateUtil.parseDateyyyyMMdd("20171123"));
// This is to compare the output with previous releases, only
if (Util.isDebug()) {
docDis.setConfidentialityCode(
org.ehealth_connector.common.enums.ConfidentialityCode.NORMAL);
docDis.setTimestamp(mDate);
docDis.setSetId(new Identificator("2.16.756.5.30.1.1.1.1",
"6776944c-2770-9f24-8678-8df36e92f1f5"));
}
......@@ -1056,12 +1056,12 @@ public class DemoMtps {
final CdaChMtpsMtp docMtp = new CdaChMtpsMtp(LanguageCode.FRENCH, styleSheet, css);
docMtp.createMtpHeader(md, legalAuthenticator, mdOrganization, patient, mtpsMtpId,
new Date(), defaultLanguageCode);
docMtp.setTimestamp(DateUtil.parseDateyyyyMMdd("20171123"));
// This is to compare the output with previous releases, only
if (Util.isDebug()) {
docMtp.setConfidentialityCode(
org.ehealth_connector.common.enums.ConfidentialityCode.NORMAL);
docMtp.setTimestamp(DateUtil.parseDateyyyyMMdd("20171123"));
docMtp.setSetId(new Identificator("2.16.756.5.30.1.1.1.1",
"6776a874-2770-9f24-c05c-8df36e92f1f5"));
}
......@@ -1209,12 +1209,12 @@ public class DemoMtps {
final CdaChMtpsPadv docPadv = new CdaChMtpsPadv(LanguageCode.FRENCH, styleSheet, css);
docPadv.createPadvHeader(pharmacist, legalAuthenticator, pharmOrganization, patient,
mtpsPadvId, new Date(), defaultLanguageCode);
docPadv.setTimestamp(DateUtil.parseDateyyyyMMdd("20171123"));
// This is to compare the output with previous releases, only
if (Util.isDebug()) {
docPadv.setConfidentialityCode(
org.ehealth_connector.common.enums.ConfidentialityCode.NORMAL);
docPadv.setTimestamp(DateUtil.parseDateyyyyMMdd("20171123"));
docPadv.setSetId(new Identificator("2.16.756.5.30.1.1.1.1",
"6776b288-2770-9f24-c2ec-8df36e92f1f5"));
}
......@@ -1442,12 +1442,12 @@ public class DemoMtps {
final CdaChMtpsPml docPml = new CdaChMtpsPml(LanguageCode.FRENCH, styleSheet, css);
docPml.createPmlHeader(md, legalAuthenticator, mdOrganization, patient, mtpsPmlId,
new Date(), defaultLanguageCode);
docPml.setTimestamp(DateUtil.parseDateyyyyMMdd("20171123"));
// This is to compare the output with previous releases, only
if (Util.isDebug()) {
docPml.setConfidentialityCode(
org.ehealth_connector.common.enums.ConfidentialityCode.NORMAL);
docPml.setTimestamp(DateUtil.parseDateyyyyMMdd("20171123"));
docPml.setSetId(new Identificator("2.16.756.5.30.1.1.1.1",
"6776bbd4-2770-9f24-ee3e-8df36e92f1f5"));
}
......@@ -1495,12 +1495,12 @@ public class DemoMtps {
final CdaChMtpsPre docPre = new CdaChMtpsPre(LanguageCode.FRENCH, styleSheet, css);
docPre.createPreHeader(md, legalAuthenticator, mdOrganization, patient, mtpsPreId,
new Date(), defaultLanguageCode);
docPre.setTimestamp(DateUtil.parseDateyyyyMMdd("20171123"));
// This is to compare the output with previous releases, only
if (Util.isDebug()) {
docPre.setConfidentialityCode(
org.ehealth_connector.common.enums.ConfidentialityCode.NORMAL);
docPre.setTimestamp(DateUtil.parseDateyyyyMMdd("20171123"));
docPre.setSetId(new Identificator("2.16.756.5.30.1.1.1.1",
"6776c9d0-2770-9f24-c52c-8df36e92f1f5"));
}
......@@ -2232,10 +2232,10 @@ public class DemoMtps {
+ doc.getPatient().getAdministrativeGenderCode().getCodeValue() + " / "
+ DateUtil.formatDateCH(doc.getPatient().getBirthday()) + ")\n";
retVal = retVal + "- Document author: " + doc.getAuthor().getCompleteName() + " "
+ DateUtil.formatDateCH(doc.getTimestamp()) + "\n";
+ DateUtil.formatDateCH(doc.getAuthor().getTimeAsDate()) + "\n";
retVal = retVal + "- Legal Authenticator: "
+ doc.getLegalAuthenticatorAsAuthor().getCompleteName() + " "
+ DateUtil.formatDateCH(doc.getTimestamp()) + "\n";
+ DateUtil.formatDateCH(doc.getLegalAuthenticatorAsAuthor().getTimeAsDate()) + "\n";
retVal = retVal + "\n";
retVal = retVal + "===== Extracting some medical payload from Clinical Document =====\n";
......
......@@ -1021,8 +1021,7 @@ public class XdResources {
confCodeNormal.setText(
org.ehealth_connector.common.enums.ConfidentialityCode.NORMAL.getDisplayName());
confSwissEprCodeNormal = FhirCommon.createCodeableConcept(
org.ehealth_connector.common.ch.enums.ConfidentialityCode.NORMAL
.getCodeSystemValue(),
org.ehealth_connector.common.ch.enums.ConfidentialityCode.NORMAL.getCodeSystemId(),
org.ehealth_connector.common.ch.enums.ConfidentialityCode.NORMAL.getCodeValue());
confSwissEprCodeNormal.setText(
org.ehealth_connector.common.ch.enums.ConfidentialityCode.NORMAL.getDisplayName());
......@@ -1084,41 +1083,41 @@ public class XdResources {
// Swiss EPR Document Metadata
// =========================
docFormatCodeCdaSwissEpr = FhirCommon.createCoding(
FormatCode.IMMUNIZATION_CONTENT.getCodeSystemValue(),
FormatCode.IMMUNIZATION_CONTENT.getCodeSystemId(),
FormatCode.IMMUNIZATION_CONTENT.getCodeValue());
docFormatCodeCdaSwissEpr.setDisplay(FormatCode.IMMUNIZATION_CONTENT.getDisplayName());
docFormatCodePdfSwissEpr = FhirCommon.createCoding(
FormatCode.MIMETYPE_SUFFICIENT.getCodeSystemValue(),
FormatCode.MIMETYPE_SUFFICIENT.getCodeSystemId(),
FormatCode.MIMETYPE_SUFFICIENT.getCodeValue());
docFormatCodePdfSwissEpr.setDisplay(FormatCode.MIMETYPE_SUFFICIENT.getDisplayName());
docFacilityTypeCodeSwissEpr = FhirCommon.createCodeableConcept(
HealthcareFacilityTypeCode.AMBULATORY_CARE_SITE.getCodeSystemValue(),
HealthcareFacilityTypeCode.AMBULATORY_CARE_SITE.getCodeSystemId(),
HealthcareFacilityTypeCode.AMBULATORY_CARE_SITE.getCodeValue());
docFacilityTypeCodeSwissEpr
.setText(HealthcareFacilityTypeCode.AMBULATORY_CARE_SITE.getDisplayName());
docTypeCodeSwissEprCda = FhirCommon.createCodeableConcept(
TypeCode.ANAESTHESIOLOGY_REPORT.getCodeSystemValue(),
TypeCode.ANAESTHESIOLOGY_REPORT.getCodeSystemId(),
TypeCode.ANAESTHESIOLOGY_REPORT.getCodeValue());
docTypeCodeSwissEprCda.setText(TypeCode.ANAESTHESIOLOGY_REPORT.getDisplayName());
docTypeCodeSwissEprPdf = FhirCommon.createCodeableConcept(
TypeCode.ADVANCE_DIRECTIVE_REPORT.getCodeSystemValue(),
TypeCode.ADVANCE_DIRECTIVE_REPORT.getCodeSystemId(),
TypeCode.ADVANCE_DIRECTIVE_REPORT.getCodeValue());
docTypeCodeSwissEprPdf.setText(TypeCode.ADVANCE_DIRECTIVE_REPORT.getDisplayName());
docClassCodeSwissEprCda = FhirCommon.createCodeableConcept(
ClassCode.EPISODE_SUMMARY_REPORTS.getCodeSystemValue(),
ClassCode.EPISODE_SUMMARY_REPORTS.getCodeSystemId(),
ClassCode.EPISODE_SUMMARY_REPORTS.getCodeValue());
docClassCodeSwissEprCda.setText(ClassCode.EPISODE_SUMMARY_REPORTS.getDisplayName());
docClassCodeSwissEprPdf = FhirCommon.createCodeableConcept(
ClassCode.OTHER_COMPOSITION.getCodeSystemValue(),
ClassCode.OTHER_COMPOSITION.getCodeSystemId(),
ClassCode.OTHER_COMPOSITION.getCodeValue());
docClassCodeSwissEprPdf.setText(ClassCode.OTHER_COMPOSITION.getDisplayName());
practiceSettingCodeSwissEpr = FhirCommon.createCoding(
PracticeSettingCode.GENERAL_MEDICINE.getCodeSystemValue(),
PracticeSettingCode.GENERAL_MEDICINE.getCodeSystemId(),
PracticeSettingCode.GENERAL_MEDICINE.getCodeValue());
practiceSettingCodeSwissEpr
.setDisplay(PracticeSettingCode.GENERAL_MEDICINE.getDisplayName());
......
......@@ -61,7 +61,7 @@ public class DemoUtil {
public static Author createAuthorLabMember() {
Author a = new Author(new Name("Pipette", "Documenter"), "7608888888888");
a.setFunctionCode(createFunctionCodeLaboratoryTechnician());
a.setFunctionCode(createFunctionCodeLaboratoryTechnicianCdaChV1());
final Telecoms telecoms = new Telecoms();
telecoms.addPhone("+41.99.999.99.99", AddressUse.PUBLIC);
......@@ -84,7 +84,7 @@ public class DemoUtil {
public static Author createAuthorMpaLab() {
Author a = new Author(new Name("Heidi", "Sticht"), "7608888888888");
a.setFunctionCode(createFunctionCodeLaboratoryTechnician());
a.setFunctionCode(createFunctionCodeLaboratoryTechnicianCdaChV1());
final Telecoms telecoms = new Telecoms();
telecoms.addPhone("+41.32.234.55.66", AddressUse.PUBLIC);
......@@ -124,10 +124,9 @@ public class DemoUtil {
}
public static Code createFunctionCodeLaboratoryTechnician() {
Code retVal = new Code();
retVal.addTranslation(new Code("2.16.840.1.113883.2.9.6.2.7", "3212", "ISCO-08",
"Medical and pathology laboratory technicians"));
public static Code createFunctionCodeLaboratoryTechnicianCdaChV1() {
Code retVal = new Code("2.16.840.1.113883.2.9.6.2.7", "3212", "ISCO-08",
"Medical and pathology laboratory technicians");
retVal.setOriginalText("Laborfachperson");
retVal.setNullFlavor(NullFlavor.TEMPORARILY_UNAVAILABLE);
return retVal;
......
......@@ -32,6 +32,7 @@ import org.ehealth_connector.common.enums.CodeSystems;
import org.ehealth_connector.common.enums.CountryCode;
import org.ehealth_connector.common.enums.NameQualifier;
import org.ehealth_connector.common.enums.NameUse;
import org.ehealth_connector.common.enums.NullFlavor;
import org.ehealth_connector.common.utils.DateUtil;
public class DemoUtilCdaChV2 {
......@@ -53,6 +54,15 @@ public class DemoUtilCdaChV2 {
return dataEnterer;
}
public static Code createFunctionCodeLaboratoryTechnicianCdaChV2() {
Code retVal = new Code();
retVal.addTranslation(new Code("2.16.840.1.113883.2.9.6.2.7", "3212", "ISCO-08",
"Medical and pathology laboratory technicians"));
retVal.setOriginalText("Laborfachperson");
retVal.setNullFlavor(NullFlavor.TEMPORARILY_UNAVAILABLE);
return retVal;
}
public static Organization createOrganizationGruppenpraxis() {
final Telecoms telecoms = new Telecoms();
......
......@@ -6,6 +6,7 @@ For CDA serialization/deserialization demos:
DemoLRTP [rscFn] [outputFn]
DemoMTPS [rscFn] [outputFn]
DemoVACD [rscFn] [outputFn]
DemoCdaChV2 configFn
For CDA validation demo:
DemoValidation configFn cdaFn
......
......@@ -97,6 +97,13 @@ public class CdaChV2StructuredBody<EClinicalDocument extends ClinicalDocument>
getDoc().getAuthors().add(docAuthor);
}
public void addNarrativeTextSection(String title, String text) {
Section s = CDAFactory.eINSTANCE.createSection();
s.setTitle(DatatypesFactory.eINSTANCE.createST(title));
s.createStrucDocText(text);
getDoc().addSection(s);
}
@Override
public void initCda() {
......
......@@ -789,20 +789,11 @@ public class ObservationChTextBuilder extends TextBuilder {
if (high == null)
high = "";
if (!"".equals(value))
if (value.length() == 17)
value = formatDate(DateUtil.parseDateyyyyMMddHHmmZZZZ(value));
else
value = formatDate(DateUtil.parseDateyyyyMMddHHmmssZZZZ(value));
value = parseDate(value);
if (!"".equals(low))
if (low.length() == 17)
low = formatDate(DateUtil.parseDateyyyyMMddHHmmZZZZ(low));
else
low = formatDate(DateUtil.parseDateyyyyMMddHHmmssZZZZ(low));
value = parseDate(low);
if (!"".equals(high))
if (high.length() == 17)
high = formatDate(DateUtil.parseDateyyyyMMddHHmmZZZZ(high));
else
high = formatDate(DateUtil.parseDateyyyyMMddHHmmssZZZZ(high));
value = parseDate(high);
if ("".equals(low) && "".equals(high))
retVal = value;
else
......@@ -1132,6 +1123,19 @@ public class ObservationChTextBuilder extends TextBuilder {
return retVal;
}
private String parseDate(String value) {
String retVal = "";
if (value.length() > 17)
retVal = formatDate(DateUtil.parseDateyyyyMMddHHmmssZZZZ(value));
else if (value.length() == 17)
retVal = formatDate(DateUtil.parseDateyyyyMMddHHmmZZZZ(value));
else if (value.length() == 8)
retVal = formatDate(DateUtil.parseDateyyyyMMdd(value));
else
retVal = "Not yet implemented";
return retVal;
}
/**
* Sets the observation comparator.
*
......
......@@ -24,6 +24,7 @@ import java.util.Date;
import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.ehealth_connector.cda.Consumable;
import org.ehealth_connector.cda.MdhtFacade;
import org.ehealth_connector.cda.SectionAnnotationCommentEntry;
......@@ -520,7 +521,7 @@ public class Immunization extends MdhtFacade<org.openhealthtools.mdht.uml.cda.ch
public void setAuthor(Author author) {
getMdht().getAuthors().clear();
if (author != null)
getMdht().getAuthors().add(author.getAuthorMdht());
getMdht().getAuthors().add(EcoreUtil.copy(author.getAuthorMdht()));
}
/**
......
......@@ -23,6 +23,7 @@ import java.util.Date;
import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.ehealth_connector.cda.Consumable;
import org.ehealth_connector.cda.ExternalDocumentEntry;
import org.ehealth_connector.cda.MdhtFacade;
......@@ -460,7 +461,7 @@ public class ImmunizationRecommendation
public void setAuthor(org.ehealth_connector.common.Author author) {
getMdht().getAuthors().clear();
if (author != null)
getMdht().getAuthors().add(author.getAuthorMdht());
getMdht().getAuthors().add(EcoreUtil.copy(author.getAuthorMdht()));
}
......
......@@ -43,6 +43,7 @@ import org.ehealth_connector.common.enums.EhcVersions;
import org.ehealth_connector.common.enums.LanguageCode;
import org.ehealth_connector.common.enums.ParticipantType;
import org.ehealth_connector.common.enums.Signature;
import org.ehealth_connector.common.enums.StatusCode;
import org.ehealth_connector.common.utils.DateUtil;
import org.ehealth_connector.common.utils.Util;
import org.openhealthtools.mdht.uml.cda.AssignedCustodian;
......@@ -50,9 +51,11 @@ import org.openhealthtools.mdht.uml.cda.AssignedEntity;
import org.openhealthtools.mdht.uml.cda.AssociatedEntity;
import org.openhealthtools.mdht.uml.cda.Authenticator;
import org.openhealthtools.mdht.uml.cda.Author;
import org.openhealthtools.mdht.uml.cda.Authorization;
import org.openhealthtools.mdht.uml.cda.CDAFactory;
import org.openhealthtools.mdht.uml.cda.CDAPackage;