use of com.nedap.archie.rm.support.identification.LocatableRef in project openEHR_SDK by ehrbase.
the class InstructionDetailsRMUnmarshaller method handle.
/**
* {@inheritDoc}
*/
@Override
public void handle(String currentTerm, InstructionDetails rmObject, Map<FlatPathDto, String> currentValues, Context<Map<FlatPathDto, String>> context, Set<String> consumedPaths) {
if (currentValues.keySet().stream().anyMatch(k -> List.of("instruction_uid", "wt_path", "instruction_index").contains(k.getLast().getAttributeName()))) {
throw new SdkException(String.format("Calculation of Path from instruction_uid, wt_path or instruction_index is not supported. Provide |path at %s ", currentTerm));
}
if (currentValues.keySet().stream().anyMatch(k -> List.of("activity_index").contains(k.getLast().getAttributeName()))) {
throw new SdkException(String.format("Calculation of activity_id from activity_index is not supported. Provide |activity_id at %s ", currentTerm));
}
setValue(currentTerm, "activity_id", currentValues, rmObject::setActivityId, String.class, consumedPaths);
rmObject.setInstructionId(new LocatableRef());
rmObject.getInstructionId().setNamespace("local");
rmObject.getInstructionId().setType("INSTRUCTION");
setValue(currentTerm, "composition_uid", currentValues, s -> Optional.ofNullable(s).ifPresent(p -> rmObject.getInstructionId().setId(new HierObjectId(p))), String.class, consumedPaths);
setValue(currentTerm, "path", currentValues, s -> rmObject.getInstructionId().setPath(s), String.class, consumedPaths);
}
Aggregations