Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OH2-205: Add code generation on swagger #1035

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public class AdmissionBrowserManager {

@Autowired
private AdmissionIoOperations ioOperations;

// TODO: to centralize
protected static final int DEFAULT_PAGE_SIZE = 80;

/**
* Returns all patients with ward in which they are admitted.
Expand Down Expand Up @@ -123,27 +126,67 @@ public List<Admission> getAdmissions(Patient patient) throws OHServiceException
/**
* Method that returns the list of Admissions not logically deleted
* within the specified date range, divided by pages
*
* @param dateFrom
* @param dateTo
* @return the list of Admissions (could be empty)
* @throws OHServiceException
*/
public List<Admission> getAdmissions(LocalDateTime dateFrom, LocalDateTime dateTo, int page, int size) throws OHServiceException {
return ioOperations.getAdmissionsByAdmissionDate(dateFrom, dateTo, PageRequest.of(page, size));
public List<Admission> getAdmissions(LocalDateTime dateFrom, LocalDateTime dateTo) throws OHServiceException {
return ioOperations.getAdmissionsByAdmissionDate(dateFrom, dateTo, PageRequest.of(0, DEFAULT_PAGE_SIZE));
}

/**
* Method that returns the list of Admissions not logically deleted
* within the specified date range, divided by pages
*
* @param dateFrom
* @param dateTo
* @param page
* @param size
* @return {@link PagedResponse<Admission>}.
* @throws OHServiceException
*/
public PagedResponse<Admission> getAdmissionsPageable(LocalDateTime dateFrom, LocalDateTime dateTo, int page, int size) throws OHServiceException {
return ioOperations.getAdmissionsByAdmissionDates(dateFrom, dateTo, PageRequest.of(page, size));
}

/**
* Method that returns the list of Admissions not logically deleted
* within the specified date range
*
* @param dateFrom
* @param dateTo
* @return the list of Admissions (could be empty)
* @throws OHServiceException
*/
public List<Admission> getAdmissionsByDate(LocalDateTime dateFrom, LocalDateTime dateTo) throws OHServiceException {
return ioOperations.getAdmissionsByAdmDate(dateFrom, dateTo);
}

/**
* Method that returns the list of completed Admissions (Discharges) not logically deleted
* within the specified date range, divided by pages
*
* @param dateFrom
* @param dateTo
* @param page
* @param size
* @return the list of completed Admissions (could be empty)
* @throws OHServiceException
*/
public List<Admission> getDischarges(LocalDateTime dateFrom, LocalDateTime dateTo, int page, int size) throws OHServiceException {
return ioOperations.getAdmissionsByDischargeDate(dateFrom, dateTo, PageRequest.of(page, size));
}

/**
* Method that returns the list of completed Admissions (Discharges) not logically deleted
* within the specified date range, divided by pages
* @param dateFrom
* @param dateTo
* @param page
* @param size
* @return {@link PagedResponse<Admission>}
* @throws OHServiceException
*/
public PagedResponse<Admission> getDischargesPageable(LocalDateTime dateFrom, LocalDateTime dateTo, int page, int size) throws OHServiceException {
return ioOperations.getAdmissionsByDischargeDates(dateFrom, dateTo, PageRequest.of(page, size));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ List<Admission> findAllWhereWardAndDates(
@Query(value = "select a FROM Admission a WHERE a.disDate >= :dateFrom AND a.disDate <= :dateTo and a.deleted = 'N'")
List<Admission> findAllWhereDischargeDate(@Param("dateFrom") LocalDateTime dateFrom, @Param("dateTo") LocalDateTime dateTo, Pageable pageable);

@Query(value = "select a FROM Admission a WHERE a.admDate >= :dateFrom AND a.admDate <= :dateTo and a.deleted = 'N'")
List<Admission> findAllWhereAdmissionDate(@Param("dateFrom") LocalDateTime dateFrom, @Param("dateTo") LocalDateTime dateTo);

@Query(value = "select a FROM Admission a WHERE a.admDate >= :dateFrom AND a.admDate <= :dateTo and a.deleted = 'N'")
Page<Admission> findAllWhere_AdmissionDate_Paginated(@Param("dateFrom") LocalDateTime dateFrom, @Param("dateTo") LocalDateTime dateTo, Pageable pageable);

Expand Down
59 changes: 57 additions & 2 deletions src/main/java/org/isf/admission/service/AdmissionIoOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,32 +324,87 @@ public boolean deletePatientPhoto(int patientId) throws OHServiceException {
return patientRepository.save(foundPatient) != null;
}

/**
* Returns the list of Admissions by pages
*
* @param dateFrom.
* @param daTo
* @param pageable
* @return the list of {@link Admission}.
* @throws OHServiceException if an error occurs during database request.
ArnaudFonzam marked this conversation as resolved.
Show resolved Hide resolved
*/
public List<Admission> getAdmissionsByAdmissionDate(LocalDateTime dateFrom, LocalDateTime dateTo, Pageable pageable) {
return repository.findAllWhereAdmissionDate(dateFrom, dateTo, pageable);
}

/**
* Returns the list of Admissions
*
* @param dateFrom.
* @param daTo
* @return the list of {@link Admission}.
* @throws OHServiceException if an error occurs during database request.
*/
public List<Admission> getAdmissionsByAdmDate(LocalDateTime dateFrom, LocalDateTime dateTo) {
return repository.findAllWhereAdmissionDate(dateFrom, dateTo);
}

/**
* Returns the list of Admissions with discharge
*
* @param dateFrom.
* @param daTo
* @param pageable
* @return the list of {@link Admission}.
* @throws OHServiceException if an error occurs during database request.
*/
public List<Admission> getAdmissionsByDischargeDate(LocalDateTime dateFrom, LocalDateTime dateTo, Pageable pageable) {
return repository.findAllWhereDischargeDate(dateFrom, dateTo, pageable);
}

/**
* Returns the list of Admissions by page
*
* @param dateFrom.
* @param daTo
* @param pageable
* @return the list of {@link Admission}.
* @throws OHServiceException if an error occurs during database request.
*/
public PagedResponse<Admission> getAdmissionsByAdmissionDates(LocalDateTime dateFrom, LocalDateTime dateTo, Pageable pageable) {
Page<Admission> pagedResult = repository.findAllWhere_AdmissionDate_Paginated(dateFrom, dateTo, pageable);
return setPaginationData(pagedResult);
}

/**
* Returns the list of Admissions with discharge by page
*
* @param dateFrom.
* @param daTo
* @param pageable
* @return the list of {@link Admission}.
* @throws OHServiceException if an error occurs during database request.
*/
public PagedResponse<Admission> getAdmissionsByDischargeDates(LocalDateTime dateFrom, LocalDateTime dateTo, Pageable pageable) {
Page<Admission> pagedResult = repository.findAllWhere_DischargeDate_Paginated(dateFrom, dateTo, pageable);
return setPaginationData(pagedResult);
}

/**
* Returns the list of Admissions with page info
*
* @param page of admission
* @return {@link PagedResponse<Admission>}.
* @throws OHServiceException if an error occurs during database request.
*/
public PagedResponse<Admission> setPaginationData(Page<Admission> pages){
ArnaudFonzam marked this conversation as resolved.
Show resolved Hide resolved
PagedResponse<Admission> data = new PagedResponse<Admission>();
data.setData(pages.getContent());
PageInfo pageInfo = new PageInfo();
pageInfo.setSize(pages.getPageable().getPageSize());
pageInfo.setPage(pages.getPageable().getPageNumber());
pageInfo.setNbOfElements(pages.getNumberOfElements());
pageInfo.setTotalCount(pages.getTotalElements());
pageInfo.setTotalNbOfElements(pages.getTotalElements());
pageInfo.setTotalPage(pages.getTotalPages());
pageInfo.setHasPreviousPage(pages.hasPrevious());
pageInfo.setHasNextPage(pages.hasNext());
data.setPageInfo(pageInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,16 @@ protected void validateDiseaseType(DiseaseType diseaseType, boolean insert) thro
throw new OHDataValidationException(errors);
}
}

/**
* Returns {@link DiseaseType}.
*
* @Param code
* @return object {@link DiseaseType}, <code>null</code> otherwise.
* @throws OHServiceException
*/
public DiseaseType getDiseaseType(String code) throws OHServiceException {
return ioOperations.getDiseaseTypes(code);
}

}
17 changes: 17 additions & 0 deletions src/main/java/org/isf/distype/service/DiseaseTypeIoOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package org.isf.distype.service;

import java.util.List;
import java.util.Optional;

import org.isf.distype.model.DiseaseType;
import org.isf.utils.db.TranslateOHServiceException;
Expand Down Expand Up @@ -90,4 +91,20 @@ public boolean deleteDiseaseType(DiseaseType diseaseType) throws OHServiceExcept
public boolean isCodePresent(String code) throws OHServiceException {
return repository.existsById(code);
}

/**
* Returns {@link DiseaseType}s.
*
* @Param code
* @return a disease type.
* @throws OHServiceException if an error occurs retrieving the diseases type.
*/
public DiseaseType getDiseaseTypes(String code) throws OHServiceException {
Optional<DiseaseType> diseaseType = repository.findById(code);
if ( diseaseType.isPresent()) {
return diseaseType.get();
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ public PagedResponse<PatientExamination> setPaginationData(Page<PatientExaminati
pageInfo.setSize(pages.getPageable().getPageSize());
pageInfo.setPage(pages.getPageable().getPageNumber());
pageInfo.setNbOfElements(pages.getNumberOfElements());
pageInfo.setTotalCount(pages.getTotalElements());
pageInfo.setTotalNbOfElements(pages.getTotalElements());
pageInfo.setTotalPage(pages.getTotalPages());
pageInfo.setHasPreviousPage(pages.hasPrevious());
pageInfo.setHasNextPage(pages.hasNext());
data.setPageInfo(pageInfo);
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/isf/lab/manager/LabManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Map;
import java.util.Optional;

import org.isf.exa.model.Exam;
import org.isf.generaldata.GeneralData;
import org.isf.generaldata.MessageBundle;
import org.isf.lab.model.Laboratory;
Expand Down Expand Up @@ -500,5 +501,9 @@ public Optional<Laboratory> getLaboratory(Integer code) throws OHServiceExceptio
public List<LaboratoryRow> getLaboratoryRowList(Integer code) throws OHServiceException {
return ioOperations.getLabRow(code);
}

public PagedResponse<Laboratory> getLaboratoryPageable(Exam exam, LocalDateTime dateFrom, LocalDateTime dateTo, Patient patient, int page, int size) throws OHServiceException {
return ioOperations.getLaboratoryPageable(exam, dateFrom, dateTo, patient, page, size);
}

}
17 changes: 17 additions & 0 deletions src/main/java/org/isf/lab/service/LabIoOperationRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@
import java.time.LocalDateTime;
import java.util.List;

import org.isf.exa.model.Exam;
import org.isf.lab.model.Laboratory;
import org.isf.patient.model.Patient;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface LabIoOperationRepository extends JpaRepository<Laboratory, Integer> {
List<Laboratory> findByLabDateBetweenOrderByLabDateDesc(LocalDateTime dateFrom, LocalDateTime dateTo);
Expand All @@ -45,4 +49,17 @@ public interface LabIoOperationRepository extends JpaRepository<Laboratory, Inte
List<Laboratory> findByLabDateBetweenAndExamDescriptionAndPatientCode(LocalDateTime dateFrom, LocalDateTime dateTo, String exam, Integer patient);

Page<Laboratory> findByLabDateBetweenOrderByLabDateDesc(LocalDateTime dateFrom, LocalDateTime dateTo, Pageable pageable);

@Query(value = "select lab from Laboratory lab where lab.labDate >= :dateFrom and lab.labDate < :dateTo")
Page<Laboratory> findByLabDateBetweenOrderByLabDateDescPage(@Param("dateFrom") LocalDateTime dateFrom, @Param("dateTo") LocalDateTime dateTo, Pageable pageable);
ArnaudFonzam marked this conversation as resolved.
Show resolved Hide resolved

@Query(value = "select lab from Laboratory lab where (lab.labDate >= :dateFrom and lab.labDate < :dateTo) or lab.exam = :exam")
Page<Laboratory> findByLabDateBetweenAndExam_DescriptionOrderByLabDateDescPage(@Param("dateFrom") LocalDateTime dateFrom, @Param("dateTo") LocalDateTime dateTo, @Param("exam")Exam exam, Pageable pageable);
ArnaudFonzam marked this conversation as resolved.
Show resolved Hide resolved

@Query(value = "select lab from Laboratory lab where (lab.labDate >= :dateFrom and lab.labDate < :dateTo) or lab.patient = :patient")
Page<Laboratory> findByLabDateBetweenAndPatientCodePage(@Param("dateFrom") LocalDateTime dateFrom, @Param("dateTo") LocalDateTime dateTo, @Param("patient") Patient patient, Pageable pageable);
ArnaudFonzam marked this conversation as resolved.
Show resolved Hide resolved

@Query(value = "select lab from Laboratory lab where (lab.labDate >= :dateFrom and lab.labDate < :dateTo) or lab.exam = :exam or lab.patient = :patient")
Page<Laboratory> findByLabDateBetweenAndExamDescriptionAndPatientCodePage(@Param("dateFrom") LocalDateTime dateFrom, @Param("dateTo") LocalDateTime dateTo, @Param("exam") Exam exam, @Param("patient") Patient patient, Pageable pageable);
ArnaudFonzam marked this conversation as resolved.
Show resolved Hide resolved

}
22 changes: 21 additions & 1 deletion src/main/java/org/isf/lab/service/LabIoOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.List;
import java.util.Optional;

import org.isf.exa.model.Exam;
import org.isf.lab.model.Laboratory;
import org.isf.lab.model.LaboratoryForPrint;
import org.isf.lab.model.LaboratoryRow;
Expand Down Expand Up @@ -410,14 +411,33 @@ public Optional<Laboratory> getLaboratory(int code) throws OHServiceException {
return repository.findById(code);
}

public PagedResponse<Laboratory> getLaboratoryPageable(Exam exam, LocalDateTime dateFrom, LocalDateTime dateTo, Patient patient, int page, int size) throws OHServiceException {
Page<Laboratory> laboritories = null;

if (exam != null && patient != null) {
laboritories = repository.findByLabDateBetweenAndExamDescriptionAndPatientCodePage(dateFrom, dateTo, exam, patient, PageRequest.of(page, size));
}
if (exam != null && patient == null) {
laboritories = repository.findByLabDateBetweenAndExam_DescriptionOrderByLabDateDescPage(dateFrom, dateTo, exam, PageRequest.of(page, size));
}
if (patient != null && exam == null) {
laboritories = repository.findByLabDateBetweenAndPatientCodePage(dateFrom, dateTo, patient, PageRequest.of(page, size));
}
if (patient == null && exam == null) {
laboritories = repository.findByLabDateBetweenOrderByLabDateDescPage(dateFrom, dateTo, PageRequest.of(page, size));
}
return setPaginationData(laboritories);
}

public PagedResponse<Laboratory> setPaginationData(Page<Laboratory> pages){
ArnaudFonzam marked this conversation as resolved.
Show resolved Hide resolved
PagedResponse<Laboratory> data = new PagedResponse<Laboratory>();
data.setData(pages.getContent());
PageInfo pageInfo = new PageInfo();
pageInfo.setSize(pages.getPageable().getPageSize());
pageInfo.setPage(pages.getPageable().getPageNumber());
pageInfo.setNbOfElements(pages.getNumberOfElements());
pageInfo.setTotalCount(pages.getTotalElements());
pageInfo.setTotalNbOfElements(pages.getTotalElements());
pageInfo.setTotalPage(pages.getTotalPages());
pageInfo.setHasPreviousPage(pages.hasPrevious());
pageInfo.setHasNextPage(pages.hasNext());
data.setPageInfo(pageInfo);
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/org/isf/opd/manager/OpdBrowserManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
package org.isf.opd.manager;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import org.isf.disease.model.Disease;
import org.isf.distype.model.DiseaseType;
import org.isf.generaldata.GeneralData;
import org.isf.generaldata.MessageBundle;
import org.isf.menu.manager.UserBrowsingManager;
Expand All @@ -35,6 +37,7 @@
import org.isf.utils.exception.OHDataValidationException;
import org.isf.utils.exception.OHServiceException;
import org.isf.utils.exception.model.OHExceptionMessage;
import org.isf.utils.pagination.PagedResponse;
import org.isf.ward.model.Ward;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -249,4 +252,25 @@ public Optional<Opd> getOpdById(int code) {
public List<Opd> getOpdByProgYear(int code) {
return ioOperations.getOpdByProgYear(code);
}

public PagedResponse<Opd> getOpdPageable(Ward ward, DiseaseType diseaseType, String diseaseCode, LocalDate dateFrom, LocalDate dateTo, int ageFrom, int ageTo, char sex, char newPatient, String user, int page, int size)
ArnaudFonzam marked this conversation as resolved.
Show resolved Hide resolved
throws OHServiceException {
LocalDateTime dateFr = dateFrom.atStartOfDay();
LocalDateTime dateT = dateTo.atStartOfDay();
return ioOperations.getOpdListPageable(ward, diseaseType, diseaseCode, dateFr, dateT, ageFrom, ageTo, sex, newPatient, user, page, size);
}

/**
* Returns {@link List} of {@link Opd}s associated to specified patient ID with page info.
*
* @param patientcode - the patient ID
* @param page - the number of page
* @param size - the size of the list
* @return the list of {@link Opd}s associated to specified patient ID.
* the whole list of {@link Opd}s if <code>0</code> is passed.
* @throws OHServiceException
*/
public PagedResponse<Opd> getOpdListPageable(int patientcode, int page, int size) throws OHServiceException {
return ioOperations.getOpdListPageables(patientcode, page, size);
}
}
Loading