|
10 | 10 | import android.database.Cursor; |
11 | 11 | import android.inputmethodservice.Keyboard; |
12 | 12 | import android.os.Bundle; |
| 13 | +import android.text.Editable; |
13 | 14 | import android.text.InputType; |
| 15 | +import android.text.TextWatcher; |
14 | 16 | import android.view.Menu; |
15 | 17 | import android.view.MenuInflater; |
16 | 18 | import android.view.MenuItem; |
@@ -93,7 +95,7 @@ public static Intent newIntent(@NonNull Context context, @NonNull String claimUU |
93 | 95 | RadioButton rbEmergency, rbReferral, rbOther, rbPositive, rbNegative; |
94 | 96 | ImageButton btnScan; |
95 | 97 | LinearLayout llFagepFields; |
96 | | - TextInputLayout ettClaimPrefix, ettGuaranteeNo; |
| 98 | + TextInputLayout ettClaimPrefix, ettGuaranteeNo, tilCHFID; |
97 | 99 |
|
98 | 100 | @Override |
99 | 101 | protected void onCreate(Bundle savedInstanceState) { |
@@ -140,6 +142,7 @@ protected void onCreate(Bundle savedInstanceState) { |
140 | 142 | etVisitType = findViewById(R.id.etVisitType); |
141 | 143 | ettClaimPrefix = findViewById(R.id.ettClaimPrefix); |
142 | 144 | ettGuaranteeNo = findViewById(R.id.ettGuaranteeNo); |
| 145 | + tilCHFID = findViewById(R.id.tilCHFID); |
143 | 146 |
|
144 | 147 | String[] visitTypes = getResources().getStringArray(R.array.visitType); |
145 | 148 | ArrayAdapter<String> visitTypeAdapter = new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, visitTypes); |
@@ -340,6 +343,45 @@ public void onItemClick(AdapterView<?> adapterView, View view, int position, lon |
340 | 343 | } |
341 | 344 | }); |
342 | 345 | } |
| 346 | + |
| 347 | + etInsureeNumber.addTextChangedListener(new TextWatcher() { |
| 348 | + @Override |
| 349 | + public void beforeTextChanged(CharSequence s, int start, int count, int after) {} |
| 350 | + |
| 351 | + @Override |
| 352 | + public void onTextChanged(CharSequence s, int start, int before, int count) {} |
| 353 | + |
| 354 | + @Override |
| 355 | + public void afterTextChanged(Editable s) { |
| 356 | + int length = s != null ? s.length() : 0; |
| 357 | + if (length > 0 && length < 12) { |
| 358 | + tilCHFID.setError(getResources().getString(R.string.minChfIdRequired)); |
| 359 | + } else { |
| 360 | + tilCHFID.setError(null); |
| 361 | + } |
| 362 | + } |
| 363 | + }); |
| 364 | + |
| 365 | + etClaimPrefix.addTextChangedListener(new TextWatcher() { |
| 366 | + @Override |
| 367 | + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {} |
| 368 | + |
| 369 | + @Override |
| 370 | + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {} |
| 371 | + |
| 372 | + @Override |
| 373 | + public void afterTextChanged(Editable s) { |
| 374 | + String program = etProgram.getText().toString(); |
| 375 | + if(program.equals("Cheque Santé") || program.equals("Chèque Santé")){ |
| 376 | + int length = s != null ? s.length() : 0; |
| 377 | + if (length > 0 && length < 6) { |
| 378 | + ettClaimPrefix.setError(getResources().getString(R.string.minChequeNumberRequired)); |
| 379 | + } else { |
| 380 | + ettClaimPrefix.setError(null); |
| 381 | + } |
| 382 | + } |
| 383 | + } |
| 384 | + }); |
343 | 385 | } |
344 | 386 |
|
345 | 387 | private boolean isIntentReadonly() { |
@@ -776,6 +818,9 @@ private boolean isValidData() { |
776 | 818 | if (etInsureeNumber.getText().length() == 0) { |
777 | 819 | showValidationDialog(etInsureeNumber, getResources().getString(R.string.MissingCHFID)); |
778 | 820 | return false; |
| 821 | + } else if(etInsureeNumber.getText().length() < 12){ |
| 822 | + showValidationDialog(etInsureeNumber, getResources().getString(R.string.minChfIdRequired)); |
| 823 | + return false; |
779 | 824 | } |
780 | 825 |
|
781 | 826 | /*if (!etProgram.getText().toString().equals("VIH")) { |
@@ -832,9 +877,13 @@ private boolean isValidData() { |
832 | 877 | return false; |
833 | 878 | } |
834 | 879 |
|
| 880 | + String program = etProgram.getText().toString(); |
835 | 881 | if(etClaimPrefix.getText().length() == 0){ |
836 | 882 | showValidationDialog(etClaimPrefix, getResources().getString(R.string.MissingChequeNumber)); |
837 | 883 | return false; |
| 884 | + } else if((program.equals("Cheque Santé") || program.equals("Chèque Santé")) && etClaimPrefix.length() < 6){ |
| 885 | + showValidationDialog(etClaimPrefix, getResources().getString(R.string.minChequeNumberRequired)); |
| 886 | + return false; |
838 | 887 | } |
839 | 888 |
|
840 | 889 | if(etClaimCode.getText().length() > 7){ |
|
0 commit comments