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
3 changes: 2 additions & 1 deletion src/main/java/com/iemr/flw/controller/StopTBController.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ public String getAllDiagnostics(@RequestBody Map<String, Object> body) {
logger.error("Error in getAllDiagnostics: " + e);
response.setError(5000, "Error fetching diagnostics records: " + e.getMessage());
}
return response.toString();
// toString() drops null fields; keep keys like sputumCollectionDate present as null
return response.toStringWithSerializeNulls();
}

}
3 changes: 3 additions & 0 deletions src/main/java/com/iemr/flw/domain/iemr/StopTBDiagnostics.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public class StopTBDiagnostics {
@Column(name = "sputum_submitted_at", length = 255)
private String sputumSubmittedAt;

@Column(name = "SputumCollectionDate")
private Timestamp sputumCollectionDate;

// Truenat / NAAT
@Column(name = "is_truenat_conducted_id")
private Integer isTruenatConductedId;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/iemr/flw/domain/iemr/TBConfirmedCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public class TBConfirmedCase {
@Column(name = "reason_for_not_completing")
private String reasonForNotCompleting;

@Column(name = "remarks")
private String remarks;

@Column(name = "created_at")
private LocalDate createdAt = LocalDate.now();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class TBConfirmedCaseDTO {
private String placeOfDeath;
private String reasonForDeath ;
private String reasonForNotCompleting;
private String remarks;
private Boolean counselled;
private List<String> sideEffects;

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/iemr/flw/domain/iemr/TBScreening.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,7 @@ public class TBScreening {

@Column(name = "others")
private Boolean others;

@Column(name = "OtherSymptomsDetails", length = 200)
private String otherSymptomsDetails;
}
25 changes: 24 additions & 1 deletion src/main/java/com/iemr/flw/service/impl/StopTBServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,12 @@ public List<Map<String, Object>> saveNurseTBScreening(List<Map<String, Object>>
screening.setFatigue(getBool(data, "fatigue"));
screening.setFailureToGainWeight(getBool(data, "failureToGainWeightInChildren"));
screening.setDecreasedActivityOrPlayfulness(getBool(data, "decreasedActivityOrPlayfulnessInChildren"));
screening.setOthers(getBool(data, "otherSymptoms"));
Boolean otherSymptoms = getBool(data, "otherSymptoms");
screening.setOthers(otherSymptoms);
// Details are only kept when "Others" = Yes; older app versions don't send them.
screening.setOtherSymptomsDetails(Boolean.TRUE.equals(otherSymptoms)
? normalizeOtherSymptomsDetails(getString(data, "otherSymptomsDetails"))
: null);

String symptomaticInput = getString(data, "symptomatic");
if ("Yes".equalsIgnoreCase(symptomaticInput)) {
Expand Down Expand Up @@ -366,6 +371,7 @@ private Map<String, Object> screeningToMap(TBScreening s) {
m.put("failureToGainWeightInChildren", s.getFailureToGainWeight());
m.put("decreasedActivityOrPlayfulnessInChildren", s.getDecreasedActivityOrPlayfulness());
m.put("otherSymptoms", s.getOthers());
m.put("otherSymptomsDetails", s.getOtherSymptomsDetails());
return m;
}

Expand Down Expand Up @@ -539,6 +545,12 @@ public List<Map<String, Object>> saveDiagnostics(List<Map<String, Object>> dataL
diag.setReasonForDenialSputum(getString(data, "reasonForDenialSputum"));
diag.setReasonForDenialSputumOther(getString(data, "reasonForDenialSputumOther"));
diag.setSputumSubmittedAt(getString(data, "sputumSubmittedAt"));
// The today/yesterday window is enforced in the app: records can sync days after entry.
if (Boolean.FALSE.equals(getBool(data, "isSputumCollected"))) {
diag.setSputumCollectionDate(null);
} else if (data.containsKey("sputumCollectionDate")) {
diag.setSputumCollectionDate(getTimestamp(data, "sputumCollectionDate"));
}

diag.setIsTruenatConducted(getBool(data, "isTruenatConducted"));
diag.setReasonNotConductedNaat(getString(data, "reasonNotConductedNaat"));
Expand Down Expand Up @@ -652,6 +664,7 @@ private Map<String, Object> diagnosticsToMap(StopTBDiagnostics d) {
m.put("reasonForDenialSputum", d.getReasonForDenialSputum());
m.put("reasonForDenialSputumOther", d.getReasonForDenialSputumOther());
m.put("sputumSubmittedAt", d.getSputumSubmittedAt());
m.put("sputumCollectionDate", d.getSputumCollectionDate());
m.put("isTruenatConducted", d.getIsTruenatConducted());
m.put("reasonNotConductedNaat", d.getReasonNotConductedNaat());
m.put("reasonNotConductedNaatOther", d.getReasonNotConductedNaatOther());
Expand Down Expand Up @@ -887,6 +900,16 @@ private String getString(Map<String, Object> m, String key) {
return v != null ? v.toString() : null;
}

private static final int OTHER_SYMPTOMS_DETAILS_MAX_LENGTH = 200;

private String normalizeOtherSymptomsDetails(String details) {
if (details == null || details.trim().isEmpty()) return null;
String trimmed = details.trim();
return trimmed.length() > OTHER_SYMPTOMS_DETAILS_MAX_LENGTH
? trimmed.substring(0, OTHER_SYMPTOMS_DETAILS_MAX_LENGTH)
: trimmed;
}

private Long getLong(Map<String, Object> m, String key) {
Object v = m.get(key);
if (v == null) return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ public String save(List<TBConfirmedCaseDTO> request, String authorisation) throw
entity.setReasonForDeath(dto.getReasonForDeath());
entity.setReasonForNotCompleting(dto.getReasonForNotCompleting());
if (dto.getSideEffects() != null) entity.setSideEffects(joinSideEffects(dto.getSideEffects()));
// older app builds don't send remarks β€” keep the saved value instead of clearing it
if (dto.getRemarks() != null) {
entity.setRemarks(dto.getRemarks());
}
// Stop TB / Nikshay reporting β€” same gap as tb_suspected: benRegID is computed
// above for the visit lookup but was never persisted onto the entity.
entity.setBenRegID(beneficiaryRegID);
Expand Down Expand Up @@ -712,6 +716,7 @@ private TBConfirmedCaseDTO toDTO(TBConfirmedCase entity) {
dto.setPlaceOfDeath(entity.getPlaceOfDeath());
dto.setReasonForDeath(entity.getReasonForDeath());
dto.setReasonForNotCompleting(entity.getReasonForNotCompleting());
dto.setRemarks(entity.getRemarks());
dto.setUpdateDate(entity.getLastModDate());
dto.setUpdatedBy(entity.getModifiedBy());
dto.setSideEffects(splitSideEffects(entity.getSideEffects()));
Expand Down
Loading