diff --git a/src/main/java/org/isf/accounting/service/AccountingBillIoOperationRepository.java b/src/main/java/org/isf/accounting/service/AccountingBillIoOperationRepository.java index 5b1232936..c2d93cfec 100644 --- a/src/main/java/org/isf/accounting/service/AccountingBillIoOperationRepository.java +++ b/src/main/java/org/isf/accounting/service/AccountingBillIoOperationRepository.java @@ -46,7 +46,7 @@ public interface AccountingBillIoOperationRepository extends JpaRepository 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 findAllPendindBillsByBillPatient(@Param("patID") int patID); @@ -64,4 +64,7 @@ List findByDateAndPatient(@Param("dateFrom") LocalDateTime dateFrom, @Para @Query(value = "select distinct b.user FROM Bill b ORDER BY b.user asc") List findUserDistinctByOrderByUserAsc(); + + @Query("select count(b) from Bill b where active=1") + long countAllActiveBills(); } \ No newline at end of file diff --git a/src/main/java/org/isf/accounting/service/AccountingIoOperations.java b/src/main/java/org/isf/accounting/service/AccountingIoOperations.java index 647e93d88..cef1d910c 100644 --- a/src/main/java/org/isf/accounting/service/AccountingIoOperations.java +++ b/src/main/java/org/isf/accounting/service/AccountingIoOperations.java @@ -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. @@ -66,7 +65,7 @@ public List getPendingBills(int patID) throws OHServiceException { } return billRepository.findByStatusOrderByDateDesc("O"); } - + /** * Get all the {@link Bill}s. * @return a list of bills. @@ -75,7 +74,7 @@ public List getPendingBills(int patID) throws OHServiceException { public List getBills() throws OHServiceException { return billRepository.findAllByOrderByDateDesc(); } - + /** * Get the {@link Bill} with specified billID. * @param billID @@ -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 getUsers() throws OHServiceException { - Set accountingUsers = new TreeSet<>(String::compareTo); - accountingUsers.addAll(billRepository.findUserDistinctByOrderByUserAsc()); - accountingUsers.addAll(billPaymentRepository.findUserDistinctByOrderByUserAsc()); + public List getUsers() throws OHServiceException { + Set accountingUsers = new TreeSet<>(String::compareTo); + accountingUsers.addAll(billRepository.findUserDistinctByOrderByUserAsc()); + accountingUsers.addAll(billPaymentRepository.findUserDistinctByOrderByUserAsc()); return new ArrayList<>(accountingUsers); } @@ -239,7 +238,7 @@ public List getPayments(List bills) throws OHServiceExceptio * @throws OHServiceException */ public List getPaymentsBetweenDatesWherePatient(LocalDateTime dateFrom, LocalDateTime dateTo, Patient patient) - throws OHServiceException { + throws OHServiceException { return billPaymentRepository.findByDateAndPatient(TimeTools.getBeginningOfDay(dateFrom), TimeTools.getBeginningOfNextDay(dateTo), patient.getCode()); } @@ -299,6 +298,17 @@ public List 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(); + } + } diff --git a/src/main/java/org/isf/admission/service/AdmissionIoOperationRepository.java b/src/main/java/org/isf/admission/service/AdmissionIoOperationRepository.java index 6ad6bb180..9db7884cc 100644 --- a/src/main/java/org/isf/admission/service/AdmissionIoOperationRepository.java +++ b/src/main/java/org/isf/admission/service/AdmissionIoOperationRepository.java @@ -52,19 +52,22 @@ List findAllWhereWardAndDates( @Query(value = "select a FROM Admission a WHERE a.admitted =1 and a.ward.code = :ward and a.deleted = 'N'") List 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 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 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 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 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 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(); } \ No newline at end of file diff --git a/src/main/java/org/isf/admission/service/AdmissionIoOperations.java b/src/main/java/org/isf/admission/service/AdmissionIoOperations.java index 3d0251ba9..37eec7821 100644 --- a/src/main/java/org/isf/admission/service/AdmissionIoOperations.java +++ b/src/main/java/org/isf/admission/service/AdmissionIoOperations.java @@ -328,7 +328,7 @@ public Patient deletePatientPhoto(int patientId) throws OHServiceException { } return patientRepository.save(foundPatient); } - + /** * Returns the list of Admissions by pages * @@ -353,7 +353,7 @@ public List getAdmissionsByAdmissionDate(LocalDateTime dateFrom, Loca public List getAdmissionsByAdmDate(LocalDateTime dateFrom, LocalDateTime dateTo) throws OHServiceException { return repository.findAllWhereAdmissionDate(dateFrom, dateTo); } - + /** * Returns the list of Admissions with discharge * @@ -394,7 +394,7 @@ public PagedResponse getAdmissionsByDischargeDates(LocalDateTime date Page pagedResult = repository.findAllWhere_DischargeDate_Paginated(dateFrom, dateTo, pageable); return setPaginationData(pagedResult); } - + /** * Returns the list of Admissions with page info * @@ -407,4 +407,15 @@ PagedResponse setPaginationData(Page 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(); + } + } diff --git a/src/main/java/org/isf/generaldata/GeneralData.java b/src/main/java/org/isf/generaldata/GeneralData.java index 4fcb0ff39..b3bc46c39 100644 --- a/src/main/java/org/isf/generaldata/GeneralData.java +++ b/src/main/java/org/isf/generaldata/GeneralData.java @@ -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; @@ -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; @@ -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; @@ -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); @@ -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) { @@ -254,7 +263,7 @@ public static void initialize() { public boolean getSINGLEUSER() { return SINGLEUSER; } - + /** * @return the USERSLISTLOGIN */ diff --git a/src/main/java/org/isf/lab/service/LabIoOperationRepository.java b/src/main/java/org/isf/lab/service/LabIoOperationRepository.java index 8c6d5ec45..1557aa381 100644 --- a/src/main/java/org/isf/lab/service/LabIoOperationRepository.java +++ b/src/main/java/org/isf/lab/service/LabIoOperationRepository.java @@ -34,6 +34,7 @@ import org.springframework.data.repository.query.Param; public interface LabIoOperationRepository extends JpaRepository { + List findByLabDateBetweenOrderByLabDateDesc(LocalDateTime dateFrom, LocalDateTime dateTo); List findByLabDateBetweenAndExam_DescriptionOrderByLabDateDesc(LocalDateTime dateFrom, LocalDateTime dateTo, String exam); @@ -42,24 +43,32 @@ public interface LabIoOperationRepository extends JpaRepository findByLabDateBetweenOrderByExam_Examtype_DescriptionDesc(LocalDateTime dateFrom, LocalDateTime dateTo); - List findByLabDateBetweenAndExam_DescriptionContainingOrderByExam_Examtype_DescriptionDesc(LocalDateTime dateFrom, LocalDateTime dateTo, String exam); + List findByLabDateBetweenAndExam_DescriptionContainingOrderByExam_Examtype_DescriptionDesc(LocalDateTime dateFrom, LocalDateTime dateTo, + String exam); List findByLabDateBetweenAndPatientCode(LocalDateTime dateFrom, LocalDateTime dateTo, Integer patientCode); - + List findByLabDateBetweenAndExamDescriptionAndPatientCode(LocalDateTime dateFrom, LocalDateTime dateTo, String exam, Integer patient); - + Page 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 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 findByLabDateBetweenAndExam_DescriptionOrderByLabDateDescPage(@Param("dateFrom") LocalDateTime dateFrom, @Param("dateTo") LocalDateTime dateTo, @Param("exam")Exam exam, Pageable pageable); - + Page 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 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 findByLabDateBetweenAndPatientCodePage(@Param("dateFrom") LocalDateTime dateFrom, @Param("dateTo") LocalDateTime dateTo, @Param("patient") Patient patient, Pageable pageable); - + Page 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 findByLabDateBetweenAndExamDescriptionAndPatientCodePage(@Param("dateFrom") LocalDateTime dateFrom, @Param("dateTo") LocalDateTime dateTo, @Param("exam") Exam exam, @Param("patient") Patient patient, Pageable pageable); + Page 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(); } diff --git a/src/main/java/org/isf/lab/service/LabIoOperations.java b/src/main/java/org/isf/lab/service/LabIoOperations.java index 90129f346..e34a6e9fe 100644 --- a/src/main/java/org/isf/lab/service/LabIoOperations.java +++ b/src/main/java/org/isf/lab/service/LabIoOperations.java @@ -103,7 +103,7 @@ public List getLaboratory(boolean oneWeek, int pageNo, int pageSize) } return repository.findAll(pageable).getContent(); } - + public PagedResponse getLaboratoryPageable(boolean oneWeek, int pageNo, int pageSize) throws OHServiceException { Pageable pageable = PageRequest.of(pageNo, pageSize); if (oneWeek) { @@ -115,7 +115,7 @@ public PagedResponse getLaboratoryPageable(boolean oneWeek, int page Page pagedResult = repository.findAll(pageable); return setPaginationData(pagedResult); } - + /** * Return the whole list of exams ({@link Laboratory}s) within the last week. * @@ -405,29 +405,41 @@ public boolean isCodePresent(Integer code) throws OHServiceException { public Optional getLaboratory(int code) throws OHServiceException { return repository.findById(code); } - - public PagedResponse getLaboratoryPageable(Exam exam, LocalDateTime dateFrom, LocalDateTime dateTo, Patient patient, int page, int size) throws OHServiceException { + + public PagedResponse getLaboratoryPageable(Exam exam, LocalDateTime dateFrom, LocalDateTime dateTo, Patient patient, int page, int size) + throws OHServiceException { Page 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 setPaginationData(Page pages) { PagedResponse 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(); + } + } diff --git a/src/main/java/org/isf/medicalstock/service/MedicalStockIoOperations.java b/src/main/java/org/isf/medicalstock/service/MedicalStockIoOperations.java index ff666b2e7..b92efee34 100644 --- a/src/main/java/org/isf/medicalstock/service/MedicalStockIoOperations.java +++ b/src/main/java/org/isf/medicalstock/service/MedicalStockIoOperations.java @@ -50,16 +50,16 @@ * - added complete Ward and Movement construction in getMovement() */ @Service -@Transactional(rollbackFor=OHServiceException.class) +@Transactional(rollbackFor = OHServiceException.class) @TranslateOHServiceException public class MedicalStockIoOperations { @Autowired private MovementIoOperationRepository movRepository; - + @Autowired private LotIoOperationRepository lotRepository; - + @Autowired private MedicalsIoOperationRepository medicalRepository; @@ -87,7 +87,7 @@ private boolean isAutomaticLotMode() { public List getMedicalsFromLot(String lotCode) throws OHServiceException { return movRepository.findAllByLot(lotCode); } - + /** * Store the specified {@link Movement} by using automatically the most old lots * and splitting in more movements if required @@ -103,17 +103,17 @@ public boolean newAutomaticDischargingMovement(Movement movement) throws OHServi int qty = movement.getQuantity(); // movement initial quantity for (Lot lot : lots) { Movement splitMovement = new Movement(movement.getMedical(), movement.getType(), movement.getWard(), - null, // lot to be set - movement.getDate(), - qty, // quantity can remain the same or changed if greater than lot quantity - null, - movement.getRefNo()); + null, // lot to be set + movement.getDate(), + qty, // quantity can remain the same or changed if greater than lot quantity + null, + movement.getRefNo()); int qtLot = lot.getMainStoreQuantity(); if (qtLot < qty) { splitMovement.setQuantity(qtLot); result = storeMovement(splitMovement, lot.getCode()); if (result) { - //medical stock movement inserted updates quantity of the medical + // medical stock movement inserted updates quantity of the medical result = updateStockQuantity(splitMovement); } qty = qty - qtLot; @@ -121,7 +121,7 @@ public boolean newAutomaticDischargingMovement(Movement movement) throws OHServi splitMovement.setQuantity(qty); result = storeMovement(splitMovement, lot.getCode()); if (result) { - //medical stock movement inserted updates quantity of the medical + // medical stock movement inserted updates quantity of the medical result = updateStockQuantity(splitMovement); } break; @@ -130,7 +130,7 @@ public boolean newAutomaticDischargingMovement(Movement movement) throws OHServi return result; } - + /** * Stores the specified {@link Movement}. * @param movement - the movement to store. @@ -144,9 +144,9 @@ public boolean newMovement(Movement movement) throws OHServiceException { lotCode = movement.getLot().getCode(); } - //we have to manage the Lot + // we have to manage the Lot if (movement.getType().getType().contains("+")) { - //if is in automatic lot mode then we have to generate a new lot code + // if is in automatic lot mode then we have to generate a new lot code if (isAutomaticLotMode() || lotCode.equals("")) { lotCode = generateLotCode(); } @@ -162,14 +162,14 @@ public boolean newMovement(Movement movement) throws OHServiceException { boolean movementStored = storeMovement(movement, lotCode); if (movementStored) { - //medical stock movement inserted updates quantity of the medical + // medical stock movement inserted updates quantity of the medical return updateStockQuantity(movement); } - //something is failed + // something is failed return false; } - + /** * Prepare the insert of the specified {@link Movement} (no commit) * @param movement - the movement to store. @@ -179,7 +179,7 @@ public boolean newMovement(Movement movement) throws OHServiceException { public boolean prepareChargingMovement(Movement movement) throws OHServiceException { return newMovement(movement); } - + /** * Prepare the insert of the specified {@link Movement} (no commit) * @param movement - the movement to store. @@ -195,13 +195,13 @@ public boolean prepareDischargingMovement(Movement movement) throws OHServiceExc boolean movementStored = storeMovement(movement, lotCode); - //medical stock movement inserted + // medical stock movement inserted if (movementStored) { // updates quantity of the medical return updateStockQuantity(movement); } - //something is failed + // something is failed return false; } @@ -269,11 +269,11 @@ public boolean storeLot(String lotCode, Lot lot, Medical medical) throws OHServi */ protected boolean updateStockQuantity(Movement movement) throws OHServiceException { if (movement.getType().getType().contains("+")) { - //incoming medical stock + // incoming medical stock Medical medical = movement.getMedical(); return updateMedicalIncomingQuantity(medical.getCode(), movement.getQuantity()); } else { - //outgoing medical stock + // outgoing medical stock Medical medical = movement.getMedical(); boolean updated = updateMedicalOutcomingQuantity(medical.getCode(), movement.getQuantity()); if (!updated) { @@ -281,7 +281,7 @@ protected boolean updateStockQuantity(Movement movement) throws OHServiceExcepti } else { Ward ward = movement.getWard(); if (ward != null) { - //updates stock quantity for wards + // updates stock quantity for wards return updateMedicalWardQuantity(ward, medical, movement.getQuantity(), movement.getLot()); } else { return true; @@ -335,7 +335,7 @@ protected boolean updateMedicalWardQuantity(Ward ward, Medical medical, int quan medicalStockRepository.save(medicalWard); } else { medicalWard = new MedicalWard(ward, medical, quantity, 0, lot); - medicalStockRepository.insertMedicalWard(ward.getCode(), medical.getCode(), (double)quantity, lot.getCode()); + medicalStockRepository.insertMedicalWard(ward.getCode(), medical.getCode(), (double) quantity, lot.getCode()); } medicalStockRepository.save(medicalWard); return true; @@ -362,7 +362,7 @@ public List getMovements(String wardId, LocalDateTime dateFrom, LocalD List pMovement = new ArrayList<>(); List pMovementCode = movRepository.findMovementWhereDatesAndId(wardId, TimeTools.truncateToSeconds(dateFrom), - TimeTools.truncateToSeconds(dateTo)); + TimeTools.truncateToSeconds(dateTo)); for (int i = 0; i < pMovementCode.size(); i++) { Integer code = pMovementCode.get(i); Movement movement = movRepository.findById(code).orElse(null); @@ -387,25 +387,25 @@ public List getMovements(String wardId, LocalDateTime dateFrom, LocalD * @throws OHServiceException */ public List getMovements( - Integer medicalCode, - String medicalType, - String wardId, - String movType, - LocalDateTime movFrom, - LocalDateTime movTo, - LocalDateTime lotPrepFrom, - LocalDateTime lotPrepTo, - LocalDateTime lotDueFrom, - LocalDateTime lotDueTo) throws OHServiceException { + Integer medicalCode, + String medicalType, + String wardId, + String movType, + LocalDateTime movFrom, + LocalDateTime movTo, + LocalDateTime lotPrepFrom, + LocalDateTime lotPrepTo, + LocalDateTime lotDueFrom, + LocalDateTime lotDueTo) throws OHServiceException { List pMovement = new ArrayList<>(); List pMovementCode = movRepository.findMovementWhereData(medicalCode, medicalType, wardId, movType, - TimeTools.truncateToSeconds(movFrom), - TimeTools.truncateToSeconds(movTo), - TimeTools.truncateToSeconds(lotPrepFrom), - TimeTools.truncateToSeconds(lotPrepTo), - TimeTools.truncateToSeconds(lotDueFrom), - TimeTools.truncateToSeconds(lotDueTo)); + TimeTools.truncateToSeconds(movFrom), + TimeTools.truncateToSeconds(movTo), + TimeTools.truncateToSeconds(lotPrepFrom), + TimeTools.truncateToSeconds(lotPrepTo), + TimeTools.truncateToSeconds(lotDueFrom), + TimeTools.truncateToSeconds(lotDueTo)); for (int i = 0; i < pMovementCode.size(); i++) { Integer code = pMovementCode.get(i); Movement movement = movRepository.findById(code).orElse(null); @@ -428,14 +428,14 @@ public List getMovements( * @throws OHServiceException if an error occurs retrieving the movements. */ public List getMovementForPrint( - String medicalDescription, - String medicalTypeCode, - String wardId, - String movType, - LocalDateTime movFrom, - LocalDateTime movTo, - String lotCode, - MovementOrder order) throws OHServiceException { + String medicalDescription, + String medicalTypeCode, + String wardId, + String movType, + LocalDateTime movFrom, + LocalDateTime movTo, + String lotCode, + MovementOrder order) throws OHServiceException { List pMovement = new ArrayList<>(); List pMovementCode = movRepository.findMovementForPrint(medicalDescription, medicalTypeCode, wardId, movType, movFrom, movTo, lotCode, order); @@ -456,7 +456,7 @@ public List getMovementForPrint( */ public List getLotsByMedical(Medical medical) throws OHServiceException { List lots = lotRepository.findByMedicalOrderByDueDate(medical.getCode()); - //retrieve quantities + // retrieve quantities lots.forEach(lot -> { lot.setMainStoreQuantity(lotRepository.getMainStoreQuantity(lot)); lot.setWardsTotalQuantity(lotRepository.getWardsTotalQuantity(lot)); @@ -473,7 +473,7 @@ public List getLotsByMedical(Medical medical) throws OHServiceException { public LocalDateTime getLastMovementDate() throws OHServiceException { return movRepository.findMaxDate(); } - + /** * Check if the reference number is already used * @return true if is already used, false otherwise. @@ -494,4 +494,14 @@ public List getMovementsByReference(String refNo) throws OHServiceExce return movRepository.findAllByRefNo(refNo); } + /** + * Count active {@link Movement}s + * + * @return the number of recorded {@link Movement}s + * @throws OHServiceException + */ + public long countAllActiveMovements() { + return this.movRepository.countAllActiveMovements(); + } + } diff --git a/src/main/java/org/isf/medicalstock/service/MovementIoOperationRepository.java b/src/main/java/org/isf/medicalstock/service/MovementIoOperationRepository.java index f7c1842f9..263d4f390 100644 --- a/src/main/java/org/isf/medicalstock/service/MovementIoOperationRepository.java +++ b/src/main/java/org/isf/medicalstock/service/MovementIoOperationRepository.java @@ -41,17 +41,17 @@ public interface MovementIoOperationRepository extends JpaRepository findAllByLot(@Param("lot") String lot); @Query(value = "select mov from Movement mov " + - "join mov.type movtype " + - "left join mov.lot lot " + - "left join mov.ward ward " + - "where mov.refNo = :refNo order by mov.date, mov.refNo") + "join mov.type movtype " + + "left join mov.lot lot " + + "left join mov.ward ward " + + "where mov.refNo = :refNo order by mov.date, mov.refNo") List findAllByRefNo(@Param("refNo") String refNo); List findByLot(Lot lot); @@ -61,4 +61,7 @@ public interface MovementIoOperationRepository extends JpaRepository findAllWhereRefNo(@Param("refNo") String refNo); + + @Query("select count(m) from Movement m where active=1") + long countAllActiveMovements(); } diff --git a/src/main/java/org/isf/medicalstockward/service/MedicalStockWardIoOperations.java b/src/main/java/org/isf/medicalstockward/service/MedicalStockWardIoOperations.java index 7435c7caa..c4d07f388 100644 --- a/src/main/java/org/isf/medicalstockward/service/MedicalStockWardIoOperations.java +++ b/src/main/java/org/isf/medicalstockward/service/MedicalStockWardIoOperations.java @@ -44,18 +44,19 @@ * @author mwithi */ @Service -@Transactional(rollbackFor=OHServiceException.class) +@Transactional(rollbackFor = OHServiceException.class) @TranslateOHServiceException -public class MedicalStockWardIoOperations -{ +public class MedicalStockWardIoOperations { @Autowired private MedicalStockWardIoOperationRepository repository; + @Autowired private MovementWardIoOperationRepository movementRepository; + @Autowired private LotIoOperationRepository lotRepository; - + /** * Get all {@link MovementWard}s with the specified criteria. * @param wardId the ward id. @@ -68,15 +69,15 @@ public List getWardMovements(String wardId, LocalDateTime dateFrom List pMovementWard = new ArrayList<>(); List pMovementWardCode = new ArrayList<>(repository.findAllWardMovement(wardId, TimeTools.truncateToSeconds(dateFrom), - TimeTools.truncateToSeconds(dateTo))); + TimeTools.truncateToSeconds(dateTo))); for (Integer code : pMovementWardCode) { MovementWard movementWard = movementRepository.findById(code).orElse(null); pMovementWard.add(movementWard); } return pMovementWard; } - - /** + + /** * Get all {@link MovementWard}s with the specified criteria. * @param idwardTo the target ward id. * @param dateFrom the lower bound for the movement date range. @@ -84,9 +85,9 @@ public List getWardMovements(String wardId, LocalDateTime dateFrom * @return the retrieved movements. * @throws OHServiceException if an error occurs retrieving the movements. */ - public List getWardMovementsToWard(String idwardTo, LocalDateTime dateFrom, LocalDateTime dateTo) throws OHServiceException { - return movementRepository.findWardMovements(idwardTo, TimeTools.truncateToSeconds(dateFrom), TimeTools.truncateToSeconds(dateTo)); - } + public List getWardMovementsToWard(String idwardTo, LocalDateTime dateFrom, LocalDateTime dateTo) throws OHServiceException { + return movementRepository.findWardMovements(idwardTo, TimeTools.truncateToSeconds(dateFrom), TimeTools.truncateToSeconds(dateTo)); + } /** * Gets the current quantity for the specified {@link Medical} and specified {@link Ward}. @@ -103,7 +104,7 @@ public int getCurrentQuantityInWard(Ward ward, Medical medical) throws OHService } return (int) (mainQuantity != null ? mainQuantity : 0.0); } - + /** * Gets the current quantity for the specified {@link Ward} and {@link Lot}. * @param ward - if {@code null} the quantity is counted for the whole hospital @@ -261,7 +262,6 @@ public List getWardMovementsToPatient(Integer patId) { return movementRepository.findWardMovementPat(patId); } - /** * Gets all the {@link MedicalWard}s associated to the specified ward summarized by lot * (total quantity, regardless the lot) @@ -285,4 +285,15 @@ public List getMedicalsWardTotalQuantity(char wardId) throws OHServ } return medicalWardsQty; } + + /** + * Count active {@link MovementWard} + * + * @return the number of recorded {@link MovementWard} + * @throws OHServiceException + */ + public long countAllActiveMovementsWard() { + return this.movementRepository.countAllActiveMovementsWard(); + } + } diff --git a/src/main/java/org/isf/medicalstockward/service/MovementWardIoOperationRepository.java b/src/main/java/org/isf/medicalstockward/service/MovementWardIoOperationRepository.java index e59b3bb70..b49b8ce67 100644 --- a/src/main/java/org/isf/medicalstockward/service/MovementWardIoOperationRepository.java +++ b/src/main/java/org/isf/medicalstockward/service/MovementWardIoOperationRepository.java @@ -35,12 +35,15 @@ public interface MovementWardIoOperationRepository extends JpaRepository findWardMovements(@Param("idWardTo") String idWardTo, - @Param("dateFrom") LocalDateTime dateFrom, - @Param("dateTo") LocalDateTime dateTo); + @Param("dateFrom") LocalDateTime dateFrom, + @Param("dateTo") LocalDateTime dateTo); List findByPatient_code(int code); @Query(value = "SELECT * FROM OH_MEDICALDSRSTOCKMOVWARD WHERE MMVN_PAT_ID = :patId", nativeQuery = true) List findWardMovementPat(@Param("patId") Integer patId); + @Query("select count(m) from MovementWard m where active=1") + long countAllActiveMovementsWard(); + } diff --git a/src/main/java/org/isf/menu/service/MenuIoOperations.java b/src/main/java/org/isf/menu/service/MenuIoOperations.java index e3ad8cb9c..844d8a6de 100644 --- a/src/main/java/org/isf/menu/service/MenuIoOperations.java +++ b/src/main/java/org/isf/menu/service/MenuIoOperations.java @@ -36,7 +36,7 @@ import org.springframework.transaction.annotation.Transactional; @Service -@Transactional(rollbackFor=OHServiceException.class) +@Transactional(rollbackFor = OHServiceException.class) @TranslateOHServiceException public class MenuIoOperations { @@ -48,7 +48,7 @@ public class MenuIoOperations { private UserMenuItemIoOperationRepository menuRepository; @Autowired private GroupMenuIoOperationRepository groupMenuRepository; - + /** * Returns the list of {@link User}s * @@ -60,12 +60,21 @@ public List getUser() throws OHServiceException { } /** - * Count all active users + * Count all active {@link User}s + * + * @return + */ + public long countAllActiveUsers() { + return repository.countAllActiveUsers(); + } + + /** + * Count all active {@link UserGroup}s * * @return */ - public long countAllActive() { - return repository.countAllActive(); + public long countAllActiveGroups() { + return repository.countAllActiveGroups(); } /** @@ -78,7 +87,7 @@ public long countAllActive() { public List getUser(String groupID) throws OHServiceException { return repository.findAllWhereUserGroupNameByOrderUserNameAsc(groupID); } - + /** * Returns {@link User} from its username * @@ -89,7 +98,7 @@ public List getUser(String groupID) throws OHServiceException { public User getUserByName(String userName) throws OHServiceException { return repository.findByUserName(userName); } - + /** * Returns {@link User} description from its username * @@ -101,7 +110,7 @@ public String getUsrInfo(String userName) throws OHServiceException { User user = repository.findById(userName).orElse(null); return user.getDesc(); } - + /** * Returns the list of {@link UserGroup}s * @@ -111,7 +120,7 @@ public String getUsrInfo(String userName) throws OHServiceException { public List getUserGroup() throws OHServiceException { return groupRepository.findAllByOrderByCodeAsc(); } - + /** * Checks if the specified {@link User} code is already present. * @@ -122,7 +131,7 @@ public List getUserGroup() throws OHServiceException { public boolean isUserNamePresent(String userName) throws OHServiceException { return repository.existsById(userName); } - + /** * Checks if the specified {@link UserGroup} code is already present. * @@ -133,7 +142,7 @@ public boolean isUserNamePresent(String userName) throws OHServiceException { public boolean isGroupNamePresent(String groupName) throws OHServiceException { return groupRepository.existsById(groupName); } - + /** * Inserts a new {@link User} in the DB * @@ -144,7 +153,7 @@ public boolean isGroupNamePresent(String groupName) throws OHServiceException { public boolean newUser(User user) throws OHServiceException { return repository.save(user) != null; } - + /** * Updates an existing {@link User} in the DB * @@ -155,7 +164,7 @@ public boolean newUser(User user) throws OHServiceException { public boolean updateUser(User user) throws OHServiceException { return repository.updateUser(user.getDesc(), user.getUserGroupName(), user.getUserName()) > 0; } - + /** * Updates the password of an existing {@link User} in the DB * @@ -275,7 +284,7 @@ private boolean insertGroupMenu(UserGroup aGroup, UserMenuItem item) throws OHSe groupMenuRepository.save(groupMenu); return true; } - + /** * Deletes a {@link UserGroup} * diff --git a/src/main/java/org/isf/menu/service/UserIoOperationRepository.java b/src/main/java/org/isf/menu/service/UserIoOperationRepository.java index 1ea3b05aa..0d77993a9 100644 --- a/src/main/java/org/isf/menu/service/UserIoOperationRepository.java +++ b/src/main/java/org/isf/menu/service/UserIoOperationRepository.java @@ -63,6 +63,9 @@ public interface UserIoOperationRepository extends JpaRepository { void setLastLogin(@Param("lastLoggedIn") LocalDateTime lockTime, @Param("id") String id); @Query("select count(u) from User u where active=1") - long countAllActive(); + long countAllActiveUsers(); + + @Query("select count(g) from UserGroup g where active=1") + long countAllActiveGroups(); } diff --git a/src/main/java/org/isf/opd/service/OpdIoOperationRepository.java b/src/main/java/org/isf/opd/service/OpdIoOperationRepository.java index 4d8f81a6e..23555b33b 100644 --- a/src/main/java/org/isf/opd/service/OpdIoOperationRepository.java +++ b/src/main/java/org/isf/opd/service/OpdIoOperationRepository.java @@ -80,4 +80,7 @@ Page findOpdListPageable(@Param("ward") Ward ward, @Param("diseaseType") Di @Query(value = "SELECT OPD_CREATED_DATE FROM OH_OPD O WHERE OPD_ACTIVE=1 ORDER BY OPD_ID DESC LIMIT 1", nativeQuery = true) LocalDateTime lastOpdCreationDate(); + + @Query("select count(o) from Opd o where active=1") + long countAllActiveOpds(); } diff --git a/src/main/java/org/isf/opd/service/OpdIoOperations.java b/src/main/java/org/isf/opd/service/OpdIoOperations.java index 35cc5a338..28618220e 100644 --- a/src/main/java/org/isf/opd/service/OpdIoOperations.java +++ b/src/main/java/org/isf/opd/service/OpdIoOperations.java @@ -93,6 +93,16 @@ public LocalDateTime lastOpdCreationDate() { return this.repository.lastOpdCreationDate(); } + /** + * Count not deleted {@link Opd}s + * + * @return the number of recorded {@link Opd}s + * @throws OHServiceException + */ + public long countAllActiveOpds() { + return this.repository.countAllActiveOpds(); + } + /** * Return all {@link Opd}s within specified dates and parameters. * @@ -212,9 +222,8 @@ public boolean isCodePresent(Integer code) throws OHServiceException { * @throws OHServiceException */ public boolean isExistOpdNum(int opdNum, int year) throws OHServiceException { - List opds = year == 0 ? - repository.findByProgYear(opdNum) : - repository.findByProgYearAndDateBetween(opdNum, LocalDateTime.of(year, 1, 1, 0, 0), LocalDateTime.of(year + 1, 1, 1, 0, 0)); + List opds = year == 0 ? repository.findByProgYear(opdNum) + : repository.findByProgYearAndDateBetween(opdNum, LocalDateTime.of(year, 1, 1, 0, 0), LocalDateTime.of(year + 1, 1, 1, 0, 0)); return !opds.isEmpty(); } @@ -235,7 +244,7 @@ public Optional getOpdById(Integer code) { public List getOpdByProgYear(Integer code) { return repository.findByProgYear(code); } - + /** * Retrieves a page of {@link Opd}s within specified dates and parameters. * @@ -255,18 +264,18 @@ public List getOpdByProgYear(Integer code) { * @throws OHServiceException */ public PagedResponse getOpdListPageable( - Ward ward, - String diseaseTypeCode, - String diseaseCode, - LocalDate dateFrom, - LocalDate dateTo, - int ageFrom, - int ageTo, - char sex, - char newPatient, - String user, - int page, - int size) throws OHServiceException { + Ward ward, + String diseaseTypeCode, + String diseaseCode, + LocalDate dateFrom, + LocalDate dateTo, + int ageFrom, + int ageTo, + char sex, + char newPatient, + String user, + int page, + int size) throws OHServiceException { Pageable pageRequest = PageRequest.of(page, size); List ops = this.getOpdList(ward, diseaseTypeCode, diseaseCode, dateFrom, dateTo, ageFrom, ageTo, sex, newPatient, null); int start = (int) pageRequest.getOffset(); @@ -274,7 +283,7 @@ public PagedResponse getOpdListPageable( List pageContent = ops.subList(start, end); return setPaginationData(new PageImpl<>(pageContent, pageRequest, ops.size())); } - + PagedResponse setPaginationData(Page pages) { PagedResponse data = new PagedResponse<>(); data.setData(pages.getContent()); diff --git a/src/main/java/org/isf/operation/service/OperationRowIoOperationRepository.java b/src/main/java/org/isf/operation/service/OperationRowIoOperationRepository.java index 123d68b53..b672112b2 100644 --- a/src/main/java/org/isf/operation/service/OperationRowIoOperationRepository.java +++ b/src/main/java/org/isf/operation/service/OperationRowIoOperationRepository.java @@ -28,6 +28,7 @@ import org.isf.operation.model.OperationRow; import org.isf.patient.model.Patient; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; /** @@ -43,6 +44,9 @@ public interface OperationRowIoOperationRepository extends JpaRepository findByOpd(Opd opd); - + List findByAdmissionPatientOrOpdPatient(Patient patient, Patient patient1); + + @Query("select count(o) from OperationRow o where active=1") + long countAllActiveOperations(); } diff --git a/src/main/java/org/isf/operation/service/OperationRowIoOperations.java b/src/main/java/org/isf/operation/service/OperationRowIoOperations.java index 8d1029ce7..fbf07da70 100644 --- a/src/main/java/org/isf/operation/service/OperationRowIoOperations.java +++ b/src/main/java/org/isf/operation/service/OperationRowIoOperations.java @@ -38,20 +38,20 @@ * @author hp */ @Service -@Transactional(rollbackFor=OHServiceException.class) +@Transactional(rollbackFor = OHServiceException.class) @TranslateOHServiceException public class OperationRowIoOperations { - - @Autowired - private OperationRowIoOperationRepository repository; - - public List getOperationRow() throws OHServiceException{ - return repository.findByOrderByOpDateDesc(); - } - public List getOperationRowByAdmission(Admission adm) throws OHServiceException{ - return repository.findByAdmission(adm); - } + @Autowired + private OperationRowIoOperationRepository repository; + + public List getOperationRow() throws OHServiceException { + return repository.findByOrderByOpDateDesc(); + } + + public List getOperationRowByAdmission(Admission adm) throws OHServiceException { + return repository.findByAdmission(adm); + } public List getOperationRowByOpd(Opd opd) throws OHServiceException { if (opd.isPersisted()) { @@ -87,10 +87,21 @@ public OperationRow updateOperationRow(OperationRow opRow) throws OHServiceExcep } public OperationRow newOperationRow(OperationRow opRow) throws OHServiceException { - return repository.save(opRow); + return repository.save(opRow); } public List getOperationRowByPatient(Patient patient) throws OHServiceException { return repository.findByAdmissionPatientOrOpdPatient(patient, patient); } + + /** + * Count active {@link OperationRow}s + * + * @return the number of recorded {@link OperationRow}s + * @throws OHServiceException + */ + public long countAllActiveOperations() { + return this.repository.countAllActiveOperations(); + } + } diff --git a/src/main/java/org/isf/patient/service/PatientIoOperationRepository.java b/src/main/java/org/isf/patient/service/PatientIoOperationRepository.java index 25af47009..c1f5d740e 100644 --- a/src/main/java/org/isf/patient/service/PatientIoOperationRepository.java +++ b/src/main/java/org/isf/patient/service/PatientIoOperationRepository.java @@ -61,5 +61,5 @@ public interface PatientIoOperationRepository extends JpaRepository getPatientsByParams(Map params); @Query("select count(p) from Patient p where active=1 and deleted not like 'Y'") - long countAllActivePatients(); + long countAllActiveNotDeletedPatients(); } diff --git a/src/main/java/org/isf/patient/service/PatientIoOperations.java b/src/main/java/org/isf/patient/service/PatientIoOperations.java index 542613ada..445b69fe4 100644 --- a/src/main/java/org/isf/patient/service/PatientIoOperations.java +++ b/src/main/java/org/isf/patient/service/PatientIoOperations.java @@ -323,7 +323,7 @@ PagedResponse setPaginationData(Page pages){ * @throws OHServiceException */ public long countAllActivePatients() throws OHServiceException { - return repository.countAllActivePatients(); + return repository.countAllActiveNotDeletedPatients(); } } diff --git a/src/main/java/org/isf/telemetry/envdatacollector/collectors/HardwareDataCollector.java b/src/main/java/org/isf/telemetry/envdatacollector/collectors/HardwareDataCollector.java index 6d068b2e9..d9d5334da 100644 --- a/src/main/java/org/isf/telemetry/envdatacollector/collectors/HardwareDataCollector.java +++ b/src/main/java/org/isf/telemetry/envdatacollector/collectors/HardwareDataCollector.java @@ -52,7 +52,7 @@ public String getId() { @Override public String getDescription() { - return "Hardware information (ex. CPU Intel, RAM, etc.)"; + return "Hardware information (CPU, RAM)"; } @Override diff --git a/src/main/java/org/isf/telemetry/envdatacollector/collectors/OpenHospitalDataCollector.java b/src/main/java/org/isf/telemetry/envdatacollector/collectors/OpenHospitalDataCollector.java index a0c64a622..5975b4013 100644 --- a/src/main/java/org/isf/telemetry/envdatacollector/collectors/OpenHospitalDataCollector.java +++ b/src/main/java/org/isf/telemetry/envdatacollector/collectors/OpenHospitalDataCollector.java @@ -26,17 +26,25 @@ import java.util.List; import java.util.Map; -import org.isf.generaldata.Version; +import org.isf.accounting.service.AccountingIoOperations; +import org.isf.admission.service.AdmissionIoOperations; +import org.isf.lab.service.LabIoOperations; +import org.isf.medicalstock.service.MedicalStockIoOperations; +import org.isf.medicalstockward.service.MedicalStockWardIoOperations; import org.isf.menu.service.MenuIoOperations; import org.isf.opd.service.OpdIoOperations; +import org.isf.operation.service.OperationRowIoOperations; import org.isf.patient.service.PatientIoOperations; import org.isf.telemetry.envdatacollector.AbstractDataCollector; import org.isf.telemetry.envdatacollector.collectors.remote.common.GeoIpInfoBean; import org.isf.telemetry.envdatacollector.collectors.remote.common.GeoIpInfoCommonService; import org.isf.telemetry.envdatacollector.collectors.remote.common.GeoIpInfoSettings; import org.isf.telemetry.envdatacollector.constants.CollectorsConstants; +import org.isf.therapy.service.TherapyIoOperations; import org.isf.utils.exception.OHException; import org.isf.utils.exception.OHServiceException; +import org.isf.vaccine.service.VaccineIoOperations; +import org.isf.visits.service.VisitsIoOperations; import org.isf.ward.service.WardIoOperations; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,6 +71,33 @@ public class OpenHospitalDataCollector extends AbstractDataCollector { @Autowired private OpdIoOperations opdIoOperations; + @Autowired + private AdmissionIoOperations admissionIoOperations; + + @Autowired + private LabIoOperations laboratoryIoOperations; + + @Autowired + private VaccineIoOperations vaccineIoOperations; + + @Autowired + private OperationRowIoOperations operationIoOperations; + + @Autowired + private MedicalStockIoOperations medicalStockIoOperations; + + @Autowired + private MedicalStockWardIoOperations medicalStockWardIoOperations; + + @Autowired + private TherapyIoOperations therapyIoOperations; + + @Autowired + private VisitsIoOperations visitIoOperations; + + @Autowired + private AccountingIoOperations accountingIoOperations; + @Autowired private List geoIpServices; @@ -76,7 +111,7 @@ public String getId() { @Override public String getDescription() { - return "Hospital information (ex. Italy, 100 beds, 5 wards, etc.)"; + return "Hospital general information (Country, Region, City, Postal Code, TimeZone, Currency, OH Version, Number of Patients / Beds / Wards / Users)"; } @Override @@ -100,16 +135,22 @@ public Map retrieveData() throws OHException { } }); - Version.initialize(); - result.put(CollectorsConstants.APP_VERSION, Version.VER_MAJOR.concat(".").concat(Version.VER_MINOR).concat(".").concat(Version.VER_RELEASE)); - // result.put(CollectorsConst.APP_VER_MAJOR, Version.VER_MAJOR); - // result.put(CollectorsConst.APP_VER_MINOR, Version.VER_MINOR); - // result.put(CollectorsConst.APP_RELEASE, Version.VER_RELEASE); - - result.put(CollectorsConstants.OH_TOTAL_ACTIVE_PATIENTS, String.valueOf(patientIoOperations.countAllActivePatients())); - result.put(CollectorsConstants.OH_TOTAL_ACTIVE_USERS, String.valueOf(this.menuIoOperations.countAllActive())); - result.put(CollectorsConstants.OH_TOTAL_ACTIVE_WARDS, String.valueOf(this.wardIoOperations.countAllActiveWards())); - result.put(CollectorsConstants.OH_TOTAL_ACTIVE_BEDS, String.valueOf(this.wardIoOperations.countAllActiveBeds())); + result.put(CollectorsConstants.OH_NUMBER_OF_PATIENTS, String.valueOf(patientIoOperations.countAllActivePatients())); + result.put(CollectorsConstants.OH_NUMBER_OF_USERS, String.valueOf(menuIoOperations.countAllActiveUsers())); + result.put(CollectorsConstants.OH_NUMBER_OF_ROLES, String.valueOf(menuIoOperations.countAllActiveGroups())); + result.put(CollectorsConstants.OH_NUMBER_OF_WARDS, String.valueOf(wardIoOperations.countAllActiveWards())); + result.put(CollectorsConstants.OH_NUMBER_OF_BEDS, String.valueOf(wardIoOperations.countAllActiveBeds())); + + result.put(CollectorsConstants.OH_NUMBER_OF_OPDS, String.valueOf(opdIoOperations.countAllActiveOpds())); + result.put(CollectorsConstants.OH_NUMBER_OF_ADMISSIONS, String.valueOf(admissionIoOperations.countAllActiveAdmissions())); + result.put(CollectorsConstants.OH_NUMBER_OF_EXAMS, String.valueOf(laboratoryIoOperations.countAllActiveLabs())); + result.put(CollectorsConstants.OH_NUMBER_OF_VACCINES, String.valueOf(vaccineIoOperations.countAllActiveVaccinations())); + result.put(CollectorsConstants.OH_NUMBER_OF_OPERATIONS, String.valueOf(operationIoOperations.countAllActiveOperations())); + result.put(CollectorsConstants.OH_NUMBER_OF_STOCKMOVEMENTS, String.valueOf(medicalStockIoOperations.countAllActiveMovements())); + result.put(CollectorsConstants.OH_NUMBER_OF_STOCKWMOVEMENTSWARDS, String.valueOf(medicalStockWardIoOperations.countAllActiveMovementsWard())); + result.put(CollectorsConstants.OH_NUMBER_OF_THERAPIES, String.valueOf(therapyIoOperations.countAllActiveTherapies())); + result.put(CollectorsConstants.OH_NUMBER_OF_APPOINTMENTS, String.valueOf(visitIoOperations.countAllActiveAppointments())); + result.put(CollectorsConstants.OH_NUMBER_OF_BILLS, String.valueOf(accountingIoOperations.countAllActiveBills())); LocalDateTime lastUsedTime = opdIoOperations.lastOpdCreationDate(); if (lastUsedTime == null) { diff --git a/src/main/java/org/isf/telemetry/envdatacollector/collectors/SoftwareDataCollector.java b/src/main/java/org/isf/telemetry/envdatacollector/collectors/SoftwareDataCollector.java index 984fb2049..36b795799 100644 --- a/src/main/java/org/isf/telemetry/envdatacollector/collectors/SoftwareDataCollector.java +++ b/src/main/java/org/isf/telemetry/envdatacollector/collectors/SoftwareDataCollector.java @@ -21,9 +21,17 @@ */ package org.isf.telemetry.envdatacollector.collectors; +import java.sql.DatabaseMetaData; +import java.sql.SQLException; import java.util.LinkedHashMap; import java.util.Map; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + +import org.hibernate.engine.spi.SessionImplementor; +import org.isf.generaldata.GeneralData; +import org.isf.generaldata.Version; import org.isf.telemetry.envdatacollector.AbstractDataCollector; import org.isf.telemetry.envdatacollector.constants.CollectorsConstants; import org.isf.utils.exception.OHException; @@ -41,6 +49,10 @@ public class SoftwareDataCollector extends AbstractDataCollector { private static final String ID = "TEL_SW"; private static final Logger LOGGER = LoggerFactory.getLogger(SoftwareDataCollector.class); + private String version; + + @PersistenceContext + private EntityManager em; @Override public String getId() { @@ -49,7 +61,9 @@ public String getId() { @Override public String getDescription() { - return "Software information (ex. Ubuntu 12.04, MySQL 5.7.36, etc.)"; + Version.initialize(); + version = Version.VER_MAJOR.concat(".").concat(Version.VER_MINOR).concat(".").concat(Version.VER_RELEASE); + return "Software information versions and usage (ex. Ubuntu 22.04, MariaDB 10.6, Open Hospital " + version + ")"; } @Override @@ -65,7 +79,46 @@ public Map retrieveData() throws OHException { result.put(CollectorsConstants.OS_BITNESS, String.valueOf(os.getBitness())); result.put(CollectorsConstants.OS_CODENAME, os.getVersionInfo().getCodeName()); - } catch (RuntimeException e) { + SessionImplementor sessionImp = (SessionImplementor) em.getDelegate(); + DatabaseMetaData dbmd = sessionImp.connection().getMetaData(); + result.put(CollectorsConstants.DBMS_DRIVER_NAME, dbmd.getDriverName()); + result.put(CollectorsConstants.DBMS_DRIVER_VERSION, dbmd.getDriverVersion()); + result.put(CollectorsConstants.DBMS_PRODUCT_NAME, dbmd.getDatabaseProductName()); + result.put(CollectorsConstants.DBMS_PRODUCT_VERSION, dbmd.getDatabaseProductVersion()); + + Version.initialize(); + result.put(CollectorsConstants.APP_VERSION, version); + result.put(CollectorsConstants.APP_MODE, GeneralData.MODE); + result.put(CollectorsConstants.APP_DEMODATA, String.valueOf(GeneralData.DEMODATA)); + result.put(CollectorsConstants.APP_APISERVER, String.valueOf(GeneralData.APISERVER)); + result.put(CollectorsConstants.APP_LANGUAGE, GeneralData.LANGUAGE); + // result.put(CollectorsConstants.APP_SINGLEUSER, GeneralData.getSINGLEUSER()); + result.put(CollectorsConstants.APP_DEBUG, String.valueOf(GeneralData.DEBUG)); + result.put(CollectorsConstants.APP_INTERNALVIEWER, String.valueOf(GeneralData.INTERNALVIEWER)); + result.put(CollectorsConstants.APP_SMSENABLED, String.valueOf(GeneralData.SMSENABLED)); + result.put(CollectorsConstants.APP_VIDEOMODULEENABLED, String.valueOf(GeneralData.VIDEOMODULEENABLED)); + result.put(CollectorsConstants.APP_XMPPMODULEENABLED, String.valueOf(GeneralData.XMPPMODULEENABLED)); + result.put(CollectorsConstants.APP_ENHANCEDSEARCH, String.valueOf(GeneralData.ENHANCEDSEARCH)); + result.put(CollectorsConstants.APP_INTERNALPHARMACIES, String.valueOf(GeneralData.INTERNALPHARMACIES)); + result.put(CollectorsConstants.APP_LABEXTENDED, String.valueOf(GeneralData.LABEXTENDED)); + result.put(CollectorsConstants.APP_LABMULTIPLEINSERT, String.valueOf(GeneralData.LABMULTIPLEINSERT)); + result.put(CollectorsConstants.APP_MATERNITYRESTARTINJUNE, String.valueOf(GeneralData.MATERNITYRESTARTINJUNE)); + result.put(CollectorsConstants.APP_MERGEFUNCTION, String.valueOf(GeneralData.MERGEFUNCTION)); + result.put(CollectorsConstants.APP_OPDEXTENDED, String.valueOf(GeneralData.OPDEXTENDED)); + result.put(CollectorsConstants.APP_PATIENTEXTENDED, String.valueOf(GeneralData.PATIENTEXTENDED)); + result.put(CollectorsConstants.APP_PATIENTVACCINEEXTENDED, String.valueOf(GeneralData.PATIENTVACCINEEXTENDED)); + result.put(CollectorsConstants.APP_MAINMENUALWAYSONTOP, String.valueOf(GeneralData.MAINMENUALWAYSONTOP)); + result.put(CollectorsConstants.APP_ALLOWMULTIPLEOPENEDBILL, String.valueOf(GeneralData.ALLOWMULTIPLEOPENEDBILL)); + result.put(CollectorsConstants.APP_ALLOWPRINTOPENEDBILL, String.valueOf(GeneralData.ALLOWPRINTOPENEDBILL)); + result.put(CollectorsConstants.APP_RECEIPTPRINTER, String.valueOf(GeneralData.RECEIPTPRINTER)); + result.put(CollectorsConstants.APP_AUTOMATICLOT_IN, String.valueOf(GeneralData.AUTOMATICLOT_IN)); + result.put(CollectorsConstants.APP_AUTOMATICLOT_OUT, String.valueOf(GeneralData.AUTOMATICLOT_OUT)); + result.put(CollectorsConstants.APP_AUTOMATICLOTWARD_TOWARD, String.valueOf(GeneralData.AUTOMATICLOTWARD_TOWARD)); + result.put(CollectorsConstants.APP_LOTWITHCOST, String.valueOf(GeneralData.LOTWITHCOST)); + result.put(CollectorsConstants.APP_DICOMMODULEENABLED, String.valueOf(GeneralData.DICOMMODULEENABLED)); + result.put(CollectorsConstants.APP_DICOMTHUMBNAILS, String.valueOf(GeneralData.DICOMTHUMBNAILS)); + + } catch (RuntimeException | SQLException e) { LOGGER.error("Something went wrong with " + ID); LOGGER.error(e.toString()); throw new OHException("Data collector [" + ID + "]", e); diff --git a/src/main/java/org/isf/telemetry/envdatacollector/collectors/TelemetryDataCollector.java b/src/main/java/org/isf/telemetry/envdatacollector/collectors/TelemetryDataCollector.java index 05586fe65..cc1e1e770 100644 --- a/src/main/java/org/isf/telemetry/envdatacollector/collectors/TelemetryDataCollector.java +++ b/src/main/java/org/isf/telemetry/envdatacollector/collectors/TelemetryDataCollector.java @@ -53,7 +53,7 @@ public String getId() { @Override public String getDescription() { - return "Telemetry ID (this instance)"; + return "Telemetry Unique ID (this instance)"; } @Override diff --git a/src/main/java/org/isf/telemetry/envdatacollector/collectors/_ApplicationDataCollector.java b/src/main/java/org/isf/telemetry/envdatacollector/collectors/_ApplicationDataCollector.java deleted file mode 100644 index 80527dbc9..000000000 --- a/src/main/java/org/isf/telemetry/envdatacollector/collectors/_ApplicationDataCollector.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2022 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) - * - * Open Hospital is a free and open source software for healthcare data management. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * https://www.gnu.org/licenses/gpl-3.0-standalone.html - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.isf.telemetry.envdatacollector.collectors; - -import java.util.HashMap; -import java.util.Map; - -import org.isf.generaldata.Version; -import org.isf.telemetry.envdatacollector.constants.CollectorsConstants; -import org.isf.utils.exception.OHException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -@Order(value = 10) -@Component -public class _ApplicationDataCollector { - - private static final String ID = "TEL_APPLICATION"; - private static final Logger LOGGER = LoggerFactory.getLogger(_ApplicationDataCollector.class); - - public String getId() { - return ID; - } - - public String getDescription() { - return "Application technical information (ex. OH version)"; - } - - public Map retrieveData() throws OHException { - LOGGER.debug("Collecting application data..."); - Map result = new HashMap<>(); - try { - Version.initialize(); - result.put(CollectorsConstants.APP_VER_MAJOR, Version.VER_MAJOR); - result.put(CollectorsConstants.APP_VER_MINOR, Version.VER_MINOR); - result.put(CollectorsConstants.APP_RELEASE, Version.VER_RELEASE); - return result; - } catch (Exception e) { - LOGGER.error("Something went wrong with " + ID); - LOGGER.error(e.toString()); - throw new OHException("Data collector [" + ID + "]", e); - } - } - -} diff --git a/src/main/java/org/isf/telemetry/envdatacollector/collectors/_DBMSDataCollector.java b/src/main/java/org/isf/telemetry/envdatacollector/collectors/_DBMSDataCollector.java deleted file mode 100644 index fbcc86f45..000000000 --- a/src/main/java/org/isf/telemetry/envdatacollector/collectors/_DBMSDataCollector.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2022 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) - * - * Open Hospital is a free and open source software for healthcare data management. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * https://www.gnu.org/licenses/gpl-3.0-standalone.html - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.isf.telemetry.envdatacollector.collectors; - -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.util.HashMap; -import java.util.Map; - -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; - -import org.hibernate.engine.spi.SessionImplementor; -import org.isf.telemetry.envdatacollector.constants.CollectorsConstants; -import org.isf.utils.exception.OHException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -@Order(value = 20) -@Component -public class _DBMSDataCollector { - - @PersistenceContext - private EntityManager em; - - private static final String ID = "TEL_DBMS"; - private static final Logger LOGGER = LoggerFactory.getLogger(_DBMSDataCollector.class); - - public String getId() { - return ID; - } - - public String getDescription() { - return "DBMS information (ex. MySQL 5.0)"; - } - - public Map retrieveData() throws OHException { - LOGGER.debug("Collecting DBMS data..."); - Map result = new HashMap<>(); - Connection con = null; - try { - SessionImplementor sessionImp = (SessionImplementor) em.getDelegate(); - DatabaseMetaData dbmd = sessionImp.connection().getMetaData(); - result.put(CollectorsConstants.DBMS_DRIVER_NAME, dbmd.getDriverName()); - result.put(CollectorsConstants.DBMS_DRIVER_VERSION, dbmd.getDriverVersion()); - result.put(CollectorsConstants.DBMS_PRODUCT_NAME, dbmd.getDatabaseProductName()); - result.put(CollectorsConstants.DBMS_PRODUCT_VERSION, dbmd.getDatabaseProductVersion()); - return result; - } catch (Exception e) { - LOGGER.error("Something went wrong with " + ID + " (1)"); - LOGGER.error(e.toString()); - throw new OHException("Data collector [" + ID + "]", e); - } - } - -} diff --git a/src/main/java/org/isf/telemetry/envdatacollector/collectors/_HardwareDataCollector.java b/src/main/java/org/isf/telemetry/envdatacollector/collectors/_HardwareDataCollector.java deleted file mode 100644 index 03ddfd0dd..000000000 --- a/src/main/java/org/isf/telemetry/envdatacollector/collectors/_HardwareDataCollector.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2022 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) - * - * Open Hospital is a free and open source software for healthcare data management. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * https://www.gnu.org/licenses/gpl-3.0-standalone.html - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.isf.telemetry.envdatacollector.collectors; - -import java.util.HashMap; -import java.util.Map; - -import org.isf.telemetry.envdatacollector.constants.CollectorsConstants; -import org.isf.utils.exception.OHException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import oshi.SystemInfo; -import oshi.hardware.CentralProcessor; -import oshi.hardware.HardwareAbstractionLayer; - -@Order(value = 30) -@Component -public class _HardwareDataCollector { - - private static final String ID = "TEL_HW"; - private static final Logger LOGGER = LoggerFactory.getLogger(_HardwareDataCollector.class); - - public String getId() { - return ID; - } - - public String getDescription() { - return "Hardware information (ex. CPU Intel)"; - } - - public Map retrieveData() throws OHException { - LOGGER.debug("Collecting Hardware data..."); - Map result = new HashMap<>(); - try { - SystemInfo si = new SystemInfo(); - HardwareAbstractionLayer hard = si.getHardware(); - CentralProcessor cpu = hard.getProcessor(); - result.put(CollectorsConstants.HW_CPU_NUM_PHYSICAL_PROCESSES, String.valueOf(cpu.getPhysicalProcessorCount())); - result.put(CollectorsConstants.HW_CPU_NUM_LOGICAL_PROCESSES, String.valueOf(cpu.getLogicalProcessorCount())); - result.put(CollectorsConstants.HW_CPU_NAME, cpu.getProcessorIdentifier().getName()); - result.put(CollectorsConstants.HW_CPU_IDENTIFIER, cpu.getProcessorIdentifier().getIdentifier()); - result.put(CollectorsConstants.HW_CPU_MODEL, cpu.getProcessorIdentifier().getModel()); - result.put(CollectorsConstants.HW_CPU_ARCHITECTURE, cpu.getProcessorIdentifier().getMicroarchitecture()); - result.put(CollectorsConstants.HW_CPU_VENDOR, cpu.getProcessorIdentifier().getVendor()); - result.put(CollectorsConstants.HW_CPU_CTX_SWITCHES, String.valueOf(cpu.getContextSwitches())); - } catch (RuntimeException e) { - LOGGER.error("Something went wrong with " + ID); - LOGGER.error(e.toString()); - throw new OHException("Data collector [" + ID + "]", e); - } - return result; - } - -} diff --git a/src/main/java/org/isf/telemetry/envdatacollector/collectors/_LocationDataCollector.java b/src/main/java/org/isf/telemetry/envdatacollector/collectors/_LocationDataCollector.java deleted file mode 100644 index 3e2518d96..000000000 --- a/src/main/java/org/isf/telemetry/envdatacollector/collectors/_LocationDataCollector.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2022 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) - * - * Open Hospital is a free and open source software for healthcare data management. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * https://www.gnu.org/licenses/gpl-3.0-standalone.html - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.isf.telemetry.envdatacollector.collectors; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.isf.telemetry.envdatacollector.collectors.remote.common.GeoIpInfoBean; -import org.isf.telemetry.envdatacollector.collectors.remote.common.GeoIpInfoCommonService; -import org.isf.telemetry.envdatacollector.collectors.remote.common.GeoIpInfoSettings; -import org.isf.telemetry.envdatacollector.constants.CollectorsConstants; -import org.isf.utils.exception.OHException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -@Order(value = 60) -@Component -public class _LocationDataCollector { - - private static final String ID = "TEL_LOCATION"; - private static final Logger LOGGER = LoggerFactory.getLogger(_LocationDataCollector.class); - - @Autowired - private GeoIpInfoSettings settings; - - @Autowired - List geoIpServices; - - public String getId() { - return ID; - } - - public String getDescription() { - return "Location information (ex. Italy)"; - } - - public Map retrieveData() throws OHException { - LOGGER.debug("Collecting location data..."); - Map result = new HashMap<>(); - try { - - String geoIpServiceName = this.settings.get("telemetry.enabled.geo.ip.lookup.service"); - LOGGER.debug("{} - {}", geoIpServiceName, geoIpServices.size()); - this.geoIpServices.forEach(service -> { - if (service.getServiceName().equals(geoIpServiceName)) { - GeoIpInfoBean json = service.retrieveIpInfo(); - LOGGER.debug(json.toString()); - result.put(CollectorsConstants.LOC_COUNTRY_NAME, json.getCountryName()); - result.put(CollectorsConstants.LOC_COUNTRY_CODE, json.getCountryCode()); - result.put(CollectorsConstants.LOC_REGION_NAME, json.getRegionName()); - result.put(CollectorsConstants.LOC_CITY, json.getCity()); - result.put(CollectorsConstants.LOC_ZIP_CODE, json.getPostalCode()); - result.put(CollectorsConstants.LOC_TIMEZONE, json.getTimeZone()); - result.put(CollectorsConstants.LOC_CURRENCY_CODE, json.getCurrencyCode()); - } - }); - } catch (RuntimeException e) { - LOGGER.error("Something went wrong with " + ID); - LOGGER.error(e.toString()); - throw new OHException("Data collector [" + ID + "]", e); - } - return result; - } - -} \ No newline at end of file diff --git a/src/main/java/org/isf/telemetry/envdatacollector/collectors/_OpenHospitalDataCollector.java b/src/main/java/org/isf/telemetry/envdatacollector/collectors/_OpenHospitalDataCollector.java deleted file mode 100644 index 7c522cc44..000000000 --- a/src/main/java/org/isf/telemetry/envdatacollector/collectors/_OpenHospitalDataCollector.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2022 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) - * - * Open Hospital is a free and open source software for healthcare data management. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * https://www.gnu.org/licenses/gpl-3.0-standalone.html - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.isf.telemetry.envdatacollector.collectors; - -import java.util.HashMap; -import java.util.Map; - -import org.isf.menu.service.MenuIoOperations; -import org.isf.patient.service.PatientIoOperations; -import org.isf.telemetry.envdatacollector.constants.CollectorsConstants; -import org.isf.utils.exception.OHException; -import org.isf.utils.exception.OHServiceException; -import org.isf.ward.service.WardIoOperations; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -@Order(value = 40) -@Component -public class _OpenHospitalDataCollector { - - private static final String ID = "TEL_OH"; - private static final Logger LOGGER = LoggerFactory.getLogger(_OpenHospitalDataCollector.class); - - @Autowired - private PatientIoOperations patientIoOperations; - - @Autowired - private MenuIoOperations menuIoOperations; - - @Autowired - private WardIoOperations wardIoOperations; - - public String getId() { - return ID; - } - - public String getDescription() { - return "Hospital information (ex. 100 beds)"; - } - - public Map retrieveData() throws OHException { - LOGGER.debug("Collecting Open Hospital data..."); - Map result = new HashMap<>(); - try { - result.put(CollectorsConstants.OH_TOTAL_ACTIVE_PATIENTS, String.valueOf(patientIoOperations.countAllActivePatients())); - result.put(CollectorsConstants.OH_TOTAL_ACTIVE_USERS, String.valueOf(this.menuIoOperations.countAllActive())); - result.put(CollectorsConstants.OH_TOTAL_ACTIVE_WARDS, String.valueOf(this.wardIoOperations.countAllActiveWards())); - result.put(CollectorsConstants.OH_TOTAL_ACTIVE_BEDS, String.valueOf(this.wardIoOperations.countAllActiveBeds())); - } catch (OHServiceException e) { - LOGGER.error("Something went wrong with " + ID); - LOGGER.error(e.toString()); - throw new OHException("Data collector [" + ID + "]", e); - } - return result; - } - -} diff --git a/src/main/java/org/isf/telemetry/envdatacollector/collectors/_OperativeSystemDataCollector.java b/src/main/java/org/isf/telemetry/envdatacollector/collectors/_OperativeSystemDataCollector.java deleted file mode 100644 index 5631884dd..000000000 --- a/src/main/java/org/isf/telemetry/envdatacollector/collectors/_OperativeSystemDataCollector.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2022 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) - * - * Open Hospital is a free and open source software for healthcare data management. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * https://www.gnu.org/licenses/gpl-3.0-standalone.html - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.isf.telemetry.envdatacollector.collectors; - -import java.util.HashMap; -import java.util.Map; - -import org.isf.telemetry.envdatacollector.constants.CollectorsConstants; -import org.isf.utils.exception.OHException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import oshi.SystemInfo; -import oshi.software.os.OperatingSystem; - -@Order(value = 30) -@Component -public class _OperativeSystemDataCollector { - - private static final String ID = "TEL_OS"; - private static final Logger LOGGER = LoggerFactory.getLogger(_OperativeSystemDataCollector.class); - - public String getId() { - return ID; - } - - public String getDescription() { - return "Operative System information (ex. Ubuntu 12.04)"; - } - - public Map retrieveData() throws OHException { - LOGGER.debug("Collecting OS data..."); - Map result = new HashMap<>(); - try { - SystemInfo si = new SystemInfo(); - OperatingSystem os = si.getOperatingSystem(); - result.put(CollectorsConstants.OS_FAMILY, os.getFamily()); - result.put(CollectorsConstants.OS_VERSION, os.getVersionInfo().getVersion()); - result.put(CollectorsConstants.OS_MANUFACTURER, os.getManufacturer()); - result.put(CollectorsConstants.OS_BITNESS, String.valueOf(os.getBitness())); - result.put(CollectorsConstants.OS_CODENAME, os.getVersionInfo().getCodeName()); - } catch (RuntimeException e) { - LOGGER.error("Something went wrong with " + ID); - LOGGER.error(e.toString()); - throw new OHException("Data collector [" + ID + "]", e); - } - return result; - } - -} diff --git a/src/main/java/org/isf/telemetry/envdatacollector/collectors/_TimeDataCollector.java b/src/main/java/org/isf/telemetry/envdatacollector/collectors/_TimeDataCollector.java deleted file mode 100644 index 0874cf3fd..000000000 --- a/src/main/java/org/isf/telemetry/envdatacollector/collectors/_TimeDataCollector.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2022 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) - * - * Open Hospital is a free and open source software for healthcare data management. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * https://www.gnu.org/licenses/gpl-3.0-standalone.html - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.isf.telemetry.envdatacollector.collectors; - -import java.time.LocalDateTime; -import java.util.HashMap; -import java.util.Map; - -import org.isf.opd.service.OpdIoOperations; -import org.isf.telemetry.envdatacollector.constants.CollectorsConstants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -@Order(value = 50) -@Component -public class _TimeDataCollector { - - private static final String ID = "TEL_TIME"; - private static final Logger LOGGER = LoggerFactory.getLogger(_TimeDataCollector.class); - - @Autowired - private OpdIoOperations opdIoOperations; - - public String getId() { - return ID; - } - - public String getDescription() { - return "Time information (ex. last used timestamp)"; - } - - public Map retrieveData() { - LOGGER.debug("Collecting Time data..."); - Map result = new HashMap<>(); - LocalDateTime lastUsedTime = this.opdIoOperations.lastOpdCreationDate(); - if (lastUsedTime == null) { - lastUsedTime = LocalDateTime.now(); - } - result.put(CollectorsConstants.TIME_LAST_USED, String.valueOf(lastUsedTime)); - return result; - } - -} diff --git a/src/main/java/org/isf/telemetry/envdatacollector/constants/CollectorsConstants.java b/src/main/java/org/isf/telemetry/envdatacollector/constants/CollectorsConstants.java index 292b33758..9971992b6 100644 --- a/src/main/java/org/isf/telemetry/envdatacollector/constants/CollectorsConstants.java +++ b/src/main/java/org/isf/telemetry/envdatacollector/constants/CollectorsConstants.java @@ -55,13 +55,50 @@ public interface CollectorsConstants { // TEL_OH String APP_VERSION = "app_version"; - String APP_VER_MAJOR = "app_ver_major"; - String APP_VER_MINOR = "app_ver_minor"; - String APP_RELEASE = "app_release"; - String OH_TOTAL_ACTIVE_PATIENTS = "oh_active_patients"; - String OH_TOTAL_ACTIVE_USERS = "oh_active_users"; - String OH_TOTAL_ACTIVE_WARDS = "oh_active_wards"; - String OH_TOTAL_ACTIVE_BEDS = "oh_active_beds"; + String APP_MODE = "app_mode"; + String APP_DEMODATA = "app_demodata"; + String APP_APISERVER = "app_apiserver"; + String APP_LANGUAGE = "app_language"; + String APP_SINGLEUSER = "app_singleuser"; + String APP_DEBUG = "app_debug"; + String APP_INTERNALVIEWER = "app_internaluser"; + String APP_SMSENABLED = "app_smsenabled"; + String APP_VIDEOMODULEENABLED = "app_videomoduleenabled"; + String APP_XMPPMODULEENABLED = "app_xmppmoduleenabled"; + String APP_ENHANCEDSEARCH = "app_enhancedsearch"; + String APP_INTERNALPHARMACIES = "app_internalpharmacies"; + String APP_LABEXTENDED = "app_labextended"; + String APP_LABMULTIPLEINSERT = "app_labmultipleinsert"; + String APP_MATERNITYRESTARTINJUNE = "app_maternityrestartinjune"; + String APP_MERGEFUNCTION = "app_mergefunction"; + String APP_OPDEXTENDED = "app_opdextended"; + String APP_PATIENTEXTENDED = "app_patientextended"; + String APP_PATIENTVACCINEEXTENDED = "app_patientvaccineextended"; + String APP_MAINMENUALWAYSONTOP = "app_mainmenualwaysontop"; + String APP_ALLOWMULTIPLEOPENEDBILL = "app_allowmultipleopenedbill"; + String APP_ALLOWPRINTOPENEDBILL = "app_allowprintopenedbill"; + String APP_RECEIPTPRINTER = "app_receiptprinter"; + String APP_AUTOMATICLOT_IN = "app_automaticlot_in"; + String APP_AUTOMATICLOT_OUT = "app_automaticlot_out"; + String APP_AUTOMATICLOTWARD_TOWARD = "app_automaticlotward_toward"; + String APP_LOTWITHCOST = "app_lotwithcost"; + String APP_DICOMMODULEENABLED = "app_dicommoduleenabled"; + String APP_DICOMTHUMBNAILS = "app_dicomthumbnails"; + String OH_NUMBER_OF_PATIENTS = "oh_patients"; + String OH_NUMBER_OF_USERS = "oh_users"; + String OH_NUMBER_OF_ROLES = "oh_roles"; + String OH_NUMBER_OF_WARDS = "oh_wards"; + String OH_NUMBER_OF_BEDS = "oh_beds"; + String OH_NUMBER_OF_OPDS = "oh_opds"; + String OH_NUMBER_OF_ADMISSIONS = "oh_admissions"; + String OH_NUMBER_OF_EXAMS = "oh_exams"; + String OH_NUMBER_OF_VACCINES = "oh_vaccines"; + String OH_NUMBER_OF_OPERATIONS = "oh_operations"; + String OH_NUMBER_OF_STOCKMOVEMENTS = "oh_stockmovements"; + String OH_NUMBER_OF_STOCKWMOVEMENTSWARDS = "oh_stockmovementswards"; + String OH_NUMBER_OF_THERAPIES = "oh_therapies"; + String OH_NUMBER_OF_APPOINTMENTS = "oh_appointments"; + String OH_NUMBER_OF_BILLS = "oh_bills"; String TIME_LAST_USED = "time_last_used"; // TEL_LOCATION diff --git a/src/main/java/org/isf/therapy/service/TherapyIoOperationRepository.java b/src/main/java/org/isf/therapy/service/TherapyIoOperationRepository.java index 7b7075bba..da0db13bf 100644 --- a/src/main/java/org/isf/therapy/service/TherapyIoOperationRepository.java +++ b/src/main/java/org/isf/therapy/service/TherapyIoOperationRepository.java @@ -27,11 +27,18 @@ import org.isf.therapy.model.TherapyRow; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; public interface TherapyIoOperationRepository extends JpaRepository { + List findAllByOrderByPatientAscTherapyIDAsc(); + List findByPatientCodeOrderByPatientCodeAscTherapyIDAsc(Integer patient); + @Modifying void deleteByPatient(@Param("patient") Patient patient); + + @Query("select count(t) from TherapyRow t where active=1") + long countAllActiveTherapies(); } \ No newline at end of file diff --git a/src/main/java/org/isf/therapy/service/TherapyIoOperations.java b/src/main/java/org/isf/therapy/service/TherapyIoOperations.java index d5bd1bc1a..eea0be554 100644 --- a/src/main/java/org/isf/therapy/service/TherapyIoOperations.java +++ b/src/main/java/org/isf/therapy/service/TherapyIoOperations.java @@ -61,7 +61,7 @@ public TherapyRow newTherapy(TherapyRow thRow) throws OHServiceException { */ public List getTherapyRows(int patID) throws OHServiceException { return patID != 0 ? repository.findByPatientCodeOrderByPatientCodeAscTherapyIDAsc(patID) - : repository.findAllByOrderByPatientAscTherapyIDAsc(); + : repository.findAllByOrderByPatientAscTherapyIDAsc(); } /** @@ -84,4 +84,15 @@ public void deleteAllTherapies(Patient patient) throws OHServiceException { public boolean isCodePresent(Integer code) throws OHServiceException { return repository.existsById(code); } + + /** + * Count active {@link TherapyRow}s + * + * @return the number of recorded {@link TherapyRow}s + * @throws OHServiceException + */ + public long countAllActiveTherapies() { + return this.repository.countAllActiveTherapies(); + } + } diff --git a/src/main/java/org/isf/vaccine/service/VaccineIoOperationRepository.java b/src/main/java/org/isf/vaccine/service/VaccineIoOperationRepository.java index 8062ac64a..0b9b41dc3 100644 --- a/src/main/java/org/isf/vaccine/service/VaccineIoOperationRepository.java +++ b/src/main/java/org/isf/vaccine/service/VaccineIoOperationRepository.java @@ -25,6 +25,7 @@ import org.isf.vaccine.model.Vaccine; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; @Repository @@ -34,4 +35,7 @@ public interface VaccineIoOperationRepository extends JpaRepository findByVaccineType_CodeOrderByDescriptionAsc(String code); + @Query("select count(v) from Vaccine v where active=1") + long countAllActiveVaccinations(); + } \ No newline at end of file diff --git a/src/main/java/org/isf/vaccine/service/VaccineIoOperations.java b/src/main/java/org/isf/vaccine/service/VaccineIoOperations.java index 63f3107cd..fc978964c 100644 --- a/src/main/java/org/isf/vaccine/service/VaccineIoOperations.java +++ b/src/main/java/org/isf/vaccine/service/VaccineIoOperations.java @@ -40,13 +40,13 @@ * 20/10/2011 - Cla - insert vaccinetype managment */ @Service -@Transactional(rollbackFor=OHServiceException.class) +@Transactional(rollbackFor = OHServiceException.class) @TranslateOHServiceException public class VaccineIoOperations { @Autowired private VaccineIoOperationRepository repository; - + /** * Returns the list of {@link Vaccine}s based on vaccine type code. * @@ -55,9 +55,7 @@ public class VaccineIoOperations { * @throws OHServiceException */ public List getVaccine(String vaccineTypeCode) throws OHServiceException { - return vaccineTypeCode != null ? - repository.findByVaccineType_CodeOrderByDescriptionAsc(vaccineTypeCode) : - repository.findAllByOrderByDescriptionAsc(); + return vaccineTypeCode != null ? repository.findByVaccineType_CodeOrderByDescriptionAsc(vaccineTypeCode) : repository.findAllByOrderByDescriptionAsc(); } /** @@ -70,7 +68,7 @@ public List getVaccine(String vaccineTypeCode) throws OHServiceExceptio public Vaccine newVaccine(Vaccine vaccine) throws OHServiceException { return repository.save(vaccine); } - + /** * Updates a {@link Vaccine} in the DB. * @@ -102,7 +100,7 @@ public void deleteVaccine(Vaccine vaccine) throws OHServiceException { public boolean isCodePresent(String code) throws OHServiceException { return repository.existsById(code); } - + /** * Returns the {@link Vaccine} based on its code. * @@ -113,4 +111,14 @@ public Vaccine findVaccine(String code) throws OHServiceException { return repository.findById(code).orElse(null); } + /** + * Count active {@link Vaccine}s + * + * @return the number of recorded {@link Vaccine}s + * @throws OHServiceException + */ + public long countAllActiveVaccinations() { + return this.repository.countAllActiveVaccinations(); + } + } diff --git a/src/main/java/org/isf/visits/service/VisitsIoOperationRepository.java b/src/main/java/org/isf/visits/service/VisitsIoOperationRepository.java index 85f215b39..a5a309988 100644 --- a/src/main/java/org/isf/visits/service/VisitsIoOperationRepository.java +++ b/src/main/java/org/isf/visits/service/VisitsIoOperationRepository.java @@ -34,15 +34,15 @@ public interface VisitsIoOperationRepository extends JpaRepository { List findAllByOrderByPatient_CodeAscDateAsc(); - + Visit findAllByVisitID(@Param("visitID") int visitID); List findAllByPatient_CodeOrderByPatient_CodeAscDateAsc(@Param("patient") Integer patient); - + List findAllByWardIsNullOrderByPatient_CodeAscDateAsc(); List findAllByWardIsNullAndPatient_CodeOrderByPatient_CodeAscDateAsc(@Param("patient") Integer patient); - + @Modifying void deleteByPatient_Code(@Param("patient") Integer patient); @@ -52,4 +52,7 @@ public interface VisitsIoOperationRepository extends JpaRepository findAllWherePatientByOrderPatientAndDateAsc(@Param("patient") Integer patient); + @Query("select count(v) from Visit v where active=1") + long countAllActiveAppointments(); + } \ No newline at end of file diff --git a/src/main/java/org/isf/visits/service/VisitsIoOperations.java b/src/main/java/org/isf/visits/service/VisitsIoOperations.java index 2a072cb60..10faefcc9 100644 --- a/src/main/java/org/isf/visits/service/VisitsIoOperations.java +++ b/src/main/java/org/isf/visits/service/VisitsIoOperations.java @@ -32,13 +32,13 @@ import org.springframework.transaction.annotation.Transactional; @Service -@Transactional(rollbackFor=OHServiceException.class) +@Transactional(rollbackFor = OHServiceException.class) @TranslateOHServiceException public class VisitsIoOperations { @Autowired private VisitsIoOperationRepository repository; - + /** * Returns the list of all {@link Visit}s related to a {@link Patient} ID. * @@ -47,11 +47,9 @@ public class VisitsIoOperations { * @throws OHServiceException */ public List getVisits(Integer patID) throws OHServiceException { - return patID != 0 ? - repository.findAllByPatient_CodeOrderByPatient_CodeAscDateAsc(patID) : - repository.findAllByOrderByPatient_CodeAscDateAsc(); + return patID != 0 ? repository.findAllByPatient_CodeOrderByPatient_CodeAscDateAsc(patID) : repository.findAllByOrderByPatient_CodeAscDateAsc(); } - + /** * Returns the list of all {@link Visit}s related to a {@link Patient} ID in OPD (Ward is {@code null}). * @@ -60,13 +58,12 @@ public List getVisits(Integer patID) throws OHServiceException { * @throws OHServiceException */ public List getVisitsOPD(Integer patID) throws OHServiceException { - return patID != 0 ? - repository.findAllByWardIsNullAndPatient_CodeOrderByPatient_CodeAscDateAsc(patID) : - repository.findAllByWardIsNullOrderByPatient_CodeAscDateAsc(); + return patID != 0 ? repository.findAllByWardIsNullAndPatient_CodeOrderByPatient_CodeAscDateAsc(patID) + : repository.findAllByWardIsNullOrderByPatient_CodeAscDateAsc(); } public Visit getVisit(int visitID) throws OHServiceException { return repository.findAllByVisitID(visitID); - + } /** @@ -86,7 +83,6 @@ public List getVisitsWard(String wardId) throws OHServiceException { return visits; } - /** * Insert a new {@link Visit}. * @@ -97,7 +93,7 @@ public List getVisitsWard(String wardId) throws OHServiceException { public Visit newVisit(Visit visit) throws OHServiceException { return repository.save(visit); } - + /** * Update a {@link Visit}. * @@ -139,4 +135,15 @@ public Visit findVisit(int id) { public void deleteVisit(Visit visit) throws OHServiceException { repository.delete(visit); } + + /** + * Count active {@link Visit}s + * + * @return the number of recorded {@link Visit}s + * @throws OHServiceException + */ + public long countAllActiveAppointments() { + return this.repository.countAllActiveAppointments(); + } + }