Skip to content

Commit

Permalink
Fixed issue #557 - Improve the formatting for associated complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
nehav39 committed Nov 15, 2019
1 parent dc70a7f commit e63b372
Showing 1 changed file with 1 addition and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ public class QuestionNodeActivity extends AppCompatActivity {
private String encounterVitals;
private String encounterAdultIntials;

private List<Node> optionsList = new ArrayList<>();
Node assoSympNode;
private JSONObject assoSympObj = new JSONObject();
private JSONArray assoSympArr = new JSONArray();
private JSONObject finalAssoSympObj = new JSONObject();

@Override
protected void onCreate(Bundle savedInstanceState) {
sessionManager = new SessionManager(this);
Expand Down Expand Up @@ -290,10 +284,6 @@ private void fabClick() {
complaintNumber++;
setupQuestions(complaintNumber);
complaintConfirmed = false;
} else if (complaints.size() > 1 && complaintNumber == complaints.size() - 1) {
complaintNumber++;
removeDuplicateSymptoms();
complaintConfirmed = false;
} else {
if (intentTag != null && intentTag.equals("edit")) {
Log.i(TAG, "fabClick: update" + insertion);
Expand Down Expand Up @@ -408,92 +398,14 @@ private void updateDatabase(String string) {
private void setupQuestions(int complaintIndex) {
nodeComplete = false;

if (complaints.size() > 1) {
getAssociatedSymptoms(complaintIndex);
} else {
currentNode = complaintsNodes.get(complaintIndex);
}
currentNode = complaintsNodes.get(complaintIndex);

adapter = new CustomExpandableListAdapter(this, currentNode, this.getClass().getSimpleName());
questionListView.setAdapter(adapter);
questionListView.setChoiceMode(ExpandableListView.CHOICE_MODE_MULTIPLE);
questionListView.expandGroup(0);
setTitle(patientName + ": " + currentNode.findDisplay());
}

private void getAssociatedSymptoms(int complaintIndex) {

List<Node> assoComplaintsNodes = new ArrayList<>();
assoComplaintsNodes.addAll(complaintsNodes);

for (int i = 0; i < complaintsNodes.get(complaintIndex).size(); i++) {

if (complaintsNodes.get(complaintIndex).getOptionsList().get(i).getText()
.equalsIgnoreCase("Associated symptoms")) {

optionsList.addAll(complaintsNodes.get(complaintIndex).getOptionsList().get(i).getOptionsList());

assoComplaintsNodes.get(complaintIndex).getOptionsList().remove(i);
currentNode = assoComplaintsNodes.get(complaintIndex);
Log.e("CurrentNode", "" + currentNode);

}
}
}

private void removeDuplicateSymptoms() {

nodeComplete = false;

HashSet<String> hashSet = new HashSet<>();

List<Node> finalOptionsList = new ArrayList<>(optionsList);

if (optionsList.size() != 0) {

for (int i = 0; i < optionsList.size(); i++) {

if (hashSet.contains(optionsList.get(i).getText())) {

finalOptionsList.remove(optionsList.get(i));

} else {
hashSet.add(optionsList.get(i).getText());
}
}

try {
assoSympObj.put("id", "ID_294177528");
assoSympObj.put("text", "Associated symptoms");
assoSympObj.put("display", "Do you have the following symptom(s)?");
assoSympObj.put("display-or", "ତମର ଏହି ଲକ୍ଷଣ ସବୁ ଅଛି କି?");
assoSympObj.put("pos-condition", "c.");
assoSympObj.put("neg-condition", "s.");
assoSympArr.put(0, assoSympObj);
finalAssoSympObj.put("id", "ID_844006222");
finalAssoSympObj.put("text", "Associated symptoms");
finalAssoSympObj.put("display-or", "ପେଟଯନ୍ତ୍ରଣା");
finalAssoSympObj.put("perform-physical-exam", "");
finalAssoSympObj.put("options", assoSympArr);

} catch (JSONException e) {
e.printStackTrace();
}

assoSympNode = new Node(finalAssoSympObj);
assoSympNode.getOptionsList().get(0).setOptionsList(finalOptionsList);
assoSympNode.getOptionsList().get(0).setTerminal(false);

currentNode = assoSympNode;
adapter = new CustomExpandableListAdapter(this, currentNode, this.getClass().getSimpleName());
questionListView.setAdapter(adapter);
questionListView.setChoiceMode(ExpandableListView.CHOICE_MODE_MULTIPLE);
questionListView.expandGroup(0);
setTitle(patientName + ": " + currentNode.getText());

}
}

//Dialog Alert forcing user to answer all questions.
//Can be removed if necessary
//TODO: Add setting to allow for all questions unrequired..addAll(Arrays.asList(splitExams))
Expand Down

0 comments on commit e63b372

Please sign in to comment.