Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/flat add test for op 2 #304

Merged
merged 30 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f65875a
add roundTripEhrbaseConformanceDataTypesDvText
stefanspiska Dec 22, 2021
9c2589e
fix junit dependency
stefanspiska Dec 23, 2021
6bcf3fd
fix test
stefanspiska Dec 23, 2021
bed7729
add test for dv_coded_text
stefanspiska Dec 23, 2021
87377a4
add test for dv_quantity
stefanspiska Jan 10, 2022
8ed2be0
Merge branch 'develop' into feature/flat_add_test_for_op
stefanspiska Jan 10, 2022
db473a6
add test for dv_quantity.range
stefanspiska Jan 11, 2022
c0aa1ad
fix test
stefanspiska Jan 11, 2022
0e5d08d
update conformance template
stefanspiska Jan 11, 2022
010aec8
Merge branch 'develop' into feature/flat_add_test_for_op
stefanspiska Jan 12, 2022
14a8440
add test for interval of dv_quantity
stefanspiska Jan 12, 2022
33e1349
add test for DvProportion
stefanspiska Jan 12, 2022
727e044
add test for DV_Count
stefanspiska Jan 12, 2022
ea2cfd7
add test for DV_DATE_TIME , DV_TIME and DV_DATE
stefanspiska Jan 12, 2022
bbbd32f
add test for DvDuration
stefanspiska Jan 13, 2022
dba1a58
fix test
stefanspiska Jan 13, 2022
22363bf
fix test
stefanspiska Jan 14, 2022
5bfa6e1
Merge branch 'develop' into feature/flat_add_test_for_op
stefanspiska Jan 14, 2022
09715e8
add test for DV_ORDINAL
stefanspiska Jan 14, 2022
2f6416b
add test for DvBoolean
stefanspiska Jan 17, 2022
61c8bf1
add test for DV_IDENTIFIER
stefanspiska Jan 17, 2022
02170cc
add test for Dv_uri & dv_ehr_uri
stefanspiska Jan 17, 2022
e52da82
add test for DvMultimedia & DvParsable
stefanspiska Jan 18, 2022
75ea00f
Merge branch 'develop' into feature/flat_add_test_for_op
stefanspiska Jan 19, 2022
b2bb042
fix test
stefanspiska Jan 19, 2022
d87ed94
fix review
stefanspiska Jan 20, 2022
8f6dca4
add test for Element
stefanspiska Jan 21, 2022
21b2e14
add test for Cluster
stefanspiska Jan 21, 2022
9f9cd75
add test for Event
stefanspiska Jan 21, 2022
0123f67
Merge branch 'develop' into feature/flat_add_test_for_op_2
stefanspiska Jan 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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