-
Notifications
You must be signed in to change notification settings - Fork 8
Module: husky fhir emed ch epr
Quentin Ligier edited this page Feb 17, 2023
·
2 revisions
This is the module dedicated to the CH-EMED-EPR IG.
It is built upon the HAPI FHIR library, which does most of the work of implementing resources, providing parser and serializer. Resources are extended to provide a better API.
You can use HAPI's parser to get the standard resources, or our own ChEmedEprParser:
final var parser = new ChEmedEprParser(FhirContext.forR4Cached());
final var document = (ChEmedEprDocumentMtp) parser.parse(jsonOrXml, EmedDocumentType.MTP);
final var json = parser.serialize(document, EncodingEnum.JSON);
final var xml = parser.serializePrettyPrint(document, EncodingEnum.XML);
Easier done with the custom resources:
final UUID id = UUID.randomUUID();
final var composition = new ChEmedEprCompositionPmlc(id, date, language);
composition.getCardSection(); // Force creation of the required section
final var document = new ChEmedEprDocumentPmlc(id, timestamp);
document.getCompositionEntry().setResource(composition).setFullUrl(Uuids.URN_PREFIX + id);
// ...
A validator pre-loaded with the last IG version is available in ChEmedEprValidator:
final var validator = new ChEmedEprValidator(FhirContext.forR4Cached());
final var result = validator.validateDocumentBundle(document);
if (!result.isSuccessful()) {
System.out.println(String.format("[%s] %s [%s] in %s",
message.getSeverity().name(),
message.getMessage(),
message.getMessageId(),
message.getLocationString()));
}