Search in sources :

Example 1 with CodePhraseRecord

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());
}
Also used : DvCodedTextRecord(org.ehrbase.jooq.pg.udt.records.DvCodedTextRecord) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) Record(org.jooq.Record) CodePhraseRecord(org.ehrbase.jooq.pg.udt.records.CodePhraseRecord) DvCodedTextRecord(org.ehrbase.jooq.pg.udt.records.DvCodedTextRecord) EventContextRecord(org.ehrbase.jooq.pg.tables.records.EventContextRecord) EventContextRecord(org.ehrbase.jooq.pg.tables.records.EventContextRecord) CodePhraseRecord(org.ehrbase.jooq.pg.udt.records.CodePhraseRecord) Test(org.junit.Test)

Example 2 with CodePhraseRecord

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;
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) DvCodedTextRecord(org.ehrbase.jooq.pg.udt.records.DvCodedTextRecord) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) CodePhraseRecord(org.ehrbase.jooq.pg.udt.records.CodePhraseRecord) DvText(com.nedap.archie.rm.datavalues.DvText)

Aggregations

DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)2 CodePhraseRecord (org.ehrbase.jooq.pg.udt.records.CodePhraseRecord)2 DvCodedTextRecord (org.ehrbase.jooq.pg.udt.records.DvCodedTextRecord)2 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)1 DvText (com.nedap.archie.rm.datavalues.DvText)1 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)1 EventContextRecord (org.ehrbase.jooq.pg.tables.records.EventContextRecord)1 Record (org.jooq.Record)1 Test (org.junit.Test)1