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);
}
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;
}
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());
}
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;
}
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"));
}
Aggregations