Search in sources :

Example 11 with ObjectId

use of com.nedap.archie.rm.support.identification.ObjectId in project openEHR_SDK by ehrbase.

the class CanonicalJsonMarshallingTest method marshallContribution.

@Test
public void marshallContribution() {
    List<ObjectRef<? extends ObjectId>> versions = new ArrayList<>();
    versions.add(new ObjectRef<>(new HierObjectId("COMPOSITION"), "local", "b5c4aaed-2adc-4c56-9005-e21ff3cca62a::local.ehrbase.org::2"));
    Contribution expected = new Contribution();
    expected.setUid(new HierObjectId("bbf60d27-9200-4995-a950-279f889d1050"));
    expected.setVersions(versions);
    CanonicalJson cut = new CanonicalJson();
    String json = cut.marshal(expected);
    Contribution actual = cut.unmarshal(json, Contribution.class);
    Assert.assertEquals(actual, expected);
}
Also used : ObjectId(com.nedap.archie.rm.support.identification.ObjectId) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) ArrayList(java.util.ArrayList) ObjectRef(com.nedap.archie.rm.support.identification.ObjectRef) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) Contribution(com.nedap.archie.rm.changecontrol.Contribution) Test(org.junit.Test)

Example 12 with ObjectId

use of com.nedap.archie.rm.support.identification.ObjectId in project openEHR_SDK by ehrbase.

the class DtoFromCompositionWalker method writeField.

private void writeField(Field field, Object dto, Object value) {
    try {
        PropertyDescriptor propertyDescriptor = new PropertyDescriptor(field.getName(), dto.getClass());
        Object dtoList = value;
        if (EnumValueSet.class.isAssignableFrom(field.getType()) && value != null && CodePhrase.class.isAssignableFrom(value.getClass())) {
            CodePhrase codePhrase = (CodePhrase) value;
            EnumValueSet enumValueSet = Arrays.stream(field.getType().getEnumConstants()).map(o -> (EnumValueSet) o).filter(v -> {
                String terminologyId = Optional.ofNullable(codePhrase.getTerminologyId()).map(ObjectId::getValue).orElse(null);
                return v.getTerminologyId().equals(terminologyId);
            }).filter(v -> v.getCode().equals(codePhrase.getCodeString())).findAny().orElse(null);
            dtoList = enumValueSet;
        }
        if (dtoList instanceof RmPrimitive) {
            dtoList = ((RmPrimitive<?>) dtoList).getValue();
        }
        if (List.class.isAssignableFrom(field.getType())) {
            dtoList = propertyDescriptor.getReadMethod().invoke(dto);
            if (dtoList == null) {
                dtoList = new ArrayList<>();
            }
            ((List) dtoList).add(value);
        }
        propertyDescriptor.getWriteMethod().invoke(dto, dtoList);
    } catch (IllegalAccessException | InvocationTargetException | IntrospectionException | IllegalArgumentException e) {
        throw new ClientException(e.getMessage(), e);
    }
}
Also used : java.util(java.util) SdkException(org.ehrbase.util.exception.SdkException) LoggerFactory(org.slf4j.LoggerFactory) TypeToken(com.google.common.reflect.TypeToken) ObjectId(com.nedap.archie.rm.support.identification.ObjectId) FromCompositionWalker(org.ehrbase.serialisation.walker.FromCompositionWalker) StringUtils(org.apache.commons.lang3.StringUtils) EnumValueSet(org.ehrbase.client.classgenerator.EnumValueSet) Function(java.util.function.Function) RmPrimitive(org.ehrbase.serialisation.walker.RmPrimitive) FieldUtils(org.apache.commons.lang3.reflect.FieldUtils) ClientException(org.ehrbase.client.exception.ClientException) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) OptionFor(org.ehrbase.client.annotations.OptionFor) Path(org.ehrbase.client.annotations.Path) Context(org.ehrbase.serialisation.walker.Context) ReflectionHelper(org.ehrbase.util.reflection.ReflectionHelper) Logger(org.slf4j.Logger) CaseUtils(org.apache.commons.text.CaseUtils) Field(java.lang.reflect.Field) Collectors(java.util.stream.Collectors) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) IntrospectionException(java.beans.IntrospectionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) FlatPath(org.ehrbase.webtemplate.parser.FlatPath) Stream(java.util.stream.Stream) ParameterizedType(java.lang.reflect.ParameterizedType) PropertyDescriptor(java.beans.PropertyDescriptor) RMObject(com.nedap.archie.rm.RMObject) Entity(org.ehrbase.client.annotations.Entity) WebTemplateNode(org.ehrbase.webtemplate.model.WebTemplateNode) PropertyDescriptor(java.beans.PropertyDescriptor) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) ObjectId(com.nedap.archie.rm.support.identification.ObjectId) IntrospectionException(java.beans.IntrospectionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) EnumValueSet(org.ehrbase.client.classgenerator.EnumValueSet) RmPrimitive(org.ehrbase.serialisation.walker.RmPrimitive) RMObject(com.nedap.archie.rm.RMObject) ClientException(org.ehrbase.client.exception.ClientException)

Example 13 with ObjectId

use of com.nedap.archie.rm.support.identification.ObjectId in project ehrbase by ehrbase.

the class PersistedPartyIdentified method render.

@Override
public PartyProxy render(PartyIdentifiedRecord partyIdentifiedRecord) {
    PartyRef partyRef = null;
    if (partyIdentifiedRecord.getPartyRefType() != null) {
        ObjectId objectID = new PersistedObjectId().fromDB(partyIdentifiedRecord);
        partyRef = new PartyRef(objectID, partyIdentifiedRecord.getPartyRefNamespace(), partyIdentifiedRecord.getPartyRefType());
    }
    List<DvIdentifier> identifierList = new PartyIdentifiers(domainAccess).retrieve(partyIdentifiedRecord);
    PartyIdentified partyIdentified = new PartyIdentified(partyRef, partyIdentifiedRecord.getName(), identifierList.isEmpty() ? null : identifierList);
    return partyIdentified;
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) ObjectId(com.nedap.archie.rm.support.identification.ObjectId) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier)

Example 14 with ObjectId

use of com.nedap.archie.rm.support.identification.ObjectId in project ehrbase by ehrbase.

the class ContextAccess method getPartyIdentifiedFromRecord.

private static PartyIdentified getPartyIdentifiedFromRecord(PartyIdentifiedRecord partyIdentifiedRecord, List<DvIdentifier> identifiers) {
    PartyIdentified healthCareFacility;
    PartyRef partyRef = null;
    if (partyIdentifiedRecord.getPartyRefValue() != null && partyIdentifiedRecord.getPartyRefScheme() != null) {
        ObjectId objectID = new PersistedObjectId().fromDB(partyIdentifiedRecord);
        partyRef = new PartyRef(objectID, partyIdentifiedRecord.getPartyRefNamespace(), partyIdentifiedRecord.getPartyRefType());
    }
    healthCareFacility = new PartyIdentified(partyRef, partyIdentifiedRecord.getName(), identifiers.isEmpty() ? null : identifiers);
    return healthCareFacility;
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) ObjectId(com.nedap.archie.rm.support.identification.ObjectId) PersistedObjectId(org.ehrbase.dao.access.jooq.party.PersistedObjectId) PersistedObjectId(org.ehrbase.dao.access.jooq.party.PersistedObjectId)

Aggregations

ObjectId (com.nedap.archie.rm.support.identification.ObjectId)14 GenericId (com.nedap.archie.rm.support.identification.GenericId)7 ObjectRef (com.nedap.archie.rm.support.identification.ObjectRef)7 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)5 PartyRef (com.nedap.archie.rm.support.identification.PartyRef)5 Map (java.util.Map)5 Test (org.junit.Test)5 Context (org.ehrbase.serialisation.walker.Context)4 WorkflowIdTest (care.better.platform.web.template.WorkflowIdTest)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 Composition (com.nedap.archie.rm.composition.Composition)3 Entry (com.nedap.archie.rm.composition.Entry)3 Section (com.nedap.archie.rm.composition.Section)3 OffsetDateTime (java.time.OffsetDateTime)3 ZoneId (java.time.ZoneId)3 ZonedDateTime (java.time.ZonedDateTime)3 DateTimeFormatter (java.time.format.DateTimeFormatter)3 IntStream (java.util.stream.IntStream)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3