Exemplo n.º 1
0
function loadRegisterXml($filename)
{
    $xml = file_get_contents($filename);
    $resourceNode = @simplexml_load_string($xml);
    if (!$resourceNode) {
        throw new RuntimeException("Failed to parse " . $filename);
    }
    $resource = new Resource();
    $resource->setType('perinatologie/dossier');
    foreach ($resourceNode->property as $propertyNode) {
        $property = new Property((string) $propertyNode['name'], (string) $propertyNode);
        $resource->addProperty($property);
    }
    foreach ($resourceNode->share as $shareNode) {
        $share = new Share();
        $share->setName((string) $shareNode->name);
        $share->setIdentifierType((string) $shareNode->identifier['type']);
        $share->setIdentifier((string) $shareNode->identifier);
        $share->setPermission((string) $shareNode->permission);
        $resource->addShare($share);
    }
    return $resource;
}
 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.º 3
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();
 }
Exemplo n.º 4
0
 private function buildRegisterXml(Resource $resource)
 {
     $resourceNode = new SimpleXMLElement('<resource type="' . $resource->getType() . '" />');
     foreach ($resource->getProperties() as $property) {
         $resourceNode->addChild('property', $property->getValue())->addAttribute('name', $property->getName());
     }
     foreach ($resource->getShares() as $share) {
         $shareNode = $resourceNode->addChild('share');
         $shareNode->addChild('name', $share->getName());
         $shareNode->addChild('identifier', $share->getIdentifier())->addAttribute('type', $share->getIdentifierType());
         $shareNode->addChild('permission', $share->getPermission());
     }
     //echo $clientNode->asXML();
     $dom = dom_import_simplexml($resourceNode)->ownerDocument;
     $dom->formatOutput = true;
     return $dom->saveXML();
 }