@openmrs/esm-stock-management-app 1.0.1-pre.327
Sign up to get free protection for your applications and to get access to all the features.
- package/.editorconfig +12 -0
- package/.eslintignore +2 -0
- package/.eslintrc +39 -0
- package/.husky/pre-commit +4 -0
- package/.husky/pre-push +6 -0
- package/.prettierignore +14 -0
- package/.turbo.json +18 -0
- package/.yarn/plugins/@yarnpkg/plugin-outdated.cjs +35 -0
- package/LICENSE +401 -0
- package/README.md +3 -0
- package/__mocks__/react-i18next.js +55 -0
- package/dist/26.js +2 -0
- package/dist/26.js.LICENSE.txt +32 -0
- package/dist/26.js.map +1 -0
- package/dist/294.js +2 -0
- package/dist/294.js.LICENSE.txt +9 -0
- package/dist/294.js.map +1 -0
- package/dist/375.js +2 -0
- package/dist/375.js.LICENSE.txt +40 -0
- package/dist/375.js.map +1 -0
- package/dist/46.js +1 -0
- package/dist/46.js.map +1 -0
- package/dist/484.js +1 -0
- package/dist/484.js.map +1 -0
- package/dist/574.js +1 -0
- package/dist/629.js +1 -0
- package/dist/629.js.map +1 -0
- package/dist/707.js +1 -0
- package/dist/707.js.map +1 -0
- package/dist/800.js +2 -0
- package/dist/800.js.LICENSE.txt +3 -0
- package/dist/800.js.map +1 -0
- package/dist/935.js +2 -0
- package/dist/935.js.LICENSE.txt +19 -0
- package/dist/935.js.map +1 -0
- package/dist/979.js +1 -0
- package/dist/979.js.map +1 -0
- package/dist/main.js +2 -0
- package/dist/main.js.LICENSE.txt +60 -0
- package/dist/main.js.map +1 -0
- package/dist/openmrs-esm-stock-management-app.js +1 -0
- package/dist/openmrs-esm-stock-management-app.js.buildmanifest.json +356 -0
- package/dist/openmrs-esm-stock-management-app.js.map +1 -0
- package/dist/routes.json +1 -0
- package/i18next-parser.config.js +89 -0
- package/jest.config.js +25 -0
- package/package.json +116 -0
- package/src/config-schema.ts +18 -0
- package/src/constants.ts +214 -0
- package/src/core/api/api.ts +34 -0
- package/src/core/api/types/Auditable.ts +9 -0
- package/src/core/api/types/BaseOpenmrsData.ts +4 -0
- package/src/core/api/types/BaseOpenmrsMetadata.ts +6 -0
- package/src/core/api/types/BaseOpenmrsObject.ts +3 -0
- package/src/core/api/types/BatchJob.ts +121 -0
- package/src/core/api/types/DashboardExtension.ts +8 -0
- package/src/core/api/types/Location.ts +16 -0
- package/src/core/api/types/LocationTree.ts +7 -0
- package/src/core/api/types/OpenmrsData.ts +5 -0
- package/src/core/api/types/OpenmrsMetadata.ts +8 -0
- package/src/core/api/types/OpenmrsObject.ts +3 -0
- package/src/core/api/types/PageableResult.ts +15 -0
- package/src/core/api/types/Party.ts +8 -0
- package/src/core/api/types/RecordPermission.ts +9 -0
- package/src/core/api/types/Retireable.ts +9 -0
- package/src/core/api/types/Voidable.ts +9 -0
- package/src/core/api/types/concept/Concept.ts +24 -0
- package/src/core/api/types/concept/ConceptName.ts +14 -0
- package/src/core/api/types/concept/Drug.ts +14 -0
- package/src/core/api/types/identity/Credentials.ts +4 -0
- package/src/core/api/types/identity/Patient.ts +3 -0
- package/src/core/api/types/identity/Person.ts +4 -0
- package/src/core/api/types/identity/PriviledgeScope.ts +9 -0
- package/src/core/api/types/identity/Privilege.ts +5 -0
- package/src/core/api/types/identity/Role.ts +5 -0
- package/src/core/api/types/identity/Session.ts +16 -0
- package/src/core/api/types/identity/User.ts +19 -0
- package/src/core/api/types/identity/UserRoleScope.ts +17 -0
- package/src/core/api/types/identity/UserRoleScopeLocation.ts +7 -0
- package/src/core/api/types/identity/UserRoleScopeOperationType.ts +6 -0
- package/src/core/api/types/stockItem/ImportResult.ts +9 -0
- package/src/core/api/types/stockItem/StockBatch.ts +8 -0
- package/src/core/api/types/stockItem/StockBatchDTO.ts +8 -0
- package/src/core/api/types/stockItem/StockItem.ts +63 -0
- package/src/core/api/types/stockItem/StockItemInventory.ts +10 -0
- package/src/core/api/types/stockItem/StockItemPackagingUOM.ts +20 -0
- package/src/core/api/types/stockItem/StockItemTransaction.ts +22 -0
- package/src/core/api/types/stockItem/StockRule.ts +28 -0
- package/src/core/api/types/stockOperation/LocationType.ts +4 -0
- package/src/core/api/types/stockOperation/StockOperation.ts +36 -0
- package/src/core/api/types/stockOperation/StockOperationAction.ts +24 -0
- package/src/core/api/types/stockOperation/StockOperationDTO.ts +64 -0
- package/src/core/api/types/stockOperation/StockOperationItem.ts +13 -0
- package/src/core/api/types/stockOperation/StockOperationItemCost.ts +14 -0
- package/src/core/api/types/stockOperation/StockOperationItemDTO.ts +29 -0
- package/src/core/api/types/stockOperation/StockOperationLinkDTO.ts +13 -0
- package/src/core/api/types/stockOperation/StockOperationStatus.ts +18 -0
- package/src/core/api/types/stockOperation/StockOperationType.ts +162 -0
- package/src/core/api/types/stockOperation/StockSource.ts +8 -0
- package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.component.tsx +37 -0
- package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.scss +0 -0
- package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.test.tsx +8 -0
- package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.component.tsx +40 -0
- package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.scss +0 -0
- package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.test.tsx +8 -0
- package/src/core/components/carbon/controlled-number-input/controlled-number-input.component.tsx +44 -0
- package/src/core/components/carbon/controlled-number-input/controlled-number-input.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-number-input/controlled-number-input.scss +0 -0
- package/src/core/components/carbon/controlled-number-input/controlled-number-input.test.tsx +8 -0
- package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.component.tsx +54 -0
- package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.scss +0 -0
- package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.test.tsx +8 -0
- package/src/core/components/carbon/controlled-text-area/controlled-text-area.component.tsx +37 -0
- package/src/core/components/carbon/controlled-text-area/controlled-text-area.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-text-area/controlled-text-area.scss +0 -0
- package/src/core/components/carbon/controlled-text-area/controlled-text-area.test.tsx +11 -0
- package/src/core/components/carbon/controlled-text-input/controlled-text-input.component.tsx +37 -0
- package/src/core/components/carbon/controlled-text-input/controlled-text-input.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-text-input/controlled-text-input.scss +0 -0
- package/src/core/components/carbon/controlled-text-input/controlled-text-input.test.tsx +8 -0
- package/src/core/components/carbon/types.ts +7 -0
- package/src/core/components/card/metrics-card-component.tsx +102 -0
- package/src/core/components/card/metrics-card.scss +78 -0
- package/src/core/components/overlay/hook.ts +47 -0
- package/src/core/components/overlay/overlay.component.tsx +52 -0
- package/src/core/components/overlay/overlay.scss +97 -0
- package/src/core/components/side-nav/side-nav.component.tsx +62 -0
- package/src/core/components/side-nav/side-nav.scss +126 -0
- package/src/core/components/side-nav/types.ts +6 -0
- package/src/core/components/table/table.component.tsx +239 -0
- package/src/core/components/table/table.scss +173 -0
- package/src/core/components/table/types.ts +8 -0
- package/src/core/components/tabs/types.ts +7 -0
- package/src/core/components/tabs/vertical-tabs.component.tsx +53 -0
- package/src/core/components/tabs/vertical-tabs.scss +126 -0
- package/src/core/hooks/debounce-hook.ts +35 -0
- package/src/core/print/PrintStyles.ts +774 -0
- package/src/core/print/PrintTemplate.ts +65 -0
- package/src/core/print/printUtils.ts +19 -0
- package/src/core/utils/alert.ts +10 -0
- package/src/core/utils/datetimeUtils.ts +84 -0
- package/src/core/utils/debounce.ts +21 -0
- package/src/core/utils/imageUtils.ts +82 -0
- package/src/core/utils/stringUtils.ts +27 -0
- package/src/core/utils/utils.ts +70 -0
- package/src/createDashboardLink.tsx +43 -0
- package/src/dashboard/stock-management-dashboard-side-nav.component.tsx +50 -0
- package/src/dashboard/stock-management-dashboard.component.tsx +41 -0
- package/src/dashboard/stock-management-dashboard.scss +8 -0
- package/src/dashboard.meta.ts +5 -0
- package/src/declarations.d.ts +6 -0
- package/src/index.ts +64 -0
- package/src/root.component.tsx +12 -0
- package/src/root.scss +174 -0
- package/src/routes.json +53 -0
- package/src/setup-tests.ts +1 -0
- package/src/stock-app-menu-item/item.component.tsx +21 -0
- package/src/stock-app-menu-item/item.resource.ts +0 -0
- package/src/stock-app-menu-item/item.scss +17 -0
- package/src/stock-batch/stock-batch.resource.ts +79 -0
- package/src/stock-home/stock-home-detail-card.scss +211 -0
- package/src/stock-home/stock-home-detail-cards.component.tsx +62 -0
- package/src/stock-home/stock-home-inventory-card.component.tsx +80 -0
- package/src/stock-home/stock-home-inventory-expiry.resource.tsx +32 -0
- package/src/stock-home/stock-home-inventory-items.resource.tsx +28 -0
- package/src/stock-home/stock-home-issuing-card.component.tsx +84 -0
- package/src/stock-home/stock-home-issuing.resource.tsx +18 -0
- package/src/stock-home/stock-home-landing-page-component.tsx +14 -0
- package/src/stock-home/stock-home-metrics.tsx +112 -0
- package/src/stock-home/stock-home-receiving-card.component.tsx +66 -0
- package/src/stock-home/stock-home-receiving.resource.tsx +17 -0
- package/src/stock-home/stock-home.scss +13 -0
- package/src/stock-home/useDisposalList.tsx +18 -0
- package/src/stock-home/useStockList.tsx +36 -0
- package/src/stock-items/add-bulk-stock-item/add-stock-items-bulk-import-action-button.component.tsx +26 -0
- package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.component.tsx +109 -0
- package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.resource.ts +14 -0
- package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.scss +0 -0
- package/src/stock-items/add-stock-item/add-stock-action-button.component.tsx +21 -0
- package/src/stock-items/add-stock-item/add-stock-item.component.tsx +84 -0
- package/src/stock-items/add-stock-item/add-stock-item.resource.tsx +36 -0
- package/src/stock-items/add-stock-item/add-stock-item.scss +5 -0
- package/src/stock-items/add-stock-item/batch-information/batch-information.component.tsx +98 -0
- package/src/stock-items/add-stock-item/batch-information/batch-information.resource.tsx +71 -0
- package/src/stock-items/add-stock-item/batch-information/batch-information.scss +0 -0
- package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.component.tsx +79 -0
- package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.resource.tsx +0 -0
- package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.scss +0 -0
- package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.test.tsx +8 -0
- package/src/stock-items/add-stock-item/dispensing-package-measurement/dispensing-package-measurement.component.tsx +76 -0
- package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.component.tsx +66 -0
- package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.resource.tsx +0 -0
- package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.scss +0 -0
- package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.test.tsx +8 -0
- package/src/stock-items/add-stock-item/drug-selector/drug-selector.component.tsx +83 -0
- package/src/stock-items/add-stock-item/drug-selector/drug-selector.resource.tsx +50 -0
- package/src/stock-items/add-stock-item/drug-selector/drug-selector.scss +0 -0
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.component.tsx +255 -0
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.resource.tsx +38 -0
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.scss +21 -0
- package/src/stock-items/add-stock-item/packaging-units/validationSchema.ts +14 -0
- package/src/stock-items/add-stock-item/packaging-units-concept-selector/packaging-units-concept-selector.component.tsx +95 -0
- package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.component.tsx +70 -0
- package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.resource.tsx +0 -0
- package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.scss +0 -0
- package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.test.tsx +8 -0
- package/src/stock-items/add-stock-item/quantities/quantities.component.tsx +83 -0
- package/src/stock-items/add-stock-item/quantities/quantities.resource.tsx +69 -0
- package/src/stock-items/add-stock-item/quantities/quantities.scss +0 -0
- package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.component.tsx +67 -0
- package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.resource.tsx +0 -0
- package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.scss +0 -0
- package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.test.tsx +8 -0
- package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx +239 -0
- package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.resource.tsx +14 -0
- package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.scss +13 -0
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rule-button.component.tsx +30 -0
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.component.tsx +424 -0
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.scss +18 -0
- package/src/stock-items/add-stock-item/stock-item-rules/delete-stock-rule-modal.component.tsx +47 -0
- package/src/stock-items/add-stock-item/stock-item-rules/edit-stock-rule.component.tsx +37 -0
- package/src/stock-items/add-stock-item/stock-item-rules/edit-stock-rule.scss +0 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.component.tsx +222 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.resource.tsx +72 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.scss +13 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-delete.component.tsx +67 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-delete.scss +0 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-filter.component.tsx +38 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-filter.scss +13 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules.resource.ts +79 -0
- package/src/stock-items/add-stock-item/stock-item-units-edit/stock-item-units-edit.component.tsx +132 -0
- package/src/stock-items/add-stock-item/stock-rules/stock-rules.component.tsx +16 -0
- package/src/stock-items/add-stock-item/stock-rules/stock-rules.resource.tsx +0 -0
- package/src/stock-items/add-stock-item/stock-rules/stock-rules.scss +0 -0
- package/src/stock-items/add-stock-item/transactions/transactions.component.tsx +151 -0
- package/src/stock-items/add-stock-item/transactions/transactions.resource.tsx +109 -0
- package/src/stock-items/add-stock-item/transactions/transactions.scss +0 -0
- package/src/stock-items/components/filter-stock-items/filter-stock-items.component.tsx +28 -0
- package/src/stock-items/components/filter-stock-items/filter-stock-items.resource.tsx +0 -0
- package/src/stock-items/components/filter-stock-items/filter-stock-items.scss +3 -0
- package/src/stock-items/edit-stock-item/edit-stock-item-action-menu.component.tsx +30 -0
- package/src/stock-items/stock-item.utils.tsx +62 -0
- package/src/stock-items/stock-items-table.component.tsx +266 -0
- package/src/stock-items/stock-items-table.resource.ts +58 -0
- package/src/stock-items/stock-items-table.scss +66 -0
- package/src/stock-items/stock-items.component.tsx +12 -0
- package/src/stock-items/stock-items.resource.ts +365 -0
- package/src/stock-items/types.ts +8 -0
- package/src/stock-items/validationSchema.ts +67 -0
- package/src/stock-locations/stock-locations-table.component.tsx +69 -0
- package/src/stock-locations/stock-locations-table.resource.tsx +73 -0
- package/src/stock-locations/stock-locations-table.scss +0 -0
- package/src/stock-locations/stock-locations.component.tsx +12 -0
- package/src/stock-locations/stock-locations.resource.ts +0 -0
- package/src/stock-lookups/stock-lookups.resource.ts +306 -0
- package/src/stock-management-admin-card-link.component.tsx +29 -0
- package/src/stock-management-header/stock-management-Illustration.tsx +35 -0
- package/src/stock-management-header/stock-management-header.component.tsx +37 -0
- package/src/stock-management-header/stock-management-header.scss +58 -0
- package/src/stock-management.component.tsx +6 -0
- package/src/stock-operations/add-stock-operation/add-stock-operation.component.tsx +491 -0
- package/src/stock-operations/add-stock-operation/add-stock-operation.resource.tsx +33 -0
- package/src/stock-operations/add-stock-operation/add-stock-operation.scss +44 -0
- package/src/stock-operations/add-stock-operation/add-stock-operation.utils.tsx +241 -0
- package/src/stock-operations/add-stock-operation/add-stock-utils.ts +110 -0
- package/src/stock-operations/add-stock-operation/base-operation-details.component.tsx +352 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition-row.component.tsx +347 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition-row.resource.tsx +0 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition-row.scss +0 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition-row.test.tsx +11 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition.component.scss +5 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition.component.tsx +272 -0
- package/src/stock-operations/add-stock-operation/stock-operation-context/useStockOperationContext.tsx +22 -0
- package/src/stock-operations/add-stock-operation/stock-operation-submission.component.tsx +188 -0
- package/src/stock-operations/add-stock-operation/types.ts +55 -0
- package/src/stock-operations/add-stock-operation/validationSchema.ts +45 -0
- package/src/stock-operations/batch-no-selector/batch-no-selector.component.tsx +100 -0
- package/src/stock-operations/batch-no-selector/batch-no-selector.resource.tsx +46 -0
- package/src/stock-operations/batch-no-selector/batch-no-selector.scss +0 -0
- package/src/stock-operations/batch-no-selector/batch-no-selector.test.tsx +11 -0
- package/src/stock-operations/edit-stock-operation/edit-stock-operation-action-menu.component.tsx +73 -0
- package/src/stock-operations/party-selector/party-selector.component.tsx +58 -0
- package/src/stock-operations/qty-uom-selector/qty-uom-selector.component.tsx +65 -0
- package/src/stock-operations/qty-uom-selector/qty-uom-selector.resource.tsx +0 -0
- package/src/stock-operations/qty-uom-selector/qty-uom-selector.scss +0 -0
- package/src/stock-operations/qty-uom-selector/qty-uom-selector.test.tsx +11 -0
- package/src/stock-operations/stock-item-selector/stock-item-selector.component.tsx +74 -0
- package/src/stock-operations/stock-item-selector/stock-item-selector.resource.tsx +47 -0
- package/src/stock-operations/stock-item-selector/stock-item-selector.scss +0 -0
- package/src/stock-operations/stock-item-selector/stock-item-selector.test.tsx +11 -0
- package/src/stock-operations/stock-operation-operations-filter/stock-operation-operations-filter.component.tsx +27 -0
- package/src/stock-operations/stock-operation-operations-filter/stock-operation-operations-filter.scss +13 -0
- package/src/stock-operations/stock-operation-reason-selector/stock-operation-reason-selector.component.tsx +65 -0
- package/src/stock-operations/stock-operation-sources-filter/stock-operation-sources-filter.component.tsx +30 -0
- package/src/stock-operations/stock-operation-sources-filter/stock-operation-sources-filter.scss +13 -0
- package/src/stock-operations/stock-operation-statuses-filter/stock-operation-statuses-filter.component.tsx +32 -0
- package/src/stock-operations/stock-operation-statuses-filter/stock-operation-statuses-filter.scss +13 -0
- package/src/stock-operations/stock-operation-types-selector/stock-operation-types-selector.component.tsx +80 -0
- package/src/stock-operations/stock-operation.utils.tsx +106 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-approve-button.component.tsx +36 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-approve-dispatch-button.component.tsx +36 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-cancel-button.component.tsx +37 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-complete-button.component.tsx +36 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-completed-dispatch-button.component.tsx +36 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-dialog.component.tsx +167 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-dialog.scss +14 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-issue-stock-button.component.tsx +58 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-print-button.component.tsx +160 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-reject-button.component.tsx +37 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-return-button.component.tsx +37 -0
- package/src/stock-operations/stock-operations-table.component.tsx +524 -0
- package/src/stock-operations/stock-operations-table.resource.tsx +77 -0
- package/src/stock-operations/stock-operations-table.scss +0 -0
- package/src/stock-operations/stock-operations.component.tsx +12 -0
- package/src/stock-operations/stock-operations.resource.ts +238 -0
- package/src/stock-operations/stock-print-reports/GoodsReceivedNote.tsx +147 -0
- package/src/stock-operations/stock-print-reports/RequisitionDocument.tsx +153 -0
- package/src/stock-operations/stock-print-reports/StockOperationReport.tsx +133 -0
- package/src/stock-operations/stock-print-reports/StockTransferDocument.tsx +161 -0
- package/src/stock-operations/swr-revalidation.ts +7 -0
- package/src/stock-operations/users-selector/users-selector.component.tsx +77 -0
- package/src/stock-operations/users-selector/users-selector.resource.tsx +47 -0
- package/src/stock-operations/validation-schema.ts +195 -0
- package/src/stock-reports/ReportType.ts +63 -0
- package/src/stock-reports/stock-reports.component.tsx +0 -0
- package/src/stock-reports/stock-reports.resource.ts +0 -0
- package/src/stock-settings/stock-settings.component.tsx +11 -0
- package/src/stock-settings/stock-settings.resource.ts +0 -0
- package/src/stock-sources/add-stock-source-button.component.tsx +21 -0
- package/src/stock-sources/add-stock-sources/add-stock-sources.component.tsx +152 -0
- package/src/stock-sources/add-stock-sources/add-stock-sources.scss +18 -0
- package/src/stock-sources/delete-stock-modal.component.tsx +47 -0
- package/src/stock-sources/edit-stock-source/edit-stock-source.component.tsx +35 -0
- package/src/stock-sources/edit-stock-source/edit-stock-source.scss +0 -0
- package/src/stock-sources/stock-sources-delete/stock-sources-delate.scss +0 -0
- package/src/stock-sources/stock-sources-delete/stock-sources-delete.component.tsx +72 -0
- package/src/stock-sources/stock-sources-filter/stock-sources-filter.component.tsx +35 -0
- package/src/stock-sources/stock-sources-filter/stock-sources-filter.scss +13 -0
- package/src/stock-sources/stock-sources-items-table.component.tsx +213 -0
- package/src/stock-sources/stock-sources-items-table.resource.ts +56 -0
- package/src/stock-sources/stock-sources.component.tsx +12 -0
- package/src/stock-sources/stock-sources.resource.ts +80 -0
- package/src/stock-sources/stock-sources.scss +220 -0
- package/src/stock-sources/swr-revalidation.ts +7 -0
- package/src/stock-tabs/commodity-tabs.component.tsx +43 -0
- package/src/stock-tabs/commodity-tabs.scss +0 -0
- package/src/stock-user-role-scopes/add-stock-user-role-scope-button.component.tsx +21 -0
- package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.component.tsx +525 -0
- package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.scss +37 -0
- package/src/stock-user-role-scopes/delete-stock-user-scope/delete-stock-user-scope.component.tsx +73 -0
- package/src/stock-user-role-scopes/delete-stock-user-scope/delete-stock-user-scope.scss +0 -0
- package/src/stock-user-role-scopes/delete-stock-user-scope-modal.component.tsx +47 -0
- package/src/stock-user-role-scopes/edit-stock-user-scope/edit-stock-user-scope-action-menu.component.tsx +35 -0
- package/src/stock-user-role-scopes/stock-user-role-scopes-items-table.component.tsx +284 -0
- package/src/stock-user-role-scopes/stock-user-role-scopes-items-table.resource.ts +31 -0
- package/src/stock-user-role-scopes/stock-user-role-scopes.component.tsx +12 -0
- package/src/stock-user-role-scopes/stock-user-role-scopes.resource.ts +76 -0
- package/src/stock-user-role-scopes/stock-user-role-scopes.scss +61 -0
- package/src/stock-user-role-scopes/swr-revalidation.ts +7 -0
- package/src/utils.ts +10 -0
- package/translations/en.json +24 -0
- package/tsconfig.json +23 -0
- package/webpack.config.js +1 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
import { StockItemFilter, useStockItems } from "./stock-items.resource";
|
2
|
+
import { useEffect, useMemo, useState } from "react";
|
3
|
+
import { useTranslation } from "react-i18next";
|
4
|
+
import { ResourceRepresentation } from "../core/api/api";
|
5
|
+
import { usePagination } from "@openmrs/esm-framework";
|
6
|
+
|
7
|
+
export function useStockItemsPages(v?: ResourceRepresentation) {
|
8
|
+
const { t } = useTranslation();
|
9
|
+
|
10
|
+
const pageSizes = [10, 20, 30, 40, 50];
|
11
|
+
const [currentPage, setCurrentPage] = useState(1);
|
12
|
+
const [currentPageSize, setPageSize] = useState(10);
|
13
|
+
const [searchString, setSearchString] = useState(null);
|
14
|
+
|
15
|
+
// Drug filter type
|
16
|
+
const [isDrug, setDrug] = useState("");
|
17
|
+
|
18
|
+
const [stockItemFilter, setStockItemFilter] = useState<StockItemFilter>({
|
19
|
+
startIndex: currentPage - 1,
|
20
|
+
v: v || ResourceRepresentation.Default,
|
21
|
+
limit: 10,
|
22
|
+
q: null,
|
23
|
+
totalCount: true,
|
24
|
+
});
|
25
|
+
|
26
|
+
const { items, isLoading, isError } = useStockItems(stockItemFilter);
|
27
|
+
const pagination = usePagination(items.results, currentPageSize);
|
28
|
+
|
29
|
+
useEffect(() => {
|
30
|
+
setStockItemFilter({
|
31
|
+
startIndex: currentPage - 1,
|
32
|
+
v: ResourceRepresentation.Default,
|
33
|
+
limit: currentPageSize,
|
34
|
+
q: searchString,
|
35
|
+
totalCount: true,
|
36
|
+
isDrug: isDrug,
|
37
|
+
});
|
38
|
+
}, [searchString, currentPage, currentPageSize, isDrug]);
|
39
|
+
|
40
|
+
return {
|
41
|
+
items: pagination.results,
|
42
|
+
pagination,
|
43
|
+
totalCount: items.totalCount,
|
44
|
+
currentPageSize,
|
45
|
+
currentPage,
|
46
|
+
setCurrentPage,
|
47
|
+
setPageSize,
|
48
|
+
pageSizes,
|
49
|
+
isLoading,
|
50
|
+
isError,
|
51
|
+
isDrug,
|
52
|
+
setDrug: (drug: string) => {
|
53
|
+
setCurrentPage(1);
|
54
|
+
setDrug(drug);
|
55
|
+
},
|
56
|
+
setSearchString,
|
57
|
+
};
|
58
|
+
}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
@use '@carbon/styles/scss/spacing';
|
2
|
+
@use '@carbon/styles/scss/type';
|
3
|
+
@import "~@openmrs/esm-styleguide/src/vars";
|
4
|
+
@import '../root.scss';
|
5
|
+
.headerBtnContainer {
|
6
|
+
background-color: $ui-background;
|
7
|
+
padding: spacing.$spacing-05;
|
8
|
+
text-align: right;
|
9
|
+
}
|
10
|
+
|
11
|
+
.tileContainer {
|
12
|
+
background-color: $ui-02;
|
13
|
+
border-top: 1px solid $ui-03;
|
14
|
+
padding: 5rem 0;
|
15
|
+
}
|
16
|
+
|
17
|
+
.tile {
|
18
|
+
margin: auto;
|
19
|
+
width: fit-content;
|
20
|
+
}
|
21
|
+
|
22
|
+
.tileContent {
|
23
|
+
display: flex;
|
24
|
+
flex-direction: column;
|
25
|
+
align-items: center;
|
26
|
+
}
|
27
|
+
.content {
|
28
|
+
@include type.type-style('heading-compact-02');
|
29
|
+
color: $text-02;
|
30
|
+
margin-bottom: 0.5rem;
|
31
|
+
}
|
32
|
+
|
33
|
+
.helper {
|
34
|
+
@include type.type-style('body-compact-01');
|
35
|
+
color: $text-02;
|
36
|
+
}
|
37
|
+
|
38
|
+
.separator {
|
39
|
+
@include type.type-style('body-compact-02');
|
40
|
+
color: $text-02;
|
41
|
+
width: 80%;
|
42
|
+
margin: 1.5rem auto;
|
43
|
+
overflow: hidden;
|
44
|
+
text-align: center;
|
45
|
+
|
46
|
+
&::before,
|
47
|
+
&::after {
|
48
|
+
background-color: $text-03;
|
49
|
+
content: '';
|
50
|
+
display: inline-block;
|
51
|
+
height: 1px;
|
52
|
+
position: relative;
|
53
|
+
vertical-align: middle;
|
54
|
+
width: 50%;
|
55
|
+
}
|
56
|
+
|
57
|
+
&::before {
|
58
|
+
right: 0.5rem;
|
59
|
+
margin-left: -50%;
|
60
|
+
}
|
61
|
+
|
62
|
+
&::after {
|
63
|
+
left: 0.5rem;
|
64
|
+
margin-right: -50%;
|
65
|
+
}
|
66
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import StockItemsTableComponent from "./stock-items-table.component";
|
3
|
+
|
4
|
+
const StockItems = () => {
|
5
|
+
return (
|
6
|
+
<div style={{ margin: "5px" }}>
|
7
|
+
<StockItemsTableComponent />
|
8
|
+
</div>
|
9
|
+
);
|
10
|
+
};
|
11
|
+
|
12
|
+
export default StockItems;
|
@@ -0,0 +1,365 @@
|
|
1
|
+
import { openmrsFetch } from "@openmrs/esm-framework";
|
2
|
+
import { ResourceFilterCriteria, toQueryParams } from "../core/api/api";
|
3
|
+
import { PageableResult } from "../core/api/types/PageableResult";
|
4
|
+
import {
|
5
|
+
InventoryGroupBy,
|
6
|
+
StockItemDTO,
|
7
|
+
} from "../core/api/types/stockItem/StockItem";
|
8
|
+
import { StockItemInventory } from "../core/api/types/stockItem/StockItemInventory";
|
9
|
+
import useSWR from "swr";
|
10
|
+
import { StockItemTransactionDTO } from "../core/api/types/stockItem/StockItemTransaction";
|
11
|
+
import { StockOperationItemCost } from "../core/api/types/stockOperation/StockOperationItemCost";
|
12
|
+
import { StockBatchDTO } from "../core/api/types/stockItem/StockBatchDTO";
|
13
|
+
import { StockItemPackagingUOMDTO } from "../core/api/types/stockItem/StockItemPackagingUOM";
|
14
|
+
import { StockRule } from "../core/api/types/stockItem/StockRule";
|
15
|
+
|
16
|
+
export interface StockItemFilter extends ResourceFilterCriteria {
|
17
|
+
isDrug?: string | null | undefined;
|
18
|
+
drugUuid?: string | null;
|
19
|
+
conceptUuid?: string | null;
|
20
|
+
}
|
21
|
+
|
22
|
+
export interface StockItemTransactionFilter extends ResourceFilterCriteria {
|
23
|
+
stockItemUuid?: string | null;
|
24
|
+
partyUuid?: string | null;
|
25
|
+
stockOperationUuid?: string | null;
|
26
|
+
includeBatchNo?: boolean | null;
|
27
|
+
dateMin?: string | null;
|
28
|
+
dateMax?: string | null;
|
29
|
+
stockBatchUuid?: string | null | undefined;
|
30
|
+
}
|
31
|
+
|
32
|
+
export interface StockItemInventoryFilter extends ResourceFilterCriteria {
|
33
|
+
stockItemUuid?: string | null;
|
34
|
+
partyUuid?: string | null;
|
35
|
+
locationUuid?: string | null;
|
36
|
+
includeBatchNo?: boolean | null;
|
37
|
+
stockBatchUuid?: string | null;
|
38
|
+
groupBy?: InventoryGroupBy | null;
|
39
|
+
totalBy?: InventoryGroupBy | null;
|
40
|
+
stockOperationUuid?: string | null;
|
41
|
+
date?: string | null;
|
42
|
+
includeStockItemName?: "true" | "false" | "0" | "1";
|
43
|
+
excludeExpired?: boolean | null;
|
44
|
+
}
|
45
|
+
|
46
|
+
export interface StockItemPackagingUOMFilter extends ResourceFilterCriteria {
|
47
|
+
stockItemUuid?: string | null | undefined;
|
48
|
+
}
|
49
|
+
|
50
|
+
export interface StockBatchFilter extends ResourceFilterCriteria {
|
51
|
+
stockItemUuid?: string | null | undefined;
|
52
|
+
excludeExpired?: boolean | null;
|
53
|
+
includeStockItemName?: "true" | "false" | "0" | "1";
|
54
|
+
}
|
55
|
+
|
56
|
+
export interface StockInventoryResult
|
57
|
+
extends PageableResult<StockItemInventory> {
|
58
|
+
total: StockItemInventory[];
|
59
|
+
}
|
60
|
+
|
61
|
+
export interface StockRuleFilter extends ResourceFilterCriteria {
|
62
|
+
stockItemUuid?: string | null;
|
63
|
+
locationUuid?: string | null;
|
64
|
+
}
|
65
|
+
|
66
|
+
// getStockItems
|
67
|
+
export function useStockItems(filter: StockItemFilter) {
|
68
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockitem${toQueryParams(filter)}`;
|
69
|
+
const { data, error, isLoading } = useSWR<
|
70
|
+
{
|
71
|
+
data: PageableResult<StockItemDTO>;
|
72
|
+
},
|
73
|
+
Error
|
74
|
+
>(apiUrl, openmrsFetch);
|
75
|
+
|
76
|
+
return {
|
77
|
+
items: data?.data || <PageableResult<StockItemDTO>>{},
|
78
|
+
isLoading,
|
79
|
+
isError: error,
|
80
|
+
};
|
81
|
+
}
|
82
|
+
|
83
|
+
// getStockItemTransactions
|
84
|
+
export function useStockItemTransactions(filter: StockItemTransactionFilter) {
|
85
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockitemtransaction${toQueryParams(
|
86
|
+
filter
|
87
|
+
)}`;
|
88
|
+
const { data, error, isLoading } = useSWR<
|
89
|
+
{
|
90
|
+
data: PageableResult<StockItemTransactionDTO>;
|
91
|
+
},
|
92
|
+
Error
|
93
|
+
>(apiUrl, openmrsFetch);
|
94
|
+
|
95
|
+
return {
|
96
|
+
items: data?.data || <PageableResult<StockItemTransactionDTO>>{},
|
97
|
+
isLoading,
|
98
|
+
isError: error,
|
99
|
+
};
|
100
|
+
}
|
101
|
+
|
102
|
+
// getStockItemInventory
|
103
|
+
export function useStockItemInventory(filter: StockItemInventoryFilter) {
|
104
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockiteminventory${toQueryParams(
|
105
|
+
filter
|
106
|
+
)}`;
|
107
|
+
const { data, error, isLoading } = useSWR<
|
108
|
+
{
|
109
|
+
data: StockInventoryResult;
|
110
|
+
},
|
111
|
+
Error
|
112
|
+
>(apiUrl, openmrsFetch);
|
113
|
+
|
114
|
+
return {
|
115
|
+
items: data?.data || <StockInventoryResult>{},
|
116
|
+
isLoading,
|
117
|
+
isError: error,
|
118
|
+
};
|
119
|
+
}
|
120
|
+
|
121
|
+
// getStockOperationItemsCost
|
122
|
+
export function useStockOperationItemsCost(filter: string) {
|
123
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockoperationitemcost?v=default&stockOperationUuid=${filter}`;
|
124
|
+
const { data, error, isLoading } = useSWR<
|
125
|
+
{
|
126
|
+
data: PageableResult<StockOperationItemCost>;
|
127
|
+
},
|
128
|
+
Error
|
129
|
+
>(apiUrl, openmrsFetch);
|
130
|
+
return {
|
131
|
+
items: data.data ? data.data : [],
|
132
|
+
isLoading,
|
133
|
+
isError: error,
|
134
|
+
};
|
135
|
+
}
|
136
|
+
|
137
|
+
// getStockBatches
|
138
|
+
export function useStockBatches(filter: StockBatchFilter) {
|
139
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockbatch${toQueryParams(
|
140
|
+
filter
|
141
|
+
)}`;
|
142
|
+
const { data, error, isLoading } = useSWR<
|
143
|
+
{
|
144
|
+
data: PageableResult<StockBatchDTO>;
|
145
|
+
},
|
146
|
+
Error
|
147
|
+
>(apiUrl, openmrsFetch);
|
148
|
+
return {
|
149
|
+
items: data?.data || <PageableResult<StockBatchDTO>>{},
|
150
|
+
isLoading,
|
151
|
+
isError: error,
|
152
|
+
};
|
153
|
+
}
|
154
|
+
|
155
|
+
// getStockItemPackagingUOMs
|
156
|
+
export function useStockItemPackagingUOMs(filter: StockItemPackagingUOMFilter) {
|
157
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockitempackaginguom${toQueryParams(
|
158
|
+
filter
|
159
|
+
)}`;
|
160
|
+
const { data, error, isLoading } = useSWR<
|
161
|
+
{
|
162
|
+
data: PageableResult<StockItemPackagingUOMDTO>;
|
163
|
+
},
|
164
|
+
Error
|
165
|
+
>(apiUrl, openmrsFetch);
|
166
|
+
|
167
|
+
return {
|
168
|
+
items: data?.data || <PageableResult<StockItemPackagingUOMDTO>>{},
|
169
|
+
isLoading,
|
170
|
+
isError: error,
|
171
|
+
};
|
172
|
+
}
|
173
|
+
|
174
|
+
// getStockItem
|
175
|
+
export function useStockItem(id: string) {
|
176
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockitem/${id}?v=full`;
|
177
|
+
const { data, error, isLoading } = useSWR<
|
178
|
+
{
|
179
|
+
data: StockItemDTO;
|
180
|
+
},
|
181
|
+
Error
|
182
|
+
>(apiUrl, openmrsFetch);
|
183
|
+
return {
|
184
|
+
item: data?.data || <StockItemDTO>{},
|
185
|
+
isLoading,
|
186
|
+
isError: error,
|
187
|
+
};
|
188
|
+
}
|
189
|
+
|
190
|
+
// deleteStockItems
|
191
|
+
export function deleteStockItems(ids: string[]) {
|
192
|
+
let otherIds = ids.reduce((p, c, i) => {
|
193
|
+
if (i === 0) return p;
|
194
|
+
p += (p.length > 0 ? "," : "") + encodeURIComponent(c);
|
195
|
+
return p;
|
196
|
+
}, "");
|
197
|
+
if (otherIds.length > 0) {
|
198
|
+
otherIds = "?ids=" + otherIds;
|
199
|
+
}
|
200
|
+
|
201
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockitem/${ids[0]}${otherIds}`;
|
202
|
+
|
203
|
+
const abortController = new AbortController();
|
204
|
+
|
205
|
+
return openmrsFetch(apiUrl, {
|
206
|
+
method: "DELETE",
|
207
|
+
headers: {
|
208
|
+
"Content-Type": "application/json",
|
209
|
+
},
|
210
|
+
signal: abortController.signal,
|
211
|
+
});
|
212
|
+
}
|
213
|
+
|
214
|
+
// deleteStockItemPackagingUnit
|
215
|
+
export function deleteStockItemPackagingUnit(id: string) {
|
216
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockitempackaginguom/${id}`;
|
217
|
+
const abortController = new AbortController();
|
218
|
+
|
219
|
+
return openmrsFetch(apiUrl, {
|
220
|
+
method: "DELETE",
|
221
|
+
headers: {
|
222
|
+
"Content-Type": "application/json",
|
223
|
+
},
|
224
|
+
signal: abortController.signal,
|
225
|
+
});
|
226
|
+
}
|
227
|
+
|
228
|
+
// createStockItem
|
229
|
+
export function createStockItem(item: StockItemDTO) {
|
230
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockitem`;
|
231
|
+
const abortController = new AbortController();
|
232
|
+
delete item.isDrug;
|
233
|
+
return openmrsFetch(apiUrl, {
|
234
|
+
method: "POST",
|
235
|
+
headers: {
|
236
|
+
"Content-Type": "application/json",
|
237
|
+
},
|
238
|
+
signal: abortController.signal,
|
239
|
+
body: item,
|
240
|
+
});
|
241
|
+
}
|
242
|
+
|
243
|
+
// updateStockItem
|
244
|
+
export function updateStockItem(item: StockItemDTO) {
|
245
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockitem/${item.uuid}`;
|
246
|
+
const abortController = new AbortController();
|
247
|
+
delete item.isDrug;
|
248
|
+
delete item.dateCreated;
|
249
|
+
return openmrsFetch(apiUrl, {
|
250
|
+
method: "POST",
|
251
|
+
headers: {
|
252
|
+
"Content-Type": "application/json",
|
253
|
+
},
|
254
|
+
signal: abortController.signal,
|
255
|
+
body: item,
|
256
|
+
});
|
257
|
+
}
|
258
|
+
|
259
|
+
// createStockItemPackagingUnit
|
260
|
+
export function createStockItemPackagingUnit(item: StockItemPackagingUOMDTO) {
|
261
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockitempackaginguom`;
|
262
|
+
const abortController = new AbortController();
|
263
|
+
return openmrsFetch(apiUrl, {
|
264
|
+
method: "POST",
|
265
|
+
headers: {
|
266
|
+
"Content-Type": "application/json",
|
267
|
+
},
|
268
|
+
signal: abortController.signal,
|
269
|
+
body: item,
|
270
|
+
});
|
271
|
+
}
|
272
|
+
|
273
|
+
// updateStockItemPackagingUnit
|
274
|
+
export function updateStockItemPackagingUnit(item: StockItemDTO, uuid: string) {
|
275
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockitempackaginguom/${uuid}`;
|
276
|
+
const abortController = new AbortController();
|
277
|
+
return openmrsFetch(apiUrl, {
|
278
|
+
method: "POST",
|
279
|
+
headers: {
|
280
|
+
"Content-Type": "application/json",
|
281
|
+
},
|
282
|
+
signal: abortController.signal,
|
283
|
+
body: item,
|
284
|
+
});
|
285
|
+
}
|
286
|
+
|
287
|
+
// importStockItem
|
288
|
+
export function importStockItem(item: FormData) {
|
289
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockitemimport`;
|
290
|
+
const abortController = new AbortController();
|
291
|
+
return openmrsFetch(apiUrl, {
|
292
|
+
method: "POST",
|
293
|
+
headers: {
|
294
|
+
"Content-Type": "application/json",
|
295
|
+
},
|
296
|
+
signal: abortController.signal,
|
297
|
+
body: item,
|
298
|
+
});
|
299
|
+
}
|
300
|
+
|
301
|
+
// stock rules
|
302
|
+
// getStockRules
|
303
|
+
export function useStockRules(filter: StockRuleFilter) {
|
304
|
+
console.warn("Rules filter: " + JSON.stringify(filter));
|
305
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockrule${toQueryParams(filter)}`;
|
306
|
+
const { data, error, isLoading } = useSWR<
|
307
|
+
{
|
308
|
+
data: PageableResult<StockRule>;
|
309
|
+
},
|
310
|
+
Error
|
311
|
+
>(apiUrl, openmrsFetch);
|
312
|
+
|
313
|
+
// return {
|
314
|
+
// items: data.data ? data.data : [],
|
315
|
+
// isLoading,
|
316
|
+
// isError: error,
|
317
|
+
// };
|
318
|
+
|
319
|
+
return {
|
320
|
+
items: data?.data || <PageableResult<StockRule>>{},
|
321
|
+
isLoading,
|
322
|
+
isError: error,
|
323
|
+
};
|
324
|
+
}
|
325
|
+
|
326
|
+
// createStockRule
|
327
|
+
export function createStockRule(item: StockRule) {
|
328
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockrule`;
|
329
|
+
const abortController = new AbortController();
|
330
|
+
return openmrsFetch(apiUrl, {
|
331
|
+
method: "POST",
|
332
|
+
headers: {
|
333
|
+
"Content-Type": "application/json",
|
334
|
+
},
|
335
|
+
signal: abortController.signal,
|
336
|
+
body: item,
|
337
|
+
});
|
338
|
+
}
|
339
|
+
|
340
|
+
// updateStockRule
|
341
|
+
export function updateStockRule(item: StockRule, uuid: string) {
|
342
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockrule/${uuid}`;
|
343
|
+
const abortController = new AbortController();
|
344
|
+
return openmrsFetch(apiUrl, {
|
345
|
+
method: "POST",
|
346
|
+
headers: {
|
347
|
+
"Content-Type": "application/json",
|
348
|
+
},
|
349
|
+
signal: abortController.signal,
|
350
|
+
body: item,
|
351
|
+
});
|
352
|
+
}
|
353
|
+
|
354
|
+
// deleteStockRule
|
355
|
+
export function deleteStockRule(id: string) {
|
356
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockrule/${id}`;
|
357
|
+
const abortController = new AbortController();
|
358
|
+
return openmrsFetch(apiUrl, {
|
359
|
+
method: "DELETE",
|
360
|
+
headers: {
|
361
|
+
"Content-Type": "application/json",
|
362
|
+
},
|
363
|
+
signal: abortController.signal,
|
364
|
+
});
|
365
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { StockItemDTO } from "../core/api/types/stockItem/StockItem";
|
2
|
+
import { StockOperationDTO } from "../core/api/types/stockOperation/StockOperationDTO";
|
3
|
+
|
4
|
+
export type SaveStockItem = (item: StockItemDTO) => Promise<void>;
|
5
|
+
export type SaveStockOperation = (item: StockOperationDTO) => Promise<void>;
|
6
|
+
export type SaveStockOperationAction = (
|
7
|
+
item: StockOperationDTO
|
8
|
+
) => Promise<void>;
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import { z } from "zod";
|
2
|
+
|
3
|
+
const nullableString = z.string().max(255).nullish();
|
4
|
+
|
5
|
+
// Stock item details
|
6
|
+
export const stockItemDetailsSchema = z
|
7
|
+
.object({
|
8
|
+
isDrug: z.boolean(),
|
9
|
+
drugUuid: z.string().nullish(),
|
10
|
+
drugName: z.string().nullish(),
|
11
|
+
commonName: nullableString,
|
12
|
+
acronym: nullableString,
|
13
|
+
hasExpiration: z.boolean(),
|
14
|
+
expiryNotice: z.coerce.number().nullish(),
|
15
|
+
uuid: z.string().nullish(),
|
16
|
+
conceptUuid: z.string().nullish(),
|
17
|
+
conceptName: z.string().nullish(),
|
18
|
+
preferredVendorUuid: z.string().nullish(),
|
19
|
+
preferredVendorName: z.string().nullish(),
|
20
|
+
purchasePrice: z.number().nullish(),
|
21
|
+
purchasePriceUoMUuid: z.string().nullish(),
|
22
|
+
purchasePriceUoMName: z.string().nullish(),
|
23
|
+
categoryUuid: z.string().nullish(),
|
24
|
+
categoryName: z.string().nullish(),
|
25
|
+
dispensingUnitUuid: z.string().nullish(),
|
26
|
+
dispensingUnitName: z.string().nullish(),
|
27
|
+
dispensingUnitPackagingUoMUuid: z.string().nullish(),
|
28
|
+
dispensingUnitPackagingUoMName: z.string().nullish(),
|
29
|
+
defaultStockOperationsUoMUuid: z.string().nullish(),
|
30
|
+
defaultStockOperationsUoMName: z.string().nullish(),
|
31
|
+
reorderLevel: z.number().nullish(),
|
32
|
+
reorderLevelUoMUuid: z.string().nullish(),
|
33
|
+
reorderLevelUoMName: z.string().nullish(),
|
34
|
+
dateCreated: z.coerce.date().nullish(),
|
35
|
+
creatorGivenName: z.string().nullish(),
|
36
|
+
creatorFamilyName: z.string().nullish(),
|
37
|
+
voided: z.boolean().nullish(),
|
38
|
+
})
|
39
|
+
.refine(
|
40
|
+
({ isDrug, drugUuid }) => {
|
41
|
+
return isDrug ? !!drugUuid : true;
|
42
|
+
},
|
43
|
+
{
|
44
|
+
message: "Drug required",
|
45
|
+
path: ["drugUuid"],
|
46
|
+
}
|
47
|
+
)
|
48
|
+
.refine(
|
49
|
+
({ isDrug, dispensingUnitUuid }) => {
|
50
|
+
return isDrug ? !!dispensingUnitUuid : true;
|
51
|
+
},
|
52
|
+
{
|
53
|
+
message: "Dispensing Unit required",
|
54
|
+
path: ["dispensingUnitUuid"],
|
55
|
+
}
|
56
|
+
)
|
57
|
+
.refine(
|
58
|
+
({ hasExpiration, expiryNotice }) => {
|
59
|
+
return hasExpiration ? !!expiryNotice : true;
|
60
|
+
},
|
61
|
+
{
|
62
|
+
message: "Expiry Notice required",
|
63
|
+
path: ["expiryNotice"],
|
64
|
+
}
|
65
|
+
);
|
66
|
+
|
67
|
+
export type StockItemFormData = z.infer<typeof stockItemDetailsSchema>;
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { useStockLocationPages } from "./stock-locations-table.resource";
|
3
|
+
import {
|
4
|
+
Button,
|
5
|
+
DataTableSkeleton,
|
6
|
+
TableToolbarAction,
|
7
|
+
TableToolbarMenu,
|
8
|
+
TableToolbarSearch,
|
9
|
+
Tile,
|
10
|
+
} from "@carbon/react";
|
11
|
+
import styles from "../stock-items/stock-items-table.scss";
|
12
|
+
import { ResourceRepresentation } from "../core/api/api";
|
13
|
+
import DataList from "../core/components/table/table.component";
|
14
|
+
import { useTranslation } from "react-i18next";
|
15
|
+
|
16
|
+
interface StockLocationsTableProps {
|
17
|
+
status?: string;
|
18
|
+
}
|
19
|
+
|
20
|
+
const StockLocationsItems: React.FC<StockLocationsTableProps> = () => {
|
21
|
+
const { t } = useTranslation();
|
22
|
+
|
23
|
+
const { tableHeaders, tableRows, items, isLoadingLocations } =
|
24
|
+
useStockLocationPages({
|
25
|
+
v: ResourceRepresentation.Full,
|
26
|
+
});
|
27
|
+
|
28
|
+
const handleRefresh = () => {
|
29
|
+
// search.refetch()
|
30
|
+
};
|
31
|
+
|
32
|
+
const createStockItem = () => {
|
33
|
+
// search.refetch()
|
34
|
+
};
|
35
|
+
|
36
|
+
if (isLoadingLocations) {
|
37
|
+
return <DataTableSkeleton role="progressbar" />;
|
38
|
+
}
|
39
|
+
|
40
|
+
if (items?.length) {
|
41
|
+
return (
|
42
|
+
<DataList columns={tableHeaders} data={tableRows}>
|
43
|
+
{({ onInputChange }) => (
|
44
|
+
<>
|
45
|
+
<TableToolbarSearch persistent onChange={onInputChange} />
|
46
|
+
<TableToolbarMenu>
|
47
|
+
<TableToolbarAction onClick={handleRefresh}>
|
48
|
+
Refresh
|
49
|
+
</TableToolbarAction>
|
50
|
+
</TableToolbarMenu>
|
51
|
+
<Button onClick={createStockItem} size="md" kind="primary">
|
52
|
+
{t("stockmanagement.addnewlocation", "Add Location")}
|
53
|
+
</Button>
|
54
|
+
</>
|
55
|
+
)}
|
56
|
+
</DataList>
|
57
|
+
);
|
58
|
+
}
|
59
|
+
|
60
|
+
return (
|
61
|
+
<div className={styles.tileContainer}>
|
62
|
+
<Tile className={styles.tile}>
|
63
|
+
<p className={styles.content}>No stock items to display</p>
|
64
|
+
</Tile>
|
65
|
+
</div>
|
66
|
+
);
|
67
|
+
};
|
68
|
+
|
69
|
+
export default StockLocationsItems;
|