/** * Tests a Type against the corresponding section of a profile. * * @param encoded optional encoded form of type (if you want to specify this -- if null, default * pipe-encoded form is used to check length and constant val) */ public List<HL7Exception> testType(Type type, AbstractComponent<?> profile, String encoded, String profileID) { List<HL7Exception> exList = new ArrayList<HL7Exception>(); if (encoded == null) encoded = PipeParser.encode(type, this.enc); testUsage(encoded, profile.getUsage(), profile.getName(), exList); if (!profile.getUsage().equals("X")) { checkDataType(profile.getDatatype(), type, exList); checkLength(profile.getLength(), profile.getName(), encoded, exList); checkConstantValue(profile.getConstantValue(), encoded, exList); testTypeAgainstTable(type, profile, profileID, exList); } return exList; }
comp.setName(elem.getAttribute("Name")); comp.setUsage(elem.getAttribute("Usage")); comp.setDatatype(elem.getAttribute("Datatype")); String length = elem.getAttribute("Length"); if (length != null && length.length() > 0) { try { comp.setLength(Long.parseLong(length)); } catch (NumberFormatException e) { throw new ProfileException("Length must be a long integer: " + length, e); comp.setConstantValue(elem.getAttribute("ConstantValue")); String table = elem.getAttribute("Table"); if (table != null && table.length() > 0) { try { comp.setTable(table); } catch (NumberFormatException e) { throw new ProfileException("Table must be a short integer: " + table, e); comp.setImpNote(getValueOfFirstElement("ImpNote", elem)); comp.setDescription(getValueOfFirstElement("Description", elem)); comp.setReference(getValueOfFirstElement("Reference", elem)); comp.setPredicate(getValueOfFirstElement("Predicate", elem)); DataValue val = new DataValue(); val.setExValue(child.getAttribute("ExValue")); comp.setDataValues(dataValIndex++, val);
/** * Tests table values for ID, IS, and CE types. An empty list is returned for all other types or * if the table name or number is missing. */ protected void testTypeAgainstTable(Type type, AbstractComponent<?> profile, String profileID, List<HL7Exception> exList) { if (profile.getTable() != null && (type.getName().equals("IS") || type.getName().equals("ID"))) { String codeSystem = String.format("HL7%1$4s", profile.getTable()).replace(" ", "0"); String value = ((Primitive) type).getValue(); addTableTestResult(profileID, codeSystem, value, exList); } else if (type.getName().equals("CE")) { String value = Terser.getPrimitive(type, 1, 1).getValue(); String codeSystem = Terser.getPrimitive(type, 3, 1).getValue(); addTableTestResult(profileID, codeSystem, value, exList); value = Terser.getPrimitive(type, 4, 1).getValue(); codeSystem = Terser.getPrimitive(type, 6, 1).getValue(); addTableTestResult(profileID, codeSystem, value, exList); } }
/** * Tests table values for ID, IS, and CE types. An empty list is returned for all other types or * if the table name or number is missing. */ protected void testTypeAgainstTable(Type type, AbstractComponent<?> profile, String profileID, List<HL7Exception> exList) { if (profile.getTable() != null && (type.getName().equals("IS") || type.getName().equals("ID"))) { String codeSystem = String.format("HL7%1$4s", profile.getTable()).replace(" ", "0"); String value = ((Primitive) type).getValue(); addTableTestResult(profileID, codeSystem, value, exList); } else if (type.getName().equals("CE")) { String value = Terser.getPrimitive(type, 1, 1).getValue(); String codeSystem = Terser.getPrimitive(type, 3, 1).getValue(); addTableTestResult(profileID, codeSystem, value, exList); value = Terser.getPrimitive(type, 4, 1).getValue(); codeSystem = Terser.getPrimitive(type, 6, 1).getValue(); addTableTestResult(profileID, codeSystem, value, exList); } }
comp.setName(elem.getAttribute("Name")); comp.setUsage(elem.getAttribute("Usage")); comp.setDatatype(elem.getAttribute("Datatype")); String length = elem.getAttribute("Length"); if (length != null && length.length() > 0) { try { comp.setLength(Long.parseLong(length)); } catch (NumberFormatException e) { throw new ProfileException("Length must be a long integer: " + length, e); comp.setConstantValue(elem.getAttribute("ConstantValue")); String table = elem.getAttribute("Table"); if (table != null && table.length() > 0) { try { comp.setTable(table); } catch (NumberFormatException e) { throw new ProfileException("Table must be a short integer: " + table, e); comp.setImpNote(getValueOfFirstElement("ImpNote", elem)); comp.setDescription(getValueOfFirstElement("Description", elem)); comp.setReference(getValueOfFirstElement("Reference", elem)); comp.setPredicate(getValueOfFirstElement("Predicate", elem)); DataValue val = new DataValue(); val.setExValue(child.getAttribute("ExValue")); comp.setDataValues(dataValIndex++, val);
/** * Tests a Type against the corresponding section of a profile. * * @param encoded optional encoded form of type (if you want to specify this -- if null, default * pipe-encoded form is used to check length and constant val) */ public List<HL7Exception> testType(Type type, AbstractComponent<?> profile, String encoded, String profileID) { List<HL7Exception> exList = new ArrayList<HL7Exception>(); if (encoded == null) encoded = PipeParser.encode(type, this.enc); testUsage(encoded, profile.getUsage(), profile.getName(), exList); if (!profile.getUsage().equals("X")) { checkDataType(profile.getDatatype(), type, exList); checkLength(profile.getLength(), profile.getName(), encoded, exList); checkConstantValue(profile.getConstantValue(), encoded, exList); testTypeAgainstTable(type, profile, profileID, exList); } return exList; }