简体   繁体   English

C-CDA验证失败,因为服务器中存在“未知类型”,但在独立项目中却没有

[英]C-CDA validation fails because of “Unknown type” in my server but not in standalone project

I was checking how to use the MDHT libraries to validate C-CDA documents, reviewing the current implementations, to create a validation web service for my project. 我正在检查如何使用MDHT库来验证C-CDA文档,并查看当前的实现,以为我的项目创建一个验证Web服务。 I firstly made a Eclipse local Java Project, added the JARs to the classpath, and implement the code. 我首先创建了一个Eclipse本地Java项目,将JAR添加到类路径中,并实现了代码。 The execution was successful. 执行成功。 But when I copy the same code to my web project (made with Spring Boot) and send a request that executes such code, the program fails. 但是,当我将相同的代码复制到我的Web项目(由Spring Boot创建)中并发送执行此类代码的请求时,程序将失败。

To explain better, I made the following minimal method: 为了更好地解释,我做了以下最少的方法:

public void executeMDHTCode(byte[] fileContents) {
    System.out.println(Arrays.toString(fileContents));
    ValidationResult result = new ValidationResult();
    ClinicalDocument doc = null;

    try {
        ConsolPackage.eINSTANCE.eClass();
        doc = CDAUtil.load(new ByteArrayInputStream(fileContents), result);
    } catch (ClassCastException|SAXParseException|Resource.IOWrappedException e) {
        doc = null;
    } catch (Exception e) {
        throw new RuntimeException("Unknown error: " + e.getMessage(), e);
    }
}

Then I used it in the following main method in my test project 然后我在测试项目的以下主要方法中使用了它

public static void main(String[] args) throws IOException { 
    ByteArrayOutputStream outstr = new ByteArrayOutputStream();
    int b = -1;
    InputStream stream = AppTest.class.getResourceAsStream("xml_ccda_invalid.xml");
    while((b = stream.read()) != -1) {
        outstr.write(b);
    }

    executeMDHTCode(outstr.toByteArray());   // only added 'static'
}

And then used the same code in my server project (encapsulating it in a ccdaService ) 然后在服务器项目中使用相同的代码(将其封装在ccdaService

@RequestMapping(/*POST endpoint properties*/)
public ResponseEntity<Object> validateCCDAFile(@RequestBody MultipartFile file) throws IOException {
    ccdaService.executeMDHTCode(file.getBytes());
    return null;
}

The document to be tested in both cases, xml_ccda_invalid.xml , contains the following: 两种情况下都要测试的文档xml_ccda_invalid.xml包含以下内容:

<?xml version="1.0" encoding="UTF-8"?>
<ClinicalDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:hl7-org:v3" xsi:schemaLocation="urn:hl7-org:v3 CDA.xsd">
  <realmCode code="US"/>
</ClinicalDocument>

As I said, the test project version terminates correctly. 如我所说,测试项目版本正确终止。 But the server version throws the following exception: 但是服务器版本引发以下异常:

java.lang.UnsupportedOperationException: Unknown type ([vocab, ActClinicalDocument, DOCCLIN])
    at org.eclipse.mdht.uml.cda.operations.ClinicalDocumentOperations.validateClassCode(ClinicalDocumentOperations.java:133) ~[org.eclipse.mdht.uml.cda-3.0.0.201706220503.jar:?]
    at org.eclipse.mdht.uml.cda.impl.ClinicalDocumentImpl.validateClassCode(ClinicalDocumentImpl.java:1659) ~[org.eclipse.mdht.uml.cda-3.0.0.201706220503.jar:?]
    at org.eclipse.mdht.uml.cda.util.CDAValidator.validateClinicalDocument_validateClassCode(CDAValidator.java:1769) ~[org.eclipse.mdht.uml.cda-3.0.0.201706220503.jar:?]
    at org.eclipse.mdht.uml.cda.util.CDAValidator.validateClinicalDocument(CDAValidator.java:1753) ~[org.eclipse.mdht.uml.cda-3.0.0.201706220503.jar:?]
    at org.eclipse.mdht.uml.cda.util.CDAValidator.validate(CDAValidator.java:1075) ~[org.eclipse.mdht.uml.cda-3.0.0.201706220503.jar:?]
    at org.eclipse.emf.ecore.util.EObjectValidator.validate(EObjectValidator.java:324) ~[org.eclipse.emf.ecore-2.12.0.v20160420-0247.jar:?]
    at org.eclipse.emf.ecore.util.Diagnostician.doValidate(Diagnostician.java:171) ~[org.eclipse.emf.ecore-2.12.0.v20160420-0247.jar:?]
    at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:158) ~[org.eclipse.emf.ecore-2.12.0.v20160420-0247.jar:?]
    at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:137) ~[org.eclipse.emf.ecore-2.12.0.v20160420-0247.jar:?]
    at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:108) ~[org.eclipse.emf.ecore-2.12.0.v20160420-0247.jar:?]
    at org.eclipse.mdht.uml.cda.util.CDAUtil.validate(CDAUtil.java:707) ~[org.eclipse.mdht.uml.cda-3.0.0.201706220503.jar:?]
    at org.eclipse.mdht.uml.cda.util.CDAUtil.validate(CDAUtil.java:696) ~[org.eclipse.mdht.uml.cda-3.0.0.201706220503.jar:?]
    at org.eclipse.mdht.uml.cda.util.CDAUtil.performEMFValidation(CDAUtil.java:830) ~[org.eclipse.mdht.uml.cda-3.0.0.201706220503.jar:?]
    at org.eclipse.mdht.uml.cda.util.CDAUtil.load(CDAUtil.java:277) ~[org.eclipse.mdht.uml.cda-3.0.0.201706220503.jar:?]
    at org.eclipse.mdht.uml.cda.util.CDAUtil.load(CDAUtil.java:252) ~[org.eclipse.mdht.uml.cda-3.0.0.201706220503.jar:?]
    at companypackage.service.impl.CCDAServiceImpl.executeMDHTCode(CCDAServiceImpl.java:109) ~[bin/:?]
    at companypackage.controller.CCDAController.validateCCDAFile(CCDAController.java:32) ~[bin/:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_102]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_102]
    at (other spring and apache calls...)

I used the println statement to check the contents of the input array, and they are in both cases identical, so it's not a matter of server processing of the file. 我使用了println语句来检查输入数组的内容,在两种情况下它们都是相同的,因此这不是服务器处理文件的问题。

I have not idea why this happens. 我不知道为什么会这样。 I put all the jars of the server project into the test project's classpath and it still worked, so it's not a class name clash. 我将服务器项目的所有jar放入测试项目的类路径中,并且仍然有效,因此这不是类名冲突。 It seems to be only interfere when actually used. 似乎只有在实际使用时才会产生干扰。

What could I be missing? 我可能会缺少什么?

The looks to be an issue with the war file deployment - the ActClinicalDocument is defined in the org.eclipse.mdht.uml.hl7.vocab jar; 战争文件部署似乎是一个问题-ActClinicalDocument是在org.eclipse.mdht.uml.hl7.vocab jar中定义的; if you are using maven for the build you can look at the following maven example https://github.com/mdht/mdht-models/tree/develop/examples/org.openhealthtools.mdht.cda.maven.example 如果您正在使用Maven进行构建,则可以查看以下Maven示例https://github.com/mdht/mdht-models/tree/develop/examples/org.openhealthtools.mdht.cda.maven.example

if not make sure in your eclipse project that the jars etc are included in the binary build 如果不能确保在eclipse项目中jars等包含在二进制版本中

听起来您好像没有在独立项目中应用架构,或者可能不是同一架构,因此它是在不参考验证过程的情况下进行验证的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM