Skip to content

Commit

Permalink
Minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jayasanka-sack committed Oct 24, 2024
1 parent efa8cb7 commit 539eb15
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.*;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

@Repository
Expand All @@ -30,7 +35,7 @@ public List<VisitWithDiagnoses> getVisitsByPatientId(Patient patient) {
"ORDER BY v.startDatetime DESC";

List<Visit> visits = sessionFactory.getCurrentSession()
.createQuery(hqlVisit) // For Hibernate versions < 5.2
.createQuery(hqlVisit)
.setParameter("patientId", patient.getId())
.setParameter("encounterTypeUuid", visitNoteEncounterTypeUuid).list();

Expand All @@ -39,12 +44,12 @@ public List<VisitWithDiagnoses> getVisitsByPatientId(Patient patient) {
"WHERE e.visit.id IN :visitIds";

List<Integer> visitIds = visits.stream()
.map(Visit::getId) // Extract the IDs from Visit objects
.map(Visit::getId)
.collect(Collectors.toList());

List<Diagnosis> diagnoses = sessionFactory.getCurrentSession()
.createQuery(hqlDiagnosis)
.setParameterList("visitIds", visitIds) // Use the list of IDs
.setParameterList("visitIds", visitIds)
.list();

Map<Visit, Set<Diagnosis>> visitToDiagnosesMap = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import lombok.Getter;
import lombok.Setter;
import org.openmrs.*;
import org.openmrs.Diagnosis;
import org.openmrs.Visit;

import java.util.Set;

Expand Down

0 comments on commit 539eb15

Please sign in to comment.