Skip to content

Commit

Permalink
feat: add CM translate result parameters r4 to r5 converter
Browse files Browse the repository at this point in the history
  • Loading branch information
adamfilep committed Oct 9, 2024
1 parent 26060d9 commit a768361
Showing 1 changed file with 47 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,15 @@ public static com.b2international.fhir.r5.operations.ConceptMapTranslateParamete
.setDependency(parameters.getDependency() == null ? null : parameters.getDependency().stream().map(dependency -> convert(dependency)).toList());
}

// ConceptMap translate result - TODO
// ConceptMap translate result
public static com.b2international.fhir.r5.operations.ConceptMapTranslateResultParameters convert(com.b2international.fhir.r4.operations.ConceptMapTranslateResultParameters parameters) {
return null;
return new com.b2international.fhir.r5.operations.ConceptMapTranslateResultParameters()
.setResult(parameters.getResult() == null ? null : parameters.getResult().getValue())
.setMessage(parameters.getMessage() == null ? null : parameters.getMessage().getValue())
.setMatch(parameters.getMatch() == null ? null : parameters.getMatch().stream().map(match -> convert(match)).toList());
}

//ValueSet expand
// ValueSet expand
public static com.b2international.fhir.r5.operations.ValueSetExpandParameters convert(com.b2international.fhir.r4.operations.ValueSetExpandParameters parameters) {
return new com.b2international.fhir.r5.operations.ValueSetExpandParameters()
.setUrl(parameters.getUrl() == null ? null : parameters.getUrl().getValue())
Expand All @@ -272,7 +275,7 @@ public static com.b2international.fhir.r5.operations.ValueSetExpandParameters co
.setForceSystemVersion(parameters.getForceSystemVersion() == null ? null : parameters.getForceSystemVersion().stream().map(ex -> ex.getValue()).toList());
}

//ValueSet validate-code
// ValueSet validate-code
public static com.b2international.fhir.r5.operations.ValueSetValidateCodeParameters convert(com.b2international.fhir.r4.operations.ValueSetValidateCodeParameters parameters) {
return new com.b2international.fhir.r5.operations.ValueSetValidateCodeParameters()
.setUrl(parameters.getUrl() == null ? null : parameters.getUrl().getValue())
Expand Down Expand Up @@ -364,6 +367,40 @@ private static com.b2international.fhir.r4.operations.ConceptMapTranslateResultP
.setSource(r5Match.getOriginMap() == null ? null : r5Match.getOriginMap().getValue());
}

//TODO: revise r4 ConceptMapEquivalence to r5 ConceptMapRelationship conversion
private static com.b2international.fhir.r5.operations.ConceptMapTranslateResultParameters.Match convert(com.b2international.fhir.r4.operations.ConceptMapTranslateResultParameters.Match r4Match) {

var r5Match = new com.b2international.fhir.r5.operations.ConceptMapTranslateResultParameters.Match();

switch(org.hl7.fhir.r4.model.codesystems.ConceptMapEquivalence.fromCode(r4Match.getEquivalence().getCode())) {
case RELATEDTO:
break;
case EQUIVALENT:
r5Match.setRelationship(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.RELATEDTO.toCode());
case EQUAL:
break;
case WIDER:
r5Match.setRelationship(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.SOURCEISNARROWERTHANTARGET.toCode());
case SUBSUMES:
break;
case NARROWER:
r5Match.setRelationship(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.SOURCEISBROADERTHANTARGET.toCode());
case SPECIALIZES:
break;
case UNMATCHED:
break;
case DISJOINT:
r5Match.setRelationship(org.hl7.fhir.r5.model.Enumerations.ConceptMapRelationship.NOTRELATEDTO.toCode());
default:
r5Match.setRelationship("");
}
r5Match.setConcept(r4Match.getConcept() == null ? null : (org.hl7.fhir.r5.model.Coding) VersionConvertorFactory_40_50.convertType(r4Match.getConcept()))
.setProduct(r4Match.getProduct() == null ? null : r4Match.getProduct().stream().map(product -> convert(product)).toList())
.setOriginMap(r4Match.getSource() == null ? null : r4Match.getSource().getValue());

return r5Match;
}

private static com.b2international.fhir.r4.operations.ConceptMapTranslateResultParameters.Match.Product convert(com.b2international.fhir.r5.operations.ConceptMapTranslateResultParameters.Match.Product r5Product) {
var r4Product = new com.b2international.fhir.r4.operations.ConceptMapTranslateResultParameters.Match.Product()
.setElement(r5Product.getAttribute() == null ? null : r5Product.getAttribute().getValue());
Expand All @@ -376,6 +413,12 @@ private static com.b2international.fhir.r4.operations.ConceptMapTranslateResultP
return r4Product;
}

private static com.b2international.fhir.r5.operations.ConceptMapTranslateResultParameters.Match.Product convert(com.b2international.fhir.r4.operations.ConceptMapTranslateResultParameters.Match.Product r4Product) {
return new com.b2international.fhir.r5.operations.ConceptMapTranslateResultParameters.Match.Product()
.setAttribute(r4Product.getElement() == null ? null : r4Product.getElement().getValue())
.setValue(r4Product.getConcept() == null ? null : (org.hl7.fhir.r5.model.Coding) VersionConvertorFactory_40_50.convertType(r4Product.getConcept()));
}

private static com.b2international.fhir.r4.operations.ConceptMapTranslateParameters.Dependency convert (com.b2international.fhir.r5.operations.ConceptMapTranslateParameters.Dependency r5dependency) {

var r4Dependency = new com.b2international.fhir.r4.operations.ConceptMapTranslateParameters.Dependency()
Expand Down

0 comments on commit a768361

Please sign in to comment.