@kenyaemr/esm-billing-app 5.4.2-pre.2159 → 5.4.2-pre.2167

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/routes.json CHANGED
@@ -1 +1 @@
1
- {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"kenyaemr":"^19.0.0"},"pages":[{"component":"billableServicesHome","route":"billable-services"},{"component":"requirePaymentModal","routeRegex":"^patient/.+/chart","online":true,"offline":false}],"extensions":[{"component":"billingDashboardLink","name":"billing-dashboard-link","slot":"homepage-dashboard-slot","meta":{"slot":"billing-dashboard-slot"}},{"component":"benefitsPackageDashboardLink","name":"benefits-package-dashboard-link","slot":"patient-chart-dashboard-slot","meta":{"name":"benefits-package","slot":"patient-chart-benefits-dashboard-slot","path":"insurance-benefits","columns":1,"columnSpan":1},"featureFlag":"healthInformationExchange"},{"component":"benefitsPackage","name":"benefits-package","slot":"patient-chart-benefits-dashboard-slot"},{"component":"root","name":"billing-dashboard-root","slot":"billing-dashboard-slot"},{"component":"benefitsEligibilyRequestForm","name":"benefits-eligibility-request-form"},{"component":"benefitsPreAuthForm","name":"benefits-pre-auth-form"},{"name":"billing-patient-summary","component":"billingPatientSummary","slot":"patient-chart-billing-dashboard-slot","order":10,"meta":{"columnSpan":4}},{"name":"billing-summary-dashboard-link","component":"billingSummaryDashboardLink","slot":"patient-chart-dashboard-slot","order":11,"meta":{"columns":1,"columnSpan":1,"slot":"patient-chart-billing-dashboard-slot","path":"Billing","layoutMode":"anchored"}},{"name":"billing-check-in-form","slot":"extra-visit-attribute-slot","component":"billingCheckInForm"},{"name":"require-billing-modal","component":"requirePaymentModal"},{"name":"patient-banner-billing-tags","component":"visitAttributeTags","slot":"patient-banner-tags-slot","order":2},{"name":"initiate-payment-modal","component":"initiatePaymentDialog"},{"name":"delete-billableservice-modal","component":"deleteBillableServiceModal"},{"name":"refund-bill-modal","component":"refundBillModal"},{"name":"delete-bill-modal","component":"deleteBillModal"},{"name":"lab-order-billable-item","component":"labOrder","slot":"top-of-lab-order-form-slot"},{"name":"procedure-order-billable-item","component":"procedureOrder","slot":"top-of-procedure-order-form-slot"},{"name":"imaging-order-billable-item","component":"imagingOrder","slot":"top-of-imaging-order-form-slot"},{"name":"price-info-order","component":"priceInfoOrder"},{"name":"drug-order-billable-item","component":"drugOrder","slot":"medication-info-slot"},{"name":"order-action-button","component":"orderActionButton","slots":["prescription-action-button-slot","imaging-orders-action","procedure-orders-action","tests-ordered-actions-slot"],"order":0},{"component":"billingOverviewLink","name":"billing-overview-link","order":0,"slot":"billing-dashboard-group-nav-slot"},{"component":"billDepositDashboardLink","name":"bill-deposit-dashboard-link","slot":"billing-dashboard-group-nav-slot"},{"component":"paymentHistoryLink","name":"payment-history-link","slot":"billing-dashboard-group-nav-slot"},{"component":"paymentPointsLink","name":"payment-points-link","slot":"billing-dashboard-group-nav-slot"},{"component":"paymentModesLink","name":"payment-modes-link","slot":"billing-dashboard-group-nav-slot"},{"component":"billManagerLink","name":"bill-manager-link","slot":"billing-dashboard-group-nav-slot"},{"component":"chargeableItemsLink","name":"chargeable-items-link","slot":"billing-dashboard-group-nav-slot"},{"component":"billableExemptionsLink","name":"billable-exemptions-link","slot":"billing-dashboard-group-nav-slot"},{"component":"claimsManagementOverviewDashboardLink","name":"claims-management-overview-link","order":0,"slot":"claims-management-dashboard-link-slot"},{"component":"preAuthRequestsDashboardLink","name":"preauthrequest-overview-link","slot":"claims-management-dashboard-link-slot"},{"component":"claimsOverview","name":"claims-overview-dashboard-link","slot":"claims-management-overview-slot"},{"component":"waiveBillActionButton","name":"waive-bill-action-button","slot":"bill-actions-slot"},{"component":"deleteBillActionButton","name":"delete-bill-action-button","slot":"bill-actions-slot"},{"component":"refundLineItem","name":"refund-line-item","slot":"bill-actions-overflow-menu-slot"},{"name":"edit-line-item","component":"editLineItem","slot":"bill-actions-overflow-menu-slot"},{"name":"cancel-line-item","component":"cancelLineItem","slot":"bill-actions-overflow-menu-slot"}],"workspaces":[{"name":"create-bill-workspace","component":"createBillWorkspace","title":"Create Bill Workspace","type":"other-form"},{"name":"waive-bill-form","component":"waiveBillForm","title":"Waive Bill Form","type":"other-form"},{"name":"edit-bill-form","component":"editBillForm","title":"Edit Bill Form","type":"other-form"},{"name":"billable-service-form","component":"addServiceForm","title":"Create Charge Item Form","type":"other-form"},{"name":"commodity-form","component":"addCommodityForm","title":"Create Charge Item Form","type":"other-form"},{"name":"billing-form","component":"billingForm","title":"Billing Form","type":"other-form","width":"extra-wide"},{"name":"payment-mode-workspace","component":"paymentModeWorkspace","title":"Payment Mode Workspace","type":"other-form"},{"name":"cancel-bill-workspace","component":"cancelBillWorkspace","title":"Cancel Bill Workspace","type":"other-form"},{"name":"add-deposit-workspace","component":"addDepositWorkspace","title":"Add Deposit","type":"other-form"},{"name":"deposit-transaction-workspace","component":"depositTransactionWorkspace","title":"Deposit Transaction","type":"other-form"}],"modals":[{"name":"create-payment-point","component":"createPaymentPoint"},{"name":"clock-out-modal","component":"clockOut"},{"name":"bulk-import-billable-services-modal","component":"bulkImportBillableServicesModal"},{"name":"delete-payment-mode-modal","component":"deletePaymentModeModal"},{"name":"manage-claim-request-modal","component":"manageClaimRequestModal"},{"name":"paid-bill-receipt-print-preview-modal","component":"paidBillReceiptPrintPreviewModal"},{"name":"clock-in-modal","component":"clockIn"},{"name":"create-bill-item-modal","component":"createBillItemModal"},{"name":"delete-deposit-modal","component":"deleteDepositModal"},{"name":"reverse-transaction-modal","component":"reverseTransactionModal"}],"version":"5.4.2-pre.2159"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"kenyaemr":"^19.0.0"},"pages":[{"component":"billableServicesHome","route":"billable-services"},{"component":"requirePaymentModal","routeRegex":"^patient/.+/chart","online":true,"offline":false}],"extensions":[{"component":"billingDashboardLink","name":"billing-dashboard-link","slot":"homepage-dashboard-slot","meta":{"slot":"billing-dashboard-slot"}},{"component":"benefitsPackageDashboardLink","name":"benefits-package-dashboard-link","slot":"patient-chart-dashboard-slot","meta":{"name":"benefits-package","slot":"patient-chart-benefits-dashboard-slot","path":"insurance-benefits","columns":1,"columnSpan":1},"featureFlag":"healthInformationExchange"},{"component":"benefitsPackage","name":"benefits-package","slot":"patient-chart-benefits-dashboard-slot"},{"component":"root","name":"billing-dashboard-root","slot":"billing-dashboard-slot"},{"component":"benefitsEligibilyRequestForm","name":"benefits-eligibility-request-form"},{"component":"benefitsPreAuthForm","name":"benefits-pre-auth-form"},{"name":"billing-patient-summary","component":"billingPatientSummary","slot":"patient-chart-billing-dashboard-slot","order":10,"meta":{"columnSpan":4}},{"name":"billing-summary-dashboard-link","component":"billingSummaryDashboardLink","slot":"patient-chart-dashboard-slot","order":11,"meta":{"columns":1,"columnSpan":1,"slot":"patient-chart-billing-dashboard-slot","path":"Billing","layoutMode":"anchored"}},{"name":"billing-check-in-form","slot":"extra-visit-attribute-slot","component":"billingCheckInForm"},{"name":"require-billing-modal","component":"requirePaymentModal"},{"name":"patient-banner-billing-tags","component":"visitAttributeTags","slot":"patient-banner-tags-slot","order":2},{"name":"initiate-payment-modal","component":"initiatePaymentDialog"},{"name":"delete-billableservice-modal","component":"deleteBillableServiceModal"},{"name":"refund-bill-modal","component":"refundBillModal"},{"name":"delete-bill-modal","component":"deleteBillModal"},{"name":"lab-order-billable-item","component":"labOrder","slot":"top-of-lab-order-form-slot"},{"name":"procedure-order-billable-item","component":"procedureOrder","slot":"top-of-procedure-order-form-slot"},{"name":"imaging-order-billable-item","component":"imagingOrder","slot":"top-of-imaging-order-form-slot"},{"name":"price-info-order","component":"priceInfoOrder"},{"name":"drug-order-billable-item","component":"drugOrder","slot":"medication-info-slot"},{"name":"order-action-button","component":"orderActionButton","slots":["prescription-action-button-slot","imaging-orders-action","procedure-orders-action","tests-ordered-actions-slot"],"order":0},{"component":"billingOverviewLink","name":"billing-overview-link","order":0,"slot":"billing-dashboard-group-nav-slot"},{"component":"billDepositDashboardLink","name":"bill-deposit-dashboard-link","slot":"billing-dashboard-group-nav-slot"},{"component":"paymentHistoryLink","name":"payment-history-link","slot":"billing-dashboard-group-nav-slot"},{"component":"paymentPointsLink","name":"payment-points-link","slot":"billing-dashboard-group-nav-slot"},{"component":"paymentModesLink","name":"payment-modes-link","slot":"billing-dashboard-group-nav-slot"},{"component":"billManagerLink","name":"bill-manager-link","slot":"billing-dashboard-group-nav-slot"},{"component":"chargeableItemsLink","name":"chargeable-items-link","slot":"billing-dashboard-group-nav-slot"},{"component":"billableExemptionsLink","name":"billable-exemptions-link","slot":"billing-dashboard-group-nav-slot"},{"component":"claimsManagementOverviewDashboardLink","name":"claims-management-overview-link","order":0,"slot":"claims-management-dashboard-link-slot"},{"component":"preAuthRequestsDashboardLink","name":"preauthrequest-overview-link","slot":"claims-management-dashboard-link-slot"},{"component":"claimsOverview","name":"claims-overview-dashboard-link","slot":"claims-management-overview-slot"},{"component":"waiveBillActionButton","name":"waive-bill-action-button","slot":"bill-actions-slot"},{"component":"deleteBillActionButton","name":"delete-bill-action-button","slot":"bill-actions-slot"},{"component":"refundLineItem","name":"refund-line-item","slot":"bill-actions-overflow-menu-slot"},{"name":"edit-line-item","component":"editLineItem","slot":"bill-actions-overflow-menu-slot"},{"name":"cancel-line-item","component":"cancelLineItem","slot":"bill-actions-overflow-menu-slot"}],"workspaces":[{"name":"create-bill-workspace","component":"createBillWorkspace","title":"Create Bill Workspace","type":"other-form"},{"name":"waive-bill-form","component":"waiveBillForm","title":"Waive Bill Form","type":"other-form"},{"name":"edit-bill-form","component":"editBillForm","title":"Edit Bill Form","type":"other-form"},{"name":"billable-service-form","component":"addServiceForm","title":"Create Charge Item Form","type":"other-form"},{"name":"commodity-form","component":"addCommodityForm","title":"Create Charge Item Form","type":"other-form"},{"name":"billing-form","component":"billingForm","title":"Billing Form","type":"other-form","width":"extra-wide"},{"name":"payment-mode-workspace","component":"paymentModeWorkspace","title":"Payment Mode Workspace","type":"other-form"},{"name":"cancel-bill-workspace","component":"cancelBillWorkspace","title":"Cancel Bill Workspace","type":"other-form"},{"name":"add-deposit-workspace","component":"addDepositWorkspace","title":"Add Deposit","type":"other-form"},{"name":"deposit-transaction-workspace","component":"depositTransactionWorkspace","title":"Deposit Transaction","type":"other-form"}],"modals":[{"name":"create-payment-point","component":"createPaymentPoint"},{"name":"clock-out-modal","component":"clockOut"},{"name":"bulk-import-billable-services-modal","component":"bulkImportBillableServicesModal"},{"name":"delete-payment-mode-modal","component":"deletePaymentModeModal"},{"name":"manage-claim-request-modal","component":"manageClaimRequestModal"},{"name":"paid-bill-receipt-print-preview-modal","component":"paidBillReceiptPrintPreviewModal"},{"name":"clock-in-modal","component":"clockIn"},{"name":"create-bill-item-modal","component":"createBillItemModal"},{"name":"delete-deposit-modal","component":"deleteDepositModal"},{"name":"reverse-transaction-modal","component":"reverseTransactionModal"}],"version":"5.4.2-pre.2167"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kenyaemr/esm-billing-app",
3
- "version": "5.4.2-pre.2159",
3
+ "version": "5.4.2-pre.2167",
4
4
  "description": "Billing app for KenyaEMR",
5
5
  "browser": "dist/kenyaemr-esm-billing-app.js",
6
6
  "main": "src/index.ts",
@@ -1,18 +1,63 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { Edit } from '@carbon/react/icons';
3
- import { launchWorkspace } from '@openmrs/esm-framework';
3
+ import { launchWorkspace, navigateAndLaunchWorkspace } from '@openmrs/esm-framework';
4
4
  import { BaseOrderButton } from './base-order-button.component';
5
5
  import { useMedicationOrderAction, useOrderByUuid } from '../hooks/useMedicationOrderAction';
6
6
  import { launchPrescriptionEditWorkspace } from '../hooks/useModalHandler';
7
7
  import { useTranslation } from 'react-i18next';
8
+ import { useVisitOrOfflineVisit } from '@openmrs/esm-patient-common-lib/src';
9
+ import { Button } from '@carbon/react';
10
+
8
11
  export interface MedicationOrderButtonProps {
9
12
  medicationRequestBundle?: {
10
13
  request: fhir.MedicationRequest;
14
+ dispenses: Array<fhir.MedicationDispense>;
11
15
  };
12
16
  actionText?: string;
13
17
  closeable?: boolean;
14
18
  }
15
19
 
20
+ interface ModifyButtonProps {
21
+ currentVisit: boolean;
22
+ isLoading: boolean;
23
+ order: any;
24
+ patientUuid: string;
25
+ }
26
+
27
+ const ModifyButton: React.FC<ModifyButtonProps> = ({ currentVisit, isLoading, order, patientUuid }) => {
28
+ const { t } = useTranslation();
29
+
30
+ if (currentVisit) {
31
+ return (
32
+ <BaseOrderButton
33
+ size="lg"
34
+ kind="tertiary"
35
+ Icon={Edit}
36
+ isLoading={isLoading}
37
+ isDisabled={false}
38
+ buttonText={t('modify', 'Modify')}
39
+ onClick={() => launchPrescriptionEditWorkspace(order, patientUuid)}
40
+ />
41
+ );
42
+ }
43
+
44
+ return (
45
+ <Button
46
+ kind="danger--tertiary"
47
+ size="lg"
48
+ onClick={() =>
49
+ navigateAndLaunchWorkspace({
50
+ targetUrl: `\${openmrsSpaBase}/patient/${patientUuid}/chart`,
51
+ contextKey: `patient/${patientUuid}`,
52
+ workspaceName: 'start-visit-workspace-form',
53
+ additionalProps: { patientUuid },
54
+ })
55
+ }>
56
+ {t('activeVisitRequired', 'Start visit to modify')}
57
+ </Button>
58
+ );
59
+ };
60
+
16
61
  export const MedicationOrderButton: React.FC<MedicationOrderButtonProps> = ({
17
62
  medicationRequestBundle,
18
63
  actionText,
@@ -30,8 +75,9 @@ export const MedicationOrderButton: React.FC<MedicationOrderButtonProps> = ({
30
75
  } = useMedicationOrderAction(medicationRequestBundle);
31
76
  const { data: order, isLoading: isOrderLoading } = useOrderByUuid(medicationRequestBundle?.request?.id);
32
77
  const isLoading = isMedicationOrderLoading && isOrderLoading;
33
-
78
+ const { currentVisit } = useVisitOrOfflineVisit(patientUuid);
34
79
  const buttonText = actionText ?? defaultButtonText;
80
+
35
81
  const launchModal = useCallback(() => {
36
82
  if (shouldShowBillModal) {
37
83
  launchWorkspace('create-bill-workspace', {
@@ -45,7 +91,7 @@ export const MedicationOrderButton: React.FC<MedicationOrderButtonProps> = ({
45
91
  if (dispenseFormProps) {
46
92
  launchWorkspace('dispense-workspace', dispenseFormProps);
47
93
  }
48
- }, [shouldShowBillModal, medicationRequestBundle, dispenseFormProps, patientUuid, order]);
94
+ }, [shouldShowBillModal, medicationRequestBundle, dispenseFormProps, order]);
49
95
 
50
96
  if (!closeable) {
51
97
  return null;
@@ -54,15 +100,7 @@ export const MedicationOrderButton: React.FC<MedicationOrderButtonProps> = ({
54
100
  return (
55
101
  <div>
56
102
  {shouldAllowModify && (
57
- <BaseOrderButton
58
- size="lg"
59
- kind="tertiary"
60
- Icon={Edit}
61
- isLoading={isLoading}
62
- isDisabled={false}
63
- buttonText={t('modify', 'Modify')}
64
- onClick={() => launchPrescriptionEditWorkspace(order, patientUuid)}
65
- />
103
+ <ModifyButton currentVisit={!!currentVisit} isLoading={isLoading} order={order} patientUuid={patientUuid} />
66
104
  )}
67
105
  <BaseOrderButton
68
106
  size="lg"
@@ -7,6 +7,7 @@ import { createMedicationDispenseProps } from '../../test-order/dispense.resourc
7
7
 
8
8
  interface MedicationRequest {
9
9
  request: fhir.MedicationRequest;
10
+ dispenses: Array<fhir.MedicationDispense>;
10
11
  }
11
12
 
12
13
  export function useMedicationOrderAction(medicationRequestBundle?: MedicationRequest) {
@@ -35,14 +36,31 @@ export function useMedicationOrderAction(medicationRequestBundle?: MedicationReq
35
36
  const shouldShowBillModal =
36
37
  stockItemQuantity > 0 && itemHasBill.length < 1 && billableItem.length > 0 && !billableItemServiceStatus;
37
38
  const isDisabled = hasPendingPayment || (stockItemQuantity < 1 && !!drugUuid);
39
+ const isANonBillableItem = billableItem.length === 0;
40
+ const hasBeenDispensed = medicationRequestBundle?.dispenses?.length > 0;
41
+
42
+ /**
43
+ * Determines if modification of the medication order is allowed based on several conditions:
44
+ * 1. No pending payments exist
45
+ * 2. Stock item is available (quantity > 0)
46
+ * 3. Item hasn't been billed yet (no existing bills)
47
+ * 4. Item exists in billable items list
48
+ * 5. Special case: Non-billable items that haven't been dispensed can be modified
49
+ */
50
+ const shouldAllowModify = (() => {
51
+ // Special case: Non-billable items that haven't been dispensed can always be modified
52
+ if (!hasBeenDispensed && isANonBillableItem) {
53
+ return true;
54
+ }
55
+
56
+ // For all other cases, check the standard conditions
57
+ const hasNoPendingPayments = !hasPendingPayment;
58
+ const hasAvailableStock = stockItemQuantity > 0;
59
+ const hasNoExistingBills = itemHasBill.length < 1;
60
+ const isBillableItem = billableItem.length > 0;
38
61
 
39
- // Modification is allowed only when:
40
- // 1. There are no pending payments
41
- // 2. Stock item is available (quantity > 0)
42
- // 3. Item hasn't been billed yet (no existing bills)
43
- // 4. Item exists in billable items list
44
- const shouldAllowModify =
45
- !hasPendingPayment && stockItemQuantity > 0 && itemHasBill.length < 1 && billableItem.length > 0;
62
+ return hasNoPendingPayments && hasAvailableStock && hasNoExistingBills && isBillableItem;
63
+ })();
46
64
 
47
65
  const getButtonText = () => {
48
66
  if (hasPendingPayment) {
@@ -2,6 +2,7 @@
2
2
  "action": "Action",
3
3
  "actions": "Actions",
4
4
  "active": "Active",
5
+ "activeVisitRequired": "Start visit to modify",
5
6
  "addBill": "Add bill item(s)",
6
7
  "addCommodityChargeItem": "Add charge item",
7
8
  "addDeposit": "Add deposit",
@@ -274,8 +275,8 @@
274
275
  "serviceConcept": "Service Concept",
275
276
  "serviceType": "Service Type",
276
277
  "shaBenefits": "SHA benefits",
277
- "shaFacilityRegistrationRequired": "Facility registration number Required",
278
- "shaFacilityRegistrationRequiredDescription": "Facility registration number is required to process claims. Please update facility registration number details.",
278
+ "shaFacilityLicenseNumbernRequiredDescription": "Facility license number is required to process claims. Please update facility license number details.",
279
+ "shaFacilityLicenseNumberRequired": "Facility license number Required",
279
280
  "shaNo": "SHA NUMBER: ",
280
281
  "SHIF": "Social Health Insurance Fund",
281
282
  "shortName": "Short Name",