Search in sources :

Example 1 with PartyProxy

use of com.nedap.archie.rm.generic.PartyProxy in project ehrbase by ehrbase.

the class ContextAccess method mapRmEventContext.

/**
 * @throws InternalServerException on failure of decoding DvText or DvDateTime
 */
@Override
public EventContext mapRmEventContext() {
    // get the facility entry
    PartyIdentifiedRecord partyIdentifiedRecord = getContext().fetchOne(PARTY_IDENTIFIED, PARTY_IDENTIFIED.ID.eq(eventContextRecord.getFacility()));
    // facility identifiers
    PartyIdentified healthCareFacility = null;
    if (partyIdentifiedRecord != null) {
        List<DvIdentifier> identifiers = new ArrayList<>();
        getContext().fetch(IDENTIFIER, IDENTIFIER.PARTY.eq(partyIdentifiedRecord.getId())).forEach(record -> {
            DvIdentifier dvIdentifier = new DvIdentifier();
            dvIdentifier.setIssuer(record.getIssuer());
            dvIdentifier.setAssigner(record.getAssigner());
            dvIdentifier.setId(record.getIdValue());
            dvIdentifier.setType(record.getTypeName());
            identifiers.add(dvIdentifier);
        });
        // get PartyRef values from record
        healthCareFacility = getPartyIdentifiedFromRecord(partyIdentifiedRecord, identifiers);
    }
    List<Participation> participationList = new ArrayList<>();
    // get the participations
    getContext().fetch(PARTICIPATION, PARTICIPATION.EVENT_CONTEXT.eq(eventContextRecord.getId())).forEach(record -> {
        // retrieve performer
        PartyProxy performer = new PersistedPartyProxy(this).retrieve(record.getPerformer());
        DvInterval<DvDateTime> dvInterval = convertDvIntervalDvDateTimeFromRecord(record);
        DvCodedText mode = convertModeFromRecord(record);
        Participation participation = new Participation(performer, (DvText) new RecordedDvCodedText().fromDB(record, PARTICIPATION.FUNCTION), mode, dvInterval);
        participationList.add(participation);
    });
    DvCodedText concept = (DvCodedText) new RecordedDvCodedText().fromDB(eventContextRecord, EVENT_CONTEXT.SETTING);
    ItemStructure otherContext = null;
    if (eventContextRecord.getOtherContext() != null) {
        otherContext = new RawJson().unmarshal((eventContextRecord.getOtherContext().data()), ItemStructure.class);
    }
    return new EventContext(healthCareFacility, new RecordedDvDateTime().decodeDvDateTime(eventContextRecord.getStartTime(), eventContextRecord.getStartTimeTzid()), new RecordedDvDateTime().decodeDvDateTime(eventContextRecord.getEndTime(), eventContextRecord.getEndTimeTzid()), participationList.isEmpty() ? null : participationList, eventContextRecord.getLocation(), concept, otherContext);
}
Also used : Participation(com.nedap.archie.rm.generic.Participation) PartyIdentifiedRecord(org.ehrbase.jooq.pg.tables.records.PartyIdentifiedRecord) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) RecordedDvCodedText(org.ehrbase.service.RecordedDvCodedText) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) RawJson(org.ehrbase.serialisation.dbencoding.RawJson) ArrayList(java.util.ArrayList) ItemStructure(com.nedap.archie.rm.datastructures.ItemStructure) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier) PersistedPartyProxy(org.ehrbase.dao.access.jooq.party.PersistedPartyProxy) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) RecordedDvDateTime(org.ehrbase.service.RecordedDvDateTime) EventContext(com.nedap.archie.rm.composition.EventContext) RecordedDvDateTime(org.ehrbase.service.RecordedDvDateTime) RecordedDvCodedText(org.ehrbase.service.RecordedDvCodedText) PersistedPartyProxy(org.ehrbase.dao.access.jooq.party.PersistedPartyProxy) PartyProxy(com.nedap.archie.rm.generic.PartyProxy)

Example 2 with PartyProxy

use of com.nedap.archie.rm.generic.PartyProxy in project ehrbase by ehrbase.

the class AttestationAccess method getAsAttestation.

@Override
public Attestation getAsAttestation() {
    // take most values from super class entry
    AuditDetails audit = auditDetailsAccess.getAsAuditDetails();
    String systemId = audit.getSystemId();
    PartyProxy committer = audit.getCommitter();
    DvDateTime time = audit.getTimeCommitted();
    DvCodedText changeType = audit.getChangeType();
    DvText description = audit.getDescription();
    // FIXME VERSIONED_OBJECT_POC: implement retrieval from "attested_view" table
    DvMultimedia attestedView = null;
    String proof = attestationRecord.getProof();
    // FIXME VERSIONED_OBJECT_POC: implement?! seems to be completely unsupported right now
    List<DvEHRURI> items = null;
    DvText reason = new DvText(attestationRecord.getReason());
    boolean isPending = attestationRecord.getIsPending();
    return new Attestation(systemId, committer, time, changeType, description, attestedView, proof, items, reason, isPending);
}
Also used : DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) DvEHRURI(com.nedap.archie.rm.datavalues.DvEHRURI) PartyProxy(com.nedap.archie.rm.generic.PartyProxy) AuditDetails(com.nedap.archie.rm.generic.AuditDetails) DvMultimedia(com.nedap.archie.rm.datavalues.encapsulated.DvMultimedia) Attestation(com.nedap.archie.rm.generic.Attestation) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) DvText(com.nedap.archie.rm.datavalues.DvText)

Example 3 with PartyProxy

use of com.nedap.archie.rm.generic.PartyProxy in project ehrbase by ehrbase.

the class AuditDetailsAccess method getAsAuditDetails.

@Override
public AuditDetails getAsAuditDetails() {
    String systemId = getSystemId().toString();
    PartyProxy party = new PersistedPartyProxy(this).retrieve(getCommitter());
    DvDateTime time = new DvDateTime(getTimeCommitted().toLocalDateTime());
    DvCodedText changeType = new DvCodedText(getChangeType().getLiteral(), new CodePhrase(new TerminologyId("openehr"), Integer.toString(I_ConceptAccess.ContributionChangeType.valueOf(getChangeType().getLiteral().toUpperCase()).getCode())));
    DvText description = new DvText(getDescription());
    return new AuditDetails(systemId, party, time, changeType, description);
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) PartyProxy(com.nedap.archie.rm.generic.PartyProxy) PersistedPartyProxy(org.ehrbase.dao.access.jooq.party.PersistedPartyProxy) AuditDetails(com.nedap.archie.rm.generic.AuditDetails) PersistedPartyProxy(org.ehrbase.dao.access.jooq.party.PersistedPartyProxy) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) DvText(com.nedap.archie.rm.datavalues.DvText)

Example 4 with PartyProxy

use of com.nedap.archie.rm.generic.PartyProxy in project openEHR_SDK by ehrbase.

the class EntryPostprocessor method process.

/**
 * {@inheritDoc}
 */
@Override
public void process(String term, Entry rmObject, Map<FlatPathDto, String> values, Set<String> consumedPaths, Context<Map<FlatPathDto, String>> context) {
    consumedPaths.add(term + PATH_DIVIDER + "encoding|code");
    consumedPaths.add(term + PATH_DIVIDER + "encoding|terminology");
    Map<FlatPathDto, String> subjectValues = FlatHelper.filter(values, term + "/subject", false);
    if (!subjectValues.isEmpty()) {
        if (rmObject.getSubject() == null) {
            // If it was PartyRelated it would be set by now do to the relationship  and if it was
            // PartySelf subjectValues would be empty
            rmObject.setSubject(new PartyIdentified());
        }
        callUnmarshal(term, "subject", rmObject.getSubject(), values, consumedPaths, context, context.getNodeDeque().peek().findChildById("subject").orElse(buildDummyChild("subject", context.getNodeDeque().peek())));
    }
    PartyProxy subject = rmObject.getSubject();
    if (subject == null || (subject instanceof PartyIdentified && ((PartyIdentified) subject).getName() == null && CollectionUtils.isEmpty(((PartyIdentified) subject).getIdentifiers()) && subject.getExternalRef() == null && (!(subject instanceof PartyRelated) || ((PartyRelated) subject).getRelationship() == null || StringUtils.isEmpty(((PartyRelated) subject).getRelationship().getValue())))) {
        rmObject.setSubject(new PartySelf());
    }
    Map<FlatPathDto, String> providerList = values.entrySet().stream().filter(e -> e.getKey().startsWith(term + PATH_DIVIDER + "_provider")).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
    if (!MapUtils.isEmpty(providerList)) {
        if (!(rmObject.getProvider() instanceof PartyIdentified)) {
            rmObject.setProvider(new PartyIdentified());
        }
        PartyIdentifiedRMUnmarshaller partyIdentifiedRMUnmarshaller = new PartyIdentifiedRMUnmarshaller();
        partyIdentifiedRMUnmarshaller.handle(term + PATH_DIVIDER + "_provider", (PartyIdentified) rmObject.getProvider(), providerList, null, consumedPaths);
    }
    Map<Integer, Map<String, String>> other = extractMultiValued(term, "_other_participation", values);
    other.values().stream().map(Map::entrySet).map(s -> s.stream().collect(Collectors.toMap(e -> "ctx/" + DefaultValuePath.PARTICIPATION.getPath() + "_" + e.getKey().replace("identifiers_", "identifiers|"), e -> StringUtils.wrap(e.getValue(), '"'))).entrySet()).map(DefaultValues::buildParticipation).forEach(rmObject::addOtherParticipant);
    consumeAllMatching(term + PATH_DIVIDER + "_other_participation", values, consumedPaths, false);
    Map<FlatPathDto, String> workflowIdValues = filter(values, term + "/_work_flow_id", false);
    if (!workflowIdValues.isEmpty()) {
        ObjectRef<GenericId> ref = new ObjectRef<>();
        ref.setId(new GenericId());
        rmObject.setWorkflowId(ref);
        setValue(term + "/_work_flow_id", "id", workflowIdValues, s -> ref.getId().setValue(s), String.class, consumedPaths);
        setValue(term + "/_work_flow_id", "id_scheme", workflowIdValues, s -> ref.getId().setScheme(s), String.class, consumedPaths);
        setValue(term + "/_work_flow_id", "namespace", workflowIdValues, ref::setNamespace, String.class, consumedPaths);
        setValue(term + "/_work_flow_id", "type", workflowIdValues, ref::setType, String.class, consumedPaths);
    }
}
Also used : Entry(com.nedap.archie.rm.composition.Entry) PartyProxy(com.nedap.archie.rm.generic.PartyProxy) PartySelf(com.nedap.archie.rm.generic.PartySelf) MapUtils(org.apache.commons.collections4.MapUtils) ObjectRef(com.nedap.archie.rm.support.identification.ObjectRef) Context(org.ehrbase.serialisation.walker.Context) FlatHelper(org.ehrbase.serialisation.walker.FlatHelper) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) DefaultValuePath(org.ehrbase.serialisation.walker.defaultvalues.DefaultValuePath) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) Set(java.util.Set) DefaultValues(org.ehrbase.serialisation.walker.defaultvalues.DefaultValues) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) CollectionUtils(org.apache.commons.collections4.CollectionUtils) PartyIdentifiedRMUnmarshaller(org.ehrbase.serialisation.flatencoding.std.umarshal.rmunmarshaller.PartyIdentifiedRMUnmarshaller) PATH_DIVIDER(org.ehrbase.webtemplate.parser.OPTParser.PATH_DIVIDER) GenericId(com.nedap.archie.rm.support.identification.GenericId) Map(java.util.Map) PartyRelated(com.nedap.archie.rm.generic.PartyRelated) GenericId(com.nedap.archie.rm.support.identification.GenericId) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) PartyRelated(com.nedap.archie.rm.generic.PartyRelated) PartySelf(com.nedap.archie.rm.generic.PartySelf) PartyIdentifiedRMUnmarshaller(org.ehrbase.serialisation.flatencoding.std.umarshal.rmunmarshaller.PartyIdentifiedRMUnmarshaller) PartyProxy(com.nedap.archie.rm.generic.PartyProxy) ObjectRef(com.nedap.archie.rm.support.identification.ObjectRef) Map(java.util.Map)

Example 5 with PartyProxy

use of com.nedap.archie.rm.generic.PartyProxy in project openEHR_SDK by ehrbase.

the class ParticipationConfig method buildChildValues.

/**
 * {@inheritDoc}
 */
@Override
public Map<String, Object> buildChildValues(String currentTerm, Participation rmObject, Context<Map<String, Object>> context) {
    Map<String, Object> result = new HashMap<>();
    addValue(result, currentTerm, "id", Optional.of(rmObject).map(Participation::getPerformer).map(PartyProxy::getExternalRef).map(ObjectRef::getId).map(ObjectId::getValue).orElse(null));
    addValue(result, currentTerm, "id_namespace", Optional.of(rmObject).map(Participation::getPerformer).map(PartyProxy::getExternalRef).map(ObjectRef::getNamespace).orElse(null));
    addValue(result, currentTerm, "id_scheme", Optional.of(rmObject).map(Participation::getPerformer).map(PartyProxy::getExternalRef).map(PartyRef::getId).filter(cls -> GenericId.class.isAssignableFrom(cls.getClass())).map(GenericId.class::cast).map(GenericId::getScheme).orElse(null));
    addValue(result, currentTerm, "name", Optional.of(rmObject).map(Participation::getPerformer).filter(p -> PartyIdentified.class.isAssignableFrom(p.getClass())).map(PartyIdentified.class::cast).map(PartyIdentified::getName).orElse(null));
    addValue(result, currentTerm, "mode", Optional.of(rmObject).map(Participation::getMode).map(DvText::getValue).orElse(null));
    addValue(result, currentTerm, "function", Optional.of(rmObject).map(Participation::getFunction).map(DvText::getValue).orElse(null));
    List<DvIdentifier> dvIdentifiers = Optional.of(rmObject).map(Participation::getPerformer).filter(p -> PartyIdentified.class.isAssignableFrom(p.getClass())).map(PartyIdentified.class::cast).map(PartyIdentified::getIdentifiers).orElse(Collections.emptyList());
    IntStream.range(0, dvIdentifiers.size()).forEach(i -> {
        DvIdentifier identifier = dvIdentifiers.get(i);
        addValue(result, currentTerm, "identifiers_id:" + i, identifier.getId());
        addValue(result, currentTerm, "identifiers_issuer:" + i, identifier.getIssuer());
        addValue(result, currentTerm, "identifiers_assigner:" + i, identifier.getAssigner());
        addValue(result, currentTerm, "identifiers_type:" + i, identifier.getType());
    });
    return result;
}
Also used : DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier) PartyProxy(com.nedap.archie.rm.generic.PartyProxy) IntStream(java.util.stream.IntStream) ObjectRef(com.nedap.archie.rm.support.identification.ObjectRef) Context(org.ehrbase.serialisation.walker.Context) java.util(java.util) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) PartyRef(com.nedap.archie.rm.support.identification.PartyRef) DvText(com.nedap.archie.rm.datavalues.DvText) GenericId(com.nedap.archie.rm.support.identification.GenericId) Participation(com.nedap.archie.rm.generic.Participation) ObjectId(com.nedap.archie.rm.support.identification.ObjectId) Participation(com.nedap.archie.rm.generic.Participation) GenericId(com.nedap.archie.rm.support.identification.GenericId) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) ObjectId(com.nedap.archie.rm.support.identification.ObjectId) DvText(com.nedap.archie.rm.datavalues.DvText) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier) PartyProxy(com.nedap.archie.rm.generic.PartyProxy) ObjectRef(com.nedap.archie.rm.support.identification.ObjectRef)

Aggregations

PartyProxy (com.nedap.archie.rm.generic.PartyProxy)10 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)7 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)6 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)6 Participation (com.nedap.archie.rm.generic.Participation)5 PersistedPartyProxy (org.ehrbase.dao.access.jooq.party.PersistedPartyProxy)5 DvText (com.nedap.archie.rm.datavalues.DvText)4 GenericId (com.nedap.archie.rm.support.identification.GenericId)4 EventContext (com.nedap.archie.rm.composition.EventContext)3 DvIdentifier (com.nedap.archie.rm.datavalues.DvIdentifier)3 AuditDetails (com.nedap.archie.rm.generic.AuditDetails)3 ObjectRef (com.nedap.archie.rm.support.identification.ObjectRef)3 Context (org.ehrbase.serialisation.walker.Context)3 RecordedDvCodedText (org.ehrbase.service.RecordedDvCodedText)3 RecordedDvDateTime (org.ehrbase.service.RecordedDvDateTime)3 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)2 ObjectId (com.nedap.archie.rm.support.identification.ObjectId)2 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2