Search in sources :

Example 1 with ValidationErrorDto

use of care.better.platform.web.template.validator.ValidationErrorDto in project openEHR_SDK by ehrbase.

the class CompositionValidatorImp method validateWithParams.

@Override
public List<ValidationErrorDto> validateWithParams(String template, String rawComposition, boolean strictTextValidation, boolean relaxedNameMatching) throws Exception {
    TemplateDocument templateDocument = TemplateDocument.Factory.parse(IOUtils.toInputStream(template, StandardCharsets.UTF_8));
    Composition composition = new CanonicalJson().unmarshal(rawComposition.replace("@class", "_type"), Composition.class);
    org.ehrbase.validation.CompositionValidator validator = new org.ehrbase.validation.CompositionValidator();
    List<ValidationErrorDto> errorDtoList = validator.validate(composition, templateDocument.getTemplate()).stream().filter(e -> !List.of("/content[openEHR-EHR-SECTION.ispek_dialog.v1 and name/value='Restraint medication']/items[openEHR-EHR-INSTRUCTION.medication_order.v1]/activities[at0001]/description[at0002]/items[at0070]", "/context/other_context[at0001]/items[at0.0.81]").contains(e.getAqlPath())).peek(e -> logger.info(e.getMessage() + "|" + e.getAqlPath())).map(e -> new ValidationErrorDto(e.getMessage(), new String[0], 0)).collect(Collectors.toList());
    return errorDtoList;
}
Also used : IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) TemplateDocument(org.openehr.schemas.v1.TemplateDocument) Logger(org.slf4j.Logger) Composition(com.nedap.archie.rm.composition.Composition) LoggerFactory(org.slf4j.LoggerFactory) CompositionValidator(care.better.platform.web.template.validator.CompositionValidator) Collectors(java.util.stream.Collectors) ValidationErrorDto(care.better.platform.web.template.validator.ValidationErrorDto) StandardCharsets(java.nio.charset.StandardCharsets) TemplateDocument(org.openehr.schemas.v1.TemplateDocument) Composition(com.nedap.archie.rm.composition.Composition) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionValidator(care.better.platform.web.template.validator.CompositionValidator) ValidationErrorDto(care.better.platform.web.template.validator.ValidationErrorDto)

Aggregations

CompositionValidator (care.better.platform.web.template.validator.CompositionValidator)1 ValidationErrorDto (care.better.platform.web.template.validator.ValidationErrorDto)1 Composition (com.nedap.archie.rm.composition.Composition)1 StandardCharsets (java.nio.charset.StandardCharsets)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 IOUtils (org.apache.commons.io.IOUtils)1 CanonicalJson (org.ehrbase.serialisation.jsonencoding.CanonicalJson)1 TemplateDocument (org.openehr.schemas.v1.TemplateDocument)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1