Search in sources :

Example 26 with DvText

use of com.nedap.archie.rm.datavalues.DvText in project openEHR_SDK by ehrbase.

the class DvOrderedPostprocessor method process.

/**
 * {@inheritDoc}
 */
@Override
public void process(String term, DvOrdered rmObject, Map<FlatPathDto, String> values, Set<String> consumedPaths, Context<Map<FlatPathDto, String>> context) {
    handleNormalRange(values, consumedPaths, context, term + "/_normal_range", rmObject::setNormalRange);
    FlatHelper.extractMultiValuedFullPath(term, "_other_reference_ranges", values).forEach((k, v) -> {
        ReferenceRange referenceRange = new ReferenceRange();
        rmObject.addOtherReferenceRange(referenceRange);
        Map<FlatPathDto, String> meaningValues = FlatHelper.filter(values, term + "/_other_reference_ranges:" + k + "/meaning", false);
        if (!meaningValues.isEmpty()) {
            final DvText meaning;
            String meaningAttributeName = "meaning";
            boolean isDvCodedText = isDvCodedText(meaningValues, term + "/_other_reference_ranges:" + k + "/meaning");
            if (isDvCodedText) {
                meaning = new DvCodedText();
            } else {
                meaning = new DvText();
            }
            referenceRange.setMeaning(meaning);
            callUnmarshal(term + "/_other_reference_ranges:" + k, meaningAttributeName, meaning, meaningValues, consumedPaths, context, context.getNodeDeque().peek().findChildById(meaningAttributeName).orElse(buildDummyChild(meaningAttributeName, context.getNodeDeque().peek())));
            callPostProcess(term + "/_other_reference_ranges:" + k, meaningAttributeName, meaning, meaningValues, consumedPaths, context, context.getNodeDeque().peek().findChildById(meaningAttributeName).orElse(buildDummyChild(meaningAttributeName, context.getNodeDeque().peek())));
        }
        handleNormalRange(v, consumedPaths, context, term + "/_other_reference_ranges:" + k, referenceRange::setRange);
    });
    setValue(term, "normal_status", values, s -> {
        if (s != null) {
            rmObject.setNormalStatus(new CodePhrase(new TerminologyId("openehr_normal_statuses"), s));
        }
    }, String.class, consumedPaths);
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) FlatHelper.isDvCodedText(org.ehrbase.serialisation.walker.FlatHelper.isDvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) ReferenceRange(com.nedap.archie.rm.datavalues.quantity.ReferenceRange) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) DvText(com.nedap.archie.rm.datavalues.DvText)

Example 27 with DvText

use of com.nedap.archie.rm.datavalues.DvText 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 28 with DvText

use of com.nedap.archie.rm.datavalues.DvText in project openEHR_SDK by ehrbase.

the class DvTextValidatorTest method testValidate.

@Test
void testValidate() throws Exception {
    var node = parseNode("/webtemplate_nodes/dv_text.json");
    var result = validator.validate(new DvText("Test value"), node);
    assertTrue(result.isEmpty());
}
Also used : DvText(com.nedap.archie.rm.datavalues.DvText) Test(org.junit.jupiter.api.Test)

Example 29 with DvText

use of com.nedap.archie.rm.datavalues.DvText 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)

Example 30 with DvText

use of com.nedap.archie.rm.datavalues.DvText in project openEHR_SDK by ehrbase.

the class DefaultRestCompositionEndpointIT method testSaveCompositionWithDefaultEntity.

@Test
public void testSaveCompositionWithDefaultEntity() throws URISyntaxException {
    openEhrClient = setupDefaultRestClientWithDefaultProvider(o -> {
        DefaultValues defaultValues = new DefaultValues();
        defaultValues.addDefaultValue(DefaultValuePath.END_TIME, OffsetDateTime.of(2019, 05, 03, 22, 00, 00, 00, ZoneOffset.UTC));
        Participation participation = new Participation(new PartyIdentified(null, "Dr. Peter", null), new DvText("Performer"), ParticipationMode.PHYSICALLY_PRESENT.toCodedText(), null);
        defaultValues.addDefaultValue(DefaultValuePath.PARTICIPATION, new ArrayList<>(Collections.singleton(participation)));
        return defaultValues;
    });
    ehr = openEhrClient.ehrEndpoint().createEhr();
    EhrbaseBloodPressureSimpleDeV0Composition bloodPressureSimpleDeV0 = TestData.buildEhrbaseBloodPressureSimpleDeV0WithEmptyFields();
    // Not set during creation
    assertThat(bloodPressureSimpleDeV0.getEndTimeValue()).isNull();
    assertThat(bloodPressureSimpleDeV0.getParticipations()).isEmpty();
    // during saving default values will be set
    bloodPressureSimpleDeV0 = openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(bloodPressureSimpleDeV0);
    assertThat(bloodPressureSimpleDeV0.getEndTimeValue()).isEqualTo(OffsetDateTime.of(2019, 05, 03, 22, 00, 00, 00, ZoneOffset.UTC));
    assertThat(bloodPressureSimpleDeV0.getParticipations()).extracting(p -> ((PartyIdentified) p.getPerformer()).getName(), p -> p.getMode().getValue()).containsExactlyInAnyOrder(new Tuple("Dr. Peter", "physically present"));
}
Also used : Language(org.ehrbase.client.classgenerator.shareddefinition.Language) Composition(com.nedap.archie.rm.composition.Composition) VersionUid(org.ehrbase.client.openehrclient.VersionUid) URISyntaxException(java.net.URISyntaxException) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) GECCOSerologischerBefundComposition(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.GECCOSerologischerBefundComposition) EpisodeofcareTeamElement(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.definition.EpisodeofcareTeamElement) Assertions.assertThatNoException(org.assertj.core.api.Assertions.assertThatNoException) BefundJedesEreignisPointEvent(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.definition.BefundJedesEreignisPointEvent) After(org.junit.After) URI(java.net.URI) ZoneOffset(java.time.ZoneOffset) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) MethodInterceptor(net.sf.cglib.proxy.MethodInterceptor) ProAnalytQuantitativesErgebnisDvCount(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.definition.ProAnalytQuantitativesErgebnisDvCount) org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.definition(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.definition) OpenEhrClient(org.ehrbase.client.openehrclient.OpenEhrClient) UUID(java.util.UUID) Category(org.junit.experimental.categories.Category) StandardCharsets(java.nio.charset.StandardCharsets) AnforderungDefiningCode(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.definition.AnforderungDefiningCode) IOUtils(org.apache.commons.io.IOUtils) EpisodeOfCareComposition(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition) ParticipationMode(org.ehrbase.client.classgenerator.shareddefinition.ParticipationMode) LabortestBezeichnungDefiningCode(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.definition.LabortestBezeichnungDefiningCode) OffsetDateTime(java.time.OffsetDateTime) OptimisticLockException(org.ehrbase.client.exception.OptimisticLockException) Optional(java.util.Optional) TestData(org.ehrbase.client.TestData) DefaultRestClientTestHelper.setupDefaultRestClientWithDefaultProvider(org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestClientTestHelper.setupDefaultRestClientWithDefaultProvider) Territory(org.ehrbase.client.classgenerator.shareddefinition.Territory) BeforeClass(org.junit.BeforeClass) EhrbaseBloodPressureSimpleDeV0Composition(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition) EhrbaseMultiOccurrenceDeV1Composition(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.EhrbaseMultiOccurrenceDeV1Composition) ArrayList(java.util.ArrayList) ProVirusCluster(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.ProVirusCluster) Flattener(org.ehrbase.client.flattener.Flattener) ClientException(org.ehrbase.client.exception.ClientException) Enhancer(net.sf.cglib.proxy.Enhancer) BefundObservation(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.definition.BefundObservation) PartySelf(com.nedap.archie.rm.generic.PartySelf) Integration(org.ehrbase.client.Integration) Tuple(org.assertj.core.groups.Tuple) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionTestDataCanonicalJson(org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson) DvText(com.nedap.archie.rm.datavalues.DvText) EpisodeofcareAdminEntry(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.definition.EpisodeofcareAdminEntry) TestDataTemplateProvider(org.ehrbase.client.templateprovider.TestDataTemplateProvider) DefaultValuePath(org.ehrbase.serialisation.walker.defaultvalues.DefaultValuePath) WrongStatusCodeException(org.ehrbase.client.exception.WrongStatusCodeException) Test(org.junit.Test) IOException(java.io.IOException) Participation(com.nedap.archie.rm.generic.Participation) DefaultValues(org.ehrbase.serialisation.walker.defaultvalues.DefaultValues) KorotkoffSoundsDefiningCode(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.definition.KorotkoffSoundsDefiningCode) VirologischerBefundComposition(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.VirologischerBefundComposition) VirusnachweistestDefiningCode(org.ehrbase.client.classgenerator.examples.geccoserologischerbefundcomposition.definition.VirusnachweistestDefiningCode) CompositionEndpoint(org.ehrbase.client.openehrclient.CompositionEndpoint) Assert(org.junit.Assert) Collections(java.util.Collections) Setting(org.ehrbase.client.classgenerator.shareddefinition.Setting) Participation(com.nedap.archie.rm.generic.Participation) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) ArrayList(java.util.ArrayList) DefaultValues(org.ehrbase.serialisation.walker.defaultvalues.DefaultValues) EhrbaseBloodPressureSimpleDeV0Composition(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition) Tuple(org.assertj.core.groups.Tuple) DvText(com.nedap.archie.rm.datavalues.DvText) Test(org.junit.Test)

Aggregations

DvText (com.nedap.archie.rm.datavalues.DvText)50 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)16 Test (org.junit.Test)14 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)11 PartySelf (com.nedap.archie.rm.generic.PartySelf)11 Composition (com.nedap.archie.rm.composition.Composition)10 PartyRef (com.nedap.archie.rm.support.identification.PartyRef)9 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)9 ArrayList (java.util.ArrayList)9 CanonicalJson (org.ehrbase.serialisation.jsonencoding.CanonicalJson)9 EhrStatus (com.nedap.archie.rm.ehr.EhrStatus)8 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)8 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)8 UUID (java.util.UUID)8 Participation (com.nedap.archie.rm.generic.Participation)6 Optional (java.util.Optional)6 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)6 Folder (com.nedap.archie.rm.directory.Folder)5 PartyProxy (com.nedap.archie.rm.generic.PartyProxy)5 URI (java.net.URI)5