<commit_before>package com.muzima.controller;

import android.util.Log;
import com.muzima.api.model.CohortMember;
import com.muzima.api.model.Patient;
import com.muzima.api.model.PatientIdentifier;
import com.muzima.api.service.CohortService;
import com.muzima.api.service.PatientService;
import org.apache.lucene.queryParser.ParseException;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import static com.muzima.utils.Constants.LOCAL_PATIENT;
import static org.apache.commons.lang.StringUtils.isEmpty;

public class PatientController {

    public static final String TAG = "PatientController";
    private PatientService patientService;
    private CohortService cohortService;

    public PatientController(PatientService patientService, CohortService cohortService) {
        this.patientService = patientService;
        this.cohortService = cohortService;
    }

    public void replacePatients(List<Patient> patients) throws PatientReplaceException {
        try {
            patientService.updatePatients(patients);
        } catch (IOException e) {
            throw new PatientReplaceException(e);
        }
    }

    public List<Patient> getPatients(String cohortId) throws PatientLoadException {
        try {
            List<CohortMember> cohortMembers = cohortService.getCohortMembers(cohortId);
            List<Patient> patients = new ArrayList<Patient>();
            for (CohortMember member : cohortMembers) {
                patients.add(patientService.getPatientByUuid(member.getPatientUuid()));
            }
            return patients;
        } catch (IOException e) {
            throw new PatientLoadException(e);
        }
    }

    public List<Patient> getAllPatients() throws PatientLoadException {
        try {
            return patientService.getAllPatients();
        } catch (IOException e) {
            throw new PatientLoadException(e);
        }
    }

    public int getTotalPatientsCount() throws PatientLoadException {
        try {
            return patientService.countAllPatients();
        } catch (IOException e) {
            throw new PatientLoadException(e);
        }
    }

    public Patient getPatientByUuid(String uuid) throws PatientLoadException {
        try {
            return patientService.getPatientByUuid(uuid);
        } catch (IOException e) {<commit_msg>Removed explicit patient fetching call from PatientController<commit_after>package com.muzima.controller;

import android.util.Log;
import com.muzima.api.model.CohortMember;
import com.muzima.api.model.Patient;
import com.muzima.api.model.PatientIdentifier;
import com.muzima.api.service.CohortService;
import com.muzima.api.service.PatientService;
import org.apache.lucene.queryParser.ParseException;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import static com.muzima.utils.Constants.LOCAL_PATIENT;
import static org.apache.commons.lang.StringUtils.isEmpty;

public class PatientController {

    public static final String TAG = "PatientController";
    private PatientService patientService;
    private CohortService cohortService;

    public PatientController(PatientService patientService, CohortService cohortService) {
        this.patientService = patientService;
        this.cohortService = cohortService;
    }

    public void replacePatients(List<Patient> patients) throws PatientReplaceException {
        try {
            patientService.updatePatients(patients);
        } catch (IOException e) {
            throw new PatientReplaceException(e);
        }
    }

    public List<Patient> getPatients(String cohortId) throws PatientLoadException {
        try {
            List<CohortMember> cohortMembers = cohortService.getCohortMembers(cohortId);
            //TODO: Replace this with Google Guava
            List<Patient> patients = new ArrayList<Patient>();
            for (CohortMember member : cohortMembers) {
                patients.add(member.getPatient());
            }
            return patients;
        } catch (IOException e) {
            throw new PatientLoadException(e);
        }
    }

    public List<Patient> getAllPatients() throws PatientLoadException {
        try {
            return patientService.getAllPatients();
        } catch (IOException e) {
            throw new PatientLoadException(e);
        }
    }

    public int getTotalPatientsCount() throws PatientLoadException {
        try {
            return patientService.countAllPatients();
        } catch (IOException e) {
            throw new PatientLoadException(e);
        }
    }

    public Patient getPatientByUuid(String uuid) throws PatientLoadException {
        try {
            return patientService.getPatientByUuid(uuid);
        } catch (IOException e) {
{'fraction_non_alphanumeric': 0.07936507936507936, 'fraction_numerical': 0.0, 'mean_word_length': 2.964403973509934, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5829174', 'n_tokens_mistral': 1332, 'n_tokens_neox': 1206, 'n_words': 278}