Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions src/main/java/com/iemr/mmu/data/anc/BenPersonalHabit.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ public class BenPersonalHabit {
@Column(name = "NumberperDay")
private Short numberperDay;

@Expose
@Column(name = "NumberperWeek")
private Short numberperWeek;

@Expose
@Column(name = "TobaccoUseDuration")
private Timestamp tobaccoUseDuration;
Expand Down Expand Up @@ -333,10 +337,18 @@ public Short getNumberperDay() {
return numberperDay;
}

public Short getNumberperWeek() {
return numberperWeek;
}

public void setNumberperDay(Short numberperDay) {
this.numberperDay = numberperDay;
}

public void setNumberperWeek(Short numberperWeek) {
this.numberperWeek = numberperWeek;
}

public Timestamp getTobaccoUseDuration() {
return tobaccoUseDuration;
}
Expand Down Expand Up @@ -579,6 +591,9 @@ public ArrayList<BenPersonalHabit> getPersonalHistory() {
if (null != tobaccoInfo.get("numberperDay")) {
benPersonalHabit.setNumberperDay(new Short(tobaccoInfo.get("numberperDay")));
}
if (null != tobaccoInfo.get("numberperWeek")) {
benPersonalHabit.setNumberperWeek(new Short(tobaccoInfo.get("numberperWeek")));
}
timePeriodUnit = (String) tobaccoInfo.get("durationUnit");

if (null != tobaccoInfo.get("duration")) {
Expand Down Expand Up @@ -634,7 +649,7 @@ public ArrayList<BenPersonalHabit> getPersonalHistory() {
}

public BenPersonalHabit(Date createdDate, String dietaryType, String physicalActivityType, String tobaccoUseStatus,
String tobaccoUseType, String otherTobaccoUseType, Short numberperDay, Date tobaccoUseDuration,
String tobaccoUseType, String otherTobaccoUseType, Short numberperDay, Short numberperWeek, Date tobaccoUseDuration,
Character riskySexualPracticesStatus) {
super();
this.captureDate = createdDate;
Expand All @@ -650,6 +665,8 @@ public BenPersonalHabit(Date createdDate, String dietaryType, String physicalAct
} else if(riskySexualPracticesStatus !=null && riskySexualPracticesStatus == '1') {
this.riskySexualPracticeStatus = "Yes";
}
this.numberperWeek = numberperWeek;

}

public BenPersonalHabit(Date createdDate, String dietaryType, String physicalActivityType,
Expand Down Expand Up @@ -687,7 +704,7 @@ public BenPersonalHabit(Long beneficiaryRegID, Long benVisitID, Integer provider
}

public BenPersonalHabit(String tobaccoUseTypeID, String tobaccoUseType, String otherTobaccoUseType,
Short numberperDay, Timestamp tobaccoUseDuration, String alcoholTypeID, String alcoholType,
Short numberperDay, Short numberperWeek, Timestamp tobaccoUseDuration, String alcoholTypeID, String alcoholType,
String otherAlcoholType, String alcoholIntakeFrequency, String avgAlcoholConsumption,
Timestamp alcoholDuration, Timestamp createdDate, Long visitCode) {
super();
Expand All @@ -704,6 +721,7 @@ public BenPersonalHabit(String tobaccoUseTypeID, String tobaccoUseType, String o
this.alcoholDuration = alcoholDuration;
this.createdDate = createdDate;
this.visitCode = visitCode;
this.numberperWeek = numberperWeek;
}

public static BenPersonalHabit getPersonalDetails(ArrayList<Object[]> personalHistoryDetails) {
Expand All @@ -712,15 +730,15 @@ public static BenPersonalHabit getPersonalDetails(ArrayList<Object[]> personalHi
Object[] obj1 = personalHistoryDetails.get(0);

personalDetails = new BenPersonalHabit((Long) obj1[0], (Long) obj1[1], (Integer) obj1[2], (String) obj1[3],
(String) obj1[4], (String) obj1[5], (String) obj1[11], (Character) obj1[18]);
(String) obj1[4], (String) obj1[5], (String) obj1[12], (Character) obj1[19]);

ArrayList<Map<String, String>> tobaccoList = new ArrayList<Map<String, String>>();
ArrayList<Map<String, String>> alcoholList = new ArrayList<Map<String, String>>();
for (Object[] obj : personalHistoryDetails) {
BenPersonalHabit personalHabits = new BenPersonalHabit((String) obj[6], (String) obj[7],
(String) obj[8], (Short) obj[9], (Timestamp) obj[10], (String) obj[12], (String) obj[13],
(String) obj[14], (String) obj[15], (String) obj[16], (Timestamp) obj[17], (Timestamp) obj[19],
(Long) obj[20]);
(String) obj[8], (Short) obj[9], (Short) obj[10], (Timestamp) obj[11], (String) obj[13], (String) obj[14],
(String) obj[15], (String) obj[16], (String) obj[17], (Timestamp) obj[18], (Timestamp) obj[20],
(Long) obj[21]);

Map<String, Object> timePeriod = null;
// Integer timePeriodAgo = null;
Expand All @@ -732,7 +750,10 @@ public static BenPersonalHabit getPersonalDetails(ArrayList<Object[]> personalHi
if (null != personalHabits.getNumberperDay()) {
tobaccoInfo.put("numberperDay", personalHabits.getNumberperDay().toString());
}

if (null != personalHabits.getNumberperWeek()) {
tobaccoInfo.put("numberperWeek", personalHabits.getNumberperWeek().toString());
}

timePeriod = Utility.convertTimeToWords(personalHabits.getTobaccoUseDuration(),
personalHabits.getCreatedDate());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public interface BenPersonalHabitRepo extends CrudRepository<BenPersonalHabit, I
@Query("select benVisitID from BenPersonalHabit a where a.beneficiaryRegID = :beneficiaryRegID order by benVisitID desc")
public ArrayList<Long> getBenLastVisitID(@Param("beneficiaryRegID") Long beneficiaryRegID);

@Query("select Date(createdDate), dietaryType, physicalActivityType, tobaccoUseStatus, tobaccoUseType, otherTobaccoUseType, numberperDay, "
@Query("select Date(createdDate), dietaryType, physicalActivityType, tobaccoUseStatus, tobaccoUseType, otherTobaccoUseType, numberperDay, numberperWeek, "
+ "Date(tobaccoUseDuration), riskySexualPracticesStatus from BenPersonalHabit a where a.beneficiaryRegID = :beneficiaryRegID "
+ "AND tobaccoUseStatus is not null AND deleted = false order by createdDate DESC")
public ArrayList<Object[]> getBenPersonalTobaccoHabitDetail(@Param("beneficiaryRegID") Long beneficiaryRegID);
Expand All @@ -51,7 +51,7 @@ public interface BenPersonalHabitRepo extends CrudRepository<BenPersonalHabit, I
public ArrayList<Object[]> getBenPersonalAlcoholHabitDetail(@Param("beneficiaryRegID") Long beneficiaryRegID);

@Query(" SELECT beneficiaryRegID, benVisitID, providerServiceMapID, dietaryType, physicalActivityType, tobaccoUseStatus, tobaccoUseTypeID, "
+ "tobaccoUseType, otherTobaccoUseType, numberperDay, tobaccoUseDuration, alcoholIntakeStatus, alcoholTypeID, "
+ "tobaccoUseType, otherTobaccoUseType, numberperDay, numberperWeek, tobaccoUseDuration, alcoholIntakeStatus, alcoholTypeID, "
+ "alcoholType, otherAlcoholType, alcoholIntakeFrequency, avgAlcoholConsumption, alcoholDuration, riskySexualPracticesStatus, createdDate, visitCode "
+ "FROM BenPersonalHabit WHERE beneficiaryRegID = :benRegID AND deleted = false AND visitCode = :visitCode")
public ArrayList<Object[]> getBenPersonalHabitDetail(@Param("benRegID") Long benRegID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,11 @@ public String fetchBenPersonalTobaccoHistory(Long beneficiaryRegID) {
column.put("keyName", "numberperDay");
columns.add(column);

column = new HashMap<String, Object>();
column.put("columnName", "Number Per Week");
column.put("keyName", "numberperWeek");
columns.add(column);

column = new HashMap<String, Object>();
column.put("columnName", "Tobacco Use Start Date");
column.put("keyName", "tobacco_use_duration");
Expand All @@ -1100,8 +1105,8 @@ public String fetchBenPersonalTobaccoHistory(Long beneficiaryRegID) {
for (Object[] obj : benPersonalHabits) {

BenPersonalHabit benPersonalHabit = new BenPersonalHabit((Date) obj[0], (String) obj[1],
(String) obj[2], (String) obj[3], (String) obj[4], (String) obj[5], (Short) obj[6],
(Date) obj[7], (Character) obj[8]);
(String) obj[2], (String) obj[3], (String) obj[4], (String) obj[5], (Short) obj[6], (Short) obj[7],
(Date) obj[8], (Character) obj[9]);

personalHabits.add(benPersonalHabit);
}
Expand Down
Loading