Skip to content

Commit

Permalink
Added Milestone for End of Treatment in FlowshetUI
Browse files Browse the repository at this point in the history
Modified Highlighted milestone for continuation 6 months after treatment
end date
  • Loading branch information
Omar Ahmed committed Jan 29, 2017
1 parent c7b6f0d commit b570e11
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ hs_err_pid*

.idea
target/
*.iml
*.iml
/bin/
16 changes: 13 additions & 3 deletions omod/src/main/java/org/bahmni/flowsheet/ui/FlowsheetUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public class FlowsheetUI {

private List<Milestone> milestones;
private Map<String, List<String>> flowsheetData;
private String highlightedMilestone;
private String highlightedCurrentMilestone;
private String endDateMilestone;

public Map<String, List<String>> getFlowsheetData() {
if(null == this.flowsheetData) {
Expand All @@ -27,11 +28,11 @@ public void setFlowsheetData(Map<String, List<String>> flowsheetData) {
}

public String getHighlightedMilestone() {
return highlightedMilestone;
return highlightedCurrentMilestone;
}

public void setHighlightedMilestone(String highlightedMilestone) {
this.highlightedMilestone = highlightedMilestone;
this.highlightedCurrentMilestone = highlightedMilestone;
}

public List<Milestone> getMilestones() {
Expand All @@ -41,4 +42,13 @@ public List<Milestone> getMilestones() {
public void setMilestones(List<Milestone> milestones) {
this.milestones = milestones;
}

public String getEndDateMilestone() {
return endDateMilestone;
}

public void setEndDateMilestone(String endDateMilestone) {
this.endDateMilestone = endDateMilestone;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ public FlowsheetUI getFlowsheetForPatientProgram(PatientProgram patientProgram,

Set<String> floatingMilestoneNames = getFloatingMilestoneNames(flowsheetConfig.getMilestoneConfigs());
setNotApplicableStatusToFixedMilestones(endDate, milestones, floatingMilestoneNames);
String highlightedMilestoneName = findHighlightedMilestoneInFixedMilestones(milestones, endDate, floatingMilestoneNames);

String highlightedCurrentMilestoneName = findCurrentMonthMilestone(milestones, endDate, floatingMilestoneNames);
String treatmentEndMilestoneName = findEndDateMilestone(milestones, endDate, floatingMilestoneNames);

List<QuestionConfig> questionConfigs = flowsheetConfig.getQuestionConfigs();

Map<String, List<String>> flowsheetData = new LinkedHashMap<>();
Expand All @@ -99,7 +100,8 @@ public FlowsheetUI getFlowsheetForPatientProgram(PatientProgram patientProgram,
}

presentationFlowsheet.setMilestones(flowsheetMilestones);
presentationFlowsheet.setHighlightedMilestone(highlightedMilestoneName);
presentationFlowsheet.setHighlightedMilestone(highlightedCurrentMilestoneName);
presentationFlowsheet.setEndDateMilestone(treatmentEndMilestoneName);
presentationFlowsheet.setFlowsheetData(flowsheetData);
return presentationFlowsheet;
}
Expand Down Expand Up @@ -244,17 +246,43 @@ private String getProgramAttribute(BahmniPatientProgram bahmniPatientProgram, St
return "";
}

private String findHighlightedMilestoneInFixedMilestones(Set<Milestone> milestones, Date endDate, Set<String> floatingMilestones) {
private String findCurrentMonthMilestone(Set<Milestone> milestones, Date endDate, Set<String> floatingMilestones) {
if (endDate == null) {
endDate = new Date();
}

//TODO: Use the following snippet based on Configuration json

Calendar cal = GregorianCalendar.getInstance();
cal.setTime(endDate);
cal.add(6, Calendar.MONTH);
endDate = cal.getTime();

for (Milestone milestone : milestones) {
if ((!floatingMilestones.contains(milestone.getName())) && (milestone.getStartDate().before(endDate) || DateUtils.isSameDay(milestone.getStartDate(), endDate)) && (milestone.getEndDate().after(endDate) || DateUtils.isSameDay(milestone.getEndDate(), endDate))) {
if ((!floatingMilestones.contains(milestone.getName()))
&& (milestone.getStartDate().before(endDate) || DateUtils.isSameDay(milestone.getStartDate(), endDate))
&& (milestone.getEndDate().after(endDate) || DateUtils.isSameDay(milestone.getEndDate(), endDate))) {
return milestone.getName();
}
}
return "";
}

private String findEndDateMilestone(Set<Milestone> milestones, Date endDate, Set<String> floatingMilestones) {
if (endDate == null) {
endDate = new Date();
}

for (Milestone milestone : milestones) {
if ((!floatingMilestones.contains(milestone.getName()))
&& (milestone.getStartDate().before(endDate) || DateUtils.isSameDay(milestone.getStartDate(), endDate))
&& (milestone.getEndDate().after(endDate) || DateUtils.isSameDay(milestone.getEndDate(), endDate))) {
return milestone.getName();
}
}
return "";
}


private Set<String> getFloatingMilestoneNames(List<MilestoneConfig> milestoneConfigs) {
Set<String> floatingMilestoneNames = new HashSet<>();
Expand Down Expand Up @@ -288,10 +316,10 @@ private String getColorCodeForStatus(Status status) {
return "green";
}
if (status.equals(Status.PLANNED)) {
return "yellow";
return "grey";
}
if (status.equals(Status.PENDING)) {
return "purple";
return "grey";
}
if (status.equals(Status.NOT_APPLICABLE)) {
return "grey";
Expand Down

0 comments on commit b570e11

Please sign in to comment.