use of org.hisp.dhis.api.mobile.model.PatientAttribute in project dhis2-core by dhis2.
the class Program method deSerialize.
@Override
public void deSerialize(DataInputStream dataInputStream) throws IOException {
super.deSerialize(dataInputStream);
this.setVersion(dataInputStream.readInt());
this.setType(dataInputStream.readInt());
this.setDateOfEnrollmentDescription(dataInputStream.readUTF());
this.setDateOfIncidentDescription(dataInputStream.readUTF());
this.setTrackedEntityName(dataInputStream.readUTF());
// Read program stage
int programStageNumber = dataInputStream.readInt();
if (programStageNumber > 0) {
for (int i = 0; i < programStageNumber; i++) {
ProgramStage programStage = new ProgramStage();
programStage.deSerialize(dataInputStream);
programStages.add(programStage);
}
}
// Read program attribute
int programAttSize = dataInputStream.readInt();
if (programAttSize > 0) {
for (int i = 0; i < programAttSize; i++) {
PatientAttribute pa = new PatientAttribute();
pa.deSerialize(dataInputStream);
programAttributes.add(pa);
}
}
this.setRelationshipText(dataInputStream.readUTF());
this.setRelatedProgramId(dataInputStream.readInt());
this.setRelationshipType(dataInputStream.readInt());
}
use of org.hisp.dhis.api.mobile.model.PatientAttribute in project dhis2-core by dhis2.
the class Program method serialize.
@Override
public void serialize(DataOutputStream dout) throws IOException {
super.serialize(dout);
dout.writeInt(getVersion());
dout.writeInt(this.getType());
dout.writeUTF(getDateOfEnrollmentDescription());
dout.writeUTF(getDateOfIncidentDescription());
dout.writeUTF(getTrackedEntityName());
// Write program stage
dout.writeInt(programStages.size());
for (ProgramStage ps : programStages) {
ps.serialize(dout);
}
// Write program attribute
dout.writeInt(programAttributes.size());
for (PatientAttribute pa : programAttributes) {
pa.serialize(dout);
}
String relationshipText = getRelationshipText();
if (relationshipText == null) {
dout.writeUTF("");
} else {
dout.writeUTF(getRelationshipText());
}
dout.writeInt(getRelatedProgramId());
dout.writeInt(relationshipType);
}
use of org.hisp.dhis.api.mobile.model.PatientAttribute 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.PatientAttribute in project dhis2-core by dhis2.
the class Patient method deSerialize.
@Override
public void deSerialize(DataInputStream din) throws IOException, EOFException {
this.setId(din.readInt());
this.setOrganisationUnitName(din.readUTF());
this.setTrackedEntityName(din.readUTF());
// Read Attribute
int attsNumb = din.readInt();
if (attsNumb > 0) {
attributes = new ArrayList<>();
for (int j = 0; j < attsNumb; j++) {
PatientAttribute pa = new PatientAttribute();
pa.deSerialize(din);
attributes.add(pa);
}
}
// Read enrollment programs
int numbEnrollmentPrograms = din.readInt();
if (numbEnrollmentPrograms > 0) {
this.enrollmentPrograms = new ArrayList<>();
for (int i = 0; i < numbEnrollmentPrograms; i++) {
ProgramInstance program = new ProgramInstance();
program.deSerialize(din);
this.enrollmentPrograms.add(program);
}
}
// Read completed programs
int numbCompletedPrograms = din.readInt();
if (numbCompletedPrograms > 0) {
this.completedPrograms = new ArrayList<>();
for (int i = 0; i < numbCompletedPrograms; i++) {
ProgramInstance program = new ProgramInstance();
program.deSerialize(din);
this.completedPrograms.add(program);
}
}
// Read relationships
int numbRelationships = din.readInt();
if (numbRelationships > 0) {
this.relationships = new ArrayList<>();
for (int i = 0; i < numbRelationships; i++) {
Relationship relationship = new Relationship();
relationship.deSerialize(din);
this.relationships.add(relationship);
}
}
this.setIdToAddRelative(din.readInt());
this.setRelTypeIdToAdd(din.readInt());
int numEnrollmentRelationships = din.readInt();
if (numEnrollmentRelationships > 0) {
Relationship enrollmentRelationship = new Relationship();
enrollmentRelationship.deSerialize(din);
this.setEnrollmentRelationship(enrollmentRelationship);
}
}
use of org.hisp.dhis.api.mobile.model.PatientAttribute in project dhis2-core by dhis2.
the class PatientIdentifierAndAttribute method serializeVersion2_10.
@Override
public void serializeVersion2_10(DataOutputStream dout) throws IOException {
if (patientAttributes == null) {
dout.writeInt(0);
} else {
dout.writeInt(patientAttributes.size());
for (PatientAttribute pa : patientAttributes) {
pa.setClientVersion(DataStreamSerializable.TWO_POINT_TEN);
pa.serialize(dout);
}
}
}
Aggregations