Search in sources :

Example 1 with OptionSet

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

the class ActivityReportingServiceImpl method getAttsForMobile.

@Override
public List<org.hisp.dhis.api.mobile.model.PatientAttribute> getAttsForMobile() {
    List<org.hisp.dhis.api.mobile.model.PatientAttribute> list = new ArrayList<>();
    for (TrackedEntityAttribute patientAtt : getPatientAtts(null)) {
        PatientAttribute patientAttribute = new PatientAttribute(patientAtt.getName(), null, null, false, patientAtt.getDisplayInListNoProgram(), new OptionSet());
        patientAttribute.setType(patientAtt.getValueType());
        list.add(patientAttribute);
    }
    return list;
}
Also used : TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute) PatientAttribute(org.hisp.dhis.api.mobile.model.PatientAttribute) ArrayList(java.util.ArrayList) OptionSet(org.hisp.dhis.api.mobile.model.OptionSet)

Example 2 with OptionSet

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

the class ProgramStageDataElement method deSerialize.

@Override
public void deSerialize(DataInputStream dint) throws IOException {
    super.deSerialize(dint);
    this.setType(dint.readUTF());
    if (dint.readBoolean()) {
        this.setNumberType(dint.readUTF());
    } else {
        this.setNumberType(null);
    }
    this.setCompulsory(dint.readBoolean());
    this.categoryOptionCombos = new ModelList();
    this.categoryOptionCombos.deSerialize(dint);
    if (dint.readBoolean() == false) {
        this.optionSet = null;
    } else {
        this.optionSet = new OptionSet();
        this.optionSet.deSerialize(dint);
    }
    if (dint.readBoolean() == false) {
        this.setValue(null);
    } else {
        this.setValue(dint.readUTF());
    }
}
Also used : ModelList(org.hisp.dhis.api.mobile.model.ModelList) OptionSet(org.hisp.dhis.api.mobile.model.OptionSet)

Example 3 with OptionSet

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

the class DefaultProgramService method getPatientAttributeForMobile.

private org.hisp.dhis.api.mobile.model.PatientAttribute getPatientAttributeForMobile(ProgramTrackedEntityAttribute ppa) {
    TrackedEntityAttribute pa = ppa.getAttribute();
    org.hisp.dhis.api.mobile.model.PatientAttribute mobileAttribute = new org.hisp.dhis.api.mobile.model.PatientAttribute();
    mobileAttribute.setName(pa.getName());
    mobileAttribute.setType(pa.getValueType());
    mobileAttribute.setValue("");
    if (ppa.isDisplayInList()) {
        mobileAttribute.setDisplayedInList(true);
    } else {
        mobileAttribute.setDisplayedInList(false);
    }
    mobileAttribute.setMandatory(ppa.isMandatory());
    if (pa.hasOptionSet()) {
        OptionSet optionSet = new OptionSet();
        if (pa.getOptionSet() != null) {
            optionSet.setId(pa.getOptionSet().getId());
            optionSet.setName(pa.getOptionSet().getName());
            optionSet.setOptions(pa.getOptionSet().getOptionValues());
            mobileAttribute.setOptionSet(optionSet);
        }
    }
    return mobileAttribute;
}
Also used : ProgramTrackedEntityAttribute(org.hisp.dhis.program.ProgramTrackedEntityAttribute) TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute) OptionSet(org.hisp.dhis.api.mobile.model.OptionSet)

Example 4 with OptionSet

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

the class ActivityReportingServiceImpl method getPatientModel.

// get patient model for LWUIT
private org.hisp.dhis.api.mobile.model.LWUITmodel.Patient getPatientModel(TrackedEntityInstance patient) {
    org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patientModel = new org.hisp.dhis.api.mobile.model.LWUITmodel.Patient();
    List<org.hisp.dhis.api.mobile.model.PatientAttribute> patientAtts = new ArrayList<>();
    List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramInstance> mobileProgramInstanceList = new ArrayList<>();
    List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramInstance> mobileCompletedProgramInstanceList = new ArrayList<>();
    patientModel.setId(patient.getId());
    if (patient.getOrganisationUnit() != null) {
        patientModel.setOrganisationUnitName(patient.getOrganisationUnit().getName());
    }
    if (patient.getTrackedEntity() != null) {
        patientModel.setTrackedEntityName(patient.getTrackedEntity().getName());
    } else {
        patientModel.setTrackedEntityName("");
    }
    List<TrackedEntityAttributeValue> atts = new ArrayList<>(patient.getTrackedEntityAttributeValues());
    for (TrackedEntityAttributeValue value : atts) {
        if (value != null) {
            org.hisp.dhis.api.mobile.model.PatientAttribute patientAttribute = new org.hisp.dhis.api.mobile.model.PatientAttribute(value.getAttribute().getName(), value.getValue(), null, false, value.getAttribute().getDisplayInListNoProgram(), new OptionSet());
            patientAttribute.setType(value.getAttribute().getValueType());
            patientAtts.add(patientAttribute);
        }
    }
    patientModel.setAttributes(patientAtts);
    List<ProgramInstance> listOfProgramInstance = new ArrayList<>(programInstanceService.getProgramInstances(new ProgramInstanceQueryParams().setTrackedEntityInstance(patient).setProgramStatus(ProgramStatus.ACTIVE).setOrganisationUnitMode(OrganisationUnitSelectionMode.ALL)));
    if (listOfProgramInstance.size() > 0) {
        for (ProgramInstance each : listOfProgramInstance) {
            mobileProgramInstanceList.add(getMobileProgramInstance(each));
        }
    }
    patientModel.setEnrollmentPrograms(mobileProgramInstanceList);
    List<ProgramInstance> listOfCompletedProgramInstance = new ArrayList<>(programInstanceService.getProgramInstances(new ProgramInstanceQueryParams().setTrackedEntityInstance(patient).setProgramStatus(ProgramStatus.COMPLETED).setOrganisationUnitMode(OrganisationUnitSelectionMode.ALL)));
    if (listOfCompletedProgramInstance.size() > 0) {
        for (ProgramInstance each : listOfCompletedProgramInstance) {
            mobileCompletedProgramInstanceList.add(getMobileProgramInstance(each));
        }
    }
    patientModel.setCompletedPrograms(mobileCompletedProgramInstanceList);
    // Set Relationship
    Collection<Relationship> relationships = relationshipService.getRelationshipsForTrackedEntityInstance(patient);
    List<org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship> relationshipList = new ArrayList<>();
    for (Relationship eachRelationship : relationships) {
        org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship relationshipMobile = new org.hisp.dhis.api.mobile.model.LWUITmodel.Relationship();
        relationshipMobile.setId(eachRelationship.getId());
        if (eachRelationship.getEntityInstanceA().getId() == patient.getId()) {
            relationshipMobile.setName(eachRelationship.getRelationshipType().getaIsToB());
            relationshipMobile.setaIsToB(eachRelationship.getRelationshipType().getaIsToB());
            relationshipMobile.setbIsToA(eachRelationship.getRelationshipType().getbIsToA());
            relationshipMobile.setPersonBId(eachRelationship.getEntityInstanceB().getId());
        } else {
            relationshipMobile.setName(eachRelationship.getRelationshipType().getbIsToA());
            relationshipMobile.setaIsToB(eachRelationship.getRelationshipType().getbIsToA());
            relationshipMobile.setbIsToA(eachRelationship.getRelationshipType().getaIsToB());
            relationshipMobile.setPersonBId(eachRelationship.getEntityInstanceA().getId());
        }
        // get relative's name
        TrackedEntityInstance relative = entityInstanceService.getTrackedEntityInstance(relationshipMobile.getPersonBId());
        List<TrackedEntityAttributeValue> attributes = new ArrayList<>(relative.getTrackedEntityAttributeValues());
        List<TrackedEntityAttributeValue> attributesInList = new ArrayList<>();
        for (TrackedEntityAttributeValue value : attributes) {
            if (value != null && value.getAttribute().getDisplayInListNoProgram()) {
                attributesInList.add(value);
            }
        }
        Collections.sort(attributesInList, new TrackedEntityAttributeValueSortOrderComparator());
        String relativeName = "";
        for (TrackedEntityAttributeValue value : attributesInList) {
            if (value != null && value.getAttribute().getDisplayInListNoProgram()) {
                relativeName += value.getValue() + " ";
            }
        }
        relationshipMobile.setPersonBName(relativeName);
        relationshipList.add(relationshipMobile);
    }
    patientModel.setRelationships(relationshipList);
    return patientModel;
}
Also used : Patient(org.hisp.dhis.api.mobile.model.LWUITmodel.Patient) ProgramInstance(org.hisp.dhis.program.ProgramInstance) TrackedEntityAttributeValueSortOrderComparator(org.hisp.dhis.api.mobile.model.comparator.TrackedEntityAttributeValueSortOrderComparator) ArrayList(java.util.ArrayList) PatientAttribute(org.hisp.dhis.api.mobile.model.PatientAttribute) PatientAttribute(org.hisp.dhis.api.mobile.model.PatientAttribute) TrackedEntityAttributeValue(org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue) Patient(org.hisp.dhis.api.mobile.model.LWUITmodel.Patient) TrackedEntityInstance(org.hisp.dhis.trackedentity.TrackedEntityInstance) Relationship(org.hisp.dhis.relationship.Relationship) OptionSet(org.hisp.dhis.api.mobile.model.OptionSet) ProgramInstanceQueryParams(org.hisp.dhis.program.ProgramInstanceQueryParams)

Example 5 with OptionSet

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

the class ModelMapping method getOptionSet.

public static OptionSet getOptionSet(org.hisp.dhis.dataelement.DataElement dataElement) {
    org.hisp.dhis.option.OptionSet dhisOptionSet = dataElement.getOptionSet();
    OptionSet mobileOptionSet = new OptionSet();
    if (dhisOptionSet != null) {
        mobileOptionSet.setId(dhisOptionSet.getId());
        mobileOptionSet.setName(dhisOptionSet.getName());
        mobileOptionSet.setOptions(dhisOptionSet.getOptionValues());
    } else {
        return null;
    }
    return mobileOptionSet;
}
Also used : OptionSet(org.hisp.dhis.api.mobile.model.OptionSet)

Aggregations

OptionSet (org.hisp.dhis.api.mobile.model.OptionSet)5 ArrayList (java.util.ArrayList)2 PatientAttribute (org.hisp.dhis.api.mobile.model.PatientAttribute)2 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)2 Patient (org.hisp.dhis.api.mobile.model.LWUITmodel.Patient)1 ModelList (org.hisp.dhis.api.mobile.model.ModelList)1 TrackedEntityAttributeValueSortOrderComparator (org.hisp.dhis.api.mobile.model.comparator.TrackedEntityAttributeValueSortOrderComparator)1 ProgramInstance (org.hisp.dhis.program.ProgramInstance)1 ProgramInstanceQueryParams (org.hisp.dhis.program.ProgramInstanceQueryParams)1 ProgramTrackedEntityAttribute (org.hisp.dhis.program.ProgramTrackedEntityAttribute)1 Relationship (org.hisp.dhis.relationship.Relationship)1 TrackedEntityInstance (org.hisp.dhis.trackedentity.TrackedEntityInstance)1 TrackedEntityAttributeValue (org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue)1