@Test public void shouldDeleteVoidedEncountersWhenDownloadingEncounters() throws EncounterController.DeleteEncounterException, EncounterController.DownloadEncounterException, SetupConfigurationController.SetupConfigurationFetchException { String[] patientUuids = new String[]{"patientUuid1", "patientUuid2"}; final Patient patient = new Patient() {{ setUuid("patient1"); }}; SetupConfigurationTemplate setupConfigurationTemplate = new SetupConfigurationTemplate(); setupConfigurationTemplate.setUuid("dummySetupConfig"); when(setupConfigurationController.getActiveSetupConfigurationTemplate()).thenReturn(setupConfigurationTemplate); List<Encounter> encounters = new ArrayList<>(); encounters.add(new Encounter(){{setPatient(patient);}}); Encounter voidedEncounter = mock(Encounter.class); when(voidedEncounter.isVoided()).thenReturn(true); when(voidedEncounter.getPatient()).thenReturn(patient); encounters.add(voidedEncounter); when(encounterController.downloadEncountersByPatientUuids(asList(patientUuids), setupConfigurationTemplate.getUuid())).thenReturn(encounters); muzimaSyncService.downloadEncountersForPatientsByPatientUUIDs(asList(patientUuids),true); verify(encounterController).deleteEncounters(Collections.singletonList(voidedEncounter)); }
public int[] downloadEncountersForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingEncounters) { int[] result = new int[4]; try { String activeSetupConfigUuid = null; try { SetupConfigurationTemplate setupConfigurationTemplate = setupConfigurationController.getActiveSetupConfigurationTemplate(); if (setupConfigurationTemplate != null) { activeSetupConfigUuid = setupConfigurationTemplate.getUuid(); } } catch (SetupConfigurationController.SetupConfigurationFetchException e) { Log.e(getClass().getSimpleName(), "Could not obtain active setup config", e); } List<List<String>> slicedPatientUuids = split(patientUuids); Set<String> patientsForDownloadedEncounters = new HashSet(); long totalTimeDownloading = 0, totalTimeReplacing = 0, totalTimeSaving = 0; int i = 0; for (List<String> slicedPatientUuid : slicedPatientUuids) { Log.i(getClass().getSimpleName(), "Downloading encounters for " + slicedPatientUuid.size() + " patients"); long startDownloadEncounters = System.currentTimeMillis(); List<Encounter> allEncounters = new ArrayList<>(encounterController.downloadEncountersByPatientUuids(slicedPatientUuid, activeSetupConfigUuid)); long endDownloadObservations = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Downloading encounters : " + (endDownloadObservations - startDownloadEncounters) / 1000 + " sec\n"); totalTimeDownloading += endDownloadObservations - startDownloadEncounters; Log.i(getClass().getSimpleName(), "Encounters download successful with " + allEncounters.size() + " encounters"); for (Encounter encounter : allEncounters) { patientsForDownloadedEncounters.add(encounter.getPatient().getUuid()); } Log.i(getClass().getSimpleName(), "Downloaded Encounters for patient " + patientsForDownloadedEncounters.size() + " of " + patientUuids.size()); updateProgressDialog(muzimaApplication.getString(R.string.info_encounter_download_progress, patientsForDownloadedEncounters.size(), patientUuids.size())); ArrayList<Encounter> voidedEncounters = getVoidedEncounters(allEncounters); allEncounters.removeAll(voidedEncounters); encounterController.deleteEncounters(voidedEncounters); Log.i(getClass().getSimpleName(), "Voided encounters delete successful with " + voidedEncounters.size() + " encounters"); if (replaceExistingEncounters) { encounterController.replaceEncounters(allEncounters); long replacedEncounters = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Replacing encounters for patients: " + (replacedEncounters - endDownloadObservations) / 1000 + " sec"); totalTimeReplacing += replacedEncounters - endDownloadObservations; } else { encounterController.saveEncounters(allEncounters); long savedEncounters = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Saving encounters : " + (savedEncounters - endDownloadObservations) / 1000 + " sec\n"); totalTimeSaving += savedEncounters - endDownloadObservations; } result[1] += allEncounters.size(); result[2] += voidedEncounters.size(); } Log.d(getClass().getSimpleName(), "Total Downloading encounters : " + totalTimeDownloading / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Replacing encounters : " + totalTimeReplacing / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Saving encounters : " + totalTimeSaving / 1000 + " sec\n"); result[0] = SUCCESS; result[3] = patientsForDownloadedEncounters.size(); } catch (EncounterController.DownloadEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading encounters.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (EncounterController.ReplaceEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while replacing encounters.", e); result[0] = SyncStatusConstants.REPLACE_ERROR; } catch (EncounterController.DeleteEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while deleting encounters.", e); result[0] = SyncStatusConstants.DELETE_ERROR; } catch (EncounterController.SaveEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while saving encounters.", e); result[0] = SyncStatusConstants.SAVE_ERROR; } return result; }
MuzimaSyncService { public int[] downloadEncountersForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingEncounters) { int[] result = new int[4]; try { String activeSetupConfigUuid = null; try { SetupConfigurationTemplate setupConfigurationTemplate = setupConfigurationController.getActiveSetupConfigurationTemplate(); if (setupConfigurationTemplate != null) { activeSetupConfigUuid = setupConfigurationTemplate.getUuid(); } } catch (SetupConfigurationController.SetupConfigurationFetchException e) { Log.e(getClass().getSimpleName(), "Could not obtain active setup config", e); } List<List<String>> slicedPatientUuids = split(patientUuids); Set<String> patientsForDownloadedEncounters = new HashSet(); long totalTimeDownloading = 0, totalTimeReplacing = 0, totalTimeSaving = 0; int i = 0; for (List<String> slicedPatientUuid : slicedPatientUuids) { Log.i(getClass().getSimpleName(), "Downloading encounters for " + slicedPatientUuid.size() + " patients"); long startDownloadEncounters = System.currentTimeMillis(); List<Encounter> allEncounters = new ArrayList<>(encounterController.downloadEncountersByPatientUuids(slicedPatientUuid, activeSetupConfigUuid)); long endDownloadObservations = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Downloading encounters : " + (endDownloadObservations - startDownloadEncounters) / 1000 + " sec\n"); totalTimeDownloading += endDownloadObservations - startDownloadEncounters; Log.i(getClass().getSimpleName(), "Encounters download successful with " + allEncounters.size() + " encounters"); for (Encounter encounter : allEncounters) { patientsForDownloadedEncounters.add(encounter.getPatient().getUuid()); } Log.i(getClass().getSimpleName(), "Downloaded Encounters for patient " + patientsForDownloadedEncounters.size() + " of " + patientUuids.size()); updateProgressDialog(muzimaApplication.getString(R.string.info_encounter_download_progress, patientsForDownloadedEncounters.size(), patientUuids.size())); ArrayList<Encounter> voidedEncounters = getVoidedEncounters(allEncounters); allEncounters.removeAll(voidedEncounters); encounterController.deleteEncounters(voidedEncounters); Log.i(getClass().getSimpleName(), "Voided encounters delete successful with " + voidedEncounters.size() + " encounters"); if (replaceExistingEncounters) { encounterController.replaceEncounters(allEncounters); long replacedEncounters = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Replacing encounters for patients: " + (replacedEncounters - endDownloadObservations) / 1000 + " sec"); totalTimeReplacing += replacedEncounters - endDownloadObservations; } else { encounterController.saveEncounters(allEncounters); long savedEncounters = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Saving encounters : " + (savedEncounters - endDownloadObservations) / 1000 + " sec\n"); totalTimeSaving += savedEncounters - endDownloadObservations; } result[1] += allEncounters.size(); result[2] += voidedEncounters.size(); } Log.d(getClass().getSimpleName(), "Total Downloading encounters : " + totalTimeDownloading / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Replacing encounters : " + totalTimeReplacing / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Saving encounters : " + totalTimeSaving / 1000 + " sec\n"); result[0] = SUCCESS; result[3] = patientsForDownloadedEncounters.size(); } catch (EncounterController.DownloadEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading encounters.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (EncounterController.ReplaceEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while replacing encounters.", e); result[0] = SyncStatusConstants.REPLACE_ERROR; } catch (EncounterController.DeleteEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while deleting encounters.", e); result[0] = SyncStatusConstants.DELETE_ERROR; } catch (EncounterController.SaveEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while saving encounters.", e); result[0] = SyncStatusConstants.SAVE_ERROR; } return result; } }
MuzimaSyncService { public int[] downloadEncountersForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingEncounters) { int[] result = new int[4]; try { String activeSetupConfigUuid = null; try { SetupConfigurationTemplate setupConfigurationTemplate = setupConfigurationController.getActiveSetupConfigurationTemplate(); if (setupConfigurationTemplate != null) { activeSetupConfigUuid = setupConfigurationTemplate.getUuid(); } } catch (SetupConfigurationController.SetupConfigurationFetchException e) { Log.e(getClass().getSimpleName(), "Could not obtain active setup config", e); } List<List<String>> slicedPatientUuids = split(patientUuids); Set<String> patientsForDownloadedEncounters = new HashSet(); long totalTimeDownloading = 0, totalTimeReplacing = 0, totalTimeSaving = 0; int i = 0; for (List<String> slicedPatientUuid : slicedPatientUuids) { Log.i(getClass().getSimpleName(), "Downloading encounters for " + slicedPatientUuid.size() + " patients"); long startDownloadEncounters = System.currentTimeMillis(); List<Encounter> allEncounters = new ArrayList<>(encounterController.downloadEncountersByPatientUuids(slicedPatientUuid, activeSetupConfigUuid)); long endDownloadObservations = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Downloading encounters : " + (endDownloadObservations - startDownloadEncounters) / 1000 + " sec\n"); totalTimeDownloading += endDownloadObservations - startDownloadEncounters; Log.i(getClass().getSimpleName(), "Encounters download successful with " + allEncounters.size() + " encounters"); for (Encounter encounter : allEncounters) { patientsForDownloadedEncounters.add(encounter.getPatient().getUuid()); } Log.i(getClass().getSimpleName(), "Downloaded Encounters for patient " + patientsForDownloadedEncounters.size() + " of " + patientUuids.size()); updateProgressDialog(muzimaApplication.getString(R.string.info_encounter_download_progress, patientsForDownloadedEncounters.size(), patientUuids.size())); ArrayList<Encounter> voidedEncounters = getVoidedEncounters(allEncounters); allEncounters.removeAll(voidedEncounters); encounterController.deleteEncounters(voidedEncounters); Log.i(getClass().getSimpleName(), "Voided encounters delete successful with " + voidedEncounters.size() + " encounters"); if (replaceExistingEncounters) { encounterController.replaceEncounters(allEncounters); long replacedEncounters = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Replacing encounters for patients: " + (replacedEncounters - endDownloadObservations) / 1000 + " sec"); totalTimeReplacing += replacedEncounters - endDownloadObservations; } else { encounterController.saveEncounters(allEncounters); long savedEncounters = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Saving encounters : " + (savedEncounters - endDownloadObservations) / 1000 + " sec\n"); totalTimeSaving += savedEncounters - endDownloadObservations; } result[1] += allEncounters.size(); result[2] += voidedEncounters.size(); } Log.d(getClass().getSimpleName(), "Total Downloading encounters : " + totalTimeDownloading / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Replacing encounters : " + totalTimeReplacing / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Saving encounters : " + totalTimeSaving / 1000 + " sec\n"); result[0] = SUCCESS; result[3] = patientsForDownloadedEncounters.size(); } catch (EncounterController.DownloadEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading encounters.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (EncounterController.ReplaceEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while replacing encounters.", e); result[0] = SyncStatusConstants.REPLACE_ERROR; } catch (EncounterController.DeleteEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while deleting encounters.", e); result[0] = SyncStatusConstants.DELETE_ERROR; } catch (EncounterController.SaveEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while saving encounters.", e); result[0] = SyncStatusConstants.SAVE_ERROR; } return result; } MuzimaSyncService(MuzimaApplication muzimaContext); }
MuzimaSyncService { public int[] downloadEncountersForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingEncounters) { int[] result = new int[4]; try { String activeSetupConfigUuid = null; try { SetupConfigurationTemplate setupConfigurationTemplate = setupConfigurationController.getActiveSetupConfigurationTemplate(); if (setupConfigurationTemplate != null) { activeSetupConfigUuid = setupConfigurationTemplate.getUuid(); } } catch (SetupConfigurationController.SetupConfigurationFetchException e) { Log.e(getClass().getSimpleName(), "Could not obtain active setup config", e); } List<List<String>> slicedPatientUuids = split(patientUuids); Set<String> patientsForDownloadedEncounters = new HashSet(); long totalTimeDownloading = 0, totalTimeReplacing = 0, totalTimeSaving = 0; int i = 0; for (List<String> slicedPatientUuid : slicedPatientUuids) { Log.i(getClass().getSimpleName(), "Downloading encounters for " + slicedPatientUuid.size() + " patients"); long startDownloadEncounters = System.currentTimeMillis(); List<Encounter> allEncounters = new ArrayList<>(encounterController.downloadEncountersByPatientUuids(slicedPatientUuid, activeSetupConfigUuid)); long endDownloadObservations = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Downloading encounters : " + (endDownloadObservations - startDownloadEncounters) / 1000 + " sec\n"); totalTimeDownloading += endDownloadObservations - startDownloadEncounters; Log.i(getClass().getSimpleName(), "Encounters download successful with " + allEncounters.size() + " encounters"); for (Encounter encounter : allEncounters) { patientsForDownloadedEncounters.add(encounter.getPatient().getUuid()); } Log.i(getClass().getSimpleName(), "Downloaded Encounters for patient " + patientsForDownloadedEncounters.size() + " of " + patientUuids.size()); updateProgressDialog(muzimaApplication.getString(R.string.info_encounter_download_progress, patientsForDownloadedEncounters.size(), patientUuids.size())); ArrayList<Encounter> voidedEncounters = getVoidedEncounters(allEncounters); allEncounters.removeAll(voidedEncounters); encounterController.deleteEncounters(voidedEncounters); Log.i(getClass().getSimpleName(), "Voided encounters delete successful with " + voidedEncounters.size() + " encounters"); if (replaceExistingEncounters) { encounterController.replaceEncounters(allEncounters); long replacedEncounters = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Replacing encounters for patients: " + (replacedEncounters - endDownloadObservations) / 1000 + " sec"); totalTimeReplacing += replacedEncounters - endDownloadObservations; } else { encounterController.saveEncounters(allEncounters); long savedEncounters = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Saving encounters : " + (savedEncounters - endDownloadObservations) / 1000 + " sec\n"); totalTimeSaving += savedEncounters - endDownloadObservations; } result[1] += allEncounters.size(); result[2] += voidedEncounters.size(); } Log.d(getClass().getSimpleName(), "Total Downloading encounters : " + totalTimeDownloading / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Replacing encounters : " + totalTimeReplacing / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Saving encounters : " + totalTimeSaving / 1000 + " sec\n"); result[0] = SUCCESS; result[3] = patientsForDownloadedEncounters.size(); } catch (EncounterController.DownloadEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading encounters.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (EncounterController.ReplaceEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while replacing encounters.", e); result[0] = SyncStatusConstants.REPLACE_ERROR; } catch (EncounterController.DeleteEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while deleting encounters.", e); result[0] = SyncStatusConstants.DELETE_ERROR; } catch (EncounterController.SaveEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while saving encounters.", e); result[0] = SyncStatusConstants.SAVE_ERROR; } return result; } MuzimaSyncService(MuzimaApplication muzimaContext); int authenticate(String[] credentials); int authenticate(String[] credentials, boolean isUpdatePasswordRequired); int[] downloadForms(); int[] downloadFormTemplatesAndRelatedMetadata(String[] formIds, boolean replaceExistingTemplates); int[] downloadFormTemplates(String[] formIds, boolean replaceExistingTemplates); int[] downloadLocations(String[] locationIds); int[] downloadProviders(String[] providerIds); int[] downloadConcepts(String[] conceptIds); int[] downloadCohorts(); int[] downloadCohorts(String[] cohortUuids); int[] downloadPatientsForCohortsWithUpdatesAvailable(); int[] downloadRemovedCohortMembershipData(String[] cohortUuids); int[] downloadPatientsForCohorts(String[] cohortUuids); int[] downloadPatients(String[] patientUUIDs); int[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation); int[] downloadObservationsForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingObservations); int[] downloadEncountersForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingEncounters); int[] downloadEncountersForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingEncounters); int[] uploadAllCompletedForms(); void consolidatePatients(); List<FormData> getArchivedFormData(); int[] checkAndDeleteTemporaryDataForProcessedFormData(List<FormData> archivedFormData); List<String> getUuidsForAllPatientsFromLocalStorage(); List<Patient> updatePatientsNotPartOfCohorts(); int[] downloadNotifications(String receiverUuid); int[] downloadPatientReportHeaders(String patientUuid); int[] downloadAllPatientReportHeadersAndReports(); int[] downloadPatientReportsByUuid(String[] reportUuids); void downloadSetupConfigurations(); int[] downloadSetupConfigurationTemplate(String uuid); int[] downloadAndSaveUpdatedSetupConfigurationTemplate(String uuid); int[] updateSetupConfigurationTemplates(); int[] downloadSetting(String property); int[] downloadNewSettings(); void updateSettingsPreferences(List<MuzimaSetting> muzimaSettings); int[] downloadRelationshipsTypes(); int[] downloadRelationshipsForPatientsByPatientUUIDs(List<String> patientUuids); int[] downloadRelationshipsForPatientsByCohortUUIDs(String[] cohortUuids); String getDefaultLocation(); }
MuzimaSyncService { public int[] downloadEncountersForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingEncounters) { int[] result = new int[4]; try { String activeSetupConfigUuid = null; try { SetupConfigurationTemplate setupConfigurationTemplate = setupConfigurationController.getActiveSetupConfigurationTemplate(); if (setupConfigurationTemplate != null) { activeSetupConfigUuid = setupConfigurationTemplate.getUuid(); } } catch (SetupConfigurationController.SetupConfigurationFetchException e) { Log.e(getClass().getSimpleName(), "Could not obtain active setup config", e); } List<List<String>> slicedPatientUuids = split(patientUuids); Set<String> patientsForDownloadedEncounters = new HashSet(); long totalTimeDownloading = 0, totalTimeReplacing = 0, totalTimeSaving = 0; int i = 0; for (List<String> slicedPatientUuid : slicedPatientUuids) { Log.i(getClass().getSimpleName(), "Downloading encounters for " + slicedPatientUuid.size() + " patients"); long startDownloadEncounters = System.currentTimeMillis(); List<Encounter> allEncounters = new ArrayList<>(encounterController.downloadEncountersByPatientUuids(slicedPatientUuid, activeSetupConfigUuid)); long endDownloadObservations = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Downloading encounters : " + (endDownloadObservations - startDownloadEncounters) / 1000 + " sec\n"); totalTimeDownloading += endDownloadObservations - startDownloadEncounters; Log.i(getClass().getSimpleName(), "Encounters download successful with " + allEncounters.size() + " encounters"); for (Encounter encounter : allEncounters) { patientsForDownloadedEncounters.add(encounter.getPatient().getUuid()); } Log.i(getClass().getSimpleName(), "Downloaded Encounters for patient " + patientsForDownloadedEncounters.size() + " of " + patientUuids.size()); updateProgressDialog(muzimaApplication.getString(R.string.info_encounter_download_progress, patientsForDownloadedEncounters.size(), patientUuids.size())); ArrayList<Encounter> voidedEncounters = getVoidedEncounters(allEncounters); allEncounters.removeAll(voidedEncounters); encounterController.deleteEncounters(voidedEncounters); Log.i(getClass().getSimpleName(), "Voided encounters delete successful with " + voidedEncounters.size() + " encounters"); if (replaceExistingEncounters) { encounterController.replaceEncounters(allEncounters); long replacedEncounters = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Replacing encounters for patients: " + (replacedEncounters - endDownloadObservations) / 1000 + " sec"); totalTimeReplacing += replacedEncounters - endDownloadObservations; } else { encounterController.saveEncounters(allEncounters); long savedEncounters = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Saving encounters : " + (savedEncounters - endDownloadObservations) / 1000 + " sec\n"); totalTimeSaving += savedEncounters - endDownloadObservations; } result[1] += allEncounters.size(); result[2] += voidedEncounters.size(); } Log.d(getClass().getSimpleName(), "Total Downloading encounters : " + totalTimeDownloading / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Replacing encounters : " + totalTimeReplacing / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Saving encounters : " + totalTimeSaving / 1000 + " sec\n"); result[0] = SUCCESS; result[3] = patientsForDownloadedEncounters.size(); } catch (EncounterController.DownloadEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading encounters.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (EncounterController.ReplaceEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while replacing encounters.", e); result[0] = SyncStatusConstants.REPLACE_ERROR; } catch (EncounterController.DeleteEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while deleting encounters.", e); result[0] = SyncStatusConstants.DELETE_ERROR; } catch (EncounterController.SaveEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while saving encounters.", e); result[0] = SyncStatusConstants.SAVE_ERROR; } return result; } MuzimaSyncService(MuzimaApplication muzimaContext); int authenticate(String[] credentials); int authenticate(String[] credentials, boolean isUpdatePasswordRequired); int[] downloadForms(); int[] downloadFormTemplatesAndRelatedMetadata(String[] formIds, boolean replaceExistingTemplates); int[] downloadFormTemplates(String[] formIds, boolean replaceExistingTemplates); int[] downloadLocations(String[] locationIds); int[] downloadProviders(String[] providerIds); int[] downloadConcepts(String[] conceptIds); int[] downloadCohorts(); int[] downloadCohorts(String[] cohortUuids); int[] downloadPatientsForCohortsWithUpdatesAvailable(); int[] downloadRemovedCohortMembershipData(String[] cohortUuids); int[] downloadPatientsForCohorts(String[] cohortUuids); int[] downloadPatients(String[] patientUUIDs); int[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation); int[] downloadObservationsForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingObservations); int[] downloadEncountersForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingEncounters); int[] downloadEncountersForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingEncounters); int[] uploadAllCompletedForms(); void consolidatePatients(); List<FormData> getArchivedFormData(); int[] checkAndDeleteTemporaryDataForProcessedFormData(List<FormData> archivedFormData); List<String> getUuidsForAllPatientsFromLocalStorage(); List<Patient> updatePatientsNotPartOfCohorts(); int[] downloadNotifications(String receiverUuid); int[] downloadPatientReportHeaders(String patientUuid); int[] downloadAllPatientReportHeadersAndReports(); int[] downloadPatientReportsByUuid(String[] reportUuids); void downloadSetupConfigurations(); int[] downloadSetupConfigurationTemplate(String uuid); int[] downloadAndSaveUpdatedSetupConfigurationTemplate(String uuid); int[] updateSetupConfigurationTemplates(); int[] downloadSetting(String property); int[] downloadNewSettings(); void updateSettingsPreferences(List<MuzimaSetting> muzimaSettings); int[] downloadRelationshipsTypes(); int[] downloadRelationshipsForPatientsByPatientUUIDs(List<String> patientUuids); int[] downloadRelationshipsForPatientsByCohortUUIDs(String[] cohortUuids); String getDefaultLocation();  }