Search in sources :

Example 1 with Instruction

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

the class DBEncodeTest method testDBEncodeDecodeInstruction.

@Test
public void testDBEncodeDecodeInstruction() throws IOException {
    Composition composition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.NESTED_EN_V1.getStream(), UTF_8), Composition.class);
    CompositionSerializer compositionSerializer = new CompositionSerializer();
    String encoded = compositionSerializer.dbEncode(composition);
    Assert.assertTrue(encoded.contains(CompositionSerializer.TAG_EXPIRY_TIME));
    String json = new LightRawJsonEncoder(encoded).encodeCompositionAsString();
    Composition result = new CanonicalJson().unmarshal(json, Composition.class);
    DvDateTime expiryTime = ((Instruction) ((Section) result.getContent().get(0)).getItems().get(0)).getExpiryTime();
    Assert.assertNotNull(expiryTime);
    Assert.assertEquals(OffsetDateTime.parse("2021-05-18T13:13:09.780+03:00"), expiryTime.getValue());
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionTestDataCanonicalJson(org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson) LightRawJsonEncoder(org.ehrbase.serialisation.dbencoding.rawjson.LightRawJsonEncoder) Instruction(com.nedap.archie.rm.composition.Instruction) Section(com.nedap.archie.rm.composition.Section) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) Test(org.junit.Test)

Example 2 with Instruction

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

the class InstructionPostprocessor method process.

/**
 * {@inheritDoc}
 */
@Override
public void process(String term, Instruction rmObject, Map<FlatPathDto, String> values, Set<String> consumedPaths, Context<Map<FlatPathDto, String>> context) {
    Map<FlatPathDto, String> wfDefinition = values.entrySet().stream().filter(e -> e.getKey().startsWith(term + PATH_DIVIDER + "_wf_definition")).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
    if (!wfDefinition.isEmpty()) {
        rmObject.setWfDefinition(new DvParsable());
        handleRmAttribute(term, rmObject.getWfDefinition(), wfDefinition, consumedPaths, context, "wf_definition");
    }
}
Also used : Context(org.ehrbase.serialisation.walker.Context) PATH_DIVIDER(org.ehrbase.webtemplate.parser.OPTParser.PATH_DIVIDER) Map(java.util.Map) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) Set(java.util.Set) Instruction(com.nedap.archie.rm.composition.Instruction) DvParsable(com.nedap.archie.rm.datavalues.encapsulated.DvParsable) Collectors(java.util.stream.Collectors) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) DvParsable(com.nedap.archie.rm.datavalues.encapsulated.DvParsable) Map(java.util.Map)

Example 3 with Instruction

use of com.nedap.archie.rm.composition.Instruction 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

Instruction (com.nedap.archie.rm.composition.Instruction)3 Section (com.nedap.archie.rm.composition.Section)2 Action (com.nedap.archie.rm.composition.Action)1 AdminEntry (com.nedap.archie.rm.composition.AdminEntry)1 Composition (com.nedap.archie.rm.composition.Composition)1 Evaluation (com.nedap.archie.rm.composition.Evaluation)1 Observation (com.nedap.archie.rm.composition.Observation)1 DvParsable (com.nedap.archie.rm.datavalues.encapsulated.DvParsable)1 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 RawJson (org.ehrbase.serialisation.dbencoding.RawJson)1 LightRawJsonEncoder (org.ehrbase.serialisation.dbencoding.rawjson.LightRawJsonEncoder)1 CanonicalJson (org.ehrbase.serialisation.jsonencoding.CanonicalJson)1 Context (org.ehrbase.serialisation.walker.Context)1 CompositionTestDataCanonicalJson (org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson)1 PATH_DIVIDER (org.ehrbase.webtemplate.parser.OPTParser.PATH_DIVIDER)1 FlatPathDto (org.ehrbase.webtemplate.path.flat.FlatPathDto)1 Test (org.junit.Test)1