use of org.openehealth.ipf.commons.ihe.xds.core.validate.XDSMetaDataException in project ipf by oehf.
the class AdhocQueryRequestValidatorTest method testDuplicateSlotForFindDocumentsQueryValidationWithSuccess.
@Test
public void testDuplicateSlotForFindDocumentsQueryValidationWithSuccess() {
var query = new FindDocumentsQuery();
query.setPatientId(new Identifiable("id3", new AssigningAuthority("1.3")));
var ebXML = transformer.toEbXML(request);
ebXML.addSlot(QueryParameter.DOC_ENTRY_EVENT_CODE.getSlotName(), "('event-code-1^^event-code-scheme-1')");
ebXML.addSlot(QueryParameter.DOC_ENTRY_EVENT_CODE.getSlotName(), "('event-code-2^^event-code-scheme-2')");
try {
validator.validate(ebXML, ITI_18);
} catch (XDSMetaDataException e) {
fail("Test should succeed, but failed with exception: " + XDSMetaDataException.class);
}
}
use of org.openehealth.ipf.commons.ihe.xds.core.validate.XDSMetaDataException in project ipf by oehf.
the class Timestamp method fromHL7.
/**
* Creates a {@link Timestamp} object from the given string.
* @param s
* String of the pattern <code>YYYY[MM[DD[HH[MM[SS[.S[S[S[S]]]]]]]]][+/-ZZZZ]</code>.
* Milliseconds will be ignored.
* @return
* a {@link Timestamp} object, or <code>null</code> if the parameter is <code>null</code> or empty.
*/
public static Timestamp fromHL7(String s) {
if (StringUtils.isEmpty(s)) {
return null;
}
var pos = Math.max(s.indexOf('-'), s.indexOf('+'));
var len = (pos >= 0) ? pos : s.length();
// determine precision
Precision precision;
if (len >= 14) {
precision = Precision.SECOND;
} else if (len >= 12) {
precision = Precision.MINUTE;
} else if (len >= 10) {
precision = Precision.HOUR;
} else if (len >= 8) {
precision = Precision.DAY;
} else if (len >= 6) {
precision = Precision.MONTH;
} else {
precision = Precision.YEAR;
}
// parse timestamp
try {
return new Timestamp(HL7DTM.toZonedDateTime(s), precision);
} catch (DataTypeException e) {
throw new XDSMetaDataException(ValidationMessage.INVALID_TIME, s);
}
}
Aggregations