@@ -2,8 +2,9 @@ import React from 'react';
2
2
import { ComboBox , InlineLoading , InlineNotification , Layer } from '@carbon/react' ;
3
3
import { type MedicationDispense , type InventoryItem } from '../../types' ;
4
4
import { useDispenseStock } from './stock.resource' ;
5
- import { formatDate } from '@openmrs/esm-framework' ;
5
+ import { formatDate , useConfig } from '@openmrs/esm-framework' ;
6
6
import { useTranslation } from 'react-i18next' ;
7
+ import { type PharmacyConfig } from '../../config-schema' ;
7
8
8
9
type StockDispenseProps = {
9
10
medicationDispense : MedicationDispense ;
@@ -13,6 +14,8 @@ type StockDispenseProps = {
13
14
14
15
const StockDispense : React . FC < StockDispenseProps > = ( { medicationDispense, updateInventoryItem } ) => {
15
16
const { t } = useTranslation ( ) ;
17
+ const config = useConfig < PharmacyConfig > ( ) ;
18
+
16
19
const drugUuid = medicationDispense ?. medicationReference ?. reference ?. split ( '/' ) [ 1 ] ;
17
20
const { inventoryItems, error, isLoading } = useDispenseStock ( drugUuid ) ;
18
21
const validInventoryItems = inventoryItems . filter ( ( item ) => isValidBatch ( medicationDispense , item ) ) ;
@@ -31,6 +34,9 @@ const StockDispense: React.FC<StockDispenseProps> = ({ medicationDispense, updat
31
34
32
35
//check whether the drug will expire before the medication period ends
33
36
function isValidBatch ( medicationToDispense , inventoryItem ) {
37
+ if ( typeof config !== 'undefined' && ! config . validateBatch ) {
38
+ return true ;
39
+ }
34
40
if ( medicationToDispense ?. dosageInstruction && medicationToDispense ?. dosageInstruction . length > 0 ) {
35
41
return medicationToDispense . dosageInstruction . some ( ( instruction ) => {
36
42
if (
0 commit comments