Search in sources :

Example 56 with TerminologyId

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

the class DvCodedTextTest method testValidate_FhirCodeSystem_WrongTerminologyId.

@Test
void testValidate_FhirCodeSystem_WrongTerminologyId() throws Exception {
    var codePhrase = new CodePhrase(new TerminologyId("http://hl7.org/fhir/name-use"), "usual");
    // Mockito initialization
    Mockito.when(fhirTerminologyValidationMock.supports("//fhir.hl7.org/CodeSystem?url=http://hl7.org/fhir/observation-status")).thenReturn(true);
    Mockito.doThrow(new ConstraintViolationException(List.of(new ConstraintViolation("/test/dv_coded_text_fhir_value_set", "The terminology http://hl7.org/fhir/name-use must be http://hl7.org/fhir/observation-status")))).when(fhirTerminologyValidationMock).validate("/test/dv_coded_text_fhir_code_system", "//fhir.hl7.org/CodeSystem?url=http://hl7.org/fhir/observation-status", codePhrase);
    var validator = new DvCodedTextValidator(fhirTerminologyValidationMock);
    var node = parseNode("/webtemplate_nodes/dv_codedtext_fhir_codesystem.json");
    var result = validator.validate(new DvCodedText("Usual", codePhrase), node);
    assertEquals(1, result.size());
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) ConstraintViolation(org.ehrbase.validation.ConstraintViolation) ConstraintViolationException(org.ehrbase.validation.ConstraintViolationException) Test(org.junit.jupiter.api.Test)

Example 57 with TerminologyId

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

the class DvCodedTextTest method testValidate_FhirValueSet.

@Test
void testValidate_FhirValueSet() throws Exception {
    var codePhrase = new CodePhrase(new TerminologyId("http://terminology.hl7.org/CodeSystem/v3-EntityNameUseR2"), "UKN");
    // Mockito initialization
    Mockito.when(fhirTerminologyValidationMock.supports("//fhir.hl7.org/ValueSet/$expand?url=http://terminology.hl7.org/ValueSet/v3-EntityNameUseR2")).thenReturn(true);
    Mockito.doNothing().when(fhirTerminologyValidationMock).validate("/test/dv_coded_text_fhir_value_set", "//fhir.hl7.org/ValueSet/$expand?url=http://terminology.hl7.org/ValueSet/v3-EntityNameUseR2", codePhrase);
    var validator = new DvCodedTextValidator(fhirTerminologyValidationMock);
    var node = parseNode("/webtemplate_nodes/dv_codedtext_fhir_valueset.json");
    var result = validator.validate(new DvCodedText("Anonymous", codePhrase), node);
    assertTrue(result.isEmpty());
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) Test(org.junit.jupiter.api.Test)

Example 58 with TerminologyId

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

the class EntryAccess method retrieveInstanceInComposition.

/**
 * @throws IllegalArgumentException if DB is inconsistent or operation fails
 */
public static List<I_EntryAccess> retrieveInstanceInComposition(I_DomainAccess domainAccess, I_CompositionAccess compositionAccess) {
    Result<EntryRecord> entryRecords = domainAccess.getContext().selectFrom(ENTRY).where(ENTRY.COMPOSITION_ID.eq(compositionAccess.getId())).fetch();
    // build the list of parameters to recreate the composition
    Map<SystemValue, Object> values = new HashMap<>();
    values.put(SystemValue.COMPOSER, new PersistedPartyProxy(domainAccess).retrieve(compositionAccess.getComposerId()));
    // optional handling for persistent compositions that do not have a context
    Optional<I_ContextAccess> opContextAccess = compositionAccess.getContextId().map(id -> I_ContextAccess.retrieveInstance(domainAccess, id));
    opContextAccess.ifPresent(context -> values.put(SystemValue.CONTEXT, context.mapRmEventContext()));
    values.put(SystemValue.LANGUAGE, new CodePhrase(new TerminologyId("ISO_639-1"), compositionAccess.getLanguageCode()));
    String territory2letters = domainAccess.getContext().fetchOne(TERRITORY, TERRITORY.CODE.eq(compositionAccess.getTerritoryCode())).getTwoletter();
    values.put(SystemValue.TERRITORY, new CodePhrase(new TerminologyId("ISO_3166-1"), territory2letters));
    if (compositionAccess.getFeederAudit() != null) {
        values.put(SystemValue.FEEDER_AUDIT, new FeederAuditEncoding().fromDB(compositionAccess.getFeederAudit()));
    }
    if (compositionAccess.getLinks() != null) {
        values.put(SystemValue.LINKS, new LinksEncoding().fromDB(compositionAccess.getLinks()));
    }
    List<I_EntryAccess> content = new ArrayList<>();
    try {
        EntryAccess entryAccess = new EntryAccess(domainAccess);
        for (EntryRecord record : entryRecords) {
            // set the record UID in the composition with matching version number
            Integer version = I_CompositionAccess.getLastVersionNumber(domainAccess, compositionAccess.getId());
            values.put(SystemValue.UID, new ObjectVersionId(compositionAccess.getId().toString() + "::" + domainAccess.getServerConfig().getNodename() + "::" + version));
            entryAccess.entryRecord = record;
            String value = record.getEntry().data();
            entryAccess.composition = new RawJson().unmarshal(value, Composition.class);
            // continuing optional handling for persistent compositions
            opContextAccess.map(I_ContextAccess::mapRmEventContext).ifPresent(ec -> values.put(SystemValue.CONTEXT, ec));
            values.put(SystemValue.CATEGORY, new RecordedDvCodedText().fromDB(record, ENTRY.CATEGORY));
            setCompositionAttributes(entryAccess.composition, values);
            buildArchetypeDetails(entryAccess);
            content.add(entryAccess);
        }
    } catch (Exception e) {
        throw new IllegalArgumentException(DB_INCONSISTENCY + e);
    }
    return content;
}
Also used : I_EntryAccess(org.ehrbase.dao.access.interfaces.I_EntryAccess) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ObjectVersionId(com.nedap.archie.rm.support.identification.ObjectVersionId) I_EntryAccess(org.ehrbase.dao.access.interfaces.I_EntryAccess) RecordedDvCodedText(org.ehrbase.service.RecordedDvCodedText) FeederAuditEncoding(org.ehrbase.serialisation.dbencoding.rmobject.FeederAuditEncoding) LinksEncoding(org.ehrbase.serialisation.dbencoding.rmobject.LinksEncoding) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) Composition(com.nedap.archie.rm.composition.Composition) RawJson(org.ehrbase.serialisation.dbencoding.RawJson) InternalServerException(org.ehrbase.api.exception.InternalServerException) PersistedPartyProxy(org.ehrbase.dao.access.jooq.party.PersistedPartyProxy) I_ContextAccess(org.ehrbase.dao.access.interfaces.I_ContextAccess) EntryRecord(org.ehrbase.jooq.pg.tables.records.EntryRecord)

Example 59 with TerminologyId

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

the class EventContextFactory method makeNull.

public EventContext makeNull() {
    PartyRef partyRef = new PartyRef(new HierObjectId("ref"), "null", "null");
    PartyIdentified healthcareFacility = new PartyIdentified(partyRef, "null", null);
    DvCodedText concept = new DvCodedText("Other Care", new CodePhrase(new TerminologyId("openehr"), "238"));
    return new EventContext(healthcareFacility, new DvDateTime(new DateTime(0L).toString()), null, null, null, 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) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) DateTime(org.joda.time.DateTime) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)

Example 60 with TerminologyId

use of com.nedap.archie.rm.support.identification.TerminologyId 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)

Aggregations

TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)62 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)60 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)50 Test (org.junit.jupiter.api.Test)23 Test (org.junit.Test)13 DvText (com.nedap.archie.rm.datavalues.DvText)10 Composition (com.nedap.archie.rm.composition.Composition)8 ArrayList (java.util.ArrayList)7 AbstractRMObjectValidatorTest (org.ehrbase.validation.webtemplate.AbstractRMObjectValidatorTest)7 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)6 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)5 RMObject (com.nedap.archie.rm.RMObject)4 EventContext (com.nedap.archie.rm.composition.EventContext)4 PartyProxy (com.nedap.archie.rm.generic.PartyProxy)4 List (java.util.List)4 Locatable (com.nedap.archie.rm.archetyped.Locatable)3 Entry (com.nedap.archie.rm.composition.Entry)3 DvURI (com.nedap.archie.rm.datavalues.DvURI)3 DvOrdinal (com.nedap.archie.rm.datavalues.quantity.DvOrdinal)3 PartyRelated (com.nedap.archie.rm.generic.PartyRelated)3