Search in sources :

Example 6 with PartyRef

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

the class DefaultRestEhrFieldsEndpointIT method testCreateEhrWithStatus.

@Test
public void testCreateEhrWithStatus() {
    EhrStatus ehrStatus = new EhrStatus();
    ehrStatus.setQueryable(false);
    ehrStatus.setModifiable(false);
    HierObjectId subjectId = new HierObjectId(UUID.randomUUID().toString());
    ehrStatus.setSubject(new PartySelf(new PartyRef(subjectId, "default", "PERSON")));
    ehrStatus.setArchetypeNodeId("just-a-status");
    ehrStatus.setName(new DvText("Status"));
    ehr = openEhrClient.ehrEndpoint().createEhr(ehrStatus);
    assertThat(ehr).isNotNull();
    EhrStatus actual = openEhrClient.ehrEndpoint().getEhrStatus(ehr).get();
    assertThat(actual.getSubject().getExternalRef().getId()).isEqualTo(subjectId);
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) PartySelf(com.nedap.archie.rm.generic.PartySelf) DvText(com.nedap.archie.rm.datavalues.DvText) Test(org.junit.Test)

Example 7 with PartyRef

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

the class DefaultValues method buildParticipation.

public static Participation buildParticipation(Collection<Map.Entry<String, String>> subValues) {
    Participation participation = new Participation();
    participation.setPerformer(new PartyIdentified());
    extractExact(subValues, "id", s -> {
        participation.getPerformer().setExternalRef(new PartyRef());
        participation.getPerformer().getExternalRef().setType("PARTY");
        GenericId id = new GenericId();
        id.setValue(s);
        participation.getPerformer().getExternalRef().setId(id);
    });
    extract(subValues, "name", ((PartyIdentified) participation.getPerformer())::setName);
    if (participation.getPerformer().getExternalRef() != null) {
        extract(subValues, "id_namespace", n -> participation.getPerformer().getExternalRef().setNamespace(n));
        extract(subValues, "id_scheme", ((GenericId) participation.getPerformer().getExternalRef().getId())::setScheme);
    }
    extract(subValues, "function", s -> participation.setFunction(new DvText(s)));
    extract(subValues, "mode", s -> {
        ParticipationMode participationMode = findEnumValueOrThrow(s, ParticipationMode.class);
        participation.setMode(new DvCodedText());
        participation.getMode().setValue(participationMode.getValue());
        participation.getMode().setDefiningCode(participationMode.toCodePhrase());
    });
    ((PartyIdentified) participation.getPerformer()).setIdentifiers(splitByIndex(filter(subValues.stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)), DefaultValuePath.PARTICIPATION.getPath() + "_" + "identifiers")).values().stream().map(DefaultValues::toDvIdentifier).collect(Collectors.toList()));
    return participation;
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) Participation(com.nedap.archie.rm.generic.Participation) GenericId(com.nedap.archie.rm.support.identification.GenericId) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) ParticipationMode(org.ehrbase.client.classgenerator.shareddefinition.ParticipationMode) DvText(com.nedap.archie.rm.datavalues.DvText)

Example 8 with PartyRef

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

the class AbstractValueInserter method buildPartyIdentified.

protected PartyIdentified buildPartyIdentified(DefaultValues defaultValues, DefaultValuePath<String> name, DefaultValuePath<String> id, PartyProxy partyProxy) {
    if (partyProxy == null || !PartyIdentified.class.isAssignableFrom(partyProxy.getClass())) {
        partyProxy = new PartyIdentified();
    }
    if (defaultValues.containsDefaultValue(name)) {
        ((PartyIdentified) partyProxy).setName(defaultValues.getDefaultValue(name));
    }
    if (defaultValues.containsDefaultValue(id)) {
        PartyRef partyRef = new PartyRef();
        partyRef.setNamespace(defaultValues.getDefaultValue(DefaultValuePath.ID_NAMESPACE));
        partyRef.setType("PARTY");
        partyRef.setId(new GenericId(defaultValues.getDefaultValue(id), defaultValues.getDefaultValue(DefaultValuePath.ID_SCHEME)));
        partyProxy.setExternalRef(partyRef);
    }
    addSchemeNamespace(partyProxy.getExternalRef(), defaultValues);
    return (PartyIdentified) partyProxy;
}
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)

Example 9 with PartyRef

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

the class PartyIdentifiedRMUnmarshaller method handle.

@Override
public void handle(String currentTerm, PartyIdentified rmObject, Map<FlatPathDto, String> currentValues, Context<Map<FlatPathDto, String>> context, Set<String> consumedPaths) {
    setValue(currentTerm, "name", currentValues, rmObject::setName, String.class, consumedPaths);
    if (rmObject.getName() == null) {
        // betters implementation uses /name or  /_name instead of |name for subject
        setValue(currentTerm + "/name", null, currentValues, rmObject::setName, String.class, consumedPaths);
        if (rmObject.getName() == null) {
            setValue(currentTerm + "/_name", null, currentValues, rmObject::setName, String.class, consumedPaths);
        }
    }
    rmObject.setExternalRef(new PartyRef());
    rmObject.getExternalRef().setType("PARTY");
    rmObject.getExternalRef().setId(new GenericId());
    setValue(currentTerm, "id", currentValues, rmObject.getExternalRef().getId()::setValue, String.class, consumedPaths);
    setValue(currentTerm, "id_scheme", currentValues, ((GenericId) rmObject.getExternalRef().getId())::setScheme, String.class, consumedPaths);
    setValue(currentTerm, "id_namespace", currentValues, rmObject.getExternalRef()::setNamespace, String.class, consumedPaths);
    // remove if not set
    if (rmObject.getExternalRef().getId() == null || StringUtils.isBlank(rmObject.getExternalRef().getId().getValue())) {
        rmObject.setExternalRef(null);
    }
    Map<Integer, Map<String, String>> identifiers = extractMultiValued(currentTerm, "_identifier", currentValues);
    rmObject.setIdentifiers(identifiers.values().stream().map(DefaultValues::toDvIdentifier).collect(Collectors.toList()));
    consumeAllMatching(currentTerm + PATH_DIVIDER + "_identifier", currentValues, consumedPaths, false);
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) GenericId(com.nedap.archie.rm.support.identification.GenericId) DefaultValues(org.ehrbase.serialisation.walker.defaultvalues.DefaultValues) Map(java.util.Map)

Example 10 with PartyRef

use of com.nedap.archie.rm.support.identification.PartyRef in project fhir-bridge by ehrbase.

the class EhrLookupProcessor method createEhr.

/**
 * Creates an EHR for the given patient ID.
 *
 * @param patientId the given patient ID
 * @return the EHR ID
 */
private UUID createEhr(IIdType patientId) {
    Patient patient = patientDao.read(patientId);
    Identifier pseudonym = PatientUtils.getPseudonym(patient);
    PartySelf subject = new PartySelf(new PartyRef(new HierObjectId(pseudonym.getValue()), "DEMOGRAPHIC", "PERSON"));
    EhrStatus ehrStatus = new EhrStatus(ARCHETYPE_NODE_ID, new DvText("EHR Status"), subject, true, true, null);
    UUID ehrId = openEhrClient.ehrEndpoint().createEhr(ehrStatus);
    PatientEhr patientEhr = new PatientEhr(patientId.getIdPart(), ehrId);
    patientEhrRepository.save(patientEhr);
    LOG.debug("Created PatientEhr: patientId={}, ehrId={}", patientEhr.getPatientId(), patientEhr.getEhrId());
    return ehrId;
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) Identifier(org.hl7.fhir.r4.model.Identifier) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) Patient(org.hl7.fhir.r4.model.Patient) UUID(java.util.UUID) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) PartySelf(com.nedap.archie.rm.generic.PartySelf) DvText(com.nedap.archie.rm.datavalues.DvText) PatientEhr(org.ehrbase.fhirbridge.core.domain.PatientEhr)

Aggregations

PartyRef (com.nedap.archie.rm.support.identification.PartyRef)19 DvText (com.nedap.archie.rm.datavalues.DvText)9 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)8 PartySelf (com.nedap.archie.rm.generic.PartySelf)8 GenericId (com.nedap.archie.rm.support.identification.GenericId)8 EhrStatus (com.nedap.archie.rm.ehr.EhrStatus)7 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)6 ObjectId (com.nedap.archie.rm.support.identification.ObjectId)5 Test (org.junit.Test)4 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)3 EventContext (com.nedap.archie.rm.composition.EventContext)2 ItemTree (com.nedap.archie.rm.datastructures.ItemTree)2 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)2 DvIdentifier (com.nedap.archie.rm.datavalues.DvIdentifier)2 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)2 Participation (com.nedap.archie.rm.generic.Participation)2 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)2 URI (java.net.URI)2 UUID (java.util.UUID)2 DateTime (org.joda.time.DateTime)2