/** * {@inheritdoc} */ public function jsonSerializationDataProvider() { $imageConfig = ImageConfig::createNew()->setGreyscale(false)->setGridlinesByWeight(false)->setScalePercent(200)->setShowExtraCentiles(false); return array(array('Grow\\Client\\Model\\Measurement', array('date' => new DateTime('2014-09-20 01:01:01'), 'imageConfig' => $imageConfig, 'type' => 0, 'value' => 32), '{ "date":"2014-09-20", "imageconfig":{ "greyscale":0, "gridlinesbyweight":0, "scalepercent":200, "showextracentiles":0 }, "type":0, "value":32 }')); }
/** * {@inheritdoc} */ public function getChart($chartIdentifier, DateTime $edd, ImageConfig $imageConfig) { $url = $this->buildQuery(sprintf('/api/Storage/Chart/%s/', $chartIdentifier), array('EDD' => $edd->format('Y-m-d'), 'ImageConfig' => array('Greyscale' => $imageConfig->getGreyscale() ? 'true' : 'false', 'ShowExtraCentiles' => $imageConfig->getShowExtraCentiles() ? 'true' : 'false', 'GridlinesByWeight' => $imageConfig->getGridlinesByWeight() ? 'true' : 'false', 'ScalePercent' => (int) $imageConfig->getScalePercent()))); $data = $this->doRequest($url); return Chart::createFromJson($data)->setChartIdentifier($chartIdentifier); }
/** * {@inheritdoc} */ public function jsonSerializationDataProvider() { $babies = array(Baby::createNew()->setBirthOrderNumber(0)->setBirthWeight(3550)->setGender(1)->setGestation(275)->setName('Baby1')->setUnknown(false), Baby::createNew()->setBirthOrderNumber(2)->setBirthWeight(3350)->setGender(1)->setGestation(280)->setName('Baby3')->setUnknown(false), Baby::createNew()->setBirthOrderNumber(1)->setBirthWeight(3450)->setGender(1)->setGestation(290)->setName('Baby2')->setUnknown(false), Baby::createNew()->setBirthOrderNumber(3)->setUnknown(true)); $imageConfig = ImageConfig::createNew()->setGreyscale(false)->setGridlinesByWeight(false)->setScalePercent(200)->setShowExtraCentiles(false); $pdfConfig = PdfConfig::createNew()->setGreyscale(false)->setGridlinesByWeight(false)->setShowExtraCentiles(false); return array(array('Grow\\Client\\Model\\Chart', array('babies' => $babies, "dob" => new DateTime("1990-01-01 01:01:01"), "edd" => new DateTime("2015-01-07 01:01:01"), "ethnicity" => "Unclassified", "firstname" => "SampleFN", "lastname" => "SampleLN", "motherRef" => "SampleMR", "getPdf" => true, "getImage" => true, "height" => 163, "imageConfig" => $imageConfig, "pdfConfig" => $pdfConfig, "weight" => 45), '{ "babies":[{ "birthordernumber":0, "birthweight":3550, "gender":1, "gestation":275, "name":"Baby1", "unknown":0 },{ "birthordernumber":2, "birthweight":3350, "gender":1, "gestation":280, "name":"Baby3", "unknown":0 },{ "birthordernumber":1, "birthweight":3450, "gender":1, "gestation":290, "name":"Baby2", "unknown":0 },{ "birthordernumber":3, "unknown":1 }], "dob":"1990-01-01", "edd":"2015-01-07", "ethnicity":"Unclassified", "firstname":"SampleFN", "lastname":"SampleLN", "motherref":"SampleMR", "getpdf": 1, "getimage": 1, "height":163, "imageconfig":{ "greyscale":0, "gridlinesbyweight":0, "scalepercent":200, "showextracentiles":0 }, "pdfconfig":{ "greyscale":0, "gridlinesbyweight":0, "showextracentiles":0 }, "weight":45 }'), array('Grow\\Client\\Model\\Chart', array("dob" => new DateTime("1990-01-01 01:01:01"), "edd" => new DateTime("2015-01-07 01:01:01"), "ethnicity" => "Unclassified", "firstname" => "SampleFN", "lastname" => "SampleLN", "motherRef" => "", "getPdf" => false, "getImage" => false, "height" => 163, "weight" => 45), '{ "dob":"1990-01-01", "edd":"2015-01-07", "ethnicity":"Unclassified", "firstname":"SampleFN", "lastname":"SampleLN", "motherref":"", "getpdf": 0, "getimage": 0, "height":163, "weight":45 }')); }
use Grow\Client\Model\Chart; use Grow\Client\Model\Centile; use Grow\Client\Model\Measurement; use Grow\Client\Model\Config\ImageConfig; use Grow\Client\Model\Config\PdfConfig; use Grow\Client\Model\Option\GenderOption; use Grow\Client\Model\Option\EthnicityOption; $apiClient = ApiClientFactory::getInstance()->getClient(GROW_API_USERNAME, GROW_API_PASSWORD); $edd = new DateTime("-1 day"); $ethnicities = $apiClient->getEthnicities(); $genders = $apiClient->getGenders(); $outcomes = $apiClient->getOutcomes(); $measurementTypes = $apiClient->getMeasurementTypes(); $hospitals = $apiClient->getHospitals(); $babies = array(Baby::createNew()->setBirthOrderNumber(0)->setBirthWeight(3550)->setGender($genders->current()->getIdentifier())->setGestation(275)->setName('Baby1')->setUnknown(false), Baby::createNew()->setBirthOrderNumber(1)->setUnknown(true)); $imageConfig = ImageConfig::createNew()->setGreyscale(false)->setGridlinesByWeight(false)->setScalePercent(200)->setShowExtraCentiles(false); $pdfConfig = PdfConfig::createNew()->setGreyscale(false)->setGridlinesByWeight(false)->setShowExtraCentiles(false); $chart = Chart::createNew()->setBabies($babies)->setDob(new DateTime("1990-01-01 01:01:01"))->setEdd($edd)->setEthnicity($ethnicities->current()->getIdentifier())->setFirstname("SampleFN")->setLastname("SampleLN")->setMotherRef("SampleMR")->setGetPdf(true)->setGetImage(true)->setHeight(163)->setImageConfig($imageConfig)->setPdfConfig($pdfConfig)->setWeight(45); $chartResponse = $apiClient->addChart($chart); $chartIdentifier = $chart->getChartIdentifier(); $chartIdentifierPrefix = $apiClient->getChartIdentifierPrefix($chartIdentifier); $prefixedChartIdentifier = sprintf("%s%s", (string) $chartIdentifierPrefix, $chartIdentifier); echo sprintf("Chart #%s added.\n", $chartIdentifier); $imageFilename = sprintf("/tmp/%s.jpg", $chartIdentifier); $chartResponse->saveImage($imageFilename); echo sprintf("Chart's image saved as '%s'.\n", $imageFilename); $pdfFilename = sprintf("/tmp/%s.pdf", $chartIdentifier); $chartResponse->savePdf($pdfFilename); echo sprintf("Chart's pdf saved as '%s'.\n", $pdfFilename); // getChart($chartIdentifier, DateTime $edd, ImageConfig $imageConfig); // Measurement - Add