feat (medication-item): add qty calculation if intervalMultiplier is not nil
This commit is contained in:
@@ -29,4 +29,15 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.MedicationItem) {
|
||||
data.IsRedeemed = inputSrc.IsRedeemed
|
||||
data.Quantity = inputSrc.Quantity
|
||||
data.Note = inputSrc.Note
|
||||
|
||||
if inputSrc.IntervalMultiplier != nil {
|
||||
data.Quantity = countQty(*inputSrc)
|
||||
}
|
||||
}
|
||||
|
||||
func countQty(input e.CreateDto) float64 {
|
||||
if input.Frequency != nil && input.Dose != 0 && input.IntervalMultiplier != nil {
|
||||
return (float64(*input.Frequency) * float64(input.Dose)) * float64(*input.IntervalMultiplier)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user