-
Notifications
You must be signed in to change notification settings - Fork 6
Improve use of already calculated constraints #116
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
Conversation
…lation, working on percentage setting of dose quantity
…ated constraints, remove need to recacl min-max
Greptile OverviewGreptile SummaryThis PR introduces a calculated constraints tracking system to improve order processing efficiency. The key architectural change is adding a Key Changes:
Issues Found:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant OrderProcessor
participant Order
participant OrderVariable
participant Variable
Note over Client,Variable: Calculated Constraints Flow
Client->>OrderProcessor: CalcMinMax Command
OrderProcessor->>Order: applyConstraints()
Order->>OrderVariable: applyConstraints()
OrderVariable->>OrderVariable: Check if Calculated is set
alt Calculated constraints exist
OrderVariable->>OrderVariable: applyCalculatedConstraints()
else No calculated constraints
OrderVariable->>OrderVariable: Apply regular Constraints
end
OrderProcessor->>Order: calcMinMax()
Order->>Variable: solveMinMax()
Variable-->>Order: Solved order with min/max
OrderProcessor->>Order: setCalculatedConstraints()
Order->>OrderVariable: setCalculatedConstraints()
OrderVariable->>OrderVariable: Store Variable.Values as Calculated
OrderProcessor->>Order: increaseIncrements()
Order->>Variable: increaseIncrement()
Variable->>Variable: Filter increments > current
Variable-->>Order: Updated increments
OrderProcessor->>Order: solveNormDose()
Order->>Order: hasNormDose()
alt Has norm dose
Order->>Order: setNormDose()
end
Order-->>Client: Result with calculated constraints
Note over Client,Variable: Property Change Flow
Client->>OrderProcessor: ChangeProperty Command
OrderProcessor->>OrderProcessor: processChangeProperty()
OrderProcessor->>Order: Apply property changes
Order->>OrderVariable: setPercValue() / setMinValue() / etc
OrderProcessor->>Order: calcMinMax()
Order-->>Client: Updated order
|
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.
5 files reviewed, 7 comments
| // |> solveMinMax "Order Property Set Frequency" printErr logger | ||
| // step to a min, median or max value | ||
| |> Result.map (OrderPropertyChange.proc [ ScheduleFrequency step ]) | ||
| // |> Result.map (OrderPropertyChange.proc [ ScheduleFrequency step ]) | ||
| |> OrderPropertyChange.proc [ ScheduleFrequency step ] | ||
| |> Ok |
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.
commented-out code should be removed rather than kept in the codebase
| // |> solveMinMax "Order Property Set Frequency" printErr logger | |
| // step to a min, median or max value | |
| |> Result.map (OrderPropertyChange.proc [ ScheduleFrequency step ]) | |
| // |> Result.map (OrderPropertyChange.proc [ ScheduleFrequency step ]) | |
| |> OrderPropertyChange.proc [ ScheduleFrequency step ] | |
| |> Ok | |
| |> OrderPropertyChange.proc [ ScheduleFrequency step ] | |
| |> Ok |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Informedica.GenORDER.Lib/OrderProcessor.fs
Line: 69:73
Comment:
commented-out code should be removed rather than kept in the codebase
```suggestion
|> OrderPropertyChange.proc [ ScheduleFrequency step ]
|> Ok
```
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.| // re-calc the min max | ||
| |> solveMinMax "Order Property Set Dose Rate" printErr logger | ||
| // |> solveMinMax "Order Property Set Dose Rate" printErr logger | ||
| // step to a min, median or max rate | ||
| |> Result.map (OrderPropertyChange.proc [ OrderableDose step ]) | ||
|
|
||
| // |> Result.map (OrderPropertyChange.proc [ OrderableDose step ]) | ||
| |> OrderPropertyChange.proc [ OrderableDose step ] | ||
| |> Ok |
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.
commented-out code should be removed
| // re-calc the min max | |
| |> solveMinMax "Order Property Set Dose Rate" printErr logger | |
| // |> solveMinMax "Order Property Set Dose Rate" printErr logger | |
| // step to a min, median or max rate | |
| |> Result.map (OrderPropertyChange.proc [ OrderableDose step ]) | |
| // |> Result.map (OrderPropertyChange.proc [ OrderableDose step ]) | |
| |> OrderPropertyChange.proc [ OrderableDose step ] | |
| |> Ok | |
| |> OrderPropertyChange.proc [ OrderableDose step ] | |
| |> Ok |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Informedica.GenORDER.Lib/OrderProcessor.fs
Line: 112:117
Comment:
commented-out code should be removed
```suggestion
|> OrderPropertyChange.proc [ OrderableDose step ]
|> Ok
```
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.| OrderableDoseCount OrderVariable.Count.applyConstraints | ||
| ] | ||
| // re-calc min max | ||
| |> solveMinMax "Order Property Set Dose Quantity" printErr logger | ||
| // |> solveMinMax "Order Property Set Dose Quantity" printErr logger | ||
| // step to a min, median or max dose quantity | ||
| |> Result.map (OrderPropertyChange.proc [ OrderableDose step ]) | ||
| // |> Result.map (OrderPropertyChange.proc [ OrderableDose step ]) | ||
| |> OrderPropertyChange.proc [ OrderableDose step ] | ||
| |> Ok |
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.
commented-out code should be removed
| OrderableDoseCount OrderVariable.Count.applyConstraints | |
| ] | |
| // re-calc min max | |
| |> solveMinMax "Order Property Set Dose Quantity" printErr logger | |
| // |> solveMinMax "Order Property Set Dose Quantity" printErr logger | |
| // step to a min, median or max dose quantity | |
| |> Result.map (OrderPropertyChange.proc [ OrderableDose step ]) | |
| // |> Result.map (OrderPropertyChange.proc [ OrderableDose step ]) | |
| |> OrderPropertyChange.proc [ OrderableDose step ] | |
| |> Ok | |
| |> OrderPropertyChange.proc [ OrderableDose step ] | |
| |> Ok |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Informedica.GenORDER.Lib/OrderProcessor.fs
Line: 169:176
Comment:
commented-out code should be removed
```suggestion
|> OrderPropertyChange.proc [ OrderableDose step ]
|> Ok
```
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.| ] | ||
| // re-calc min max | ||
| // |> solveMinMax "Order Property Set Dose Quantity" printErr logger | ||
| // step to a min, median or max dose quantity | ||
| // |> Result.map (OrderPropertyChange.proc [ OrderableDose step ]) | ||
| |> OrderPropertyChange.proc [ OrderableDose step ] | ||
| |> Ok |
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.
commented-out code should be removed
| ] | |
| // re-calc min max | |
| // |> solveMinMax "Order Property Set Dose Quantity" printErr logger | |
| // step to a min, median or max dose quantity | |
| // |> Result.map (OrderPropertyChange.proc [ OrderableDose step ]) | |
| |> OrderPropertyChange.proc [ OrderableDose step ] | |
| |> Ok | |
| |> OrderPropertyChange.proc [ OrderableDose step ] | |
| |> Ok |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Informedica.GenORDER.Lib/OrderProcessor.fs
Line: 198:204
Comment:
commented-out code should be removed
```suggestion
|> OrderPropertyChange.proc [ OrderableDose step ]
|> Ok
```
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.| os.OrderIsSolved |> not //&& | ||
| //os.HasValues |> not |
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.
commented-out condition should be removed or documented
| os.OrderIsSolved |> not //&& | |
| //os.HasValues |> not | |
| os.OrderIsSolved |> not |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Informedica.GenORDER.Lib/OrderProcessor.fs
Line: 724:725
Comment:
commented-out condition should be removed or documented
```suggestion
os.OrderIsSolved |> not
```
How can I resolve this? If you propose a fix, please make it concise.| |> Result.map (OrderPropertyChange.proc [ ComponentOrderableQuantity (cmp, step) ]) | ||
| // |> OrderPropertyChange.proc [ ComponentOrderableQuantity (cmp, step) ] | ||
| // |> Ok |
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.
commented-out code should be removed
| |> Result.map (OrderPropertyChange.proc [ ComponentOrderableQuantity (cmp, step) ]) | |
| // |> OrderPropertyChange.proc [ ComponentOrderableQuantity (cmp, step) ] | |
| // |> Ok | |
| |> Result.map (OrderPropertyChange.proc [ ComponentOrderableQuantity (cmp, step) ]) |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Informedica.GenORDER.Lib/OrderProcessor.fs
Line: 329:331
Comment:
commented-out code should be removed
```suggestion
|> Result.map (OrderPropertyChange.proc [ ComponentOrderableQuantity (cmp, step) ])
```
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.
Additional Comments (1)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! Prompt To Fix With AIThis is a comment left during a code review.
Path: src/Informedica.GenORDER.Lib/OrderProcessor.fs
Line: 282:331
Comment:
inconsistent error handling approach - other property setter functions (`orderPropertySetFrequency`, `orderPropertySetDoseRate`, `orderPropertySetDoseQuantity`) now return `Ok` directly without calling `solveMinMax`, but this function still uses `Result.bind` pattern. Consider aligning with the new pattern or documenting why this needs different handling
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise. |
This pull request introduces several enhancements and refactorings to the
OrderandOrderProcessormodules, focusing on improved constraint handling, dose normalization, and table output formatting. It adds new utility functions for applying and setting calculated constraints, refines how orders are processed when properties change, and streamlines table output for better logging and debugging. Additionally, new script files are included in the project.Constraint and Dose Handling Improvements:
applyOnlyMaxConstraints,applyCalculatedConstraints, andsetCalculatedConstraintsfunctions to theOrdermodule, enabling more precise application and management of constraints on doses and orders. [1] [2] [3]hasNormDoseand improvedsetNormDoselogic to better handle normalization of doses based on order schedules and components. [1] [2]Order Property Processing Enhancements:
OrderProcessorto use new constraint application functions and to process property changes in a more functional, composable way (e.g., always returningOk, not using intermediateResult.map). AddedorderPropertySetDoseQuantityPercfor setting dose quantity by percentage. [1] [2] [3]Console Table and Logging Refactor:
printTablewithtoConsoleTable, addedtoConsoleTableString, and updated logging to use these new functions for clearer, more informative output. [1] [2] [3] [4] [5]Increment and Calculation Adjustments:
@greptile: review
calcMinMaxto remove theincreaseIncrementparameter. [1] [2] [3] [4]Project Structure:
Constraints.fsxandNormDose.fsxto the project file for improved testing and documentation.