Skip to content

Commit

Permalink
[26233] LG1 - medicalvalues OE Plugin - display error messages and se…
Browse files Browse the repository at this point in the history
…nd additional data (#341)
  • Loading branch information
MKmedicalvalues authored and huthomas committed Jul 24, 2024
1 parent ff9ec74 commit a65d509
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;

import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.PartInitException;
Expand Down Expand Up @@ -36,52 +37,54 @@
public class LabOrderAction extends Action {

public LabOrderAction() {
setId("ch.elexis.laborder.lg1_medicalvalues.laborder"); //$NON-NLS-1$
setId("ch.elexis.laborder.lg1_medicalvalues.laborder"); //$NON-NLS-1$
setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin("ch.elexis.labororder.lg1_medicalvalues", //$NON-NLS-1$
"rsc/lg1_logo.png"));
"rsc/lg1_logo.png"));
setText(Messages.LabOrderAction_nameAction);
}

@Override
public void run() {
IPatient patient = ContextServiceHolder.get().getActivePatient().get();
if (patient != null) {
try {
URL url = buildOrderCreationUrl(patient);

PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(url);
} catch (NoEncounterSelectedException e) {
MessageDialog.openError(Display.getDefault().getActiveShell(),
Messages.LabOrderAction_errorTitleNoFallSelected,
Messages.LabOrderAction_errorMessageNoFallSelected);
} catch (URISyntaxException | MalformedURLException e) {
LoggerFactory.getLogger(getClass()).error("Error building medicalvalues order creation API URL", e);
MessageDialog.openError(Display.getDefault().getActiveShell(), "Fehler",
"Es ist ein Fehler beim Erstellen der URL für die Auftragserstellung aufgetreten.\n\n" + e.getLocalizedMessage());
} catch (IOException e) {
LoggerFactory.getLogger(getClass()).error("Error contacting LG1 web service", e);
MessageDialog.openError(Display.getDefault().getActiveShell(), "Fehler",
"Es ist ein Fehler beim LG1 Aufruf aufgetreten.\n\n" + e.getLocalizedMessage());
} catch (PartInitException e) {
LoggerFactory.getLogger(getClass()).error("Error opening browser with medicalvalues order creation API URL", e);
MessageDialog.openError(Display.getDefault().getActiveShell(), "Fehler",
"Es ist ein Fehler beim Öffnen des Browsers aufgetreten.\n\n" + e.getLocalizedMessage());
} catch (IllegalArgumentException e) {
LoggerFactory.getLogger(getClass()).error("Error calling medicalvalues order creation API", e);
MessageDialog.openError(Display.getDefault().getActiveShell(), "Fehler",
"Es fehlen zur Auftragserstellung benötigte Patientendaten.\n\n" + e.getLocalizedMessage());
}
} else {
MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Fehler",
"Es ist kein Patient ausgewählt.");
try {
IPatient patient = ContextServiceHolder.get().getActivePatient().get();
URL url = buildOrderCreationUrl(patient);

PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(url);
} catch (NoSuchElementException e) {
MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Fehler",
"Es ist kein Patient ausgewählt.");
} catch (NoEncounterSelectedException e) {
MessageDialog.openInformation(Display.getDefault().getActiveShell(),
Messages.LabOrderAction_errorTitleNoFallSelected,
Messages.LabOrderAction_errorMessageNoFallSelected);
} catch (URISyntaxException | MalformedURLException e) {
LoggerFactory.getLogger(getClass()).error("Error building medicalvalues order creation API URL", e);
MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Fehler",
"Es ist ein Fehler beim Erstellen der URL für die Auftragserstellung aufgetreten.\n\n"
+ e.getLocalizedMessage());
} catch (IOException e) {
LoggerFactory.getLogger(getClass()).error("Error contacting LG1 web service", e);
MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Fehler",
"Es ist ein Fehler beim LG1 Aufruf aufgetreten.\n\n" + e.getLocalizedMessage());
} catch (PartInitException e) {
LoggerFactory.getLogger(getClass())
.error("Error opening browser with medicalvalues order creation API URL", e);
MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Fehler",
"Es ist ein Fehler beim Öffnen des Browsers aufgetreten.\n\n" + e.getLocalizedMessage());
} catch (IllegalArgumentException e) {
LoggerFactory.getLogger(getClass()).error("Error calling medicalvalues order creation API", e);
MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Fehler",
"Es fehlen zur Auftragserstellung benötigte Patientendaten.\n\n" + e.getLocalizedMessage());
}
}

private URL buildOrderCreationUrl(IPatient patient) throws URISyntaxException, MalformedURLException, NoEncounterSelectedException {
URIBuilder builder = new URIBuilder("https://oe.lg1.ch/de/diagnostic-intelligence/orders/importPatientAndCreateOrder");
private URL buildOrderCreationUrl(IPatient patient)
throws URISyntaxException, MalformedURLException, NoEncounterSelectedException {
URIBuilder builder = new URIBuilder(
"https://oe.lg1.ch/de/diagnostic-intelligence/orders/importPatientAndCreateOrder");

Patient lg1Patient = Patient.of(patient);
lg1Patient.toMedicalvaluesOrderCreationAPIQueryParams(builder);
Patient lg1Patient = Patient.of(patient);
lg1Patient.toMedicalvaluesOrderCreationAPIQueryParams(builder);

return builder.build().toURL();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import java.util.Optional;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.NoSuchElementException;
import java.util.Objects;

import java.time.format.DateTimeFormatter;

Expand Down Expand Up @@ -47,10 +49,12 @@ public class Patient {
String country = StringUtils.EMPTY;
String telephoneNumberHome = StringUtils.EMPTY;
String mobilePhoneNumber = StringUtils.EMPTY;
String email = StringUtils.EMPTY;
String insurancenumber = StringUtils.EMPTY;
String insurancename = StringUtils.EMPTY;
String insurancegln = StringUtils.EMPTY;
String billing = StringUtils.EMPTY;
String reason = StringUtils.EMPTY;
String socialSecurityNumber = StringUtils.EMPTY;
String physicianGlnNumber = StringUtils.EMPTY;

Expand Down Expand Up @@ -91,24 +95,29 @@ public static Patient of(IPatient patient) throws NoEncounterSelectedException {

ret.telephoneNumberHome = patient.getPhone1();
ret.mobilePhoneNumber = patient.getMobile();
ret.email = patient.getEmail();

ICoverage coverage = ContextServiceHolder.get().getActiveCoverage().get();
Optional<ICoverage> coverage = ContextServiceHolder.get().getActiveCoverage();
ICoverage activeCoverage = null;

if (coverage == null) {
if (coverage.isPresent()) {
activeCoverage = coverage.get();
} else {
throw new NoEncounterSelectedException();
}

ret.insurancenumber = coverage.getInsuranceNumber();
ret.insurancenumber = activeCoverage.getInsuranceNumber();

IContact costBearer = coverage.getCostBearer();
IContact costBearer = activeCoverage.getCostBearer();
ret.insurancename = costBearer.getDescription1();

IXid costBearerEAN = costBearer.getXid(XidConstants.EAN);
if (costBearerEAN != null) {
ret.insurancegln = costBearerEAN.getDomainId();
}

ret.billing = getBilling(coverage);
ret.billing = getBilling(activeCoverage);
ret.reason = getReason(activeCoverage);

IXid patientAHV = patient.getXid(XidConstants.CH_AHV);
if (patientAHV != null) {
Expand All @@ -134,7 +143,7 @@ public void toMedicalvaluesOrderCreationAPIQueryParams(URIBuilder builder) throw
setRequiredParameterOrThrow(builder, "patient_name_given", "Vorname", this.firstname);
setRequiredParameterOrThrow(builder, "patient_name_family", "Nachname", this.lastname);
setRequiredParameterOrThrow(builder, "patient_birthDate", "Geburtsdatum", this.dateofbirth);
setRequiredParameterOrThrow(builder, "patient_gender", "Geschlecht",this.gender);
setRequiredParameterOrThrow(builder, "patient_gender", "Geschlecht", this.gender);
setRequiredParameterOrThrow(builder, "coverage_type", "Abrechnungsart", this.billing);

setOptionalParameter(builder, "patient_name_title", this.title);
Expand All @@ -146,12 +155,15 @@ public void toMedicalvaluesOrderCreationAPIQueryParams(URIBuilder builder) throw
setOptionalParameter(builder, "patient_address_country", this.country);
setOptionalParameter(builder, "patient_telecom_home", this.telephoneNumberHome);
setOptionalParameter(builder, "patient_telecom_mobile", this.mobilePhoneNumber);
setOptionalParameter(builder, "patient_email", this.email);
setOptionalParameter(builder, "coverage_payor_display", this.insurancename);
setOptionalParameter(builder, "coverage_payor_identifier", this.insurancegln);
setOptionalParameter(builder, "coverage_identifier", this.insurancenumber);
setOptionalParameter(builder, "order_treatment_type", this.reason);
}

private void setRequiredParameterOrThrow(URIBuilder builder, String key, String readableKey, String value) throws IllegalArgumentException {
private void setRequiredParameterOrThrow(URIBuilder builder, String key, String readableKey, String value)
throws IllegalArgumentException {
if (value == null || value.isEmpty()) {
throw new IllegalArgumentException(readableKey);
}
Expand All @@ -165,12 +177,12 @@ private void setOptionalParameter(URIBuilder builder, String key, String value)
}
}

private static String getBilling(ICoverage coverage){
private static String getBilling(ICoverage coverage) {
BillingLaw billingLaw = coverage.getBillingSystem().getLaw();
if (billingLaw == BillingLaw.VVG ||
billingLaw == BillingLaw.MV ||
billingLaw == BillingLaw.IV ||
billingLaw == BillingLaw.KVG) {
billingLaw == BillingLaw.MV ||
billingLaw == BillingLaw.IV ||
billingLaw == BillingLaw.KVG) {
return "SwissIns";
}
if (billingLaw == BillingLaw.UVG) {
Expand All @@ -182,4 +194,23 @@ private static String getBilling(ICoverage coverage){

return "SEL";
}

private static String getReason(ICoverage coverage) {
String reason = coverage.getReason();

if (Objects.equals(reason, "Krankheit")) {
return "1";
}
if (Objects.equals(reason, "Mutterschaft")) {
return "2";
}
if (Objects.equals(reason, "Unfall")) {
return "3";
}
if (Objects.equals(reason, "Prävention")) {
return "4";
}

return StringUtils.EMPTY;
}
}

0 comments on commit a65d509

Please sign in to comment.