Skip to content
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

Map mSupply losses and adjustments to eSIGL #166

Open
wlthomson opened this issue Jul 8, 2021 · 1 comment
Open

Map mSupply losses and adjustments to eSIGL #166

wlthomson opened this issue Jul 8, 2021 · 1 comment

Comments

@wlthomson
Copy link
Contributor

wlthomson commented Jul 8, 2021

Requested by IC:

Losses and Adjustments: sum of all inventory adjustments in the period for the district store and every lower level store for this item

Background

The eSIGL column "Losses and Adjustments" ("Pertes et Ajustements") displays data stored in the array field lossesAndAdjustments, where each element is an object, e.g.

[{
  "type": { 
    "id": null,
    "name":"RETOUR_AU_SITE",
    "description": "Retour au site",
    "additive": true,
    "displayOrder": 4
   },
  "quantity":"10"}
}, ...]

where:

  • name is a (unique?) string representing the reason for the adjustment.
  • additive = true represents a positive adjustment, and additive = false a negative adjustment.
  • quantity is a positive integer.

mSupply represents inventory adjustments for items as trans_line records, where:

  • is_from_inventory_adjustment = true.
  • quantity represents the adjustment quantity as a real-valued number.
  • option.title represents the description of the reason for the adjustment.
  • option.type represents the type of adjustment, e.g. option.type = "positiveInventoryAdjustment" represents a positive adjustment, option.type = "negativeInventoryAdjustment" represents a negative adjustment.

Implementation

A few things involved with this one:

  • For a given requisition, aggregating inventory adjustments (grouping by optionID) for each item over the period of the requisition, e.g. psuedo-SQL:
SELECT transact
WHERE transact.type = "invad" 
AND transact.confirmDate BETWEEN requisition.period.startDate - requisition.period.endDate

UNFOLD INTO trans_lines

GROUP trans_lines BY trans_line.item_ID AND trans_line.optionID
  • Mapping real-valued mSupply quantities to postive integers.
  • Mapping mSupply option.type to eSIGL type.name.
@mark-prins
Copy link
Contributor

Can confirm that the losses and adjustments display on the requisition correctly when submitted using postman.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants