/*
* Copyright (c) 2014. The Trustees of Indiana University.
*
* This version of the code is licensed under the MPL 2.0 Open Source license with additional
* healthcare disclaimer. If the user is an entity intending to commercialize any application
* that uses this code in a for-profit venture, please contact the copyright holder.
*/
package com.muzima.adapters.observations;
import com.muzima.api.model.Concept;
import com.muzima.controller.ConceptController;
import com.muzima.controller.ObservationController;
import com.muzima.model.observation.Concepts;
import java.io.IOException;
import java.util.List;
public class ConceptsByPatient extends ConceptAction {
private String patientUuid;
private ObservationController controller;
private ConceptController conceptController;
public ConceptsByPatient(ConceptController conceptController, ObservationController controller, String patientUuid) {
this.controller = controller;
this.patientUuid = patientUuid;
this.conceptController = conceptController;
}
@Override
Concepts get() throws ObservationController.LoadObservationException {
return controller.getConceptWithObservations(patientUuid);
}
@Override
Concepts get(Concept concept) throws ObservationController.LoadObservationException {
return controller.getConceptWithObservations(patientUuid,concept.getUuid());
}
@Override
List<Concept> getConcepts() throws ObservationController.LoadObservationException{
try {
return conceptController.getConcepts();
}catch (ConceptController.ConceptFetchException e){
throw new ObservationController.LoadObservationException(e);
}
}
@Override
public String toString() {
return "ConceptsByPatient{" +
"patientUuid='" + patientUuid + '\'' +
", controller=" + controller +
'}';
}
}