Skip to content

Commit

Permalink
New set of data
Browse files Browse the repository at this point in the history
  • Loading branch information
mwithi committed Nov 7, 2023
1 parent f7e226f commit 6127eff
Show file tree
Hide file tree
Showing 37 changed files with 508 additions and 736 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public interface AccountingBillIoOperationRepository extends JpaRepository<Bill,

@Query(value = "select b from Bill b where b.billPatient.id = :patientCode and b.date >= :dateFrom and b.date < :dateTo")
List<Bill> findByDateAndPatient(@Param("dateFrom") LocalDateTime dateFrom, @Param("dateTo") LocalDateTime dateTo,
@Param("patientCode") Integer patientCode);
@Param("patientCode") Integer patientCode);

@Query(value = "select b from Bill b where b.status='O' and b.billPatient.id = :patID")
List<Bill> findAllPendindBillsByBillPatient(@Param("patID") int patID);
Expand All @@ -64,4 +64,7 @@ List<Bill> findByDateAndPatient(@Param("dateFrom") LocalDateTime dateFrom, @Para

@Query(value = "select distinct b.user FROM Bill b ORDER BY b.user asc")
List<String> findUserDistinctByOrderByUserAsc();

@Query("select count(b) from Bill b where active=1")
long countAllActiveBills();
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,17 @@
* Persistence class for Accounting module.
*/
@Service
@Transactional(rollbackFor=OHServiceException.class)
@Transactional(rollbackFor = OHServiceException.class)
@TranslateOHServiceException
public class AccountingIoOperations {
public class AccountingIoOperations {

@Autowired
private AccountingBillIoOperationRepository billRepository;
@Autowired
private AccountingBillPaymentIoOperationRepository billPaymentRepository;
@Autowired
private AccountingBillItemsIoOperationRepository billItemsRepository;



/**
* Returns all the pending {@link Bill}s for the specified patient.
* @param patID the patient id.
Expand All @@ -66,7 +65,7 @@ public List<Bill> getPendingBills(int patID) throws OHServiceException {
}
return billRepository.findByStatusOrderByDateDesc("O");
}

/**
* Get all the {@link Bill}s.
* @return a list of bills.
Expand All @@ -75,7 +74,7 @@ public List<Bill> getPendingBills(int patID) throws OHServiceException {
public List<Bill> getBills() throws OHServiceException {
return billRepository.findAllByOrderByDateDesc();
}

/**
* Get the {@link Bill} with specified billID.
* @param billID
Expand All @@ -91,10 +90,10 @@ public Bill getBill(int billID) throws OHServiceException {
* @return a list of user id.
* @throws OHServiceException if an error occurs retrieving the users list.
*/
public List<String> getUsers() throws OHServiceException {
Set<String> accountingUsers = new TreeSet<>(String::compareTo);
accountingUsers.addAll(billRepository.findUserDistinctByOrderByUserAsc());
accountingUsers.addAll(billPaymentRepository.findUserDistinctByOrderByUserAsc());
public List<String> getUsers() throws OHServiceException {
Set<String> accountingUsers = new TreeSet<>(String::compareTo);
accountingUsers.addAll(billRepository.findUserDistinctByOrderByUserAsc());
accountingUsers.addAll(billPaymentRepository.findUserDistinctByOrderByUserAsc());
return new ArrayList<>(accountingUsers);
}

Expand Down Expand Up @@ -239,7 +238,7 @@ public List<BillPayments> getPayments(List<Bill> bills) throws OHServiceExceptio
* @throws OHServiceException
*/
public List<BillPayments> getPaymentsBetweenDatesWherePatient(LocalDateTime dateFrom, LocalDateTime dateTo, Patient patient)
throws OHServiceException {
throws OHServiceException {
return billPaymentRepository.findByDateAndPatient(TimeTools.getBeginningOfDay(dateFrom), TimeTools.getBeginningOfNextDay(dateTo), patient.getCode());
}

Expand Down Expand Up @@ -299,6 +298,17 @@ public List<Bill> getBillsBetweenDatesWhereBillItem(LocalDateTime dateFrom, Loca
return billRepository.findByDateBetween(TimeTools.getBeginningOfDay(dateFrom), TimeTools.getBeginningOfNextDay(dateTo));
}
return billRepository.findAllWhereDatesAndBillItem(TimeTools.getBeginningOfDay(dateFrom), TimeTools.getBeginningOfNextDay(dateTo),
billItem.getItemDescription());
billItem.getItemDescription());
}

/**
* Count active {@link Bill}s
*
* @return the number of recorded {@link Bill}s
* @throws OHServiceException
*/
public long countAllActiveBills() {
return this.billRepository.countAllActiveBills();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,22 @@ List<Admission> findAllWhereWardAndDates(

@Query(value = "select a FROM Admission a WHERE a.admitted =1 and a.ward.code = :ward and a.deleted = 'N'")
List<Admission> findAllWhereWardIn(@Param("ward") String ward);

@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, Pageable pageable);

@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);

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

@Query("select count(a) from Admission a where active=1 and deleted not like 'Y'")
long countAllActiveNotDeletedAdmissions();
}
17 changes: 14 additions & 3 deletions src/main/java/org/isf/admission/service/AdmissionIoOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public Patient deletePatientPhoto(int patientId) throws OHServiceException {
}
return patientRepository.save(foundPatient);
}

/**
* Returns the list of Admissions by pages
*
Expand All @@ -353,7 +353,7 @@ public List<Admission> getAdmissionsByAdmissionDate(LocalDateTime dateFrom, Loca
public List<Admission> getAdmissionsByAdmDate(LocalDateTime dateFrom, LocalDateTime dateTo) throws OHServiceException {
return repository.findAllWhereAdmissionDate(dateFrom, dateTo);
}

/**
* Returns the list of Admissions with discharge
*
Expand Down Expand Up @@ -394,7 +394,7 @@ public PagedResponse<Admission> getAdmissionsByDischargeDates(LocalDateTime date
Page<Admission> pagedResult = repository.findAllWhere_DischargeDate_Paginated(dateFrom, dateTo, pageable);
return setPaginationData(pagedResult);
}

/**
* Returns the list of Admissions with page info
*
Expand All @@ -407,4 +407,15 @@ PagedResponse<Admission> setPaginationData(Page<Admission> pages) {
data.setPageInfo(PageInfo.from(pages));
return data;
}

/**
* Count not deleted {@link Admission}s
*
* @return the number of recorded {@link Admission}s
* @throws OHServiceException
*/
public long countAllActiveAdmissions() {
return this.repository.countAllActiveNotDeletedAdmissions();
}

}
25 changes: 17 additions & 8 deletions src/main/java/org/isf/generaldata/GeneralData.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ public final class GeneralData extends ConfigurationProperties {

private final boolean SINGLEUSER;
private final boolean USERSLISTLOGIN;


public static String MODE;
public static boolean DEMODATA;
public static boolean APISERVER;

public static String LANGUAGE;
public static boolean AUTOMATICLOT_IN;
public static boolean AUTOMATICLOT_OUT;
Expand Down Expand Up @@ -102,6 +106,9 @@ public final class GeneralData extends ConfigurationProperties {
private static final String DEFAULT_LANGUAGE = "en";
private static final boolean DEFAULT_SINGLEUSER = false;
private static final boolean DEFAULT_USERSLISTLOGIN = false;
private static final String DEFAULT_MODE = "";
private static final boolean DEFAULT_DEMODATA = false;
private static final boolean DEFAULT_APISERVER = false;
private static final boolean DEFAULT_AUTOMATICLOT_IN = true;
private static final boolean DEFAULT_AUTOMATICLOT_OUT = true;
private static final boolean DEFAULT_AUTOMATICLOTWARD_TOWARD = true;
Expand All @@ -118,7 +125,7 @@ public final class GeneralData extends ConfigurationProperties {
private static final String DEFAULT_BILLSREPORTMONTHLY = "BillsReportMonthly";
private static final String DEFAULT_PHARMACEUTICALORDER = "PharmaceuticalOrder";
private static final String DEFAULT_PHARMACEUTICALSTOCK = "PharmaceuticalStock_ver4";
private static final String DEFAULT_PHARMACEUTICALSTOCKLOT = "PharmaceuticalStock_ver5"; //TODO: verify if really used
private static final String DEFAULT_PHARMACEUTICALSTOCKLOT = "PharmaceuticalStock_ver5"; // TODO: verify if really used
private static final String DEFAULT_PHARMACEUTICALAMC = "PharmaceuticalAMC";
private static final boolean DEFAULT_PATIENTEXTENDED = false;
private static final boolean DEFAULT_OPDEXTENDED = false;
Expand Down Expand Up @@ -153,18 +160,20 @@ public final class GeneralData extends ConfigurationProperties {
private static final String DEFAULT_PATIENTPHOTOSTORAGE = "DB";
public static final int IMAGE_THUMBNAIL_MAX_WIDTH = 140;
public static final int MAX_PROFILE_IMAGE_FILE_SIZE_BYTES = 32768;

private static GeneralData mySingleData;

public static void reset() {
mySingleData = null;
}



private GeneralData(String fileProperties) {
super(fileProperties, EXIT_ON_FAIL);
SINGLEUSER = myGetProperty("SINGLEUSER", DEFAULT_SINGLEUSER);
USERSLISTLOGIN = myGetProperty("USERSLISTLOGIN", DEFAULT_USERSLISTLOGIN);
MODE = myGetProperty("MODE", DEFAULT_MODE);
DEMODATA = myGetProperty("DEMODATA", DEFAULT_DEMODATA);
APISERVER = myGetProperty("APISERVER", DEFAULT_APISERVER);
LANGUAGE = myGetProperty("LANGUAGE", DEFAULT_LANGUAGE);
AUTOMATICLOT_IN = myGetProperty("AUTOMATICLOT_IN", DEFAULT_AUTOMATICLOT_IN);
AUTOMATICLOT_OUT = myGetProperty("AUTOMATICLOT_OUT", DEFAULT_AUTOMATICLOT_OUT);
Expand Down Expand Up @@ -235,7 +244,7 @@ private GeneralData(String fileProperties) {
}
PATIENTPHOTOSTORAGE = myGetProperty("PATIENTPHOTOSTORAGE", DEFAULT_PATIENTPHOTOSTORAGE);
SESSIONTIMEOUT = myGetProperty("SESSIONTIMEOUT", DEFAULT_SESSIONTIMEOUT);
}
}

public static GeneralData getGeneralData() {
if (mySingleData == null) {
Expand All @@ -254,7 +263,7 @@ public static void initialize() {
public boolean getSINGLEUSER() {
return SINGLEUSER;
}

/**
* @return the USERSLISTLOGIN
*/
Expand Down
33 changes: 21 additions & 12 deletions src/main/java/org/isf/lab/service/LabIoOperationRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.springframework.data.repository.query.Param;

public interface LabIoOperationRepository extends JpaRepository<Laboratory, Integer> {

List<Laboratory> findByLabDateBetweenOrderByLabDateDesc(LocalDateTime dateFrom, LocalDateTime dateTo);

List<Laboratory> findByLabDateBetweenAndExam_DescriptionOrderByLabDateDesc(LocalDateTime dateFrom, LocalDateTime dateTo, String exam);
Expand All @@ -42,24 +43,32 @@ public interface LabIoOperationRepository extends JpaRepository<Laboratory, Inte

List<Laboratory> findByLabDateBetweenOrderByExam_Examtype_DescriptionDesc(LocalDateTime dateFrom, LocalDateTime dateTo);

List<Laboratory> findByLabDateBetweenAndExam_DescriptionContainingOrderByExam_Examtype_DescriptionDesc(LocalDateTime dateFrom, LocalDateTime dateTo, String exam);
List<Laboratory> findByLabDateBetweenAndExam_DescriptionContainingOrderByExam_Examtype_DescriptionDesc(LocalDateTime dateFrom, LocalDateTime dateTo,
String exam);

List<Laboratory> findByLabDateBetweenAndPatientCode(LocalDateTime dateFrom, LocalDateTime dateTo, Integer patientCode);

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 order by lab.labDate desc")
Page<Laboratory> findByLabDateBetweenOrderByLabDateDescPage(@Param("dateFrom") LocalDateTime dateFrom, @Param("dateTo") LocalDateTime dateTo, Pageable pageable);

@Query(value = "select lab from Laboratory lab where (lab.labDate >= :dateFrom and lab.labDate < :dateTo) and lab.exam = :exam order by lab.labDate desc")
Page<Laboratory> findByLabDateBetweenAndExam_DescriptionOrderByLabDateDescPage(@Param("dateFrom") LocalDateTime dateFrom, @Param("dateTo") LocalDateTime dateTo, @Param("exam")Exam exam, Pageable pageable);

Page<Laboratory> findByLabDateBetweenOrderByLabDateDescPage(@Param("dateFrom") LocalDateTime dateFrom, @Param("dateTo") LocalDateTime dateTo,
Pageable pageable);

@Query(value = "select lab from Laboratory lab where (lab.labDate >= :dateFrom and lab.labDate < :dateTo) and lab.exam = :exam order by lab.labDate desc")
Page<Laboratory> findByLabDateBetweenAndExam_DescriptionOrderByLabDateDescPage(@Param("dateFrom") LocalDateTime dateFrom,
@Param("dateTo") LocalDateTime dateTo, @Param("exam") Exam exam, Pageable pageable);

@Query(value = "select lab from Laboratory lab where (lab.labDate >= :dateFrom and lab.labDate < :dateTo) and lab.patient = :patient order by lab.labDate desc")
Page<Laboratory> findByLabDateBetweenAndPatientCodePage(@Param("dateFrom") LocalDateTime dateFrom, @Param("dateTo") LocalDateTime dateTo, @Param("patient") Patient patient, Pageable pageable);

Page<Laboratory> findByLabDateBetweenAndPatientCodePage(@Param("dateFrom") LocalDateTime dateFrom, @Param("dateTo") LocalDateTime dateTo,
@Param("patient") Patient patient, Pageable pageable);

@Query(value = "select lab from Laboratory lab where (lab.labDate >= :dateFrom and lab.labDate < :dateTo) and lab.exam = :exam and lab.patient = :patient order by lab.labDate desc")
Page<Laboratory> findByLabDateBetweenAndExamDescriptionAndPatientCodePage(@Param("dateFrom") LocalDateTime dateFrom, @Param("dateTo") LocalDateTime dateTo, @Param("exam") Exam exam, @Param("patient") Patient patient, Pageable pageable);
Page<Laboratory> findByLabDateBetweenAndExamDescriptionAndPatientCodePage(@Param("dateFrom") LocalDateTime dateFrom, @Param("dateTo") LocalDateTime dateTo,
@Param("exam") Exam exam, @Param("patient") Patient patient, Pageable pageable);

@Query("select count(l) from Laboratory l where active=1")
long countAllActiveLabs();

}
28 changes: 20 additions & 8 deletions src/main/java/org/isf/lab/service/LabIoOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public List<Laboratory> getLaboratory(boolean oneWeek, int pageNo, int pageSize)
}
return repository.findAll(pageable).getContent();
}

public PagedResponse<Laboratory> getLaboratoryPageable(boolean oneWeek, int pageNo, int pageSize) throws OHServiceException {
Pageable pageable = PageRequest.of(pageNo, pageSize);
if (oneWeek) {
Expand All @@ -115,7 +115,7 @@ public PagedResponse<Laboratory> getLaboratoryPageable(boolean oneWeek, int page
Page<Laboratory> pagedResult = repository.findAll(pageable);
return setPaginationData(pagedResult);
}

/**
* Return the whole list of exams ({@link Laboratory}s) within the last week.
*
Expand Down Expand Up @@ -405,29 +405,41 @@ public boolean isCodePresent(Integer code) throws OHServiceException {
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 {

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));
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));
laboritories = repository.findByLabDateBetweenAndPatientCodePage(dateFrom, dateTo, patient, PageRequest.of(page, size));
}
if (patient == null && exam == null) {
laboritories = repository.findByLabDateBetweenOrderByLabDateDescPage(dateFrom, dateTo, PageRequest.of(page, size));
laboritories = repository.findByLabDateBetweenOrderByLabDateDescPage(dateFrom, dateTo, PageRequest.of(page, size));
}
return setPaginationData(laboritories);
}

PagedResponse<Laboratory> setPaginationData(Page<Laboratory> pages) {
PagedResponse<Laboratory> data = new PagedResponse<>();
data.setData(pages.getContent());
data.setPageInfo(PageInfo.from(pages));
return data;
}

/**
* Count active {@link Laboratory}s
*
* @return the number of recorded {@link Laboratory}s
* @throws OHServiceException
*/
public long countAllActiveLabs() {
return this.repository.countAllActiveLabs();
}

}
Loading

0 comments on commit 6127eff

Please sign in to comment.