-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(feat) O3-3259 Add ability to deduct stock items while performing dispensing medication #107
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please share a gif
src/routes.json
Outdated
@@ -1,7 +1,8 @@ | |||
{ | |||
"backendDependencies": { | |||
"fhir2": ">=1.2", | |||
"webservices.rest": "^2.2.0" | |||
"webservices.rest": "^2.2.0", | |||
"stockmanagement": "^1.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change stockmanagement version to ^1.4.1 >
batchNumber: inventoryItems.batchNumber, | ||
quantity: Math.floor(inventoryItems.quantity), | ||
quantityUoM: inventoryItems.quantityUoM, | ||
expiration: formatDate(new Date(inventoryItems.expiration)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format this to MM/YYYY
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific reason why it should marked that way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really but it looks better when shorter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Date formatting should remain consistent within the application unless there's a strong reason not to, so I think formatDate()
is more likely to be correct here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tend to agree with @ibacher
* Interface for the stock dispense request object. | ||
*/ | ||
export type StockDispenseRequest = { | ||
locationUuid: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this too changes to dispenseLocationUuid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as per the request body and not the response ?
*/ | ||
export type StockDispenseRequest = { | ||
locationUuid: string; | ||
patientUuid: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is just patient,order,encounter,stockItem,stockBatch as per new version of stockmanagement 1.4.0
src/routes.json
Outdated
@@ -1,7 +1,8 @@ | |||
{ | |||
"backendDependencies": { | |||
"fhir2": ">=1.2", | |||
"webservices.rest": "^2.2.0" | |||
"webservices.rest": "^2.2.0", | |||
"stockmanagement": "^1.4.1 " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@donaldkibet won't this mean implementations that don't use stock management will keep getting dependency errors? Is there a middle ground for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with @pirupius , thanks for flagging this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm... We probably do need a way of indicating optional dependencies, though, right, i.e., if this only works with stockmanagement
>= 1.4.1, then we do want some way of flagging that for implementations that do use stockmanagement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing for the backlog: https://openmrs.atlassian.net/browse/O3-3266
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried to relax this with
"stockmanagement": ">=1.4.1"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either way, for now, we can't have it in backend dependencies, because it will create an annoying pop-up for everyone who's not using stock management, hence the ticket.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it then be removed entirely? If yes, how best can we still have this requirement, at least somewhere in the application?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. For now, I don't think we can. We need this feature to properly support that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this needs to be removed for now.
Thanks @donaldkibet ! Looking forward to adding this functionality... I should be able to review this today and will follow up with questions... would it be possible to add a little more details to the ticket about the approach we are taking for this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good @donaldkibet though I added some requests for changes.
Would be great to see some screen shots of this as well when you get a chance.
src/config-schema.ts
Outdated
enableStockDispense: { | ||
_type: Type.Boolean, | ||
_description: 'To enable or disable the deduction of stock during the dispensing process', | ||
_default: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To maintain the same behavior by default, this default value should be false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i agree
src/routes.json
Outdated
@@ -1,7 +1,8 @@ | |||
{ | |||
"backendDependencies": { | |||
"fhir2": ">=1.2", | |||
"webservices.rest": "^2.2.0" | |||
"webservices.rest": "^2.2.0", | |||
"stockmanagement": "^1.4.1 " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with @pirupius , thanks for flagging this.
@@ -0,0 +1,79 @@ | |||
import useSWR from 'swr'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we've started a pattern of calling something "useDispenseStock" but then including multiple different hooks in it, but I think it would be better to get away from this and call this something like stock.resource.tsx or stock-management.resource.tsx. Do you agree @denniskigen @ibacher ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, that's substantially more consistent with every other app in the ecosystem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ibacher ! So @donaldkibet yes, let's please change the name of this file.
/** | ||
* Interface for the stock dispense request object. | ||
*/ | ||
export type StockDispenseRequest = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to include this here instead of in types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was left by mistake, moved to types file
* @param {string} drugUuid - The UUID of the drug. | ||
* @returns {Array} - The inventory items. | ||
*/ | ||
export const useDispenseStock = (drugUuid: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you are setting limit=10, will there be a problem if there are more than 10 matching inventory items?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@slubwama can give us a clear explanation why we need to add this and if its really necessary we find how to pass it from the UI.
@@ -67,6 +77,30 @@ const DispenseForm: React.FC<DispenseFormProps> = ({ | |||
medicationRequestBundle, | |||
config.dispenseBehavior.restrictTotalQuantityDispensed, | |||
); | |||
|
|||
if (config.enableStockDispense) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is breaking up the logic around fulfiller status, can we break this up into a separate "then" block, or at least move it up to line 73, before the "const newFulfillerStatus..." line?
Also, defer to you about the order operations... ie, would you want to move the dispense request before the "saveMedicationRequest" so that you only update the medication request if the stock update is successful? Of course, then you run into the opposite risk: that the stock could be updated and then the dispense fails. Would be great to make this a little more transactional, but, admittedly, that is likely difficult.
@mogoodrich @ibacher made the requested changes. Attached is an image of the changes Kapture.2024-05-24.at.09.22.27.mp4 |
713e06e
to
008f671
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@donaldkibet everything looks good to me, with the exception of the fact that it looks like we are still including the stock management dependency?
@mogoodrich removed the stock management requirement from the backend dependencies until this PR is merged in. I have also update comments on the config to make it explicit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @donaldkibet , LGTM!
Feel free to merge.
Thanks, @mogoodrich |
…pensing medication (#107) (fix bug with stock dispense conditional)
*/ | ||
export const useDispenseStock = (drugUuid: string) => { | ||
const session = useSession(); | ||
const url = `/ws/rest/v1/stockmanagement/stockiteminventory?v=default&totalCount=true&drugUuid=${drugUuid}&includeBatchNo=true&groupBy=LocationStockItemBatchNo&dispenseLocationUuid=${session?.sessionLocation?.uuid}&includeStrength=1&includeConceptRefIds=1&emptyBatch=1&emptyBatchLocationUuid=${session?.sessionLocation?.uuid}&dispenseAtLocation=1`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not to weigh into this after the fact, but, thinking about the TAC call we are on right now, it would be great if, long-term, the stock management module support an FHIR endpoint so that it would hopefully be more standardized.
Requirements
Summary
See https://openmrs.atlassian.net/browse/O3-3259
Screenshots
Related Issue
For the feature to work, the pharmacist has to be given the privileges required to access stock and inventory rest endpoints.
Other