Skip to content

Commit

Permalink
Omar Ahmed |ED-4|Patient Monitoring tool improvments for configurable
Browse files Browse the repository at this point in the history
status tracking
  • Loading branch information
Omar Ahmed committed Feb 1, 2017
1 parent b570e11 commit 65b3cc6
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
import java.util.List;

public class FlowsheetConfig {
private boolean trackPending;
private boolean trackPlanned;
private int monthsPostTreatEnd;

private List<MilestoneConfig> milestoneConfigs;
private List<QuestionConfig> questionConfigs = new ArrayList<>();

Expand Down Expand Up @@ -37,4 +41,35 @@ public QuestionConfig getQuestionConfigByName(String name){
}
return null;
}

@JsonProperty(FlowsheetConstant.TRACK_PENDING)
public boolean getTrackPending() {
return trackPending;
}

@JsonProperty(FlowsheetConstant.TRACK_PENDING)
public void setTrackPending(boolean trackPending) {
this.trackPending = trackPending;
}

@JsonProperty(FlowsheetConstant.TRACK_PLANNED)
public boolean getTrackPlanned() {
return trackPlanned;
}

@JsonProperty(FlowsheetConstant.TRACK_PLANNED)
public void setTrackPlanned(boolean trackPlanned) {
this.trackPlanned = trackPlanned;
}

@JsonProperty(FlowsheetConstant.MONTHS_POST_TREATMENT_END)
public int getMonthsPostTreatEnd() {
return monthsPostTreatEnd;
}

@JsonProperty(FlowsheetConstant.MONTHS_POST_TREATMENT_END)
public void setMonthsPostTreatEnd(int monthsPostTreatEnd) {
this.monthsPostTreatEnd = monthsPostTreatEnd;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@ private FlowsheetConstant() {
public static final String MAX = "max";
public static final String HANDLER = "handler" ;
public static final String QUESTIONS = "questions";
public static final String CONFIG = "config";
public static final String CONFIG = "config";
public static final String TRACK_PLANNED = "trackPlanned";
public static final String TRACK_PENDING= "trackPending";
public static final String MONTHS_POST_TREATMENT_END = "monthsPostTreatmentEnd";

}
6 changes: 3 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 @@ -27,12 +27,12 @@ public void setFlowsheetData(Map<String, List<String>> flowsheetData) {
this.flowsheetData = flowsheetData;
}

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

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

public List<Milestone> getMilestones() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,15 @@ public FlowsheetUI getFlowsheetForPatientProgram(PatientProgram patientProgram,

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

int monthsPostTreatment=0;
if(flowsheetConfig.getMonthsPostTreatEnd()> -1)
{
monthsPostTreatment = flowsheetConfig.getMonthsPostTreatEnd();
}

String highlightedCurrentMilestoneName = findCurrentMonthMilestone(milestones, endDate, floatingMilestoneNames, monthsPostTreatment);

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

List<QuestionConfig> questionConfigs = flowsheetConfig.getQuestionConfigs();
Expand All @@ -83,12 +91,8 @@ public FlowsheetUI getFlowsheetForPatientProgram(PatientProgram patientProgram,
String questionName = questionConfig.getName();
List<String> colorCodes = new LinkedList<>();
for (Milestone milestone : milestones) {
Question milestoneQuestion = getQuestionFromSet(milestone.getQuestions(), questionName);
if (milestoneQuestion == null) {
colorCodes.add("grey");
} else {
colorCodes.add(getColorCodeForStatus(milestoneQuestion.getResult().getStatus()));
}
Question milestoneQuestion = getQuestionFromSet(milestone.getQuestions(), questionName);
colorCodes.add(getColorCodeForStatus(milestoneQuestion, flowsheetConfig));
}
flowsheetData.put(questionName, colorCodes);
}
Expand All @@ -100,7 +104,7 @@ public FlowsheetUI getFlowsheetForPatientProgram(PatientProgram patientProgram,
}

presentationFlowsheet.setMilestones(flowsheetMilestones);
presentationFlowsheet.setHighlightedMilestone(highlightedCurrentMilestoneName);
presentationFlowsheet.setHighlightedCurrentMilestone(highlightedCurrentMilestoneName);
presentationFlowsheet.setEndDateMilestone(treatmentEndMilestoneName);
presentationFlowsheet.setFlowsheetData(flowsheetData);
return presentationFlowsheet;
Expand Down Expand Up @@ -246,26 +250,39 @@ private String getProgramAttribute(BahmniPatientProgram bahmniPatientProgram, St
return "";
}

private String findCurrentMonthMilestone(Set<Milestone> milestones, Date endDate, Set<String> floatingMilestones) {
private String findCurrentMonthMilestone(Set<Milestone> milestones, Date endDate, Set<String> floatingMilestones,int monthsPostEndDate) {
Date currentDate = new Date();
Date endDatePlusMonths = null;
Milestone currentMilestone=null;

if (endDate == null) {
endDate = new Date();
}
boolean trackAfterEndDate=false;

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

if(monthsPostEndDate>0)
{
trackAfterEndDate = true;
}
Calendar cal = GregorianCalendar.getInstance();
cal.setTime(endDate);
cal.add(6, Calendar.MONTH);
endDate = cal.getTime();

cal.add(Calendar.MONTH, monthsPostEndDate);
endDatePlusMonths = 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))) {
return milestone.getName();
if( (!floatingMilestones.contains(milestone.getName()))
&& (milestone.getStartDate().before(currentDate) || DateUtils.isSameDay(milestone.getStartDate(), currentDate))
&& (milestone.getEndDate().after(currentDate) || DateUtils.isSameDay(milestone.getEndDate(), currentDate))) {
currentMilestone = milestone;
break;
}
}
return "";
if(currentMilestone==null)
return "";
if(currentMilestone.getStartDate().before(endDatePlusMonths))
return currentMilestone.getName();
else
return "";
}

private String findEndDateMilestone(Set<Milestone> milestones, Date endDate, Set<String> floatingMilestones) {
Expand Down Expand Up @@ -311,20 +328,32 @@ private FlowsheetConfig getFlowsheetConfig(String configFilePath) throws Excepti
return flowsheetConfig;
}

private String getColorCodeForStatus(Status status) {
if (status.equals(Status.DATA_ADDED)) {
return "green";
private String getColorCodeForStatus(Question milestoneQuestion, FlowsheetConfig flowsheetConf) {

String result="grey";
if(milestoneQuestion == null || milestoneQuestion.getResult() == null)
return result;

Status status = milestoneQuestion.getResult().getStatus();

if (status.equals(Status.DATA_ADDED)) {
result = "green";
}
if (status.equals(Status.PLANNED)) {
return "grey";

if ( status.equals(Status.PLANNED)) {
if(flowsheetConf.getTrackPlanned())
result = "yellow";
}

if (status.equals(Status.PENDING)) {
return "grey";
if(flowsheetConf.getTrackPending())
result = "purple";
}

if (status.equals(Status.NOT_APPLICABLE)) {
return "grey";
result="grey";
}
return "grey";
return result;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void shouldSetFlowsheetWhenEndDateIsGiven() throws Exception {
assertEquals("M4", flowsheetHeaders.get(3).getName());
assertEquals("MTx", flowsheetHeaders.get(4).getName());
assertEquals("M6M", flowsheetHeaders.get(5).getName());
assertEquals("M3", flowsheetUI.getHighlightedMilestone());
assertEquals("M3", flowsheetUI.getHighlightedCurrentMilestone());
assertEquals(6, flowsheetData.get("New Drugs").size());
assertEquals(6, flowsheetData.get("Blood Pressure").size());
assertEquals("grey", coloursForNewDrugs.get(0));
Expand Down Expand Up @@ -164,7 +164,7 @@ public void shouldSetFlowsheetWhenEndDateIsNotGiven() throws Exception {
assertEquals("M4", flowsheetHeaders.get(3).getName());
assertEquals("MTx", flowsheetHeaders.get(4).getName());
assertEquals("M6M", flowsheetHeaders.get(5).getName());
assertEquals("", flowsheetUI.getHighlightedMilestone());
assertEquals("", flowsheetUI.getHighlightedCurrentMilestone());
assertEquals(6, flowsheetData.get("New Drugs").size());
assertEquals(6, flowsheetData.get("Blood Pressure").size());
assertEquals("grey", coloursForNewDrugs.get(0));
Expand Down

0 comments on commit 65b3cc6

Please sign in to comment.