Skip to content

Commit

Permalink
Feature/flat add test for op 2 (#304)
Browse files Browse the repository at this point in the history
* add roundTripEhrbaseConformanceDataTypesDvText

see CDR-27

* fix junit dependency

* fix test

see CDR-27

* add  test for dv_coded_text

see CDR-27

* add  test for dv_quantity

see CDR-27

* add test for dv_quantity.range

see CDR-27

* fix test

see CDR-27

* update conformance template
see CDR-27

* add test for interval of dv_quantity

see CDR-27

* add test for DvProportion

see CDR-27

* add test for DV_Count

see CDR-27

* add test for DV_DATE_TIME , DV_TIME and DV_DATE

see CDR-27

* add test for DvDuration

see CDR-27

* fix test

see CDR-27

* fix test

see CDR-27

* add test for DV_ORDINAL

see CDR-27

* add test for DvBoolean

see CDR-27

* add test for DV_IDENTIFIER

see CDR-27

* add test for Dv_uri & dv_ehr_uri

see CDR-27

* add test for DvMultimedia & DvParsable

see CDR-27

* fix test

see CDR-27

* fix review

see CDR-27

* add test for Element

see CDR-27

* add test for Cluster

see CDR-27

* add test for Event

see CDR-27
  • Loading branch information
stefanspiska authored Jan 24, 2022
1 parent 4f1489b commit c7daee2
Show file tree
Hide file tree
Showing 14 changed files with 595 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
import java.util.Map;
import java.util.Optional;

import static org.ehrbase.serialisation.flatencoding.std.marshal.StdFromCompositionWalker.findStdConfig;

public class FeederAudiDetailsStdConfig extends AbstractsStdConfig<FeederAuditDetails> {

private static final PartyIdentifiedStdConfig PARTY_IDENTIFIED_STD_CONFIG =
new PartyIdentifiedStdConfig();

@Override
/** {@inheritDoc} */
Expand All @@ -47,15 +47,24 @@ public Map<String, Object> buildChildValues(
addValue(result, currentTerm, "version_id", rmObject.getVersionId());

if (rmObject.getLocation() != null) {
StdConfig stdConfig = findStdConfig(rmObject.getLocation().getClass());
result.putAll(
PARTY_IDENTIFIED_STD_CONFIG.buildChildValues(
stdConfig.buildChildValues(
currentTerm + "/location", rmObject.getLocation(), context));
}
if (rmObject.getProvider() != null) {
StdConfig stdConfig = findStdConfig(rmObject.getProvider().getClass());
result.putAll(
PARTY_IDENTIFIED_STD_CONFIG.buildChildValues(
stdConfig.buildChildValues(
currentTerm + "/provider", rmObject.getProvider(), context));
}

if (rmObject.getSubject() != null) {
StdConfig stdConfig = findStdConfig(rmObject.getSubject().getClass());
result.putAll(
stdConfig.buildChildValues(
currentTerm + "/subject", rmObject.getSubject(), context));
}
return result;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
*
* * Copyright (c) 2020 Stefan Spiska (Vitasystems GmbH) and Hannover Medical School
* * This file is part of Project EHRbase
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/

package org.ehrbase.serialisation.flatencoding.std.marshal.postprocessor;

import com.nedap.archie.rm.datastructures.IntervalEvent;
import org.ehrbase.serialisation.walker.Context;

import java.util.Map;

public class IntervalEventMarshalPostprocessor extends AbstractMarshalPostprocessor<IntervalEvent> {

/** {@inheritDoc} Adds the encoding information */
@Override
public void process(
String term,
IntervalEvent rmObject,
Map<String, Object> values,
Context<Map<String, Object>> context) {

if (rmObject.getSampleCount() != null) {

addValue(values,term,"sample_count",rmObject.getSampleCount());
}
}

/** {@inheritDoc} */
@Override
public Class<IntervalEvent> getAssociatedClass() {
return IntervalEvent.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.nedap.archie.rm.datavalues.DvText;
import com.nedap.archie.rm.support.identification.ObjectId;
import org.ehrbase.serialisation.walker.Context;
import org.ehrbase.serialisation.walker.FlatHelper;

import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -75,7 +76,7 @@ public void process(
}

if (rmObject.getFeederAudit() != null) {
handleRmAttribute(term, rmObject.getFeederAudit(), values, context, "feeder_audit");
callMarshal (term,"_feeder_audit", rmObject.getFeederAudit(), values, context, context.getNodeDeque().peek().findChildById("feeder_audit").orElse(FlatHelper.buildDummyChild("feeder_audit",context.getNodeDeque().peek())));
}

if (Optional.ofNullable(rmObject.getName())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
*
* * Copyright (c) 2020 Stefan Spiska (Vitasystems GmbH) and Hannover Medical School
* * This file is part of Project EHRbase
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/

package org.ehrbase.serialisation.flatencoding.std.umarshal.postprocessor;

import com.nedap.archie.rm.archetyped.FeederAuditDetails;
import com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime;
import com.nedap.archie.rm.generic.PartyIdentified;
import org.ehrbase.serialisation.walker.Context;
import org.ehrbase.serialisation.walker.FlatHelper;
import org.ehrbase.webtemplate.path.flat.FlatPathDto;

import java.util.Map;
import java.util.Set;

public class FeederAuditDetailsPostprocessor extends AbstractUnmarshalPostprocessor<FeederAuditDetails> {

/** {@inheritDoc} */
@Override
public void process(
String term,
FeederAuditDetails rmObject,
Map<FlatPathDto, String> values,
Set<String> consumedPaths,
Context<Map<FlatPathDto, String>> context) {

Map<FlatPathDto, String> locationValues = FlatHelper.filter(values, term + "/_location", false);
if(!locationValues.isEmpty() ){
rmObject.setLocation(new PartyIdentified());
handleRmAttribute(term,rmObject.getLocation(),locationValues,consumedPaths,context,"location" );

}

Map<FlatPathDto, String> subjectValues = FlatHelper.filter(values, term + "/_subject", false);
if(!subjectValues.isEmpty() ){
rmObject.setSubject(new PartyIdentified());
handleRmAttribute(term,rmObject.getSubject(),subjectValues,consumedPaths,context,"subject" );

}

Map<FlatPathDto, String> providerValues = FlatHelper.filter(values, term + "/_provider", false);
if(!providerValues.isEmpty() ){
rmObject.setProvider(new PartyIdentified());
handleRmAttribute(term,rmObject.getProvider(),providerValues,consumedPaths,context,"provider" );

}

Map<FlatPathDto, String> timeValues = FlatHelper.filter(values, term + "/_time", false);
if(!timeValues.isEmpty() ){
rmObject.setTime(new DvDateTime( ));
handleRmAttribute(term,rmObject.getTime(),timeValues,consumedPaths,context,"time" );

}

}

/** {@inheritDoc} */
@Override
public Class<FeederAuditDetails> getAssociatedClass() {
return FeederAuditDetails.class;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
*
* * Copyright (c) 2020 Stefan Spiska (Vitasystems GmbH) and Hannover Medical School
* * This file is part of Project EHRbase
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/

package org.ehrbase.serialisation.flatencoding.std.umarshal.postprocessor;

import com.nedap.archie.rm.archetyped.FeederAudit;
import org.ehrbase.serialisation.walker.Context;
import org.ehrbase.serialisation.walker.FlatHelper;
import org.ehrbase.webtemplate.path.flat.FlatPathDto;

import java.util.Map;
import java.util.Set;

public class FeederAuditPostprocessor extends AbstractUnmarshalPostprocessor<FeederAudit> {

/** {@inheritDoc} */
@Override
public void process(
String term,
FeederAudit rmObject,
Map<FlatPathDto, String> values,
Set<String> consumedPaths,
Context<Map<FlatPathDto, String>> context) {

Map<FlatPathDto, String> locationValues = FlatHelper.filter(values, term + "/originating_system_audit", false);
if(!locationValues.isEmpty() && rmObject.getOriginatingSystemAudit() != null){

callPostProcess(term,"originating_system_audit",rmObject.getOriginatingSystemAudit(),locationValues,consumedPaths,context,null );

}


}

/** {@inheritDoc} */
@Override
public Class<FeederAudit> getAssociatedClass() {
return FeederAudit.class;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
*
* * Copyright (c) 2020 Stefan Spiska (Vitasystems GmbH) and Hannover Medical School
* * This file is part of Project EHRbase
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/

package org.ehrbase.serialisation.flatencoding.std.umarshal.postprocessor;

import com.nedap.archie.rm.datastructures.IntervalEvent;
import org.ehrbase.serialisation.walker.Context;
import org.ehrbase.webtemplate.path.flat.FlatPathDto;

import java.util.Map;
import java.util.Set;

public class IntervalEventPostprocessor extends AbstractUnmarshalPostprocessor<IntervalEvent> {

/** {@inheritDoc} */
@Override
public void process(
String term,
IntervalEvent rmObject,
Map<FlatPathDto, String> values,
Set<String> consumedPaths,
Context<Map<FlatPathDto, String>> context) {

setValue(term, "sample_count", values, rmObject::setSampleCount, Long.class, consumedPaths);
}

/** {@inheritDoc} */
@Override
public Class<IntervalEvent> getAssociatedClass() {
return IntervalEvent.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import java.util.Map;
import java.util.Set;

import static org.ehrbase.serialisation.flatencoding.std.umarshal.StdToCompositionWalker.findRMUnmarshaller;

public class FeederAuditDetailsRMUnmarshaller extends AbstractRMUnmarshaller<FeederAuditDetails> {

private static final PartyIdentifiedRMUnmarshaller PARTY_IDENTIFIED_RM_UNMARSHALLER =
Expand Down Expand Up @@ -66,16 +68,29 @@ public void handle(

if (!locationValues.isEmpty()) {
rmObject.setLocation(new PartyIdentified());
PARTY_IDENTIFIED_RM_UNMARSHALLER.handle(
RMUnmarshaller rmUnmarshaller = findRMUnmarshaller(rmObject.getLocation().getClass());
rmUnmarshaller.handle(
currentTerm + "/location", rmObject.getLocation(), locationValues, null, consumedPaths);
}

Map<FlatPathDto, String> subjectValues =
FlatHelper.filter(currentValues, currentTerm + "/subject", false);

if (!subjectValues.isEmpty()) {
rmObject.setSubject(new PartyIdentified());
RMUnmarshaller rmUnmarshaller = findRMUnmarshaller(rmObject.getSubject().getClass());
rmUnmarshaller.handle(
currentTerm + "/subject", rmObject.getSubject(), subjectValues, null, consumedPaths);
}


Map<FlatPathDto, String> providerValues =
FlatHelper.filter(currentValues, currentTerm + "/provider", false);

if (!providerValues.isEmpty()) {
rmObject.setProvider(new PartyIdentified());
PARTY_IDENTIFIED_RM_UNMARSHALLER.handle(
RMUnmarshaller rmUnmarshaller = findRMUnmarshaller(rmObject.getProvider().getClass());
rmUnmarshaller.handle(
currentTerm + "/provider", rmObject.getProvider(), providerValues, null, consumedPaths);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,52 @@ public void roundTripEhrbaseConformanceDataTypesDvMultimedia() throws IOExceptio
check(testData, new String[] {}, new String[] {}, new String[]{});
}


@Test
public void roundTripEhrbaseConformanceElementNullFlavor() throws IOException {

CompositionTestDataSimSDTJson testData =
CompositionTestDataSimSDTJson.EHRBASE_CONFORMANCE_ELEMENT_NULL_FLAVOR;

check(testData, new String[] {}, new String[] {}, new String[]{});
}

@Test
public void roundTripEhrbaseConformanceElementFeederAudit() throws IOException {

CompositionTestDataSimSDTJson testData =
CompositionTestDataSimSDTJson.EHRBASE_CONFORMANCE_ELEMENT_FEEDER_AUDIT;

check(testData, new String[] {}, new String[] {}, new String[]{});
}

@Test
public void roundTripEhrbaseConformanceCluster() throws IOException {

CompositionTestDataSimSDTJson testData =
CompositionTestDataSimSDTJson.EHRBASE_CONFORMANCE_CLUSTER;

check(testData, new String[] {}, new String[] {}, new String[]{});
}

@Test
public void roundTripEhrbaseConformancePointEvent() throws IOException {

CompositionTestDataSimSDTJson testData =
CompositionTestDataSimSDTJson.EHRBASE_CONFORMANCE_POINT_EVENT;

check(testData, new String[] {}, new String[] {}, new String[]{});
}

@Test
public void roundTripEhrbaseConformanceIntervalEvent() throws IOException {

CompositionTestDataSimSDTJson testData =
CompositionTestDataSimSDTJson.EHRBASE_CONFORMANCE_INTERVAL_EVENT;

check(testData, new String[] {}, new String[] {}, new String[]{});
}

@Test
public void roundTripEhrbaseConformanceDataTypesIntervalDvDuration() throws IOException {

Expand Down
Loading

0 comments on commit c7daee2

Please sign in to comment.