Skip to content

Commit

Permalink
Finish OTC-683
Browse files Browse the repository at this point in the history
OTC-683 The CHF-ID number was seen Null I on the status
  • Loading branch information
dragos-dobre authored Aug 30, 2022
2 parents 77cb6c9 + 281b198 commit 77cada0
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 61 deletions.
8 changes: 7 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ android {
versionCode gitVersionCode
versionName gitVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
useLibrary('org.apache.http.legacy')
vectorDrawables {
useSupportLibrary = true
}
Expand Down Expand Up @@ -206,6 +205,10 @@ android {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
}

dependencies {
Expand All @@ -219,6 +222,9 @@ dependencies {
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'org.jetbrains:annotations:15.0'
implementation 'org.apache.httpcomponents:httpclient:4.5.9'
implementation 'org.apache.httpcomponents:httpcore:4.4.11'



androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/assets/pages/Insuree.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,18 @@ $(document).ready(function () {
var ExceedThreshold = -1;

if (PolicyId > 0 && IsNewIns == 0) {
var PolicyStatus = Android.getPolicyStatus(PolicyId);
if (TotalIns >= MemberCount) {
ExceedThreshold = 0;
Android.ShowDialog(Android.getString('ExceedMemberCount'));
} else if (TotalIns >= Threshold) {
ExceedThreshold = 1;
} else if (PolicyStatus == 2) {
} else {
ExceedThreshold = 0;
}

}
var InsureeId = Android.SaveInsuree(jsonInsuree, FamilyId, 0, parseInt(ExceedThreshold), PolicyId);
if (InsureeId == 7 || InsureeId == 6) {
if (TotalIns >= MemberCount) {
$("#divProgress").hide();
} else {
$("#divProgress").hide();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -947,8 +947,6 @@ public int SaveInsuree(String InsureeData, int FamilyId, int isHead, int ExceedT
int isOffline = 1;
int insureeIsOffline = 1;
int MaxInsureeId = 0;
Boolean res = false;
int newInsureeId = 0;
try {
global = (Global) mContext.getApplicationContext();
HashMap<String, String> data = jsonToTable(InsureeData);
Expand Down Expand Up @@ -1061,7 +1059,6 @@ public int SaveInsuree(String InsureeData, int FamilyId, int isHead, int ExceedT
if (global.isNetworkAvailable()) {
//if (isOffline == 0){
MaxInsureeId = -MaxInsureeId;
newInsureeId = MaxInsureeId;
//}
values.put("InsureeId", MaxInsureeId);

Expand Down Expand Up @@ -1116,41 +1113,11 @@ else if (ExceedThreshold == 0)
values.put("isOffline", insureeIsOffline);
sqlHandler.updateData("tblInsuree", values, "InsureeId = ? AND (isOffline = ?)", new String[]{String.valueOf(InsureeId), String.valueOf(insureeIsOffline)});
}
if (global.isNetworkAvailable()) {
if (isOffline == 0 || isOffline == 2) {
if (isOffline == 2) isOffline = 0;
if (global.getUserId() > 0) {
if (rtInsureeId > 0) {
newInsureeId = -rtInsureeId;
} else {
newInsureeId = rtInsureeId;
}
if (rtInsureeId == 0 && res) {
inProgress = false;
} else {
}
inProgress = false;
}
inProgress = false;
} else {
inProgress = false;
}
inProgress = false;
} else {
inProgress = false;
}


} catch (NumberFormatException e) {
e.printStackTrace();
throw new Exception(e.getMessage());
} catch (UserException e) {
} catch (NumberFormatException | UserException e) {
e.printStackTrace();
throw new Exception(e.getMessage());
}
while (inProgress) {
}
inProgress = false;

return rtInsureeId;
}

Expand Down
31 changes: 9 additions & 22 deletions app/src/main/java/org/openimis/imispolicies/Enquire.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,30 +276,19 @@ private void getInsureeInfo() {
jsonArray = jsonObject.getJSONArray("details");

for (i = 0; i < jsonArray.length(); i++) {
jsonObject = jsonArray.getJSONObject(i);


HashMap<String, String> Policy = new HashMap<>();
jsonObject = jsonArray.getJSONObject(i);
double iDedType = 0;
if (!jsonObject.getString("dedType").equalsIgnoreCase("null"))
iDedType = Double.parseDouble(jsonObject.getString("dedType"));
double iDedType = Double.parseDouble(JsonUtils.getStringOrDefault(jsonObject, "dedType", "0", true));

String Ded = "", Ded1 = "", Ded2 = "";
String Ceiling = "", Ceiling1 = "", Ceiling2 = "";

String jDed1 = "", jDed2 = "", jCeiling1 = "", jCeiling2 = "";
String jDed1, jDed2, jCeiling1, jCeiling2;

if (jsonObject.getString("ded1").equalsIgnoreCase("null")) jDed1 = "";
else jDed1 = jsonObject.getString("ded1");
if (jsonObject.getString("ded2").equalsIgnoreCase("null")) jDed2 = "";
else jDed2 = jsonObject.getString("ded2");
if (jsonObject.getString("ceiling1").equalsIgnoreCase("null"))
jCeiling1 = "";
else jCeiling1 = jsonObject.getString("ceiling1");
if (jsonObject.getString("ceiling2").equalsIgnoreCase("null"))
jCeiling2 = "";
else jCeiling2 = jsonObject.getString("ceiling2");
jDed1 = JsonUtils.getStringOrDefault(jsonObject, "ded1", "", true);
jDed2 = JsonUtils.getStringOrDefault(jsonObject, "ded2", "", true);
jCeiling1 = JsonUtils.getStringOrDefault(jsonObject, "ceiling1", "", true);
jCeiling2 = JsonUtils.getStringOrDefault(jsonObject, "ceiling2", "", true);

//Get the type

Expand All @@ -325,12 +314,11 @@ private void getInsureeInfo() {

}

if (jsonObject.getString("expiryDate").equals("null")){
if (JsonUtils.isStringEmpty(jsonObject, "expiryDate", true)) {
Policy.put("Heading", getResources().getString(R.string.EnquireNoPolicies));
}
else{
} else {
Policy.put("Heading", jsonObject.getString("productCode"));
Policy.put("Heading1", jsonObject.getString("expiryDate") + " " + jsonObject.getString("status"));
Policy.put("Heading1", JsonUtils.getStringOrDefault(jsonObject, "expiryDate", "", true) + " " + jsonObject.getString("status"));
Policy.put("SubItem1", jsonObject.getString("productName"));
Policy.put("SubItem2", Ded);
Policy.put("SubItem3", Ceiling);
Expand Down Expand Up @@ -404,7 +392,6 @@ private void getInsureeInfo() {
result = "";
}
});

}

protected String buildEnquireValue(JSONObject jsonObject, String jsonKey, int labelId) throws JSONException {
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/java/org/openimis/imispolicies/util/JsonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,23 @@ public static boolean isStringEmpty(JSONObject object, @NonNull String field, bo
return true;
}
}

/**
* @param object Json object
* @param field field to be checked
* @param defaultValue default value to be used if requested value does not exists
* @param checkNullString Should "null" string be considered empty
* @return value of the specified field if exists, default value otherwise
*/
public static String getStringOrDefault(@NonNull JSONObject object, @NonNull String field, String defaultValue, boolean checkNullString) {
try {
if (!isStringEmpty(object, field, checkNullString)) {
return object.getString(field);
} else {
return defaultValue;
}
} catch (JSONException e) {
return defaultValue;
}
}
}

0 comments on commit 77cada0

Please sign in to comment.