Commit 2152dc0d authored by thomas's avatar thomas
Browse files

[11481] re charge tarmed on kons fall transfer

parent 8692c996
Pipeline #5190 passed with stages
in 2 minutes and 11 seconds
......@@ -16,8 +16,10 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import ch.elexis.admin.AccessControlDefaults;
import ch.elexis.core.constants.Preferences;
......@@ -27,10 +29,15 @@ import ch.elexis.core.data.events.ElexisEventDispatcher;
import ch.elexis.core.data.interfaces.IOptifier;
import ch.elexis.core.data.interfaces.IVerrechenbar;
import ch.elexis.core.data.interfaces.events.MessageEvent;
import ch.elexis.core.data.service.CodeElementServiceHolder;
import ch.elexis.core.data.status.ElexisStatus;
import ch.elexis.core.exceptions.PersistenceException;
import ch.elexis.core.model.ICodeElement;
import ch.elexis.core.model.IDiagnose;
import ch.elexis.core.model.IPersistentObject;
import ch.elexis.core.model.prescription.EntryType;
import ch.elexis.core.services.ICodeElementService;
import ch.elexis.core.services.ICodeElementService.ContextKeys;
import ch.elexis.core.text.model.Samdas;
import ch.rgw.tools.ExHandler;
import ch.rgw.tools.JdbcLink;
......@@ -123,15 +130,37 @@ public class Konsultation extends PersistentObject implements Comparable<Konsult
Fall alt = getFall();
set(FLD_CASE_ID, f.getId());
if (alt != null) {
ICodeElementService codeElementService = CodeElementServiceHolder.getService();
HashMap<Object, Object> context = getCodeElementServiceContext();
List<Verrechnet> vv = getLeistungen();
for (Verrechnet verrechnet : vv) {
if (setToStandartPreis) {
verrechnet.setStandardPreis();
} else {
IVerrechenbar v = verrechnet.getVerrechenbar();
TimeTool date = new TimeTool(verrechnet.getKons().getDatum());
double factor = v.getFactor(date, f);
verrechnet.set(Verrechnet.SCALE_SELLING, Double.toString(factor));
// tarmed needs to be recharged
if (isTarmed(verrechnet)) {
// make sure verrechenbar is matching for the kons
Optional<ICodeElement> matchingVerrechenbar = codeElementService
.createFromString(v.getCodeSystemName(), v.getCode(), context);
if (matchingVerrechenbar.isPresent()) {
int amount = verrechnet.getZahl();
removeLeistung(verrechnet);
for (int i = 0; i < amount; i++) {
addLeistung((IVerrechenbar) matchingVerrechenbar.get());
}
} else {
MessageEvent.fireInformation("Info",
"Achtung: durch den Fall wechsel wurde die Position "
+ v.getCode()
+ " automatisch entfernt, da diese im neuen Fall nicht vorhanden ist.");
removeLeistung(verrechnet);
}
} else {
TimeTool date = new TimeTool(verrechnet.getKons().getDatum());
double factor = v.getFactor(date, f);
verrechnet.set(Verrechnet.SCALE_SELLING, Double.toString(factor));
}
}
}
}
......@@ -139,6 +168,21 @@ public class Konsultation extends PersistentObject implements Comparable<Konsult
}
}
private HashMap<Object, Object> getCodeElementServiceContext(){
HashMap<Object, Object> ret = new HashMap<>();
ret.put(ContextKeys.CONSULTATION, this);
IPersistentObject coverage = getFall();
if (coverage != null) {
ret.put(ContextKeys.COVERAGE, coverage);
}
return ret;
}
private boolean isTarmed(Verrechnet verrechnet){
String fullname = verrechnet.get(Verrechnet.CLASS);
return fullname.contains("TarmedLeistung");
}
/** Eine neue Konsultation zu einem Fall erstellen */
public Konsultation(Fall fall){
if (fall == null) {
......
......@@ -796,8 +796,7 @@ public class KonsDetailView extends ViewPart
Messages.KonsDetailView_No
}, 0); // $NON-NLS-1$
if (msd.open() == Window.OK) {
actKons.setFall(nFall);
setKons(actKons);
actKons.transferToFall(nFall, false, false);
} else {
ignoreSelectionEventOnce();
comboViewerFall.setSelection(new StructuredSelection(actFall));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment