Skip to content

Commit

Permalink
Add hardcoded uuids to config schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ODORA0 committed Apr 23, 2024
1 parent 0d3be67 commit d22a30a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/billable-services/billable-service.resource.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import useSWR from 'swr';
import { type OpenmrsResource, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
import { type OpenmrsResource, openmrsFetch, restBaseUrl, useConfig } from '@openmrs/esm-framework';
import { type ServiceConcept } from '../types';
import { apiBasePath } from '../constants';

Expand All @@ -22,7 +22,9 @@ export const useBillableServices = () => {
};

export function useServiceTypes() {
const url = `${restBaseUrl}/concept/21b8cf43-9f9f-4d02-9f4a-d710ece54261?v=custom:(setMembers:(uuid,display))`;
const config = useConfig();
const serviceConceptUuid = config.serviceTypes.billableService;
const url = `${restBaseUrl}/concept/${serviceConceptUuid}?v=custom:(setMembers:(uuid,display))`;

const { data, error, isLoading } = useSWR<{ data }>(url, openmrsFetch);

Expand Down
8 changes: 4 additions & 4 deletions src/billing-form/billing-form.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type BillingFormProps = {

const BillingForm: React.FC<BillingFormProps> = ({ patientUuid, closeWorkspace }) => {
const { t } = useTranslation();
const { defaultCurrency } = useConfig();
const { defaultCurrency, postBilledItems } = useConfig();
const isTablet = useLayoutType() === 'tablet';

const [grandTotal, setGrandTotal] = useState(0);
Expand Down Expand Up @@ -180,8 +180,8 @@ const BillingForm: React.FC<BillingFormProps> = ({ patientUuid, closeWorkspace }
const postBillItems = () => {
setIsSubmitting(true);
const bill = {
cashPoint: '54065383-b4d4-42d2-af4d-d250a1fd2590',
cashier: 'f9badd80-ab76-11e2-9e96-0800200c9a66',
cashPoint: postBilledItems.cashPoint,
cashier: postBilledItems.cashier,
lineItems: [],
payments: [],
patient: patientUuid,
Expand All @@ -193,7 +193,7 @@ const BillingForm: React.FC<BillingFormProps> = ({ patientUuid, closeWorkspace }
quantity: parseInt(item.Qnty),
price: item.Price,
priceName: 'Default',
priceUuid: '7b9171ac-d3c1-49b4-beff-c9902aee5245',
priceUuid: postBilledItems.priceUuid,
lineItemOrder: 0,
paymentStatus: 'PENDING',
};
Expand Down
20 changes: 20 additions & 0 deletions src/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ export const configSchema = {
},
},

postBilledItems: {
_type: Type.Object,
_description: 'Post Bill Items such as cashPoints, cashier, priceUUid when submitting a bill',
_default: {
cashPoint: '54065383-b4d4-42d2-af4d-d250a1fd2590',
cashier: 'f9badd80-ab76-11e2-9e96-0800200c9a66',
priceUuid: '7b9171ac-d3c1-49b4-beff-c9902aee5245',
},
},

serviceTypes: {
_type: Type.Object,
_description: 'Post Bill Items such as cashPoints, cashier, priceUUid when submitting a bill',
_default: {
billableService: '21b8cf43-9f9f-4d02-9f4a-d710ece54261',
},
},

defaultCurrency: {
_type: Type.String,
_description: 'The default currency for the application. Specify the currency code (e.g., KES, UGX, GBP).',
Expand All @@ -54,4 +72,6 @@ export interface ConfigObject {
pageSize;
object;
showEditBillButton: boolean;
postBilledItems: Object;
serviceTypes: Object;
}

0 comments on commit d22a30a

Please sign in to comment.