diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d76efbf..67bcb37 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build IPF Gazelle with Maven +name: Build IPF Gazelle with Maven with Java 17 on: [push, pull_request] @@ -8,18 +8,15 @@ env: jobs: build: runs-on: ubuntu-latest - strategy: - matrix: - java: [ 11, 17 ] - name: Java ${{ matrix.java }} build + name: Java 17 build timeout-minutes: 90 steps: - uses: actions/checkout@v4 - name: Setup Java uses: actions/setup-java@v3 with: - distribution: 'zulu' - java-version: ${{ matrix.java }} + distribution: 'temurin' + java-version: 17 cache: 'maven' - name: Build with Maven run: mvn -B clean package --file pom.xml diff --git a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/CachingGazelleProfileRule.java b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/CachingGazelleProfileRule.java index fbcac95..dbb54a6 100644 --- a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/CachingGazelleProfileRule.java +++ b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/CachingGazelleProfileRule.java @@ -26,9 +26,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; +import jakarta.xml.bind.JAXBContext; +import jakarta.xml.bind.JAXBException; +import jakarta.xml.bind.Unmarshaller; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.concurrent.ConcurrentHashMap; @@ -78,11 +78,11 @@ public CachingGazelleProfileRule(ConformanceProfile profile) { @Override public ValidationException[] apply(Message message) { try { - ConformanceProfile profile = this.profile == null ? guessGazelleProfile(iheTransaction, message) : this.profile; + var profile = this.profile == null ? guessGazelleProfile(iheTransaction, message) : this.profile; if (profile == null) { return failed("No matching profile could be loaded for message of type " + message.getClass().getName()); } - GazelleProfileRule rule = parseProfile(message.getParser().getHapiContext(), profile.profileInfo().profileId()); + var rule = parseProfile(message.getParser().getHapiContext(), profile.profileInfo().profileId()); if (rule == null) { return failed("Cannot parse conformance profile " + profile.profileInfo().profileId() + " for message of type " + message.getClass().getName()); } @@ -99,41 +99,38 @@ public ValidationException[] apply(Message message) { * @param hapiContext HapiContext from the message * @param profileId profile id * @return GazelleProfileRule - * @throws JAXBException - * @throws IOException */ protected GazelleProfileRule parseProfile(HapiContext hapiContext, String profileId) throws JAXBException, IOException { - GazelleProfileRule validator = VALIDATOR_CACHE.get(profileId); + var validator = VALIDATOR_CACHE.get(profileId); if (validator != null) return validator; // Several threads could attempt to load the same profile, but this should only happen at the very // beginning. As a benefit we don't need any locking here. LOG.debug("Conformance Profile {} requested, but has not been parsed yet", profileId); - GazelleProfileRule loaded = loadRule(hapiContext, profileId); + var loaded = loadRule(hapiContext, profileId); if (VALIDATOR_CACHE.putIfAbsent(profileId, loaded) == null) { LOG.debug("Added conformance profile {} to cache", profileId); return loaded; } else { - LOG.debug("Parsed conformance profile {}, but was already added"); + LOG.debug("Parsed conformance profile {}, but was already added", profileId); return VALIDATOR_CACHE.get(profileId); } } protected GazelleProfileRule loadRule(HapiContext hapiContext, String profileId) throws JAXBException, IOException { - String profileString = hapiContext.getProfileStore().getProfile(profileId); - HL7V2XConformanceProfile conformanceProfile = + var profileString = hapiContext.getProfileStore().getProfile(profileId); + var conformanceProfile = (HL7V2XConformanceProfile) getUnmarshaller().unmarshal(new ByteArrayInputStream(profileString.getBytes())); - GazelleProfileRule validator = new GazelleProfileRule(conformanceProfile); - return validator; + return new GazelleProfileRule(conformanceProfile); } // Unmarshaller are not thread-safe, but creation should happen only once for each profile private Unmarshaller getUnmarshaller() { try { - JAXBContext jaxbContext = JAXBContext.newInstance(HL7V2XConformanceProfile.class); + var jaxbContext = JAXBContext.newInstance(HL7V2XConformanceProfile.class); return jaxbContext.createUnmarshaller(); } catch (JAXBException jaxbException) { throw new RuntimeException(jaxbException.getMessage()); diff --git a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/GazelleProfileRule.java b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/GazelleProfileRule.java index 5382213..7954bf1 100644 --- a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/GazelleProfileRule.java +++ b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/GazelleProfileRule.java @@ -16,45 +16,8 @@ package org.openehealth.ipf.gazelle.validation.core; -import static org.openehealth.ipf.gazelle.validation.core.util.MessageUtils.checkMSHEventField; -import static org.openehealth.ipf.gazelle.validation.core.util.MessageUtils.checkMSHTypeField; -import static org.openehealth.ipf.gazelle.validation.core.util.MessageUtils.checkMSHVersionField; -import static org.openehealth.ipf.gazelle.validation.core.util.ProfileAssertions.profileNotHL7Compliant; -import static org.openehealth.ipf.gazelle.validation.core.util.ProfileAssertions.profileViolatedWhen; -import static org.openehealth.ipf.gazelle.validation.core.util.ProfileValidationMessage.COMPONENT_NOT_DEFINED_IN_PROFILE; -import static org.openehealth.ipf.gazelle.validation.core.util.ProfileValidationMessage.COMPONENT_TYPE_MISMATCH; -import static org.openehealth.ipf.gazelle.validation.core.util.ProfileValidationMessage.FIELD_NOT_DEFINED_IN_PROFILE; -import static org.openehealth.ipf.gazelle.validation.core.util.ProfileValidationMessage.FIELD_NOT_FOUND; -import static org.openehealth.ipf.gazelle.validation.core.util.ProfileValidationMessage.HL7_DATATYPE_MISMATCH; -import static org.openehealth.ipf.gazelle.validation.core.util.ProfileValidationMessage.LENGTH_EXCEEDED; -import static org.openehealth.ipf.gazelle.validation.core.util.ProfileValidationMessage.LESS_THAN_MINIMUM_CARDINALITY; -import static org.openehealth.ipf.gazelle.validation.core.util.ProfileValidationMessage.MORE_THAN_MAXIMUM_CARDINALITY; -import static org.openehealth.ipf.gazelle.validation.core.util.ProfileValidationMessage.NOT_SUPPORTED_ELEMENT_PRESENT; -import static org.openehealth.ipf.gazelle.validation.core.util.ProfileValidationMessage.NO_ELEMENTS_AFTER_NULL; -import static org.openehealth.ipf.gazelle.validation.core.util.ProfileValidationMessage.PROFILE_STRUCTURE_MISMATCH; -import static org.openehealth.ipf.gazelle.validation.core.util.ProfileValidationMessage.PROFILE_STRUCTURE_NOT_EXIST_IN_JAVA_CLASS; -import static org.openehealth.ipf.gazelle.validation.core.util.ProfileValidationMessage.REQUIRED_ELEMENT_MISSING; -import static org.openehealth.ipf.gazelle.validation.core.util.ProfileValidationMessage.STRUCTURE_NOT_DEFINED_IN_PROFILE; -import static org.openehealth.ipf.gazelle.validation.core.util.ProfileValidationMessage.SUBCOMPONENT_TYPE_MISMATCH; -import static org.openehealth.ipf.gazelle.validation.core.util.ProfileValidationMessage.WRONG_COMPONENT_TYPE; -import static org.openehealth.ipf.gazelle.validation.core.util.ProfileValidationMessage.WRONG_CONSTANT_VALUE; -import static org.openehealth.ipf.gazelle.validation.core.util.ProfileValidationMessage.WRONG_FIELD_TYPE; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - import ca.uhn.hl7v2.HL7Exception; -import ca.uhn.hl7v2.model.Composite; -import ca.uhn.hl7v2.model.DataTypeException; -import ca.uhn.hl7v2.model.Group; -import ca.uhn.hl7v2.model.Message; -import ca.uhn.hl7v2.model.Primitive; -import ca.uhn.hl7v2.model.Segment; -import ca.uhn.hl7v2.model.Structure; -import ca.uhn.hl7v2.model.Type; -import ca.uhn.hl7v2.model.Visitable; +import ca.uhn.hl7v2.model.*; import ca.uhn.hl7v2.model.primitive.TSComponentOne; import ca.uhn.hl7v2.parser.EncodingCharacters; import ca.uhn.hl7v2.parser.PipeParser; @@ -64,8 +27,16 @@ import org.openehealth.ipf.gazelle.validation.core.stub.HL7V2XConformanceProfile; import org.openehealth.ipf.gazelle.validation.core.stub.HL7V2XStaticDef; import org.openehealth.ipf.gazelle.validation.core.stub.SegmentType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import static org.openehealth.ipf.gazelle.validation.core.util.MessageUtils.*; +import static org.openehealth.ipf.gazelle.validation.core.util.ProfileAssertions.profileNotHL7Compliant; +import static org.openehealth.ipf.gazelle.validation.core.util.ProfileAssertions.profileViolatedWhen; +import static org.openehealth.ipf.gazelle.validation.core.util.ProfileValidationMessage.*; /** * A modified conformance profile validator from HAPI. This implementation differs from HAPI's @@ -74,9 +45,8 @@ */ public class GazelleProfileRule extends AbstractMessageRule { - private EncodingCharacters enc; - private static final Logger LOG = LoggerFactory.getLogger(GazelleProfileRule.class); - private HL7V2XConformanceProfile profile; + private final EncodingCharacters enc; + private final HL7V2XConformanceProfile profile; private boolean validateChildren = true; public GazelleProfileRule(HL7V2XConformanceProfile profile) { @@ -97,7 +67,7 @@ public ValidationException[] apply(Message message) { List violations = new ArrayList<>(); HL7V2XStaticDef staticDef = null; - for (Object ref : profile.getDynamicDevesAndHL7V2XStaticDevesAndHL7V2XStaticDefReves()) { + for (var ref : profile.getDynamicDevesAndHL7V2XStaticDevesAndHL7V2XStaticDefReves()) { if (ref.getClass().isAssignableFrom(HL7V2XStaticDef.class)) { staticDef = (HL7V2XStaticDef) ref; } @@ -106,14 +76,14 @@ public ValidationException[] apply(Message message) { if (staticDef == null) { violations.add(new ValidationException("No Static Definitions found in HL7V2XConformance profile")); } else { - Terser terser = new Terser(message); + var terser = new Terser(message); checkMSHTypeField(staticDef.getMsgType(), terser, violations); checkMSHEventField(staticDef.getEventType(), terser, violations); // checkMSHStructureField(staticDef.getMsgStructID(), terser, violations); checkMSHVersionField(profile.getHL7Version(), terser, violations); violations.addAll(testGroup(message, staticDef.getSegmentsAndSegGroups())); } - return violations.toArray(new ValidationException[violations.size()]); + return violations.toArray(new ValidationException[0]); } /** @@ -129,19 +99,19 @@ protected List testGroup(Group group, List profile) List exList = new ArrayList<>(); List allowedStructures = new ArrayList<>(); - for (Object struct : profile) { - UsageInfo usage = new UsageInfo(struct); + for (var struct : profile) { + var usage = new UsageInfo(struct); if (!usage.disallowed()) { allowedStructures.add(usage.name); try { - List nonEmptyStructures = nonEmptyStructure(group.getAll(usage.name)); + var nonEmptyStructures = nonEmptyStructure(group.getAll(usage.name)); exList.addAll(testCardinality(nonEmptyStructures.size(), usage)); // test children on instances with content if (validateChildren) { - for (Structure structure : nonEmptyStructures) { + for (var structure : nonEmptyStructures) { exList.addAll(testStructure(structure, struct)); } } @@ -164,10 +134,10 @@ protected List testGroup(Group group, List profile) */ protected List checkForExtraStructures(Group group, List allowedStructures) { List exList = new ArrayList<>(); - for (String childName : group.getNames()) { + for (var childName : group.getNames()) { if (!allowedStructures.contains(childName)) { try { - for (Structure rep : group.getAll(childName)) { + for (var rep : group.getAll(childName)) { profileViolatedWhen(!isEmpty(rep), exList, STRUCTURE_NOT_DEFINED_IN_PROFILE, childName); } } catch (HL7Exception he) { @@ -226,27 +196,24 @@ protected List testStructure(Structure s, Object profile) { protected List testSegment(Segment segment, SegmentType profile) { List exList = new ArrayList<>(); List allowedFields = new ArrayList<>(); - int i = 1; - for (SegmentType.Field field : profile.getFields()) { - UsageInfo usage = new UsageInfo(field); + var i = 1; + for (var field : profile.getFields()) { + var usage = new UsageInfo(field); // only test a field in detail if it isn't X if (!usage.disallowed()) { allowedFields.add(i); // see which instances have content try { - Collection nonEmptyFields = nonEmptyField(segment.getField(i)); + var nonEmptyFields = nonEmptyField(segment.getField(i)); exList.addAll(testCardinality(nonEmptyFields.size(), usage)); // test field instances with content if (validateChildren) { - for (Type type : nonEmptyFields) { - boolean escape = true; // escape field value when checking length - if (profile.getName().equalsIgnoreCase("MSH") && i < 3) { - escape = false; - } - List childExceptions = testField(type, field, escape); - for (ValidationException ex : childExceptions) { + for (var type : nonEmptyFields) { + var escape = !profile.getName().equalsIgnoreCase("MSH") || i >= 3; // escape field value when checking length + var childExceptions = testField(type, field, escape); + for (var ex : childExceptions) { ex.setFieldPosition(i); } exList.addAll(childExceptions); @@ -261,7 +228,7 @@ protected List testSegment(Segment segment, SegmentType pro // complain about X fields with content exList.addAll(checkForExtraFields(segment, allowedFields)); - for (ValidationException ex : exList) { + for (var ex : exList) { ex.setSegmentName(profile.getName()); } return exList; @@ -275,12 +242,12 @@ protected List testSegment(Segment segment, SegmentType pro * @param allowedFields an array of Integers containing field #s of allowed fields */ protected List checkForExtraFields(Segment segment, List allowedFields) { - ArrayList exList = new ArrayList<>(); - for (int i = 1; i <= segment.numFields(); i++) { + var exList = new ArrayList(); + for (var i = 1; i <= segment.numFields(); i++) { if (!allowedFields.contains(i)) { try { - Type[] reps = segment.getField(i); - for (Type rep : reps) { + var reps = segment.getField(i); + for (var rep : reps) { profileViolatedWhen(!isEmpty(rep), exList, FIELD_NOT_DEFINED_IN_PROFILE, i, segment.getName()); } } catch (HL7Exception he) { @@ -292,46 +259,44 @@ protected List checkForExtraFields(Segment segment, List testField(Type type, SegmentType.Field profile, boolean escape) { - List exList = new ArrayList<>(); - UsageInfo usage = new UsageInfo(profile); + var usage = new UsageInfo(profile); // account for MSH 1 & 2 which aren't escaped String encoded = null; if (!escape && Primitive.class.isAssignableFrom(type.getClass())) encoded = ((Primitive) type).getValue(); - exList.addAll(testType(type, profile.getDatatype(), usage, encoded, false)); + List exList = new ArrayList<>(testType(type, profile.getDatatype(), usage, encoded, false)); // test children if (validateChildren) { - if (profile.getComponents().size() > 0 && !usage.disallowed()) { + if (!profile.getComponents().isEmpty() && !usage.disallowed()) { if (Composite.class.isAssignableFrom(type.getClass())) { - Composite comp = (Composite) type; - int i = 1; - boolean nullContext = false; - for (SegmentType.Field.Component component : profile.getComponents()) { + var comp = (Composite) type; + var i = 1; + var nullContext = false; + for (var component : profile.getComponents()) { try { SegmentType.Field.Component component2; if (nullContext) { component2 = new SegmentType.Field.Component(); component2.setConstantValue(component.getConstantValue()); - component2.setDatatype(component.getDatatype()); - component2.getDataValues().addAll(component.getDataValues()); component2.setDescription(component.getDescription()); - component2.setImpNote(component.getImpNote()); - component2.setLength(component.getLength()); + component2.setDatatype(component.getDatatype()); component2.setName(component.getName()); component2.setPredicate(component.getPredicate()); component2.setReference(component.getReference()); - component2.getSubComponents().addAll(component.getSubComponents()); + component2.setImpNote(component.getImpNote()); + component2.setLength(component.getLength()); component2.setTable(component.getTable()); + component2.getSubComponents().addAll(component.getSubComponents()); + component2.getDataValues().addAll(component.getDataValues()); component2.setUsage("NULL"); } else { component2 = component; if ((i == 1) && profile.isNullable() && - PipeParser.encode(comp.getComponent(0), this.enc).equals("\"\"")) - { + PipeParser.encode(comp.getComponent(0), this.enc).equals("\"\"")) { nullContext = true; } } @@ -362,7 +327,7 @@ protected List testType(Type type, String dataType, UsageIn * pipe-encoded form is used to check length and constant val) */ protected List testType(Type type, String dataType, UsageInfo usage, String encoded, boolean testUsage) { - ArrayList exList = new ArrayList<>(); + var exList = new ArrayList(); if (encoded == null) encoded = PipeParser.encode(type, this.enc); @@ -388,7 +353,7 @@ protected List testType(Type type, String dataType, UsageIn exList, LENGTH_EXCEEDED, usage.name, encoded.length(), usage.length); // check constant value - if (usage.constantValue != null && usage.constantValue.length() > 0) { + if (usage.constantValue != null && !usage.constantValue.isEmpty()) { profileViolatedWhen(!encoded.equals(usage.constantValue), exList, WRONG_CONSTANT_VALUE, encoded, usage.constantValue); } @@ -415,38 +380,24 @@ protected void testUsage(List exList, String encoded, Usage } else if (usage.nullContext()) { profileViolatedWhen(!encoded.isEmpty(), exList, NO_ELEMENTS_AFTER_NULL, usage.name); } - /* - else if (usage.equalsIgnoreCase("RE")) { - // can't test anything - } else if (usage.equalsIgnoreCase("O")) { - // can't test anything - } else if (usage.equalsIgnoreCase("C")) { - // can't test anything yet -- wait for condition syntax in v2.6 - } else if (usage.equalsIgnoreCase("CE")) { - // can't test anything - } else if (usage.equalsIgnoreCase("B")) { - // can't test anything - } - */ } protected List testComponent(Type type, SegmentType.Field.Component profile) { - List exList = new ArrayList<>(); - UsageInfo usage = new UsageInfo(profile); - exList.addAll(testType(type, profile.getDatatype(), usage, null)); + var usage = new UsageInfo(profile); + List exList = new ArrayList<>(testType(type, profile.getDatatype(), usage, null)); // test children try { - if (profile.getSubComponents().size() > 0 && !usage.disallowed() && !isEmpty(type)) { + if (!profile.getSubComponents().isEmpty() && !usage.disallowed() && !isEmpty(type)) { if (Composite.class.isAssignableFrom(type.getClass())) { - Composite comp = (Composite) type; + var comp = (Composite) type; if (validateChildren) { - int i = 1; - for (SegmentType.Field.Component.SubComponent subComponent : profile.getSubComponents()) { - UsageInfo scUsage = new UsageInfo(subComponent); + var i = 1; + for (var subComponent : profile.getSubComponents()) { + var scUsage = new UsageInfo(subComponent); try { - Type sub = comp.getComponent(i - 1); + var sub = comp.getComponent(i - 1); exList.addAll(testType(sub, subComponent.getDatatype(), scUsage, null)); } catch (DataTypeException de) { profileNotHL7Compliant(exList, SUBCOMPONENT_TYPE_MISMATCH, type.getName(), i); @@ -473,27 +424,28 @@ protected List testComponent(Type type, SegmentType.Field.C protected List checkUndefinedComponents(Composite comp, int numInProfile) { List exList = new ArrayList<>(); - StringBuilder extra = new StringBuilder(); - for (int i = numInProfile; i < comp.getComponents().length; i++) { + var extra = new StringBuilder(); + for (var i = numInProfile; i < comp.getComponents().length; i++) { try { - String s = comp.getComponent(i).encode(); - if (s.length() > 0) { + var s = comp.getComponent(i).encode(); + if (!s.isEmpty()) { extra.append(s).append(enc.getComponentSeparator()); } } catch (HL7Exception de) { exList.add(new ValidationException(de)); } } - profileViolatedWhen(extra.toString().length() > 0, exList, COMPONENT_NOT_DEFINED_IN_PROFILE, extra.toString()); + profileViolatedWhen(!extra.toString().isEmpty(), exList, COMPONENT_NOT_DEFINED_IN_PROFILE, extra.toString()); return exList; } + @SafeVarargs private static List nonEmptyStructure(T... input) throws HL7Exception { List result = new ArrayList<>(); if (input != null) { - for (T element : input) { + for (var element : input) { if (!isEmpty(element)) result.add(element); } } @@ -502,30 +454,29 @@ private static List nonEmptyStructure(T... input) throw // In contrast to {@link #nonEmptyStructure, this will only remove trailing empty fields. // If all fields are empty, an empty list is returned + @SafeVarargs private static Collection nonEmptyField(T... input) throws HL7Exception { if (input == null || input.length == 0) return Collections.emptySet(); - if (input.length == 1) return isEmpty(input[0]) ? Collections.emptySet() : Collections.singleton(input[0]); + if (input.length == 1) return isEmpty(input[0]) ? Collections.emptySet() : Collections.singleton(input[0]); - boolean seenNonEmptyRepetition = false; + var seenNonEmptyRepetition = false; List result = new ArrayList<>(); - for (T element : input) { - boolean isEmpty = isEmpty(element); + for (var element : input) { + var isEmpty = isEmpty(element); if (!(isEmpty && seenNonEmptyRepetition)) { seenNonEmptyRepetition = result.add(element); } } - return seenNonEmptyRepetition ? result : Collections.emptySet(); + return seenNonEmptyRepetition ? result : Collections.emptySet(); } // Work around HAPI #224: TSComponentOne implementation of isEmpty is buggy private static boolean isEmpty(Visitable v) throws HL7Exception { if (v == null) return true; - if (v instanceof TSComponentOne) { - TSComponentOne tsc1 = (TSComponentOne) v; + if (v instanceof TSComponentOne tsc1) { return tsc1.getValue() == null || tsc1.getValue().isEmpty(); } - if (v instanceof Composite && v.getClass().getName().endsWith(".TS")) { - Composite ts = (Composite)v; + if (v instanceof Composite ts && v.getClass().getName().endsWith(".TS")) { return isEmpty(ts.getComponent(0)); } return v.isEmpty(); diff --git a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/UsageInfo.java b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/UsageInfo.java index 28b7745..b9db45e 100644 --- a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/UsageInfo.java +++ b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/UsageInfo.java @@ -22,7 +22,7 @@ /** * Helper class that encapsulate usage-specific attributes of a confirmance profile */ -class UsageInfo { +public class UsageInfo { String name; String usage; int max; @@ -32,16 +32,16 @@ class UsageInfo { UsageInfo(Object profileElement) { if (profileElement.getClass().isAssignableFrom(SegmentType.class)) { - SegmentType structure = (SegmentType) profileElement; + var structure = (SegmentType) profileElement; usage = structure.getUsage(); name = structure.getName(); - max = structure.getMax().equals("*") ? Short.MAX_VALUE : Short.valueOf(structure.getMax()); + max = structure.getMax().equals("*") ? Short.MAX_VALUE : Short.parseShort(structure.getMax()); min = structure.getMin().intValue(); } else if (profileElement.getClass().isAssignableFrom(HL7V2XStaticDef.SegGroup.class)) { - HL7V2XStaticDef.SegGroup segGroup = (HL7V2XStaticDef.SegGroup) profileElement; + var segGroup = (HL7V2XStaticDef.SegGroup) profileElement; usage = segGroup.getUsage(); name = segGroup.getName(); - max = segGroup.getMax().equals("*") ? Short.MAX_VALUE : Short.valueOf(segGroup.getMax()); + max = segGroup.getMax().equals("*") ? Short.MAX_VALUE : Short.parseShort(segGroup.getMax()); min = segGroup.getMin().intValue(); } else { // Should never happen as the XML schema and JAXB translation do not yield other types @@ -52,7 +52,7 @@ class UsageInfo { UsageInfo(SegmentType.Field field) { usage = field.getUsage(); name = field.getName(); - max = field.getMax().equals("*") ? Short.MAX_VALUE : Short.valueOf(field.getMax()); + max = field.getMax().equals("*") ? Short.MAX_VALUE : Short.parseShort(field.getMax()); min = field.getMin().intValue(); length = field.getLength().intValue(); constantValue = field.getConstantValue(); diff --git a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/AcknowledgmentType.java b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/AcknowledgmentType.java index 54141e0..c4aee9e 100644 --- a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/AcknowledgmentType.java +++ b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/AcknowledgmentType.java @@ -8,8 +8,8 @@ package org.openehealth.ipf.gazelle.validation.core.stub; -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlEnum; +import jakarta.xml.bind.annotation.XmlType; /** diff --git a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/HL7V2XConformanceProfile.java b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/HL7V2XConformanceProfile.java index 500e01d..8ac28d0 100644 --- a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/HL7V2XConformanceProfile.java +++ b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/HL7V2XConformanceProfile.java @@ -10,18 +10,20 @@ import java.util.ArrayList; import java.util.List; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementRef; -import javax.xml.bind.annotation.XmlElementRefs; -import javax.xml.bind.annotation.XmlElements; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import java.util.Objects; + +import jakarta.xml.bind.JAXBElement; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlElementRef; +import jakarta.xml.bind.annotation.XmlElementRefs; +import jakarta.xml.bind.annotation.XmlElements; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.adapters.CollapsedStringAdapter; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** @@ -470,11 +472,7 @@ public static class DynamicDef { * */ public AcknowledgmentType getAccAck() { - if (accAck == null) { - return AcknowledgmentType.NE; - } else { - return accAck; - } + return Objects.requireNonNullElse(accAck, AcknowledgmentType.NE); } /** @@ -498,11 +496,7 @@ public void setAccAck(AcknowledgmentType value) { * */ public AcknowledgmentType getAppAck() { - if (appAck == null) { - return AcknowledgmentType.AL; - } else { - return appAck; - } + return Objects.requireNonNullElse(appAck, AcknowledgmentType.AL); } /** @@ -526,11 +520,7 @@ public void setAppAck(AcknowledgmentType value) { * */ public String getMsgAckMode() { - if (msgAckMode == null) { - return "Deferred"; - } else { - return msgAckMode; - } + return Objects.requireNonNullElse(msgAckMode, "Deferred"); } /** @@ -554,11 +544,7 @@ public void setMsgAckMode(String value) { * */ public String getQueryMessageType() { - if (queryMessageType == null) { - return "NonQuery"; - } else { - return queryMessageType; - } + return Objects.requireNonNullElse(queryMessageType, "NonQuery"); } /** @@ -582,11 +568,7 @@ public void setQueryMessageType(String value) { * */ public String getQueryMode() { - if (queryMode == null) { - return "RealTime"; - } else { - return queryMode; - } + return Objects.requireNonNullElse(queryMode, "RealTime"); } /** diff --git a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/HL7V2XStaticDef.java b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/HL7V2XStaticDef.java index 2d7805e..8a7fbe7 100644 --- a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/HL7V2XStaticDef.java +++ b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/HL7V2XStaticDef.java @@ -11,16 +11,18 @@ import java.math.BigInteger; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElements; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlSchemaType; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import java.util.Objects; + +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlElements; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlSchemaType; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.adapters.CollapsedStringAdapter; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** @@ -383,11 +385,7 @@ public void setIdentifier(String value) { * */ public String getRole() { - if (role == null) { - return "Sender"; - } else { - return role; - } + return Objects.requireNonNullElse(role, "Sender"); } /** diff --git a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/MetaDataType.java b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/MetaDataType.java index a02a453..e2fc765 100644 --- a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/MetaDataType.java +++ b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/MetaDataType.java @@ -8,10 +8,10 @@ package org.openehealth.ipf.gazelle.validation.core.stub; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlType; /** diff --git a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/ObjectFactory.java b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/ObjectFactory.java index d6d970f..08c94ae 100644 --- a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/ObjectFactory.java +++ b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/ObjectFactory.java @@ -8,9 +8,9 @@ package org.openehealth.ipf.gazelle.validation.core.stub; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.annotation.XmlElementDecl; -import javax.xml.bind.annotation.XmlRegistry; +import jakarta.xml.bind.JAXBElement; +import jakarta.xml.bind.annotation.XmlElementDecl; +import jakarta.xml.bind.annotation.XmlRegistry; import javax.xml.namespace.QName; diff --git a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/SegmentType.java b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/SegmentType.java index 27103b4..2c7e28a 100644 --- a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/SegmentType.java +++ b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/SegmentType.java @@ -11,14 +11,14 @@ import java.math.BigInteger; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlSchemaType; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlSchemaType; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.adapters.CollapsedStringAdapter; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** diff --git a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/UseCaseElementType.java b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/UseCaseElementType.java index a040ee2..e02e68d 100644 --- a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/UseCaseElementType.java +++ b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/stub/UseCaseElementType.java @@ -8,11 +8,11 @@ package org.openehealth.ipf.gazelle.validation.core.stub; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.XmlValue; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlValue; /** diff --git a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/util/MessageUtils.java b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/util/MessageUtils.java index 3e50bfd..e2da0e4 100644 --- a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/util/MessageUtils.java +++ b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/util/MessageUtils.java @@ -76,12 +76,11 @@ public static String mshField(String mshFieldNo, Terser t) throws HL7Exception { * @param iheTransaction concrete IHETransaction * @param message hapi message * @return GazelleProfile that matches message type, event, structure & version - * @throws HL7Exception */ public static ConformanceProfile guessGazelleProfile(HL7v2Transactions iheTransaction, Message message) throws HL7Exception { - Terser terser = new Terser(message); - for (ConformanceProfile conformanceProfile : iheTransaction.conformanceProfiles()) { + var terser = new Terser(message); + for (var conformanceProfile : iheTransaction.conformanceProfiles()) { if (matches(conformanceProfile.profileInfo(), terser)) { return conformanceProfile; } diff --git a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/util/ProfileAssertions.java b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/util/ProfileAssertions.java index 1155a15..7425d52 100644 --- a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/util/ProfileAssertions.java +++ b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/util/ProfileAssertions.java @@ -30,7 +30,7 @@ private ProfileAssertions() { public static void profileViolatedWhen(boolean errorCondition, List exceptions, ProfileValidationMessage validationErrorMessage, Object... details) { if (errorCondition) { - ValidationException he = new ValidationException(String.format(validationErrorMessage.errorMessage(), details)); + var he = new ValidationException(String.format(validationErrorMessage.errorMessage(), details)); he.setError(validationErrorMessage.errorCode()); he.setSeverity(validationErrorMessage.severity()); exceptions.add(he); @@ -38,7 +38,7 @@ public static void profileViolatedWhen(boolean errorCondition, List exceptions, ProfileValidationMessage validationErrorMessage, Object... details) { - ValidationException he = new ValidationException(String.format(validationErrorMessage.errorMessage(), details)); + var he = new ValidationException(String.format(validationErrorMessage.errorMessage(), details)); he.setError(validationErrorMessage.errorCode()); he.setSeverity(validationErrorMessage.severity()); exceptions.add(he); diff --git a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/util/ProfileValidationMessage.java b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/util/ProfileValidationMessage.java index 21b86dd..4cfe29e 100644 --- a/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/util/ProfileValidationMessage.java +++ b/commons/core/src/main/java/org/openehealth/ipf/gazelle/validation/core/util/ProfileValidationMessage.java @@ -58,11 +58,11 @@ public enum ProfileValidationMessage { LESS_THAN_MINIMUM_CARDINALITY("%1s must have at least %2s repetitions (has %3s)", APPLICATION_INTERNAL_ERROR, ERROR), MORE_THAN_MAXIMUM_CARDINALITY("%1s must have no more than %2s repetitions (has %3s)", APPLICATION_INTERNAL_ERROR, ERROR),; - private String errorMessage; - private ErrorCode errorCode; - private Severity severity; + private final String errorMessage; + private final ErrorCode errorCode; + private final Severity severity; - private ProfileValidationMessage(String errorMessage, ErrorCode errorCode, Severity severity){ + ProfileValidationMessage(String errorMessage, ErrorCode errorCode, Severity severity){ this.errorMessage = errorMessage; this.errorCode = errorCode; this.severity = severity; diff --git a/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/AbstractGazelleProfileValidatorTest.java b/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/AbstractGazelleProfileValidatorTest.java index 688ca95..d6436e9 100644 --- a/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/AbstractGazelleProfileValidatorTest.java +++ b/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/AbstractGazelleProfileValidatorTest.java @@ -34,11 +34,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; +import jakarta.xml.bind.JAXBContext; +import jakarta.xml.bind.JAXBException; +import jakarta.xml.bind.Unmarshaller; import java.io.ByteArrayInputStream; import java.io.IOException; +import java.nio.charset.StandardCharsets; /** * @author Boris Stanojevic @@ -52,15 +53,15 @@ public abstract class AbstractGazelleProfileValidatorTest { protected Unmarshaller unmarshaller; @BeforeEach - public void onBefore() throws IOException, JAXBException { + public void onBefore() throws JAXBException { hapiContext = createHapiContext(false); - JAXBContext jaxbContext = JAXBContext.newInstance(HL7V2XConformanceProfile.class); + var jaxbContext = JAXBContext.newInstance(HL7V2XConformanceProfile.class); unmarshaller = jaxbContext.createUnmarshaller(); } protected void printOutExceptions(ValidationException... exceptions) { if (exceptions != null) { - for (ValidationException exc : exceptions) { + for (var exc : exceptions) { switch (exc.getSeverity()) { case ERROR: LOG.error("ERROR:", exc); @@ -77,8 +78,8 @@ protected void printOutExceptions(ValidationException... exceptions) { } protected int countExceptions(ValidationException[] exceptions, Severity severity) { - int count = 0; - for (ValidationException exc : exceptions) { + var count = 0; + for (var exc : exceptions) { if (severity.equals(exc.getSeverity())) { ++count; } @@ -89,7 +90,7 @@ protected int countExceptions(ValidationException[] exceptions, Severity severit protected String getMessageAsString(String resourcePath) { String message = null; try { - message = IOUtils.toString(this.getClass().getClassLoader().getResource(resourcePath)); + message = IOUtils.toString(this.getClass().getClassLoader().getResource(resourcePath), StandardCharsets.UTF_8); } catch (IOException ioe) { ioe.printStackTrace(); } @@ -107,10 +108,10 @@ protected HapiContext createHapiContext(boolean validating) { protected RuntimeProfile parseProfile(String profileId) throws ProfileException, IOException { - String profileString = hapiContext.getProfileStore().getProfile(profileId); - ProfileParser profileParser = new ProfileParser(false); - RuntimeProfile runtimeProfile = profileParser.parse(profileString); - MetaData metaData = new MetaData(); + var profileString = hapiContext.getProfileStore().getProfile(profileId); + var profileParser = new ProfileParser(false); + var runtimeProfile = profileParser.parse(profileString); + var metaData = new MetaData(); metaData.setVersion(runtimeProfile.getHL7Version()); runtimeProfile.getMessage().setMetaData(metaData); return runtimeProfile; @@ -119,7 +120,7 @@ protected RuntimeProfile parseProfile(String profileId) protected HL7V2XConformanceProfile unmarshalProfile(ConformanceProfile profile) throws IOException, JAXBException { - String profileString = hapiContext.getProfileStore().getProfile(profile.profileInfo().profileId()); + var profileString = hapiContext.getProfileStore().getProfile(profile.profileInfo().profileId()); return (HL7V2XConformanceProfile) unmarshaller.unmarshal(new ByteArrayInputStream(profileString.getBytes())); } diff --git a/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/CachingGazelleProfileRuleTest.java b/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/CachingGazelleProfileRuleTest.java index 3480bed..db28aba 100644 --- a/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/CachingGazelleProfileRuleTest.java +++ b/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/CachingGazelleProfileRuleTest.java @@ -26,8 +26,6 @@ import org.openehealth.ipf.gazelle.validation.profile.ConformanceProfileInfo; import org.openehealth.ipf.gazelle.validation.profile.ConformanceProfileInfoImpl; -import javax.xml.bind.JAXBException; -import java.io.IOException; import java.util.List; import java.util.concurrent.*; @@ -62,7 +60,7 @@ public void testCaching() throws Exception { expect(mockProfile.profileInfo()).andReturn(cpi); HapiContext context = new DefaultHapiContext(); - GazelleProfileRule obtainedRule = profileRule1.parseProfile(context, "4711"); + var obtainedRule = profileRule1.parseProfile(context, "4711"); assertSame(obtainedRule, profileRule1.parseProfile(context, "4711")); assertSame(obtainedRule, profileRule2.parseProfile(context, "4711")); } @@ -73,11 +71,11 @@ public void testConcurrentCaching() throws Exception { expect(mockProfile.profileInfo()).andReturn(cpi); final HapiContext context = new DefaultHapiContext(); - ExecutorService executor = Executors.newCachedThreadPool(); + var executor = Executors.newCachedThreadPool(); final List rules = new CopyOnWriteArrayList<>(); - int runs = 100; - final CountDownLatch latch = new CountDownLatch(runs); - for (int i = 0; i < runs; i++) { + var runs = 100; + final var latch = new CountDownLatch(runs); + for (var i = 0; i < runs; i++) { Thread.sleep(10); executor.submit(() -> { try { @@ -90,8 +88,8 @@ public void testConcurrentCaching() throws Exception { } assertTrue(latch.await(5, TimeUnit.SECONDS)); assertEquals(runs, rules.size()); - GazelleProfileRule expected = rules.get(0); - for (int i = 1; i < runs; i++) { + var expected = rules.get(0); + for (var i = 1; i < runs; i++) { assertSame(expected, rules.get(i)); } } @@ -104,7 +102,7 @@ public TestCachingGazelleProfileRule(ConformanceProfile profile) { } @Override - protected GazelleProfileRule loadRule(HapiContext hapiContext, String profileId) throws JAXBException, IOException { + protected GazelleProfileRule loadRule(HapiContext hapiContext, String profileId) { try { Thread.sleep(100); // may take some time return new GazelleProfileRule(createMock(HL7V2XConformanceProfile.class)); diff --git a/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/ConformanceProfileRuleTest.java b/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/ConformanceProfileRuleTest.java index 0c16b69..035f597 100644 --- a/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/ConformanceProfileRuleTest.java +++ b/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/ConformanceProfileRuleTest.java @@ -16,9 +16,7 @@ package org.openehealth.ipf.gazelle.validation.core; import ca.uhn.hl7v2.Severity; -import ca.uhn.hl7v2.validation.ValidationException; import org.junit.jupiter.api.Test; -import org.openehealth.ipf.gazelle.validation.core.stub.HL7V2XConformanceProfile; import org.openehealth.ipf.gazelle.validation.profile.pixpdq.ItiPixPdqProfile; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -31,10 +29,10 @@ public class ConformanceProfileRuleTest extends AbstractGazelleProfileValidatorT @Test public void testIti8Merge() throws Exception { - HL7V2XConformanceProfile runtimeProfile = unmarshalProfile(ItiPixPdqProfile.ITI_8_ADT_A40); - GazelleProfileRule profileRule = new GazelleProfileRule(runtimeProfile); + var runtimeProfile = unmarshalProfile(ItiPixPdqProfile.ITI_8_ADT_A40); + var profileRule = new GazelleProfileRule(runtimeProfile); - ValidationException[] exceptions = profileRule.apply(getParsedMessage("hl7/iti-8.hl7")); + var exceptions = profileRule.apply(getParsedMessage("hl7/iti-8.hl7")); printOutExceptions(exceptions); assertEquals(1, countExceptions(exceptions, Severity.ERROR)); @@ -44,10 +42,10 @@ public void testIti8Merge() throws Exception { @Test public void testIti8Feed() throws Exception { - HL7V2XConformanceProfile runtimeProfile = unmarshalProfile(ItiPixPdqProfile.ITI_8_ADT_A01); - GazelleProfileRule profileRule = new GazelleProfileRule(runtimeProfile); + var runtimeProfile = unmarshalProfile(ItiPixPdqProfile.ITI_8_ADT_A01); + var profileRule = new GazelleProfileRule(runtimeProfile); - ValidationException[] exceptions = profileRule.apply(getParsedMessage("hl7/iti-8-feed.hl7")); + var exceptions = profileRule.apply(getParsedMessage("hl7/iti-8-feed.hl7")); printOutExceptions(exceptions); assertEquals(0, countExceptions(exceptions, Severity.ERROR)); @@ -57,10 +55,10 @@ public void testIti8Feed() throws Exception { @Test public void testIti9Response() throws Exception { - HL7V2XConformanceProfile runtimeProfile = unmarshalProfile(ItiPixPdqProfile.ITI_9_RSP_K23); - GazelleProfileRule profileRule = new GazelleProfileRule(runtimeProfile); + var runtimeProfile = unmarshalProfile(ItiPixPdqProfile.ITI_9_RSP_K23); + var profileRule = new GazelleProfileRule(runtimeProfile); - ValidationException[] exceptions = profileRule.apply(getParsedMessage("hl7/iti-9-response.hl7")); + var exceptions = profileRule.apply(getParsedMessage("hl7/iti-9-response.hl7")); printOutExceptions(exceptions); assertEquals(0, countExceptions(exceptions, Severity.ERROR)); @@ -70,10 +68,10 @@ public void testIti9Response() throws Exception { @Test public void testIti21() throws Exception { - HL7V2XConformanceProfile runtimeProfile = unmarshalProfile(ItiPixPdqProfile.ITI_21_QBP_Q22); - GazelleProfileRule profileRule = new GazelleProfileRule(runtimeProfile); + var runtimeProfile = unmarshalProfile(ItiPixPdqProfile.ITI_21_QBP_Q22); + var profileRule = new GazelleProfileRule(runtimeProfile); - ValidationException[] exceptions = profileRule.apply(getParsedMessage("hl7/iti-21.hl7")); + var exceptions = profileRule.apply(getParsedMessage("hl7/iti-21.hl7")); printOutExceptions(exceptions); assertEquals(0, countExceptions(exceptions, Severity.ERROR)); @@ -83,10 +81,10 @@ public void testIti21() throws Exception { @Test public void testIti10() throws Exception { - HL7V2XConformanceProfile runtimeProfile = unmarshalProfile(ItiPixPdqProfile.ITI_10_ADT_A31); - GazelleProfileRule profileRule = new GazelleProfileRule(runtimeProfile); + var runtimeProfile = unmarshalProfile(ItiPixPdqProfile.ITI_10_ADT_A31); + var profileRule = new GazelleProfileRule(runtimeProfile); - ValidationException[] exceptions = profileRule.apply(getParsedMessage("hl7/iti-10.hl7")); + var exceptions = profileRule.apply(getParsedMessage("hl7/iti-10.hl7")); printOutExceptions(exceptions); assertEquals(1, countExceptions(exceptions, Severity.ERROR)); diff --git a/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/ConformanceProfileStoreTest.java b/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/ConformanceProfileStoreTest.java index 6f30226..ad869a9 100644 --- a/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/ConformanceProfileStoreTest.java +++ b/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/ConformanceProfileStoreTest.java @@ -38,13 +38,13 @@ public class ConformanceProfileStoreTest extends AbstractGazelleProfileValidator private ProfileStore profileStore; @BeforeEach - public void setup() throws Exception { + public void setup() { profileStore = hapiContext.getProfileStore(); } @Test public void testITI30ProfileStore() throws IOException { - String profileString = profileStore.getProfile(ItiPamProfile.ITI_30_ADT_A47.profileInfo().profileId()); + var profileString = profileStore.getProfile(ItiPamProfile.ITI_30_ADT_A47.profileInfo().profileId()); assertNotNull(profileString); assertTrue(profileString.contains("HL7v2xStaticDef")); assertTrue(profileString.contains("EventType=\"A47\"")); @@ -53,7 +53,7 @@ public void testITI30ProfileStore() throws IOException { @Test public void testITI9ProfileStore() throws IOException { - String profileString = profileStore.getProfile(ItiPixPdqProfile.ITI_9_RSP_K23.profileInfo().profileId()); + var profileString = profileStore.getProfile(ItiPixPdqProfile.ITI_9_RSP_K23.profileInfo().profileId()); assertNotNull(profileString); assertTrue(profileString.contains("HL7v2xStaticDef")); assertTrue(profileString.contains("EventType=\"K23\"")); diff --git a/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/ConformanceProfileTest.java b/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/ConformanceProfileTest.java index 4c77596..82eb7ca 100644 --- a/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/ConformanceProfileTest.java +++ b/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/ConformanceProfileTest.java @@ -17,7 +17,6 @@ import org.junit.jupiter.api.Test; -import org.openehealth.ipf.gazelle.validation.profile.ConformanceProfileInfo; import org.openehealth.ipf.gazelle.validation.profile.card.CardProfile; import org.openehealth.ipf.gazelle.validation.profile.rad.RadProfile; @@ -28,7 +27,7 @@ public class ConformanceProfileTest { @Test public void testProfile(){ - ConformanceProfileInfo conformanceProfileInfo = CardProfile.CARD_7_ACK_ALL.profileInfo(); + var conformanceProfileInfo = CardProfile.CARD_7_ACK_ALL.profileInfo(); assert conformanceProfileInfo.triggerEvent().equals("ACK^ALL^ACK"); assert conformanceProfileInfo.type().equals("ACK"); assert conformanceProfileInfo.structure().equals("ACK"); @@ -46,7 +45,7 @@ public void testProfile(){ assert conformanceProfileInfo.profileId().equals("1.3.6.1.4.12559.11.1.1.4"); assert conformanceProfileInfo.hl7version().equals("2.3.1"); - ConformanceProfileInfo conformanceProfileInfo1 = RadProfile.RAD_48_SIU_S12.profileInfo(); + var conformanceProfileInfo1 = RadProfile.RAD_48_SIU_S12.profileInfo(); assert conformanceProfileInfo.equals(conformanceProfileInfo1); } } diff --git a/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/HL7v2IHETransactionTest.java b/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/HL7v2IHETransactionTest.java index 67869a0..a31aa5e 100644 --- a/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/HL7v2IHETransactionTest.java +++ b/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/HL7v2IHETransactionTest.java @@ -17,16 +17,12 @@ import ca.uhn.hl7v2.HL7Exception; -import ca.uhn.hl7v2.model.Message; import org.junit.jupiter.api.Test; import org.openehealth.ipf.gazelle.validation.core.util.MessageUtils; -import org.openehealth.ipf.gazelle.validation.profile.ConformanceProfile; import org.openehealth.ipf.gazelle.validation.profile.HL7v2Transactions; import org.openehealth.ipf.gazelle.validation.profile.pixpdq.ItiPixPdqProfile; import org.openehealth.ipf.gazelle.validation.profile.pixpdq.PixPdqTransactions; -import java.util.List; - /** * @author Boris Stanojevic */ @@ -35,7 +31,7 @@ public class HL7v2IHETransactionTest extends AbstractGazelleProfileValidatorTest @Test public void testIHETransaction(){ HL7v2Transactions iheTransaction = PixPdqTransactions.ITI8; - List profiles = iheTransaction.conformanceProfiles(); + var profiles = iheTransaction.conformanceProfiles(); assert profiles.size() == 11; assert profiles.contains(ItiPixPdqProfile.ITI_8_ACK); @@ -53,8 +49,8 @@ public void testIHETransaction(){ @Test public void testGuessTransactionProfile() throws HL7Exception { - Message message = getParsedMessage("hl7/iti-8.hl7"); - ConformanceProfile profile = MessageUtils.guessGazelleProfile(PixPdqTransactions.ITI8, message); + var message = getParsedMessage("hl7/iti-8.hl7"); + var profile = MessageUtils.guessGazelleProfile(PixPdqTransactions.ITI8, message); assert profile != null; assert profile.equals(ItiPixPdqProfile.ITI_8_ADT_A40); diff --git a/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/NullFieldValidatorTest.java b/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/NullFieldValidatorTest.java index 83c0fd8..92f47bd 100644 --- a/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/NullFieldValidatorTest.java +++ b/commons/core/src/test/java/org/openehealth/ipf/gazelle/validation/core/NullFieldValidatorTest.java @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import org.openehealth.ipf.gazelle.validation.core.stub.HL7V2XConformanceProfile; -import java.io.InputStream; - import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -33,22 +31,22 @@ public class NullFieldValidatorTest extends AbstractGazelleProfileValidatorTest { private Message getMessage(String substanceId) throws Exception { - final String messageString = + final var messageString = "MSH|^~\\&|sa|sf|ra|rf|20150321213310+0200||OUL^R22^OUL_R22|123|P|2.5.1|||ER|AL||UNICODE UTF-8|||LAB-29^IHE\r" + "INV|" + substanceId + "|OK\r"; return new PipeParser().parse(messageString); } private GazelleProfileRule getRule(String fileName) throws Exception { - InputStream stream = getClass().getClassLoader().getResourceAsStream("profiles/" + fileName + ".xml"); - HL7V2XConformanceProfile conformanceProfile = (HL7V2XConformanceProfile) unmarshaller.unmarshal(stream); + var stream = getClass().getClassLoader().getResourceAsStream("profiles/" + fileName + ".xml"); + var conformanceProfile = (HL7V2XConformanceProfile) unmarshaller.unmarshal(stream); return new GazelleProfileRule(conformanceProfile); } private ValidationException[] validate(String substanceId, String ruleFileName, boolean shallFail) throws Exception { - Message message = getMessage(substanceId); - GazelleProfileRule rule = getRule(ruleFileName); - ValidationException[] exceptions = rule.apply(message); + var message = getMessage(substanceId); + var rule = getRule(ruleFileName); + var exceptions = rule.apply(message); assertEquals(shallFail ? 1 : 0, countExceptions(exceptions, Severity.ERROR)); return exceptions; } @@ -69,7 +67,7 @@ public void testProfileWithNulls() throws Exception { validate("id", "withNulls", true); // CE.3 is not set validate("\"\"", "withNulls", false); // CE.1 is NULL, CE.3 is not set - ValidationException[] exceptions = validate("\"\"^^HL70451", "withNulls", true); // CE.1 is NULL, CE.3 is set + var exceptions = validate("\"\"^^HL70451", "withNulls", true); // CE.1 is NULL, CE.3 is set assertTrue(exceptions[0].getMessage().startsWith("Element 'name of coding system' cannot be present when the field is set to NULL at INV-1")); validate("id^^HL70451", "withNulls", false); // CE.1 and CE.3 are set diff --git a/pom.xml b/pom.xml index e22435b..3577289 100644 --- a/pom.xml +++ b/pom.xml @@ -8,11 +8,10 @@ pom - + 17 + 17 + UTF-8 - - 11 - 11 3.12.1 1.8.0 @@ -31,10 +30,10 @@ 2.15.1 5.2.0 2.2 - 2.4.1 - 2.3.9 - 1.7.36 - 5.10.2 + 2.5.1 + 4.0.4 + 2.0.11 + 5.10.1 https://github.com/oehf/ipf-gazelle @@ -214,7 +213,7 @@ maven-compiler-plugin ${compiler-plugin-version} - 11 + 17 true diff --git a/profiles/card/src/main/java/org/openehealth/ipf/gazelle/validation/profile/card/CardProfile.java b/profiles/card/src/main/java/org/openehealth/ipf/gazelle/validation/profile/card/CardProfile.java index 6527fc2..f347e4d 100644 --- a/profiles/card/src/main/java/org/openehealth/ipf/gazelle/validation/profile/card/CardProfile.java +++ b/profiles/card/src/main/java/org/openehealth/ipf/gazelle/validation/profile/card/CardProfile.java @@ -24,20 +24,20 @@ */ public enum CardProfile implements ConformanceProfile { - CARD_7_MDM_T02_RC ("1.3.6.1.4.12559.11.1.1.138", "CARD-7", "MDM^T02^MDM_T02", "2.5"), - CARD_7_MDM_T10_RC ("1.3.6.1.4.12559.11.1.1.139", "CARD-7", "MDM^T10^MDM_T02", "2.5"), - CARD_7_MDM_T02_RM ("1.3.6.1.4.12559.11.1.1.140", "CARD-7", "MDM^T02^MDM_T02", "2.5"), - CARD_7_MDM_T10_RM ("1.3.6.1.4.12559.11.1.1.141", "CARD-7", "MDM^T10^MDM_T02", "2.5"), - CARD_8_MDM_T01 ("1.3.6.1.4.12559.11.1.1.142", "CARD-8", "MDM^T01^MDM_T01", "2.5"), - CARD_8_MDM_T09 ("1.3.6.1.4.12559.11.1.1.143", "CARD-8", "MDM^T09^MDM_T01", "2.5"), - CARD_8_ACK_T01 ("1.3.6.1.4.12559.11.1.1.144", "CARD-8", "ACK^T01^ACK", "2.5"), - CARD_8_ACK_T09 ("1.3.6.1.4.12559.11.1.1.145", "CARD-8", "ACK^T09^ACK", "2.5"), - CARD_7_ACK_ALL ("1.3.6.1.4.12559.11.1.1.146", "CARD-7", "ACK^ALL^ACK", "2.5"); + CARD_7_MDM_T02_RC ("1.3.6.1.4.12559.11.1.1.138", "CARD-7", "MDM^T02^MDM_T02"), + CARD_7_MDM_T10_RC ("1.3.6.1.4.12559.11.1.1.139", "CARD-7", "MDM^T10^MDM_T02"), + CARD_7_MDM_T02_RM ("1.3.6.1.4.12559.11.1.1.140", "CARD-7", "MDM^T02^MDM_T02"), + CARD_7_MDM_T10_RM ("1.3.6.1.4.12559.11.1.1.141", "CARD-7", "MDM^T10^MDM_T02"), + CARD_8_MDM_T01 ("1.3.6.1.4.12559.11.1.1.142", "CARD-8", "MDM^T01^MDM_T01"), + CARD_8_MDM_T09 ("1.3.6.1.4.12559.11.1.1.143", "CARD-8", "MDM^T09^MDM_T01"), + CARD_8_ACK_T01 ("1.3.6.1.4.12559.11.1.1.144", "CARD-8", "ACK^T01^ACK"), + CARD_8_ACK_T09 ("1.3.6.1.4.12559.11.1.1.145", "CARD-8", "ACK^T09^ACK"), + CARD_7_ACK_ALL ("1.3.6.1.4.12559.11.1.1.146", "CARD-7", "ACK^ALL^ACK"); private final ConformanceProfileInfo info; - CardProfile(String profileId, String transaction, String triggerEvent, String hl7version){ - info = new ConformanceProfileInfoImpl(profileId, transaction, triggerEvent, hl7version); + CardProfile(String profileId, String transaction, String triggerEvent){ + info = new ConformanceProfileInfoImpl(profileId, transaction, triggerEvent, "2.5"); } @Override diff --git a/profiles/core/src/main/java/org/openehealth/ipf/gazelle/validation/profile/ConformanceProfileInfoImpl.java b/profiles/core/src/main/java/org/openehealth/ipf/gazelle/validation/profile/ConformanceProfileInfoImpl.java index c510cee..f93de1d 100644 --- a/profiles/core/src/main/java/org/openehealth/ipf/gazelle/validation/profile/ConformanceProfileInfoImpl.java +++ b/profiles/core/src/main/java/org/openehealth/ipf/gazelle/validation/profile/ConformanceProfileInfoImpl.java @@ -19,31 +19,8 @@ /** * Default implementation of a ConformanceProfileInfo */ -public class ConformanceProfileInfoImpl implements ConformanceProfileInfo { - - private final String profileId; - private final String transaction; - private final String triggerEvent; - private final String hl7version; - - public ConformanceProfileInfoImpl(String profileId, String transaction, String triggerEvent, String hl7version) { - this.profileId = profileId; - this.triggerEvent = triggerEvent; - this.transaction = transaction; - this.hl7version = hl7version; - } - - public String profileId() { - return profileId; - } - - public String transaction() { - return transaction; - } - - public String triggerEvent() { - return triggerEvent; - } +public record ConformanceProfileInfoImpl(String profileId, String transaction, String triggerEvent, + String hl7version) implements ConformanceProfileInfo { public String type() { return triggerEvent.split("\\^")[0]; @@ -56,8 +33,4 @@ public String event() { public String structure() { return triggerEvent.split("\\^").length > 2 ? triggerEvent.split("\\^")[2] : ""; } - - public String hl7version() { - return hl7version; - } } diff --git a/profiles/core/src/main/java/org/openehealth/ipf/gazelle/validation/profile/HL7v2Transactions.java b/profiles/core/src/main/java/org/openehealth/ipf/gazelle/validation/profile/HL7v2Transactions.java index 6bdbd6c..409e0e9 100644 --- a/profiles/core/src/main/java/org/openehealth/ipf/gazelle/validation/profile/HL7v2Transactions.java +++ b/profiles/core/src/main/java/org/openehealth/ipf/gazelle/validation/profile/HL7v2Transactions.java @@ -22,11 +22,11 @@ /** * Holder for conformance profiles that all belong to a certain group. An example for such a group is * an IHE transaction, but there is no restriction to IHE at this point. - * + *

* Implementations of this interface return a dedicated set of conformance profiles that ultimately * carry an ID reference to the profile definition and information about the (set of) messages the * profile applies to. T - * + *

* There is a number of enum implementations for IHE transactions in dedicated modules */ public interface HL7v2Transactions { diff --git a/profiles/iti-pam/src/main/java/org/openehealth/ipf/gazelle/validation/profile/pam/ItiPamProfile.java b/profiles/iti-pam/src/main/java/org/openehealth/ipf/gazelle/validation/profile/pam/ItiPamProfile.java index c2856b6..4f066a9 100644 --- a/profiles/iti-pam/src/main/java/org/openehealth/ipf/gazelle/validation/profile/pam/ItiPamProfile.java +++ b/profiles/iti-pam/src/main/java/org/openehealth/ipf/gazelle/validation/profile/pam/ItiPamProfile.java @@ -25,50 +25,50 @@ public enum ItiPamProfile implements ConformanceProfile { - ITI_30_ACK ("1.3.6.1.4.12559.11.1.1.33", "ITI-30", "ACK", "2.5"), - ITI_30_ADT_A28 ("1.3.6.1.4.12559.11.1.1.36", "ITI-30", "ADT^A28^ADT_A05", "2.5"), - ITI_30_ADT_A37 ("1.3.6.1.4.12559.11.1.1.37", "ITI-30", "ADT^A37^ADT_A37", "2.5"), - ITI_30_ADT_A47 ("1.3.6.1.4.12559.11.1.1.38", "ITI-30", "ADT^A47^ADT_A30", "2.5"), - ITI_30_ADT_A31 ("1.3.6.1.4.12559.11.1.1.39", "ITI-30", "ADT^A31^ADT_A05", "2.5"), - ITI_30_ADT_A40 ("1.3.6.1.4.12559.11.1.1.40", "ITI-30", "ADT^A40^ADT_A39", "2.5"), - ITI_30_ADT_A24 ("1.3.6.1.4.12559.11.1.1.41", "ITI-30", "ADT^A24^ADT_A24", "2.5"), - ITI_31_ACK ("1.3.6.1.4.12559.11.1.1.44", "ITI-31", "ACK", "2.5"), - ITI_31_ADT_A16 ("1.3.6.1.4.12559.11.1.1.45", "ITI-31", "ADT^A16^ADT_A16", "2.5"), - ITI_31_ADT_A07 ("1.3.6.1.4.12559.11.1.1.46", "ITI-31", "ADT^A07^ADT_A06", "2.5"), - ITI_31_ADT_A25 ("1.3.6.1.4.12559.11.1.1.47", "ITI-31", "ADT^A25^ADT_A21", "2.5"), - ITI_31_ADT_A52 ("1.3.6.1.4.12559.11.1.1.48", "ITI-31", "ADT^A52^ADT_A52", "2.5"), - ITI_31_ADT_A08 ("1.3.6.1.4.12559.11.1.1.49", "ITI-31", "ADT^A08^ADT_A01", "2.5"), - ITI_31_ADT_A26 ("1.3.6.1.4.12559.11.1.1.50", "ITI-31", "ADT^A26^ADT_A21", "2.5"), - ITI_31_ADT_A44 ("1.3.6.1.4.12559.11.1.1.51", "ITI-31", "ADT^A44^ADT_A43", "2.5"), - ITI_31_ADT_A53 ("1.3.6.1.4.12559.11.1.1.52", "ITI-31", "ADT^A53^ADT_A52", "2.5"), - ITI_31_ADT_A09 ("1.3.6.1.4.12559.11.1.1.53", "ITI-31", "ADT^A09^ADT_A09", "2.5"), - ITI_31_ADT_A27 ("1.3.6.1.4.12559.11.1.1.54", "ITI-31", "ADT^A27^ADT_A21", "2.5"), - ITI_31_ADT_A54 ("1.3.6.1.4.12559.11.1.1.55", "ITI-31", "ADT^A54^ADT_A54", "2.5"), - ITI_31_ADT_A55 ("1.3.6.1.4.12559.11.1.1.56", "ITI-31", "ADT^A55^ADT_A52", "2.5"), - ITI_31_ADT_A38 ("1.3.6.1.4.12559.11.1.1.57", "ITI-31", "ADT^A38^ADT_A38", "2.5"), - ITI_31_ADT_Z99 ("1.3.6.1.4.12559.11.1.1.58", "ITI-31", "ADT^Z99^ADT_A01", "2.5"), - ITI_31_ADT_A10 ("1.3.6.1.4.12559.11.1.1.59", "ITI-31", "ADT^A10^ADT_A09", "2.5"), - ITI_31_ADT_A01 ("1.3.6.1.4.12559.11.1.1.60", "ITI-31", "ADT^A01^ADT_A01", "2.5"), - ITI_31_ADT_A11 ("1.3.6.1.4.12559.11.1.1.61", "ITI-31", "ADT^A11^ADT_A09", "2.5"), - ITI_31_ADT_A02 ("1.3.6.1.4.12559.11.1.1.62", "ITI-31", "ADT^A02^ADT_A02", "2.5"), - ITI_31_ADT_A12 ("1.3.6.1.4.12559.11.1.1.63", "ITI-31", "ADT^A12^ADT_A12", "2.5"), - ITI_31_ADT_A03 ("1.3.6.1.4.12559.11.1.1.64", "ITI-31", "ADT^A03^ADT_A03", "2.5"), - ITI_31_ADT_A21 ("1.3.6.1.4.12559.11.1.1.65", "ITI-31", "ADT^A21^ADT_A21", "2.5"), - ITI_31_ADT_A13 ("1.3.6.1.4.12559.11.1.1.66", "ITI-31", "ADT^A13^ADT_A01", "2.5"), - ITI_31_ADT_A04 ("1.3.6.1.4.12559.11.1.1.67", "ITI-31", "ADT^A04^ADT_A01", "2.5"), - ITI_31_ADT_A22 ("1.3.6.1.4.12559.11.1.1.68", "ITI-31", "ADT^A22^ADT_A21", "2.5"), - ITI_31_ADT_A40 ("1.3.6.1.4.12559.11.1.1.69", "ITI-31", "ADT^A40^ADT_A39", "2.5"), - ITI_31_ADT_A14 ("1.3.6.1.4.12559.11.1.1.70", "ITI-31", "ADT^A14^ADT_A05", "2.5"), - ITI_31_ADT_A05 ("1.3.6.1.4.12559.11.1.1.71", "ITI-31", "ADT^A05^ADT_A05", "2.5"), - ITI_31_ADT_A32 ("1.3.6.1.4.12559.11.1.1.72", "ITI-31", "ADT^A32^ADT_A21", "2.5"), - ITI_31_ADT_A15 ("1.3.6.1.4.12559.11.1.1.73", "ITI-31", "ADT^A15^ADT_A15", "2.5"), - ITI_31_ADT_A06 ("1.3.6.1.4.12559.11.1.1.74", "ITI-31", "ADT^A06^ADT_A06", "2.5"), - ITI_31_ADT_A33 ("1.3.6.1.4.12559.11.1.1.75", "ITI-31", "ADT^A33^ADT_A21", "2.5"); + ITI_30_ACK ("1.3.6.1.4.12559.11.1.1.33", "ITI-30", "ACK"), + ITI_30_ADT_A28 ("1.3.6.1.4.12559.11.1.1.36", "ITI-30", "ADT^A28^ADT_A05"), + ITI_30_ADT_A37 ("1.3.6.1.4.12559.11.1.1.37", "ITI-30", "ADT^A37^ADT_A37"), + ITI_30_ADT_A47 ("1.3.6.1.4.12559.11.1.1.38", "ITI-30", "ADT^A47^ADT_A30"), + ITI_30_ADT_A31 ("1.3.6.1.4.12559.11.1.1.39", "ITI-30", "ADT^A31^ADT_A05"), + ITI_30_ADT_A40 ("1.3.6.1.4.12559.11.1.1.40", "ITI-30", "ADT^A40^ADT_A39"), + ITI_30_ADT_A24 ("1.3.6.1.4.12559.11.1.1.41", "ITI-30", "ADT^A24^ADT_A24"), + ITI_31_ACK ("1.3.6.1.4.12559.11.1.1.44", "ITI-31", "ACK"), + ITI_31_ADT_A16 ("1.3.6.1.4.12559.11.1.1.45", "ITI-31", "ADT^A16^ADT_A16"), + ITI_31_ADT_A07 ("1.3.6.1.4.12559.11.1.1.46", "ITI-31", "ADT^A07^ADT_A06"), + ITI_31_ADT_A25 ("1.3.6.1.4.12559.11.1.1.47", "ITI-31", "ADT^A25^ADT_A21"), + ITI_31_ADT_A52 ("1.3.6.1.4.12559.11.1.1.48", "ITI-31", "ADT^A52^ADT_A52"), + ITI_31_ADT_A08 ("1.3.6.1.4.12559.11.1.1.49", "ITI-31", "ADT^A08^ADT_A01"), + ITI_31_ADT_A26 ("1.3.6.1.4.12559.11.1.1.50", "ITI-31", "ADT^A26^ADT_A21"), + ITI_31_ADT_A44 ("1.3.6.1.4.12559.11.1.1.51", "ITI-31", "ADT^A44^ADT_A43"), + ITI_31_ADT_A53 ("1.3.6.1.4.12559.11.1.1.52", "ITI-31", "ADT^A53^ADT_A52"), + ITI_31_ADT_A09 ("1.3.6.1.4.12559.11.1.1.53", "ITI-31", "ADT^A09^ADT_A09"), + ITI_31_ADT_A27 ("1.3.6.1.4.12559.11.1.1.54", "ITI-31", "ADT^A27^ADT_A21"), + ITI_31_ADT_A54 ("1.3.6.1.4.12559.11.1.1.55", "ITI-31", "ADT^A54^ADT_A54"), + ITI_31_ADT_A55 ("1.3.6.1.4.12559.11.1.1.56", "ITI-31", "ADT^A55^ADT_A52"), + ITI_31_ADT_A38 ("1.3.6.1.4.12559.11.1.1.57", "ITI-31", "ADT^A38^ADT_A38"), + ITI_31_ADT_Z99 ("1.3.6.1.4.12559.11.1.1.58", "ITI-31", "ADT^Z99^ADT_A01"), + ITI_31_ADT_A10 ("1.3.6.1.4.12559.11.1.1.59", "ITI-31", "ADT^A10^ADT_A09"), + ITI_31_ADT_A01 ("1.3.6.1.4.12559.11.1.1.60", "ITI-31", "ADT^A01^ADT_A01"), + ITI_31_ADT_A11 ("1.3.6.1.4.12559.11.1.1.61", "ITI-31", "ADT^A11^ADT_A09"), + ITI_31_ADT_A02 ("1.3.6.1.4.12559.11.1.1.62", "ITI-31", "ADT^A02^ADT_A02"), + ITI_31_ADT_A12 ("1.3.6.1.4.12559.11.1.1.63", "ITI-31", "ADT^A12^ADT_A12"), + ITI_31_ADT_A03 ("1.3.6.1.4.12559.11.1.1.64", "ITI-31", "ADT^A03^ADT_A03"), + ITI_31_ADT_A21 ("1.3.6.1.4.12559.11.1.1.65", "ITI-31", "ADT^A21^ADT_A21"), + ITI_31_ADT_A13 ("1.3.6.1.4.12559.11.1.1.66", "ITI-31", "ADT^A13^ADT_A01"), + ITI_31_ADT_A04 ("1.3.6.1.4.12559.11.1.1.67", "ITI-31", "ADT^A04^ADT_A01"), + ITI_31_ADT_A22 ("1.3.6.1.4.12559.11.1.1.68", "ITI-31", "ADT^A22^ADT_A21"), + ITI_31_ADT_A40 ("1.3.6.1.4.12559.11.1.1.69", "ITI-31", "ADT^A40^ADT_A39"), + ITI_31_ADT_A14 ("1.3.6.1.4.12559.11.1.1.70", "ITI-31", "ADT^A14^ADT_A05"), + ITI_31_ADT_A05 ("1.3.6.1.4.12559.11.1.1.71", "ITI-31", "ADT^A05^ADT_A05"), + ITI_31_ADT_A32 ("1.3.6.1.4.12559.11.1.1.72", "ITI-31", "ADT^A32^ADT_A21"), + ITI_31_ADT_A15 ("1.3.6.1.4.12559.11.1.1.73", "ITI-31", "ADT^A15^ADT_A15"), + ITI_31_ADT_A06 ("1.3.6.1.4.12559.11.1.1.74", "ITI-31", "ADT^A06^ADT_A06"), + ITI_31_ADT_A33 ("1.3.6.1.4.12559.11.1.1.75", "ITI-31", "ADT^A33^ADT_A21"); private final ConformanceProfileInfo info; - ItiPamProfile(String profileId, String transaction, String triggerEvent, String hl7version){ - info = new ConformanceProfileInfoImpl(profileId, transaction, triggerEvent, hl7version); + ItiPamProfile(String profileId, String transaction, String triggerEvent){ + info = new ConformanceProfileInfoImpl(profileId, transaction, triggerEvent, "2.5"); } @Override diff --git a/profiles/pat/src/main/java/org/openehealth/ipf/gazelle/validation/profile/pat/PatProfile.java b/profiles/pat/src/main/java/org/openehealth/ipf/gazelle/validation/profile/pat/PatProfile.java index d70775c..0c57309 100644 --- a/profiles/pat/src/main/java/org/openehealth/ipf/gazelle/validation/profile/pat/PatProfile.java +++ b/profiles/pat/src/main/java/org/openehealth/ipf/gazelle/validation/profile/pat/PatProfile.java @@ -24,12 +24,12 @@ */ public enum PatProfile implements ConformanceProfile { - PAT_10_ORU_R01 ("1.3.6.1.4.12559.11.1.1.152", "PAT-10", "ORU^R01^ORU_R01", "2.5.1"); + PAT_10_ORU_R01 ("1.3.6.1.4.12559.11.1.1.152", "PAT-10", "ORU^R01^ORU_R01"); private final ConformanceProfileInfo info; - PatProfile(String profileId, String transaction, String triggerEvent, String hl7version){ - info = new ConformanceProfileInfoImpl(profileId, transaction, triggerEvent, hl7version); + PatProfile(String profileId, String transaction, String triggerEvent){ + info = new ConformanceProfileInfoImpl(profileId, transaction, triggerEvent, "2.5.1"); } @Override diff --git a/profiles/pharmh/src/main/java/org/openehealth/ipf/gazelle/validation/profile/pharmh/PharmhProfile.java b/profiles/pharmh/src/main/java/org/openehealth/ipf/gazelle/validation/profile/pharmh/PharmhProfile.java index 0671c57..2434591 100644 --- a/profiles/pharmh/src/main/java/org/openehealth/ipf/gazelle/validation/profile/pharmh/PharmhProfile.java +++ b/profiles/pharmh/src/main/java/org/openehealth/ipf/gazelle/validation/profile/pharmh/PharmhProfile.java @@ -24,29 +24,29 @@ */ public enum PharmhProfile implements ConformanceProfile { - PHARM_H1_ORP_O10 ("1.3.6.1.4.12559.11.1.1.154", "PHARM-H1", "ORP^O10^ORP_O10", "2.6"), - PHARM_H2_RDE_O11 ("1.3.6.1.4.12559.11.1.1.155", "PHARM-H2", "RDE^O11^RDE_O11", "2.6"), - PHARM_H2_RRE_O12_PRES_PLACER ("1.3.6.1.4.12559.11.1.1.156", "PHARM-H2", "RRE^O12^RRE_O12", "2.6"), - PHARM_H3_RRG_O16_PRES_PLACER ("1.3.6.1.4.12559.11.1.1.157", "PHARM-H3", "RRG^O16^RRG_O16", "2.6"), - PHARM_H3_RGV_O15 ("1.3.6.1.4.12559.11.1.1.158", "PHARM-H3", "RGV^O15^RGV_O15", "2.6"), - PHARM_H4_RAS_O17 ("1.3.6.1.4.12559.11.1.1.159", "PHARM-H4", "RAS^O17^RAS_O17", "2.6"), - PHARM_H4_RRA_O18_PRES_PLACER ("1.3.6.1.4.12559.11.1.1.160", "PHARM-H4", "RRA^O18^RRA_O18", "2.6"), - PHARM_H1_OMP_O09 ("1.3.6.1.4.12559.11.1.1.161", "PHARM-H1", "OMP^O09^OMP_O09", "2.6"), - PHARM_H3_RRG_O16_MED_ADM_INFO ("1.3.6.1.4.12559.11.1.1.162", "PHARM-H3", "RRG^O16^RRG_O16", "2.6"), - PHARM_H5_ORP_O10_MED_ADM_INFO ("1.3.6.1.4.12559.11.1.1.163", "PHARM-H5", "ORP^O10^ORP_O10", "2.6"), - PHARM_H6_RRE_O12 ("1.3.6.1.4.12559.11.1.1.164", "PHARM-H6", "RRE^O12^RRE_O12", "2.6"), - PHARM_H5_OMP_O09 ("1.3.6.1.4.12559.11.1.1.165", "PHARM-H5", "OMP^O09^OMP_O09", "2.6"), - PHARM_H3_RRG_O16 ("1.3.6.1.4.12559.11.1.1.166", "PHARM-H3", "RRG^O16^RRG_O16", "2.6"), - PHARM_H6_RDE_O11 ("1.3.6.1.4.12559.11.1.1.167", "PHARM-H6", "RDE^O11^RDE_O11", "2.6"), - PHARM_H4_RRA_O18_MED_DIS ("1.3.6.1.4.12559.11.1.1.168", "PHARM-H4", "RRA^O18^RRA_O18", "2.6"), - PHARM_H5_ORP_O10_MED_DIS ("1.3.6.1.4.12559.11.1.1.169", "PHARM-H5", "ORP^O10^ORP_O10", "2.6"), - PHARM_H2_RRE_O12_MED_DIS ("1.3.6.1.4.12559.11.1.1.170", "PHARM-H2", "RRE^O12^RRE_O12", "2.6"); + PHARM_H1_ORP_O10 ("1.3.6.1.4.12559.11.1.1.154", "PHARM-H1", "ORP^O10^ORP_O10"), + PHARM_H2_RDE_O11 ("1.3.6.1.4.12559.11.1.1.155", "PHARM-H2", "RDE^O11^RDE_O11"), + PHARM_H2_RRE_O12_PRES_PLACER ("1.3.6.1.4.12559.11.1.1.156", "PHARM-H2", "RRE^O12^RRE_O12"), + PHARM_H3_RRG_O16_PRES_PLACER ("1.3.6.1.4.12559.11.1.1.157", "PHARM-H3", "RRG^O16^RRG_O16"), + PHARM_H3_RGV_O15 ("1.3.6.1.4.12559.11.1.1.158", "PHARM-H3", "RGV^O15^RGV_O15"), + PHARM_H4_RAS_O17 ("1.3.6.1.4.12559.11.1.1.159", "PHARM-H4", "RAS^O17^RAS_O17"), + PHARM_H4_RRA_O18_PRES_PLACER ("1.3.6.1.4.12559.11.1.1.160", "PHARM-H4", "RRA^O18^RRA_O18"), + PHARM_H1_OMP_O09 ("1.3.6.1.4.12559.11.1.1.161", "PHARM-H1", "OMP^O09^OMP_O09"), + PHARM_H3_RRG_O16_MED_ADM_INFO ("1.3.6.1.4.12559.11.1.1.162", "PHARM-H3", "RRG^O16^RRG_O16"), + PHARM_H5_ORP_O10_MED_ADM_INFO ("1.3.6.1.4.12559.11.1.1.163", "PHARM-H5", "ORP^O10^ORP_O10"), + PHARM_H6_RRE_O12 ("1.3.6.1.4.12559.11.1.1.164", "PHARM-H6", "RRE^O12^RRE_O12"), + PHARM_H5_OMP_O09 ("1.3.6.1.4.12559.11.1.1.165", "PHARM-H5", "OMP^O09^OMP_O09"), + PHARM_H3_RRG_O16 ("1.3.6.1.4.12559.11.1.1.166", "PHARM-H3", "RRG^O16^RRG_O16"), + PHARM_H6_RDE_O11 ("1.3.6.1.4.12559.11.1.1.167", "PHARM-H6", "RDE^O11^RDE_O11"), + PHARM_H4_RRA_O18_MED_DIS ("1.3.6.1.4.12559.11.1.1.168", "PHARM-H4", "RRA^O18^RRA_O18"), + PHARM_H5_ORP_O10_MED_DIS ("1.3.6.1.4.12559.11.1.1.169", "PHARM-H5", "ORP^O10^ORP_O10"), + PHARM_H2_RRE_O12_MED_DIS ("1.3.6.1.4.12559.11.1.1.170", "PHARM-H2", "RRE^O12^RRE_O12"); private final ConformanceProfileInfo info; - PharmhProfile(String profileId, String transaction, String triggerEvent, String hl7version){ - info = new ConformanceProfileInfoImpl(profileId, transaction, triggerEvent, hl7version); + PharmhProfile(String profileId, String transaction, String triggerEvent){ + info = new ConformanceProfileInfoImpl(profileId, transaction, triggerEvent, "2.6"); } @Override