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

Pharmacy retail bill cancellation is not working #9975 #9980

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -56,6 +56,8 @@
import com.divudi.entity.BillComponent;
import com.divudi.entity.BillEntry;
import com.divudi.entity.BillSession;
import com.divudi.entity.Family;
import com.divudi.entity.FamilyMember;
import com.divudi.entity.Patient;
import com.divudi.entity.PatientDeposit;
import com.divudi.entity.PatientDepositHistory;
Expand Down Expand Up @@ -89,6 +91,8 @@
import com.divudi.facade.CashTransactionHistoryFacade;
import com.divudi.facade.DrawerEntryFacade;
import com.divudi.facade.DrawerFacade;
import com.divudi.facade.FamilyFacade;
import com.divudi.facade.FamilyMemberFacade;
import com.divudi.facade.PatientDepositFacade;
import com.divudi.facade.PatientDepositHistoryFacade;
import com.divudi.facade.PatientEncounterFacade;
Expand Down Expand Up @@ -169,6 +173,10 @@ public class DataAdministrationController implements Serializable {
@EJB
PatientFacade patientFacade;
@EJB
FamilyMemberFacade familyMemberFacade;
@EJB
FamilyFacade familyFacade;
@EJB
PatientDepositFacade patientDepositFacade;
@EJB
PatientEncounterFacade patientEncounterFacade;
Expand Down Expand Up @@ -490,6 +498,61 @@ public void retireAllBillRelatedData() {
System.out.println(progressMessage);
}

public void retireAllMembershipData() {
progress = 0;
progressMessage = "Starting retirement process...";
System.out.println(progressMessage);
String jpql = "Select f from Family f where f.retired=:ret";
Map params = new HashMap();
params.put("ret", false);
List<Family> families;

Date retiredAt = new Date(); // Common timestamp for all retire operations
WebUser retirer = sessionController.getLoggedUser(); // The user performing the operation
String uuid = CommonFunctions.generateUuid();

families = familyFacade.findByJpql(jpql, params);
for (Family f : families) {
f.setRetired(true);
f.setRetirer(retirer);
f.setRetiredAt(retiredAt);
f.setRetireComments(uuid);
familyFacade.edit(f);
}

jpql = "Select p from Patient p where p.retired=:ret and p.person.membershipScheme is not null";
params = new HashMap();
params.put("ret", false);
List<Patient> patients = patientFacade.findByJpql(jpql, params);
for (Patient f : patients) {
f.setRetired(true);
f.setRetirer(retirer);
f.setRetiredAt(retiredAt);
f.setRetireComments(uuid);
if (f.getPerson() != null) {
f.getPerson().setRetired(true);
f.getPerson().setRetirer(retirer);
f.getPerson().setRetiredAt(retiredAt);
f.getPerson().setRetireComments(uuid);
}
patientFacade.edit(f);
}

List<FamilyMember> familyMembers;
jpql = "Select fm from FamilyMember fm where fm.retired=:ret";
params = new HashMap();
params.put("ret", false);
familyMembers = patientFacade.findByJpql(jpql, params);
for (FamilyMember f : familyMembers) {
f.setRetired(true);
f.setRetirer(retirer);
f.setRetiredAt(retiredAt);
f.setRetireComments(uuid);
familyMemberFacade.edit(f);
}

}

public void retireAllPatientInvestigationRelatedData() {
progress = 0;
progressMessage = "Starting retirement process...";
Expand Down Expand Up @@ -565,7 +628,7 @@ private <T> int retireEntities(List<T> entities, Date retiredAt, WebUser retirer
retirable.setRetirer(retirer);
retirable.setRetireComments(uuid);
facade.edit(entity); // Use the specific facade passed as a parameter
}else{
} else {
System.out.println("Entity that does not implement retirable");
System.out.println("entity = " + entity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1449,13 +1449,11 @@ public void setBillItem(BillItem billItem) {
// }
@Override
public PaymentMethod getPaymentMethod() {
System.out.println("get paymentMethod = " + paymentMethod);
return paymentMethod;
}

@Override
public void setPaymentMethod(PaymentMethod paymentMethod) {
System.out.println("setPaymentMethod = " + paymentMethod);
this.paymentMethod = paymentMethod;
}

Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/divudi/entity/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public class Person implements Serializable, RetirableEntity {
private Item religion;

@ManyToOne
@Deprecated
private MembershipScheme membershipScheme;

@Transient
Expand Down
Loading