Search in sources :

Example 1 with LocatableRef

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);
}
Also used : InstructionDetails(com.nedap.archie.rm.composition.InstructionDetails) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) Context(org.ehrbase.serialisation.walker.Context) List(java.util.List) SdkException(org.ehrbase.util.exception.SdkException) Map(java.util.Map) LocatableRef(com.nedap.archie.rm.support.identification.LocatableRef) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) Optional(java.util.Optional) Set(java.util.Set) SdkException(org.ehrbase.util.exception.SdkException) LocatableRef(com.nedap.archie.rm.support.identification.LocatableRef) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId)

Aggregations

InstructionDetails (com.nedap.archie.rm.composition.InstructionDetails)1 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)1 LocatableRef (com.nedap.archie.rm.support.identification.LocatableRef)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Context (org.ehrbase.serialisation.walker.Context)1 SdkException (org.ehrbase.util.exception.SdkException)1 FlatPathDto (org.ehrbase.webtemplate.path.flat.FlatPathDto)1