This commit is contained in:
parent
a3fef1c38c
commit
2b45f5aa7e
Binary file not shown.
@ -4,7 +4,6 @@ use std::ptr;
|
|||||||
|
|
||||||
use crate::libssv::SSV_LireDroitsVitale;
|
use crate::libssv::SSV_LireDroitsVitale;
|
||||||
|
|
||||||
|
|
||||||
use crate::ssv_memory::{decode_ssv_memory, Block};
|
use crate::ssv_memory::{decode_ssv_memory, Block};
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
@ -15,8 +14,6 @@ pub struct CarteVitale {
|
|||||||
donneesBeneficiaire: Vec<DonneesBeneficiaire>,
|
donneesBeneficiaire: Vec<DonneesBeneficiaire>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 1. CB = Caractères Binaires »
|
// 1. CB = Caractères Binaires »
|
||||||
// 2. CE = Caractères « Etendus » (ISO 8859-1)
|
// 2. CE = Caractères « Etendus » (ISO 8859-1)
|
||||||
// 3. CA = Caractères Alphanumériques (ASCII?)
|
// 3. CA = Caractères Alphanumériques (ASCII?)
|
||||||
@ -39,7 +36,6 @@ struct DonneesAssure {
|
|||||||
donnees_ruf_famille: String, // CE - 55
|
donnees_ruf_famille: String, // CE - 55
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
struct ServiceAMOFamille {
|
struct ServiceAMOFamille {
|
||||||
code_service_amo_famille: String, // CN - 2
|
code_service_amo_famille: String, // CN - 2
|
||||||
@ -47,7 +43,6 @@ struct ServiceAMOFamille {
|
|||||||
date_de_fin_service_amo_famille: String, // CN - Format AAAAMMJJ0000
|
date_de_fin_service_amo_famille: String, // CN - Format AAAAMMJJ0000
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
struct DonneesAccidentTravail {
|
struct DonneesAccidentTravail {
|
||||||
organisme_gestionnaire_risque_at: String, // CN - 9
|
organisme_gestionnaire_risque_at: String, // CN - 9
|
||||||
@ -61,7 +56,6 @@ struct DonneesAccidentTravail {
|
|||||||
identifiant_at2: String, // CN - 9
|
identifiant_at2: String, // CN - 9
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
struct DonneesBeneficiaire {
|
struct DonneesBeneficiaire {
|
||||||
nom_usuel: String, // CE - 27
|
nom_usuel: String, // CE - 27
|
||||||
@ -89,14 +83,12 @@ struct DonneesBeneficiaire {
|
|||||||
donneesRUFBeneficiaireComplementaire: DonneesRUFBeneficiaireComplementaire,
|
donneesRUFBeneficiaireComplementaire: DonneesRUFBeneficiaireComplementaire,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
struct PeriodeDroitsAMO {
|
struct PeriodeDroitsAMO {
|
||||||
date_de_debut_droits_amo: String, // CN - Format AAAAMMJJ0000
|
date_de_debut_droits_amo: String, // CN - Format AAAAMMJJ0000
|
||||||
date_de_fin_droits_amo: String, // CN - Format AAAAMMJJ0000
|
date_de_fin_droits_amo: String, // CN - Format AAAAMMJJ0000
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
struct PeriodeCodeCouverture {
|
struct PeriodeCodeCouverture {
|
||||||
date_de_debut_code_couverture: String, // CN - Format AAAAMMJJ0000
|
date_de_debut_code_couverture: String, // CN - Format AAAAMMJJ0000
|
||||||
@ -105,7 +97,6 @@ struct PeriodeCodeCouverture {
|
|||||||
code_situation: String, // CN - 4
|
code_situation: String, // CN - 4
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
struct DonneesMutuelle {
|
struct DonneesMutuelle {
|
||||||
identification_mutuelle: String, // CN - 8
|
identification_mutuelle: String, // CN - 8
|
||||||
@ -117,14 +108,12 @@ struct DonneesMutuelle {
|
|||||||
periodeDroitsMutuelle: Vec<PeriodeDroitsMutuelle>,
|
periodeDroitsMutuelle: Vec<PeriodeDroitsMutuelle>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
struct PeriodeDroitsMutuelle {
|
struct PeriodeDroitsMutuelle {
|
||||||
date_de_debut_droits_mutuelle: String, // CN - Format AAAAMMJJ0000
|
date_de_debut_droits_mutuelle: String, // CN - Format AAAAMMJJ0000
|
||||||
date_de_fin_droits_mutuelle: String, // CN - Format AAAAMMJJ0000
|
date_de_fin_droits_mutuelle: String, // CN - Format AAAAMMJJ0000
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
struct DonneesComplementaire {
|
struct DonneesComplementaire {
|
||||||
numero_complementaire_b2: String, // CA - 10
|
numero_complementaire_b2: String, // CA - 10
|
||||||
@ -146,8 +135,12 @@ struct DonneesRUFBeneficiaireComplementaire {
|
|||||||
donnees_ruf_beneficiaire_complementaire: String, // CE - 115
|
donnees_ruf_beneficiaire_complementaire: String, // CE - 115
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn LireDroitsVitale(
|
||||||
pub fn LireDroitsVitale(lecteurPS: &str, lecteurVitale: &str, codePorteurPS: &str, dateConsultation: &str) -> Result<CarteVitale, String> {
|
lecteurPS: &str,
|
||||||
|
lecteurVitale: &str,
|
||||||
|
codePorteurPS: &str,
|
||||||
|
dateConsultation: &str,
|
||||||
|
) -> Result<CarteVitale, String> {
|
||||||
let resource_ps = CString::new(lecteurPS).expect("CString::new failed");
|
let resource_ps = CString::new(lecteurPS).expect("CString::new failed");
|
||||||
let resource_vitale = CString::new(lecteurVitale).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 card_number = CString::new(codePorteurPS).expect("CString::new failed");
|
||||||
@ -165,26 +158,28 @@ pub fn LireDroitsVitale(lecteurPS: &str, lecteurVitale: &str, codePorteurPS: &st
|
|||||||
&mut buffer,
|
&mut buffer,
|
||||||
&mut size,
|
&mut size,
|
||||||
);
|
);
|
||||||
println!("SSV_LireCartePS result: {}", result);
|
println!("SSV_LireDroitsVitale result: {}", result);
|
||||||
|
|
||||||
if !buffer.is_null() {
|
if !buffer.is_null() {
|
||||||
hex_values = std::slice::from_raw_parts(buffer as *const u8, size);
|
hex_values = std::slice::from_raw_parts(buffer as *const u8, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let groups = decode_ssv_memory(hex_values, hex_values.len());
|
||||||
|
|
||||||
|
unsafe {
|
||||||
libc::free(buffer);
|
libc::free(buffer);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
let groups = decode_ssv_memory(hex_values, hex_values.len());
|
|
||||||
decode_carte_vitale(groups)
|
decode_carte_vitale(groups)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decode_carte_vitale(groups: Vec<Block>) -> Result<CarteVitale, String> {
|
fn decode_carte_vitale(groups: Vec<Block>) -> Result<CarteVitale, String> {
|
||||||
let mut cartevitale = CarteVitale::default();
|
let mut cartevitale = CarteVitale::default();
|
||||||
|
|
||||||
// let lastBlock :u16;
|
|
||||||
// let lastField :u16;
|
|
||||||
|
|
||||||
for group in groups {
|
for group in groups {
|
||||||
for field in group.content {
|
for field in group.content {
|
||||||
|
if field.content.len() > 0 {
|
||||||
match (group.id, field.id) {
|
match (group.id, field.id) {
|
||||||
(101, 1) => {
|
(101, 1) => {
|
||||||
let byte = field.content[0];
|
let byte = field.content[0];
|
||||||
@ -199,6 +194,7 @@ fn decode_carte_vitale(groups: Vec<Block>) -> Result<CarteVitale, String> {
|
|||||||
String::from_utf8_lossy(field.content).to_string();
|
String::from_utf8_lossy(field.content).to_string();
|
||||||
}
|
}
|
||||||
(101, 4) => {
|
(101, 4) => {
|
||||||
|
println!("101.4 field.size: {:#?}", field.size);
|
||||||
let byte = field.content[0];
|
let byte = field.content[0];
|
||||||
cartevitale.donneesAssure.donnees_administration_ruf1 = byte as char;
|
cartevitale.donneesAssure.donnees_administration_ruf1 = byte as char;
|
||||||
}
|
}
|
||||||
@ -247,15 +243,21 @@ fn decode_carte_vitale(groups: Vec<Block>) -> Result<CarteVitale, String> {
|
|||||||
String::from_utf8_lossy(field.content).to_string();
|
String::from_utf8_lossy(field.content).to_string();
|
||||||
}
|
}
|
||||||
(102, 2) => {
|
(102, 2) => {
|
||||||
cartevitale.serviceAMOFamille.date_de_debut_service_amo_famille =
|
cartevitale
|
||||||
|
.serviceAMOFamille
|
||||||
|
.date_de_debut_service_amo_famille =
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
String::from_utf8_lossy(field.content).to_string();
|
||||||
}
|
}
|
||||||
(102, 3) => {
|
(102, 3) => {
|
||||||
cartevitale.serviceAMOFamille.date_de_fin_service_amo_famille =
|
cartevitale
|
||||||
|
.serviceAMOFamille
|
||||||
|
.date_de_fin_service_amo_famille =
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
String::from_utf8_lossy(field.content).to_string();
|
||||||
}
|
}
|
||||||
(103, 1) => {
|
(103, 1) => {
|
||||||
cartevitale.donneesAccidentTravail.organisme_gestionnaire_risque_at =
|
cartevitale
|
||||||
|
.donneesAccidentTravail
|
||||||
|
.organisme_gestionnaire_risque_at =
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
String::from_utf8_lossy(field.content).to_string();
|
||||||
}
|
}
|
||||||
(103, 2) => {
|
(103, 2) => {
|
||||||
@ -267,7 +269,9 @@ fn decode_carte_vitale(groups: Vec<Block>) -> Result<CarteVitale, String> {
|
|||||||
String::from_utf8_lossy(field.content).to_string();
|
String::from_utf8_lossy(field.content).to_string();
|
||||||
}
|
}
|
||||||
(103, 4) => {
|
(103, 4) => {
|
||||||
cartevitale.donneesAccidentTravail.organisme_gestionnaire_at1 =
|
cartevitale
|
||||||
|
.donneesAccidentTravail
|
||||||
|
.organisme_gestionnaire_at1 =
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
String::from_utf8_lossy(field.content).to_string();
|
||||||
}
|
}
|
||||||
(103, 5) => {
|
(103, 5) => {
|
||||||
@ -279,7 +283,9 @@ fn decode_carte_vitale(groups: Vec<Block>) -> Result<CarteVitale, String> {
|
|||||||
String::from_utf8_lossy(field.content).to_string();
|
String::from_utf8_lossy(field.content).to_string();
|
||||||
}
|
}
|
||||||
(103, 7) => {
|
(103, 7) => {
|
||||||
cartevitale.donneesAccidentTravail.organisme_gestionnaire_at2 =
|
cartevitale
|
||||||
|
.donneesAccidentTravail
|
||||||
|
.organisme_gestionnaire_at2 =
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
String::from_utf8_lossy(field.content).to_string();
|
||||||
}
|
}
|
||||||
(103, 8) => {
|
(103, 8) => {
|
||||||
@ -299,6 +305,7 @@ fn decode_carte_vitale(groups: Vec<Block>) -> Result<CarteVitale, String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Ok(cartevitale)
|
Ok(cartevitale)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
mod cps;
|
mod cps;
|
||||||
mod carteVitale;
|
mod cartevitale;
|
||||||
mod libssv;
|
mod libssv;
|
||||||
mod ssv_memory;
|
mod ssv_memory;
|
||||||
mod ssvlib_demo;
|
mod ssvlib_demo;
|
||||||
|
@ -71,6 +71,8 @@ impl<'a> From<&'a [u8]> for Block<'a> {
|
|||||||
let mut field_id = 1;
|
let mut field_id = 1;
|
||||||
while field_offset < block_size {
|
while field_offset < block_size {
|
||||||
let mut field: Field<'a> = raw_content[field_offset..].into();
|
let mut field: Field<'a> = raw_content[field_offset..].into();
|
||||||
|
|
||||||
|
|
||||||
field.id = field_id;
|
field.id = field_id;
|
||||||
field_offset += field.size;
|
field_offset += field.size;
|
||||||
field_id += 1;
|
field_id += 1;
|
||||||
|
26
scripts/compile_win_headers - Copie.bat
Normal file
26
scripts/compile_win_headers - Copie.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
|
@ -1,7 +1,7 @@
|
|||||||
@echo off
|
@echo off
|
||||||
rem Set variables
|
rem Set variables
|
||||||
set LIB_DIR=crates/sesam-vitale/lib
|
set LIB_DIR=F:\PAPILLON\Krys4lideCopie\crates\sesam-vitale\lib
|
||||||
set DEF_DIR=crates/sesam-vitale/src/win/fsv
|
set DEF_DIR=F:\PAPILLON\Krys4lideCopie\crates\sesam-vitale\src\win\fsv
|
||||||
|
|
||||||
if "%1"=="/clean" (
|
if "%1"=="/clean" (
|
||||||
goto clean
|
goto clean
|
||||||
|
6
scripts/ssvw64.def
Normal file
6
scripts/ssvw64.def
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
LIBRARY "ssvw64"
|
||||||
|
EXPORTS
|
||||||
|
SSV_InitLIB2
|
||||||
|
SSV_LireCartePS
|
||||||
|
SSV_LireConfig
|
||||||
|
SSV_LireDroitsVitale
|
Loading…
Reference in New Issue
Block a user