Skip to content

Commit

Permalink
refactor: use static lookup methods
Browse files Browse the repository at this point in the history
Since all lookup classes use immutable data, this
replaces creating new objects at runtime with the use
of static methods.
  • Loading branch information
pcvolkmer committed Aug 13, 2024
1 parent e493ad1 commit 824dddd
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class BeurteilungResidualstatusVsLookup {
}
};

public final String lookupDisplay(String code) {
public static String lookupDisplay(String code) {
return lookup.get(code);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class DisplayAdtSeitenlokalisationLookup {
}
};

public final String lookupDisplay(String code) {
public static String lookupDisplay(String code) {
return lookup.get(code);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class FMLokalisationVsLookup {
}
};

public final String lookupDisplay(String code) {
public static String lookupDisplay(String code) {
return lookup.get(code);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class GradingLookup {
}
};

public final String lookupDisplay(String code) {
public static String lookupDisplay(String code) {
return lookup.get(code);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class JnuVsLookup {
}
};

public final String lookupDisplay(String code) {
public static String lookupDisplay(String code) {
return lookup.get(code);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class OPIntentionVsLookup {
}
};

public final String lookupDisplay(String code) {
public static String lookupDisplay(String code) {
return lookup.get(code);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public class OPKomplikationVsLookup {
}
};

public final String lookupDisplay(String code) {
public static String lookupDisplay(String code) {
return lookup.get(code);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class SYSTTherapieartCSLookup {
}
};

public final String lookupDisplay(List<String> code) {
public static String lookupDisplay(List<String> code) {

if (code.size() == 1) {
return lookup.get(code.get(0));
Expand All @@ -50,7 +50,7 @@ public final String lookupDisplay(List<String> code) {
}
}

public final String lookupCode(List<String> code) {
public static String lookupCode(List<String> code) {

if (code.size() == 1) {
return code.get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public class SideEffectTherapyGradingLookup {
}
};

public final String lookupCode(String code) {
public static String lookupCode(String code) {
return lookup.get(code) != null ? lookup.get(code).get(0) : null;
}

public final String lookupDisplay(String code) {
public static String lookupDisplay(String code) {
return lookup.get(code) != null ? lookup.get(code).get(1) : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public class SnomedCtSeitenlokalisationLookup {
}
};

public final String lookupCode(String AdtCode) {
public static String lookupCode(String AdtCode) {
return lookup.get(AdtCode) != null ? lookup.get(AdtCode).get(0) : null;
}

public final String lookupDisplay(String AdtCode) {
public static String lookupDisplay(String AdtCode) {
return lookup.get(AdtCode) != null ? lookup.get(AdtCode).get(1) : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class StellungOpVsLookup {
}
};

public final String lookupDisplay(String code) {
public static String lookupDisplay(String code) {
return lookup.get(code);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class SystIntentionVsLookup {
}
};

public final String lookupDisplay(String code) {
public static String lookupDisplay(String code) {
return lookup.get(code);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class TnmCpuPraefixTvsLookup {
}
};

public final String lookupDisplay(String code) {
public static String lookupDisplay(String code) {
return lookup.get(code);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ public class ObdsConditionMapper extends ObdsToFhirMapper {
@Value("${app.enableCheckDigitConv}")
private boolean checkDigitConversion;

private final SnomedCtSeitenlokalisationLookup snomedCtSeitenlokalisationLookup =
new SnomedCtSeitenlokalisationLookup();

private final DisplayAdtSeitenlokalisationLookup displayAdtSeitenlokalisationLookup =
new DisplayAdtSeitenlokalisationLookup();

@Autowired
public ObdsConditionMapper(FhirProperties fhirProperties) {
super(fhirProperties);
Expand Down Expand Up @@ -133,10 +127,10 @@ public Bundle mapOnkoResourcesToCondition(

if (adtBodySite != null) {
var adtSeitenlokalisationDisplay =
displayAdtSeitenlokalisationLookup.lookupDisplay(adtBodySite);
var snomedCtSeitenlokalisationCode = snomedCtSeitenlokalisationLookup.lookupCode(adtBodySite);
DisplayAdtSeitenlokalisationLookup.lookupDisplay(adtBodySite);
var snomedCtSeitenlokalisationCode = SnomedCtSeitenlokalisationLookup.lookupCode(adtBodySite);
var snomedCtSeitenlokalisationDisplay =
snomedCtSeitenlokalisationLookup.lookupDisplay(adtBodySite);
SnomedCtSeitenlokalisationLookup.lookupDisplay(adtBodySite);

if (adtSeitenlokalisationDisplay != null) {
bodySiteADTCoding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ public class ObdsMedicationStatementMapper extends ObdsToFhirMapper {
@Value("${app.enableCheckDigitConv}")
private boolean checkDigitConversion;

private final StellungOpVsLookup displayStellungOpLookup = new StellungOpVsLookup();

private final SystIntentionVsLookup displaySystIntentionLookup = new SystIntentionVsLookup();

private final SYSTTherapieartCSLookup displaySystTherapieLookup = new SYSTTherapieartCSLookup();

public ObdsMedicationStatementMapper(FhirProperties fhirProperties) {
super(fhirProperties);
}
Expand Down Expand Up @@ -193,8 +187,8 @@ public MedicationStatement createSystemtherapyMedicationStatement(
therapyCategory.addCoding(
new Coding()
.setSystem(fhirProperties.getSystems().getSystTherapieart())
.setCode(displaySystTherapieLookup.lookupCode(category))
.setDisplay(displaySystTherapieLookup.lookupDisplay(category)));
.setCode(SYSTTherapieartCSLookup.lookupCode(category))
.setDisplay(SYSTTherapieartCSLookup.lookupDisplay(category)));

if (systemTherapy.getSYST_Therapieart_Anmerkung() != null) {
therapyCategory.setText(systemTherapy.getSYST_Therapieart_Anmerkung());
Expand All @@ -218,7 +212,7 @@ public MedicationStatement createSystemtherapyMedicationStatement(
.setCode(systemTherapy.getSYST_Stellung_OP())
.setSystem(fhirProperties.getSystems().getSystStellungOP())
.setDisplay(
displayStellungOpLookup.lookupDisplay(
StellungOpVsLookup.lookupDisplay(
systemTherapy.getSYST_Stellung_OP()))));

stMedicationStatement
Expand All @@ -231,7 +225,7 @@ public MedicationStatement createSystemtherapyMedicationStatement(
.setCode(systemTherapy.getSYST_Intention())
.setSystem(fhirProperties.getSystems().getSystIntention())
.setDisplay(
displaySystIntentionLookup.lookupDisplay(
SystIntentionVsLookup.lookupDisplay(
systemTherapy.getSYST_Intention()))));

stMedicationStatement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ public static record ModulProstataMappingParams(

private static final Logger LOG = LoggerFactory.getLogger(ObdsObservationMapper.class);

private final GradingLookup gradingLookup = new GradingLookup();

private final TnmCpuPraefixTvsLookup tnmPraefixLookup = new TnmCpuPraefixTvsLookup();

private final FMLokalisationVsLookup fmLokalisationVSLookup = new FMLokalisationVsLookup();

private final JnuVsLookup jnuVsLookup = new JnuVsLookup();

@Value("${app.version}")
private String appVersion;

Expand Down Expand Up @@ -498,7 +490,7 @@ public Bundle createHistologieAndGradingObservation(
new Coding()
.setSystem(fhirProperties.getSystems().getGradingDktk())
.setCode(grading)
.setDisplay(gradingLookup.lookupDisplay(grading)));
.setDisplay(GradingLookup.lookupDisplay(grading)));

gradingObs.setValue(gradingValueCodeableCon);
}
Expand Down Expand Up @@ -644,7 +636,7 @@ public Bundle createFernMetaObservation(
new Coding()
.setSystem(fhirProperties.getSystems().getFMLokalisationCS())
.setCode(fernMetaLokal)
.setDisplay(fmLokalisationVSLookup.lookupDisplay(fernMetaLokal))));
.setDisplay(FMLokalisationVsLookup.lookupDisplay(fernMetaLokal))));

bundle = addResourceAsEntryInBundle(bundle, fernMetaObs);

Expand Down Expand Up @@ -734,7 +726,7 @@ public Bundle createCTnmObservation(
backBoneComponentListC.add(
createTNMComponentElement(
cTnmCpuPraefixT,
tnmPraefixLookup.lookupDisplay(cTnmCpuPraefixT),
TnmCpuPraefixTvsLookup.lookupDisplay(cTnmCpuPraefixT),
"21905-5",
"Primary tumor.clinical Cancer",
fhirProperties.getSystems().getTnmTCs(),
Expand All @@ -747,7 +739,7 @@ public Bundle createCTnmObservation(
backBoneComponentListC.add(
createTNMComponentElement(
cTnmCpuPraefixN,
tnmPraefixLookup.lookupDisplay(cTnmCpuPraefixN),
TnmCpuPraefixTvsLookup.lookupDisplay(cTnmCpuPraefixN),
"21906-3",
"Regional lymph nodes.clinical",
fhirProperties.getSystems().getTnmNCs(),
Expand All @@ -760,7 +752,7 @@ public Bundle createCTnmObservation(
backBoneComponentListC.add(
createTNMComponentElement(
cTnmCpuPraefixM,
tnmPraefixLookup.lookupDisplay(cTnmCpuPraefixM),
TnmCpuPraefixTvsLookup.lookupDisplay(cTnmCpuPraefixM),
"21907-1",
"Distant metastases.clinical [Class] Cancer",
fhirProperties.getSystems().getTnmMCs(),
Expand Down Expand Up @@ -894,7 +886,7 @@ public Bundle createPTnmObservation(
backBoneComponentListP.add(
createTNMComponentElement(
pTnmCpuPraefixT,
tnmPraefixLookup.lookupDisplay(pTnmCpuPraefixT),
TnmCpuPraefixTvsLookup.lookupDisplay(pTnmCpuPraefixT),
"21899-0",
"Primary tumor.pathology Cancer",
fhirProperties.getSystems().getTnmTCs(),
Expand All @@ -907,7 +899,7 @@ public Bundle createPTnmObservation(
backBoneComponentListP.add(
createTNMComponentElement(
pTnmCpuPraefixN,
tnmPraefixLookup.lookupDisplay(pTnmCpuPraefixN),
TnmCpuPraefixTvsLookup.lookupDisplay(pTnmCpuPraefixN),
"21900-6",
"Regional lymph nodes.pathology",
fhirProperties.getSystems().getTnmNCs(),
Expand All @@ -920,7 +912,7 @@ public Bundle createPTnmObservation(
backBoneComponentListP.add(
createTNMComponentElement(
pTnmCpuPraefixM,
tnmPraefixLookup.lookupDisplay(pTnmCpuPraefixM),
TnmCpuPraefixTvsLookup.lookupDisplay(pTnmCpuPraefixM),
"21901-4",
"Distant metastases.pathology [Class] Cancer",
fhirProperties.getSystems().getTnmMCs(),
Expand Down Expand Up @@ -1063,7 +1055,7 @@ public Bundle createDeathObservation(
new Coding()
.setSystem(fhirProperties.getSystems().getJnuCs())
.setCode(death.getTod_tumorbedingt())
.setDisplay(jnuVsLookup.lookupDisplay(death.getTod_tumorbedingt()));
.setDisplay(JnuVsLookup.lookupDisplay(death.getTod_tumorbedingt()));
deathValueCodeConcept.addCoding(deathByTumorCoding);
}

Expand Down
Loading

0 comments on commit 824dddd

Please sign in to comment.