some fix to order master and details after patient is discharged