private function getResourceDataV1(Resource $resource, Source $source)
 {
     if ($source->getUrl()) {
         $url = $source->getUrl();
     } else {
         $providerApiUrl = $resource->getPropertyValue('provider_apiurl');
         if (!$providerApiUrl) {
             throw new RuntimeException("No v1 provider_apiurl to get resource data");
         }
         $bsn = $resource->getPropertyValue('client_bsn');
         $ref = $resource->getPropertyValue('reference');
         switch ($resource->getType()) {
             case 'perinatologie/dossier':
                 $url = $providerApiUrl . '/' . $bsn . '/' . rawurlencode($ref);
                 break;
             default:
                 throw new RuntimeException("Unsupported resource type: " . $resource->getType());
         }
     }
     try {
         $hashSource = $url . $this->password;
         $headers = array();
         //echo "REQUESTING PROVIDER URL: " . $url . "\n";
         if ($this->username || $this->password) {
             // stripping http(s) because of load-balancer. Hub sees http only
             $securityHash = sha1(str_replace('https', 'http', $hashSource));
             $headers = ['uuid' => $this->username, 'securityhash' => $securityHash];
         }
         //echo "REQUESTING: " . $fullUrl . "\n";
         $res = $this->httpClient->get($url, ['headers' => $headers, 'verify' => $this->verify]);
         if ($res->getStatusCode() == 200) {
             $res = (string) $res->getBody();
             return $res;
         }
     } catch (\GuzzleHttp\Exception\RequestException $e) {
         ErrorResponseHandler::handle($e->getResponse());
     }
 }
Exemplo n.º 2
0
 private function buildUpdateClientInfoXml(Resource $resource, $providerAgb = null)
 {
     $clientNode = new SimpleXMLElement('<client />');
     $clientNode->addChild('bsn', $resource->getPropertyValue('bsn'));
     $clientNode->addChild('birthdate', $resource->getPropertyValue('birthdate'));
     $clientNode->addChild('zisnummer', $resource->getPropertyValue('zisnummer'));
     $clientNode->addChild('firstname', $resource->getPropertyValue('firstname'));
     $clientNode->addChild('lastname', $resource->getPropertyValue('lastname'));
     $eocsNode = $clientNode->addChild('eocs');
     $eocNode = $eocsNode->addChild('eoc');
     $eocNode->addChild('reference', $resource->getPropertyValue('reference'));
     $eocNode->addChild('gravida', $resource->getPropertyValue('gravida'));
     $eocNode->addChild('para', $resource->getPropertyValue('para'));
     $eocNode->addChild('starttimestamp', $resource->getPropertyValue('starttimestamp'));
     $eocNode->addChild('edd', $resource->getPropertyValue('edd'));
     foreach ($resource->getShares() as $share) {
         $shareNode = $eocNode->addChild('teammember');
         $shareNode->addChild('name', $share->getName());
         if ($share->getIdentifierType() != 'agb') {
             throw new RuntimeException('Identifier types other than AGB not supported in v1 api');
         }
         $shareNode->addChild('agb', $share->getIdentifier());
         $shareNode->addChild('permission', $share->getPermission());
     }
     $providersNode = $eocsNode->addChild('providers');
     $providerNode = $providersNode->addChild('provider');
     $providerNode->addChild('uuid', $this->username);
     if ($providerAgb) {
         $providerNode->addChild('agb', $providerAgb);
     }
     //echo $clientNode->asXML();
     $dom = dom_import_simplexml($clientNode)->ownerDocument;
     $dom->formatOutput = true;
     return $dom->saveXML();
 }