List list = q.getResultList();
if (!list.isEmpty()){
Diagnosis finalDiag = (Diagnosis) list.get(0);
info.mainFollowStage = getFollowupStage(finalDiag);
if (info.mainFollowStage == Followup.FOLLOWUP_GET_OUT){
info.mainFollowDownReason = getDownReasonExtKey(finalDiag);
}
List<Diagnosis> diagnosises = findEntityList(Diagnosis.class, "referenced", finalDiag);
if (diagnosises.size() > 0){
Diagnosis d = diagnosises.get(0);
info.attendant0DiagnosisMkbID = d.getMkb10().getId();
info.attendant0FollowStage = getFollowupStage(d);
if (d.getEncounter() == null) {
info.attendant0DiagnosisEncounter = 1;
} else {
info.attendant0DiagnosisEncounter = d.getEncounter().isPlus() ? 1 : 2;
}
if (info.attendant0FollowStage != 0){
if (info.attendant0FollowStage == Followup.FOLLOWUP_GET_OUT){
info.attendant0FollowDownReason = getDownReasonExtKey(d);
}
}
}
if (diagnosises.size() > 1){
Diagnosis d = diagnosises.get(1);
info.attendant1DiagnosisMkbID = d.getMkb10().getId();
info.attendant1FollowStage = getFollowupStage(d);
if (d.getEncounter() == null) {
info.attendant1DiagnosisEncounter = 1;
} else {
info.attendant1DiagnosisEncounter = d.getEncounter().isPlus() ? 1 : 2;
}
if (info.attendant1FollowStage == 0){
if (info.attendant1FollowStage == Followup.FOLLOWUP_GET_OUT){
info.attendant1FollowDownReason = getDownReasonExtKey(d);
}