This commit is contained in:
lienjukaisim 2024-08-15 14:36:55 +02:00
parent d56f7a2249
commit 6b6658f56d

View File

@ -167,13 +167,15 @@ pub fn LireDroitsVitale(
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 alors hex_values n'est plus correct ???
libc::free(buffer); // ??? si liberer avant decode_ssv_memory et decode_carte_vitale alors hex_values n'est plus correct ???
}
}
OUT
decode_carte_vitale(groups)
}
fn decode_carte_vitale(groups: Vec<Block>) -> Result<CarteVitale, String> {
@ -181,6 +183,39 @@ fn decode_carte_vitale(groups: Vec<Block>) -> Result<CarteVitale, String> {
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) => {
@ -188,7 +223,7 @@ fn decode_carte_vitale(groups: Vec<Block>) -> Result<CarteVitale, String> {
cartevitale.donneesAssure.type_de_carte_vitale = byte as char;
}
(101, 2) => {
cartevitale.donneesAssure.numero_de_serie =
cartevitale.donneesAssure.numero_de_serie = //bytes_to_decimal_string(&field.content);
String::from_utf8_lossy(field.content).to_string();
}
(101, 3) => {
@ -298,7 +333,385 @@ fn decode_carte_vitale(groups: Vec<Block>) -> Result<CarteVitale, String> {
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
@ -310,7 +723,12 @@ fn decode_carte_vitale(groups: Vec<Block>) -> Result<CarteVitale, String> {
}
Ok(cartevitale)
}
fn bytes_to_decimal_string(byte_array: &[u8]) -> String {
byte_array.iter()
.map(|byte| byte.to_string())
.collect::<Vec<String>>()
.join(" ")
}
// #[cfg(test)]
// mod test_decode_carte_ps {
// use super::*;