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());
}
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");
}
}
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)));
}
Aggregations