XCNValidator implements ValueValidator { @Override public void validate(String hl7xcn) throws XDSMetaDataException { Person person = Hl7v2Based.parse(hl7xcn, Person.class); metaDataAssert(person != null, PERSON_MISSING_NAME_AND_ID, hl7xcn); XCN xcn = person.getHapiObject(); metaDataAssert( isNotEmpty(xcn.getXcn1_IDNumber().getValue()) || isNotEmpty(xcn.getXcn2_FamilyName().getFn1_Surname().getValue()), PERSON_MISSING_NAME_AND_ID, hl7xcn); HD hd = xcn.getXcn9_AssigningAuthority(); if (! HD_VALIDATOR.isEmpty(hd)) { HD_VALIDATOR.validate(hd, hl7xcn); } }  @Override void validate(String hl7xcn);  }
@Test public void testValidateGoodCases() throws XDSMetaDataException { validator.validate("11375^Welby^Marcus^J^Jr. MD^Dr^^^&1.2.840.113619.6.197&ISO"); validator.validate("11375^^^^^^^^&1.2.840.113619.6.197&ISO"); validator.validate("abc^^^^^^^^&1.2.840.113619.6.197&ISO"); validator.validate("^Welby^^^^^^^"); validator.validate("^Welby"); validator.validate("abc"); validator.validate("abc^^^^^^^^"); }