HAPI FHIR – From CDA to FHIR by usinf StructureMap

I’m using hapi-fhir version 7.2.1 and I’m trying to convert a CDA document in FHIR resource by using FHIR Mapping language and StructureMap resources

I wrote this unit test

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>@SpringBootTest(
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = {FhirCda2FhirServerApplication.class})
@ExtendWith(SpringExtension.class)
@Slf4j
public class CdaToFhirTests {
@Autowired
@Qualifier("fhirJsonParser")
private IParser jsonParser;
@Autowired private FhirContext fhirContext;
@Autowired private DefaultProfileValidationSupport defaultProfileValidationSupport;
private static IWorkerContext workerContext;
@Test
public void testCdaToFhirConverter() throws Exception {
log.info("Test CDA to FHIR converter");
// prePopulatedValidationSupport.addStructureDefinition(sd);
HapiWorkerContext hapiWorkerContext =
new HapiWorkerContext(fhirContext, defaultProfileValidationSupport);
hapiWorkerContext.allStructures().stream()
.forEach(
structureDefinition -> {
log.info(
"StructureDefinition type {} url {}",
structureDefinition.getType(),
structureDefinition.getUrl());
});
log.info("ALL STRUCT {}", hapiWorkerContext.allStructures());
FileSystemResource cdaXmlResource = new FileSystemResource("ccda.xml");
StructureMap structureMap =
jsonParser.parseResource(
StructureMap.class, new FileSystemResource("StructureMap.json").getInputStream());
log.info("Loaded StructureMap {}", structureMap);
StructureMapUtilities utils = new StructureMapUtilities(hapiWorkerContext);
Element parsedCda =
Manager.parse(hapiWorkerContext, cdaXmlResource.getInputStream(), FhirFormat.XML);
Bundle target = new Bundle();
utils.transform(null, parsedCda, structureMap, target);
log.info("Bundle {}", jsonParser.encodeResourceToString(target));
}
}
</code>
<code>@SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = {FhirCda2FhirServerApplication.class}) @ExtendWith(SpringExtension.class) @Slf4j public class CdaToFhirTests { @Autowired @Qualifier("fhirJsonParser") private IParser jsonParser; @Autowired private FhirContext fhirContext; @Autowired private DefaultProfileValidationSupport defaultProfileValidationSupport; private static IWorkerContext workerContext; @Test public void testCdaToFhirConverter() throws Exception { log.info("Test CDA to FHIR converter"); // prePopulatedValidationSupport.addStructureDefinition(sd); HapiWorkerContext hapiWorkerContext = new HapiWorkerContext(fhirContext, defaultProfileValidationSupport); hapiWorkerContext.allStructures().stream() .forEach( structureDefinition -> { log.info( "StructureDefinition type {} url {}", structureDefinition.getType(), structureDefinition.getUrl()); }); log.info("ALL STRUCT {}", hapiWorkerContext.allStructures()); FileSystemResource cdaXmlResource = new FileSystemResource("ccda.xml"); StructureMap structureMap = jsonParser.parseResource( StructureMap.class, new FileSystemResource("StructureMap.json").getInputStream()); log.info("Loaded StructureMap {}", structureMap); StructureMapUtilities utils = new StructureMapUtilities(hapiWorkerContext); Element parsedCda = Manager.parse(hapiWorkerContext, cdaXmlResource.getInputStream(), FhirFormat.XML); Bundle target = new Bundle(); utils.transform(null, parsedCda, structureMap, target); log.info("Bundle {}", jsonParser.encodeResourceToString(target)); } } </code>
@SpringBootTest(
    webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
    classes = {FhirCda2FhirServerApplication.class})
@ExtendWith(SpringExtension.class)
@Slf4j
public class CdaToFhirTests {
  @Autowired
  @Qualifier("fhirJsonParser")
  private IParser jsonParser;

  @Autowired private FhirContext fhirContext;
  @Autowired private DefaultProfileValidationSupport defaultProfileValidationSupport;
  private static IWorkerContext workerContext;


  @Test
  public void testCdaToFhirConverter() throws Exception {
    log.info("Test CDA to FHIR converter");

    // prePopulatedValidationSupport.addStructureDefinition(sd);
    HapiWorkerContext hapiWorkerContext =
        new HapiWorkerContext(fhirContext, defaultProfileValidationSupport);
    hapiWorkerContext.allStructures().stream()
        .forEach(
            structureDefinition -> {
              log.info(
                  "StructureDefinition type {} url {}",
                  structureDefinition.getType(),
                  structureDefinition.getUrl());
            });

    log.info("ALL STRUCT {}", hapiWorkerContext.allStructures());
    FileSystemResource cdaXmlResource = new FileSystemResource("ccda.xml");
    StructureMap structureMap =
        jsonParser.parseResource(
            StructureMap.class, new FileSystemResource("StructureMap.json").getInputStream());
    log.info("Loaded StructureMap {}", structureMap);
    StructureMapUtilities utils = new StructureMapUtilities(hapiWorkerContext);
    Element parsedCda =
        Manager.parse(hapiWorkerContext, cdaXmlResource.getInputStream(), FhirFormat.XML);
    Bundle target = new Bundle();
    utils.transform(null, parsedCda, structureMap, target);
    log.info("Bundle {}", jsonParser.encodeResourceToString(target));
  }
}

But when I execute it I get this error:

org.hl7.fhir.exceptions.FHIRFormatError: This does not appear to be a
FHIR resource (unknown namespace/name
‘urn:hl7-org:v3::ClinicalDocument’) at line 0 col 0

at
org.hl7.fhir.r4.elementmodel.ParserBase.logError(ParserBase.java:104)
at
org.hl7.fhir.r4.elementmodel.ParserBase.getDefinition(ParserBase.java:130)
at org.hl7.fhir.r4.elementmodel.XmlParser.parse(XmlParser.java:181)
at org.hl7.fhir.r4.elementmodel.XmlParser.parse(XmlParser.java:172)
at org.hl7.fhir.r4.elementmodel.XmlParser.parse(XmlParser.java:143)
at org.hl7.fhir.r4.elementmodel.Manager.parse(Manager.java:67) at
it.eng.pnt.fhir.cda2fhir.test.CdaToFhirTests.testCdaToFhirConverter(CdaToFhirTests.java:98)
at java.base/java.lang.reflect.Method.invoke(Method.java:580) at
java.base/java.util.ArrayList.forEach(ArrayList.java:1597) at
java.base/java.util.ArrayList.forEach(ArrayList.java:1597)

I can’t figure out what I’m missing. May anybody give me a tip?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật