Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #386 from ehrbase/refactor_gecco_diagnose
Browse files Browse the repository at this point in the history
Refactor gecco diagnose
  • Loading branch information
SevKohler authored Jul 12, 2021
2 parents 064067b + 391ff48 commit 6fc5f04
Show file tree
Hide file tree
Showing 35 changed files with 3,731 additions and 3,780 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ public class AusgeschlosseneDiagnoseConverter extends EntryEntityConverter<Condi
@Override
protected AusgeschlosseneDiagnoseEvaluation convertInternal(Condition resource) {
AusgeschlosseneDiagnoseEvaluation ausgeschlosseneDiagnose = new AusgeschlosseneDiagnoseEvaluation();
ausgeschlosseneDiagnose.setAussageUeberDenAusschlussDefiningCode(AussageUeberDenAusschlussDefiningCode.KNOWN_ABSENT_QUALIFIER_VALUE);
ausgeschlosseneDiagnose.setAussageUeberDenAusschluss(DvCodedTextParser.parseDefiningCode(AussageUeberDenAusschlussDefiningCode.KNOWN_ABSENT_QUALIFIER_VALUE));
Coding problem = resource.getCode().getCoding().get(0);
if (problem.getSystem().equals(CodeSystem.SNOMED.getUrl()) &&
GeccoDiagnoseCodeDefiningCodeMaps.getProblemDiagnoseMap().containsKey(problem.getCode())) {
ausgeschlosseneDiagnose.setProblemDiagnoseDefiningCode(GeccoDiagnoseCodeDefiningCodeMaps.getProblemDiagnoseMap().get(problem.getCode()));
ausgeschlosseneDiagnose.setProblemDiagnose(DvCodedTextParser.parseDefiningCode(GeccoDiagnoseCodeDefiningCodeMaps.getProblemDiagnoseMap().get(problem.getCode())));
}
return ausgeschlosseneDiagnose;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.ehrbase.fhirbridge.ehr.converter.specific.geccodiagnose;

import com.nedap.archie.rm.datatypes.CodePhrase;
import com.nedap.archie.rm.datavalues.DvCodedText;
import com.nedap.archie.rm.support.identification.TerminologyId;
import org.ehrbase.client.classgenerator.EnumValueSet;
import org.ehrbase.fhirbridge.ehr.converter.specific.CodeSystem;
import org.hl7.fhir.r4.model.Coding;
import java.util.Optional;

public class DvCodedTextParser {

public static DvCodedText parseDefiningCode(EnumValueSet enumValueSet){
return new DvCodedText(enumValueSet.getValue(), new CodePhrase(new TerminologyId(enumValueSet.getTerminologyId(), ""), enumValueSet.getCode()));
}

public static Optional<DvCodedText> parseFHIRCoding(Coding coding){
if(coding.hasDisplay() && coding.hasSystem() && coding.hasCode() && coding.getSystem().equals(CodeSystem.SNOMED.getUrl())){
return Optional.of(new DvCodedText(coding.getDisplay(), new CodePhrase(new TerminologyId("SNOMED Clinical Terms", ""), coding.getCode())));
}else if (coding.hasCode() && coding.getSystem().equals(CodeSystem.SNOMED.getUrl())){
return Optional.of(new DvCodedText("", new CodePhrase(new TerminologyId("SNOMED Clinical Terms", ""), coding.getCode())));
}else{
return Optional.empty();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public GECCODiagnoseComposition convertInternal(@NonNull Condition resource) {
private void mapCategoryCoding(Condition resource, GECCODiagnoseComposition composition) {
Coding categoryCoding = resource.getCategory().get(0).getCoding().get(0);
if (categoryCoding.getSystem().equals(CodeSystem.SNOMED.getUrl()) && GeccoDiagnoseCodeDefiningCodeMaps.getKategorieMap().containsKey(categoryCoding.getCode())) {
composition.setKategorieDefiningCode(GeccoDiagnoseCodeDefiningCodeMaps.getKategorieMap().get(categoryCoding.getCode()));
composition.setKategorie(DvCodedTextParser.parseDefiningCode(GeccoDiagnoseCodeDefiningCodeMaps.getKategorieMap().get(categoryCoding.getCode())));
} else {
throw new UnprocessableEntityException("Category has either no or an unsupported SNOMED code");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.ehrbase.fhirbridge.ehr.opt.geccodiagnosecomposition.definition.KategorieDefiningCode;
import org.ehrbase.fhirbridge.ehr.opt.geccodiagnosecomposition.definition.NameDerKoerperstelleDefiningCode;
import org.ehrbase.fhirbridge.ehr.opt.geccodiagnosecomposition.definition.NameDesProblemsDerDiagnoseDefiningCode;
import org.ehrbase.fhirbridge.ehr.opt.geccodiagnosecomposition.definition.ProblemDiagnoseDefiningCode;
import org.ehrbase.fhirbridge.ehr.opt.geccodiagnosecomposition.definition.SchweregradDefiningCode;

Expand All @@ -13,7 +12,6 @@ class GeccoDiagnoseCodeDefiningCodeMaps {

private static final Map<String, KategorieDefiningCode> kategorieMap = new HashMap<>();
private static final Map<String, ProblemDiagnoseDefiningCode> problemDiagnoseMap = new HashMap<>();
private static final Map<String, NameDesProblemsDerDiagnoseDefiningCode> nameDesProblemDiagnoseMap = new HashMap<>();
private static final Map<String, NameDerKoerperstelleDefiningCode> koerperstelleMap = new HashMap<>();
private static final Map<String, SchweregradDefiningCode> schweregradMap = new HashMap<>();

Expand All @@ -26,10 +24,6 @@ class GeccoDiagnoseCodeDefiningCodeMaps {
problemDiagnoseMap.put(problem.getCode(), problem);
}

for (NameDesProblemsDerDiagnoseDefiningCode problem : NameDesProblemsDerDiagnoseDefiningCode.values()) {
nameDesProblemDiagnoseMap.put(problem.getCode(), problem);
}

for (NameDerKoerperstelleDefiningCode koerperstelleDefiningCode : NameDerKoerperstelleDefiningCode.values()) {
koerperstelleMap.put(koerperstelleDefiningCode.getCode(), koerperstelleDefiningCode);
}
Expand All @@ -47,10 +41,6 @@ static Map<String, ProblemDiagnoseDefiningCode> getProblemDiagnoseMap() {
return problemDiagnoseMap;
}

static Map<String, NameDesProblemsDerDiagnoseDefiningCode> getNameDesProblemDiagnoseMap() {
return nameDesProblemDiagnoseMap;
}

static Map<String, NameDerKoerperstelleDefiningCode> getKoerperstelleMap() {
return koerperstelleMap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class UnbekannteDiagnoseEvaluationConverter extends EntryEntityConverter<
@Override
protected UnbekannteDiagnoseEvaluation convertInternal(Condition condition) {
UnbekannteDiagnoseEvaluation unbekannteDiagnose = new UnbekannteDiagnoseEvaluation();
unbekannteDiagnose.setAussageUeberDieFehlendeInformationDefiningCode(AussageUeberDieFehlendeInformationDefiningCode.UNKNOWN_QUALIFIER_VALUE);
unbekannteDiagnose.setAussageUeberDieFehlendeInformation(DvCodedTextParser.parseDefiningCode(AussageUeberDieFehlendeInformationDefiningCode.UNKNOWN_QUALIFIER_VALUE));
mapProblem(condition, unbekannteDiagnose);

return unbekannteDiagnose;
Expand All @@ -22,7 +22,7 @@ private void mapProblem(Condition condition, UnbekannteDiagnoseEvaluation unbeka
for(Coding coding : condition.getCode().getCoding()){
if (coding.getSystem().equals(CodeSystem.SNOMED.getUrl()) &&
GeccoDiagnoseCodeDefiningCodeMaps.getProblemDiagnoseMap().containsKey(coding.getCode())) {
unbekannteDiagnose.setUnbekannteDiagnoseDefiningCode(GeccoDiagnoseCodeDefiningCodeMaps.getProblemDiagnoseMap().get(coding.getCode()));
unbekannteDiagnose.setUnbekannteDiagnose(DvCodedTextParser.parseDefiningCode(GeccoDiagnoseCodeDefiningCodeMaps.getProblemDiagnoseMap().get(coding.getCode())));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import org.ehrbase.fhirbridge.ehr.converter.specific.CodeSystem;
import org.ehrbase.fhirbridge.ehr.opt.geccodiagnosecomposition.definition.KoerperstelleCluster;
import org.ehrbase.fhirbridge.ehr.opt.geccodiagnosecomposition.definition.VorliegendeDiagnoseEvaluation;
import org.ehrbase.fhirbridge.ehr.opt.geccodiagnosecomposition.definition.VorliegendeDiagnoseNameDesProblemsDerDiagnoseChoice;
import org.ehrbase.fhirbridge.ehr.opt.geccodiagnosecomposition.definition.VorliegendeDiagnoseNameDesProblemsDerDiagnoseDvCodedText;
import org.hl7.fhir.r4.model.Annotation;
import org.hl7.fhir.r4.model.Coding;
import org.hl7.fhir.r4.model.Condition;
Expand Down Expand Up @@ -61,7 +63,7 @@ private void mapSeverity(Condition condition, VorliegendeDiagnoseEvaluation vorl

private void convertSevertiy(Coding coding, VorliegendeDiagnoseEvaluation vorliegendeDiagnose) {
if (coding.getSystem().equals(CodeSystem.SNOMED.getUrl()) && GeccoDiagnoseCodeDefiningCodeMaps.getSchweregradMap().containsKey(coding.getCode())) {
vorliegendeDiagnose.setSchweregradDefiningCode(GeccoDiagnoseCodeDefiningCodeMaps.getSchweregradMap().get(coding.getCode()));
vorliegendeDiagnose.setSchweregrad(DvCodedTextParser.parseDefiningCode(GeccoDiagnoseCodeDefiningCodeMaps.getSchweregradMap().get(coding.getCode())));
isEmpty = false;
} else {
throw new UnprocessableEntityException("Severity contains either a wrong code or code system.");
Expand All @@ -73,7 +75,7 @@ private void mapBodySite(Condition condition, VorliegendeDiagnoseEvaluation vorl
for (Coding bodySite : condition.getBodySite().get(0).getCoding()) {
if (bodySite.getSystem().equals(CodeSystem.SNOMED.getUrl()) && GeccoDiagnoseCodeDefiningCodeMaps.getKoerperstelleMap().containsKey(bodySite.getCode())) {
KoerperstelleCluster korperstelleCluster = new KoerperstelleCluster();
korperstelleCluster.setNameDerKoerperstelleDefiningCode(GeccoDiagnoseCodeDefiningCodeMaps.getKoerperstelleMap().get(bodySite.getCode()));
korperstelleCluster.setNameDerKoerperstelle(DvCodedTextParser.parseDefiningCode(GeccoDiagnoseCodeDefiningCodeMaps.getKoerperstelleMap().get(bodySite.getCode())));
addKoerperstelleCluster(korperstelleCluster, vorliegendeDiagnose);
isEmpty = false;
} else {
Expand All @@ -94,10 +96,13 @@ private void addKoerperstelleCluster(KoerperstelleCluster korperstelleCluster, V

private void mapNameDesProblemsDerDiagnose(Condition condition, VorliegendeDiagnoseEvaluation vorliegendeDiagnose) {
for (Coding coding : condition.getCode().getCoding()) {
if (coding.getSystem().equals(CodeSystem.SNOMED.getUrl()) &&
GeccoDiagnoseCodeDefiningCodeMaps.getNameDesProblemDiagnoseMap().containsKey(coding.getCode())) {
vorliegendeDiagnose.setNameDesProblemsDerDiagnoseDefiningCode(GeccoDiagnoseCodeDefiningCodeMaps.getNameDesProblemDiagnoseMap().get(coding.getCode()));
isEmpty = false;
if (coding.getSystem().equals(CodeSystem.SNOMED.getUrl())) {
if(DvCodedTextParser.parseFHIRCoding(coding).isPresent()){
VorliegendeDiagnoseNameDesProblemsDerDiagnoseDvCodedText vorliegendeDiagnoseNameDesProblemsDerDiagnoseDvCodedText = new VorliegendeDiagnoseNameDesProblemsDerDiagnoseDvCodedText();
vorliegendeDiagnoseNameDesProblemsDerDiagnoseDvCodedText.setNameDesProblemsDerDiagnose(DvCodedTextParser.parseFHIRCoding(coding).get());
vorliegendeDiagnose.setNameDesProblemsDerDiagnose(vorliegendeDiagnoseNameDesProblemsDerDiagnoseDvCodedText);
isEmpty = false;
}
}
}
}
Expand Down
Loading

0 comments on commit 6fc5f04

Please sign in to comment.