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;
}
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());
}
}
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;
}
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;
}
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;
}
Aggregations