Search in sources :

Example 16 with GenericId

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

the class EventContextValueInserter method insert.

@Override
public void insert(EventContext rmObject, DefaultValues defaultValues) {
    if (RMHelper.isEmpty(rmObject.getStartTime()) && defaultValues.containsDefaultValue(DefaultValuePath.TIME)) {
        rmObject.setStartTime(new DvDateTime(defaultValues.getDefaultValue(DefaultValuePath.TIME)));
    }
    if (RMHelper.isEmpty(rmObject.getEndTime()) && defaultValues.containsDefaultValue(DefaultValuePath.END_TIME)) {
        rmObject.setEndTime(new DvDateTime(defaultValues.getDefaultValue(DefaultValuePath.END_TIME)));
    }
    if (RMHelper.isEmpty(rmObject.getHealthCareFacility()) && (defaultValues.containsDefaultValue(DefaultValuePath.HEALTHCARE_FACILITY_NAME) || defaultValues.containsDefaultValue(DefaultValuePath.HEALTHCARE_FACILITY_ID))) {
        rmObject.setHealthCareFacility(buildPartyIdentified(defaultValues, DefaultValuePath.HEALTHCARE_FACILITY_NAME, DefaultValuePath.HEALTHCARE_FACILITY_ID, rmObject.getHealthCareFacility()));
    }
    if (RMHelper.isEmpty(rmObject.getLocation()) && defaultValues.containsDefaultValue(DefaultValuePath.LOCATION)) {
        rmObject.setLocation(defaultValues.getDefaultValue(DefaultValuePath.LOCATION));
    }
    if (RMHelper.isEmpty(rmObject.getSetting()) && defaultValues.containsDefaultValue(DefaultValuePath.SETTING)) {
        Setting defaultValue = defaultValues.getDefaultValue(DefaultValuePath.SETTING);
        rmObject.setSetting(new DvCodedText(defaultValue.getValue(), defaultValue.toCodePhrase()));
    }
    if (RMHelper.isEmpty(rmObject.getParticipations()) && defaultValues.containsDefaultValue(DefaultValuePath.PARTICIPATION)) {
        rmObject.setParticipations(defaultValues.getDefaultValue(DefaultValuePath.PARTICIPATION));
    }
    if (rmObject.getParticipations() != null) {
        rmObject.getParticipations().stream().map(Participation::getPerformer).filter(Objects::nonNull).map(PartyProxy::getExternalRef).filter(Objects::nonNull).filter(ref -> ref.getId() != null).forEach(ref -> {
            if (ref.getNamespace() == null && defaultValues.containsDefaultValue(DefaultValuePath.ID_NAMESPACE)) {
                ref.setNamespace(defaultValues.getDefaultValue(DefaultValuePath.ID_NAMESPACE));
            }
            if (ref.getId() instanceof GenericId && ref.getNamespace() == null && defaultValues.containsDefaultValue(DefaultValuePath.ID_SCHEME)) {
                ((GenericId) ref.getId()).setScheme(defaultValues.getDefaultValue(DefaultValuePath.ID_SCHEME));
            }
        });
    }
}
Also used : PartyProxy(com.nedap.archie.rm.generic.PartyProxy) Objects(java.util.Objects) EventContext(com.nedap.archie.rm.composition.EventContext) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) RMHelper(org.ehrbase.serialisation.walker.RMHelper) DefaultValuePath(org.ehrbase.serialisation.walker.defaultvalues.DefaultValuePath) GenericId(com.nedap.archie.rm.support.identification.GenericId) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) Participation(com.nedap.archie.rm.generic.Participation) DefaultValues(org.ehrbase.serialisation.walker.defaultvalues.DefaultValues) Setting(org.ehrbase.client.classgenerator.shareddefinition.Setting) GenericId(com.nedap.archie.rm.support.identification.GenericId) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) Setting(org.ehrbase.client.classgenerator.shareddefinition.Setting) Objects(java.util.Objects) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)

Example 17 with GenericId

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

the class EventContextFactory method makeDummy.

public EventContext makeDummy() {
    PartyRef partyRef = new PartyRef(new GenericId("123456-123", "EHRBASE-SCHEME"), "DEMOGRAPHIC", "PARTY");
    PartyIdentified healthcareFacility = new PartyIdentified(partyRef, "FACILITY", null);
    DateTime timenow = DateTime.now();
    DvCodedText concept = new DvCodedText("Other Care", new CodePhrase(new TerminologyId("openehr"), "238"));
    return new EventContext(healthcareFacility, new DvDateTime(timenow.toString()), null, null, "TEST LAB", concept, null);
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) EventContext(com.nedap.archie.rm.composition.EventContext) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) GenericId(com.nedap.archie.rm.support.identification.GenericId) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) DateTime(org.joda.time.DateTime) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)

Example 18 with GenericId

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

the class PersistedPartyProxy method getOrCreate.

/**
 * Get or create a PartyIdentified instance with the given parameters.
 */
public UUID getOrCreate(String name, String code, String scheme, String namespace, String type, List<DvIdentifier> identifiers) {
    // Check conformance to openEHR spec
    if (identifiers == null || identifiers.isEmpty()) {
        throw new IllegalArgumentException("Can't create PartyIdentified with invalid list of identifiers.");
    }
    identifiers.forEach(dv -> {
        if (!isValidDvIdentifier(dv))
            throw new IllegalArgumentException("Can't create PartyIdentified with an invalid identifier.");
    });
    // Create and persist object
    var partyIdentified = new PartyIdentified(new PartyRef(new GenericId(code, scheme), namespace, type), name, identifiers);
    return getOrCreate(partyIdentified);
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) GenericId(com.nedap.archie.rm.support.identification.GenericId) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified)

Aggregations

GenericId (com.nedap.archie.rm.support.identification.GenericId)18 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)10 PartyRef (com.nedap.archie.rm.support.identification.PartyRef)8 ObjectId (com.nedap.archie.rm.support.identification.ObjectId)7 ObjectRef (com.nedap.archie.rm.support.identification.ObjectRef)7 Map (java.util.Map)7 Composition (com.nedap.archie.rm.composition.Composition)5 PartyProxy (com.nedap.archie.rm.generic.PartyProxy)5 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)5 Entry (com.nedap.archie.rm.composition.Entry)4 Participation (com.nedap.archie.rm.generic.Participation)4 OffsetDateTime (java.time.OffsetDateTime)4 Test (org.junit.Test)4 WorkflowIdTest (care.better.platform.web.template.WorkflowIdTest)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 Section (com.nedap.archie.rm.composition.Section)3 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)3 DvText (com.nedap.archie.rm.datavalues.DvText)3 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)3