use of com.nedap.archie.rm.generic.PartyIdentified in project openEHR_SDK by ehrbase.
the class UnflattenerTest method testUnflattenEhrbaseBloodPressureSimpleDeV0.
@Test
public void testUnflattenEhrbaseBloodPressureSimpleDeV0() {
Unflattener cut = new Unflattener(new TestDataTemplateProvider());
EhrbaseBloodPressureSimpleDeV0Composition dto = buildEhrbaseBloodPressureSimpleDeV0();
Composition rmObject = (Composition) cut.unflatten(dto);
assertThat(rmObject).isNotNull();
assertThat(rmObject.getContext().getParticipations()).extracting(p -> ((PartyIdentified) p.getPerformer()).getName(), p -> p.getFunction().getValue()).containsExactlyInAnyOrder(new Tuple("Test", "Pos1"), new Tuple("Test2", "Pos2"));
assertThat(rmObject.getLanguage()).extracting(CodePhrase::getCodeString, c -> c.getTerminologyId().getValue()).containsExactly("de", "ISO_639-1");
assertThat(rmObject.getArchetypeDetails().getTemplateId().getValue()).isEqualTo("ehrbase_blood_pressure_simple.de.v0");
assertThat(rmObject.itemAtPath("/context/start_time/value")).isEqualTo(dto.getStartTimeValue());
List<Object> observationList = rmObject.itemsAtPath("/content[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]");
assertThat(observationList).size().isEqualTo(1);
Observation observation = (Observation) observationList.get(0);
DvCodedText expected = new DvCodedText("Fifth sound", new CodePhrase(new TerminologyId("local"), "at1012"));
assertThat(observation.itemAtPath("/protocol[at0011]/items[at1010]/value")).isEqualTo(expected);
assertThat(observation.getSubject()).isNotNull().extracting(Object::getClass).isEqualTo(PartySelf.class);
}
use of com.nedap.archie.rm.generic.PartyIdentified in project openEHR_SDK by ehrbase.
the class EntryMarshalPostprocessor method process.
/**
* {@inheritDoc} Adds the encoding information
*/
@Override
public void process(String term, Entry rmObject, Map<String, Object> values, Context<Map<String, Object>> context) {
values.put(term + PATH_DIVIDER + "encoding|code", "UTF-8");
values.put(term + PATH_DIVIDER + "encoding|terminology", "IANA_character-sets");
if (rmObject.getProvider() != null) {
PartyIdentifiedStdConfig partyIdentifiedStdConfig = new PartyIdentifiedStdConfig();
values.putAll(partyIdentifiedStdConfig.buildChildValues(term + PATH_DIVIDER + "_provider", (PartyIdentified) rmObject.getProvider(), null));
}
if (rmObject.getOtherParticipations() != null) {
IntStream.range(0, rmObject.getOtherParticipations().size()).forEach(i -> {
callMarshal(term, "_other_participation:" + i, rmObject.getOtherParticipations().get(i), values, context, context.getNodeDeque().peek().findChildById("participation").orElse(null));
callPostprocess(term, "_other_participation:" + i, rmObject.getOtherParticipations().get(i), values, context, context.getNodeDeque().peek().findChildById("participation").orElse(null));
});
}
if (rmObject.getWorkflowId() != null) {
addValue(values, term + "/_work_flow_id", "id", Optional.of(rmObject.getWorkflowId()).map(ObjectRef::getId).map(ObjectId::getValue).orElse(null));
addValue(values, term + "/_work_flow_id", "id_scheme", Optional.of(rmObject.getWorkflowId()).map(ObjectRef::getId).filter(i -> GenericId.class.isAssignableFrom(i.getClass())).map(GenericId.class::cast).map(GenericId::getScheme).orElse(null));
addValue(values, term + "/_work_flow_id", "namespace", rmObject.getWorkflowId().getNamespace());
addValue(values, term + "/_work_flow_id", "type", rmObject.getWorkflowId().getType());
}
}
use of com.nedap.archie.rm.generic.PartyIdentified in project openEHR_SDK by ehrbase.
the class DefaultValuesTest method unmarshal.
@Test
public void unmarshal() throws IOException, XmlException {
OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse(OperationalTemplateTestData.CORONA_ANAMNESE.getStream()).getTemplate();
WebTemplate webTemplate = new OPTParser(template).parse();
FlatJsonUnmarshaller cut = new FlatJsonUnmarshaller();
String flat = IOUtils.toString(CompositionTestDataSimSDTJson.CORONA_WITH_CONTEXT.getStream(), StandardCharsets.UTF_8);
Composition actual = cut.unmarshal(flat, webTemplate);
assertThat(actual).isNotNull();
assertThat(actual.getCategory()).isNotNull();
assertThat(actual.getCategory().getValue()).isEqualTo("event");
assertThat(actual.getLanguage()).isNotNull();
assertThat(actual.getLanguage().getCodeString()).isEqualTo(Language.DE.getCode());
assertThat(actual.getComposer()).isNotNull();
assertThat(actual.getComposer()).getClass().isAssignableFrom(PartyIdentified.class);
assertThat(((PartyIdentified) actual.getComposer()).getName()).isEqualTo("Silvia Blake");
assertThat(actual.getComposer().getExternalRef().getNamespace()).isEqualTo("HOSPITAL-NS");
assertThat(((GenericId) actual.getComposer().getExternalRef().getId()).getScheme()).isEqualTo("HOSPITAL-NS");
assertThat(((GenericId) actual.getComposer().getExternalRef().getId()).getValue()).isEqualTo("123");
assertThat(actual.getContext().getHealthCareFacility().getName()).isEqualTo("Hospital");
assertThat(actual.getContext().getStartTime()).isNotNull();
assertThat(actual.getContext().getStartTime().getValue()).isEqualTo(OffsetDateTime.of(2021, 4, 1, 12, 40, 31, 418954000, ZoneOffset.ofHours(2)));
assertThat(actual.getContext().getParticipations()).extracting(p -> ((PartyIdentified) p.getPerformer())).flatExtracting(p -> p.getIdentifiers()).extracting(DvIdentifier::getAssigner, DvIdentifier::getId, DvIdentifier::getIssuer, DvIdentifier::getType).containsExactlyInAnyOrder(new Tuple("assigner1", "id1", "issuer1", "PERSON"), new Tuple("assigner2", "id2", "issuer2", "PERSON"), new Tuple("assigner3", "id3", "issuer3", "PERSON"), new Tuple("assigner4", "id4", "issuer4", "PERSON"));
Observation observation = actual.getContent().stream().filter(c -> Observation.class.isAssignableFrom(c.getClass())).map(Observation.class::cast).findAny().orElse(null);
assertThat(observation).isNotNull();
assertThat(observation.getData()).isNotNull();
assertThat(observation.getData().getOrigin().getValue()).isEqualTo(OffsetDateTime.of(2021, 4, 1, 12, 40, 31, 418954000, ZoneOffset.ofHours(2)));
assertThat(observation.getData().getEvents().get(0).getTime().getValue()).isEqualTo(OffsetDateTime.of(2021, 4, 1, 12, 40, 31, 418954000, ZoneOffset.ofHours(2)));
assertThat(observation.getOtherParticipations()).extracting(p -> p.getFunction().getValue(), p -> ((PartyIdentified) p.getPerformer()).getName(), p -> p.getPerformer().getExternalRef().getNamespace()).containsExactlyInAnyOrder(new Tuple("requester", "Dr. Marcus Johnson", "HOSPITAL-NS"), new Tuple("performer", "Lara Markham", "HOSPITAL-NS"));
assertThat(observation.getOtherParticipations()).extracting(p -> ((PartyIdentified) p.getPerformer())).flatExtracting(p -> p.getIdentifiers()).extracting(DvIdentifier::getAssigner, DvIdentifier::getId, DvIdentifier::getIssuer, DvIdentifier::getType).containsExactlyInAnyOrder(new Tuple("assigner1", "id1", "issuer1", "PERSON"), new Tuple("assigner2", "id2", "issuer2", "PERSON"), new Tuple("assigner3", "id3", "issuer3", "PERSON"), new Tuple("assigner4", "id4", "issuer4", "PERSON"));
assertThat(observation.getWorkflowId()).isNotNull();
assertThat(observation.getWorkflowId().getNamespace()).isEqualTo("HOSPITAL-NS");
assertThat(observation.getWorkflowId().getId().getValue()).isEqualTo("567");
assertThat(observation.getWorkflowId().getType()).isEqualTo("ORGANISATION");
}
use of com.nedap.archie.rm.generic.PartyIdentified in project openEHR_SDK by ehrbase.
the class DefaultValuesTest method test.
@Test
public void test() throws IOException {
Map<String, String> currentValues = new HashMap<>();
for (Iterator<Map.Entry<String, JsonNode>> it = JacksonUtil.getObjectMapper().readTree(IOUtils.toString(CompositionTestDataSimSDTJson.CORONA_WITH_CONTEXT.getStream(), StandardCharsets.UTF_8)).fields(); it.hasNext(); ) {
Map.Entry<String, JsonNode> e = it.next();
currentValues.put(e.getKey(), e.getValue().toString());
}
DefaultValues cut = new DefaultValues(currentValues);
assertThat(cut).isNotNull();
assertThat(cut.getDefaultValue(DefaultValuePath.LANGUAGE)).isEqualTo(Language.DE);
assertThat(cut.getDefaultValue(DefaultValuePath.COMPOSER_NAME)).isEqualTo("Silvia Blake");
assertThat(cut.getDefaultValue(DefaultValuePath.TIME)).isEqualTo(OffsetDateTime.of(2021, 4, 1, 12, 40, 31, 418954000, ZoneOffset.ofHours(2)));
assertThat(cut.getDefaultValue(DefaultValuePath.HEALTHCARE_FACILITY_NAME)).isEqualTo("Hospital");
assertThat(cut.getDefaultValue(DefaultValuePath.PARTICIPATION)).isNotNull();
assertThat(cut.getDefaultValue(DefaultValuePath.PARTICIPATION)).extracting(p -> p.getFunction().getValue(), p -> ((PartyIdentified) p.getPerformer()).getName(), p -> p.getPerformer().getExternalRef().getNamespace()).containsExactlyInAnyOrder(new Tuple("requester", "Dr. Marcus Johnson", "HOSPITAL-NS"), new Tuple("performer", "Lara Markham", "HOSPITAL-NS"));
assertThat(cut.getDefaultValue(DefaultValuePath.PARTICIPATION)).extracting(p -> ((PartyIdentified) p.getPerformer())).flatExtracting(p -> p.getIdentifiers()).extracting(DvIdentifier::getAssigner, DvIdentifier::getId, DvIdentifier::getIssuer, DvIdentifier::getType).containsExactlyInAnyOrder(new Tuple("assigner1", "id1", "issuer1", "PERSON"), new Tuple("assigner2", "id2", "issuer2", "PERSON"), new Tuple("assigner3", "id3", "issuer3", "PERSON"), new Tuple("assigner4", "id4", "issuer4", "PERSON"));
assertThat(cut.getDefaultValue(DefaultValuePath.WORKFLOW_ID)).isNotNull();
assertThat(cut.getDefaultValue(DefaultValuePath.WORKFLOW_ID).getNamespace()).isEqualTo("HOSPITAL-NS");
assertThat(cut.getDefaultValue(DefaultValuePath.WORKFLOW_ID).getId().getValue()).isEqualTo("567");
assertThat(cut.getDefaultValue(DefaultValuePath.WORKFLOW_ID).getType()).isEqualTo("ORGANISATION");
}
use of com.nedap.archie.rm.generic.PartyIdentified in project openEHR_SDK by ehrbase.
the class TestData method buildTestVirologischerBefundComposition.
public static VirologischerBefundComposition buildTestVirologischerBefundComposition() {
// openEHR-EHR-COMPOSITION.report-result.v1
VirologischerBefundComposition virologischerBefundComposition = new VirologischerBefundComposition();
virologischerBefundComposition.setComposer(new PartyIdentified(null, "Test", null));
virologischerBefundComposition.setCategoryDefiningCode(Category.EVENT);
virologischerBefundComposition.setLanguage(Language.DE);
virologischerBefundComposition.setTerritory(Territory.DE);
virologischerBefundComposition.setStartTimeValue(OffsetDateTime.now());
virologischerBefundComposition.setSettingDefiningCode(Setting.SECONDARY_MEDICAL_CARE);
// context, other_context
FallidentifikationCluster fallidentifikationCluster = new FallidentifikationCluster();
fallidentifikationCluster.setFallKennungValue("9251377");
virologischerBefundComposition.setFallidentifikation(fallidentifikationCluster);
virologischerBefundComposition.setBerichtIdValue("15a69a62-1ea7-4111-98a5-28aeae854bcd");
virologischerBefundComposition.setStatusValue("Endbefund");
// openEHR-EHR-CLUSTER.specimen.v1
ProbeCluster probeCluster = new ProbeCluster();
probeCluster.setZeitpunktDerProbenentnahmeValue(new DvDateTime("2020-04-01T12:00:00Z").getValue());
probeCluster.setProbenartValue("Blut");
probeCluster.setZeitpunktDesProbeneingangsValue(new DvDateTime("2020-04-02T09:00:00Z").getValue());
probeCluster.setKommentarDesProbennehmersValue("Kommentar zur Probe");
probeCluster.setKommentarValue("Kommentar");
// openEHR-EHR-CLUSTER.laboratory_test_analyte.v1
ProVirusCluster proVirusCluster1 = new ProVirusCluster();
proVirusCluster1.setVirusValue("SARS-Cov-2");
proVirusCluster1.setAnalyseergebnisReihenfolgeMagnitude(Long.valueOf(32));
DvIdentifier identifier = new DvIdentifier();
identifier.setIssuer("Issuer");
identifier.setAssigner("Assigner");
identifier.setId("9a0e5173-07c8-443d-b414-24432b9d95ca");
identifier.setType("Prescription");
proVirusCluster1.setZugehorigeLaborprobe(identifier);
ProVirusCluster proVirusCluster2 = new ProVirusCluster();
proVirusCluster2.setVirusValue("SARS-Cov-2");
proVirusCluster2.setAnalyseergebnisReihenfolgeMagnitude(Long.valueOf(34));
proVirusCluster2.setZugehorigeLaborprobe(identifier);
// openEHR-EHR-CLUSTER.laboratory_test_panel.v0
KulturCluster kulturCluster = new KulturCluster();
kulturCluster.setProVirus(new ArrayList<>());
kulturCluster.getProVirus().add(proVirusCluster1);
kulturCluster.getProVirus().add(proVirusCluster2);
// openEHR-EHR-OBSERVATION.laboratory_test_result.v1
BefundObservation befundObservation = new BefundObservation();
// set clusters in observation
befundObservation.setKultur(new ArrayList<>());
befundObservation.getKultur().add(kulturCluster);
befundObservation.setProbe(new ArrayList<>());
befundObservation.getProbe().add(probeCluster);
befundObservation.setOriginValue(new DvDateTime("2020-04-02T12:00:00Z").getValue());
befundObservation.setTimeValue(new DvDateTime("2020-04-02T14:00:00Z").getValue());
befundObservation.setLabortestBezeichnungValue("Virologische Untersuchung");
befundObservation.setSubject(new PartySelf());
befundObservation.setLanguage(Language.DE);
virologischerBefundComposition.setBefund(befundObservation);
return virologischerBefundComposition;
}
Aggregations