-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #248 from ansforge/integration_fhir
add integration fhir folder
- Loading branch information
Showing
5 changed files
with
228 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
docs/pages/guide/version-2/integration-fhir/integration-dotnet.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
layout: menu-version-1 | ||
title: Utilisation de C# | ||
subTitle: Intégration FHIR | ||
--- | ||
|
||
Ce guide décrit comment intégrer l'API à un projet .Net Core. | ||
|
||
Si vous n'avez pas de clé d'API, veuillez suivre la procédure décrite [ici]({{ '/pages/guide/version-1/integration-fhir/integration-dotnet.html'}}). | ||
|
||
NOTE| Dans nos différents exemples, nous utilisons maven et la librairie développée par Firely Hl7.Fhir.R4. FHIR reste une API HTTP JSON/XML qui pourra être appelée avec d'autres techniques. | ||
|
||
|
||
### Dépendance | ||
|
||
Ajoutez la dépendance Hl7.Fhir.R4 à votre projet. Nous choisirons la version R4 car l'api proposée est basée sur FHIR R4. | ||
|
||
``` | ||
dotnet add package Hl7.Fhir.R4 --version 4.3.0 | ||
``` | ||
|
||
|
||
| ||
|
||
### Configuration du client HTTP FHIR avec HAPI | ||
|
||
Par rapport à l'utilisation de base du client Fhir, nous spécifions un HttpClientHandler afin d'ajouter l'API Key d'authentification. | ||
|
||
Voici un exemple nominal: | ||
<div class="code-sample"><div class="tab-content" data-name="C#"> | ||
{% highlight csharp %} | ||
// class to add the security token in the header: | ||
public class AuthorizationMessageHandler : HttpClientHandler | ||
{ | ||
protected async override System.Threading.Tasks.Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) | ||
{ | ||
request.Headers.Add("ESANTE-API-KEY", "{{site.ans.demo_key }}"); | ||
return await base.SendAsync(request, cancellationToken); | ||
} | ||
} | ||
|
||
// client creation: | ||
var settings = new FhirClientSettings | ||
{ | ||
Timeout = 40000, | ||
PreferredFormat = ResourceFormat.Json, | ||
VerifyFhirVersion = false, | ||
}; | ||
var handler = new AuthorizationMessageHandler(); | ||
var client = new FhirClient("{{site.ans.api_url}}/fhir/", settings, handler); | ||
|
||
// and then use the client: | ||
var result = client.Search<Device>(); | ||
|
||
{% endhighlight %} | ||
</div></div> | ||
|
||
|
||
Vous retrouverez toute la documentation de ce client sur le site de la librairie Firely HL7 FHIR SDK in .NET : | ||
* [Site du SDK](https://fire.ly/products/firely-net-sdk/) | ||
* [Documentation](https://docs.fire.ly/projects/Firely-NET-SDK/en/latest/) | ||
|
84 changes: 84 additions & 0 deletions
84
docs/pages/guide/version-2/integration-fhir/integration-java.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
--- | ||
layout: menu-version-1 | ||
title: Utilisation de Java | ||
subTitle: Intégration FHIR | ||
--- | ||
|
||
Ce guide décrit comment intégrer l'API à un projet Java. | ||
|
||
Si vous n'avez pas de clé d'API, veuillez suivre la procédure décrite [ici]({{ '/pages/guide/version-1/integration-fhir/integration-java.html'}}). | ||
|
||
NOTE| Dans nos différents exemples, nous utilisons maven et la librairie Hapi. FHIR reste une API HTTP JSON/XML qui pourra être appelée avec d'autres techniques. | ||
|
||
### Dépendances maven | ||
|
||
Pour l'exemple, le projet est un projet java maven. Nous utilisons la librairie [Java Hapi](https://hapifhir.io/){:target="_blank"} qui permet entre autres de faire des appels FHIR. | ||
|
||
Pour utiliser les librairies Hapi, nous allons ajouter les dépendances suivantes dans le fichier pom.xml : | ||
|
||
```xml | ||
<properties> | ||
<hapifhir_version>6.0.0</hapifhir_version> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.13</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<!-- Hapi classes --> | ||
<dependency> | ||
<groupId>ca.uhn.hapi.fhir</groupId> | ||
<artifactId>hapi-fhir-base</artifactId> | ||
<version>${hapifhir_version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>ca.uhn.hapi.fhir</groupId> | ||
<artifactId>hapi-fhir-client</artifactId> | ||
<version>${hapifhir_version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>ca.uhn.hapi.fhir</groupId> | ||
<artifactId>hapi-fhir-structures-r4</artifactId> | ||
<version>${hapifhir_version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<version>1.2.3</version> | ||
</dependency> | ||
</dependencies> | ||
``` | ||
|
||
| ||
|
||
### Configuration du client HTTP FHIR avec HAPI | ||
|
||
Par rapport à l'utilisation de base du client HAPI, nous spécifions un Intercepeur afin d'ajouter l'API Key d'authentification. | ||
|
||
Voici un exemple nominal: | ||
<div class="code-sample"><div class="tab-content" data-name="java"> | ||
{% highlight java %} | ||
// register the interceptor only one time: | ||
var client = ctx.newRestfulGenericClient("{{site.ans.api_url}}/fhir"); | ||
client.registerInterceptor(new IClientInterceptor() { | ||
@Override | ||
public void interceptRequest(IHttpRequest iHttpRequest) { | ||
iHttpRequest.addHeader("ESANTE-API-KEY", "{{site.ans.demo_key }}"); | ||
} | ||
@Override | ||
public void interceptResponse(IHttpResponse iHttpResponse) throws IOException {} | ||
}); | ||
// and then use the client: | ||
var conf = client | ||
.capabilities() | ||
.ofType(CapabilityStatement.class) | ||
.execute(); | ||
{% endhighlight %} | ||
</div></div> | ||
|
||
NOTE| La création du client est coûteuse, nous recommandons de conserver le client pour plusieurs appels. | ||
|
||
La documentation Hapi est très riche sur le fonctionnement de son client, vous pourrez trouver différents usages: [Documentation Client HAPI](https://hapifhir.io/hapi-fhir/docs/client/generic_client.html){:target="_blank"} | ||
|
64 changes: 64 additions & 0 deletions
64
docs/pages/guide/version-2/integration-fhir/integration-php.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
layout: menu-version-1 | ||
title: Utilisation de PHP | ||
subTitle: Intégration FHIR | ||
--- | ||
|
||
Ce guide décrit comment intégrer l'API à un projet PHP. | ||
|
||
Si vous n'avez pas de clé d'API, veuillez suivre la procédure décrite [ici]({{ '/pages/guide/version-1/integration-fhir/integration-php.html'}}). | ||
|
||
NOTE| Dans nos différents exemples, nous utilisons composer et la librairie dcarbone/php-fhir pour FHIR et Guzzle pour le REST. FHIR reste une API HTTP JSON/XML qui pourra être appelée avec d'autres techniques. | ||
|
||
### Dépendances composer | ||
|
||
dcarbone/php-fhir permet de parser et typer les objets FHIR. Cela pourra être utilisé par exemple pour la complétion. | ||
|
||
|
||
|
||
<div class="code-sample"><div class="tab-content" data-name="composer"> | ||
{% highlight php %} | ||
{ | ||
"require": { | ||
"dcarbone/php-fhir-generated": "v2.0.*", | ||
"guzzlehttp/guzzle": "^7.0" | ||
} | ||
} | ||
{% endhighlight %} | ||
|
||
</div> | ||
</div> | ||
|
||
|
||
### Configuration du client HTTP FHIR avec Guzzle | ||
|
||
Les requêtes sont des requêtes REST auxquelles nous précisons un header https. | ||
|
||
Voici un exemple nominal : | ||
|
||
|
||
<div class="code-sample"><div class="tab-content" data-name="PHP"> | ||
|
||
{% highlight php %} | ||
<?php | ||
require_once '../vendor/autoload.php'; | ||
use DCarbone\PHPFHIRGenerated\R4\PHPFHIRResponseParser; | ||
use DCarbone\PHPFHIRGenerated\R4\PHPFHIRResponseParserConfig; | ||
$config = new PHPFHIRResponseParserConfig([ | ||
'registerAutoloader' => true, | ||
'sxeArgs' => LIBXML_COMPACT | LIBXML_NSCLEAN | ||
]); | ||
$parser = new PHPFHIRResponseParser($config); | ||
|
||
|
||
$header = ['ESANTE-API-KEY' => 'eb2e94fa-ffe6-491f-aa9d-073f6a5a2415']; | ||
$client = new GuzzleHttp\Client([ | ||
'base_uri' => 'https://gateway.api.esante.gouv.fr', | ||
'timeout' => 2.0, | ||
'headers' => $header]); | ||
{% endhighlight %} | ||
|
||
</div></div> | ||
|
||
|