Skip to content

Commit

Permalink
feat(fhir): finalize OperationConvertor_40_50
Browse files Browse the repository at this point in the history
Remove all TODOs, resolve remaining issues, reorganize code and tidy up.
Rename OperationConvertor_4b_50 to OperationConvertor_43_50
  • Loading branch information
cmark committed Oct 9, 2024
1 parent 899b3f7 commit c04f9b4
Show file tree
Hide file tree
Showing 13 changed files with 482 additions and 439 deletions.
742 changes: 405 additions & 337 deletions src/main/java/com/b2international/fhir/conv/OperationConvertor_40_50.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
/*
* Copyright 2024 B2i Healthcare, https://b2ihealthcare.com
*
* 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 com.b2international.fhir.conv;

import java.util.List;

import org.hl7.fhir.convertors.factory.VersionConvertorFactory_43_50;

public class OperationConvertor_4b_50 {
/**
* @since 0.1
*/
public class OperationConvertor_43_50 {

// R5 to R4b
//CodeSystem lookup /
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
*/
package com.b2international.fhir.r4.operations;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import org.hl7.fhir.r4.model.*;
Expand Down Expand Up @@ -167,21 +165,18 @@ public CodeSystemLookupResultParameters setProperty(List<Property> properties) {
return this;
}

public static class Designation {

private List<Parameters.ParametersParameterComponent> part;
public static class Designation extends BasePart {

public Designation() {
this(new ArrayList<>());
super();
}

public Designation(List<Parameters.ParametersParameterComponent> part) {
this.part = part == null ? new ArrayList<>(1) : part;
super(part);
}

public CodeType getLanguage() {
StringType type = (StringType) getParameter("language").map(Parameters.ParametersParameterComponent::getValue).orElse(null);
return new CodeType(type.getValueAsString());
return (CodeType) getParameter("language").map(Parameters.ParametersParameterComponent::getValue).orElse(null);
}

public Coding getUse() {
Expand All @@ -197,54 +192,34 @@ public Designation setLanguage(String language) {
}

public Designation setLanguage(CodeType language) {
if (language == null) {
return this;
}
return addParameter(new Parameters.ParametersParameterComponent()
.setName("language")
.setValue(language));
addParameter("language", language);
return this;
}

public Designation setUse(Coding use) {
if (use == null) {
return this;
}
return addParameter(new Parameters.ParametersParameterComponent()
.setName("use")
.setValue(use));
addParameter("use", use);
return this;
}

public Designation setValue(String value) {
if (value == null) {
return this;
}
return addParameter(new Parameters.ParametersParameterComponent()
.setName("value")
.setValue(new StringType(value)));
return setValue(new StringType(value));
}

public Designation addParameter(Parameters.ParametersParameterComponent parameter) {
part.add(parameter);
public Designation setValue(StringType value) {
addParameter("value", value);
return this;
}

private Optional<Parameters.ParametersParameterComponent> getParameter(String name) {
return part.stream()
.filter(param -> param.getName().equals(name))
.findFirst();
}
}

public static class Property {

private List<Parameters.ParametersParameterComponent> part;
public static class Property extends BasePart {

public Property() {
this(new ArrayList<>());
super();
}

public Property(List<Parameters.ParametersParameterComponent> part) {
this.part = part == null ? new ArrayList<>(1) : part;
super(part);
}

public CodeType getCode() {
Expand All @@ -258,76 +233,47 @@ public Type getValue() {
public StringType getDescription() {
return (StringType) getParameter("description").map(Parameters.ParametersParameterComponent::getValue).orElse(null);
}

public List<Parameters.ParametersParameterComponent> getPart() {
return part;
}

private Optional<Parameters.ParametersParameterComponent> getParameter(String name) {
return part.stream()
.filter(param -> param.getName().equals(name))
.findFirst();
}


public List<Property> getSubProperty() {
return part.stream()
.filter(param -> param.getName().equals("subproperty"))
.map(propertyParameter -> {
List<ParametersParameterComponent> part = propertyParameter.getPart();
return new Property(part);
})
.collect(Collectors.toList());
return getParameters("subproperty")
.map(propertyParameter -> new Property(propertyParameter.getPart()))
.toList();
}

public Property setCode(String code) {
return setCode(new CodeType(code));
}

public Property setCode(CodeType code) {
if (code == null) {
return this;
}
return addParameter(new Parameters.ParametersParameterComponent()
.setName("code")
.setValue(code));
addParameter("code", code);
return this;
}

public Property setValue(Type value) {
if (value == null) {
return this;
}
return addParameter(new Parameters.ParametersParameterComponent()
.setName("value")
.setValue(value));
addParameter("value", value);
return this;
}

public Property setDescription(String description) {
return setDescription(new StringType(description));
}

public Property setDescription(StringType description) {
if (description == null) {
return this;
}
return addParameter(new Parameters.ParametersParameterComponent()
.setName("description")
.setValue(description));
addParameter("description", description);
return this;
}

public Property setSubProperty(List<Property> subproperties) {
if (subproperties == null) {
return this;
}

subproperties.stream()
.map(subproperty -> new Parameters.ParametersParameterComponent().setName("subproperty").setPart(subproperty.getPart()))
.forEach(getPart()::add);
.forEach(this::addParameter);

return this;
}

public Property addParameter(Parameters.ParametersParameterComponent parameter) {
part.add(parameter);
return this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public List<Match> getMatch() {
}

public ConceptMapTranslateResultParameters setResult(Boolean isResult) {
return isResult == null ? this : setResult(new BooleanType(isResult));
return setResult(new BooleanType(isResult));
}

public ConceptMapTranslateResultParameters setResult(BooleanType result) {
Expand Down Expand Up @@ -77,7 +77,7 @@ public ConceptMapTranslateResultParameters setMatch(List<Match> matches) {
public static final class Match extends BasePart {

public Match() {
super(null);
super();
}

public Match(List<Parameters.ParametersParameterComponent> part) {
Expand Down Expand Up @@ -121,7 +121,7 @@ public Match setProduct(List<Product> product) {

product.stream()
.map(prod -> new Parameters.ParametersParameterComponent().setName("product").setPart(prod.getPart()))
.forEach(getPart()::add);
.forEach(this::addParameter);

return this;
}
Expand All @@ -138,7 +138,7 @@ public Match setSource(UriType source) {
public static final class Product extends BasePart {

public Product() {
super(null);
super();
}

public Product(List<Parameters.ParametersParameterComponent> part) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.hl7.fhir.r5.model.*;

/**
* @since 9.2
* @since 0.1
*/
public class CodeSystemSubsumptionParameters extends BaseParameters {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.hl7.fhir.r5.model.Parameters;

/**
* @since 9.2
* @since 0.1
*/
public class CodeSystemSubsumptionResultParameters extends BaseParameters {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.hl7.fhir.r5.model.*;

/**
* @since 9.3
* @since 0.1
*/
public class CodeSystemValidateCodeParameters extends BaseParameters {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.hl7.fhir.r5.model.*;

/**
* @since 9.3
* @since 0.1
*/
public class CodeSystemValidateCodeResultParameters extends BaseParameters {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
*/
package com.b2international.fhir.r5.operations;



import java.util.List;

import org.hl7.fhir.r5.model.*;

/**
* @since 9.3
* @since 0.1
*/
public class ConceptMapTranslateParameters extends BaseParameters {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
import java.util.List;

import org.hl7.fhir.r5.model.*;
import org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship;

/**
* @since 9.3
* @since 0.1
*/
public class ConceptMapTranslateResultParameters extends BaseParameters {

Expand All @@ -45,8 +46,12 @@ public List<Match> getMatch() {
return getParameters("match").stream().map(param -> new Match(param.getPart())).toList();
}

public ConceptMapTranslateResultParameters setResult(boolean result) {
addParameter("result", new BooleanType(result));
public ConceptMapTranslateResultParameters setResult(Boolean result) {
return setResult(new BooleanType(result));
}

public ConceptMapTranslateResultParameters setResult(BooleanType result) {
addParameter("result", result);
return this;
}

Expand Down Expand Up @@ -104,12 +109,16 @@ public UriType getOriginMap() {
return getParameterValue("originMap", Parameters.ParametersParameterComponent::getValueUriType);
}

public Match setRelationship(ConceptMapRelationship relationship) {
return relationship == null ? this : setRelationship(relationship.toCode());
}

public Match setRelationship(String relationship) {
return setRelationship(new CodeType(relationship));
}

public Match setRelationship(CodeType codeType) {
addParameter("relationship", codeType);
public Match setRelationship(CodeType relationship) {
addParameter("relationship", relationship);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* @see <a href="https://www.hl7.org/fhir/valueset-operations.html#expand">FHIR:ValueSet:Operations:expand</a>
*
* @since 9.2
* @since 0.1
*/
public final class ValueSetExpandParameters extends BaseParameters {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.hl7.fhir.r5.model.*;

/**
* @since 9.2
* @since 0.1
*/
public class ValueSetValidateCodeParameters extends BaseParameters {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.hl7.fhir.r5.model.*;

/**
* @since 9.3
* @since 0.1
*/
public class ValueSetValidateCodeResultParameters extends BaseParameters {

Expand Down Expand Up @@ -58,8 +58,12 @@ public CodeableConcept getCodeableConcept() {
return getParameterValue("codeableConcept", Parameters.ParametersParameterComponent::getValueCodeableConcept);
}

public ValueSetValidateCodeResultParameters setResult(boolean result) {
addParameter("result", new BooleanType(result));
public ValueSetValidateCodeResultParameters setResult(Boolean result) {
return setResult(new BooleanType(result));
}

public ValueSetValidateCodeResultParameters setResult(BooleanType result) {
addParameter("result", result);
return this;
}

Expand Down

0 comments on commit c04f9b4

Please sign in to comment.