Compare commits
41 Commits
wip-debug-
...
3999532714
Author | SHA1 | Date | |
---|---|---|---|
3999532714
|
|||
e51dcc0ed0
|
|||
0f7a291b3c
|
|||
e7f3322484 | |||
147125eff4
|
|||
ad7a0f2594 | |||
358a279f5c
|
|||
9fc3fef350
|
|||
a194b2d888
|
|||
920b3e119b | |||
91d7474ce0 | |||
3a43428ad4 | |||
d6d487a727 | |||
65059b87d4 | |||
f8d7f82c50
|
|||
d33140ebaf
|
|||
ba88b08a57
|
|||
8c38f0e4ba | |||
648a7848fd
|
|||
f6a1af5d1e
|
|||
a19b6dcd0d
|
|||
9447ad7faf | |||
5eebd5d1cb | |||
7d41fbb519 | |||
ff2c84fb33
|
|||
b807e78ac3 | |||
d8f3c276c0 | |||
c2b4264f32 | |||
0e8514d906 | |||
86a6d2b9d3 | |||
18758ff2fe | |||
1f57b70cef | |||
83cee11e65 | |||
b1cafda669 | |||
d370a9b85d
|
|||
83b2f7358d
|
|||
8ef713ccf2
|
|||
4162e55b83 | |||
d9cedca335
|
|||
820d76d0f5
|
|||
6409e3eedf
|
28
.gitea/PULL_REQUEST_TEMPLATE.yaml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
name: Demande de fusion (Pull Request)
|
||||||
|
about: Créez une demande de fusion pour partager votre travail avec le reste de l'équipe
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Une demande de fusion (Pull Request) a pour objectif de
|
||||||
|
partager au reste de l'équipe un développement réalisé.
|
||||||
|
Décrire les modifications apportées, leur impact et le contexte
|
||||||
|
dans lequel elles ont été réalisées permettra aux relecteurices
|
||||||
|
de plus facilement comprendre et valider votre travail.
|
||||||
|
- type: textarea
|
||||||
|
id: details
|
||||||
|
attributes:
|
||||||
|
label: Détails
|
||||||
|
description: Décrivez le contenu de la PR, son impact concret
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: why
|
||||||
|
attributes:
|
||||||
|
label: Pourquoi ?
|
||||||
|
description: Pourquoi ces modifications sont elles nécessaires ? Dans quel contexte s'inscrivent-elles ?
|
||||||
|
- type: textarea
|
||||||
|
id: documentation
|
||||||
|
attributes:
|
||||||
|
label: Documentation
|
||||||
|
description: Précisez ici des références à des ressources que vous avez utilisées pour réaliser ces modifications
|
29
.gitea/issue_template/BUG_REPORT.yaml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
name: Rapport de bug
|
||||||
|
about: Remplissez un rapport d'erreur
|
||||||
|
title: "[Bug]: "
|
||||||
|
blank_issues_enabled: false
|
||||||
|
labels:
|
||||||
|
- bug
|
||||||
|
- to-triage
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
id: what-happened
|
||||||
|
attributes:
|
||||||
|
label: Que se passe-t-il ?
|
||||||
|
description: Décrivez la situation que vous rencontrez
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: environment-description
|
||||||
|
attributes:
|
||||||
|
label: Si le problème semble lié à votre environement, décrivez-le ici
|
||||||
|
placeholder: Windows 10, Firefox 89.0, etc.
|
||||||
|
- type: dropdown
|
||||||
|
id: module
|
||||||
|
attributes:
|
||||||
|
label: Ce problème est il relatif à un ou des modules en particulier ?
|
||||||
|
multiple: true
|
||||||
|
options:
|
||||||
|
- Clego
|
||||||
|
- Tauri
|
||||||
|
- Axum
|
13
.gitea/issue_template/FEATURE.yaml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
name: Proposez une fonctionnalité / amélioration
|
||||||
|
about: Proposez vos idées de fonctionnalités ou d'améliorations
|
||||||
|
blank_issues_enabled: false
|
||||||
|
labels:
|
||||||
|
- feature
|
||||||
|
- to-triage
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
id: description
|
||||||
|
attributes:
|
||||||
|
label: Décrivez votre idée
|
||||||
|
validations:
|
||||||
|
required: true
|
20
.gitea/issue_template/QUESTION.yaml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
name: Posez une question
|
||||||
|
about: Une interrogation, une difficulté ? Posez votre question
|
||||||
|
blank_issues_enabled: false
|
||||||
|
labels:
|
||||||
|
- question
|
||||||
|
- to-triage
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
id: question
|
||||||
|
attributes:
|
||||||
|
label: Que se passe-t-il ?
|
||||||
|
description: Décrivez la situation que vous rencontrez, posez votre question
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: environment-description
|
||||||
|
attributes:
|
||||||
|
label: Précisez votre environnement
|
||||||
|
description: S'il vous semble pertinent de préciser votre environement, décrivez-le ici
|
||||||
|
placeholder: Windows 10, Firefox 89.0, etc.
|
15
.gitignore
vendored
@ -4,13 +4,20 @@
|
|||||||
debug/
|
debug/
|
||||||
target/
|
target/
|
||||||
|
|
||||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
|
||||||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
|
||||||
Cargo.lock
|
|
||||||
|
|
||||||
# These are backup files generated by rustfmt
|
# These are backup files generated by rustfmt
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
|
|
||||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||||
*.pdb
|
*.pdb
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.idea
|
||||||
|
.DS_Store
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
||||||
|
|
||||||
|
4556
Cargo.lock
generated
Normal file
7
Cargo.toml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[workspace]
|
||||||
|
resolver = "2"
|
||||||
|
members = [
|
||||||
|
"crates/app",
|
||||||
|
"crates/sesam-vitale",
|
||||||
|
"crates/desktop"
|
||||||
|
, "crates/services-sesam-vitale-sys"]
|
38
README.md
@ -1,3 +1,39 @@
|
|||||||
# Krys4lide
|
# Krys4lide
|
||||||
|
|
||||||
Logiciel de pharmacie
|
Logiciel de Pharmacie libre et open-source.
|
||||||
|
|
||||||
|
## Crates
|
||||||
|
|
||||||
|
- `app`: Interface du logiciel, servie par un serveur web propulsé par Axum. Utilisable en mode endpoint ou encapsulé dans le client `desktop`
|
||||||
|
- `desktop`: Client desktop propulsé par Tauri, encapsulant le serveur web `app`
|
||||||
|
- `sesam-vitale`: Bibliothèque de gestion des services SESAM-Vitale (Lecture des cartes CPS et Vitale, téléservices ...)
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
### Pré-requis
|
||||||
|
|
||||||
|
La CLI Tauri est nécessaire au lancement du client `desktop`. Elle peut être installée via Cargo :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo install tauri-cli
|
||||||
|
```
|
||||||
|
|
||||||
|
### Exécution de l'application cliente desktop
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo tauri dev
|
||||||
|
```
|
||||||
|
|
||||||
|
### Exécution du serveur web `app` en mode endpoint
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo run --bin app
|
||||||
|
```
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
Packager le client desktop
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo tauri build
|
||||||
|
```
|
||||||
|
1
crates/app/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/target
|
12
crates/app/Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[package]
|
||||||
|
name = "app"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
askama = "0.12.1"
|
||||||
|
askama_axum = "0.4.0"
|
||||||
|
axum = "0.7.5"
|
||||||
|
tokio = { version = "1.39.1", features = ["macros", "rt-multi-thread"] }
|
||||||
|
tower-http = { version = "0.5.2", features = ["fs"] }
|
||||||
|
|
1
crates/app/assets/js/htmx.min.js
vendored
Normal file
27
crates/app/src/lib.rs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
mod templates;
|
||||||
|
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
use askama_axum::IntoResponse;
|
||||||
|
use templates::{hello::HelloResponse, index::GetIndexResponse};
|
||||||
|
use tower_http::services::ServeDir;
|
||||||
|
|
||||||
|
async fn root() -> impl IntoResponse {
|
||||||
|
return GetIndexResponse {}.into_response();
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn hello() -> impl IntoResponse {
|
||||||
|
return HelloResponse {
|
||||||
|
name: "Theo".to_string(),
|
||||||
|
}
|
||||||
|
.into_response();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_router(assets_path: &Path) -> axum::Router {
|
||||||
|
let router = axum::Router::new()
|
||||||
|
.nest_service("/assets", ServeDir::new(assets_path))
|
||||||
|
.route("/", axum::routing::get(root))
|
||||||
|
.route("/hello", axum::routing::get(hello));
|
||||||
|
|
||||||
|
router
|
||||||
|
}
|
14
crates/app/src/main.rs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
use ::app::get_router;
|
||||||
|
use std::env;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||||
|
let assets_path = Path::new(&manifest_dir).join("assets");
|
||||||
|
let router = get_router(assets_path.as_path());
|
||||||
|
|
||||||
|
// TODO: select port based on available port (or ask in CLI)
|
||||||
|
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
|
||||||
|
axum::serve(listener, router).await.unwrap();
|
||||||
|
}
|
7
crates/app/src/templates/hello.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
use askama::Template;
|
||||||
|
|
||||||
|
#[derive(Template)]
|
||||||
|
#[template(path = "hello.html")]
|
||||||
|
pub struct HelloResponse {
|
||||||
|
pub name: String,
|
||||||
|
}
|
5
crates/app/src/templates/index.rs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
use askama::Template;
|
||||||
|
|
||||||
|
#[derive(Template)]
|
||||||
|
#[template(path = "index.html")]
|
||||||
|
pub struct GetIndexResponse;
|
2
crates/app/src/templates/mod.rs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
pub mod hello;
|
||||||
|
pub mod index;
|
13
crates/app/templates/base.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>{% block title %}{{ title }}{% endblock %}</title>
|
||||||
|
|
||||||
|
<script src="/assets/js/htmx.min.js"></script>
|
||||||
|
|
||||||
|
{% block head %}{% endblock %}
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{% block body %}{% endblock %}
|
||||||
|
</body>
|
||||||
|
</html>
|
1
crates/app/templates/hello.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<div>Hello {{name}}!</div>
|
23
crates/app/templates/index.html
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Pharma Libre{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<header>
|
||||||
|
<h1>Pharma Libre</h1>
|
||||||
|
</header>
|
||||||
|
<main>
|
||||||
|
<div
|
||||||
|
id="hello"
|
||||||
|
hx-get="/hello"
|
||||||
|
hx-target="this"
|
||||||
|
hx-trigger="load"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
>
|
||||||
|
Loading...
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
7
crates/desktop/.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Generated by Cargo
|
||||||
|
# will have compiled files and executables
|
||||||
|
/target/
|
||||||
|
|
||||||
|
# Generated by Tauri
|
||||||
|
# will have schema files for capabilities auto-completion
|
||||||
|
/gen/schemas
|
24
crates/desktop/Cargo.toml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
[package]
|
||||||
|
name = "desktop"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "Un logiciel de pharmacie libre et open-source."
|
||||||
|
authors = ["p4pillon"]
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "desktop_lib"
|
||||||
|
crate-type = ["lib", "cdylib", "staticlib"]
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
tauri-build = { version = "2.0.0-beta", features = [] }
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
axum = "0.7.5"
|
||||||
|
tauri = { version = "2.0.0-beta", features = [] }
|
||||||
|
tower = "0.4.13"
|
||||||
|
tokio = "1.39.1"
|
||||||
|
|
||||||
|
app = { path = "../app" }
|
||||||
|
http = "1.1.0"
|
||||||
|
bytes = "1.6.1"
|
||||||
|
|
3
crates/desktop/build.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
tauri_build::build()
|
||||||
|
}
|
BIN
crates/desktop/icons/128x128.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
crates/desktop/icons/128x128@2x.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
crates/desktop/icons/32x32.png
Normal file
After Width: | Height: | Size: 974 B |
BIN
crates/desktop/icons/Square107x107Logo.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
crates/desktop/icons/Square142x142Logo.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
crates/desktop/icons/Square150x150Logo.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
crates/desktop/icons/Square284x284Logo.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
crates/desktop/icons/Square30x30Logo.png
Normal file
After Width: | Height: | Size: 903 B |
BIN
crates/desktop/icons/Square310x310Logo.png
Normal file
After Width: | Height: | Size: 8.4 KiB |
BIN
crates/desktop/icons/Square44x44Logo.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
crates/desktop/icons/Square71x71Logo.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
crates/desktop/icons/Square89x89Logo.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
crates/desktop/icons/StoreLogo.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
crates/desktop/icons/icon.icns
Normal file
BIN
crates/desktop/icons/icon.ico
Normal file
After Width: | Height: | Size: 85 KiB |
BIN
crates/desktop/icons/icon.png
Normal file
After Width: | Height: | Size: 14 KiB |
69
crates/desktop/src/lib.rs
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
use bytes::Bytes;
|
||||||
|
use http::{request, response, Request, Response};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use axum::body::{to_bytes, Body};
|
||||||
|
|
||||||
|
use axum::Router;
|
||||||
|
|
||||||
|
use tauri::path::BaseDirectory;
|
||||||
|
use tauri::Manager;
|
||||||
|
use tokio::sync::{Mutex, MutexGuard};
|
||||||
|
use tower::{Service, ServiceExt};
|
||||||
|
|
||||||
|
async fn process_tauri_request(
|
||||||
|
tauri_request: Request<Vec<u8>>,
|
||||||
|
mut router: MutexGuard<'_, Router>,
|
||||||
|
) -> Response<Vec<u8>> {
|
||||||
|
let (parts, body): (request::Parts, Vec<u8>) = tauri_request.into_parts();
|
||||||
|
let axum_request: Request<Body> = Request::from_parts(parts, body.into());
|
||||||
|
|
||||||
|
let axum_response: Response<Body> = router
|
||||||
|
.as_service()
|
||||||
|
.ready()
|
||||||
|
.await
|
||||||
|
.expect("Failed to get ready service from router")
|
||||||
|
.call(axum_request)
|
||||||
|
.await
|
||||||
|
.expect("Could not get response from router");
|
||||||
|
|
||||||
|
let (parts, body): (response::Parts, Body) = axum_response.into_parts();
|
||||||
|
let body: Bytes = to_bytes(body, usize::MAX).await.unwrap_or_default();
|
||||||
|
|
||||||
|
let tauri_response: Response<Vec<u8>> = Response::from_parts(parts, body.into());
|
||||||
|
|
||||||
|
tauri_response
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
|
pub fn run() {
|
||||||
|
tauri::Builder::default()
|
||||||
|
.setup(|app| {
|
||||||
|
let assets_path: PathBuf = app
|
||||||
|
.path()
|
||||||
|
.resolve("assets", BaseDirectory::Resource)
|
||||||
|
.expect("Path should be resolvable");
|
||||||
|
|
||||||
|
// Adds Axum router to application state
|
||||||
|
// This makes it so we can retrieve it from any app instance (see bellow)
|
||||||
|
let router = Arc::new(Mutex::new(app::get_router(&assets_path)));
|
||||||
|
|
||||||
|
app.manage(router);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.register_asynchronous_uri_scheme_protocol("axum", move |app, request, responder| {
|
||||||
|
// Retrieve the router from the application state and clone it for the async block
|
||||||
|
let router = Arc::clone(&app.state::<Arc<Mutex<axum::Router>>>());
|
||||||
|
|
||||||
|
// Spawn a new async task to process the request
|
||||||
|
tauri::async_runtime::spawn(async move {
|
||||||
|
let router = router.lock().await;
|
||||||
|
let response = process_tauri_request(request, router).await;
|
||||||
|
responder.respond(response);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.run(tauri::generate_context!())
|
||||||
|
.expect("error while running tauri application");
|
||||||
|
}
|
6
crates/desktop/src/main.rs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||||
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
desktop_lib::run()
|
||||||
|
}
|
41
crates/desktop/tauri.conf.json
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"productName": "Logiciel Pharma",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"identifier": "org.p4pillon.pharma.desktop",
|
||||||
|
"build": {
|
||||||
|
"beforeDevCommand": {
|
||||||
|
"cwd": "../app",
|
||||||
|
"script": "cargo run"
|
||||||
|
},
|
||||||
|
"devUrl": "http://localhost:3000",
|
||||||
|
"frontendDist": "axum://place.holder/"
|
||||||
|
},
|
||||||
|
"app": {
|
||||||
|
"withGlobalTauri": true,
|
||||||
|
"windows": [
|
||||||
|
{
|
||||||
|
"title": "Logiciel Pharma",
|
||||||
|
"width": 800,
|
||||||
|
"height": 600
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"security": {
|
||||||
|
"csp": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"bundle": {
|
||||||
|
"active": true,
|
||||||
|
"resources": {
|
||||||
|
"../app/assets/": "./assets/"
|
||||||
|
},
|
||||||
|
"targets": "all",
|
||||||
|
"icon": [
|
||||||
|
"icons/32x32.png",
|
||||||
|
"icons/128x128.png",
|
||||||
|
"icons/128x128@2x.png",
|
||||||
|
"icons/icon.icns",
|
||||||
|
"icons/icon.ico"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
4
crates/services-sesam-vitale-sys/Cargo.toml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[package]
|
||||||
|
name = "services-sesam-vitale-sys"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
285
crates/services-sesam-vitale-sys/src/bindings.rs
Normal file
@ -0,0 +1,285 @@
|
|||||||
|
#![allow(non_upper_case_globals)]
|
||||||
|
#![allow(non_camel_case_types)]
|
||||||
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
17
crates/services-sesam-vitale-sys/src/lib.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
mod types;
|
||||||
|
|
||||||
|
use types::*;
|
||||||
|
pub fn add(left: usize, right: usize) -> usize {
|
||||||
|
left + right
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn it_works() {
|
||||||
|
let result = add(2, 2);
|
||||||
|
assert_eq!(result, 4);
|
||||||
|
}
|
||||||
|
}
|
176
crates/services-sesam-vitale-sys/src/types.rs
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
struct Identification<T> {
|
||||||
|
value: T,
|
||||||
|
// Key to check the validity of the value
|
||||||
|
// TODO: implement checking algorithm
|
||||||
|
key: u8,
|
||||||
|
}
|
||||||
|
type Byte = u8;
|
||||||
|
|
||||||
|
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),
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum CategorieCarteProfessionnelSante {
|
||||||
|
Reelle,
|
||||||
|
Test,
|
||||||
|
Demonstration,
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
|
||||||
|
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>,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum IdentificationStructure {
|
||||||
|
NumeroAdeliCabinet(String),
|
||||||
|
NumeroFINESS(String),
|
||||||
|
NumeroSIREN(String),
|
||||||
|
NumeroSIRET(String),
|
||||||
|
NumeroRPPSCabinet(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
struct StructureMedicale {
|
||||||
|
identification: Identification<IdentificationStructure>,
|
||||||
|
raison_sociale: String, // Nom Entreprise
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ModeExercice {
|
||||||
|
LiberalExploitantCommercant, // Libéral, exploitant, commerçant
|
||||||
|
Salarie,
|
||||||
|
Remplacant,
|
||||||
|
Benevole,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum StatutExercice {
|
||||||
|
// TAB-Statuts géré par l’ANS il faut trouver la donnee
|
||||||
|
PLACEHOLDER(u8),
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
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>,
|
||||||
|
}
|
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,
|
||||||
|
}
|
3
crates/services-sesam-vitale-sys/src/types/mod.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
pub(crate) mod types;
|
||||||
|
pub mod common;
|
||||||
|
pub mod serialization_types;
|
@ -0,0 +1,81 @@
|
|||||||
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
|
use binrw::{BinRead, BinResult};
|
||||||
|
use bitreader::{BitReader, BitReaderError};
|
||||||
|
|
||||||
|
fn parse_memory_zone_size_bitreader(bytes: &[u8; 5]) -> Result<u32, BitReaderError> {
|
||||||
|
let mut reader = BitReader::new(bytes);
|
||||||
|
|
||||||
|
let zone_size_bit_count = match reader.read_bool()? {
|
||||||
|
true => 7,
|
||||||
|
false => reader.read_u8(7)? * 8,
|
||||||
|
};
|
||||||
|
Ok(reader.read_u32(zone_size_bit_count)?)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[binrw::parser(reader)]
|
||||||
|
fn parse_memory_zone_size() -> BinResult<u32> {
|
||||||
|
let mut value: u8 = 0;
|
||||||
|
|
||||||
|
|
||||||
|
reader.read_exact(std::slice::from_mut(&mut value));
|
||||||
|
|
||||||
|
// first bit s 0 <=> value < 128
|
||||||
|
match value.cmp(&128) {
|
||||||
|
Ordering::Less => {
|
||||||
|
Ok(value.into())
|
||||||
|
}
|
||||||
|
Ordering::Equal | Ordering::Greater => {
|
||||||
|
let zone_size_encoding_byte_count = value - 128;
|
||||||
|
let mut buf: Vec<u8> = vec![0; zone_size_encoding_byte_count.into()];
|
||||||
|
reader.read_exact(&mut buf);
|
||||||
|
|
||||||
|
let mut result = 0u32;
|
||||||
|
|
||||||
|
for (i, &byte) in buf.iter().enumerate() {
|
||||||
|
result += (byte as u32) << (8 * i);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(BinRead)]
|
||||||
|
struct MemoryZone {
|
||||||
|
#[br(parse_with = parse_memory_zone_size)]
|
||||||
|
memory_size: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum TypeIdentificationStructure {
|
||||||
|
NumeroAdeliCabinet,
|
||||||
|
NumeroFINESS,
|
||||||
|
NumeroSIREN,
|
||||||
|
NumeroSIRET,
|
||||||
|
NumeroRPPSCabinet,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum TypeDIdentificationNationale {
|
||||||
|
NumeroAdeli,
|
||||||
|
NumeroAdeliCabinetNumeroEmploye,
|
||||||
|
NumeroDRASS,
|
||||||
|
NumeroFINESSNumeroEmploye,
|
||||||
|
NumeroSIRENNumeroEmploye,
|
||||||
|
NumeroSIRETNumeroEmploye,
|
||||||
|
NumeroRPPSCabinetNumeroEmploye,
|
||||||
|
NumeroRPPS,
|
||||||
|
/// N° Etudiant Médecin type ADELI sur 9 caractères (information transmise par l’ANS)
|
||||||
|
NumeroEtudiantMedecin,
|
||||||
|
}
|
||||||
|
pub(crate) enum TypeCartePS {
|
||||||
|
/// 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,
|
||||||
|
}
|
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,
|
||||||
|
}
|
3
crates/sesam-vitale/.env.build.linux.example
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
SESAM_FSV_VERSION=1.40.13
|
||||||
|
SESAM_FSV_LIB_PATH=/opt/santesocial/fsv/${SESAM_FSV_VERSION}/lib
|
||||||
|
SESAM_FSV_SSVLIB=ssvlux64
|
3
crates/sesam-vitale/.env.build.win.example
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
SESAM_FSV_VERSION=1.40.13
|
||||||
|
SESAM_FSV_LIB_PATH="C:/Program Files/santesocial/fsv/${SESAM_FSV_VERSION}/lib"
|
||||||
|
SESAM_FSV_SSVLIB=ssvw64
|
2
crates/sesam-vitale/.env.linux.example
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
SESAM_FSV_VERSION=1.40.13
|
||||||
|
SESAM_INI_PATH=/etc/opt/santesocial/fsv/${SESAM_FSV_VERSION}/conf/sesam.ini
|
2
crates/sesam-vitale/.env.win.example
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
SESAM_FSV_VERSION=1.40.13
|
||||||
|
SESAM_INI_PATH=${ALLUSERSPROFILE}\\santesocial\\fsv\\${SESAM_FSV_VERSION}\\conf\\sesam.ini
|
9
crates/sesam-vitale/.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Ignore Rust target directory
|
||||||
|
/target
|
||||||
|
|
||||||
|
# Ignore .env files
|
||||||
|
.env
|
||||||
|
.env.build
|
||||||
|
|
||||||
|
# Ignore exploitation files - only usefull for local debugging on windows
|
||||||
|
lib/*.exp
|
11
crates/sesam-vitale/Cargo.toml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[package]
|
||||||
|
name = "sesam-vitale"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
dotenv = "0.15"
|
||||||
|
libc = "0.2"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
dotenv = "0.15"
|
34
crates/sesam-vitale/README.md
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
## Requirements
|
||||||
|
|
||||||
|
- Installer le [package FSV](https://industriels.sesam-vitale.fr/group/fournitures-sesam-vitale)
|
||||||
|
- Les librairies dynamiques (.lib, .dll, ...) fournies ne sont pas installés dans les emplacements standard du système, il faudra donc configurer leur chemin d'installation dans le fichier de configuration `.env.build` (voir ci-dessous)
|
||||||
|
- Le détail des chemins d'installation est donné dans la documentation du package FSV `fsv-mi-004_pack-FSV1.40.14_V2.3.pdf`
|
||||||
|
- Linux - par défaut : `/opt/santesocial/fsv/1.40.13/lib`
|
||||||
|
- Windows - par défaut : `C:\Program Files\santesocial\santesocial\fsv\1.40.14\lib` (ou dans Program Files (x86) si c'est le package 32bits qui a été installé)
|
||||||
|
|
||||||
|
- Installer la [CryptolibCPS](https://industriels.sesam-vitale.fr/group/galss-cryptolib-cps)
|
||||||
|
- Ce package fourni également l'utilitaire "CPS Gestion" pour obtenir des informations sur le lecteur de carte, etc.
|
||||||
|
- Linux : `cpgeslux`
|
||||||
|
- Windows : `...`
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
- Créer et éditer le fichier de configuration de build `.env.build` en s'inspirant d'un des fichiers d'exemple (`.env.build.linux.example`, `.env.build.win.example`...)
|
||||||
|
- Ce fichier est nécessaire pour le build du package Rust
|
||||||
|
- Créer et éditer le fichier de configuration de l'exécution `.env` en s'inspirant d'un des fichiers d'exemple (`.env.linux.example`, `.env.win.example`...)
|
||||||
|
- Ce fichier est nécessaire pour l'exécution du package Rust compilé, et doit donc être présent aux côtés de l'exécutable généré, le cas échéant
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
### Windows - Compilation des headers FSV
|
||||||
|
|
||||||
|
Sous windows, la librairie dynamique fournie par le package FSV nécessite des headers qui ne sont pas présents dans la `.dll`. Il est donc nécessaire de fournir ces headers, en les renseignant dans des fichiers `crates/sesam-vitale/src/win/fsv/*.def` qui seront compilés en leur version binaire `crates/sesam-vitale/lib/*.lib`.
|
||||||
|
|
||||||
|
En cas de modification des fichiers `.def`, pour re-compiler ces headers, faire appel au script `scripts/compile_win_headers.bat`.
|
||||||
|
|
||||||
|
| /!\ Attention, le script `compile_win_headers.bat` exécute, en interne, l'utilitaire `vcvarsall.bat` et le linker `lib.exe` de Visual Studio. Visual Studio doit donc être installé et le chemin vers l'intallation le script `vcvarsall.bat`, écrit en dur dans le script `compile_win_headers.bat` doit être adapté à votre installation.
|
||||||
|
|
||||||
|
## À creuser
|
||||||
|
|
||||||
|
- Compilation cross platform facilitée par du Docker : https://github.com/cross-rs/cross
|
||||||
|
- Pour éviter l'usage de dotenv pour la configuration, on peut utiliser https://direnv.net/
|
36
crates/sesam-vitale/build.rs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
extern crate dotenv;
|
||||||
|
|
||||||
|
use std::env;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// Load the .env.build file for build-time environment variables
|
||||||
|
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||||
|
let manifest_path = PathBuf::from(manifest_dir);
|
||||||
|
dotenv::from_path(manifest_path.join(".env.build")).ok();
|
||||||
|
|
||||||
|
println!("cargo::rerun-if-env-changed=SESAM_FSV_LIB_PATH");
|
||||||
|
println!("cargo::rerun-if-env-changed=SESAM_FSV_SSVLIB");
|
||||||
|
println!("cargo::rerun-if-changed=.env.build");
|
||||||
|
println!("cargo::rerun-if-changed=build.rs");
|
||||||
|
|
||||||
|
// 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());
|
||||||
|
|
||||||
|
// Add the SESAM_FSV_LIB_PATH to the linker search path
|
||||||
|
let fsv_lib_path = PathBuf::from(env::var("SESAM_FSV_LIB_PATH").unwrap());
|
||||||
|
println!("cargo::rustc-link-search=native={}", fsv_lib_path.display());
|
||||||
|
|
||||||
|
// Add the SESAM_FSV_LIB_PATH to the PATH environment variable
|
||||||
|
if cfg!(target_os = "windows") {
|
||||||
|
let path = env::var("PATH").unwrap_or(String::new());
|
||||||
|
println!("cargo:rustc-env=PATH={};{}", fsv_lib_path.display(), path);
|
||||||
|
} else if cfg!(target_os = "linux") {
|
||||||
|
println!("cargo:rustc-env=LD_LIBRARY_PATH={}", fsv_lib_path.display());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Link the SESAM_FSV_SSVLIB dynamic library
|
||||||
|
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`
|
||||||
|
}
|
0
crates/sesam-vitale/lib/.gitkeep
Normal file
BIN
crates/sesam-vitale/lib/ssvw64.lib
Normal file
14
crates/sesam-vitale/src/lib.rs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
pub fn add(left: usize, right: usize) -> usize {
|
||||||
|
left + right
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn it_works() {
|
||||||
|
let result = add(2, 2);
|
||||||
|
assert_eq!(result, 4);
|
||||||
|
}
|
||||||
|
}
|
17
crates/sesam-vitale/src/libssv.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* libssv.rs
|
||||||
|
*
|
||||||
|
* Low level bindings to the SSVLIB dynamic library.
|
||||||
|
* TODO : look for creating a dedicated *-sys crate : https://kornel.ski/rust-sys-crate
|
||||||
|
*/
|
||||||
|
|
||||||
|
use libc::{ c_char, c_void, c_ushort, size_t };
|
||||||
|
|
||||||
|
#[cfg_attr(target_os = "linux", link(name = "ssvlux64"))]
|
||||||
|
#[cfg_attr(target_os = "windows", link(name = "ssvw64"))]
|
||||||
|
extern "C" {
|
||||||
|
pub fn SSV_InitLIB2(pcRepSesamIni: *const c_char) -> c_ushort;
|
||||||
|
pub fn SSV_LireCartePS(NomRessourcePS: *const c_char, NomRessourceLecteur: *const c_char, CodePorteurPS: *const c_char, ZDonneesSortie: *mut *mut c_void, TTailleDonneesSortie: *mut size_t) -> c_ushort;
|
||||||
|
pub fn SSV_LireConfig(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 */
|
6
crates/sesam-vitale/src/main.rs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
mod ssvlib_demo;
|
||||||
|
mod libssv;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
ssvlib_demo::demo();
|
||||||
|
}
|
96
crates/sesam-vitale/src/ssvlib_demo.rs
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/**
|
||||||
|
* High level API for the SSV library,
|
||||||
|
* based on the low level bindings in libssv.rs.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern crate libc;
|
||||||
|
extern crate dotenv;
|
||||||
|
|
||||||
|
use libc::{ c_void, size_t };
|
||||||
|
use std::ffi::CString;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::ptr;
|
||||||
|
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
use crate::libssv:: {
|
||||||
|
SSV_InitLIB2,
|
||||||
|
SSV_LireCartePS,
|
||||||
|
SSV_LireConfig
|
||||||
|
};
|
||||||
|
|
||||||
|
fn ssv_init_lib_2() {
|
||||||
|
let ini_str = env::var("SESAM_INI_PATH").expect("SESAM_INI_PATH must be set");
|
||||||
|
let ini = CString::new(ini_str).expect("CString::new failed");
|
||||||
|
unsafe {
|
||||||
|
let result = SSV_InitLIB2(ini.as_ptr());
|
||||||
|
println!("SSV_InitLIB2 result: {}", result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ssv_lire_carte_ps() {
|
||||||
|
let resource_ps = CString::new("PS").expect("CString::new failed");
|
||||||
|
let resource_reader = CString::new("TRANSPA1").expect("CString::new failed");
|
||||||
|
let card_number = CString::new("1234567890").expect("CString::new failed");
|
||||||
|
|
||||||
|
let mut buffer: *mut c_void = ptr::null_mut();
|
||||||
|
let mut size: size_t = 0;
|
||||||
|
unsafe {
|
||||||
|
let result = SSV_LireCartePS(
|
||||||
|
resource_ps.as_ptr(),
|
||||||
|
resource_reader.as_ptr(),
|
||||||
|
card_number.as_ptr(),
|
||||||
|
&mut buffer,
|
||||||
|
&mut size
|
||||||
|
);
|
||||||
|
println!("SSV_LireCartePS result: {}", result);
|
||||||
|
|
||||||
|
if !buffer.is_null() {
|
||||||
|
let hex_values = std::slice::from_raw_parts(buffer as *const u8, size);
|
||||||
|
for &byte in hex_values {
|
||||||
|
print!("{:02X} ", byte);
|
||||||
|
}
|
||||||
|
println!();
|
||||||
|
|
||||||
|
libc::free(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ssv_lire_config() {
|
||||||
|
let mut buffer: *mut c_void = ptr::null_mut();
|
||||||
|
let mut size: size_t = 0;
|
||||||
|
unsafe {
|
||||||
|
let result = SSV_LireConfig(&mut buffer, &mut size);
|
||||||
|
println!("SSV_LireConfig result: {}", result);
|
||||||
|
|
||||||
|
if !buffer.is_null() {
|
||||||
|
let hex_values = std::slice::from_raw_parts(buffer as *const u8, size);
|
||||||
|
for &byte in hex_values {
|
||||||
|
print!("{:02X} ", byte);
|
||||||
|
}
|
||||||
|
println!();
|
||||||
|
|
||||||
|
libc::free(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn demo() {
|
||||||
|
/*
|
||||||
|
* TODO : this is probably not working on release, because I'm not sure it exists a CARGO_MANIFEST_DIR and so it can find the `.env`
|
||||||
|
* Maybe we could use a system standard config path to store a config file
|
||||||
|
*/
|
||||||
|
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||||
|
let manifest_path = PathBuf::from(manifest_dir);
|
||||||
|
dotenv::from_path(manifest_path.join(".env")).ok();
|
||||||
|
|
||||||
|
println!("------- Demo for the SSV library --------");
|
||||||
|
|
||||||
|
ssv_init_lib_2();
|
||||||
|
ssv_lire_carte_ps();
|
||||||
|
ssv_lire_config();
|
||||||
|
|
||||||
|
println!("-----------------------------------------");
|
||||||
|
}
|
5
crates/sesam-vitale/src/win/fsv/ssvw64.def
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
LIBRARY "ssvw64"
|
||||||
|
EXPORTS
|
||||||
|
SSV_InitLIB2
|
||||||
|
SSV_LireCartePS
|
||||||
|
SSV_LireConfig
|
0
scripts/.gitkeep
Normal file
26
scripts/compile_win_headers.bat
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
@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
|