Skip to content

Commit

Permalink
Merge pull request #492 from udsm-dhis2-lab/hotfix/gepgerrorhandling
Browse files Browse the repository at this point in the history
merge request from GePG Fixes duplication data also invoice arrangments
  • Loading branch information
iamgaspardev authored Dec 4, 2024
2 parents d171de1 + e3c54a8 commit 2d4b805
Show file tree
Hide file tree
Showing 10 changed files with 393 additions and 130 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public List<Payment> findByPatientUuid(String patientUuid) {
return query.list();
}

public String getReferenceNumberByRequestId(String requestId) {
public String getReferenceNumberByRequestId(Integer requestId) {
DbSession session = this.getSession();
String queryStr = "SELECT p.referenceNumber FROM Payment p WHERE p.id = :requestId";
Query query = session.createQuery(queryStr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public interface BillingService extends OpenmrsService {

Map<String, Object> processGepgCallbackResponse(Map<String, Object> feedBack) throws Exception;

String fetchControlNumber(String requestId) throws Exception;
String fetchControlNumber(Integer requestId) throws Exception;

List<Payment> getAllPaymentsWithStatus() throws Exception;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package org.openmrs.module.icare.billing.services.payment.gepg;

import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonPropertyOrder({ "BillId", "SubSpCode", "SpSysId", "BillAmt", "MiscAmt", "BillExprDt", "PyrId", "PyrName", "BillDesc",
"BillGenDt", "BillGenBy", "BillApprBy", "PyrCellNum", "PyrEmail", "Ccy", "BillEqvAmt", "RemFlag", "BillPayOpt",
"BillItems" })
public class BillTrxInf {

private String BillId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class GEPGService {
private PaymentDAO paymentDAO;

@Autowired
private BillingService billingService;
private BillingService billingService;

private final Map<String, Map<String, Object>> callbackResponses = new ConcurrentHashMap<>();
private final ObjectMapper objectMapper = new ObjectMapper();
Expand All @@ -46,7 +46,7 @@ public Map<String, Object> submitGepgRequest(String jsonPayload, String signatur

// Write JSON payload
try (OutputStream os = con.getOutputStream();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"))) {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"))) {
writer.write(jsonPayload);
writer.flush();
}
Expand Down Expand Up @@ -81,15 +81,18 @@ public Map<String, Object> submitGepgRequest(String jsonPayload, String signatur

// Handle different ackCodes
if ("R3001".equals(ackCode)) {
String controlNumber = billingService.fetchControlNumber(requestId);
Integer requestpaymentId = null;
requestpaymentId = Integer.parseInt(requestId);
String controlNumber = billingService.fetchControlNumber(requestpaymentId);
// Save the payload in a global property
AdministrationService administrationService = Context.getAdministrationService();
GlobalProperty globalProperty = new GlobalProperty();
globalProperty.setProperty("gepg.controlNumberGen.icareConnect");
globalProperty.setPropertyValue(controlNumber);
administrationService.saveGlobalProperty(globalProperty);
responseMap.put("status", "success");
responseMap.put("controlNumber", controlNumber != null ? controlNumber : "Not found within timeout");
responseMap.put("controlNumber",
controlNumber != null ? controlNumber : "Not found within timeout");
responseMap.put("ackCode", ackCode);
responseMap.put("message", "Request processed successfully.");
} else if ("CONS9005".equals(ackCode)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,13 @@ public ResponseEntity<?> handleCallback(HttpServletRequest request) {
private ResponseEntity<Map<String, Object>> generateErrorResponse(String errorMessage, String requestId) {
Map<String, Object> errorResponse = new HashMap<>();
try {
// AckData as per your requested format

AdministrationService administrationService = Context.getAdministrationService();
// Retrieve GePG user credentials
String gepgUsername = administrationService.getGlobalProperty(ICareConfig.GEPG_USERNAME);
String gepgPassword = administrationService.getGlobalProperty(ICareConfig.GEPG_PASSWORD);
Context.authenticate(gepgUsername, gepgPassword);
// AckData as per your requested format
Map<String, Object> ackData = new HashMap<>();
ackData.put("Description", errorMessage);
ackData.put("RequestId", requestId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class PatientsTabularListComponent implements OnInit, OnChanges {
constructor( private visitService: VisitsService,) {}

ngOnInit(): void {
console.log("payment type passed .....",this.paymentTypeSelected)
// console.log("payment type passed .....",this.paymentTypeSelected)
this.dataSource = new MatTableDataSource(
sanitizePatientsVisitsForTabularPatientListing(
this.visits,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,7 @@ export class VisitsService {
parametersString += `&includeInactive=true`;
}
//

console.log("url fired ...",`icare/visit?${parametersString.replace("&","" )}&startIndex=${startIndex}&limit=${limit}`);
// console.log("url fired ...",`icare/visit?${parametersString.replace("&","" )}&startIndex=${startIndex}&limit=${limit}`);
return (
locationUuids?.length > 0
? zip(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
mode="indeterminate"
></mat-progress-bar>
<ng-container *ngIf="params?.currentStore && params?.storeLocations">
<mat-chip-list aria-label="Fish selection">
<mat-chip-list *ngIf="!params?.storeLocations" aria-label="Fish selection">
<mat-chip
[ngClass]="{ 'selected-store': params?.currentStore?.id === store?.id }"
(click)="onSetCurrentStore($event, store)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
mode="indeterminate"
></mat-progress-bar>
<ng-container *ngIf="params?.currentStore && params?.storeLocations">
<mat-chip-list aria-label="Fish selection">
<mat-chip-list *ngIf="!params?.storeLocations" aria-label="Fish selection">
<mat-chip
[ngClass]="{ 'selected-store': params?.currentStore?.id === store?.id }"
(click)="onSetCurrentStore($event, store)"
*ngFor="let store of params?.storeLocations"
>
{{ store?.display }}
{{ store?.display }}
</mat-chip>
</mat-chip-list>
<div class="mt-2">
Expand Down

0 comments on commit 2d4b805

Please sign in to comment.