Skip to content

Commit

Permalink
[26654] remove method getCoverageWithLaw (#388)
Browse files Browse the repository at this point in the history
Co-authored-by: pdenzler <patrick.denzler@medelexis.ch>
  • Loading branch information
PatrickDenzler and pdenzler authored Oct 17, 2024
1 parent 7f96475 commit 0f6227d
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import ch.elexis.core.services.ILocalDocumentService;
import ch.elexis.core.services.holder.ContextServiceHolder;
import ch.elexis.core.services.holder.CoreModelServiceHolder;
import ch.elexis.core.services.holder.CoverageServiceHolder;
import ch.elexis.covid.cert.service.CertificateInfo;
import ch.elexis.covid.cert.service.CertificatesService;
import ch.elexis.covid.cert.service.rest.model.TestModel;
Expand Down Expand Up @@ -55,7 +56,8 @@ public void execute() {
activePatient.ifPresent(patient -> {
Map<String, ICodeElementBlock> blocks = CovidHandlerUtil.getConfiguredBlocks();
if (!blocks.isEmpty()) {
Optional<ICoverage> kkCoverage = CovidHandlerUtil.getCoverageWithLaw(patient, CovidHandlerUtil.KK_LAWS);
Optional<ICoverage> kkCoverage = CoverageServiceHolder.get().getCoverageWithLaw(patient,
CovidHandlerUtil.KK_LAWS);
Optional<CertificateInfo> todayCertificate = CovidHandlerUtil.getCertificateAtWithType(patient,
LocalDate.now(), CertificateInfo.Type.TEST);
if (kkCoverage.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import ch.elexis.core.services.ILocalDocumentService;
import ch.elexis.core.services.holder.ContextServiceHolder;
import ch.elexis.core.services.holder.CoreModelServiceHolder;
import ch.elexis.core.services.holder.CoverageServiceHolder;
import ch.elexis.covid.cert.service.CertificateInfo;
import ch.elexis.covid.cert.service.CertificatesService;
import ch.elexis.covid.cert.service.rest.model.TestModel;
Expand Down Expand Up @@ -55,7 +56,8 @@ public void execute() {
activePatient.ifPresent(patient -> {
Map<String, ICodeElementBlock> blocks = CovidHandlerUtil.getConfiguredBlocks();
if (!blocks.isEmpty()) {
Optional<ICoverage> szCoverage = CovidHandlerUtil.getCoverageWithLaw(patient, CovidHandlerUtil.SZ_LAWS);
Optional<ICoverage> szCoverage = CoverageServiceHolder.get().getCoverageWithLaw(patient,
CovidHandlerUtil.SZ_LAWS);
Optional<CertificateInfo> todayCertificate = CovidHandlerUtil.getCertificateAtWithType(patient,
LocalDate.now(), CertificateInfo.Type.TEST);
if (todayCertificate.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import ch.elexis.core.services.ILocalDocumentService;
import ch.elexis.core.services.holder.ContextServiceHolder;
import ch.elexis.core.services.holder.CoreModelServiceHolder;
import ch.elexis.core.services.holder.CoverageServiceHolder;
import ch.elexis.core.ui.text.TextContainer;
import ch.elexis.data.Brief;
import ch.elexis.data.Konsultation;
Expand All @@ -47,7 +48,8 @@ public void execute() {
activePatient.ifPresent(patient -> {
Map<String, ICodeElementBlock> blocks = CovidHandlerUtil.getConfiguredBlocks();
if (!blocks.isEmpty()) {
Optional<ICoverage> kkCoverage = CovidHandlerUtil.getCoverageWithLaw(patient, CovidHandlerUtil.KK_LAWS);
Optional<ICoverage> kkCoverage = CoverageServiceHolder.get().getCoverageWithLaw(patient,
CovidHandlerUtil.KK_LAWS);
if (kkCoverage.isPresent()) {
List<IDocumentLetter> existingLetters = CovidHandlerUtil.getLettersAt(patient, LocalDate.now(),
new String[] { CovidHandlerUtil.ATTEST_POSITIV_LETTER_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import ch.elexis.core.services.ILocalDocumentService;
import ch.elexis.core.services.holder.ContextServiceHolder;
import ch.elexis.core.services.holder.CoreModelServiceHolder;
import ch.elexis.core.services.holder.CoverageServiceHolder;
import ch.elexis.core.ui.text.TextContainer;
import ch.elexis.data.Brief;
import ch.elexis.data.Konsultation;
Expand All @@ -47,7 +48,8 @@ public void execute() {
activePatient.ifPresent(patient -> {
Map<String, ICodeElementBlock> blocks = CovidHandlerUtil.getConfiguredBlocks();
if (!blocks.isEmpty()) {
Optional<ICoverage> szCoverage = CovidHandlerUtil.getCoverageWithLaw(patient, CovidHandlerUtil.SZ_LAWS);
Optional<ICoverage> szCoverage = CoverageServiceHolder.get().getCoverageWithLaw(patient,
CovidHandlerUtil.SZ_LAWS);
List<IDocumentLetter> existingLetters = CovidHandlerUtil.getLettersAt(patient, LocalDate.now(),
new String[] { CovidHandlerUtil.ATTEST_POSITIV_LETTER_NAME,
CovidHandlerUtil.ATTEST_NEGATIV_LETTER_NAME });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,6 @@ public class CovidHandlerUtil {
public static BillingLaw[] KK_LAWS = { BillingLaw.KVG };
public static BillingLaw[] SZ_LAWS = { BillingLaw.privat, BillingLaw.VVG };

/**
* Search for the first open {@link ICoverage} of the {@link IPatient} with a
* matching law.
*
* @param patient
* @param law
* @return
*/
public static Optional<ICoverage> getCoverageWithLaw(IPatient patient, BillingLaw... laws) {
ICoverage bestMatch = null;
for (ICoverage coverage : patient.getCoverages()) {
if (coverage.isOpen()) {
if (Arrays.asList(laws).contains(coverage.getBillingSystem().getLaw())) {
bestMatch = coverage;
}
}
}
return Optional.ofNullable(bestMatch);
}

/**
* Get all configured covid {@link ICodeElementBlock} instances as map with id
* as key.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import ch.elexis.core.model.ch.BillingLaw;
import ch.elexis.core.services.IContextService;
import ch.elexis.core.services.holder.CoreModelServiceHolder;
import ch.elexis.core.services.holder.CoverageServiceHolder;

public class CovidPcrKk {

Expand All @@ -31,7 +32,8 @@ public void execute() {
activePatient.ifPresent(patient -> {
Map<String, ICodeElementBlock> blocks = CovidHandlerUtil.getConfiguredBlocks();
if (!blocks.isEmpty()) {
Optional<ICoverage> kkCoverage = CovidHandlerUtil.getCoverageWithLaw(patient, CovidHandlerUtil.KK_LAWS);
Optional<ICoverage> kkCoverage = CoverageServiceHolder.get().getCoverageWithLaw(patient,
CovidHandlerUtil.KK_LAWS);
Optional<IEncounter> pcrEncounter = CovidHandlerUtil
.getEncountersAt(patient, LocalDate.now(), (BillingLaw[]) null).stream()
.filter(e -> CovidHandlerUtil.isPcrBilled(e)).findFirst();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import ch.elexis.core.model.ch.BillingLaw;
import ch.elexis.core.services.IContextService;
import ch.elexis.core.services.holder.CoreModelServiceHolder;
import ch.elexis.core.services.holder.CoverageServiceHolder;

public class CovidPcrSz {

Expand All @@ -31,7 +32,8 @@ public void execute() {
activePatient.ifPresent(patient -> {
Map<String, ICodeElementBlock> blocks = CovidHandlerUtil.getConfiguredBlocks();
if (!blocks.isEmpty()) {
Optional<ICoverage> szCoverage = CovidHandlerUtil.getCoverageWithLaw(patient, CovidHandlerUtil.SZ_LAWS);
Optional<ICoverage> szCoverage = CoverageServiceHolder.get().getCoverageWithLaw(patient,
CovidHandlerUtil.SZ_LAWS);
Optional<IEncounter> pcrEncounter = CovidHandlerUtil
.getEncountersAt(patient, LocalDate.now(), (BillingLaw[]) null).stream()
.filter(e -> CovidHandlerUtil.isPcrBilled(e)).findFirst();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@
import ch.elexis.core.model.builder.IEncounterBuilder;
import ch.elexis.core.model.ch.BillingLaw;
import ch.elexis.core.services.IContextService;
import ch.elexis.core.services.ICoverageService;
import ch.elexis.core.services.holder.ConfigServiceHolder;
import ch.elexis.core.services.holder.CoreModelServiceHolder;

public class CovidTestBill {

@Inject
private IContextService contextService;

@Inject
private ICoverageService coverageService;

@Execute
public void execute() {
Expand All @@ -40,7 +44,7 @@ public void execute() {
ICoverage coverage = null;
if (block == blocks.get(CovidHandlerUtil.CFG_KK_BLOCKID)
|| block == blocks.get(CovidHandlerUtil.CFG_KK_PCR_BLOCKID)) {
coverage = CovidHandlerUtil.getCoverageWithLaw(patient, CovidHandlerUtil.KK_LAWS)
coverage = coverageService.getCoverageWithLaw(patient, CovidHandlerUtil.KK_LAWS)
.orElse(null);
if (coverage == null) {
Display.getDefault()
Expand All @@ -49,7 +53,7 @@ public void execute() {
"Es wurde noch kein Fall mit Gesetz KVG angelegt."));
}
} else {
coverage = CovidHandlerUtil.getCoverageWithLaw(patient, CovidHandlerUtil.SZ_LAWS)
coverage = coverageService.getCoverageWithLaw(patient, CovidHandlerUtil.SZ_LAWS)
.orElse(null);
if (coverage == null) {
coverage = createPrivateCoverage(patient);
Expand Down

0 comments on commit 0f6227d

Please sign in to comment.