Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[26834] mediorder - create medication label for rowa #768

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,7 @@ public class Messages extends NLS {
public static String Core_Ok;
public static String Core_Open;
public static String Core_Open_Template;
public static String Core_Order;
public static String Core_Organisation;
public static String Core_Other;
public static String Core_Output_Invoice;
Expand Down Expand Up @@ -5077,6 +5078,7 @@ public class Messages extends NLS {
public static String Button_UpdateCharts;
public static String Checkbox_ShowLegend;
public static String Article_Medic_Label;
public static String Rowa_Article_Medic_Label;
public static String Appointment_TrminLinks;
public static String CombinedAppointments_Titel;
public static String CombinedAppointments_ToolTipText;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2065,6 +2065,8 @@ Core_Open = open

Core_Open_Template = Vorlage \u00F6ffnen

Core_Order = Ordered

Core_Organisation = Organisation

Core_Other = Andere
Expand Down Expand Up @@ -8499,6 +8501,8 @@ RochePreferencePage_showColumnDescription = Beschreibung Spalte anzeigen

RochePreferencePage_showMaxColumns = Anzahl anzuzeigender Spalten (0 unbegrenzt)

Rowa_Article_Medic_Label = Article label with medication for rowa

RowDisplay_overview = \u00DCbersicht

SERVICES_DESCRIPTION = Shows an overview of which service was provided how many times.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2053,6 +2053,8 @@ Core_Open = \u00D6ffnen

Core_Open_Template = Vorlage \u00F6ffnen

Core_Order = Bestellt

Core_Organisation = Organisation

Core_Other = Andere
Expand Down Expand Up @@ -8461,6 +8463,8 @@ RochePreferencePage_showColumnDescription = Beschreibung Spalte anzeigen

RochePreferencePage_showMaxColumns = Anzahl anzuzeigender Spalten (0 unbegrenzt)

Rowa_Article_Medic_Label = Artikel-Etikette mit Medikation f\u00FCr Rowa

RowDisplay_overview = \u00DCbersicht

SERVICES_DESCRIPTION = Zeigt welche Leistungen wie h\u00E4ufig erbracht wurden.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2013,6 +2013,8 @@ Core_Open = to open

Core_Open_Template = Open template

Core_Order = Ordered

Core_Organisation = organization

Core_Other = Other
Expand Down Expand Up @@ -8371,6 +8373,8 @@ RochePreferencePage_showColumnDescription = Beschreibung Spalte anzeigen

RochePreferencePage_showMaxColumns = Anzahl anzuzeigender Spalten (0 unbegrenzt)

Rowa_Article_Medic_Label = Article label with medication for rowa

RowDisplay_overview = Overview

SERVICES_DESCRIPTION = Shows an overview of which service was provided how many times.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2009,6 +2009,8 @@ Core_Open = Ouvrir

Core_Open_Template = Mod\u00E8le ouvert

Core_Order = Commande

Core_Organisation = Organisation

Core_Other = Autre
Expand Down Expand Up @@ -8295,6 +8297,8 @@ RochePreferencePage_showColumnDescription = Beschreibung Spalte anzeigen

RochePreferencePage_showMaxColumns = Anzahl anzuzeigender Spalten (0 unbegrenzt)

Rowa_Article_Medic_Label = \u00E9tiquette d'article avec m\u00E9dication pour Rowa

RowDisplay_overview = enqu\u00EAte

SERVICES_DESCRIPTION = Shows an overview of which service was provided how many times.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,8 @@ Core_Open = Aprire

Core_Open_Template = Modello aperto

Core_Order = Ordinato

Core_Organisation = Organizzazione

Core_Other = Altro
Expand Down Expand Up @@ -8297,6 +8299,8 @@ RochePreferencePage_showColumnDescription = Beschreibung Spalte anzeigen

RochePreferencePage_showMaxColumns = Anzahl anzuzeigender Spalten (0 unbegrenzt)

Rowa_Article_Medic_Label = Etichettatura degli articoli con farmaci per Rowa

RowDisplay_overview = sondaggio

SERVICES_DESCRIPTION = Shows an overview of which service was provided how many times.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,5 +292,6 @@ public class Messages {
public static String Core_EAN = ch.elexis.core.l10n.Messages.Core_EAN;
public static String UI_description = ch.elexis.core.l10n.Messages.UI_description;
public static String Core_Stock = ch.elexis.core.l10n.Messages.Core_Stock;
public static String Core_Order = ch.elexis.core.l10n.Messages.Core_Order;

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;

import javax.inject.Inject;

import org.apache.commons.lang3.StringUtils;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.e4.ui.di.UIEventTopic;
import org.eclipse.jface.dialogs.IDialogConstants;
Expand All @@ -28,10 +31,10 @@
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.CheckboxCellEditor;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ColumnPixelData;
import org.eclipse.jface.viewers.ColumnViewerEditor;
import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.FocusCellOwnerDrawHighlighter;
import org.eclipse.jface.viewers.IStructuredContentProvider;
Expand Down Expand Up @@ -62,6 +65,9 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.handlers.IHandlerService;

import ch.elexis.core.common.ElexisEventTopics;
import ch.elexis.core.constants.Preferences;
Expand Down Expand Up @@ -101,6 +107,10 @@ public class OrderImportDialog extends TitleAreaDialog {
public static int ACTION_MODE_REGISTER = 0; // Einbuchungsmodus
public static int ACTION_MODE_INVENTORY = 1; // Inventurmodus

public static final String ROWA_ARTICLE_MEDICATION_LABEL_ID = "ch.itmed.fop.printing.command.RowaArticleMedicationLabelHandler";
public static final String ROWA_ARTICL_MEDICATION_LABEL_PATIENT = "rowa_article_medication_label_patient";
public static final String ROWA_ARTICL_MEDICATION_LABEL_ARTICLE = "rowa_article_medication_label_article";

@Inject
private IContextService contextService;

Expand Down Expand Up @@ -151,7 +161,7 @@ public OrderImportDialog(Shell parentShell, IOrder order, int actionMode) {
IStockEntry stockEntry = StockServiceHolder.get().findStockEntryForArticleInStock(stock,
StoreToStringServiceHolder.getStoreToString(entry.getArticle()));
if (stockEntry != null) {
OrderElement orderElement = new OrderElement(entry, stockEntry, entry.getAmount());
OrderElement orderElement = new OrderElement(entry, stockEntry, 0);
orderElements.add(orderElement);
}
} else {
Expand Down Expand Up @@ -327,7 +337,7 @@ private void createViewerColumns() {
/* OK (checkbox column) */
column = new TableViewerColumn(viewer, SWT.LEFT);
column.getColumn().setText(Messages.Core_ok);
tcLayout.setColumnData(column.getColumn(), new ColumnPixelData(50, true, true));
tcLayout.setColumnData(column.getColumn(), new ColumnWeightData(10, 30, true));
column.setLabelProvider(new CheckboxLabelProvider());
column.setEditingSupport(new EditingSupport(viewer) {
public boolean canEdit(Object element) {
Expand All @@ -353,16 +363,24 @@ public void setValue(Object element, Object value) {
if (value instanceof Boolean) {
Boolean bValue = (Boolean) value;
orderElement.setVerified(bValue.booleanValue());
if (!bValue) {
orderElement.setOrderState(OrderEntryState.OPEN.getValue());
}
}
viewer.update(orderElement, null);
}
}
});
/* Amount Ordered */
column = new TableViewerColumn(viewer, SWT.LEFT);
column.getColumn().setText(Messages.Core_Order);
tcLayout.setColumnData(column.getColumn(), new ColumnWeightData(10, 50, true));
column.setLabelProvider(new OrderedLabelProvider());

/* Amount delivered */
column = new TableViewerColumn(viewer, SWT.LEFT);
column.getColumn().setText(Messages.BestellView_delivered);
tcLayout.setColumnData(column.getColumn(), new ColumnPixelData(60, true, true));
tcLayout.setColumnData(column.getColumn(), new ColumnWeightData(10, 60, true));
column.setLabelProvider(new AmountLabelProvider());
column.setEditingSupport(new EditingSupport(viewer) {
public boolean canEdit(Object element) {
Expand Down Expand Up @@ -403,30 +421,30 @@ public void setValue(Object element, Object value) {
/* Amount on stock */
column = new TableViewerColumn(viewer, SWT.LEFT);
column.getColumn().setText(Messages.BestellView_inventory);
tcLayout.setColumnData(column.getColumn(), new ColumnPixelData(60, true, true));
tcLayout.setColumnData(column.getColumn(), new ColumnWeightData(10, 60, true));
column.setLabelProvider(new StockLabelProvider());

/* Pharamcode */
column = new TableViewerColumn(viewer, SWT.LEFT);
column.getColumn().setText(Messages.Core_Phamacode);
tcLayout.setColumnData(column.getColumn(), new ColumnPixelData(70, true, true));
tcLayout.setColumnData(column.getColumn(), new ColumnWeightData(20, 100, true));
column.setLabelProvider(new PharamcodeLabelProvider());

/* EAN */
column = new TableViewerColumn(viewer, SWT.LEFT);
column.getColumn().setText(Messages.Core_EAN);
tcLayout.setColumnData(column.getColumn(), new ColumnPixelData(70, true, true));
tcLayout.setColumnData(column.getColumn(), new ColumnWeightData(20, 100, true));
column.setLabelProvider(new EANLabelProvider());

/* Description */
column = new TableViewerColumn(viewer, SWT.LEFT);
column.getColumn().setText(Messages.UI_description);
tcLayout.setColumnData(column.getColumn(), new ColumnPixelData(200, true, true));
tcLayout.setColumnData(column.getColumn(), new ColumnWeightData(30, 170, true));
column.setLabelProvider(new DescriptionLabelProvider());

column = new TableViewerColumn(viewer, SWT.LEFT);
column.getColumn().setText(Messages.Core_Stock);
tcLayout.setColumnData(column.getColumn(), new ColumnPixelData(100, true, true));
tcLayout.setColumnData(column.getColumn(), new ColumnWeightData(20, 100, true));
column.setLabelProvider(new StockNameLabelProvider());

}
Expand Down Expand Up @@ -493,9 +511,10 @@ private void applyScanner(String gtin, int diff, IArticle article) {
diffSpinner.setSelection(DIFF_SPINNER_DEFAULT);

OrderElement orderElement = findOrderElementByEAN(gtin);
if (orderElement != null) {
if (orderElement != null && !orderElement.getOrderState().equals(OrderEntryState.DONE)) {
int newAmount = orderElement.getAmount() + diff;
updateOrderElement(orderElement, newAmount);
executeMediorderPrintLabel(orderElement, gtin);
} else {
if (actionMode == ACTION_MODE_INVENTORY) {
String mandatorId = ContextServiceHolder.get().getActiveMandator().get().getId();
Expand All @@ -513,6 +532,23 @@ private void applyScanner(String gtin, int diff, IArticle article) {
viewer.refresh();
}

private void executeMediorderPrintLabel(OrderElement orderElement, String gtin) {
ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class);
Command printMediorderLabel = commandService.getCommand(ROWA_ARTICLE_MEDICATION_LABEL_ID);

HashMap<String, String> params = new HashMap<>();
params.put(ROWA_ARTICL_MEDICATION_LABEL_PATIENT, orderElement.getStockEntry().getStock().getOwner().getId());
params.put(ROWA_ARTICL_MEDICATION_LABEL_ARTICLE, gtin);

try {
ParameterizedCommand parametrizedCommmand = ParameterizedCommand.generateCommand(printMediorderLabel,
params);
PlatformUI.getWorkbench().getService(IHandlerService.class).executeCommand(parametrizedCommmand, null);
} catch (Exception e) {
throw new RuntimeException(ROWA_ARTICLE_MEDICATION_LABEL_ID + " not found", e);
}
}

@Inject
public void barcodeEvent(@org.eclipse.e4.core.di.annotations.Optional @UIEventTopic(ElexisEventTopics.BASE_EVENT
+ "barcodeinput") Object object, IContextService contextService) {
Expand All @@ -529,7 +565,8 @@ private OrderElement findOrderElementByEAN(String ean) {
}

for (OrderElement orderElement : orderElements) {
if (orderElement.getArticle().getGtin().equals(ean)) {
if (!orderElement.getOrderState().equals(OrderEntryState.MARKED)
&& orderElement.getArticle().getGtin().equals(ean)) {
return orderElement;
}
}
Expand All @@ -543,6 +580,11 @@ private void updateOrderElement(OrderElement orderElement, int newAmount) {
if (ACTION_MODE_INVENTORY != actionMode) {
orderElement.setVerified(true);
}

if (orderElements.contains(orderElement)
&& orderElement.getAmount() == orderElement.getOrderEntry().getAmount()) {
orderElement.setOrderState(OrderEntryState.MARKED.getValue());
}
viewer.update(orderElement, null);
}

Expand Down Expand Up @@ -679,6 +721,17 @@ public String getText(Object element) {
}
}

private class OrderedLabelProvider extends BaseLabelProvider {
public String getText(Object element) {
String text = StringUtils.EMPTY;
if (element instanceof OrderElement) {
OrderElement orderElement = (OrderElement) element;
text = String.valueOf(orderElement.getOrderEntry().getAmount());
}
return text;
}
}

private class AmountLabelProvider extends BaseLabelProvider {
public String getText(Object element) {
String text = StringUtils.EMPTY;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ch.elexis.core.model;

public enum OrderEntryState {
OPEN(0), ORDERED(1), PARTIAL_DELIVER(2), DONE(3);
OPEN(0), ORDERED(1), PARTIAL_DELIVER(2), DONE(3), MARKED(4);

private final Integer value;

Expand Down