@@ -553,8 +553,9 @@ public void validateClaimAdminCode(final String claimAdminCode) {
553553 AdminName .setText (global .getOfficeName ());
554554 }
555555 Cursor c = sqlHandler .getMapping ("I" );
556- if (c != null ) {
557- if (c .getCount () == 0 ) {
556+ Cursor c1 = sqlHandler .getMapping ("S" );
557+ if (c != null && c1 != null ) {
558+ if (c .getCount () == 0 && c1 .getCount () == 0 ) {
558559 try {
559560 progressDialog .dismiss ();
560561 doLoggedIn (() -> CheckHealthFacility (claimAdminCode , HealthFacilityName ));
@@ -710,23 +711,24 @@ private void DownLoadServicesItemsPriceList(@NonNull final String claimAdministr
710711 public void run () {
711712 try {
712713 PaymentList paymentList = new FetchPaymentList ().execute (claimAdministratorCode );
713- String servicesPricelistUuid = paymentList .getServicesPricelistUuid ();
714714 Date date = Calendar .getInstance ().getTime ();
715- List <Service > services = new FetchServices ().execute (servicesPricelistUuid , date );
716- String itemsPriceListUuid = paymentList .getItemsPricelistUuid ();
717- List <Medication > medications = new FetchMedications ().execute (itemsPriceListUuid , date );
718715 sqlHandler .ClearMapping ("S" );
719716 sqlHandler .ClearMapping ("I" );
720717
721- //Insert Services
722- for (Service service : services ) {
723- sqlHandler .InsertMapping (service .getCode (), service .getName (), "S" );
718+ if (paymentList .getServicesPricelistUuid () != null && !paymentList .getServicesPricelistUuid ().isEmpty ()){
719+ List <Service > services = new FetchServices ().execute (paymentList .getServicesPricelistUuid (), date );
720+ for (Service service : services ) {
721+ sqlHandler .InsertMapping (service .getCode (), service .getName (), "S" );
722+ }
724723 }
725724
726- //Insert Items
727- for (Medication medication : medications ) {
728- sqlHandler .InsertMapping (medication .getCode (), medication .getName (), "I" );
725+ if (paymentList .getItemsPricelistUuid () != null && !paymentList .getItemsPricelistUuid ().isEmpty ()){
726+ List <Medication > medications = new FetchMedications ().execute (paymentList .getItemsPricelistUuid (), date );
727+ for (Medication medication : medications ) {
728+ sqlHandler .InsertMapping (medication .getCode (), medication .getName (), "I" );
729+ }
729730 }
731+
730732 runOnUiThread (() -> {
731733 progressDialog .dismiss ();
732734 Toast .makeText (MainActivity .this , getResources ().getString (R .string .MapSuccessful ), Toast .LENGTH_LONG ).show ();
0 commit comments