PHP code example of qrcommunication / rppsapi

1. Go to this page and download the library: Download qrcommunication/rppsapi library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

qrcommunication / rppsapi example snippets


use QrCommunication\RppsApi\RppsClient;
use QrCommunication\RppsApi\RppsClientOptions;
use QrCommunication\RppsApi\Dto\RppsSearchCriteria;

$client = new RppsClient(new RppsClientOptions(
    fhirApiKey: $_ENV['FHIR_API_KEY'] ?? null,
));

// Profil complet par RPPS
$profil = $client->getByRpps('10005173140');

echo $profil->identite->civiliteExercice->libelle . ' ';
echo $profil->identite->prenomExercice . ' ' . $profil->identite->nomExercice . "\n";
echo $profil->profession->libelle . "\n";

foreach ($profil->activites as $activite) {
    echo "  - " . $activite->structure->raisonSociale . "\n";
}

foreach ($profil->diplomesEtAutorisations as $da) {
    if ($da->diplome) {
        echo "  - [Diplome] " . $da->diplome->libelle . "\n";
    }
}

// Recherche par nom + code postal
$results = $client->search(new RppsSearchCriteria(
    nom: 'DUPONT',
    codePostal: '75',
));

echo "Total: {$results->total}\n";
foreach ($results->results as $r) {
    echo "  {$r->civilite} {$r->prenomExercice} {$r->nomExercice} — {$r->profession->libelle}\n";
}

$client = new RppsClient(new RppsClientOptions(
    fhirBaseUrl: 'https://gateway.api.esante.gouv.fr/fhir/v2',  // defaut
    fhirApiKey: 'votre-cle-gravitee',                            // optionnel
    tabularBaseUrl: 'https://tabular-api.data.gouv.fr/api/resources',  // defaut
    timeout: 30.0,                                                // secondes
    tabularPageSize: 100,                                         // defaut
    disabledSources: [],                                          // ex: ['fhir', 'mssante']
));