use of org.ehrbase.jooq.pg.udt.records.CodePhraseRecord in project ehrbase by ehrbase.
the class RecordedDvCodedTextTest method testFromDB.
@Test
public void testFromDB() {
Record record = new EventContextRecord();
DvCodedTextRecord dvCodedTextRecord = new DvCodedTextRecord();
dvCodedTextRecord.setValue("1234");
dvCodedTextRecord.setDefiningCode(new CodePhraseRecord("term1", "aaa"));
dvCodedTextRecord.setTermMapping(new String[] { ">|purpose|B|BBB|A|target" });
record.set(EventContext.EVENT_CONTEXT.SETTING, dvCodedTextRecord);
DvCodedText dvCodedText = (DvCodedText) new RecordedDvCodedText().fromDB(record, EventContext.EVENT_CONTEXT.SETTING);
assertEquals('>', dvCodedText.getMappings().get(0).getMatch());
}
use of org.ehrbase.jooq.pg.udt.records.CodePhraseRecord in project ehrbase by ehrbase.
the class RecordedDvCodedText method fromDB.
public Object fromDB(Record record, Field<DvCodedTextRecord> fromField) {
Object retObject;
DvCodedTextRecord dvCodedTextRecord = record.get(fromField);
CodePhraseRecord codePhraseDefiningCode = dvCodedTextRecord.getDefiningCode();
CodePhraseRecord codePhraseLanguage = dvCodedTextRecord.getLanguage();
CodePhraseRecord codePhraseEncoding = dvCodedTextRecord.getEncoding();
if (codePhraseDefiningCode != null)
retObject = new DvCodedText(dvCodedTextRecord.getValue(), codePhraseLanguage == null ? null : new CodePhrase(new TerminologyId(codePhraseLanguage.getTerminologyIdValue()), codePhraseLanguage.getCodeString()), codePhraseEncoding == null ? null : new CodePhrase(new TerminologyId(codePhraseEncoding.getTerminologyIdValue()), codePhraseEncoding.getCodeString()), new CodePhrase(new TerminologyId(codePhraseDefiningCode.getTerminologyIdValue()), codePhraseDefiningCode.getCodeString()));
else
// assume DvText
retObject = new DvText(dvCodedTextRecord.getValue(), codePhraseLanguage == null ? null : new CodePhrase(new TerminologyId(codePhraseLanguage.getTerminologyIdValue()), codePhraseLanguage.getCodeString()), codePhraseEncoding == null ? null : new CodePhrase(new TerminologyId(codePhraseEncoding.getTerminologyIdValue()), codePhraseEncoding.getCodeString()));
if (dvCodedTextRecord.getTermMapping() != null && dvCodedTextRecord.getTermMapping().length > 0) {
for (String dvCodedTextTermMappingRecord : dvCodedTextRecord.getTermMapping()) {
((DvText) retObject).addMapping(new PersistentTermMapping().decode(dvCodedTextTermMappingRecord));
}
}
return retObject;
}
Aggregations