| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- <?php
- require_once("common/SQLServerManager.php");
- require_once('vo/com/imt/intimamedia/vo/DragAndDropVo.php');
- require_once('vo/com/imt/intimamedia/vo/MarkerVo.php');
- class AcquisitionService
- {
- public function getTypeFromLocation($location)
- {
- $query = "SELECT * FROM [intimamedia_physician].[dbo].[tr_type] WHERE fk_location = '". $location ."'";
- $results = SQLServerManager::queryOnDatabase( $query );
-
- $resultArray = array();
- foreach( $results as $value )
- {
- array_push( $resultArray, trim( $value->code ) );
- }
- return $resultArray;
- }
-
- public function createRandomName()
- {
- $chars = "abcdefghijkmnopqrstuvwxyz023456789";
- srand((double)microtime()*1000000);
- $i = 0;
- $string = '' ;
- while ($i <= 7) {
- $num = rand() % 33;
- $tmp = substr($chars, $num, 1);
- $string = $string . $tmp;
- $i++;
- }
-
- return $string .".jpg";
- }
- // Sauvegarde des Images=========================
- public function saveImage( DragAndDropVo $dragAndDropVo, $appointmentId, $byteArrayHigh, $byteArrayLow )
- {
- $path = "../images/";
- $url = "/images/". $appointmentId ."/";
-
- /*$ff=fopen("d:/tmp.jd", "a+");
- fprintf($ff, "saveImages, url=%s\n", $url);
- fclose($ff);*/
- $folder = $path . $appointmentId;
-
- $keyType = $dragAndDropVo->type;
- $base64High = $this->createRandomName();
- $base64Small = $this->createRandomName();
- $width = $dragAndDropVo->width;
- $height = $dragAndDropVo->height;
- $collection = $dragAndDropVo->collection;
- $incidence = $dragAndDropVo->incidence;
- $dicom = ($dragAndDropVo->isDicom) ? 1 : 0;
-
- if( !is_dir ( $folder ) )
- {
- mkdir( $folder );
- }
-
- file_put_contents( $folder. "/". $base64High, $byteArrayHigh->data);
- file_put_contents( $folder. "/". $base64Small, $byteArrayLow->data);
-
- $transaction = SQLServerManager::startTransaction();
-
- $imageQuery = "INSERT INTO [intimamedia_physician].[dbo].[t_image] ( image, image_small, width, height, collection, fk_type, fk_appointment, incidence, dicom ) VALUES ( '". $url . $base64High ."', '". $url . $base64Small ."', ". $width .", ". $height .", '". $collection ."', '".$keyType ."', ". $appointmentId .", '". $incidence ."', " . $dicom . ")";
-
- $validImageQuery = SQLServerManager::executeQueryForTransaction( $imageQuery, $transaction );
- $imageId = SQLServerManager::getLastId( "[intimamedia_physician].[dbo].[t_image]", $transaction );
-
- if( $validImageQuery == "exception")
- Throw new Exception("E017");
-
- SQLServerManager::commitTransaction( $transaction );
- return $imageId;
- }
-
- public function saveMarker($list, $appointmentId)
- {
- $resultsMarkers = "";
- foreach( $list as $value )
- {
- $marker = "INSERT INTO [intimamedia_physician].[dbo].[list_marker] ( x, y, side, type, location, fk_appointment ) VALUES ( ". $value->xPosition .","
- ." ". $value->yPosition .", '". $value->side ."', '". $value->type ."', '". $value->location ."', ". $appointmentId .")";
- $resultsMarkers = SQLServerManager::queryOnDatabase( $marker );
-
- if($resultsMarkers== "exception")
- {
- Throw new Exception("E018");
- }
- }
- }
-
- public function getMarkers($appointmentId)
- {
- $query = "SELECT * FROM [intimamedia_physician].[dbo].[list_marker] WHERE fk_appointment = ". $appointmentId;
- $results = SQLServerManager::queryOnDatabase( $query );
-
-
- $resultArray = array();
- foreach( $results as $value )
- {
- $markerVo = new MarkerVo();
-
- $markerVo->type = trim( $value->type );
- $markerVo->location = trim( $value->location );
- $markerVo->side = trim( $value->side );
- $markerVo->xPosition = trim( $value->x );
- $markerVo->yPosition = trim( $value->y );
-
- array_push( $resultArray, $markerVo );
- }
- return $resultArray;
- }
-
- public function getImages($appointmentId)
- {
- $query = "SELECT * FROM [intimamedia_physician].[dbo].[t_image] WHERE fk_appointment = ". $appointmentId;
- $results = SQLServerManager::queryOnDatabase( $query );
-
- /*$ff=fopen("d:/tmp.jd", "a+");
- fprintf($ff, "getImagesFromAppointmentEvent, query=%s\n", $query);
- fclose($ff);*/
- $resultArray = array();
- foreach( $results as $value )
- {
- $dragAndDropVo = new DragAndDropVo();
- $dragAndDropVo->id = $value->id;
- $dragAndDropVo->imageSmall = $value->image_small;
- $dragAndDropVo->imageHigh = $value->image;
- $dragAndDropVo->base64Small = $value->image_small;
- $dragAndDropVo->base64High = $value->image;
- $dragAndDropVo->width = $value->width;
- $dragAndDropVo->height = $value->height;
- $dragAndDropVo->type = trim( $value->fk_type );
- $dragAndDropVo->collection = trim( $value->collection );
- $dragAndDropVo->incidence = trim( $value->incidence );
- $dragAndDropVo->isDicom = ($value->dicom) ? true : false;
-
- array_push( $resultArray, $dragAndDropVo );
- }
- return $resultArray;
- }
-
- public function deleteImage( DragAndDropVo $dragAndDropVo, $appointmentId )
- {
- $image = "DELETE FROM [intimamedia_physician].[dbo].[t_image] WHERE id = ". $dragAndDropVo->id;
- $resultImages = SQLServerManager::queryOnDatabase( $image );
-
- if($resultImages== "exception")
- {
- Throw new Exception("E019");
- }
- }
-
- public function deleteMarkers($appointmentId)
- {
- $resultsmarker = "";
- $marker = "DELETE FROM [intimamedia_physician].[dbo].[list_marker] WHERE fk_appointment = ". $appointmentId;
- $resultsmarker = SQLServerManager::queryOnDatabase( $marker );
-
- if($resultsmarker== "exception")
- {
- Throw new Exception("E020");
- }
- }
- }
- ?>
|