Skip to content

Commit 86a6ee4

Browse files
authored
Merge pull request #216 from mngoe/OP-2615
Improve enquiring process #OP-2615
2 parents e94d6ea + 55aa3e6 commit 86a6ee4

5 files changed

Lines changed: 104 additions & 81 deletions

File tree

app/src/main/graphql/org.openimis.imispolicies/GetInsureeInquire.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ query GetInsureeInquire($chfId: String) {
5353
expiryDate
5454
status
5555
value
56+
validityTo
5657
}
5758
}
5859
}

app/src/main/java/org/openimis/imispolicies/Enquire.java

Lines changed: 81 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -269,96 +269,98 @@ private void getInsureeInfo() {
269269
}
270270

271271
for (Policy policy : insuree.getPolicies()) {
272-
HashMap<String, String> policyMap = new HashMap<>();
272+
if(policy.getValidityTo() == null) {
273+
HashMap<String, String> policyMap = new HashMap<>();
273274

274-
double iDedType = policy.getDeductibleType() == null ? 0 : policy.getDeductibleType();
275+
double iDedType = policy.getDeductibleType() == null ? 0 : policy.getDeductibleType();
275276

276-
String Ded = "", Ded1 = "", Ded2 = "";
277-
String Ceiling = "", Ceiling1 = "", Ceiling2 = "";
277+
String Ded = "", Ded1 = "", Ded2 = "";
278+
String Ceiling = "", Ceiling1 = "", Ceiling2 = "";
278279

279-
//Get the type
280-
if (iDedType == 1 | iDedType == 2 | iDedType == 3) {
281-
if (policy.getDeductibleIp() != null)
282-
Ded1 = String.valueOf(policy.getDeductibleIp());
283-
if (policy.getCeilingIp() != null)
284-
Ceiling1 = String.valueOf(policy.getCeilingIp());
280+
//Get the type
281+
if (iDedType == 1 | iDedType == 2 | iDedType == 3) {
282+
if (policy.getDeductibleIp() != null)
283+
Ded1 = String.valueOf(policy.getDeductibleIp());
284+
if (policy.getCeilingIp() != null)
285+
Ceiling1 = String.valueOf(policy.getCeilingIp());
285286

286-
if (!Ded1.equals("")) Ded = "Deduction: " + Ded1;
287-
if (!Ceiling1.equals("")) Ceiling = "Ceiling: " + Ceiling1;
287+
if (!Ded1.equals("")) Ded = "Deduction: " + Ded1;
288+
if (!Ceiling1.equals("")) Ceiling = "Ceiling: " + Ceiling1;
288289

289-
} else if (iDedType == 1.1 | iDedType == 2.1 | iDedType == 3.1) {
290+
} else if (iDedType == 1.1 | iDedType == 2.1 | iDedType == 3.1) {
290291

291-
if (policy.getDeductibleIp() != null)
292-
Ded1 = " IP:" + policy.getDeductibleIp();
293-
if (policy.getDeductibleOp() != null)
294-
Ded2 = " OP:" + policy.getDeductibleOp();
295-
if (policy.getCeilingIp() != null)
296-
Ceiling1 = " IP:" + policy.getCeilingIp();
297-
if (policy.getCeilingOp() != null)
298-
Ceiling2 = " OP:" + policy.getCeilingOp();
292+
if (policy.getDeductibleIp() != null)
293+
Ded1 = " IP:" + policy.getDeductibleIp();
294+
if (policy.getDeductibleOp() != null)
295+
Ded2 = " OP:" + policy.getDeductibleOp();
296+
if (policy.getCeilingIp() != null)
297+
Ceiling1 = " IP:" + policy.getCeilingIp();
298+
if (policy.getCeilingOp() != null)
299+
Ceiling2 = " OP:" + policy.getCeilingOp();
299300

300-
if (!(Ded1 + Ded2).equals("")) Ded = "Deduction: " + Ded1 + Ded2;
301-
if (!(Ceiling1 + Ceiling2).equals(""))
302-
Ceiling = "Ceiling: " + Ceiling1 + Ceiling2;
301+
if (!(Ded1 + Ded2).equals("")) Ded = "Deduction: " + Ded1 + Ded2;
302+
if (!(Ceiling1 + Ceiling2).equals(""))
303+
Ceiling = "Ceiling: " + Ceiling1 + Ceiling2;
303304

304-
}
305+
}
305306

306-
if (policy.getExpiryDate() == null) {
307-
policyMap.put("Heading", getResources().getString(R.string.EnquireNoPolicies));
308-
} else {
309-
String expiryDate = policy.getExpiryDate() != null ?
310-
DateUtils.toDateString(policy.getExpiryDate()) : null;
311-
String status = policy.getStatus().name();
312-
String heading1;
313-
if (expiryDate != null) {
314-
heading1 = expiryDate + " " + status;
307+
if (policy.getExpiryDate() == null) {
308+
policyMap.put("Heading", getResources().getString(R.string.EnquireNoPolicies));
315309
} else {
316-
heading1 = status;
310+
String expiryDate = policy.getExpiryDate() != null ?
311+
DateUtils.toDateString(policy.getExpiryDate()) : null;
312+
String status = policy.getStatus().name();
313+
String heading1;
314+
if (expiryDate != null) {
315+
heading1 = expiryDate + " " + status;
316+
} else {
317+
heading1 = status;
318+
}
319+
policyMap.put("Heading", policy.getCode());
320+
policyMap.put("Heading1", heading1);
321+
policyMap.put("SubItem1", policy.getName());
322+
policyMap.put("SubItem2", Ded);
323+
policyMap.put("SubItem3", Ceiling);
317324
}
318-
policyMap.put("Heading", policy.getCode());
319-
policyMap.put("Heading1", heading1);
320-
policyMap.put("SubItem1", policy.getName());
321-
policyMap.put("SubItem2", Ded);
322-
policyMap.put("SubItem3", Ceiling);
323-
}
324325

325-
if (!ca.getSpecificControl("TotalAdmissionsLeft").equals("N")) {
326-
policyMap.put("SubItem4", buildEnquireValue(policy.getTotalAdmissionsLeft(), R.string.totalAdmissionsLeft));
327-
}
328-
if (!ca.getSpecificControl("TotalVisitsLeft").equals("N")) {
329-
policyMap.put("SubItem5", buildEnquireValue(policy.getTotalVisitsLeft(), R.string.totalVisitsLeft));
330-
}
331-
if (!ca.getSpecificControl("TotalConsultationsLeft").equals("N")) {
332-
policyMap.put("SubItem6", buildEnquireValue(policy.getTotalConsultationsLeft(), R.string.totalConsultationsLeft));
333-
}
334-
if (!ca.getSpecificControl("TotalSurgeriesLeft").equals("N")) {
335-
policyMap.put("SubItem7", buildEnquireValue(policy.getTotalSurgeriesLeft(), R.string.totalSurgeriesLeft));
336-
}
337-
if (!ca.getSpecificControl("TotalDelivieriesLeft").equals("N")) {
338-
policyMap.put("SubItem8", buildEnquireValue(policy.getTotalDeliveriesLeft(), R.string.totalDeliveriesLeft));
339-
}
340-
if (!ca.getSpecificControl("TotalAntenatalLeft").equals("N")) {
341-
policyMap.put("SubItem9", buildEnquireValue(policy.getTotalAntenatalLeft(), R.string.totalAntenatalLeft));
342-
}
343-
if (!ca.getSpecificControl("ConsultationAmountLeft").equals("N")) {
344-
policyMap.put("SubItem10", buildEnquireValue(policy.getConsultationAmountLeft(), R.string.consultationAmountLeft));
345-
}
346-
if (!ca.getSpecificControl("SurgeryAmountLeft").equals("N")) {
347-
policyMap.put("SubItem11", buildEnquireValue(policy.getSurgeryAmountLeft(), R.string.surgeryAmountLeft));
348-
}
349-
if (!ca.getSpecificControl("HospitalizationAmountLeft").equals("N")) {
350-
policyMap.put("SubItem12", buildEnquireValue(policy.getHospitalizationAmountLeft(), R.string.hospitalizationAmountLeft));
351-
}
352-
if (!ca.getSpecificControl("AntenatalAmountLeft").equals("N")) {
353-
policyMap.put("SubItem13", buildEnquireValue(policy.getAntenatalAmountLeft(), R.string.antenatalAmountLeft));
354-
}
355-
if (!ca.getSpecificControl("DeliveryAmountLeft").equals("N")) {
356-
policyMap.put("SubItem14", buildEnquireValue(policy.getDeliveryAmountLeft(), R.string.deliveryAmountLeft));
357-
}
326+
if (!ca.getSpecificControl("TotalAdmissionsLeft").equals("N")) {
327+
policyMap.put("SubItem4", buildEnquireValue(policy.getTotalAdmissionsLeft(), R.string.totalAdmissionsLeft));
328+
}
329+
if (!ca.getSpecificControl("TotalVisitsLeft").equals("N")) {
330+
policyMap.put("SubItem5", buildEnquireValue(policy.getTotalVisitsLeft(), R.string.totalVisitsLeft));
331+
}
332+
if (!ca.getSpecificControl("TotalConsultationsLeft").equals("N")) {
333+
policyMap.put("SubItem6", buildEnquireValue(policy.getTotalConsultationsLeft(), R.string.totalConsultationsLeft));
334+
}
335+
if (!ca.getSpecificControl("TotalSurgeriesLeft").equals("N")) {
336+
policyMap.put("SubItem7", buildEnquireValue(policy.getTotalSurgeriesLeft(), R.string.totalSurgeriesLeft));
337+
}
338+
if (!ca.getSpecificControl("TotalDelivieriesLeft").equals("N")) {
339+
policyMap.put("SubItem8", buildEnquireValue(policy.getTotalDeliveriesLeft(), R.string.totalDeliveriesLeft));
340+
}
341+
if (!ca.getSpecificControl("TotalAntenatalLeft").equals("N")) {
342+
policyMap.put("SubItem9", buildEnquireValue(policy.getTotalAntenatalLeft(), R.string.totalAntenatalLeft));
343+
}
344+
if (!ca.getSpecificControl("ConsultationAmountLeft").equals("N")) {
345+
policyMap.put("SubItem10", buildEnquireValue(policy.getConsultationAmountLeft(), R.string.consultationAmountLeft));
346+
}
347+
if (!ca.getSpecificControl("SurgeryAmountLeft").equals("N")) {
348+
policyMap.put("SubItem11", buildEnquireValue(policy.getSurgeryAmountLeft(), R.string.surgeryAmountLeft));
349+
}
350+
if (!ca.getSpecificControl("HospitalizationAmountLeft").equals("N")) {
351+
policyMap.put("SubItem12", buildEnquireValue(policy.getHospitalizationAmountLeft(), R.string.hospitalizationAmountLeft));
352+
}
353+
if (!ca.getSpecificControl("AntenatalAmountLeft").equals("N")) {
354+
policyMap.put("SubItem13", buildEnquireValue(policy.getAntenatalAmountLeft(), R.string.antenatalAmountLeft));
355+
}
356+
if (!ca.getSpecificControl("DeliveryAmountLeft").equals("N")) {
357+
policyMap.put("SubItem14", buildEnquireValue(policy.getDeliveryAmountLeft(), R.string.deliveryAmountLeft));
358+
}
358359

359-
PolicyList.add(policyMap);
360-
etCHFID.setText("");
361-
//break;
360+
PolicyList.add(policyMap);
361+
etCHFID.setText("");
362+
//break;
363+
}
362364
}
363365
}
364366
ListAdapter adapter = new SimpleAdapter(Enquire.this,
@@ -449,7 +451,8 @@ private Insuree getDataFromDb(String chfid) throws Exception {
449451
/* totalConsultationsLeft = */ null,
450452
/* totalDeliveriesLeft = */ null,
451453
/* totalSurgeriesLeft = */ null,
452-
/* totalVisitsLeft = */ null
454+
/* totalVisitsLeft = */ null,
455+
/* validityTo = */ null
453456
));
454457
}
455458
c.close();

app/src/main/java/org/openimis/imispolicies/domain/entity/Policy.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public class Policy implements Parcelable {
5353
private final Integer totalSurgeriesLeft;
5454
@Nullable
5555
private final Integer totalVisitsLeft;
56+
@Nullable
57+
private final Date validityTo;
5658

5759
public Policy(
5860
@NonNull String code,
@@ -75,7 +77,8 @@ public Policy(
7577
@Nullable Integer totalConsultationsLeft,
7678
@Nullable Integer totalDeliveriesLeft,
7779
@Nullable Integer totalSurgeriesLeft,
78-
@Nullable Integer totalVisitsLeft
80+
@Nullable Integer totalVisitsLeft,
81+
@Nullable Date validityTo
7982
) {
8083
this.code = code;
8184
this.name = name;
@@ -98,6 +101,7 @@ public Policy(
98101
this.totalDeliveriesLeft = totalDeliveriesLeft;
99102
this.totalSurgeriesLeft = totalSurgeriesLeft;
100103
this.totalVisitsLeft = totalVisitsLeft;
104+
this.validityTo = validityTo;
101105
}
102106

103107
protected Policy(Parcel in) {
@@ -194,6 +198,11 @@ protected Policy(Parcel in) {
194198
} else {
195199
totalVisitsLeft = in.readInt();
196200
}
201+
if (in.readByte() == 0) {
202+
validityTo = null;
203+
} else {
204+
validityTo = new Date(in.readLong());
205+
}
197206
}
198207

199208
@Override
@@ -309,6 +318,12 @@ public void writeToParcel(Parcel dest, int flags) {
309318
dest.writeByte((byte) 1);
310319
dest.writeInt(totalVisitsLeft);
311320
}
321+
if (validityTo == null) {
322+
dest.writeByte((byte) 0);
323+
} else {
324+
dest.writeByte((byte) 1);
325+
dest.writeLong(validityTo.getTime());
326+
}
312327
}
313328

314329
@Override
@@ -421,6 +436,9 @@ public Integer getTotalVisitsLeft() {
421436
return totalVisitsLeft;
422437
}
423438

439+
@Nullable
440+
public Date getValidityTo() { return validityTo; }
441+
424442
public enum Status {
425443
IDLE, ACTIVE, SUSPENDED, EXPIRED, READY
426444
}

app/src/main/java/org/openimis/imispolicies/usecase/FetchInsureeInquire.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ private Policy toPolicy(@NonNull GetInsureeInquireQuery.Edge1 edge) {
9090
/* totalConsultationsLeft = */ product.maxNoConsultation(),
9191
/* totalDeliveriesLeft = */ product.maxNoDelivery(),
9292
/* totalSurgeriesLeft = */ product.maxNoSurgery(),
93-
/* totalVisitsLeft = */ product.maxNoVisits()
93+
/* totalVisitsLeft = */ product.maxNoVisits(),
94+
/* validityTo = */ policy.validityTo()
9495
);
9596
}
9697

app/src/main/res/layout/policylist.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools"
44
android:layout_width="fill_parent"
5-
android:layout_height="wrap_content"
5+
android:layout_height="100dp"
66
android:orientation="vertical"
77
android:paddingBottom="5dp">
88

0 commit comments

Comments
 (0)