Skip to content

Commit 40bdb81

Browse files
committed
fix sync claims
1 parent 8d22ba7 commit 40bdb81

23 files changed

Lines changed: 48 additions & 14 deletions
29.3 KB
Loading

claimManagement/src/main/java/org/openimis/imisclaims/usecase/CreateClaims.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,22 @@ public List<PostNewClaims.Result> execute(
4747
for(PendingClaimGQL pendingClaim: claims){
4848
int insureeId = Integer.parseInt(new FetchInsuree().execute(pendingClaim.getChfId()));
4949
int adminId = Integer.parseInt(new FetchClaimAdmin().execute(pendingClaim.getClaimAdmin()));
50-
int icdId = Integer.parseInt(new FetchDiagnose().execute(pendingClaim.getIcdCode()));
50+
int icdId = new FetchDiagnose().execute(pendingClaim.getIcdCode());
5151
int icd1Id = 0;
5252
int icd2Id = 0;
5353
int icd3Id = 0;
5454
int icd4Id = 0;
55-
if(pendingClaim.getIcdCode1() != null){
56-
icd1Id = Integer.parseInt(new FetchDiagnose().execute(pendingClaim.getIcdCode1()));
55+
if(pendingClaim.getIcdCode1() != null && !pendingClaim.getIcdCode1().isEmpty()){
56+
icd1Id = new FetchDiagnose().execute(pendingClaim.getIcdCode1());
5757
}
58-
if(pendingClaim.getIcdCode2() != null){
59-
icd2Id = Integer.parseInt(new FetchDiagnose().execute(pendingClaim.getIcdCode2()));
58+
if(pendingClaim.getIcdCode2() != null && !pendingClaim.getIcdCode2().isEmpty()){
59+
icd2Id = new FetchDiagnose().execute(pendingClaim.getIcdCode2());
6060
}
61-
if(pendingClaim.getIcdCode3() != null){
62-
icd3Id = Integer.parseInt(new FetchDiagnose().execute(pendingClaim.getIcdCode3()));
61+
if(pendingClaim.getIcdCode3() != null && !pendingClaim.getIcdCode3().isEmpty()){
62+
icd3Id = new FetchDiagnose().execute(pendingClaim.getIcdCode3());
6363
}
64-
if(pendingClaim.getIcdCode4() != null){
65-
icd4Id = Integer.parseInt(new FetchDiagnose().execute(pendingClaim.getIcdCode4()));
64+
if(pendingClaim.getIcdCode4() != null && !pendingClaim.getIcdCode4().isEmpty()){
65+
icd4Id = new FetchDiagnose().execute(pendingClaim.getIcdCode4());
6666
}
6767
String hfId = sqlHandler.getHfId(pendingClaim.getHealthFacilityCode());
6868
int referFromId = 0;

claimManagement/src/main/java/org/openimis/imisclaims/usecase/FetchDiagnose.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import androidx.annotation.WorkerThread;
44
import org.openimis.imisclaims.GetDiagnoseIdQuery;
55
import org.openimis.imisclaims.network.request.GetDiagnosesGraphQLRequest;
6+
import org.openimis.imisclaims.util.IdUtils;
67

78
public class FetchDiagnose {
89

@@ -19,10 +20,8 @@ public FetchDiagnose(@NonNull GetDiagnosesGraphQLRequest request) {
1920

2021
@NonNull
2122
@WorkerThread
22-
public String execute(@NonNull String code) throws Exception {
23+
public int execute(@NonNull String code) throws Exception {
2324
GetDiagnoseIdQuery.Node node = request.get(code);
24-
byte[] bytes = node.id().getBytes();
25-
String id = new String(org.apache.commons.codec.binary.Base64.decodeBase64(bytes)).split(":")[1];
26-
return id;
25+
return IdUtils.getIdFromGraphQLString(node.id());
2726
}
2827
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.openimis.imisclaims.util;
2+
3+
import android.util.Base64;
4+
5+
import androidx.annotation.NonNull;
6+
7+
public class IdUtils {
8+
9+
private IdUtils() throws IllegalAccessException {
10+
throw new IllegalAccessException("This constructor should not be accessed");
11+
}
12+
13+
/**
14+
* <a href="https://github.com/graphql-python/graphene-sqlalchemy/issues/126">
15+
* GraphQL encodes Nodes' int ids for some reasons
16+
* </a>
17+
*/
18+
public static int getIdFromGraphQLString(@NonNull String id) {
19+
return Integer.parseInt(new String(Base64.decode(id, Base64.NO_WRAP)).split(":", 2)[1]);
20+
}
21+
}

claimManagement/src/main/res/layout/activity_claim.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
android:ems="10"
3131
android:fontFamily="sans-serif-light"
3232
android:hint="@string/HealthFacility"
33-
android:maxLength="8"></EditText>
33+
android:maxLength="15"></EditText>
3434

3535
<EditText
3636
android:id="@+id/etClaimAdmin"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3+
<background android:drawable="@color/ic_amg_background"/>
4+
<foreground android:drawable="@mipmap/ic_amg_foreground"/>
5+
</adaptive-icon>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3+
<background android:drawable="@color/ic_amg_background"/>
4+
<foreground android:drawable="@mipmap/ic_amg_foreground"/>
5+
</adaptive-icon>
2.13 KB
Loading
3.17 KB
Loading
4.25 KB
Loading

0 commit comments

Comments
 (0)