-
Notifications
You must be signed in to change notification settings - Fork 32
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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; | ||
|
@@ -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; | ||
|
@@ -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; | ||
|
||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bitte kurz erklären warum hier 0? |
||
orderElements.add(orderElement); | ||
} | ||
} else { | ||
|
@@ -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) { | ||
|
@@ -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) { | ||
|
@@ -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()); | ||
|
||
} | ||
|
@@ -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)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dreh das um, wenn du Variable.equals(Constant) hast, dann machst du im sinne der defensiven Programmierung immer Constant.equals(Variable) - sollte kein Problem sein wenn getOrderState() wohldefiniert ist, ist aber guter Stil! |
||
int newAmount = orderElement.getAmount() + diff; | ||
updateOrderElement(orderElement, newAmount); | ||
executeMediorderPrintLabel(orderElement, gtin); | ||
} else { | ||
if (actionMode == ACTION_MODE_INVENTORY) { | ||
String mandatorId = ContextServiceHolder.get().getActiveMandator().get().getId(); | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oben in dieser Classe wird ein |
||
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) { | ||
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. siehe oben |
||
&& orderElement.getArticle().getGtin().equals(ean)) { | ||
return orderElement; | ||
} | ||
} | ||
|
@@ -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()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
} | ||
viewer.update(orderElement, null); | ||
} | ||
|
||
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. diesen Cast kannst du dir sparen, das kannst du auch mit |
||
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; | ||
|
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was bedeutet MARKED? Wie bindet sich das in den Workflow Ablauf ein? |
||
|
||
private final Integer value; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wir sollten generell im System wegkommen von den Holder Klassen. Versuch bitte, ob du das auch über
@Inject
kriegen kannst. Siehe auch Kommentare unten.