Skip to content

Commit c7a52a4

Browse files
authored
fix: age issue while moving to nurse worklist (#130)
1 parent 0c3b09a commit c7a52a4

2 files changed

Lines changed: 11 additions & 15 deletions

File tree

src/main/java/com/iemr/common/identity/dto/BeneficiariesESDTO.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import lombok.AllArgsConstructor;
77
import java.util.Date;
88
import java.util.List;
9+
10+
import com.fasterxml.jackson.annotation.JsonFormat;
911
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
1012

1113
@Data
@@ -33,6 +35,7 @@ public class BeneficiariesESDTO {
3335
private String genderName;
3436

3537
@JsonProperty("dOB")
38+
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", timezone = "UTC")
3639
private Date dOB;
3740

3841
@JsonProperty("age")

src/main/java/com/iemr/common/identity/service/elasticsearch/ElasticsearchService.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,7 @@ public class ElasticsearchService {
5050
@Value("${elasticsearch.enabled}")
5151
private boolean esEnabled;
5252

53-
/**
54-
* Universal search with optional user location for ranking
55-
*/
56-
57-
/**
58-
* Advanced search with multiple criteria
59-
* Searches by firstName, lastName, gender, DOB, address fields, etc.
60-
*/
61-
53+
6254
/**
6355
* Universal search with score-based filtering and location ranking
6456
* Only returns records that actually match the query (not all 10000)
@@ -155,10 +147,10 @@ public List<Map<String, Object>> universalSearch(String query, Integer userId) {
155147
.boostMode(FunctionBoostMode.Multiply)
156148
)
157149
)
158-
.minScore(minScore) // KEY: Only return results above minimum score
159-
.size(500) // Reasonable limit - returns only matches up to 500
150+
.minScore(minScore)
151+
.size(500)
160152
.sort(so -> so
161-
.score(sc -> sc.order(SortOrder.Desc)) // Sort by relevance score
153+
.score(sc -> sc.order(SortOrder.Desc))
162154
)
163155
, BeneficiariesESDTO.class);
164156

@@ -176,7 +168,7 @@ public List<Map<String, Object>> universalSearch(String query, Integer userId) {
176168
}
177169
Map<String, Object> result = mapESResultToExpectedFormat(hit.source());
178170
if (result != null) {
179-
result.put("_score", hit.score()); // Include score for debugging
171+
result.put("_score", hit.score());
180172
}
181173
return result;
182174
})
@@ -421,8 +413,8 @@ public List<Map<String, Object>> advancedSearch(
421413
.boostMode(FunctionBoostMode.Multiply)
422414
)
423415
)
424-
.minScore(2.0) // Only return good matches
425-
.size(500) // Reasonable limit
416+
.minScore(2.0)
417+
.size(500)
426418
.sort(so -> so
427419
.score(sc -> sc.order(SortOrder.Desc))
428420
)
@@ -615,6 +607,7 @@ private Map<String, Object> mapESResultToExpectedFormat(BeneficiariesESDTO esDat
615607
result.put("genderID", esData.getGenderID());
616608
result.put("genderName", esData.getGenderName());
617609
result.put("dob", esData.getDOB());
610+
result.put("dOB", esData.getDOB());
618611
result.put("age", esData.getAge());
619612
result.put("fatherName", esData.getFatherName() != null ? esData.getFatherName() : "");
620613
result.put("spouseName", esData.getSpouseName() != null ? esData.getSpouseName() : "");

0 commit comments

Comments
 (0)