function getParametersFromRx($refraction, $toric, $vertex = null) { $rx = rxStringBreaker($refraction); if ($rx->isValidRx() != 1) { return null; } if ($vertex === 1) { $rx = $rx->diffVertex(0); } $params[sph] = $rx->sphM(); $params[cylinder] = $rx->cylM(); if ($toric === 0) { $params[sph] = $params[sph] + 0.5 * $params[cylinder]; //$params[toric] = 0; } else { if ($params[cylinder] < -0.75) { if ($rx->isOblique() == 1) { $params[oblique] = 1; } $params[toric] = 1; } } return $params; }
function findCLsByPower($params) { //print_r($params); // echo "findCLsByPower"; $toric = $params['toric']; $bifocal = $params['bifocal']; $refraction = $params['refraction'][0]; $clRx = $params['clRx'][0]; //echo "findCLsByPower"; $error_msg = array(); if (!isset($refraction) || !isset($clRx)) { $error_msg[] = "A refraction is needed!"; } if ($bifocal == 1) { $error_msg[] = "Sorry - Bifocal lenses cannot be searched by refraction or power. Only single vision lenses were returned."; } $params['bifocal'] = 0; //get some info about the desired power if (isset($refraction)) { $mr = rxStringBreaker($refraction); // break it down into an Rx object $bestCLrx = $mr->diffVertex(0); } else { $mr = rxStringBreaker($clRx); $bestCLrx = $mr; } $sphEqiv = $bestCLrx->sphericalEquivalent(); $bestSphericalRx = rxStringBreaker($sphEqiv); //remove the refraction from the $params (we'll be sending the vertexed data instead) unset($params['refraction']); $sphCylRatio = 0; if ($bestCLrx->sphP() != 0) { $sphCylRatio = $bestCLrx->cylP() / abs($bestCLrx->sphP()); } $lenses = array(); if (!isset($toric)) { //if not specified if toric or spherical //find the best spherical lenses first, if necessary if ($bestCLrx->cylP() < 0.62 || $sphCylRatio > 0.15) { $params['toric'] = 0; $params['clRx'][0] = $bestSphericalRx->prettyString(); $lensesSph = $this->getAdvSearch($params); } //get the toric lenses if there's enough cyl if ($bestCLrx->cylP() > 0.62) { $params['toric'] = 1; $params['clRx'][0] = $bestCLrx->prettyString(); $lensesCyl = $this->getAdvSearch($params); } if (isset($lensesSph) && isset($lensesCyl)) { $lenses = array_merge((array) $lenses, (array) $lensesCyl); } else { if (isset($lensesSph)) { $lenses = $lensesSph; } if (isset($lensesCyl)) { $lenses = $lensesCyl; } } } else { // toric IS specified $params['clRx'][0] = $bestCLrx->prettyString(); $lenses = $this->getAdvSearch($params); } //$lenses = $this->getAdvSearch ($params); //print_r ($lenses); // $data = array(); // // $data['msg'] = $error_msg; // $data['lenses'] = $lenses; //print_r($lenses); return $lenses; }
$onlyRx = $_REQUEST["onlyRx"]; if (!isset($onlyRx)) { $onlyRx = 0; } //kind of the opposite - only looks for lenses - does not look for powers $powers = $_REQUEST["powers"]; if (!isset($powers)) { $powers = 0; } //$dataBase = databaseObj(); $return = array(); //check if the string is a number or a +/- sign $tempStr = preg_replace('/\\s+/', '', $q); $isNumber = preg_match('/^[+-.\\d]/', $tempStr); if ($isNumber == 1 && $which == "scl" && $powers != 0) { $rxObj = rxStringBreaker($q); $rxString = $rxObj->prettyString(); $mrRow['id'] = $rxString; $mrRow['label'] = $rxString . " (refraction)"; $mrRow['type'] = "mr"; $mrRow['rx'] = $rxString; $pwrRow['id'] = $rxString; $pwrRow['label'] = $rxString . " (CL power)"; $pwrRow['type'] = "power"; $pwrRow['rx'] = $rxString; array_push($return, $mrRow); array_push($return, $pwrRow); } if ($which == "scl" && $onlyRx != 1) { //break all the words into a single array $phrase_array = explode(" ", $q);
<?php // ini_set('display_errors', 1); // ini_set('log_errors', 1); // ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); // error_reporting(E_ALL); include_once "../phpClasses/RxHelper.php"; include_once "../phpClasses/RxObject.php"; include_once "opticalcrossfunc.php"; $rx = $_REQUEST['rx']; $subscriber = $_REQUEST['subscriber']; $rxObj = rxStringBreaker($rx); $sphEquiv = rxStringBreaker($rxObj->sphericalEquivalent()); $vertexed = $rxObj->diffVertex(0); $vString = $vertexed->prettyStringMinus(); $vSphEquiv = rxStringBreaker($vertexed->sphericalEquivalent()); $params['rxString'] = $rx; $params['bgImage'] = "spherelens"; $vParams['rxString'] = $vString; $vParams['bgImage'] = "lens"; echo "<table><tr><td style='padding: 20px'>"; echo getCrossFromParams($params); echo "</td>\t<td>"; echo "<table>"; echo "<tr><th colspan=2><u>Your Rx</u></th></tr>"; if ($rxObj->isToric()) { echo "<tr><td>Plus Cyl: </td><td> " . $rxObj->prettyStringPlus() . "</td></tr>"; echo "<tr><td>Minus Cyl: </td><td> " . powerLink($rxObj->prettyStringMinus()) . "</td></tr>"; echo "<tr><td>Sph equiv: </td><td> " . powerLink($sphEquiv->prettyString()) . "</td></tr>"; echo "<tr><td>Toric Type: </td><td> " . $rxObj->toricType() . "</td></tr>"; } else {
function findCLsByPower($params) { $toric = $params['toric']; $bifocal = $params['bifocal']; $refraction = $params['refraction'][0]; //echo "findCLsByPower"; $error_msg = array(); if (!$refraction) { $error_msg[] = "A refraction is needed!"; } if ($bifocal == 1) { $error_msg[] = "Sorry - Bifocal lenses cannot be searched by refraction. Only single vision lenses were returned."; } $params['bifocal'] = 0; //get some info about the desired power $mr = rxStringBreaker($refraction); // break it down into an Rx object $bestCLrx = $mr->diffVertex(0); //vertex to the corneal plane $sphEqiv = $bestCLrx->sphericalEquivalent(); $bestSphericalRx = rxStringBreaker($sphEqiv); //remove the refraction from the $params (we'll be sending the vertexed data instead) unset($params['refraction']); if (!isset($toric)) { //not specified if toric or spherical //find the best spherical lenses first $params['toric'] = 0; $params['clRx'][0] = $bestSphericalRx->prettyString(); $lenses = $this->getAdvSearch($params); //get the toric lenses if there's enough cyl if ($bestCLrx->cylP() > 0.62) { $params['toric'] = 1; $params['clRx'][0] = $bestCLrx->prettyString(); $lenses1 = $this->getAdvSearch($params); $lenses = array_merge((array) $lenses, (array) $lenses1); } } else { $params['clRx'][0] = $bestCLrx->prettyString(); $lenses = $this->getAdvSearch($params); } //$lenses = $this->getAdvSearch ($params); //print_r ($lenses); // $data = array(); // // $data['msg'] = $error_msg; // $data['lenses'] = $lenses; return $lenses; }
function getBestCLPowerForParams($refraction, $lensPowerArray, $toric) { //print_r ($lensPowerArray); //echo "<br/>$refraction<br/>"; //get some info about the desired power $mr = rxStringBreaker($refraction); // break it down into an Rx object $bestCLrx = $mr->diffVertex(0); //vertex to the corneal plane $bestSph = $bestCLrx->sphM(); $bestCyl = $bestCLrx->cylM(); $bestAxis = $bestCLrx->axisM(); $targetSph = $bestSph; if ($toric == "") { if ($bestCyl <= -0.75) { $toric = 1; } if ($bestCyl > -0.75) { $toric = 0; } } //an array of lenses rxs that are the closest $bestRxArray = array(); //we'll only want to return the lens that provides the best vision. For each lens we'll //$bestVA = 10000; if ($toric == 0) { //if it's not a toric lens we'll need the spherical equivalent $targetSph = $bestCLrx->sphericalEquivalent(); foreach ($lensPowerArray as $paramList) { $rxArray = array(); //if the parameters are not listed as an array (but are still in a comma-separated list), explode it into an array if (!is_array($paramList['sphere'])) { $paramList['sphere'] = explode(",", $paramList['sphere']); } $rxArray['sphere'] = closestValue($paramList['sphere'], $targetSph); //echo $rxArray['sphere'] ; $rxArray['cylinder'] = null; $rxArray['axis'] = null; $rxArray['baseCurve'] = $paramList['baseCurve']; $rxArray['diameter'] = $paramList['diameter']; //create an RxObject $clRx = new RxObject($rxArray['sphere']); $rxArray['fullRx'] = $clRx->prettyStringMinus(); $rxArray['bestRx'] = $bestCLrx->prettyStringMinus(); //the diff between this Rx and the ideal Rx $rxdiff = $bestCLrx->subtractRx($clRx); $rxArray['rxDiff'] = $rxdiff->prettyStringMinus(); //echo $rxdiff ->prettyStringMinus(); $rxArray['va'] = (int) VAFromCorrection($rxdiff); $rxArray['chartVA'] = eyeChartVA($rxArray['va']); $rxArray['variation'] = $paramList['variation']; array_push($bestRxArray, $rxArray); } } else { if ($toric == 1) { //if it IS a toric lens... foreach ($lensPowerArray as $paramList) { $rxArray = array(); //if the parameters are not listed as an array (but are still in a comma-separated list), explode it into an array if (!is_array($paramList['sphere'])) { $paramList['sphere'] = explode(",", $paramList['sphere']); } if (!is_array($paramList['axis'])) { $paramList['axis'] = explode(",", $paramList['axis']); } if (!is_array($paramList['cylinder'])) { $paramList['cylinder'] = explode(",", $paramList['cylinder']); } //first, find the closest cyl power. $cyl = closestValue($paramList['cylinder'], $bestCyl); //echo "<br/>".$cyl; // If the closest $cyl is less than the $bestCyl the $targetSph will need to be adjusted //echo "<br/>targetSphere1: $targetSph"; $adjSph = $targetSph + ($bestCyl - $cyl) / 2; //echo "<br/>adjSph: $adjSph"; $rxArray['sphere'] = closestValue($paramList['sphere'], $adjSph); $rxArray['cylinder'] = $cyl; $rxArray['axis'] = closestValue($paramList['axis'], $bestAxis); $rxArray['baseCurve'] = $paramList['baseCurve']; $rxArray['diameter'] = $paramList['diameter']; //create an RxObject $clRx = new RxObject($rxArray['sphere'], $rxArray['cylinder'], $rxArray['axis']); $rxArray['fullRx'] = $clRx->prettyStringMinus(); $rxArray['bestRx'] = $bestCLrx->prettyStringMinus(); //the diff between this and the ideal Rx $rxdiff = $bestCLrx->subtractRx($clRx); $rxArray['rxDiff'] = $rxdiff->prettyStringMinus(); $rxArray['va'] = (int) VAFromCorrection($rxdiff); $rxArray['chartVA'] = eyeChartVA($rxArray['va']); $rxArray['variation'] = $paramList['variation']; array_push($bestRxArray, $rxArray); } } } //filter out the outliers $bestRxArray = removeVAOutliers($bestRxArray); //print_r ( $bestRxArray); //echo "<p> </p>"; return $bestRxArray; }
function getCrossFromParams($params) { extract($params); //if (!isset($round) ) $round = .12; if (!isset($totalSize)) { $totalSize = 140; } if (!isset($crossSize)) { $crossSize = $totalSize * 0.8; } $halfCross = $crossSize / 2; $gutter = ($totalSize - $crossSize) / 2; // label: 0= no label, 1=label in given cyl type; 2= both +/- cyl; //3= if minus show minus, if plus show minus and plus if (!isset($label)) { $label = 0; } if (!isset($doVertex)) { $doVertex = null; } if (!isset($doSphEquiv)) { $doSphEquiv = null; } if (!isset($rxString) && !isset($kString)) { return null; } //get the numbers and meridians if an Rx string is passed if (isset($rxString)) { $rxObject = rxStringBreaker($rxString); if ($doVertex == 1) { $rxObject = $rxObject->diffVertex(0); } if ($doSphEquiv == 1) { $rxObject = rxStringBreaker($rxObject->sphericalEquivalent()); } $num1 = numToDiopterString($rxObject->sphP(), 1); $num2 = numToDiopterString($rxObject->sphP() + $rxObject->cylP(), 1); $meridian1 = $rxObject->axisP(); } if (isset($kString)) { // echo "string: " . $kString; $kObject = kStringBreaker($kString); $num1 = numToDiopterString($kObject->pwr1D(), 0) . "<br>(" . numToMMString($kObject->pwr1mm()) . ")"; $num2 = numToDiopterString($kObject->pwr2D(), 0) . "<br>(" . numToMMString($kObject->pwr2mm()) . ")"; $meridian1 = $kObject->meridian1; $meridian2 = $kObject->meridian2; if ($label > 0) { $niceString1 = $kObject->prettyStringD(); } if ($label == 2) { $niceString2 = $kObject->prettyStringMM(); } } if ($label > 0 && isset($rxString)) { if ($label == 1) { $niceString1 = $doVertex == 1 ? $rxObject->prettyStringMinus() : $rxObject->prettyString(); } if ($label == 2) { $niceString1 = $rxObject->prettyStringPlus(); $niceString2 = $rxObject->prettyStringMinus(); } if ($label == 3) { $plusCyl = $rxObject->isPlusCyl(); //the cyl type the original Rx was given in $niceString1 = $rxObject->prettyStringMinus(); if ($plusCyl == 1) { $niceString2 = "(" . $rxObject->prettyStringPlus() . ")"; } } } if (isset($bgImage)) { switch ($bgImage) { case "lens": if (isset($rxObject) && $rxObject->isToric() == 1) { $image = "/images/crosses/toric_lens.png"; } else { $image = "/images/crosses/sphere_lens.png"; } break; case "spherelens": $image = "/images/crosses/sphere_lens.png"; break; case "toriclens": $image = "/images/crosses/toric_lens.png"; break; default: $image = $bgImage; } } //start the html and CSS we'll be returning $html = ""; if (isset($header)) { $html .= "<div class='opticalCrossLabel' style='font-weight:bold; text-align: center; margin: .5em;'>{$header}</div>"; } $canvasCSS = "position: relative; height:" . $totalSize . "px; width: " . $totalSize . "px;"; if (isset($image)) { $canvasCSS .= "background-image: url(" . $image . "); background-repeat:no-repeat;background-position:center; "; } $html .= "<div style='{$canvasCSS}'>"; $labelCSS = "width: 40px; height: 25px; position: absolute; text-align: center;"; //echo("toric " . $rxObject ->isToric() ); //don't need to worry about optical crosses if the lens is spherical if (isset($rxObject) && $rxObject->isToric() == 0) { // a spacer div $html .= "<div style='margin: 0 " . $gutter . "px " . $gutter * 2 . "px; width: " . $crossSize . "px; height: " . $crossSize . "px'> </div>"; $html .= "<div style=' " . $labelCSS . " ; top: " . ($halfCross + 4) . "px; left: " . ($halfCross - 8) . "px; '>"; $html .= numToDiopterString($num1, 1); $html .= "</div>"; } else { //toric lenses //an url to the optical cross images (it will be completed below - we need to calculate the angle to get the correct image) if (!isset($crossImage)) { $crossImage = "http://www.eyedock.com/images/crosses/cross"; } if (!isset($meridian2)) { $meridian2 = fixAxis($meridian1 + 90); } //find the closest 10 deg increment (for the image) $imageAngle = fixAxis($meridian1); $imageAngle = round($imageAngle / 10) * 10; if ($imageAngle > 90) { $imageAngle -= 90; } //echo $imageAngle; $radAngle1 = $meridian1 * (M_PI / 180); $radAngle2 = $meridian2 * (M_PI / 180); $x1 = intval(cos($radAngle1) * ($halfCross + $gutter) + $halfCross) - 6; $y1 = intval(-(sin($radAngle1) * ($halfCross + $gutter)) + $halfCross + $gutter / 2); $x2 = intval(cos($radAngle2) * ($halfCross + $gutter) + $halfCross) - 6; $y2 = intval(-(sin($radAngle2) * ($halfCross + $gutter)) + $halfCross + $gutter / 2); $crossCSS = "width: " . $crossSize . "px; height: " . $crossSize . "px; margin:" . $gutter . "px"; $num1CSS = $labelCSS . "top: " . $y1 . "px; left: " . $x1 . "px; "; $num2CSS = $labelCSS . "top: " . $y2 . "px; left: " . $x2 . "px; "; $num1aCSS = $labelCSS . "bottom: " . ($y1 - $gutter / 2) . "px; right: " . $x1 . "px; "; $num2aCSS = $labelCSS . "bottom: " . ($y2 - $gutter / 2) . "px; right: " . $x2 . "px; "; $html .= "<img style='{$crossCSS}' src='" . $crossImage . $imageAngle . ".png" . "' />"; $html .= "<div class='cross_num1' style='{$num1CSS}' >" . $num1 . "</div>"; $html .= "<div class='cross_num2' style='{$num2CSS}' >" . $num2 . "</div>"; $html .= "<div class='cross_meridian1' style='{$num1aCSS}' >" . numToAxisString($meridian1) . "</div>"; $html .= "<div class='cross_meridian2' style='{$num2aCSS}' >" . numToAxisString($meridian2) . "</div>"; } // end toric lenses / crosses //add the labels, if wanted if (isset($niceString1)) { $css = "width: {$totalSize} px; text-align: center"; $html .= "<div class='opticalCrossLabel' style='{$css}'>" . $niceString1 . "</div>"; if (isset($niceString2)) { $html .= "<div class='opticalCrossLabel' style='{$css}'>" . $niceString2 . "</div>"; } } if ($doVertex == 1) { $html .= "<div class='opticalCrossLabel' style='{$css} ;font-size:smaller;opticalCrossLabel margin: .5em;'>(vertexed) </div>"; } $html .= "</div>"; return $html; }