2525import org .json .JSONException ;
2626import org .json .JSONObject ;
2727import org .openimis .imisclaims .tools .Log ;
28- import org .openimis .imisclaims .util .JsonUtils ;
29- import org .openimis .imisclaims .util .StringUtils ;
3028
3129import java .text .SimpleDateFormat ;
3230import java .util .ArrayList ;
@@ -54,7 +52,7 @@ public class ClaimActivity extends ImisActivity {
5452 private int year , month , day ;
5553 int TotalItemService ;
5654
57- EditText etStartDate , etEndDate , etClaimCode , etHealthFacility , etInsureeNumber , etClaimAdmin , etGuaranteeNo , etTotalClaimed , etTotalApproved , etTotalAdjusted , etExplanation , etAdjustment ;
55+ EditText etStartDate , etEndDate , etClaimCode , etHealthFacility , etInsureeNumber , etClaimAdmin , etGuaranteeNo ;
5856 AutoCompleteTextView etDiagnosis , etDiagnosis1 , etDiagnosis2 , etDiagnosis3 , etDiagnosis4 ;
5957 TextView tvItemTotal , tvServiceTotal ;
6058 Button btnPost , btnNew ;
@@ -97,11 +95,6 @@ protected void onCreate(Bundle savedInstanceState) {
9795 rbEmergency = findViewById (R .id .rbEmergency );
9896 rbReferral = findViewById (R .id .rbReferral );
9997 rbOther = findViewById (R .id .rbOther );
100- etTotalClaimed = findViewById (R .id .etTotalClaimed );
101- etTotalApproved = findViewById (R .id .etTotalApproved );
102- etTotalAdjusted = findViewById (R .id .etTotalAdjusted );
103- etExplanation = findViewById (R .id .etExplanation );
104- etAdjustment = findViewById (R .id .etAdjustment );
10598
10699
107100 tvItemTotal .setText ("0" );
@@ -161,7 +154,6 @@ protected void onCreate(Bundle savedInstanceState) {
161154 }));
162155 }),
163156 () -> {
164- progressDialog .dismiss ();
165157 },
166158 500
167159 );
@@ -395,7 +387,7 @@ private void fillClaimFromRestore(String claimRestoreText) {
395387
396388 if (etGuaranteeNo .getVisibility () != View .GONE ) {
397389 String guaranteeNumber = claim .getString ("guarantee_number" );
398- if (StringUtils . isEmpty (guaranteeNumber , true ))
390+ if ("" . equals (guaranteeNumber ) || "null" . equals ( guaranteeNumber ))
399391 etGuaranteeNo .setText ("" );
400392 else etGuaranteeNo .setText (guaranteeNumber );
401393 }
@@ -479,27 +471,27 @@ private void fillClaimFromDatabase(String claimUUID) {
479471 try {
480472 JSONObject claimDetails = claimObject .getJSONObject ("details" );
481473
482- etClaimCode .setText (claimDetails .optString ("ClaimCode" ));
474+ etClaimCode .setText (claimDetails .getString ("ClaimCode" ));
483475 if (etClaimAdmin .getVisibility () != View .GONE ) {
484- etClaimAdmin .setText (claimDetails .optString ("ClaimAdmin" ));
476+ etClaimAdmin .setText (claimDetails .getString ("ClaimAdmin" ));
485477 }
486- etHealthFacility .setText (claimDetails .optString ("HFCode" ));
478+ etHealthFacility .setText (claimDetails .getString ("HFCode" ));
487479
488480 if (etGuaranteeNo .getVisibility () != View .GONE ) {
489- etGuaranteeNo .setText (claimDetails .optString ("GuaranteeNumber" ));
481+ etGuaranteeNo .setText (claimDetails .getString ("GuaranteeNumber" ));
490482 }
491483
492- etInsureeNumber .setText (claimDetails .optString ("InsureeNumber" ));
493- etStartDate .setText (claimDetails .optString ("StartDate" ));
494- etEndDate .setText (claimDetails .optString ("EndDate" ));
484+ etInsureeNumber .setText (claimDetails .getString ("InsureeNumber" ));
485+ etStartDate .setText (claimDetails .getString ("StartDate" ));
486+ etEndDate .setText (claimDetails .getString ("EndDate" ));
495487
496- etDiagnosis .setText (claimDetails .optString ("ICDCode" ));
497- etDiagnosis1 .setText (claimDetails .optString ("ICDCode1" ));
498- etDiagnosis2 .setText (claimDetails .optString ("ICDCode2" ));
499- etDiagnosis3 .setText (claimDetails .optString ("ICDCode3" ));
500- etDiagnosis4 .setText (claimDetails .optString ("ICDCode4" ));
488+ etDiagnosis .setText (claimDetails .getString ("ICDCode" ));
489+ etDiagnosis1 .setText (claimDetails .getString ("ICDCode1" ));
490+ etDiagnosis2 .setText (claimDetails .getString ("ICDCode2" ));
491+ etDiagnosis3 .setText (claimDetails .getString ("ICDCode3" ));
492+ etDiagnosis4 .setText (claimDetails .getString ("ICDCode4" ));
501493
502- switch (claimDetails .optString ("VisitType" ). substring ( 0 , 1 )) {
494+ switch (claimDetails .getString ("VisitType" )) {
503495 case "E" :
504496 rgVisitType .check (R .id .rbEmergency );
505497 break ;
@@ -513,44 +505,17 @@ private void fillClaimFromDatabase(String claimUUID) {
513505 rgVisitType .clearCheck ();
514506 }
515507
516- // Show claim adjustment if available (after update)
517- if (!(JsonUtils .isStringEmpty (claimDetails , "Total" , true )
518- && JsonUtils .isStringEmpty (claimDetails , "TotalApproved" , true )
519- && JsonUtils .isStringEmpty (claimDetails , "TotalAdjusted" , true )
520- && JsonUtils .isStringEmpty (claimDetails , "Explanation" , true )
521- && JsonUtils .isStringEmpty (claimDetails , "Adjustment" , true ))) {
522-
523- etTotalClaimed .setVisibility (View .VISIBLE );
524- etTotalApproved .setVisibility (View .VISIBLE );
525- etTotalAdjusted .setVisibility (View .VISIBLE );
526- etExplanation .setVisibility (View .VISIBLE );
527- etAdjustment .setVisibility (View .VISIBLE );
528-
529- etTotalClaimed .setText (claimDetails .optString ("Total" ));
530- etTotalApproved .setText (claimDetails .optString ("TotalApproved" ));
531- etTotalAdjusted .setText (claimDetails .optString ("TotalAdjusted" ));
532- etExplanation .setText (claimDetails .optString ("Explanation" ));
533- etAdjustment .setText (claimDetails .optString ("Adjustment" ));
534- }
535-
536-
537508 lvItemList .clear ();
538509 if (claimObject .has ("items" )) {
539510 JSONArray items = claimObject .getJSONArray ("items" );
540511 for (int i = 0 ; i < items .length (); i ++) {
541512 HashMap <String , String > item = new HashMap <>();
542513 JSONObject itemJson = items .getJSONObject (i );
543514
544- item .put ("Name" , sqlHandler .getReferenceName (itemJson .optString ("ItemCode" )));
545- item .put ("Code" , itemJson .optString ("ItemCode" ));
546- item .put ("Price" , itemJson .optString ("ItemPrice" ));
547- item .put ("Quantity" , itemJson .optString ("ItemQuantity" ));
548- item .put ("PriceAdjusted" , itemJson .optString ("ItemPriceAdjusted" ));
549- item .put ("QuantityAdjusted" , itemJson .optString ("ItemQuantityAdjusted" ));
550- item .put ("Explanation" , itemJson .optString ("ItemExplanation" ));
551- item .put ("Justification" , itemJson .optString ("ItemJustification" ));
552- item .put ("Valuated" , itemJson .optString ("ItemValuated" ));
553- item .put ("Result" , itemJson .optString ("ItemResult" ));
515+ item .put ("Name" , sqlHandler .getReferenceName (itemJson .getString ("ItemCode" )));
516+ item .put ("Code" , itemJson .getString ("ItemCode" ));
517+ item .put ("Price" , itemJson .getString ("ItemPrice" ));
518+ item .put ("Quantity" , itemJson .getString ("ItemQuantity" ));
554519
555520 lvItemList .add (item );
556521 }
@@ -564,16 +529,10 @@ private void fillClaimFromDatabase(String claimUUID) {
564529 HashMap <String , String > service = new HashMap <>();
565530 JSONObject serviceJson = services .getJSONObject (i );
566531
567- service .put ("Name" , sqlHandler .getReferenceName (serviceJson .optString ("ServiceCode" )));
568- service .put ("Code" , serviceJson .optString ("ServiceCode" ));
569- service .put ("Price" , serviceJson .optString ("ServicePrice" ));
570- service .put ("Quantity" , serviceJson .optString ("ServiceQuantity" ));
571- service .put ("PriceAdjusted" , serviceJson .optString ("ServicePriceAdjusted" ));
572- service .put ("QuantityAdjusted" , serviceJson .optString ("ServiceQuantityAdjusted" ));
573- service .put ("Explanation" , serviceJson .optString ("ServiceExplanation" ));
574- service .put ("Justification" , serviceJson .optString ("ServiceJustification" ));
575- service .put ("Valuated" , serviceJson .optString ("ServiceValuated" ));
576- service .put ("Result" , serviceJson .optString ("ServiceResult" ));
532+ service .put ("Name" , sqlHandler .getReferenceName (serviceJson .getString ("ServiceCode" )));
533+ service .put ("Code" , serviceJson .getString ("ServiceCode" ));
534+ service .put ("Price" , serviceJson .getString ("ServicePrice" ));
535+ service .put ("Quantity" , serviceJson .getString ("ServiceQuantity" ));
577536
578537 lvServiceList .add (service );
579538 }
@@ -705,7 +664,7 @@ protected void showValidationDialog(View view, String msg) {
705664 }
706665
707666 protected void confirmNewDialog (String msg ) {
708- runOnUiThread (() -> showDialog (null , msg , (dialog , which ) -> ClearForm (), (dialog , which ) -> dialog .dismiss ()));
667+ runOnUiThread (() -> showDialog (msg , (dialog , which ) -> ClearForm (), (dialog , which ) -> dialog .dismiss ()));
709668 }
710669
711670 private boolean saveClaim () {
@@ -721,16 +680,13 @@ private boolean saveClaim() {
721680 Calendar cal = Calendar .getInstance ();
722681 String claimDate = format .format (cal .getTime ());
723682
724- SimpleDateFormat isoFormat = AppInformation .DateTimeInfo .getDefaultIsoShortDatetimeFormatter ();
725-
726683 int SelectedId ;
727684 SelectedId = rgVisitType .getCheckedRadioButtonId ();
728685 RadioButton selectedTypeButton ;
729686 selectedTypeButton = findViewById (SelectedId );
730687 String visitType = selectedTypeButton .getTag ().toString ();
731688
732689 ContentValues claimCV = new ContentValues ();
733- String updateDate = isoFormat .format (new Date ());
734690
735691 claimCV .put ("ClaimUUID" , claimUUID );
736692 claimCV .put ("ClaimDate" , claimDate );
@@ -749,7 +705,6 @@ private boolean saveClaim() {
749705 claimCV .put ("ICDCode3" , etDiagnosis3 .getText ().toString ());
750706 claimCV .put ("ICDCode4" , etDiagnosis4 .getText ().toString ());
751707 claimCV .put ("VisitType" , visitType );
752- claimCV .put ("LastUpdated" , updateDate );
753708
754709 ArrayList <ContentValues > claimItemCVs = new ArrayList <>(lvItemList .size ());
755710 for (int i = 0 ; i < lvItemList .size (); i ++) {
@@ -759,7 +714,6 @@ private boolean saveClaim() {
759714 claimItemCV .put ("ItemCode" , lvItemList .get (i ).get ("Code" ));
760715 claimItemCV .put ("ItemPrice" , lvItemList .get (i ).get ("Price" ));
761716 claimItemCV .put ("ItemQuantity" , lvItemList .get (i ).get ("Quantity" ));
762- claimItemCV .put ("LastUpdated" , updateDate );
763717
764718 claimItemCVs .add (claimItemCV );
765719 }
@@ -772,7 +726,6 @@ private boolean saveClaim() {
772726 claimServiceCV .put ("ServiceCode" , lvServiceList .get (i ).get ("Code" ));
773727 claimServiceCV .put ("ServicePrice" , lvServiceList .get (i ).get ("Price" ));
774728 claimServiceCV .put ("ServiceQuantity" , lvServiceList .get (i ).get ("Quantity" ));
775- claimServiceCV .put ("LastUpdated" , updateDate );
776729
777730 claimServiceCVs .add (claimServiceCV );
778731 }
0 commit comments