/**
  * @see http://msdn.microsoft.com/en-us/library/dd724265.aspx
  *
  * @param $timestamp
  * @param $weight
  * @return object File
  */
 public static function createFromData($timestamp, $weight)
 {
     $weightMeasurement = HealthRecordItemFactory::getThing('Weight Measurement');
     $weightMeasurement->setTimestamp('when', $timestamp);
     $weightMeasurement->getQp()->find('kg')->text($weight);
     return $weightMeasurement;
 }
Exemplo n.º 2
0
 /**
  * @see http://msdn.microsoft.com/en-us/library/microsoft.health.itemtypes.file.createfromstream.aspx
  *
  * @param resource $stream
  * @param $name
  * @param $contentType
  * @return object File
  */
 public static function createFromStream($stream, $name, $contentType)
 {
     if ($content = stream_get_contents($stream)) {
         $file = HealthRecordItemFactory::getThing('File');
         $qp = $file->getQp();
         $qp->find('name')->text($name)->top()->find('size')->text(strlen($content))->top()->find('content-type text')->text($contentType)->top()->find('data-other')->text(base64_encode($content))->top();
         return $file;
     }
 }
Exemplo n.º 3
0
 public function getThings($thingNameOrTypeId, $recordId, $options = array())
 {
     if ($this->connector) {
         $typeId = HealthRecordItemFactory::getTypeId($thingNameOrTypeId);
         $options += array('group max' => 30);
         $this->connector->authenticatedWcRequest('GetThings', '3', '<group max="' . $options['group max'] . '"><filter><type-id>' . $typeId . '</type-id></filter><format><section>core</section><xml/></format></group>', array('record-id' => $recordId));
         $things = array();
         $qp = $this->connector->getQueryPathResponse();
         $qpThings = $qp->branch()->find('thing');
         foreach ($qpThings as $qpThing) {
             $things[] = HealthRecordItemFactory::getThing(qp('<?xml version="1.0"?>' . $qpThing->xml(), NULL, array('use_parser' => 'xml')));
         }
         return $things;
     } else {
         throw new HVClientNotConnectedException();
     }
 }