public static function createBillForTests($tests, $lab_config_id) { # Create a new bill and associate all of the desired tests with it. // The way we call the bill constructor here is awkward and assumes that the tests are all for the same patient. // While that's true for now, it's not necessarily going to stay that way, so this may need to be revisited. -Robert. $bill = new Bill(Specimen::getById($tests[0]->specimenId)->patientId); $bill->create($lab_config_id); foreach ($tests as $test) { $association = new BillsTestsAssociationObject($bill->id, $test->testId); $association->create($lab_config_id); } return $bill; }