Skip to content

Commit 216f952

Browse files
authored
Merge pull request #53 from ArkeupIDComores/feature03
Feature03
2 parents 4243ef9 + ffc2121 commit 216f952

22 files changed

Lines changed: 2382 additions & 56 deletions

claimManagement/src/main/AndroidManifest.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,28 @@
7777
<activity
7878
android:name=".ClaimActivity"
7979
android:windowSoftInputMode="stateHidden" />
80+
<activity
81+
android:name=".PreAuthorizationActivity"
82+
android:windowSoftInputMode="stateHidden" />
83+
<activity
84+
android:name=".PreAuthorizationList"
85+
android:windowSoftInputMode="stateHidden" />
8086
<activity
8187
android:name=".AddItems"
8288
android:label="@string/AddItems"
8389
android:windowSoftInputMode="stateHidden" />
90+
<activity
91+
android:name=".AddItemsPreAuth"
92+
android:label="@string/AddItems"
93+
android:windowSoftInputMode="stateHidden" />
8494
<activity
8595
android:name=".AddServices"
8696
android:label="@string/AddServices"
8797
android:windowSoftInputMode="stateHidden" />
98+
<activity
99+
android:name=".AddServicesPreAuth"
100+
android:label="@string/AddServices"
101+
android:windowSoftInputMode="stateHidden" />
88102
<activity
89103
android:name=".MapItems"
90104
android:label="@string/MapItems"

claimManagement/src/main/graphql/org.openimis.imisclaim/GetClaims.graphql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ query GetClaims($claim_administrator_code: String, $status_claim: Int, $visit_da
4848
adjustment
4949
explanation
5050
guaranteeId
51+
rejectionPreAuthorizationReason
52+
claimPreAuthorizationCode
53+
datePreAuthorization
54+
claimPreAuthorizationStatus
55+
isPreAuthorization
5156
services {
5257
qtyProvided
5358
qtyApproved

claimManagement/src/main/graphql/org.openimis.imisclaim/schema.graphqls

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,6 +1456,11 @@ type ClaimGQLType implements Node {
14561456
processStamp: DateTime
14571457
remunerated: Decimal
14581458
guaranteeId: String
1459+
rejectionPreAuthorizationReason: String
1460+
claimPreAuthorizationCode: String
1461+
datePreAuthorization: Date
1462+
claimPreAuthorizationStatus: String
1463+
isPreAuthorization: String
14591464
admin: ClaimAdminGQLType
14601465
icd: DiagnosisGQLType!
14611466
icd1: DiagnosisGQLType
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
package org.openimis.imisclaims;
2+
3+
import android.content.Intent;
4+
import android.database.Cursor;
5+
import android.os.Bundle;
6+
import android.text.Editable;
7+
import android.text.TextWatcher;
8+
import android.view.View;
9+
import android.widget.AutoCompleteTextView;
10+
import android.widget.Button;
11+
import android.widget.EditText;
12+
import android.widget.ListView;
13+
import android.widget.SimpleAdapter;
14+
15+
import java.util.HashMap;
16+
17+
import org.openimis.imisclaims.tools.Log;
18+
19+
public class AddItemsPreAuth extends ImisActivity {
20+
ListView lvItems;
21+
EditText etQuantity, etAmount;
22+
Button btnAdd;
23+
AutoCompleteTextView etItems;
24+
25+
int Pos;
26+
27+
HashMap<String, String> oItem;
28+
SimpleAdapter alAdapter;
29+
30+
@Override
31+
public void onCreate(Bundle savedInstanceState) {
32+
super.onCreate(savedInstanceState);
33+
setContentView(R.layout.additems);
34+
35+
if (actionBar != null) {
36+
actionBar.setTitle(getResources().getString(R.string.app_name_claim));
37+
}
38+
39+
lvItems = findViewById(R.id.lvItems);
40+
etQuantity = findViewById(R.id.etQuantity);
41+
etAmount = findViewById(R.id.etAmount);
42+
etItems = findViewById(R.id.etItems);
43+
btnAdd = findViewById(R.id.btnAdd);
44+
45+
alAdapter = new SimpleAdapter(AddItemsPreAuth.this, PreAuthorizationActivity.lvItemList, R.layout.lvitem,
46+
new String[]{"Code", "Name", "Price", "Quantity"},
47+
new int[]{R.id.tvLvCode, R.id.tvLvName, R.id.tvLvPrice, R.id.tvLvQuantity});
48+
lvItems.setAdapter(alAdapter);
49+
50+
if (isIntentReadonly()) {
51+
disableView(etQuantity);
52+
disableView(etAmount);
53+
disableView(etItems);
54+
disableView(btnAdd);
55+
} else {
56+
ItemAdapter itemAdapter = new ItemAdapter(this, sqlHandler);
57+
etItems.setAdapter(itemAdapter);
58+
etItems.setThreshold(1);
59+
60+
etItems.setOnItemClickListener((parent, view, position, l) -> {
61+
if (position >= 0) {
62+
63+
Cursor cursor = (Cursor) parent.getItemAtPosition(position);
64+
final int itemColumnIndex = cursor.getColumnIndexOrThrow("Code");
65+
final int descColumnIndex = cursor.getColumnIndexOrThrow("Name");
66+
String Code = cursor.getString(itemColumnIndex);
67+
String Name = cursor.getString(descColumnIndex);
68+
69+
oItem = new HashMap<>();
70+
oItem.put("Code", Code);
71+
oItem.put("Name", Name);
72+
73+
etQuantity.setText("1");
74+
etAmount.setText(sqlHandler.getItemPrice(Code));
75+
}
76+
77+
});
78+
79+
etItems.addTextChangedListener(new TextWatcher() {
80+
@Override
81+
public void onTextChanged(CharSequence s, int start, int before, int count) {
82+
btnAdd.setEnabled(s != null && s.toString().trim().length() != 0
83+
&& etQuantity.getText().toString().trim().length() != 0
84+
&& etAmount.getText().toString().trim().length() != 0);
85+
}
86+
87+
@Override
88+
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
89+
}
90+
91+
@Override
92+
public void afterTextChanged(Editable s) {
93+
}
94+
});
95+
96+
etQuantity.addTextChangedListener(new TextWatcher() {
97+
@Override
98+
public void onTextChanged(CharSequence s, int start, int before, int count) {
99+
btnAdd.setEnabled(s != null && s.toString().trim().length() != 0
100+
&& etItems.getText().toString().trim().length() != 0
101+
&& etAmount.getText().toString().trim().length() != 0);
102+
}
103+
104+
@Override
105+
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
106+
}
107+
108+
@Override
109+
public void afterTextChanged(Editable s) {
110+
}
111+
});
112+
113+
etAmount.addTextChangedListener(new TextWatcher() {
114+
@Override
115+
public void onTextChanged(CharSequence s, int start, int before, int count) {
116+
btnAdd.setEnabled(s != null && s.toString().trim().length() != 0
117+
&& etQuantity.getText().toString().trim().length() != 0
118+
&& etItems.getText().toString().trim().length() != 0);
119+
}
120+
121+
@Override
122+
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
123+
}
124+
125+
@Override
126+
public void afterTextChanged(Editable s) {
127+
}
128+
});
129+
130+
lvItems.setAdapter(alAdapter);
131+
132+
btnAdd.setEnabled(false);
133+
btnAdd.setOnClickListener(v -> {
134+
try {
135+
if (oItem == null) return;
136+
137+
String Amount, Quantity;
138+
139+
HashMap<String, String> lvItem = new HashMap<>();
140+
lvItem.put("Code", oItem.get("Code"));
141+
lvItem.put("Name", oItem.get("Name"));
142+
Amount = etAmount.getText().toString();
143+
lvItem.put("Price", Amount);
144+
if (etQuantity.getText().toString().length() == 0) Quantity = "1";
145+
else Quantity = etQuantity.getText().toString();
146+
lvItem.put("Quantity", Quantity);
147+
PreAuthorizationActivity.lvItemList.add(lvItem);
148+
149+
alAdapter.notifyDataSetChanged();
150+
151+
etItems.setText("");
152+
etAmount.setText("");
153+
etQuantity.setText("");
154+
155+
} catch (Exception e) {
156+
Log.d("AddLvError", e.getMessage());
157+
}
158+
});
159+
160+
lvItems.setOnItemLongClickListener((parent, view, position, id) -> {
161+
try {
162+
163+
Pos = position;
164+
HideAllDeleteButtons();
165+
166+
Button d = view.findViewById(R.id.btnDelete);
167+
d.setVisibility(View.VISIBLE);
168+
169+
d.setOnClickListener(v -> {
170+
PreAuthorizationActivity.lvItemList.remove(Pos);
171+
HideAllDeleteButtons();
172+
// alAdapter.notifyDataSetChanged();
173+
});
174+
175+
176+
} catch (Exception e) {
177+
Log.d("ErrorOnLongClick", e.getMessage());
178+
}
179+
return true;
180+
});
181+
}
182+
}
183+
184+
private boolean isIntentReadonly() {
185+
Intent intent = getIntent();
186+
return intent.getBooleanExtra(PreAuthorizationActivity.EXTRA_READONLY, false);
187+
}
188+
189+
private void HideAllDeleteButtons() {
190+
for (int i = 0; i <= lvItems.getLastVisiblePosition(); i++) {
191+
Button Delete = lvItems.getChildAt(i).findViewById(R.id.btnDelete);
192+
Delete.setVisibility(View.GONE);
193+
}
194+
}
195+
}

0 commit comments

Comments
 (0)