Skip to content

Commit

Permalink
remove old dispense and returns history forms, fix qty issue in stock
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Nov 18, 2024
1 parent b9d057d commit b32081b
Show file tree
Hide file tree
Showing 20 changed files with 88 additions and 439 deletions.
23 changes: 14 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,20 @@ Overview
Concepts
++++++++

Task at Central

* order (central)
* receive/label/confirm (central)
* repack/label/confirm (central)
* receive, label as bulk stock, confirm
* repack/decant, label as stock, confirm
* with site stock request, allocate to subject, label for subject
* transfer stock to site

Tasks at Site

* generate stock request PRN (site)
* allocate to subject (central)
* transfer (from central to site)
* verify transfer at site
* dispense to clinican
* dispense to patient (via CRF)
* receive physical stock at site, confirm transfered stock at site
* dispense to clinic/patient
* confirm dispense to patient on CRF

Also:

Expand Down Expand Up @@ -64,8 +69,8 @@ Orders
++++++
Track orders of IMP by recording the LOT # and expiration date.

Repack
++++++
Repack/Decant
+++++++++++++

Create new stock from an existing stock item. The container of the new stock item cannot be the same as the source container.
For example, create bottles of 128 tabs from a single bulk barrel of tablets.
Expand Down
2 changes: 0 additions & 2 deletions edc_pharmacy/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from .autocomplete_admin import SiteProxyAdmin, VisitScheduleAdmin
from .dispensing_history_admin import DispensingHistoryAdmin
from .medication import (
AssignmentAdmin,
DosageGuidelineAdmin,
Expand All @@ -11,7 +10,6 @@
UnitsAdmin,
)
from .prescription import RxAdmin, RxRefillAdmin
from .return_history_admin import ReturnHistoryAdmin
from .stock import (
AllocationAdmin,
ContainerAdmin,
Expand Down
75 changes: 0 additions & 75 deletions edc_pharmacy/admin/dispensing_history_admin.py

This file was deleted.

40 changes: 0 additions & 40 deletions edc_pharmacy/admin/prescription/rx_refill_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from ...admin_site import edc_pharmacy_admin
from ...forms import RxRefillForm
from ...models import RxRefill
from ..dispensing_history_admin import DispensingHistoryInlineAdmin
from ..model_admin_mixin import ModelAdminMixin


Expand All @@ -29,8 +28,6 @@ class RxRefillAdmin(ModelAdminMixin, admin.ModelAdmin):

model = RxRefill

inlines = [DispensingHistoryInlineAdmin]

fieldsets = (
(
None,
Expand Down Expand Up @@ -72,8 +69,6 @@ class RxRefillAdmin(ModelAdminMixin, admin.ModelAdmin):
"dashboard",
"duration",
"description",
"dispense",
"returns",
"prescription",
"active",
"packed",
Expand Down Expand Up @@ -135,41 +130,6 @@ def prescription(self, obj=None):
context = dict(title="Back to RX", url=url, label="Rx")
return render_to_string("dashboard_button.html", context=context)

@admin.display
def dispense(self, obj=None):
add = True if not obj or obj.remaining is None else obj.remaining > 0
if add:
url = reverse("edc_pharmacy_admin:edc_pharmacy_dispensinghistory_add")
url = f"{url}?rx_refill={obj.id}"
disabled = ""
else:
url = "#"
disabled = "disabled"
context = dict(
title="Dispense for this RX item",
url=url,
label="Dispense",
disabled=disabled,
)
dispense_html = render_to_string("dashboard_button.html", context=context)
url = reverse("edc_pharmacy_admin:edc_pharmacy_dispensinghistory_changelist")
url = f"{url}?rx_refill={obj.id}"
context = dict(title="Dispense history for this RX item", url=url, label="History")
dispense_history_html = render_to_string("dashboard_button.html", context=context)
return format_html(f"{dispense_html}<BR>{dispense_history_html}")

@admin.display
def returns(self, obj=None):
url = reverse("edc_pharmacy_admin:edc_pharmacy_returnhistory_add")
url = f"{url}?rx_refill={obj.id}"
context = dict(title="Returns for this RX item", url=url, label="Returns")
returns_html = render_to_string("dashboard_button.html", context=context)
url = reverse("edc_pharmacy_admin:edc_pharmacy_returnhistory_changelist")
url = f"{url}?rx_refill={obj.id}"
context = dict(title="Returns history for this RX item", url=url, label="History")
returns_history_html = render_to_string("dashboard_button.html", context=context)
return format_html(f"{returns_html}<BR>{returns_history_html}")

@admin.display(description="Description of Refill")
def description(self, obj=None):
context = {
Expand Down
59 changes: 0 additions & 59 deletions edc_pharmacy/admin/return_history_admin.py

This file was deleted.

1 change: 0 additions & 1 deletion edc_pharmacy/dispense/__init__.py

This file was deleted.

44 changes: 0 additions & 44 deletions edc_pharmacy/dispense/dispensing.py

This file was deleted.

5 changes: 0 additions & 5 deletions edc_pharmacy/forms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
from .dispensing_history_form import (
DispensingHistoryForm,
DispensingHistoryReadonlyForm,
)
from .medication import DosageGuidelineForm, FormulationForm, MedicationForm
from .prescription import RxForm, RxRefillForm
from .return_history_form import ReturnHistoryForm
from .stock import (
ContainerForm,
ContainerTypeForm,
Expand Down
40 changes: 0 additions & 40 deletions edc_pharmacy/forms/dispensing_history_form.py

This file was deleted.

9 changes: 0 additions & 9 deletions edc_pharmacy/forms/return_history_form.py

This file was deleted.

7 changes: 5 additions & 2 deletions edc_pharmacy/forms/stock/receive_item_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ def clean(self):

# in unit_qty's
if cleaned_data.get("qty"):
qty_ordered = cleaned_data.get("order_item").unit_qty
# TODO: clean this up
qty_ordered = (
cleaned_data.get("order_item").unit_qty
+ cleaned_data.get("order_item").unit_qty_received
)
qty_already_received = self._meta.model.objects.filter(
order_item=cleaned_data.get("order_item")
).aggregate(unit_qty=Sum("unit_qty"))["unit_qty"] or Decimal(0)
qty_available = qty_ordered - qty_already_received
qty_to_receive = cleaned_data.get("qty") * cleaned_data.get("container").qty

if qty_to_receive > qty_available:
raise forms.ValidationError(
{
Expand Down
Empty file.
Empty file.
10 changes: 10 additions & 0 deletions edc_pharmacy/management/commands/update_initial_pharmacy_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.core.management import BaseCommand
from meta_pharmacy.utils import update_initial_pharmacy_data


class Command(BaseCommand):

def handle(self, *args, **options):
"""This is an example of an initial set of data"""
update_initial_pharmacy_data()
print("Done")
Loading

0 comments on commit b32081b

Please sign in to comment.