Search in sources :

Example 1 with Beneficiary

use of org.hisp.dhis.api.mobile.model.Beneficiary in project dhis2-core by dhis2.

the class ActivityReportingServiceImpl method getBeneficiaryModel.

private Beneficiary getBeneficiaryModel(TrackedEntityInstance patient) {
    Beneficiary beneficiary = new Beneficiary();
    List<org.hisp.dhis.api.mobile.model.PatientAttribute> patientAtts = new ArrayList<>();
    beneficiary.setId(patient.getId());
    beneficiary.setName(patient.getName());
    // Set attribute which is used to group beneficiary on mobile (only if
    // there is attribute which is set to be group factor)
    org.hisp.dhis.api.mobile.model.PatientAttribute beneficiaryAttribute = null;
    if (groupByAttribute != null) {
        beneficiaryAttribute = new org.hisp.dhis.api.mobile.model.PatientAttribute();
        beneficiaryAttribute.setName(groupByAttribute.getName());
        TrackedEntityAttributeValue value = attValueService.getTrackedEntityAttributeValue(patient, groupByAttribute);
        beneficiaryAttribute.setValue(value == null ? "Unknown" : value.getValue());
        beneficiary.setGroupAttribute(beneficiaryAttribute);
    }
    beneficiary.setPatientAttValues(patientAtts);
    return beneficiary;
}
Also used : PatientAttribute(org.hisp.dhis.api.mobile.model.PatientAttribute) PatientAttribute(org.hisp.dhis.api.mobile.model.PatientAttribute) TrackedEntityAttributeValue(org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue) ArrayList(java.util.ArrayList) Beneficiary(org.hisp.dhis.api.mobile.model.Beneficiary)

Aggregations

ArrayList (java.util.ArrayList)1 Beneficiary (org.hisp.dhis.api.mobile.model.Beneficiary)1 PatientAttribute (org.hisp.dhis.api.mobile.model.PatientAttribute)1 TrackedEntityAttributeValue (org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue)1