Skip to content

Commit 51851de

Browse files
Daksic28huthomas
authored andcommitted
[28317] Kontaktfelder validiert und Kürzel gesperrt (#943)
1 parent 35d1a42 commit 51851de

8 files changed

Lines changed: 343 additions & 15 deletions

File tree

bundles/ch.elexis.core.data/src/ch/elexis/core/data/util/NoPoUtil.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,11 @@ public static String getElexisDateSearchString(String value) {
233233
int dotCount = StringUtils.countMatches(ret, ".");
234234
String[] parts = ret.split("\\.");
235235
StringJoiner sj = new StringJoiner(StringUtils.EMPTY);
236-
for (String string : parts) {
237-
if (string.length() == 1 && Character.isDigit(string.charAt(0))) {
236+
for (int p = 0; p < parts.length; p++) {
237+
String string = parts[p];
238+
// the year part must not be padded, otherwise a partial year like the
239+
// "1" in "15.10.1" would become "01" and shift the whole pattern
240+
if (p < 2 && string.length() == 1 && Character.isDigit(string.charAt(0))) {
238241
sj.add("0" + string);
239242
} else {
240243
sj.add(string);

bundles/ch.elexis.core.ui.contacts/src/ch/elexis/core/ui/contacts/dialogs/PatientErfassenDialog.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import ch.elexis.core.services.holder.CoreModelServiceHolder;
4343
import ch.elexis.core.types.Gender;
4444
import ch.elexis.core.ui.UiDesk;
45+
import ch.elexis.core.ui.contacts.views.util.FilterFieldInputRestrictions;
4546
import ch.elexis.core.ui.icons.ImageSize;
4647
import ch.elexis.core.ui.icons.Images;
4748
import ch.elexis.core.ui.util.SWTHelper;
@@ -98,7 +99,7 @@ protected Control createDialogArea(final Composite parent) {
9899
updateOkButtonState();
99100
});
100101
new Label(ret, SWT.NONE).setText(Messages.Sex); // $NON-NLS-1$
101-
cbSex = new Combo(ret, SWT.SINGLE);
102+
cbSex = new Combo(ret, SWT.SINGLE | SWT.READ_ONLY);
102103
String toolTip = String.format(Messages.Patient_male_female_tooltip, Messages.Patient_male_short,
103104
Messages.Patient_female_short, Messages.Patient_male_long, Messages.Patient_female_long);
104105
cbSex.setToolTipText(toolTip);
@@ -112,6 +113,7 @@ protected Control createDialogArea(final Composite parent) {
112113
tGebDat = new Text(ret, SWT.BORDER);
113114
tGebDat.setText(getField(Patient.FLD_DOB));
114115
tGebDat.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
116+
FilterFieldInputRestrictions.applyBirthdateFilterFormatting(tGebDat, true);
115117

116118
new Label(ret, SWT.NONE).setText(Messages.Core_Street); // $NON-NLS-1$
117119
tStrasse = new Text(ret, SWT.BORDER);

bundles/ch.elexis.core.ui.contacts/src/ch/elexis/core/ui/contacts/views/KontaktBlatt.java

Lines changed: 70 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
import org.eclipse.e4.core.di.annotations.Optional;
1919
import org.eclipse.e4.ui.di.UIEventTopic;
2020
import org.eclipse.jface.dialogs.MessageDialog;
21+
import org.eclipse.jface.viewers.ArrayContentProvider;
22+
import org.eclipse.jface.viewers.LabelProvider;
23+
import org.eclipse.jface.viewers.StructuredSelection;
2124
import org.eclipse.swt.SWT;
2225
import org.eclipse.swt.events.ModifyEvent;
2326
import org.eclipse.swt.events.ModifyListener;
@@ -27,6 +30,7 @@
2730
import org.eclipse.swt.layout.FillLayout;
2831
import org.eclipse.swt.layout.GridLayout;
2932
import org.eclipse.swt.widgets.Button;
33+
import org.eclipse.swt.widgets.Combo;
3034
import org.eclipse.swt.widgets.Composite;
3135
import org.eclipse.swt.widgets.Control;
3236
import org.eclipse.swt.widgets.Event;
@@ -61,6 +65,7 @@
6165
import ch.elexis.core.services.holder.ContextServiceHolder;
6266
import ch.elexis.core.services.holder.StoreToStringServiceHolder;
6367
import ch.elexis.core.ui.UiDesk;
68+
import ch.elexis.core.ui.contacts.views.util.FilterFieldInputRestrictions;
6469
import ch.elexis.core.ui.dialogs.AnschriftEingabeDialog;
6570
import ch.elexis.core.ui.dialogs.KontaktExtDialog;
6671
import ch.elexis.core.ui.e4.util.CoreUiUtil;
@@ -70,6 +75,7 @@
7075
import ch.elexis.core.ui.util.LabeledInputField.AutoForm;
7176
import ch.elexis.core.ui.util.LabeledInputField.InputData;
7277
import ch.elexis.core.ui.util.LabeledInputField.InputData.Typ;
78+
import ch.elexis.core.ui.util.LabeledInputField.IStructuredSelectionResolver;
7379
import ch.elexis.core.ui.util.SWTHelper;
7480
import ch.elexis.core.ui.views.IRefreshable;
7581
import ch.elexis.data.Kontakt;
@@ -85,6 +91,7 @@
8591
public class KontaktBlatt extends Composite implements IRefreshable, IUnlockable {
8692

8793
private static final String IS_USER = "istAnwender"; //$NON-NLS-1$
94+
private static final String IS_PATIENT = "istPatient"; //$NON-NLS-1$
8895

8996
private static final String MOBIL = Messages.Core_Mobilephone; // $NON-NLS-1$
9097
private static final String VORNAME = Messages.Core_Firstname; // $NON-NLS-1$
@@ -93,8 +100,8 @@ public class KontaktBlatt extends Composite implements IRefreshable, IUnlockable
93100
private static final String ANSPRECHPERSON = Messages.ContactPerson; // $NON-NLS-1$
94101
private static final String ZUSATZ = Messages.Core_Additional; // $NON-NLS-1$
95102
private static final String BEZEICHNUNG = Messages.Core_Description; // $NON-NLS-1$
96-
static final String[] types = { "istOrganisation", "istLabor", "istPerson", "istPatient", IS_USER, "istMandant" //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$
97-
}; // $NON-NLS-6$
103+
static final String[] types = { "istOrganisation", "istLabor", "istPerson", IS_PATIENT, IS_USER, "istMandant" //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
104+
}; // $NON-NLS-5$
98105
static final String[] typLabels = { Messages.Core_Organisation, Messages.Core_Laboratory, Messages.Core_Person,
99106
Messages.Core_Patient, Messages.Core_User, Messages.Core_Mandator };
100107
private final Button[] bTypes = new Button[types.length];
@@ -103,6 +110,7 @@ public class KontaktBlatt extends Composite implements IRefreshable, IUnlockable
103110
private final ScrolledForm form;
104111
private final FormToolkit tk;
105112
AutoForm afDetails;
113+
private InputData genderCombo;
106114
Listener mandantListener, checkIfContactExistsListener, changeEmailListener;
107115

108116
@Inject
@@ -112,7 +120,23 @@ public class KontaktBlatt extends Composite implements IRefreshable, IUnlockable
112120
new InputData(Messages.Core_Name, Kontakt.FLD_NAME1, Typ.STRING, null),
113121
new InputData(Messages.Core_Firstname, Kontakt.FLD_NAME2, Typ.STRING, null),
114122
new InputData(Messages.KontaktBlatt_Bez3, Kontakt.FLD_NAME3, Typ.STRING, null),
115-
new InputData(Messages.Sex, Person.SEX, Typ.STRING, null),
123+
new InputData(Messages.Sex, Person.SEX, null, Typ.COMBO_VIEWER, ArrayContentProvider.getInstance(),
124+
new LabelProvider() {
125+
@Override
126+
public String getText(Object element) {
127+
return element == null ? StringUtils.EMPTY : element.toString();
128+
}
129+
}, new IStructuredSelectionResolver() {
130+
@Override
131+
public StructuredSelection resolveStructuredSelection(String value) {
132+
if (Person.FEMALE.equalsIgnoreCase(value)) {
133+
return new StructuredSelection(Person.FEMALE);
134+
} else if (Person.MALE.equalsIgnoreCase(value)) {
135+
return new StructuredSelection(Person.MALE);
136+
}
137+
return new StructuredSelection(StringUtils.EMPTY);
138+
}
139+
}, new String[] { StringUtils.EMPTY, Person.MALE, Person.FEMALE }),
116140
new InputData(Messages.KontaktBlatt_LawCode, Person.FLD_TITLE_SUFFIX, Typ.STRING, null),
117141
new InputData(Messages.Core_Street, Kontakt.FLD_STREET, Typ.STRING, null),
118142
new InputData(Messages.Core_Postal_code, Kontakt.FLD_ZIP, Typ.STRING, null, 6),
@@ -236,6 +260,7 @@ public KontaktBlatt(Composite parent, int style, IViewSite vs) {
236260
bottom.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
237261
actKontakt = (Kontakt) ElexisEventDispatcher.getSelected(Kontakt.class);
238262
afDetails = new AutoForm(bottom, def);
263+
restrictSexField();
239264
((ColumnLayout) afDetails.getLayout()).minNumColumns = 5;
240265
updateFieldsView();
241266
setToolTipTextListeners();
@@ -348,6 +373,16 @@ private void updateFieldsView() {
348373
}
349374
}
350375

376+
private void restrictSexField() {
377+
genderCombo = getInputFieldByLabel(Messages.Sex);
378+
if (genderCombo != null && genderCombo.getWidget() != null
379+
&& genderCombo.getWidget().getControl() instanceof Combo) {
380+
Combo cbSex = (Combo) genderCombo.getWidget().getControl();
381+
FilterFieldInputRestrictions.restrictToValuesIgnoreCase(cbSex, Person.MALE, Person.FEMALE);
382+
FilterFieldInputRestrictions.disableMouseWheel(cbSex);
383+
}
384+
}
385+
351386
/**
352387
* Adds listeners to the {@link LabeledInputField} components to update the
353388
* tooltip text when the content in the input field has been modified.
@@ -442,7 +477,7 @@ public void widgetSelected(SelectionEvent e) {
442477
setOrganisationFieldsVisible(false);
443478
if ("istPerson".equals(type)) { //$NON-NLS-1$
444479
select("0", "0", "1", "x", "x", "x"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
445-
} else if (type.equals("istPatient")) { //$NON-NLS-1$
480+
} else if (type.equals(IS_PATIENT)) {
446481
select("0", "0", "1", "1", "x", "x"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
447482
} else if (type.equals(IS_USER)) { // $NON-NLS-1$
448483
select("0", "0", "1", "x", "1", "x"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
@@ -453,6 +488,7 @@ public void widgetSelected(SelectionEvent e) {
453488
} else {
454489
actKontakt.set(type, "0"); //$NON-NLS-1$
455490
}
491+
updateShortLabelEditable();
456492
updateFieldsView();
457493
}
458494

@@ -476,6 +512,33 @@ private void setOrganisationFieldsVisible(boolean visible) {
476512
def[9].getWidget().setVisible(visible);
477513
}
478514

515+
private void updateShortLabelEditable() {
516+
InputData shortLabel = getInputFieldByLabel(Messages.KontaktBlatt_shortLabel);
517+
Button patientButton = getTypeButton(IS_PATIENT);
518+
if (shortLabel != null && shortLabel.getWidget() != null && patientButton != null) {
519+
boolean isPatient = patientButton.getSelection();
520+
shortLabel.getWidget().setEnabled(!isPatient);
521+
}
522+
}
523+
524+
private InputData getInputFieldByLabel(String label) {
525+
for (InputData d : def) {
526+
if (label.equals(d.getLabel())) {
527+
return d;
528+
}
529+
}
530+
return null;
531+
}
532+
533+
private Button getTypeButton(String type) {
534+
for (Button b : bTypes) {
535+
if (b != null && type.equals(b.getData())) {
536+
return b;
537+
}
538+
}
539+
return null;
540+
}
541+
479542
public void activation(boolean mode) {
480543
if (ElexisEventDispatcher.getSelected(Kontakt.class) == null) {
481544
setEnabled(false);
@@ -502,12 +565,6 @@ private void setKontakt(Kontakt kontakt) {
502565
bTypes[i].setSelection((ret[i] == null) ? false : StringConstants.ONE.equals(ret[i]));
503566
bTypes[i].setEnabled(updateRight);
504567
}
505-
if (bTypes[3].getSelection() == true) {
506-
// isPatient
507-
def[17].getWidget().setEnabled(false);
508-
} else {
509-
def[17].getWidget().setEnabled(true);
510-
}
511568
if (bTypes[0].getSelection() == true) {
512569
// isOrganisation
513570
def[0].setLabel(BEZEICHNUNG);
@@ -529,6 +586,9 @@ private void setKontakt(Kontakt kontakt) {
529586
updateFieldsView();
530587
form.reflow(true);
531588
setUnlocked(LocalLockServiceHolder.get().isLockedLocal(kontakt));
589+
if (actKontakt != null) {
590+
updateShortLabelEditable();
591+
}
532592

533593
addListener(actKontakt);
534594
}

bundles/ch.elexis.core.ui.contacts/src/ch/elexis/core/ui/contacts/views/PatListeContentProvider.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public class PatListeContentProvider extends CommonViewerContentProvider impleme
5252
Object[] pats;
5353
boolean bValid = false;
5454
boolean bUpdating = false;
55+
volatile boolean bReloadPending = false;
5556
String[] orderLabels;
5657
String[] orderFields;
5758
String firstOrder;
@@ -141,6 +142,11 @@ public void run() {
141142
commonViewer.setLimitReached(pats.length == QUERY_LIMIT, QUERY_LIMIT);
142143
}
143144
bUpdating = false;
145+
if (bReloadPending) {
146+
bReloadPending = false;
147+
bValid = false;
148+
getElements(null);
149+
}
144150
}
145151
});
146152
}
@@ -181,6 +187,10 @@ protected IStatus run(IProgressMonitor monitor) {
181187
public void changed(HashMap<String, String> values) {
182188
super.setIgnoreLimit(false);
183189
bValid = false;
190+
if (bUpdating) {
191+
bReloadPending = true;
192+
return;
193+
}
184194
// trigger loading pats
185195
getElements(null);
186196
}

bundles/ch.elexis.core.ui.contacts/src/ch/elexis/core/ui/contacts/views/PatientenListeView.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.eclipse.swt.layout.GridLayout;
4343
import org.eclipse.swt.widgets.Composite;
4444
import org.eclipse.swt.widgets.Display;
45+
import org.eclipse.swt.widgets.Text;
4546
import org.eclipse.ui.PlatformUI;
4647
import org.eclipse.ui.commands.ICommandService;
4748
import org.eclipse.ui.dialogs.PropertyDialogAction;
@@ -73,6 +74,7 @@
7374
import ch.elexis.core.ui.constants.UiResourceConstants;
7475
import ch.elexis.core.ui.contacts.command.StickerFilterCommand;
7576
import ch.elexis.core.ui.contacts.dialogs.PatientErfassenDialog;
77+
import ch.elexis.core.ui.contacts.views.util.FilterFieldInputRestrictions;
7678
import ch.elexis.core.ui.e4.util.CoreUiUtil;
7779
import ch.elexis.core.ui.icons.Images;
7880
import ch.elexis.core.ui.util.SWTHelper;
@@ -184,6 +186,7 @@ public void createPartControl(final Composite parent) {
184186
makeActions();
185187

186188
dcfp = new DefaultControlFieldProvider(cv, currentUserFields) {
189+
187190
@Override
188191
public void setQuery(IQuery<?> query) {
189192
for (int i = 0; i < dbFields.length; i++) {
@@ -199,6 +202,35 @@ public void setQuery(IQuery<?> query) {
199202
}
200203
}
201204
}
205+
206+
@Override
207+
public Composite createControl(final Composite parent) {
208+
Composite ret = super.createControl(parent);
209+
restrictFilterFields();
210+
return ret;
211+
}
212+
213+
@Override
214+
public void updateFields(String[] flds, boolean redraw) {
215+
super.updateFields(flds, redraw);
216+
if (redraw) {
217+
restrictFilterFields();
218+
}
219+
}
220+
221+
private void restrictFilterFields() {
222+
for (int i = 0; i < selectors.length; i++) {
223+
if (selectors[i] == null || !(selectors[i].getWidget() instanceof Text)) {
224+
continue;
225+
}
226+
Text field = (Text) selectors[i].getWidget();
227+
if ("code".equals(dbFields[i])) { //$NON-NLS-1$
228+
FilterFieldInputRestrictions.restrictToDigits(field);
229+
} else if ("dob".equals(dbFields[i])) { //$NON-NLS-1$
230+
FilterFieldInputRestrictions.applyBirthdateFilterFormatting(field);
231+
}
232+
}
233+
}
202234
};
203235
updateFocusField();
204236

bundles/ch.elexis.core.ui.contacts/src/ch/elexis/core/ui/contacts/views/Patientenblatt2.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
import ch.elexis.core.ui.actions.RestrictedAction;
122122
import ch.elexis.core.ui.contacts.dialogs.BezugsKontaktAuswahl;
123123
import ch.elexis.core.ui.contacts.views.util.CameraCaptureUtil;
124+
import ch.elexis.core.ui.contacts.views.util.FilterFieldInputRestrictions;
124125
import ch.elexis.core.ui.dialogs.AddBuchungDialog;
125126
import ch.elexis.core.ui.dialogs.AnschriftEingabeDialog;
126127
import ch.elexis.core.ui.dialogs.KontaktDetailDialog;
@@ -270,6 +271,7 @@ private void adaptForUser(IUser user) {
270271
private BillingDiagnosisComposite billingDiagnosisComponent;
271272

272273
private InputData comboGeschlecht;
274+
private InputData dobField;
273275
StickerComposite stickerComposite;
274276
private Button deceasedBtn;
275277
private CDateTime deceasedDate;
@@ -293,7 +295,8 @@ void recreateUserpanel() {
293295
fields = new ArrayList<>(20);
294296
fields.add(new InputData(Messages.Core_Name, Patient.FLD_NAME, InputData.Typ.STRING, null)); // $NON-NLS-1$
295297
fields.add(new InputData(Messages.Core_Firstname, Patient.FLD_FIRSTNAME, InputData.Typ.STRING, null)); // $NON-NLS-1$
296-
fields.add(new InputData(Messages.Core_Enter_Birthdate, Patient.BIRTHDATE, InputData.Typ.DATE, null)); // $NON-NLS-1$
298+
dobField = new InputData(Messages.Core_Enter_Birthdate, Patient.BIRTHDATE, InputData.Typ.DATE, null); // $NON-NLS-1$
299+
fields.add(dobField);
297300
IStructuredSelectionResolver ssr = new IStructuredSelectionResolver() {
298301
@Override
299302
public StructuredSelection resolveStructuredSelection(String value) {
@@ -523,6 +526,7 @@ public void reloadContent(Object po, InputData ltf) {
523526
ipp = new InputPanel(cUserfields, COLUMNCOUNT, COLUMNCOUNT, fields.toArray(new InputData[0]));
524527
ipp.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
525528
ipp.changed(ipp.getChildren());
529+
applyInputRestrictions();
526530
// cUserfields.setRedraw(true);
527531
cUserfields.setBounds(ipp.getBounds());
528532

@@ -536,6 +540,17 @@ public void reloadContent(Object po, InputData ltf) {
536540
layout(true);
537541
}
538542

543+
private void applyInputRestrictions() {
544+
if (dobField != null && dobField.getWidget() != null && dobField.getWidget().getControl() instanceof Text) {
545+
FilterFieldInputRestrictions.applyBirthdateFilterFormatting((Text) dobField.getWidget().getControl(), true);
546+
}
547+
if (comboGeschlecht != null && comboGeschlecht.getWidget() != null
548+
&& comboGeschlecht.getWidget().getControl() instanceof Combo) {
549+
FilterFieldInputRestrictions.restrictToValues((Combo) comboGeschlecht.getWidget().getControl(),
550+
Messages.Patient_male_short, Messages.Patient_female_short);
551+
}
552+
}
553+
539554
Patientenblatt2(final Composite parent, final IViewSite site) {
540555
super(parent, SWT.NONE);
541556
viewsite = site;

0 commit comments

Comments
 (0)