Skip to content

Commit

Permalink
Added support to ensure field type input is taken on dose and duration
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgaspardev committed Nov 28, 2024
1 parent 4aeb25d commit 6d9213c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,8 @@ public ItemPrice saveItemPrice(ItemPrice itemPrice) throws APIException {
itemPrice.setPaymentType(paymentType);
if (itemPrice.getPayable() != null && itemPrice.getPayablePaymentMode() == null) {
throw new APIException("Payment mode for payable not provided");
} else if (itemPrice.getPayablePaymentMode() != null
&& itemPrice.getPayablePaymentMode().getUuid() != null
&& conceptService.getConceptByUuid(itemPrice.getPayablePaymentMode().getUuid()) != null) {
} else if (itemPrice.getPayablePaymentMode() != null && itemPrice.getPayablePaymentMode().getUuid() != null
&& conceptService.getConceptByUuid(itemPrice.getPayablePaymentMode().getUuid()) != null) {
Concept payablePaymentMode = conceptService.getConceptByUuid(itemPrice.getPayablePaymentMode().getUuid());
itemPrice.setPayablePaymentMode(payablePaymentMode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,14 @@ public Map<String, Object> generateControlNumber(@RequestBody List<Map<String, O
@RequestMapping(value = "/callback", method = RequestMethod.POST)
public ResponseEntity<?> handleCallback(HttpServletRequest request) {
try {
// Read the raw body from the request

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);
// Read the raw body from the request

String requestBody = new BufferedReader(new InputStreamReader(request.getInputStream())).lines().collect(
Collectors.joining("\n"));

Expand All @@ -184,9 +190,6 @@ public ResponseEntity<?> handleCallback(HttpServletRequest request) {
return generateErrorResponse("Empty content not allowed", "");
}

// Retrieve GePG user credentials
String gepgUsername = administrationService.getGlobalProperty(ICareConfig.GEPG_USERNAME);
String gepgPassword = administrationService.getGlobalProperty(ICareConfig.GEPG_PASSWORD);
Map<String, Object> status = (Map<String, Object>) callbackData.get("Status");
if (status == null) {
return generateErrorResponse("Status is missing in callback data.", "");
Expand All @@ -206,10 +209,10 @@ public ResponseEntity<?> handleCallback(HttpServletRequest request) {

try {
Context.authenticate(gepgUsername, gepgPassword);

Map<String, Object> processResponse = billingService.processGepgCallbackResponse(callbackData);
return ResponseEntity.ok(processResponse);

}
catch (ContextAuthenticationException e) {
return generateErrorResponse("Authentication failed please contact an Admin", requestId);
Expand All @@ -231,19 +234,21 @@ private ResponseEntity<Map<String, Object>> generateErrorResponse(String errorMe
Map<String, Object> errorResponse = new HashMap<>();
try {
// AckData as per your requested format
AdministrationService administrationService = Context.getAdministrationService();
Map<String, Object> ackData = new HashMap<>();
ackData.put("Description", errorMessage);
ackData.put("RequestId", requestId);
ackData.put("SystemAckCode", "0");
String systemCode = administrationService.getGlobalProperty(ICareConfig.GEPG_SYSTEM_CODE);

// Serialize RequestData to JSON for signing
String requestDataJson = new ObjectMapper().writeValueAsString(ackData);
String signature = billingService.signatureData(requestDataJson);

// SystemAuth as per your requested format
Map<String, Object> systemAuth = new HashMap<>();
systemAuth.put("SystemCode", "1001");
systemAuth.put("Signature",signature);
systemAuth.put("SystemCode", systemCode);
systemAuth.put("Signature", signature);

errorResponse.put("AckData", ackData);
errorResponse.put("SystemAuth", systemAuth);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@
[disabled]="shouldDisable || field?.disabled"
[placeholder]="field?.placeholder"
class="{{ fieldClass || 'field-input' }}"
[type]="field?.type === 'number' ? 'text' : field?.type"
[type]="
(field?.label === 'Dose' || field?.label === 'Duration')
? 'number'
: field?.type === 'number'
? 'text'
: field?.type
"
[required]="field?.required"
matInput
step="any"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export class FieldComponent implements AfterViewInit {
@Output() fileFieldUpdate: EventEmitter<any> = new EventEmitter<any>();

ngAfterViewInit() {

console.log("field?.key .....",this.field);
if (typeof this.field?.value === "object") {
this.value =
this.field?.value && (this.field?.value as any)?.length > 0
Expand Down Expand Up @@ -175,7 +177,9 @@ export class FieldComponent implements AfterViewInit {
}

onListenKeyEvent(event: KeyboardEvent, fieldtype: any): void {
console.log("test in ----",fieldtype);
if (fieldtype === "number") {

if (
event.key === "Backspace" ||
event.key === "ArrowLeft" ||
Expand Down

0 comments on commit 6d9213c

Please sign in to comment.