Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

9756 allergy warining for patient #10181

Merged
merged 20 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7c63729
fact: add method to find allergy medicines and check with bill item
ChinthakaPrasad Jan 21, 2025
6cfc6bb
check allergy when settle the bill function is done.
ChinthakaPrasad Jan 21, 2025
481cdbd
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Jan 21, 2025
c6b733d
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Jan 21, 2025
82e4cee
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Jan 21, 2025
efcc904
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Jan 21, 2025
47901e7
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Jan 21, 2025
5b4efe0
add application option for check allergy of patient
ChinthakaPrasad Jan 21, 2025
d46f124
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Jan 21, 2025
eb85a19
Merge branch 'development' of https://github.com/hmislk/hmis.git into…
ChinthakaPrasad Jan 22, 2025
a209232
create pharmacy service class and tranfer allergy warning feature to it.
ChinthakaPrasad Jan 22, 2025
ed96a1e
Merge branch 'development' of https://github.com/hmislk/hmis.git into…
ChinthakaPrasad Jan 22, 2025
69d64af
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Jan 22, 2025
d3511ff
Merge branch 'development' of https://github.com/hmislk/hmis.git into…
ChinthakaPrasad Jan 22, 2025
6fe7537
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Jan 22, 2025
60d9b9d
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Jan 22, 2025
b56b05a
allergy warning feature changes are done.
ChinthakaPrasad Jan 23, 2025
a8e2012
Merge branch 'development' of https://github.com/hmislk/hmis.git into…
ChinthakaPrasad Jan 23, 2025
d78132b
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Jan 23, 2025
5b89cf0
Signed-off-by: Chinthaka Prasad Wijerathna <118891516+ChinthakaPrasad…
ChinthakaPrasad Jan 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2031,7 +2031,6 @@ public void quickSearchPatientLongPhoneNumber(ControllerWithPatient controller)
return;
} else if (quickSearchPatientList.size() == 1) {
patientSearched = quickSearchPatientList.get(0);

controller.setPatient(patientSearched);
controller.setPatientDetailsEditable(false);
// controller.setPaymentMethod(null);
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/com/divudi/bean/pharmacy/PharmacySaleController.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import com.divudi.ejb.BillNumberGenerator;
import com.divudi.ejb.CashTransactionBean;
import com.divudi.ejb.PharmacyBean;
import com.divudi.ejb.PharmacyService;
import com.divudi.service.StaffService;
import com.divudi.entity.Bill;
import com.divudi.entity.BillFee;
Expand Down Expand Up @@ -1180,6 +1181,19 @@ public double addBillItemSingleItem() {
JsfUtil.addErrorMessage("Sorry Already Other User Try to Billing This Stock You Cant Add");
return addedQty;
}
if (configOptionApplicationController.getBooleanValueByKey("Check patient allergy medicines according to EMR data")) {
if (patient != null && getBillItem() != null) {

boolean allergyStatus = pharmacyService.checkAllergyForPatient(patient, billItem);
//boolean allergyStatus = checkAllergyForPatient(patient, billItem);

if (allergyStatus) {
JsfUtil.addErrorMessage(getBillItem().getPharmaceuticalBillItem().getItemBatch().getItem().getName() + " is allergy to this patient according to EMR data.");
return addedQty;
}
}
}

addedQty = qty;
billItem.getPharmaceuticalBillItem().setQtyInUnit((double) (0 - qty));
billItem.getPharmaceuticalBillItem().setStock(stock);
Expand Down Expand Up @@ -1248,6 +1262,17 @@ public void addBillItemMultipleBatches() {
return;
}

if (configOptionApplicationController.getBooleanValueByKey("Check patient allergy medicines according to EMR data.")) {
if (patient != null && getBillItem() != null) {
boolean allergy = pharmacyService.checkAllergyForPatient(patient, billItem);

if (allergy) {
JsfUtil.addErrorMessage(getBillItem().getPharmaceuticalBillItem().getItemBatch().getItem().getName() + " is allergy to this patient according to EMR data.");
return;
}
}
}

double requestedQty = getQty();
double addedQty = 0.0;
double remainingQty = getQty();
Expand Down Expand Up @@ -2066,6 +2091,9 @@ public List<Payment> createMultiplePayments(Bill bill, PaymentMethod pm) {
return ps;
}

@EJB
private PharmacyService pharmacyService;

public void settleBillWithPay() {
editingQty = null;

Expand Down Expand Up @@ -2100,6 +2128,14 @@ public void settleBillWithPay() {
return;
}
}

if (configOptionApplicationController.getBooleanValueByKey("Check patient allergy medicines according to EMR data")) {
if (!pharmacyService.checkAllergyForPatient(patient, getPreBill().getBillItems()).isEmpty()) {
JsfUtil.addErrorMessage(pharmacyService.checkAllergyForPatient(patient, getPreBill().getBillItems()));
return;
}
}

if (!getPreBill().getBillItems().isEmpty()) {
for (BillItem bi : getPreBill().getBillItems()) {
if (!userStockController.isStockAvailable(bi.getPharmaceuticalBillItem().getStock(), bi.getQty(), getSessionController().getLoggedUser())) {
Expand Down
103 changes: 103 additions & 0 deletions src/main/java/com/divudi/ejb/PharmacyService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package com.divudi.ejb;

import com.divudi.data.clinical.ClinicalFindingValueType;
import com.divudi.entity.BillItem;
import com.divudi.entity.Item;
import com.divudi.entity.Patient;
import com.divudi.entity.clinical.ClinicalFindingValue;
import com.divudi.facade.ClinicalFindingValueFacade;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ejb.EJB;
import javax.ejb.Stateless;

/**
*
* @author Chinthaka Prasad
*/
@Stateless
public class PharmacyService {

@EJB
private ClinicalFindingValueFacade clinicalFindingValueFacade;

public List<ClinicalFindingValue> getAllergyListForPatient(Patient patient) {

List<ClinicalFindingValue> allergyListOfPatient = new ArrayList<>();

if (patient == null) {
return allergyListOfPatient;
}
String jpql = "Select clinicalValue from ClinicalFindingValue clinicalValue "
+ " where clinicalValue.patient = :patient "
+ " and clinicalValue.clinicalFindingValueType = :type "
+ " and clinicalValue.retired = :retireStatus";

Map paramsForAllergySearch = new HashMap();
paramsForAllergySearch.put("patient", patient);
paramsForAllergySearch.put("type", ClinicalFindingValueType.PatientAllergy);
paramsForAllergySearch.put("retireStatus", false);

allergyListOfPatient = clinicalFindingValueFacade.findByJpql(jpql, paramsForAllergySearch);
return allergyListOfPatient;

}

public boolean checkAllergyForPatient(Patient patient, BillItem billItem) {

List<ClinicalFindingValue> allergyListOfPatient = getAllergyListForPatient(patient);

if (allergyListOfPatient == null || allergyListOfPatient.isEmpty()) {
return false;
}

for (ClinicalFindingValue c : allergyListOfPatient) {
if (c.getItemValue() != null) {
if (billItem.getPharmaceuticalBillItem().getItemBatch() != null) {
if (c.getItemValue().equals(billItem.getPharmaceuticalBillItem().getItemBatch().getItem())) {
return true;
}
}
if (billItem.getPharmaceuticalBillItem().getItemBatch().getItem() != null) {
if (c.getItemValue().equals(billItem.getPharmaceuticalBillItem().getItemBatch().getItem().getVmp())) {
return true;
}
}

if (billItem.getPharmaceuticalBillItem().getItemBatch().getItem().getVmp() != null) {
if (c.getItemValue().equals(billItem.getPharmaceuticalBillItem().getItemBatch().getItem().getVmp().getVtm())) {
return true;
}
}
}

}
return false;
}

public String checkAllergyForPatient(Patient patient, List<BillItem> items) {

boolean hasAllergicMedicines = false;
Item allergicItem;
String allergyMsg = "";

for (BillItem billItem : items) {
boolean thisItemIsAllergy = checkAllergyForPatient(patient, billItem);

if (thisItemIsAllergy) {
allergicItem = billItem.getItem();
hasAllergicMedicines = true;
allergyMsg = "This patient has allergy of " + allergicItem.getName() + " according to EMR data";
}
}

if (hasAllergicMedicines) {
return allergyMsg;
}

return "";
}

}
36 changes: 15 additions & 21 deletions src/main/resources/META-INF/persistence.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
<persistence-unit name="hmisPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>${JDBC_DATASOURCE}</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.logging.level.sql" value="SEVERE"/>
<property name="eclipselink.logging.parameters" value="true"/>
<property name="eclipselink.ddl-generation" value="create-or-extend-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="both"/>
<property name="eclipselink.ddl-generation.validation" value="true"/>
</properties>
</persistence-unit>
<persistence-unit name="hmisAuditPU" transaction-type="JTA">
<jta-data-source>${JDBC_AUDIT_DATASOURCE}</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.logging.level.sql" value="SEVERE"/>
<property name="eclipselink.logging.parameters" value="false"/>
<property name="javax.persistence.schema-generation.database.action" value="create-or-extend-tables"/>
</properties>
</persistence-unit>
<persistence-unit name="hmisPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>${JDBC_DATASOURCE}</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.logging.level.sql" value="SEVERE"/>
</properties>
</persistence-unit>
<persistence-unit name="hmisAuditPU" transaction-type="JTA">
<jta-data-source>${JDBC_AUDIT_DATASOURCE}</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.logging.level.sql" value="SEVERE"/>
</properties>
</persistence-unit>
</persistence>