Search in sources :

Example 6 with Section

use of com.nedap.archie.rm.composition.Section in project ehrbase by ehrbase.

the class EntryAccess method setCompositionFields.

/**
 * set the EntryRecord with fields from composition:<br>
 * <ul>
 * <li>category</li>
 * <li>item type</li>
 * <li>archetype node Id</li>
 * <li>entry content (json)</li>
 * </ul>
 *
 * @param record      Target {@link EntryRecord}
 * @param composition input data in {@link Composition} representation
 */
private void setCompositionFields(EntryRecord record, Composition composition) {
    record.setCategory(record.getCategory());
    if (composition.getContent() != null && !composition.getContent().isEmpty()) {
        Object node = composition.getContent().get(0);
        if (node instanceof Section) {
            record.setItemType(EntryType.valueOf("section"));
        } else if (node instanceof Evaluation || node instanceof Observation || node instanceof Instruction || node instanceof Action) {
            record.setItemType(EntryType.valueOf("care_entry"));
        } else if (node instanceof AdminEntry) {
            record.setItemType(EntryType.valueOf("admin"));
        }
    } else {
        record.setItemType(EntryType.valueOf("admin"));
    }
    record.setArchetypeId(composition.getArchetypeNodeId());
    RawJson rawJson = new RawJson();
    record.setEntry(JSONB.valueOf(rawJson.marshal(composition)));
}
Also used : Evaluation(com.nedap.archie.rm.composition.Evaluation) Action(com.nedap.archie.rm.composition.Action) RawJson(org.ehrbase.serialisation.dbencoding.RawJson) AdminEntry(com.nedap.archie.rm.composition.AdminEntry) Observation(com.nedap.archie.rm.composition.Observation) Instruction(com.nedap.archie.rm.composition.Instruction) Section(com.nedap.archie.rm.composition.Section)

Aggregations

Section (com.nedap.archie.rm.composition.Section)6 Composition (com.nedap.archie.rm.composition.Composition)5 Test (org.junit.Test)5 WorkflowIdTest (care.better.platform.web.template.WorkflowIdTest)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 Entry (com.nedap.archie.rm.composition.Entry)3 GenericId (com.nedap.archie.rm.support.identification.GenericId)3 ObjectId (com.nedap.archie.rm.support.identification.ObjectId)3 ObjectRef (com.nedap.archie.rm.support.identification.ObjectRef)3 OffsetDateTime (java.time.OffsetDateTime)3 ZoneId (java.time.ZoneId)3 ZonedDateTime (java.time.ZonedDateTime)3 DateTimeFormatter (java.time.format.DateTimeFormatter)3 Map (java.util.Map)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Helper.getFlatJson (org.ehrbase.conformance_test.extern.Helper.getFlatJson)3 RMDataFormat (org.ehrbase.serialisation.RMDataFormat)3 FlatFormat (org.ehrbase.serialisation.flatencoding.FlatFormat)3 Instruction (com.nedap.archie.rm.composition.Instruction)2