Compare commits
32 Commits
LireCarteV
...
952c8561ba
Author | SHA1 | Date | |
---|---|---|---|
952c8561ba
|
|||
9829a189a4
|
|||
c8f14cd77b
|
|||
6d9cd7fc14
|
|||
c0bbdcf030
|
|||
488f719919
|
|||
9b279ce4cd
|
|||
334e6520d5
|
|||
68376383fa
|
|||
581bd2455e
|
|||
37ef6e2c15
|
|||
1d5553a739
|
|||
eca3ea2cd6
|
|||
241629c7ab
|
|||
b9ac1a3587
|
|||
6209c087c2
|
|||
cba1534fd7
|
|||
e03abbb87e
|
|||
e6db84e9ac
|
|||
13254228a6
|
|||
f083c696f8
|
|||
8b4fe4fd10
|
|||
160dcc9249
|
|||
016ae43402
|
|||
01d17207fa
|
|||
c82d3abd9c
|
|||
cde7f3aab4
|
|||
3a263f92e1
|
|||
13b92aee9c
|
|||
3999532714
|
|||
e51dcc0ed0
|
|||
0f7a291b3c
|
5
.ignore
5
.ignore
@ -1,5 +0,0 @@
|
||||
# Ignorer les fichiers dont ne dépent pas la compilation
|
||||
*.md
|
||||
tailwind.config.js
|
||||
*.example
|
||||
scripts
|
1706
Cargo.lock
generated
1706
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -3,5 +3,6 @@ resolver = "2"
|
||||
members = [
|
||||
"crates/app",
|
||||
"crates/sesam-vitale",
|
||||
"crates/desktop"
|
||||
"crates/desktop",
|
||||
"crates/services-sesam-vitale-sys",
|
||||
]
|
||||
|
13
README.md
13
README.md
@ -47,19 +47,6 @@ Si vous souhaitez lancer les composants séparément, les indications de lanceme
|
||||
- [app](crates/app/README.md)
|
||||
- [sesam-vitale](crates/sesam-vitale/README.md)
|
||||
|
||||
## Rechargement automatique
|
||||
|
||||
Pour permettre de développer plus rapidement, il existe une librairie qui recompile automatiquement nos modifications en cours : [`cargo-watch`](https://github.com/watchexec/cargo-watch) permet de relancer une commande `cargo` lorsqu'un fichier est modifié (example: `cargo run` --> `cargo watch -x run`).
|
||||
|
||||
Voici la commande pour l'installer dans un _package_ :
|
||||
```bash
|
||||
cargo add cargo-watch --dev --package app
|
||||
```
|
||||
|
||||
Le fichier [`.ignore`](./ignore) permet d'ignorer certains fichiers pour éviter de relancer la recompilation inutilement.
|
||||
|
||||
⚠️ La librairie n'est pas compatible avec _Windows 7_ et les versions antérieurs de _Windows_.
|
||||
|
||||
## Build
|
||||
|
||||
Packager le client desktop
|
||||
|
@ -7,13 +7,7 @@ edition = "2021"
|
||||
askama = "0.12.1"
|
||||
askama_axum = "0.4.0"
|
||||
axum = "0.7.5"
|
||||
listenfd = "1.0.1"
|
||||
notify = "6.1.1"
|
||||
serde = { version = "1.0.204", features = ["derive"] }
|
||||
tokio = { version = "1.39.1", features = ["macros", "rt-multi-thread"] }
|
||||
tower-http = { version = "0.5.2", features = ["fs"] }
|
||||
tower-livereload = "0.9.3"
|
||||
|
||||
[dev-dependencies]
|
||||
cargo-watch = "8.5.1"
|
||||
systemfd = "0.4.0"
|
||||
|
@ -13,23 +13,3 @@
|
||||
```bash
|
||||
cargo run --bin app
|
||||
```
|
||||
|
||||
## Rechargement automatique (_auto-reload_)
|
||||
|
||||
Pour le projet `app`, nous utilisons en plus de `cargo-watch` ses librairies :
|
||||
- [`systemfd`](https://github.com/mitsuhiko/systemfd) permet de redémarrer un serveur sans interrompre les connexions en cours, il transmet le descripteur de fichier du socket à une nouvelle instance du serveur (exemple: `cargo watch -x run` --> `systemfd --no-pid -s http::3000 -- cargo watch -x run`). Si le port est déjà pris il en prendra un autre.
|
||||
- [`listenfd`](https://github.com/mitsuhiko/listenfd) permet, côté _Rust_, de démarrer un serveur en utilisant des connexions déjà ouvertes.
|
||||
|
||||
Pour notre application voici la commande à lancer :
|
||||
|
||||
```bash
|
||||
systemfd --no-pid -s http::3000 -- cargo watch -x 'run --bin app'
|
||||
```
|
||||
|
||||
## Chargement à chaud (_livereload_)
|
||||
|
||||
Pour que notre navigateur rafraîchisse automatique notre page lorsque le serveur a été recompilé, nous utilisons la librairie [`tower-livereload`](https://github.com/leotaku/tower-livereload).
|
||||
|
||||
A chaque changement, que ça soit sur du code en _Rust_, _HTML_, _CSS_ ou _JS_ alors le navigateur va recharger entièrement la page.
|
||||
|
||||
En Rust, il n'existe pas encore d'outil de _Hot Reload_ complet et intégré comme on en trouve dans d'autres environnements de développement web, comme pour _Node.js_.
|
||||
|
@ -3,7 +3,8 @@ mod templates;
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use askama_axum::Template;
|
||||
use askama::Template;
|
||||
use askama_axum::IntoResponse;
|
||||
use axum::http::{StatusCode, Uri};
|
||||
use tower_http::services::ServeDir;
|
||||
|
||||
@ -13,10 +14,10 @@ async fn fallback(uri: Uri) -> (StatusCode, String) {
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "index.html")]
|
||||
pub struct GetIndexTemplate;
|
||||
pub struct GetIndexResponse;
|
||||
|
||||
async fn root() -> GetIndexTemplate {
|
||||
GetIndexTemplate {}
|
||||
async fn root() -> impl IntoResponse {
|
||||
GetIndexResponse {}.into_response()
|
||||
}
|
||||
|
||||
pub fn get_router(assets_path: &Path) -> axum::Router {
|
||||
|
@ -1,63 +1,15 @@
|
||||
use ::app::get_router;
|
||||
use axum::body::Body;
|
||||
use axum::http::Request;
|
||||
use listenfd::ListenFd;
|
||||
use notify::Watcher;
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
use tokio::net::TcpListener;
|
||||
use tower_livereload::predicate::Predicate;
|
||||
use tower_livereload::LiveReloadLayer;
|
||||
|
||||
/// Nous filtrons les requêtes de `htmx` pour ne pas inclure le script _JS_ qui gère le rechargement
|
||||
/// Voir https://github.com/leotaku/tower-livereload/pull/3
|
||||
#[derive(Copy, Clone)]
|
||||
struct NotHtmxPredicate;
|
||||
impl<T> Predicate<Request<T>> for NotHtmxPredicate {
|
||||
fn check(&mut self, req: &Request<T>) -> bool {
|
||||
!(req.headers().contains_key("hx-request"))
|
||||
}
|
||||
}
|
||||
|
||||
const DEFAULT_LISTENER: &str = "localhost:3000";
|
||||
async fn get_tcp_listener() -> TcpListener {
|
||||
let mut listenfd = ListenFd::from_env();
|
||||
|
||||
match listenfd.take_tcp_listener(0).unwrap() {
|
||||
// if we are given a tcp listener on listen fd 0, we use that one
|
||||
Some(listener) => {
|
||||
listener.set_nonblocking(true).unwrap();
|
||||
TcpListener::from_std(listener).unwrap()
|
||||
}
|
||||
// otherwise fall back to local listening
|
||||
None => TcpListener::bind(DEFAULT_LISTENER).await.unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
fn get_livereload_layer(templates_path: &Path) -> LiveReloadLayer<NotHtmxPredicate> {
|
||||
let livereload = LiveReloadLayer::new();
|
||||
let reloader = livereload.reloader();
|
||||
let mut watcher = notify::recommended_watcher(move |_| reloader.reload()).unwrap();
|
||||
watcher
|
||||
.watch(templates_path, notify::RecursiveMode::Recursive)
|
||||
.unwrap();
|
||||
livereload.request_predicate::<Body, NotHtmxPredicate>(NotHtmxPredicate)
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||
let assets_path = Path::new(&manifest_dir).join("assets");
|
||||
let templates_path = Path::new(&manifest_dir).join("templates");
|
||||
let router = get_router(assets_path.as_path());
|
||||
|
||||
let livereload_layer = get_livereload_layer(&templates_path);
|
||||
let router = get_router(assets_path.as_path()).layer(livereload_layer);
|
||||
|
||||
let listener: TcpListener = get_tcp_listener().await;
|
||||
// TODO: select port based on available port (or ask in CLI)
|
||||
let listener = tokio::net::TcpListener::bind("localhost:3000").await.unwrap();
|
||||
println!("Listening on: http://{}", listener.local_addr().unwrap());
|
||||
|
||||
// Run the server with the router
|
||||
axum::serve(listener, router.into_make_service())
|
||||
.await
|
||||
.unwrap();
|
||||
axum::serve(listener, router).await.unwrap();
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
use askama_axum::Template;
|
||||
use askama::Template;
|
||||
use askama_axum::IntoResponse;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "pages/cps.html")]
|
||||
pub struct CpsTemplate;
|
||||
struct CpsResponse;
|
||||
|
||||
pub async fn cps() -> CpsTemplate {
|
||||
CpsTemplate
|
||||
}
|
||||
pub async fn cps() -> impl IntoResponse {
|
||||
CpsResponse.into_response()
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
use askama_axum::Template;
|
||||
use askama::Template;
|
||||
use askama_axum::IntoResponse;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "pages/home.html")]
|
||||
pub struct HomeTemplate;
|
||||
struct HomeResponse;
|
||||
|
||||
pub async fn home() -> HomeTemplate {
|
||||
HomeTemplate
|
||||
}
|
||||
pub async fn home() -> impl IntoResponse {
|
||||
HomeResponse.into_response()
|
||||
}
|
@ -7,4 +7,4 @@ pub fn get_routes() -> Router {
|
||||
Router::new()
|
||||
.route("/home", routing::get(home::home))
|
||||
.route("/cps", routing::get(cps::cps))
|
||||
}
|
||||
}
|
@ -1,18 +1,20 @@
|
||||
use askama_axum::Template;
|
||||
use askama::Template;
|
||||
use askama_axum::IntoResponse;
|
||||
use axum::{routing, Router};
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "hello.html")]
|
||||
struct HelloTemplate {
|
||||
struct HelloResponse {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
async fn hello() -> HelloTemplate {
|
||||
HelloTemplate {
|
||||
async fn hello() -> impl IntoResponse {
|
||||
HelloResponse {
|
||||
name: "Theo".to_string(),
|
||||
}
|
||||
}.into_response()
|
||||
}
|
||||
|
||||
pub fn get_routes() -> Router {
|
||||
Router::new().route("/", routing::get(hello))
|
||||
Router::new()
|
||||
.route("/", routing::get(hello))
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
use askama_axum::Template;
|
||||
use askama::Template;
|
||||
use askama_axum::IntoResponse;
|
||||
use axum::{extract::Query, routing, Router};
|
||||
use serde::Deserialize;
|
||||
|
||||
@ -15,18 +16,16 @@ struct MenuParameters {
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "layout/nav/nav-menu-items.html")]
|
||||
struct MenuTemplate {
|
||||
struct MenuResponse {
|
||||
mobile: bool,
|
||||
items: Vec<MenuItem>,
|
||||
}
|
||||
|
||||
impl MenuTemplate {
|
||||
impl MenuResponse {
|
||||
fn get_classes(&self, is_current_item: &bool) -> String {
|
||||
let common_classes = match self.mobile {
|
||||
true => "block border-l-4 py-2 pl-3 pr-4 text-base font-medium".to_string(),
|
||||
false => {
|
||||
"inline-flex items-center border-b-2 px-1 pt-1 text-sm font-medium".to_string()
|
||||
}
|
||||
false => "inline-flex items-center border-b-2 px-1 pt-1 text-sm font-medium".to_string(),
|
||||
};
|
||||
match (self.mobile, is_current_item) {
|
||||
(true, true) => common_classes + " border-indigo-500 bg-indigo-50 text-indigo-700",
|
||||
@ -37,8 +36,8 @@ impl MenuTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
async fn menu(Query(params): Query<MenuParameters>) -> MenuTemplate {
|
||||
MenuTemplate {
|
||||
async fn menu(Query(params): Query<MenuParameters>) -> impl IntoResponse {
|
||||
MenuResponse {
|
||||
mobile: params.mobile,
|
||||
items: vec![
|
||||
MenuItem {
|
||||
@ -51,10 +50,11 @@ async fn menu(Query(params): Query<MenuParameters>) -> MenuTemplate {
|
||||
href: "/pages/cps".to_string(),
|
||||
current: false,
|
||||
},
|
||||
],
|
||||
}
|
||||
],
|
||||
}.into_response()
|
||||
}
|
||||
|
||||
pub fn get_routes() -> Router {
|
||||
Router::new().route("/menu", routing::get(menu))
|
||||
Router::new()
|
||||
.route("/menu", routing::get(menu))
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
use askama_axum::Template;
|
||||
use askama::Template;
|
||||
use askama_axum::IntoResponse;
|
||||
use axum::{extract::Query, routing, Router};
|
||||
use serde::Deserialize;
|
||||
|
||||
@ -15,12 +16,12 @@ struct MenuParameters {
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "layout/nav/profile-menu-items.html")]
|
||||
struct MenuTemplate {
|
||||
struct MenuResponse {
|
||||
mobile: bool,
|
||||
items: Vec<MenuItem>,
|
||||
}
|
||||
|
||||
impl MenuTemplate {
|
||||
impl MenuResponse {
|
||||
fn get_classes(&self, is_current_item: &bool) -> String {
|
||||
let common_classes = match self.mobile {
|
||||
true => "block px-4 py-2 text-base font-medium text-gray-500 hover:bg-gray-100 hover:text-gray-800".to_string(),
|
||||
@ -35,8 +36,8 @@ impl MenuTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
async fn menu(Query(params): Query<MenuParameters>) -> MenuTemplate {
|
||||
MenuTemplate {
|
||||
async fn menu(Query(params): Query<MenuParameters>) -> impl IntoResponse {
|
||||
MenuResponse {
|
||||
mobile: params.mobile,
|
||||
items: vec![
|
||||
MenuItem {
|
||||
@ -55,9 +56,10 @@ async fn menu(Query(params): Query<MenuParameters>) -> MenuTemplate {
|
||||
current: false,
|
||||
},
|
||||
],
|
||||
}
|
||||
}.into_response()
|
||||
}
|
||||
|
||||
pub fn get_routes() -> Router {
|
||||
Router::new().route("/menu", routing::get(menu))
|
||||
}
|
||||
Router::new()
|
||||
.route("/menu", routing::get(menu))
|
||||
}
|
9
crates/services-sesam-vitale-sys/Cargo.toml
Normal file
9
crates/services-sesam-vitale-sys/Cargo.toml
Normal file
@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "services-sesam-vitale-sys"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
bitvec = "1.0.1"
|
||||
deku = "0.17.0"
|
||||
libc = "0.2.155"
|
288
crates/services-sesam-vitale-sys/src/bindings.rs
Normal file
288
crates/services-sesam-vitale-sys/src/bindings.rs
Normal file
@ -0,0 +1,288 @@
|
||||
#![allow(non_upper_case_globals)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
// Generated using bindgen
|
||||
|
||||
extern "C" {
|
||||
// Fonctions de gestion des données
|
||||
|
||||
pub fn SSV_LireCartePS(
|
||||
NomRessourcePS: *const ::std::os::raw::c_char,
|
||||
NomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||
CodePorteurPS: *const ::std::os::raw::c_char,
|
||||
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
pTailleZone: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
pub fn SSV_LireDroitsVitale(
|
||||
NomRessourcePS: *const ::std::os::raw::c_char,
|
||||
NomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||
CodePorteurPS: *const ::std::os::raw::c_char,
|
||||
DateConsultation: *const ::std::os::raw::c_char,
|
||||
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
pTailleZone: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
pub fn SSV_FormaterFactures(
|
||||
cFactureACreer: ::std::os::raw::c_char,
|
||||
cModeSecur: ::std::os::raw::c_char,
|
||||
cTypeFlux: ::std::os::raw::c_char,
|
||||
pZDataIn: *mut ::std::os::raw::c_void,
|
||||
TailleDataIn: usize,
|
||||
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
pTailleZone: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
pub fn SSV_ChiffrerFacture(
|
||||
pZDataIn: *mut ::std::os::raw::c_void,
|
||||
TailleDataIn: usize,
|
||||
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
pTailleZone: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
pub fn SSV_SignerFactureVitale(
|
||||
pcNomRessourceVitale: *const ::std::os::raw::c_char,
|
||||
pZDataIn: *mut ::std::os::raw::c_void,
|
||||
szTailleDataIn: usize,
|
||||
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
pszTailleZone: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
pub fn SSV_CalculerHashFactureAssure(
|
||||
pcNumSerie: *const ::std::os::raw::c_char,
|
||||
pZDataIn: *mut ::std::os::raw::c_void,
|
||||
szTailleDataIn: usize,
|
||||
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
pszTailleZone: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
pub fn SSV_AjouterSignatureAssureDansFacture(
|
||||
pZDataIn: *mut ::std::os::raw::c_void,
|
||||
szTailleDataIn: usize,
|
||||
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
pszTailleZone: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
pub fn SSV_SignerFactureCPS(
|
||||
pcNomRessourcePS: *const ::std::os::raw::c_char,
|
||||
pcNomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||
pcCodePorteurPS: *const ::std::os::raw::c_char,
|
||||
cNologSituation: ::std::os::raw::c_char,
|
||||
pZDataIn: *mut ::std::os::raw::c_void,
|
||||
szTailleDataIn: usize,
|
||||
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
pszTailleZone: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
pub fn SSV_FormaterLot(
|
||||
NBZDataIn: ::std::os::raw::c_short,
|
||||
TZDataIn: *mut *mut ::std::os::raw::c_void,
|
||||
TTailleZoneIn: *mut usize,
|
||||
pNbZDataOut: *mut ::std::os::raw::c_short,
|
||||
TZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
TTailleZoneOut: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
pub fn SSV_SignerLotCPS(
|
||||
pcNomRessourcePS: *const ::std::os::raw::c_char,
|
||||
pcNomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||
pcCodePorteurPS: *const ::std::os::raw::c_char,
|
||||
cNologSituation: ::std::os::raw::c_char,
|
||||
pZDataIn: *mut ::std::os::raw::c_void,
|
||||
szTailleDataIn: usize,
|
||||
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
pszTailleZone: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
pub fn SSV_FormaterFichier(
|
||||
pZDataIn: *mut ::std::os::raw::c_void,
|
||||
TailleDataIn: usize,
|
||||
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
pTailleZone: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
pub fn SSV_TraduireARL(
|
||||
NbZDonneesEntree: ::std::os::raw::c_short,
|
||||
TZDataIn: *mut *mut ::std::os::raw::c_void,
|
||||
TTailleZoneIn: *mut usize,
|
||||
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
pTailleZoneOut: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
pub fn SSV_LireNumSerieCarteVitale(
|
||||
pcNomRessource: *mut ::std::os::raw::c_char,
|
||||
numeroSerie: *mut ::std::os::raw::c_uchar,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
pub fn SSV_CalculerHashFacturePS(
|
||||
pcNumSerieCPS: *const ::std::os::raw::c_char,
|
||||
pZDataIn: *mut ::std::os::raw::c_void,
|
||||
usTailleDataIn: usize,
|
||||
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
pusTailleZone: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
pub fn SSV_AjouterSignaturePSFacture(
|
||||
pZDataIn: *mut ::std::os::raw::c_void,
|
||||
szTailleDataIn: usize,
|
||||
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
pszTailleZone: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
pub fn SSV_DechargerFacturesPdT(
|
||||
NomRessourcePS: *const ::std::os::raw::c_char,
|
||||
NomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||
CodePorteurPS: *const ::std::os::raw::c_char,
|
||||
pcNumFact: *const ::std::os::raw::c_char,
|
||||
sNbZDataIn: ::std::os::raw::c_short,
|
||||
pvTZDataIn: *mut *mut ::std::os::raw::c_void,
|
||||
psTTailleDataIn: *mut usize,
|
||||
pNbZDataOut: *mut ::std::os::raw::c_short,
|
||||
TZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
TTailleZoneOut: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
pub fn SSV_TraduireFSE(
|
||||
pZDataIn: *mut ::std::os::raw::c_void,
|
||||
TailleDataIn: usize,
|
||||
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
pTailleZone: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
// Fonctions TLA
|
||||
// TLA (Terminal Lecteur Applicatif) -> lecteur autre que PC-SC, on ne prend pas en compte cela
|
||||
|
||||
pub fn SSV_IdentifierTLA(
|
||||
pcNomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||
NumVersionCDC: *const ::std::os::raw::c_char,
|
||||
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
tailleDataOut: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
pub fn SSV_ChargerDonneesTLA(
|
||||
pcNomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||
sNbZDataIn: ::std::os::raw::c_short,
|
||||
pvTZDataIn: *mut *mut ::std::os::raw::c_void,
|
||||
psTTailleDataIn: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
pub fn SSV_ChargerFacturesPdT(
|
||||
pcNomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||
pcNumFacturation: *const ::std::os::raw::c_char,
|
||||
sNbZDataIn: ::std::os::raw::c_short,
|
||||
pvTZDataIn: *mut *mut ::std::os::raw::c_void,
|
||||
psTTailleDataIn: *mut usize,
|
||||
pNbZDataOut: *mut ::std::os::raw::c_short,
|
||||
TZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
TTailleZoneOut: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
pub fn SSV_DechargerFSETLA(
|
||||
NomRessourcePS: *const ::std::os::raw::c_char,
|
||||
NomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||
CodePorteurPS: *const ::std::os::raw::c_char,
|
||||
pcNumFact: *const ::std::os::raw::c_char,
|
||||
pNbZDataOut: *mut ::std::os::raw::c_short,
|
||||
TZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
TTailleZoneOut: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
pub fn SSV_DechargerFSETLANC(
|
||||
NomRessourcePS: *const ::std::os::raw::c_char,
|
||||
NomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||
CodePorteurPS: *const ::std::os::raw::c_char,
|
||||
pcNumFact: *const ::std::os::raw::c_char,
|
||||
pNbZDataOut: *mut ::std::os::raw::c_short,
|
||||
TZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
TTailleZoneOut: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
pub fn SSV_DechargerBeneficiaires(
|
||||
NomRessourcePS: *const ::std::os::raw::c_char,
|
||||
NomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||
CodePorteurPS: *const ::std::os::raw::c_char,
|
||||
cNumFacturation: *const ::std::os::raw::c_char,
|
||||
sNbZDataOut: *mut ::std::os::raw::c_short,
|
||||
pTZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
sTTailleDataOut: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
pub fn SSV_EffacerTLA(
|
||||
NomRessourcePS: *const ::std::os::raw::c_char,
|
||||
NomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||
CodePorteurPS: *const ::std::os::raw::c_char,
|
||||
cNumFacturation: *const ::std::os::raw::c_char,
|
||||
cTypeDonnee: *const ::std::os::raw::c_char,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
pub fn SSV_SecuriserFacture(
|
||||
pcNomRessourcePS: *const ::std::os::raw::c_char,
|
||||
pcNomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||
pcCodePorteurPS: *const ::std::os::raw::c_char,
|
||||
cNologSituation: ::std::os::raw::c_char,
|
||||
pcNumFact: *const ::std::os::raw::c_char,
|
||||
pvDataIn: *mut ::std::os::raw::c_void,
|
||||
szTailleDataIn: usize,
|
||||
pvDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
pszTailleDataOut: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
// Fonctions de gestion de configuration (GALSS)
|
||||
|
||||
pub fn SSV_LireConfig(
|
||||
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||
psTailleDataOut: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
pub fn SSV_LireDateLecteur(
|
||||
pcNomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||
pcDateHeure: *mut ::std::os::raw::c_char,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
pub fn SSV_MajDateLecteur(
|
||||
pcNomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||
pcDateHeure: *const ::std::os::raw::c_char,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
pub fn SSV_ChargerAppli(
|
||||
pcNomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||
sNbZDataIn: ::std::os::raw::c_short,
|
||||
pvTZDataIn: *mut *mut ::std::os::raw::c_void,
|
||||
psTTailleDataIn: *mut usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
// Fonctions techniques
|
||||
|
||||
// La fonction Initialiser Librairie a pour objet de charger et d’initialiser dans la mémoire du système :
|
||||
// - dans le cas où le GALSS est installé sur le poste :
|
||||
// - la bibliothèque du Gestionnaire d’Accès au Lecteur Santé Social (GALSS),
|
||||
// - qui charge la bibliothèque du Protocole Santé Social (PSS),
|
||||
// - la configuration du poste de travail à l’aide du fichier galssinf,
|
||||
// - les variables globales communes aux différents Services SESAM-Vitale,
|
||||
// - les fichiers de tables et scripts des répertoires par défaut.
|
||||
// Cette fonction accède au référentiel électronique en utilisant le chemin complet indiqué dans le fichier sesam.ini.
|
||||
pub fn SSV_InitLIB2(pcFichierSesam: *const ::std::os::raw::c_char) -> ::std::os::raw::c_ushort;
|
||||
|
||||
// La fonction Terminer a pour objet de décharger de la mémoire du système les éléments
|
||||
// chargés par la fonction Initialiser Librairie, qui ne sont plus utiles.
|
||||
pub fn SSV_TermLIB() -> ::std::os::raw::c_ushort;
|
||||
|
||||
/// Fonctions de Tracage
|
||||
//La fonction Allouer Zone Mémoire a un rôle purement technique : elle permet d’allouer, autrement dit de réserver une zone ou partie de la mémoire du poste de travail pour y écrire les données à passer en entrée d’un Service SESAM-Vitale.
|
||||
// Cette fonction doit être utilisée pour allouer toutes les zones de mémoire requises en entrée des Services SESAM-Vitale de manière à permettre un diagnostic fiable par le « mode trace » en cas de dysfonctionnement. En effet, son mode d’exécution est susceptible de fournir des informations utiles au « mode trace » lorsqu’il est activé.
|
||||
pub fn SSV_AllouerZoneMem(
|
||||
pZDataIn: *mut *mut ::std::os::raw::c_void,
|
||||
taille: usize,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
// La fonction Libérer Zone Mémoire a un rôle purement technique : elle permet de libérer une zone de mémoire du poste de travail précédemment allouée après exploitation des données qu’elle contient.
|
||||
// Cette fonction doit être utilisée pour libérer toutes les zones de mémoire :
|
||||
// - celles qui ont été allouées par le progiciel de santé pour fournir les données nécessaires à l’entrée des Services SESAM-Vitale, avant leur appel, celles qui ont été allouées par les Services SESAM-Vitale pour fournir en sortie les données utiles au progiciel de santé qui a fait appel à ces services,
|
||||
// - de façon à permettre un diagnostic fiable par le mode trace en cas de dysfonctionnement
|
||||
//En effet, son exécution est susceptible de fournir des informations utiles au « mode trace » lorsqu’il est activé.
|
||||
pub fn SSV_LibererZoneMem(pZone: *mut ::std::os::raw::c_void);
|
||||
|
||||
// La fonction Initialiser Trace a pour objet de permettre l’activation du « mode trace ».
|
||||
// Ce mode de fonctionnement est prévu pour permettre à l’assistance technique du GIE
|
||||
// SESAM-Vitale d’analyser les problèmes de mise en œuvre des Services SESAM-Vitale,
|
||||
// notamment lorsque une fonction retourne un code d’erreur de valeur hexadécimale supérieure à FF00.
|
||||
pub fn SSV_InitTrace(
|
||||
pathConf: *mut ::std::os::raw::c_char,
|
||||
ModeOuvertureFicherLog: *mut ::std::os::raw::c_char,
|
||||
ModuleLog: ::std::os::raw::c_ushort,
|
||||
NiveauLog: ::std::os::raw::c_uchar,
|
||||
) -> ::std::os::raw::c_ushort;
|
||||
|
||||
}
|
70
crates/services-sesam-vitale-sys/src/lib.rs
Normal file
70
crates/services-sesam-vitale-sys/src/lib.rs
Normal file
@ -0,0 +1,70 @@
|
||||
mod bindings;
|
||||
pub mod types;
|
||||
|
||||
use bindings::{SSV_InitLIB2, SSV_LireConfig, SSV_TermLIB};
|
||||
use std::{ffi::CString, fmt, path::Path, ptr};
|
||||
use types::serialization_types::{read_from_buffer, Configuration};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SesamVitaleError {
|
||||
code: u16,
|
||||
}
|
||||
|
||||
impl fmt::Display for SesamVitaleError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "Got error code {} from SSV_LireConfig", self.code)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init_library(sesam_ini_path: &Path) -> Result<(), SesamVitaleError> {
|
||||
// TODO: better error handling
|
||||
let path_str = sesam_ini_path.to_str().unwrap();
|
||||
let path_ptr = CString::new(path_str).expect("failed to create cstring");
|
||||
|
||||
let exit_code: u16 = unsafe { SSV_InitLIB2(path_ptr.as_ptr()) };
|
||||
if exit_code != 0 {
|
||||
let error = SesamVitaleError { code: exit_code };
|
||||
return Err(error);
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
pub fn close_library() -> Result<(), SesamVitaleError> {
|
||||
let exit_code: u16 = unsafe { SSV_TermLIB() };
|
||||
if exit_code != 0 {
|
||||
let error = SesamVitaleError { code: exit_code };
|
||||
return Err(error);
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn read_config() -> Result<Configuration, SesamVitaleError> {
|
||||
let mut buffer_ptr: *mut libc::c_void = ptr::null_mut();
|
||||
let mut size: libc::size_t = 0;
|
||||
|
||||
let buffer_ptr_ptr: *mut *mut libc::c_void = &mut buffer_ptr;
|
||||
let size_ptr: *mut libc::size_t = &mut size;
|
||||
|
||||
// Need to add proper error handling -> return a result with error code pointing to an error
|
||||
// enum
|
||||
let exit_code: u16 = unsafe { SSV_LireConfig(buffer_ptr_ptr, size_ptr) };
|
||||
|
||||
if exit_code != 0 {
|
||||
let error = SesamVitaleError { code: exit_code };
|
||||
return Err(error);
|
||||
};
|
||||
|
||||
let buffer: &[u8] = unsafe { std::slice::from_raw_parts(buffer_ptr as *const u8, size) };
|
||||
|
||||
// TODO: Improve error handling
|
||||
let configuration: Configuration = read_from_buffer(buffer).unwrap();
|
||||
|
||||
// TODO: Call library function for memory delocating
|
||||
unsafe { libc::free(buffer_ptr) };
|
||||
|
||||
Ok(configuration)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {}
|
264
crates/services-sesam-vitale-sys/src/types/common.rs
Normal file
264
crates/services-sesam-vitale-sys/src/types/common.rs
Normal file
@ -0,0 +1,264 @@
|
||||
pub struct Identification<T> {
|
||||
value: T,
|
||||
// Key to check the validity of the value
|
||||
// TODO: implement checking algorithm
|
||||
key: u8,
|
||||
}
|
||||
|
||||
pub type Byte = u8;
|
||||
|
||||
pub(crate) enum IdentificationNationale {
|
||||
NumeroAdeli(String),
|
||||
NumeroEmployeeDansStructure(IdentificationStructure, String),
|
||||
NumeroDRASS(String),
|
||||
NumeroRPPS(String),
|
||||
/// N° Etudiant Médecin type ADELI sur 9 caractères (information transmise par l’ANS)
|
||||
NumeroEtudiantMedecin(String),
|
||||
}
|
||||
|
||||
pub(crate) enum TypeCarteProfessionnelSante {
|
||||
/// Carte de Professionnel de Santé (CPS)
|
||||
CarteDeProfessionnelSante,
|
||||
/// Carte de Professionnel de Santé en Formation (CPF)
|
||||
CarteDeProfessionnelSanteEnFormation,
|
||||
/// Carte de Personnel d'Établissement de Santé (CDE/CPE)
|
||||
CarteDePersonnelEtablissementSante,
|
||||
/// Carte de Personnel Autorisé (CDA/CPA)
|
||||
CarteDePersonnelAutorise,
|
||||
/// Carte de Personne Morale
|
||||
CarteDePersonneMorale,
|
||||
}
|
||||
|
||||
pub(crate) enum CategorieCarteProfessionnelSante {
|
||||
Reelle,
|
||||
Test,
|
||||
Demonstration,
|
||||
}
|
||||
|
||||
pub(crate) enum CodeCivilite {
|
||||
Adjudant,
|
||||
Amiral,
|
||||
Aspirant,
|
||||
Aumônier,
|
||||
Capitaine,
|
||||
Cardinal,
|
||||
Chanoine,
|
||||
Colonel,
|
||||
Commandant,
|
||||
Commissaire,
|
||||
Conseiller,
|
||||
Directeur,
|
||||
Docteur,
|
||||
Douanier,
|
||||
Epouxse, // Epoux(se)
|
||||
Evêque,
|
||||
Général,
|
||||
Gouverneur,
|
||||
Ingénieur,
|
||||
Inspecteur,
|
||||
Lieutenant,
|
||||
Madame,
|
||||
Mademoiselle,
|
||||
Maître,
|
||||
Maréchal,
|
||||
Médecin,
|
||||
Mesdames,
|
||||
Mesdemoiselles,
|
||||
Messieurs,
|
||||
Monseigneur,
|
||||
Monsieur,
|
||||
NotreDame,
|
||||
Pasteur,
|
||||
Préfet,
|
||||
Président,
|
||||
Professeur,
|
||||
Recteur,
|
||||
Sergent,
|
||||
SousPréfet,
|
||||
Technicien,
|
||||
Veuve,
|
||||
}
|
||||
|
||||
pub(crate) enum IdentificationStructure {
|
||||
NumeroAdeliCabinet(String),
|
||||
NumeroFINESS(String),
|
||||
NumeroSIREN(String),
|
||||
NumeroSIRET(String),
|
||||
NumeroRPPSCabinet(String),
|
||||
}
|
||||
|
||||
pub(crate) enum ModeExercice {
|
||||
LiberalExploitantCommercant, // Libéral, exploitant, commerçant
|
||||
Salarie,
|
||||
Remplacant,
|
||||
Benevole,
|
||||
}
|
||||
|
||||
pub(crate) enum StatutExercice {
|
||||
// TAB-Statuts géré par l’ANS il faut trouver la donnee
|
||||
PLACEHOLDER(u8),
|
||||
}
|
||||
|
||||
pub(crate) enum SecteurActivite {
|
||||
EtablissementPublicDeSanté,
|
||||
HopitauxMilitaires,
|
||||
EtablissementPrivePSPH, // Participant au Service Public Hospitalier
|
||||
EtablissementPriveNonPSPH,
|
||||
DispensaireDeSoins,
|
||||
AutresStructuresDeSoinsRelevantDuServiceDeSanteDesArmees,
|
||||
CabinetIndividuel,
|
||||
CabinetDeGroupe,
|
||||
ExerciceEnSociete,
|
||||
SecteurPrivePHTempsPlein,
|
||||
TransportSanitaire,
|
||||
EntrepriseDInterim,
|
||||
EtablissementDeSoinsEtPrevention,
|
||||
PreventionEtSoinsEnEntreprise,
|
||||
SanteScolaireEtUniversitaire,
|
||||
RecrutementEtGestionRH,
|
||||
PMIPlanificationFamiliale,
|
||||
EtablissementPourHandicapes,
|
||||
ComMarketingConsultingMedia,
|
||||
EtablissementPersonnesAgees,
|
||||
EtablissementAideaLaFamille,
|
||||
EtablissementDEnseignement,
|
||||
EtablissementsDeProtectionDeLEnfance,
|
||||
EtablissementsDHebergementEtDeReadaptation,
|
||||
Recherche,
|
||||
AssurancePrivee,
|
||||
OrganismeDeSecuriteSociale,
|
||||
MinistèreEtServicesDeconcentres,
|
||||
CollectivitesTerritoriales,
|
||||
AssociationsEtOrganitationsHumanitaire,
|
||||
LaboratoireDeBiologieMedicale,
|
||||
AutreEtablissementSanitaire,
|
||||
ProductionCommercialisationGrosBienMedicaux,
|
||||
CommerceDétailDeBiensMédicaux,
|
||||
PharmacieDOfficine,
|
||||
CentreDeDialyse,
|
||||
ParaPharmacie,
|
||||
AutreSecteurDActivité,
|
||||
SecteurNonDefini,
|
||||
CentreAntiCancer,
|
||||
CentreDeTransfusionSanguine,
|
||||
RépartitionDistribributionFabricationExploitationImportationMedicamentsEtDispositifsMédicaux,
|
||||
IncendiesEtSecours,
|
||||
EntreprisesIndustriellesEtTertiairesHorsIndustriesPharmaceutiques,
|
||||
EntiteDUnTOM,
|
||||
FabricationExploitationImportationMedicamentsEtDispositifsMedicaux,
|
||||
}
|
||||
|
||||
pub(crate) type IdentificationFacturation = u32;
|
||||
pub(crate) enum CodeConventionnel {
|
||||
NonConventionne,
|
||||
Conventionne,
|
||||
ConventionneAvecDepassement,
|
||||
ConventionneAvecHonorairesLibres,
|
||||
}
|
||||
|
||||
/// Code spécialité ou Code spécialité de l'exécutant
|
||||
pub(crate) enum CodeSpecialite {
|
||||
MedecineGenerale,
|
||||
AnesthesieReanimation,
|
||||
Cardiologie,
|
||||
ChirurgieGenerale,
|
||||
DermatologieEtVenerologie,
|
||||
Radiologie,
|
||||
GynecologieObstetrique,
|
||||
GastroEnterologieEtHepatologie,
|
||||
MedecineInterne,
|
||||
NeuroChirurgie,
|
||||
OtoRhinoLaryngologie,
|
||||
Pediatrie,
|
||||
Pneumologie,
|
||||
Rhumatologie,
|
||||
Ophtalmologie,
|
||||
ChirurgieUrologique,
|
||||
NeuroPsychiatrie,
|
||||
Stomatologie,
|
||||
ChirurgienDentiste,
|
||||
ReanimationMedicale,
|
||||
SageFemme,
|
||||
SpecialisteEnMedecineGeneraleAvecDiplome,
|
||||
SpecialisteEnMedecineGeneraleReconnuParLOrdre,
|
||||
Infirmier,
|
||||
Psychologue,
|
||||
MasseurKinesitherapeute,
|
||||
PedicurePodologue,
|
||||
Orthophoniste,
|
||||
Orthoptiste,
|
||||
LaboratoireDAnalysesMedicales,
|
||||
ReeducationReadaptationFonctionnelle,
|
||||
Neurologie,
|
||||
Psychiatrie,
|
||||
Geriatrie,
|
||||
Nephrologie,
|
||||
ChirurgieDentaireSpecialiteODF,
|
||||
AnatomoCytoPathologie,
|
||||
MedecinBiologiste,
|
||||
LaboratoirePolyvalent,
|
||||
LaboratoireDAnatomoCytoPathologique,
|
||||
ChirurgieOrthopediqueEtTraumatologie,
|
||||
EndocrinologieEtMetabolisme,
|
||||
ChirurgieInfantile,
|
||||
ChirurgieMaxilloFaciale,
|
||||
ChirurgieMaxilloFacialeEtStomatologie,
|
||||
ChirurgiePlastiqueReconstructriceEtEsthetique,
|
||||
ChirurgieThoraciqueEtCardioVasculaire,
|
||||
ChirurgieVasculaire,
|
||||
ChirurgieVisceraleEtDigestive,
|
||||
PharmacieDOfficine,
|
||||
PharmacieMutualiste,
|
||||
ChirurgienDentisteSpecialiteCO,
|
||||
ChirurgienDentisteSpecialiteMBD,
|
||||
PrestataireDeTypeSociete,
|
||||
PrestataireArtisan,
|
||||
PrestataireDeTypeAssociation,
|
||||
Orthesiste,
|
||||
Opticien,
|
||||
Audioprothesiste,
|
||||
ÉpithesisteOculariste,
|
||||
PodoOrthesiste,
|
||||
Orthoprothesiste,
|
||||
ChirurgieOrale,
|
||||
GynecologieMedicale,
|
||||
Hematologie,
|
||||
MedecineNucleaire,
|
||||
OncologieMedicale,
|
||||
OncologieRadiotherapique,
|
||||
PsychiatrieDeLEnfantEtDeLAdolescent,
|
||||
Radiotherapie,
|
||||
Obstetrique,
|
||||
GenetiqueMedicale,
|
||||
ObstetriqueEtGynecologieMedicale,
|
||||
SantePubliqueEtMedecineSociale,
|
||||
MedecineDesMaladiesInfectieusesEtTropicales,
|
||||
MedecineLegaleEtExpertisesMedicales,
|
||||
MedecineDUrgence,
|
||||
MedecineVasculaire,
|
||||
Allergologie,
|
||||
InfirmierExercantEnPratiquesAvancees, // IPA
|
||||
}
|
||||
|
||||
/// Page 54 dictionnaires des donnees
|
||||
/// donnees inutilises pour les pharmacies
|
||||
pub(crate) enum CodeZoneTarifaire {}
|
||||
|
||||
pub(crate) enum CodeZoneIK {
|
||||
PasIndemniteKilometrique,
|
||||
IndemnitesKilometriquesPlaine,
|
||||
IndemnitesKilometriquesMontagne,
|
||||
}
|
||||
|
||||
pub(crate) enum CodeAgrement {
|
||||
PasDAgrementRadio,
|
||||
/// Agrément D ou agrément DDASS
|
||||
AgrementDDASS,
|
||||
/// Agrément A, B, C, E et F
|
||||
AgrementABCEF,
|
||||
/// Agrément G, H et J
|
||||
AgrementGHJ,
|
||||
AgrementK,
|
||||
AgrementL,
|
||||
AgrementM,
|
||||
}
|
1
crates/services-sesam-vitale-sys/src/types/mod.rs
Normal file
1
crates/services-sesam-vitale-sys/src/types/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod serialization_types;
|
@ -0,0 +1,248 @@
|
||||
use bitvec::index::BitIdx;
|
||||
use std::{error::Error, fmt, str::FromStr, vec::Vec};
|
||||
|
||||
use deku::{
|
||||
bitvec::{BitStore, Msb0}, ctx::ByteSize, deku_derive, reader::{Reader, ReaderRet}, DekuContainerRead, DekuError, DekuReader
|
||||
};
|
||||
|
||||
#[deku_derive(DekuRead)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[deku(endian = "big")]
|
||||
pub(crate) struct GroupId(u16);
|
||||
|
||||
trait MapToDekuParseError<T> {
|
||||
fn map_to_deku_parse_error(self) -> Result<T, DekuError>;
|
||||
}
|
||||
|
||||
impl<T, E: Error> MapToDekuParseError<T> for Result<T, E> {
|
||||
fn map_to_deku_parse_error(self) -> Result<T, DekuError> {
|
||||
self.map_err(|e| DekuError::Parse(e.to_string().into()))
|
||||
}
|
||||
}
|
||||
|
||||
#[deku_derive(DekuRead)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub(crate) struct DataField {
|
||||
#[deku(reader = "read_size(deku::reader)")]
|
||||
pub(crate) data_size: ByteSize,
|
||||
|
||||
#[deku(bytes_read = "data_size.0")]
|
||||
pub(crate) data: Vec<u8>,
|
||||
}
|
||||
|
||||
#[deku_derive(DekuRead)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub(crate) struct BlockHeader {
|
||||
pub(crate) group_id: GroupId,
|
||||
|
||||
#[deku(reader = "read_size(deku::reader)")]
|
||||
pub(crate) data_size: ByteSize,
|
||||
}
|
||||
|
||||
#[deku_derive(DekuRead)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub(crate) struct DataBlock {
|
||||
pub(crate) header: BlockHeader,
|
||||
|
||||
#[deku(ctx = "header.group_id")]
|
||||
pub(crate) inner: DataGroup,
|
||||
}
|
||||
|
||||
fn read_size<R: std::io::Read>(reader: &mut Reader<R>) -> Result<ByteSize, DekuError> {
|
||||
let first_byte: u8 = u8::from_reader_with_ctx(reader, ())?;
|
||||
|
||||
let is_length_expanded = first_byte.get_bit::<Msb0>(BitIdx::new(0).map_to_deku_parse_error()?);
|
||||
|
||||
match is_length_expanded {
|
||||
true => {
|
||||
let size_of_data_size: ByteSize = ByteSize((first_byte & 0b0111_1111) as usize);
|
||||
|
||||
if size_of_data_size.0 > 4 {
|
||||
return Err(DekuError::Parse("Size of the length encoding is > 4, this is not normal. Probable parsing error".to_string().into()));
|
||||
};
|
||||
|
||||
// maximum size of the buffer is 4, we use the offset to read values less than 4 bytes
|
||||
let buffer: &mut [u8; 4] = &mut [0; 4];
|
||||
let write_offset = 4 - size_of_data_size.0;
|
||||
|
||||
match reader.read_bytes(size_of_data_size.0, &mut buffer[write_offset..])? {
|
||||
ReaderRet::Bits(_bit_vec) => Err(DekuError::Parse("Got bits when trying to read bytes -> reader is unaligned, this is not normal.".to_string().into())),
|
||||
ReaderRet::Bytes => Ok(ByteSize(u32::from_be_bytes(*buffer) as usize)),
|
||||
}
|
||||
}
|
||||
false => Ok(ByteSize(first_byte as usize)),
|
||||
}
|
||||
}
|
||||
|
||||
// Using this as the map function asks deku to parse a datafield
|
||||
// We then use the datafield and convert it to the corresponding value
|
||||
fn convert_from_data_field<T>(data_field: DataField) -> Result<T, DekuError>
|
||||
where
|
||||
T: FromStr,
|
||||
T::Err: Error,
|
||||
{
|
||||
let text = String::from_utf8(data_field.data).map_to_deku_parse_error()?;
|
||||
T::from_str(&text).map_to_deku_parse_error()
|
||||
}
|
||||
|
||||
#[deku_derive(DekuRead)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct SSVVersionNumber(#[deku(map = "convert_from_data_field")] u16);
|
||||
|
||||
#[deku_derive(DekuRead)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct GALSSVersionNumber(#[deku(map = "convert_from_data_field")] u16);
|
||||
|
||||
#[deku_derive(DekuRead)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct PSSVersionNumber(#[deku(map = "convert_from_data_field")] u16);
|
||||
|
||||
#[deku_derive(DekuRead)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct ConfigurationHeader {
|
||||
pub ssv_version: SSVVersionNumber,
|
||||
pub galss_version: GALSSVersionNumber,
|
||||
pub pss_version: PSSVersionNumber,
|
||||
}
|
||||
|
||||
#[deku_derive(DekuRead)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct PCSCReaderName(#[deku(map = "convert_from_data_field")] String);
|
||||
|
||||
#[deku_derive(DekuRead)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct CardType(#[deku(map = "convert_from_data_field")] u8);
|
||||
|
||||
#[deku_derive(DekuRead)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct PCSCReader {
|
||||
pub name: PCSCReaderName,
|
||||
pub card_type: CardType,
|
||||
}
|
||||
|
||||
#[deku_derive(DekuRead)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct SESAMVitaleComponentID(#[deku(map = "convert_from_data_field")] u16);
|
||||
|
||||
#[deku_derive(DekuRead)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct SESAMVitaleComponentDescription(#[deku(map = "convert_from_data_field")] String);
|
||||
|
||||
#[deku_derive(DekuRead)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct SESAMVitaleComponentVersion(#[deku(map = "convert_from_data_field")] String);
|
||||
|
||||
#[deku_derive(DekuRead)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct SESAMVitaleComponent {
|
||||
pub id: SESAMVitaleComponentID,
|
||||
pub description: SESAMVitaleComponentDescription,
|
||||
pub version: SESAMVitaleComponentVersion,
|
||||
}
|
||||
|
||||
#[deku_derive(DekuRead)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct ReaderConfiguration {}
|
||||
|
||||
#[deku_derive(DekuRead)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[deku(ctx = "group_id: GroupId", id = "group_id.0")]
|
||||
pub enum DataGroup {
|
||||
#[deku(id = 60)]
|
||||
ConfigurationHeader(ConfigurationHeader),
|
||||
#[deku(id = 61)]
|
||||
ReaderConfiguration(ReaderConfiguration),
|
||||
#[deku(id = 64)]
|
||||
SESAMVitaleComponent(SESAMVitaleComponent),
|
||||
#[deku(id = 67)]
|
||||
PCSCReader(PCSCReader),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ConfigurationError {
|
||||
MultipleConfigurationHeaders,
|
||||
MissingConfigurationHeader,
|
||||
}
|
||||
|
||||
impl fmt::Display for ConfigurationError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
ConfigurationError::MultipleConfigurationHeaders => {
|
||||
write!(f, "Multiple ConfigurationHeader blocks found")
|
||||
}
|
||||
ConfigurationError::MissingConfigurationHeader => {
|
||||
write!(f, "Missing ConfigurationHeader block")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for ConfigurationError {}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Configuration {
|
||||
pub configuration_header: ConfigurationHeader,
|
||||
pub reader_configurations: Vec<ReaderConfiguration>,
|
||||
pub sesam_vitale_components: Vec<SESAMVitaleComponent>,
|
||||
pub pcsc_readers: Vec<PCSCReader>,
|
||||
}
|
||||
|
||||
impl TryFrom<Vec<DataBlock>> for Configuration {
|
||||
type Error = ConfigurationError;
|
||||
|
||||
fn try_from(data_blocks: Vec<DataBlock>) -> Result<Self, Self::Error> {
|
||||
let mut configuration_header: Option<ConfigurationHeader> = None;
|
||||
let mut reader_configurations: Vec<ReaderConfiguration> = Vec::new();
|
||||
let mut sesam_vitale_components: Vec<SESAMVitaleComponent> = Vec::new();
|
||||
let mut pcsc_readers: Vec<PCSCReader> = Vec::new();
|
||||
|
||||
for block in data_blocks {
|
||||
match block.inner {
|
||||
DataGroup::ConfigurationHeader(header) => {
|
||||
if configuration_header.is_some() {
|
||||
return Err(ConfigurationError::MultipleConfigurationHeaders);
|
||||
}
|
||||
configuration_header = Some(header);
|
||||
}
|
||||
DataGroup::ReaderConfiguration(configuration) => {
|
||||
reader_configurations.push(configuration)
|
||||
}
|
||||
DataGroup::SESAMVitaleComponent(component) => {
|
||||
sesam_vitale_components.push(component);
|
||||
}
|
||||
DataGroup::PCSCReader(reader) => {
|
||||
pcsc_readers.push(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
let configuration_header = match configuration_header {
|
||||
Some(header) => header,
|
||||
None => return Err(ConfigurationError::MissingConfigurationHeader),
|
||||
};
|
||||
|
||||
Ok(Self {
|
||||
configuration_header,
|
||||
reader_configurations,
|
||||
sesam_vitale_components,
|
||||
pcsc_readers,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn read_from_buffer<T: TryFrom<Vec<DataBlock>>>(buffer: &[u8]) -> Result<T, T::Error>{
|
||||
let mut data_blocks: Vec<DataBlock> = Vec::new();
|
||||
let mut offset = 0;
|
||||
|
||||
let mut remaining_buffer = buffer;
|
||||
|
||||
while !remaining_buffer.is_empty() {
|
||||
// TODO: properly handle errors
|
||||
let (rest, data_block) = DataBlock::from_bytes((remaining_buffer, offset)).unwrap();
|
||||
|
||||
data_blocks.push(data_block);
|
||||
|
||||
(remaining_buffer, offset) = rest;
|
||||
};
|
||||
|
||||
T::try_from(data_blocks)
|
||||
}
|
45
crates/services-sesam-vitale-sys/src/types/types.rs
Normal file
45
crates/services-sesam-vitale-sys/src/types/types.rs
Normal file
@ -0,0 +1,45 @@
|
||||
pub(crate) use crate::types::common::IdentificationNationale;
|
||||
|
||||
use super::common::{
|
||||
Byte, CategorieCarteProfessionnelSante, CodeAgrement, CodeCivilite, CodeConventionnel,
|
||||
CodeSpecialite, CodeZoneIK, CodeZoneTarifaire, Identification, IdentificationFacturation,
|
||||
IdentificationStructure, ModeExercice, SecteurActivite, StatutExercice,
|
||||
TypeCarteProfessionnelSante,
|
||||
};
|
||||
|
||||
pub(crate) struct CarteProfessionnelSante {
|
||||
type_carte: TypeCarteProfessionnelSante,
|
||||
categorie_carte: CategorieCarteProfessionnelSante,
|
||||
professionnel_sante: ProfessionnelDeSante,
|
||||
}
|
||||
|
||||
struct ProfessionnelDeSante {
|
||||
prenom: String,
|
||||
nom: String,
|
||||
code_civilite: CodeCivilite,
|
||||
identification_nationale: Identification<IdentificationNationale>,
|
||||
situations_execice: Vec<SituationDExercice>,
|
||||
}
|
||||
struct StructureMedicale {
|
||||
/// Nom Entreprise
|
||||
raison_sociale: String,
|
||||
identification: Identification<IdentificationStructure>,
|
||||
}
|
||||
|
||||
struct SituationDExercice {
|
||||
/// Numéro identifiant la situation du PS parmi ses autres situations inscrites sur sa CPS
|
||||
identifiant_situation: Byte,
|
||||
mode_exercice: Option<ModeExercice>,
|
||||
statut_exercice: Option<StatutExercice>,
|
||||
secteur_activite: Option<SecteurActivite>,
|
||||
structure_d_exercice: Option<StructureMedicale>,
|
||||
identification_facturation: Identification<IdentificationFacturation>,
|
||||
identification_remplacant: Option<Identification<IdentificationNationale>>,
|
||||
code_conventionnel: CodeConventionnel,
|
||||
code_specialite: CodeSpecialite,
|
||||
code_zone_tarifaire: CodeZoneTarifaire,
|
||||
code_zone_ik: CodeZoneIK,
|
||||
code_agrement: CodeAgrement,
|
||||
habilite_signature_facture: bool,
|
||||
habilite_signature_lot: bool,
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
SESAM_FSV_VERSION=1.40.14
|
||||
SESAM_FSV_LIB_PATH="C:/Program Files/santesocial/fsv/${SESAM_FSV_VERSION}/lib"
|
||||
SESAM_FSV_SSVLIB=ssvw64
|
@ -1,2 +0,0 @@
|
||||
SESAM_FSV_VERSION=1.40.14
|
||||
SESAM_INI_PATH=${ALLUSERSPROFILE}\\santesocial\\fsv\\${SESAM_FSV_VERSION}\\conf\\sesam.ini
|
@ -1,2 +1,2 @@
|
||||
SESAM_FSV_VERSION=1.40.13
|
||||
SESAM_INI_PATH=${ALLUSERSPROFILE}\\santesocial\\fsv\\${SESAM_FSV_VERSION}\\conf\\sesam.ini
|
||||
SESAM_FSV_VERSION=1.40.13
|
||||
SESAM_INI_PATH=${ALLUSERSPROFILE}\\santesocial\\fsv\\${SESAM_FSV_VERSION}\\conf\\sesam.ini
|
@ -16,10 +16,7 @@ fn main() {
|
||||
|
||||
// Add local lib directory to the linker search path (for def files and static libs)
|
||||
let static_lib_path = manifest_path.join("lib");
|
||||
println!(
|
||||
"cargo::rustc-link-search=native={}",
|
||||
static_lib_path.display()
|
||||
);
|
||||
println!("cargo::rustc-link-search=native={}", static_lib_path.display());
|
||||
|
||||
// Add the SESAM_FSV_LIB_PATH to the linker search path
|
||||
let fsv_lib_path = PathBuf::from(env::var("SESAM_FSV_LIB_PATH").unwrap());
|
||||
@ -34,9 +31,6 @@ fn main() {
|
||||
}
|
||||
|
||||
// Link the SESAM_FSV_SSVLIB dynamic library
|
||||
println!(
|
||||
"cargo::rustc-link-lib=dylib={}",
|
||||
env::var("SESAM_FSV_SSVLIB").unwrap()
|
||||
);
|
||||
println!("cargo::rustc-link-lib=dylib={}", env::var("SESAM_FSV_SSVLIB").unwrap());
|
||||
// TODO : try `raw-dylib` instead of `dylib` on Windows to avoid the need of the `lib` headers compiled from the `def`
|
||||
}
|
||||
|
Binary file not shown.
@ -1,876 +0,0 @@
|
||||
use libc::{c_void, size_t};
|
||||
use std::ffi::CString;
|
||||
use std::ptr;
|
||||
|
||||
use crate::libssv::SSV_LireDroitsVitale;
|
||||
|
||||
use crate::ssv_memory::{decode_ssv_memory, Block};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct CarteVitale {
|
||||
donneesAssure: DonneesAssure,
|
||||
serviceAMOFamille: ServiceAMOFamille,
|
||||
donneesAccidentTravail: DonneesAccidentTravail,
|
||||
donneesBeneficiaire: Vec<DonneesBeneficiaire>,
|
||||
}
|
||||
|
||||
// 1. CB = Caractères Binaires »
|
||||
// 2. CE = Caractères « Etendus » (ISO 8859-1)
|
||||
// 3. CA = Caractères Alphanumériques (ASCII?)
|
||||
// 4. CN = Caractères Numériques
|
||||
#[derive(Debug, Default)]
|
||||
struct DonneesAssure {
|
||||
type_de_carte_vitale: char, // CA
|
||||
numero_de_serie: String, // CN - 1 -> 20
|
||||
date_de_fin_de_validite: String, // CN - Format AAAAMMJJ0000
|
||||
donnees_administration_ruf1: char, // CN
|
||||
donnees_administration_ruf2: String, // CA - 24
|
||||
donnees_ruf_administration: String, // CE - 10
|
||||
type_d_identification_du_porteur: char, // CA
|
||||
numero_national_d_immatriculation: String, // CA - 13
|
||||
cle_du_nir: String, // CA - 2
|
||||
code_regime: String, // CN - 2
|
||||
caisse_gestionnaire: String, // CN - 3
|
||||
centre_gestionnaire: String, // CN - 4
|
||||
code_gestion: String, // CA - 2
|
||||
donnees_ruf_famille: String, // CE - 55
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct ServiceAMOFamille {
|
||||
code_service_amo_famille: String, // CN - 2
|
||||
date_de_debut_service_amo_famille: String, // CN - Format AAAAMMJJ0000
|
||||
date_de_fin_service_amo_famille: String, // CN - Format AAAAMMJJ0000
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct DonneesAccidentTravail {
|
||||
organisme_gestionnaire_risque_at: String, // CN - 9
|
||||
code_at: char, // CA - 2
|
||||
identifiant_at: String, // CN - 9
|
||||
organisme_gestionnaire_at1: String, // CN - 9
|
||||
code_at1: char, // CA - 2
|
||||
identifiant_at1: String, // CN - 9
|
||||
organisme_gestionnaire_at2: String, // CN - 9
|
||||
code_at2: char, // CA - 2
|
||||
identifiant_at2: String, // CN - 9
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct DonneesBeneficiaire {
|
||||
nom_usuel: String, // CE - 27
|
||||
nom_de_famille: String, // CE - 27
|
||||
prenom: String, // CE - 27
|
||||
adresse_ligne_1: String, // CE - 32
|
||||
adresse_ligne_2: String, // CE - 32
|
||||
adresse_ligne_3: String, // CE - 32
|
||||
adresse_ligne_4: String, // CE - 32
|
||||
adresse_ligne_5: String, // CE - 32
|
||||
nir_certifie: String, // CA - 13
|
||||
cle_du_nir_certifie: String, // CN - 2
|
||||
date_de_certification_du_nir: String, // CN - Format AAAAMMJJ0000
|
||||
date_de_naissance: String, // CN - Format AAAAMMJJ0000
|
||||
rang_de_naissance: String, // CN - 1
|
||||
qualite: String, // CN - 2
|
||||
code_service_amo_beneficiaire: char, // CA - 2
|
||||
date_de_debut_service_amo: String, // CN - Format AAAAMMJJ0000
|
||||
date_de_fin_service_amo: String, // CN - Format AAAAMMJJ0000
|
||||
donnees_ruf_amo: String, // CE - 30
|
||||
periodeDroitsAMO: Vec<PeriodeDroitsAMO>,
|
||||
periodeCodeCouverture: Vec<PeriodeCodeCouverture>,
|
||||
donneesMutuelle: DonneesMutuelle,
|
||||
donneesComplementaire: DonneesComplementaire,
|
||||
donneesRUFBeneficiaireComplementaire: DonneesRUFBeneficiaireComplementaire,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct PeriodeDroitsAMO {
|
||||
date_de_debut_droits_amo: String, // CN - Format AAAAMMJJ0000
|
||||
date_de_fin_droits_amo: String, // CN - Format AAAAMMJJ0000
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct PeriodeCodeCouverture {
|
||||
date_de_debut_code_couverture: String, // CN - Format AAAAMMJJ0000
|
||||
date_de_fin_code_couverture: String, // CN - Format AAAAMMJJ0000
|
||||
code_ald: String, // CN - 1
|
||||
code_situation: String, // CN - 4
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct DonneesMutuelle {
|
||||
identification_mutuelle: String, // CN - 8
|
||||
garanties_effectives: String, // CA - 8
|
||||
indicateur_de_traitement_mutuelle: String, // CN - 2
|
||||
type_de_services_associes: char, // CA - 1
|
||||
services_associes_au_contrat: String, // CA - 17
|
||||
code_aiguillage_sts: char, // CA - 1
|
||||
periodeDroitsMutuelle: Vec<PeriodeDroitsMutuelle>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct PeriodeDroitsMutuelle {
|
||||
date_de_debut_droits_mutuelle: String, // CN - Format AAAAMMJJ0000
|
||||
date_de_fin_droits_mutuelle: String, // CN - Format AAAAMMJJ0000
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct DonneesComplementaire {
|
||||
numero_complementaire_b2: String, // CA - 10
|
||||
numero_complementaire_edi: String, // CA - 19
|
||||
numero_adherent_amc: String, // CA - 8
|
||||
indicateur_de_traitement_amc: String, // CN - 2
|
||||
date_de_debut_validite_amc: String, // CN - Format AAAAMMJJ0000
|
||||
date_de_fin_validite_amc: String, // CN - Format AAAAMMJJ0000
|
||||
code_routage_flux_amc: String, // CA - 2
|
||||
identifiant_hote: String, // CA - 3
|
||||
nom_de_domaine_amc: String, // CE - 20
|
||||
code_aiguillage_sts: char, // CA - 1
|
||||
type_de_services_associes: char, // CA - 1
|
||||
services_associes_au_contrat: String, // CE - 17
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct DonneesRUFBeneficiaireComplementaire {
|
||||
donnees_ruf_beneficiaire_complementaire: String, // CE - 115
|
||||
}
|
||||
|
||||
pub fn LireDroitsVitale(
|
||||
lecteurPS: &str,
|
||||
lecteurVitale: &str,
|
||||
codePorteurPS: &str,
|
||||
dateConsultation: &str,
|
||||
) -> Result<CarteVitale, String> {
|
||||
let resource_ps = CString::new(lecteurPS).expect("CString::new failed");
|
||||
let resource_vitale = CString::new(lecteurVitale).expect("CString::new failed");
|
||||
let card_number = CString::new(codePorteurPS).expect("CString::new failed");
|
||||
let date_consultation = CString::new(dateConsultation).expect("CString::new failed");
|
||||
|
||||
let mut buffer: *mut c_void = ptr::null_mut();
|
||||
let mut size: size_t = 0;
|
||||
let mut hex_values: &[u8] = &[];
|
||||
unsafe {
|
||||
let result = SSV_LireDroitsVitale(
|
||||
resource_ps.as_ptr(),
|
||||
resource_vitale.as_ptr(),
|
||||
card_number.as_ptr(),
|
||||
date_consultation.as_ptr(),
|
||||
&mut buffer,
|
||||
&mut size,
|
||||
);
|
||||
println!("SSV_LireDroitsVitale result: {}", result);
|
||||
|
||||
if !buffer.is_null() {
|
||||
hex_values = std::slice::from_raw_parts(buffer as *const u8, size);
|
||||
}
|
||||
}
|
||||
|
||||
let groups = decode_ssv_memory(hex_values, hex_values.len());
|
||||
|
||||
let OUT = decode_carte_vitale(groups);
|
||||
|
||||
unsafe {
|
||||
if !buffer.is_null() {
|
||||
libc::free(buffer); // ??? si liberer avant decode_ssv_memory et decode_carte_vitale alors hex_values n'est plus correct ???
|
||||
}
|
||||
}
|
||||
OUT
|
||||
|
||||
}
|
||||
|
||||
fn decode_carte_vitale(groups: Vec<Block>) -> Result<CarteVitale, String> {
|
||||
let mut cartevitale = CarteVitale::default();
|
||||
|
||||
for group in groups {
|
||||
for field in group.content {
|
||||
match (group.id, field.id) {
|
||||
(104, 1) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.push(DonneesBeneficiaire::default());
|
||||
}
|
||||
(105, 1) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.periodeDroitsAMO
|
||||
.push(PeriodeDroitsAMO::default());
|
||||
}
|
||||
(106, 1) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.periodeCodeCouverture
|
||||
.push(PeriodeCodeCouverture::default());
|
||||
}
|
||||
(108, 1) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesMutuelle
|
||||
.periodeDroitsMutuelle
|
||||
.push(PeriodeDroitsMutuelle::default());
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if field.content.len() > 0 {
|
||||
match (group.id, field.id) {
|
||||
(101, 1) => {
|
||||
let byte = field.content[0];
|
||||
cartevitale.donneesAssure.type_de_carte_vitale = byte as char;
|
||||
}
|
||||
(101, 2) => {
|
||||
cartevitale.donneesAssure.numero_de_serie = //bytes_to_decimal_string(&field.content);
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(101, 3) => {
|
||||
cartevitale.donneesAssure.date_de_fin_de_validite =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(101, 4) => {
|
||||
println!("101.4 field.size: {:#?}", field.size);
|
||||
let byte = field.content[0];
|
||||
cartevitale.donneesAssure.donnees_administration_ruf1 = byte as char;
|
||||
}
|
||||
(101, 5) => {
|
||||
cartevitale.donneesAssure.donnees_administration_ruf2 =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(101, 6) => {
|
||||
cartevitale.donneesAssure.donnees_ruf_administration =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(101, 7) => {
|
||||
let byte = field.content[0];
|
||||
cartevitale.donneesAssure.type_d_identification_du_porteur = byte as char;
|
||||
}
|
||||
(101, 8) => {
|
||||
cartevitale.donneesAssure.numero_national_d_immatriculation =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(101, 9) => {
|
||||
cartevitale.donneesAssure.cle_du_nir =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(101, 10) => {
|
||||
cartevitale.donneesAssure.code_regime =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(101, 11) => {
|
||||
cartevitale.donneesAssure.caisse_gestionnaire =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(101, 12) => {
|
||||
cartevitale.donneesAssure.centre_gestionnaire =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(101, 13) => {
|
||||
cartevitale.donneesAssure.code_gestion =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(101, 14) => {
|
||||
cartevitale.donneesAssure.donnees_ruf_famille =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(102, 1) => {
|
||||
cartevitale.serviceAMOFamille.code_service_amo_famille =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(102, 2) => {
|
||||
cartevitale
|
||||
.serviceAMOFamille
|
||||
.date_de_debut_service_amo_famille =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(102, 3) => {
|
||||
cartevitale
|
||||
.serviceAMOFamille
|
||||
.date_de_fin_service_amo_famille =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(103, 1) => {
|
||||
cartevitale
|
||||
.donneesAccidentTravail
|
||||
.organisme_gestionnaire_risque_at =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(103, 2) => {
|
||||
let byte = field.content[0];
|
||||
cartevitale.donneesAccidentTravail.code_at = byte as char;
|
||||
}
|
||||
(103, 3) => {
|
||||
cartevitale.donneesAccidentTravail.identifiant_at =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(103, 4) => {
|
||||
cartevitale
|
||||
.donneesAccidentTravail
|
||||
.organisme_gestionnaire_at1 =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(103, 5) => {
|
||||
let byte = field.content[0];
|
||||
cartevitale.donneesAccidentTravail.code_at1 = byte as char;
|
||||
}
|
||||
(103, 6) => {
|
||||
cartevitale.donneesAccidentTravail.identifiant_at1 =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(103, 7) => {
|
||||
cartevitale
|
||||
.donneesAccidentTravail
|
||||
.organisme_gestionnaire_at2 =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(103, 8) => {
|
||||
let byte = field.content[0];
|
||||
cartevitale.donneesAccidentTravail.code_at2 = byte as char;
|
||||
}
|
||||
(103, 9) => {
|
||||
cartevitale.donneesAccidentTravail.identifiant_at2 =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(104, 1) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.nom_usuel = String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(104, 2) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.nom_de_famille = String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(104, 3) => {
|
||||
cartevitale.donneesBeneficiaire.last_mut().unwrap().prenom =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(104, 4) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.adresse_ligne_1 = String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(104, 5) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.adresse_ligne_2 = String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(104, 6) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.adresse_ligne_3 = String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(104, 7) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.adresse_ligne_4 = String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(104, 8) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.adresse_ligne_5 = String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(104, 9) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.nir_certifie = String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(104, 10) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.cle_du_nir_certifie =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(104, 11) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.date_de_certification_du_nir =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(104, 12) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.date_de_naissance = String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(104, 13) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.rang_de_naissance = String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(104, 14) => {
|
||||
cartevitale.donneesBeneficiaire.last_mut().unwrap().qualite =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(104, 15) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.code_service_amo_beneficiaire = field.content[0] as char;
|
||||
}
|
||||
(104, 16) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.date_de_debut_service_amo =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(104, 17) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.date_de_fin_service_amo =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(104, 18) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donnees_ruf_amo = String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(105, 1) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.periodeDroitsAMO
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.date_de_debut_droits_amo =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(105, 2) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.periodeDroitsAMO
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.date_de_fin_droits_amo =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(106, 1) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.periodeCodeCouverture
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.date_de_debut_code_couverture =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(106, 2) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.periodeCodeCouverture
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.date_de_fin_code_couverture =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(106, 3) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.periodeCodeCouverture
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.code_ald = String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(106, 4) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.periodeCodeCouverture
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.code_situation = String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(107, 1) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesMutuelle
|
||||
.identification_mutuelle =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(107, 2) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesMutuelle
|
||||
.garanties_effectives =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(107, 3) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesMutuelle
|
||||
.indicateur_de_traitement_mutuelle =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(107, 4) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesMutuelle
|
||||
.type_de_services_associes = field.content[0] as char;
|
||||
}
|
||||
(107, 5) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesMutuelle
|
||||
.services_associes_au_contrat =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(107, 6) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesMutuelle
|
||||
.code_aiguillage_sts = field.content[0] as char;
|
||||
}
|
||||
(108, 1) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesMutuelle
|
||||
.periodeDroitsMutuelle
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.date_de_debut_droits_mutuelle =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(108, 2) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesMutuelle
|
||||
.periodeDroitsMutuelle
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.date_de_fin_droits_mutuelle =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(109, 1) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesComplementaire
|
||||
.numero_complementaire_b2 =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(109, 2) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesComplementaire
|
||||
.numero_complementaire_edi =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(109, 3) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesComplementaire
|
||||
.numero_adherent_amc =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(109, 4) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesComplementaire
|
||||
.indicateur_de_traitement_amc =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(109, 5) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesComplementaire
|
||||
.date_de_debut_validite_amc =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(109, 6) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesComplementaire
|
||||
.date_de_fin_validite_amc =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(109, 7) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesComplementaire
|
||||
.code_routage_flux_amc =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(109, 8) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesComplementaire
|
||||
.identifiant_hote = String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(109, 9) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesComplementaire
|
||||
.nom_de_domaine_amc =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(109, 10) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesComplementaire
|
||||
.code_aiguillage_sts = field.content[0] as char;
|
||||
}
|
||||
(109, 11) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesComplementaire
|
||||
.type_de_services_associes = field.content[0] as char;
|
||||
}
|
||||
(109, 12) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesComplementaire
|
||||
.services_associes_au_contrat =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
(111, 1) => {
|
||||
cartevitale
|
||||
.donneesBeneficiaire
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.donneesRUFBeneficiaireComplementaire
|
||||
.donnees_ruf_beneficiaire_complementaire =
|
||||
String::from_utf8_lossy(field.content).to_string();
|
||||
}
|
||||
_ => {
|
||||
return Err(format!(
|
||||
"Unknown (group, field) pair: ({}, {})",
|
||||
group.id, field.id
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(cartevitale)
|
||||
}
|
||||
|
||||
// #[cfg(test)]
|
||||
// mod test_decode_carte_ps {
|
||||
// use super::*;
|
||||
|
||||
// #[test]
|
||||
// fn test_francoise_pharmacien0052419() {
|
||||
// let bytes: &[u8] = &[
|
||||
// 0, 1, 51, // Block 01, Content size 51
|
||||
// 1, 48, // Field 01, Content size 1
|
||||
// 1, 56, // Field 02, Content size 1
|
||||
// 11, 57, 57, 55, 48, 48, 53, 50, 52, 49, 57, 52, // Field 03, Content size 11
|
||||
// 1, 52, // Field 04, Content size 1
|
||||
// 2, 50, 50, // Field 05, Content size 2
|
||||
// 17, 80, 72, 65, 82, 77, 65, 67, 73, 69, 78, 48, 48, 53, 50, 52, 49,
|
||||
// 57, // Field 06, Content size 17
|
||||
// 9, 70, 82, 65, 78, 67, 79, 73, 83, 69, // Field 07, Content size 9
|
||||
// 1, 84, // Field 08, Content size 1
|
||||
// 0, 2, 83, // Block 02, Content size 83
|
||||
// 1, 1, 1, 48, 1, 49, 2, 56, 54, 1, 49, 9, 48, 66, 48, 50, 50, 49, 57, 53, 56, 1, 56, 24,
|
||||
// 80, 72, 65, 82, 77, 65, 67, 73, 69, 32, 68, 85, 32, 67, 69, 78, 84, 82, 69, 50, 50, 49,
|
||||
// 57, 53, 8, 48, 48, 50, 48, 50, 52, 49, 57, 1, 56, 0, 1, 48, 1, 49, 2, 53, 48, 2, 49,
|
||||
// 48, 2, 48, 48, 1, 48, 1, 48, 1, 48, 1, 49, 1, 49,
|
||||
// ];
|
||||
// let blocks = decode_ssv_memory(bytes, bytes.len());
|
||||
// let carte_ps = decode_carte_ps(blocks).unwrap();
|
||||
|
||||
// assert_eq!(carte_ps.titulaire.type_de_carte_ps, "0");
|
||||
// assert_eq!(carte_ps.titulaire.type_d_identification_nationale, "8");
|
||||
// assert_eq!(
|
||||
// carte_ps.titulaire.numero_d_identification_nationale,
|
||||
// "99700524194"
|
||||
// );
|
||||
// assert_eq!(
|
||||
// carte_ps.titulaire.cle_du_numero_d_identification_nationale,
|
||||
// "4"
|
||||
// );
|
||||
// assert_eq!(carte_ps.titulaire.code_civilite, "22");
|
||||
// assert_eq!(carte_ps.titulaire.nom_du_ps, "PHARMACIEN0052419");
|
||||
// assert_eq!(carte_ps.titulaire.prenom_du_ps, "FRANCOISE");
|
||||
// assert_eq!(carte_ps.titulaire.categorie_carte, 'T');
|
||||
|
||||
// assert_eq!(carte_ps.situations.len(), 1);
|
||||
// assert_eq!(
|
||||
// carte_ps.situations[0].numero_logique_de_la_situation_de_facturation_du_ps,
|
||||
// 1
|
||||
// );
|
||||
// assert_eq!(carte_ps.situations[0].mode_d_exercice, "0");
|
||||
// assert_eq!(carte_ps.situations[0].statut_d_exercice, "1");
|
||||
// assert_eq!(carte_ps.situations[0].secteur_d_activite, "86");
|
||||
// assert_eq!(carte_ps.situations[0].type_d_identification_structure, "1");
|
||||
// assert_eq!(
|
||||
// carte_ps.situations[0].numero_d_identification_structure,
|
||||
// "0B0221958"
|
||||
// );
|
||||
// assert_eq!(
|
||||
// carte_ps.situations[0].cle_du_numero_d_identification_structure,
|
||||
// "8"
|
||||
// );
|
||||
// assert_eq!(
|
||||
// carte_ps.situations[0].raison_sociale_structure,
|
||||
// "PHARMACIE DU CENTRE22195"
|
||||
// );
|
||||
// assert_eq!(
|
||||
// carte_ps.situations[0].numero_d_identification_de_facturation_du_ps,
|
||||
// "00202419"
|
||||
// );
|
||||
// assert_eq!(
|
||||
// carte_ps.situations[0].cle_du_numero_d_identification_de_facturation_du_ps,
|
||||
// "8"
|
||||
// );
|
||||
// assert_eq!(
|
||||
// carte_ps.situations[0].numero_d_identification_du_ps_remplaçant,
|
||||
// ""
|
||||
// );
|
||||
// assert_eq!(
|
||||
// carte_ps.situations[0].cle_du_numero_d_identification_du_ps_remplaçant,
|
||||
// "0"
|
||||
// );
|
||||
// assert_eq!(carte_ps.situations[0].code_conventionnel, "1");
|
||||
// assert_eq!(carte_ps.situations[0].code_specialite, "50");
|
||||
// assert_eq!(carte_ps.situations[0].code_zone_tarifaire, "10");
|
||||
// assert_eq!(carte_ps.situations[0].code_zone_ik, "00");
|
||||
// assert_eq!(carte_ps.situations[0].code_agrement_1, "0");
|
||||
// assert_eq!(carte_ps.situations[0].code_agrement_2, "0");
|
||||
// assert_eq!(carte_ps.situations[0].code_agrement_3, "0");
|
||||
// assert_eq!(
|
||||
// carte_ps.situations[0].habilitation_à_signer_une_facture,
|
||||
// "1"
|
||||
// );
|
||||
// assert_eq!(carte_ps.situations[0].habilitation_à_signer_un_lot, "1");
|
||||
// }
|
||||
|
||||
// #[test]
|
||||
// fn test_multiple_situations() {
|
||||
// let bytes: &[u8] = &[
|
||||
// 0, 1, 51, // Block 01, Content size 51
|
||||
// 1, 48, 1, 56, 11, 57, 57, 55, 48, 48, 53, 50, 52, 49, 57, 52, 1, 52, 2, 50, 50, 17, 80,
|
||||
// 72, 65, 82, 77, 65, 67, 73, 69, 78, 48, 48, 53, 50, 52, 49, 57, 9, 70, 82, 65, 78, 67,
|
||||
// 79, 73, 83, 69, 1, 84, 0, 2, 83, // Block 02, Content size 83
|
||||
// 1, 1, 1, 48, 1, 49, 2, 56, 54, 1, 49, 9, 48, 66, 48, 50, 50, 49, 57, 53, 56, 1, 56, 24,
|
||||
// 80, 72, 65, 82, 77, 65, 67, 73, 69, 32, 68, 85, 32, 67, 69, 78, 84, 82, 69, 50, 50, 49,
|
||||
// 57, 53, 8, 48, 48, 50, 48, 50, 52, 49, 57, 1, 56, 0, 1, 48, 1, 49, 2, 53, 48, 2, 49,
|
||||
// 48, 2, 48, 48, 1, 48, 1, 48, 1, 48, 1, 49, 1, 49, 0, 3,
|
||||
// 83, // Block 03, Content size 83
|
||||
// 1, 1, 1, 48, 1, 49, 2, 56, 54, 1, 49, 9, 48, 66, 48, 50, 50, 49, 57, 53, 56, 1, 56, 24,
|
||||
// 80, 72, 65, 82, 77, 65, 67, 73, 69, 32, 68, 85, 32, 67, 69, 78, 84, 82, 69, 50, 50, 49,
|
||||
// 57, 53, 8, 48, 48, 50, 48, 50, 52, 49, 57, 1, 56, 0, 1, 48, 1, 49, 2, 53, 48, 2, 49,
|
||||
// 48, 2, 48, 48, 1, 48, 1, 48, 1, 48, 1, 49, 1, 49, 0, 4,
|
||||
// 83, // Block 04, Content size 83
|
||||
// 1, 1, 1, 48, 1, 49, 2, 56, 54, 1, 49, 9, 48, 66, 48, 50, 50, 49, 57, 53, 56, 1, 56, 24,
|
||||
// 80, 72, 65, 82, 77, 65, 67, 73, 69, 32, 68, 85, 32, 67, 69, 78, 84, 82, 69, 50, 50, 49,
|
||||
// 57, 53, 8, 48, 48, 50, 48, 50, 52, 49, 57, 1, 56, 0, 1, 48, 1, 49, 2, 53, 48, 2, 49,
|
||||
// 48, 2, 48, 48, 1, 48, 1, 48, 1, 48, 1, 49, 1, 49,
|
||||
// ];
|
||||
// let blocks = decode_ssv_memory(bytes, bytes.len());
|
||||
// let carte_ps = decode_carte_ps(blocks).unwrap();
|
||||
|
||||
// assert_eq!(carte_ps.situations.len(), 3);
|
||||
// assert_eq!(
|
||||
// carte_ps.situations[0].raison_sociale_structure,
|
||||
// "PHARMACIE DU CENTRE22195"
|
||||
// );
|
||||
// assert_eq!(
|
||||
// carte_ps.situations[1].raison_sociale_structure,
|
||||
// "PHARMACIE DU CENTRE22195"
|
||||
// );
|
||||
// assert_eq!(
|
||||
// carte_ps.situations[2].raison_sociale_structure,
|
||||
// "PHARMACIE DU CENTRE22195"
|
||||
// );
|
||||
// }
|
||||
|
||||
// #[test]
|
||||
// #[should_panic]
|
||||
// fn test_missing_field() {
|
||||
// todo!();
|
||||
// }
|
||||
|
||||
// #[test]
|
||||
// #[should_panic]
|
||||
// fn test_unknown_group_field_pair() {
|
||||
// todo!();
|
||||
// }
|
||||
|
||||
// #[test]
|
||||
// #[should_panic]
|
||||
// fn test_invalid_field_format() {
|
||||
// todo!();
|
||||
// }
|
||||
// }
|
@ -1,5 +1,4 @@
|
||||
pub mod cps;
|
||||
pub mod cartevitale;
|
||||
pub mod libssv;
|
||||
pub mod ssv_memory;
|
||||
pub mod ssvlib_demo;
|
||||
|
@ -19,13 +19,5 @@ extern "C" {
|
||||
ZDonneesSortie: *mut *mut c_void,
|
||||
TTailleDonneesSortie: *mut size_t,
|
||||
) -> c_ushort;
|
||||
pub fn SSV_LireDroitsVitale(
|
||||
NomRessourcePS: *const c_char,
|
||||
NomRessourceLecteur: *const c_char,
|
||||
CodePorteurPS: *const c_char,
|
||||
DateConsultation: *const c_char,
|
||||
ZDonneesSortie: *mut *mut c_void,
|
||||
TTailleDonneesSortie: *mut size_t,
|
||||
) -> c_ushort;
|
||||
}
|
||||
// TODO : replace void* by Rust struct : https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs
|
||||
|
@ -1,5 +1,4 @@
|
||||
mod cps;
|
||||
mod cartevitale;
|
||||
mod libssv;
|
||||
mod ssv_memory;
|
||||
mod ssvlib_demo;
|
||||
|
@ -71,8 +71,6 @@ impl<'a> From<&'a [u8]> for Block<'a> {
|
||||
let mut field_id = 1;
|
||||
while field_offset < block_size {
|
||||
let mut field: Field<'a> = raw_content[field_offset..].into();
|
||||
|
||||
|
||||
field.id = field_id;
|
||||
field_offset += field.size;
|
||||
field_id += 1;
|
||||
|
@ -7,10 +7,7 @@ use std::ffi::CString;
|
||||
use std::path::PathBuf;
|
||||
use std::ptr;
|
||||
|
||||
|
||||
use crate::cps::lire_carte;
|
||||
use crate::cartevitale::LireDroitsVitale;
|
||||
|
||||
use crate::libssv::{SSV_InitLIB2, SSV_LireConfig};
|
||||
|
||||
fn ssv_init_lib_2() {
|
||||
@ -54,15 +51,10 @@ pub fn demo() {
|
||||
|
||||
let code_pin = "1234";
|
||||
let lecteur = "HID Global OMNIKEY 3x21 Smart Card Reader 0";
|
||||
let lecteurvitale = "HID Global OMNIKEY 3x21 Smart Card Reader 1";
|
||||
let dateconsultation ="20240813";
|
||||
let carte_ps = lire_carte(code_pin, lecteur).unwrap();
|
||||
println!("CartePS: {:#?}", carte_ps);
|
||||
|
||||
ssv_lire_config();
|
||||
|
||||
let carte_vitale = LireDroitsVitale(lecteur, lecteurvitale, code_pin, dateconsultation).unwrap();
|
||||
println!("carte_vitale: {:#?}", carte_vitale);
|
||||
|
||||
println!("-----------------------------------------");
|
||||
}
|
||||
|
@ -3,4 +3,3 @@ EXPORTS
|
||||
SSV_InitLIB2
|
||||
SSV_LireCartePS
|
||||
SSV_LireConfig
|
||||
SSV_LireDroitsVitale
|
@ -1,26 +0,0 @@
|
||||
@echo off
|
||||
rem Set variables
|
||||
set LIB_DIR=crates/sesam-vitale/lib
|
||||
set DEF_DIR=crates/sesam-vitale/src/win/fsv
|
||||
|
||||
if "%1"=="/clean" (
|
||||
goto clean
|
||||
)
|
||||
|
||||
rem Set the environment for the x64 platform
|
||||
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
|
||||
|
||||
rem Create a ssvw64.lib file from the ssvw64.def file
|
||||
lib /def:ssvw64.def /out:%LIB_DIR%\ssvw64.lib /machine:x64
|
||||
|
||||
rem Build complete
|
||||
pause
|
||||
exit /b 0
|
||||
|
||||
:clean
|
||||
del %LIB_DIR%\*.lib
|
||||
del %LIB_DIR%\*.exp
|
||||
|
||||
rem Clean complete
|
||||
pause
|
||||
exit /b 0
|
@ -1,7 +1,7 @@
|
||||
@echo off
|
||||
rem Set variables
|
||||
set LIB_DIR=F:\PAPILLON\Krys4lideCopie\crates\sesam-vitale\lib
|
||||
set DEF_DIR=F:\PAPILLON\Krys4lideCopie\crates\sesam-vitale\src\win\fsv
|
||||
set LIB_DIR=crates/sesam-vitale/lib
|
||||
set DEF_DIR=crates/sesam-vitale/src/win/fsv
|
||||
|
||||
if "%1"=="/clean" (
|
||||
goto clean
|
||||
|
@ -1,6 +0,0 @@
|
||||
LIBRARY "ssvw64"
|
||||
EXPORTS
|
||||
SSV_InitLIB2
|
||||
SSV_LireCartePS
|
||||
SSV_LireConfig
|
||||
SSV_LireDroitsVitale
|
Reference in New Issue
Block a user