$reff = 1; $catalog_specimen_list = get_specimen_types_catalog($lab_config_id, $reff); foreach ($catalog_specimen_list as $specimen_typeid => $specimen_name) { if (isset($_REQUEST['s_type_' . $specimen_typeid])) { $specimen_list[] = $specimen_typeid; } } # Add test type record //function add_test_type($test_name, $test_descr, $clinical_data, $cat_code, $is_panel, $specimen_list=array(), $lab_config_id, $hide_patient_name) $test_type_id = ""; if (count($specimen_list) != 0) { # Add entries to 'specimen_test' map table $test_type_id = add_test_type($test_name, $test_descr, $test_clinical_data, $cat_code, $is_panel, $lab_config_id, $hide_patient_name, $prevalenceThreshold, $targetTat, $specimen_list); } else { # No specimens selected. Add test anyway $test_type_id = add_test_type($test_name, $test_descr, $test_clinical_data, $cat_code, $is_panel, $lab_config_id, $hide_patient_name, $prevalenceThreshold, $targetTat); } if ($newCostToPatient > 0 && is_billing_enabled($_SESSION['lab_config_id'])) { // If the cost is greater than 0, we go ahead and add the cost. If not, there's no reason to make another sql call here. It'll be done elsewhere. instantiate_new_cost_of_test_type($newCostToPatient, $test_type_id); } enable_new_test($_SESSION['lab_config_id'], $test_type_id); # Merge added_measure_list and added_submeasures_list $add_measr = $added_measures_list; $merged_list = array_merge($added_measures_list, $added_submeasures_list); sort($merged_list); /* echo "<br>"; print_r($added_measures_list); echo "<br>"; print_r($added_submeasures_list);
function import_test_between_labs($test_id, $from_id, $to_id) { //echo "<pre>"; $tt = new TestType(); $test_type = new TestType(); $saved_db = DbUtil::switchToLabConfig($from_id); $test_type = $tt->getById($test_id); //print_r($test_obj); $measure_objs = $test_type->getMeasures(); //print_r($measure_objs); DbUtil::switchRestore($saved_db); $saved_db = DbUtil::switchToLabConfig($to_id); //$test_type->testTypeId; $test_name = $test_type->name; $test_descr = $test_type->description; $clinical_data = $test_type->clinical_data; $cat_code = $test_type->testCategoryId; $hide_patient_name = $test_type->hidePatientName; $prevalenceThreshold = $test_type->prevalenceThreshold; $targetTat = $test_type->targetTat; $is_panel = $test_type->isPanel; $lab_config_id = $to_id; $new_test_id = add_test_type($test_name, $test_descr, $clinical_data, $cat_code, $is_panel, $lab_config_id, $hide_patient_name, $prevalenceThreshold, $targetTat); $subm_flags = array(); $id_list = array(); foreach ($measure_objs as $mo) { if ($mo->checkIfSubmeasure() == 0) { if ($mo->getRangeType() == Measure::$RANGE_NUMERIC) { $m_id = add_measure($mo->name, $mo->range, $mo->unit); array_push($id_list, $m_id); if ($mo->range == ':') { //$ref = new ReferenceRange(); $refs = $mo->getReferenceRanges($from_id); foreach ($refs as $ref) { $ref->measureId = $m_id; $ref->addToDb($to_id); } } } else { $m_id = add_measure($mo->name, $mo->range, $mo->unit); array_push($id_list, $m_id); } } else { $dec_name = $mo->truncateSubmeasureTag(); $enc_name = "\$sub*" . $m_id . "/\$" . $dec_name; $sm_id = add_measure($enc_name, $mo->range, $mo->unit); array_push($id_list, $sm_id); } } foreach ($id_list as $measure_id) { add_test_type_measure($new_test_id, $measure_id); } DbUtil::switchRestore($saved_db); //echo "<pre>"; }