cima-rs 0.0.5

Rust library and CLI providing access to the Spanish AEMPS CIMA REST API and nomenclator XML parser
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
use cima_rs::downloader::download_and_extract_nomenclator;
use cima_rs::parser::{
    parse_atc_xml_to_csv, parse_dcp_xml_to_csv, parse_dcpf_xml_to_csv, parse_dcsa_xml_to_csv,
    parse_envases_xml_to_csv, parse_excipientes_xml_to_csv,
    parse_forma_farmaceutica_simplificada_xml_to_csv, parse_forma_farmaceutica_xml_to_csv,
    parse_laboratorio_xml_to_csv, parse_prescription_xml_to_csvs,
    parse_principio_activo_xml_to_csv, parse_situacion_registro_xml_to_csv,
    parse_unidad_contenido_xml_to_csv, parse_via_administracion_xml_to_csv,
};
use cima_rs::{
    CimaClient, MasterDataParams, MasterDataType, SearchMedicationsParams,
    SearchPresentationsParams,
};
use clap::{Parser, Subcommand};
use futures::stream::{self, StreamExt};
use std::fs;
use std::path::PathBuf;
use tracing_subscriber::EnvFilter;

#[derive(Parser, Debug)]
#[command(
    author,
    version,
    about = "A tool to work with AEMPS CIMA nomenclator data",
    long_about = "This tool provides access to AEMPS CIMA (Centro de Información Online de Medicamentos) \
                  data through both XML/CSV conversion and REST API queries."
)]
struct Args {
    #[command(subcommand)]
    command: Commands,
}

#[derive(Subcommand, Debug)]
enum Commands {
    /// Download XML files and convert to CSV format
    Csv {
        /// Directory where the generated CSV files will be stored
        #[arg(
            short,
            long,
            default_value = "csv_output",
            help = "Output directory for CSV files"
        )]
        output_dir: PathBuf,

        /// Directory where the downloaded XML files will be extracted and stored
        #[arg(
            short,
            long,
            default_value = "nomenclator_data",
            help = "Working directory for XML files"
        )]
        work_dir: PathBuf,

        /// Number of concurrent parsing tasks (defaults to number of CPU cores)
        #[arg(short, long, help = "Number of concurrent parsing tasks")]
        concurrency: Option<usize>,
    },
    /// Query the CIMA REST API
    Api {
        #[command(subcommand)]
        api_command: ApiCommands,
    },
}

#[derive(Subcommand, Debug)]
enum ApiCommands {
    /// Query medication information
    Medicamento {
        /// Registration number
        #[arg(long, group = "identifier")]
        nregistro: Option<String>,

        /// National code
        #[arg(long, group = "identifier")]
        cn: Option<String>,

        /// Show presentations
        #[arg(short, long)]
        presentaciones: bool,

        /// Show active ingredients
        #[arg(short, long)]
        activos: bool,
    },
    /// Search medications
    SearchMedicamentos {
        /// Medication name
        #[arg(long)]
        nombre: Option<String>,

        /// Laboratory name
        #[arg(long)]
        laboratorio: Option<String>,

        /// Active ingredient name
        #[arg(long)]
        principio_activo: Option<String>,

        /// ATC code or description
        #[arg(long)]
        atc: Option<String>,

        /// Only commercialized medications
        #[arg(long)]
        comercializados: bool,

        /// Only orphan medications
        #[arg(long)]
        huerfanos: bool,

        /// Only medications with black triangle
        #[arg(long)]
        triangulo: bool,

        /// Limit results
        #[arg(short, long, default_value = "10")]
        limit: usize,
    },
    /// Query presentation information
    Presentacion {
        /// National code
        #[arg(long)]
        cn: String,
    },
    /// Search presentations
    SearchPresentaciones {
        /// Registration number
        #[arg(long)]
        nregistro: Option<String>,

        /// VMP code
        #[arg(long)]
        vmp: Option<String>,

        /// Only commercialized
        #[arg(long)]
        comercializados: bool,

        /// Limit results
        #[arg(short, long, default_value = "10")]
        limit: usize,
    },
    /// Get supply problems
    SupplyProblems {
        /// National code (if not provided, returns all)
        #[arg(long)]
        cn: Option<String>,
    },
    /// Get safety notes for a medication
    SafetyNotes {
        /// Registration number
        #[arg(long)]
        nregistro: String,
    },
    /// Get change log
    Changes {
        /// Date from which to get changes (format: dd/mm/yyyy)
        #[arg(long)]
        desde: String,

        /// Limit to specific registration numbers
        #[arg(long)]
        nregistro: Vec<String>,
    },
    /// Query master data catalogs
    Maestra {
        /// Type of master data: pa (principios activos), ff (formas farmaceuticas),
        /// va (vias administracion), lab (laboratorios), atc (codigos ATC)
        #[arg(long)]
        tipo: String,

        /// Name filter
        #[arg(long)]
        nombre: Option<String>,

        /// Limit results
        #[arg(short, long, default_value = "20")]
        limit: usize,
    },
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Initialize tracing subscriber
    tracing_subscriber::fmt()
        .with_env_filter(
            EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")),
        )
        .init();

    let args = Args::parse();

    match args.command {
        Commands::Csv {
            output_dir,
            work_dir,
            concurrency,
        } => process_csv(output_dir, work_dir, concurrency).await,
        Commands::Api { api_command } => process_api(api_command).await,
    }
}

async fn process_csv(
    output_dir: PathBuf,
    work_dir: PathBuf,
    concurrency: Option<usize>,
) -> anyhow::Result<()> {
    // Ensure directories exist
    fs::create_dir_all(&output_dir)?;
    fs::create_dir_all(&work_dir)?;

    // Determine concurrency level based on CPU cores
    let num_cores = num_cpus::get();
    let concurrency = concurrency.unwrap_or(num_cores);

    tracing::info!(work_dir = ?work_dir, "Target work directory");
    tracing::info!(output_dir = ?output_dir, "Target output directory");
    tracing::info!(num_cores, "Available CPU cores");
    tracing::info!(concurrency, "Concurrency level");

    // 1. Download and extract
    tracing::info!("Downloading and extracting AEMPS Nomenclator data");
    download_and_extract_nomenclator(&work_dir).await?;

    // 2. Define files to parse
    let mapping = vec![
        (
            "DICCIONARIO_ATC.xml",
            "atc.csv",
            parse_atc_xml_to_csv as fn(PathBuf, PathBuf) -> anyhow::Result<()>,
        ),
        (
            "DICCIONARIO_DCP.xml",
            "dcp.csv",
            parse_dcp_xml_to_csv as fn(PathBuf, PathBuf) -> anyhow::Result<()>,
        ),
        ("DICCIONARIO_DCPF.xml", "dcpf.csv", parse_dcpf_xml_to_csv),
        ("DICCIONARIO_DCSA.xml", "dcsa.csv", parse_dcsa_xml_to_csv),
        (
            "DICCIONARIO_ENVASES.xml",
            "envases.csv",
            parse_envases_xml_to_csv,
        ),
        (
            "DICCIONARIO_EXCIPIENTES_DECL_OBLIGATORIA.xml",
            "excipientes.csv",
            parse_excipientes_xml_to_csv,
        ),
        (
            "DICCIONARIO_FORMA_FARMACEUTICA.xml",
            "forma_farmaceutica.csv",
            parse_forma_farmaceutica_xml_to_csv,
        ),
        (
            "DICCIONARIO_FORMA_FARMACEUTICA_SIMPLIFICADAS.xml",
            "forma_farmaceutica_simplificada.csv",
            parse_forma_farmaceutica_simplificada_xml_to_csv,
        ),
        (
            "DICCIONARIO_LABORATORIOS.xml",
            "laboratorios.csv",
            parse_laboratorio_xml_to_csv,
        ),
        (
            "DICCIONARIO_PRINCIPIOS_ACTIVOS.xml",
            "principios_activos.csv",
            parse_principio_activo_xml_to_csv,
        ),
        (
            "DICCIONARIO_SITUACION_REGISTRO.xml",
            "situacion_registro.csv",
            parse_situacion_registro_xml_to_csv,
        ),
        (
            "DICCIONARIO_UNIDAD_CONTENIDO.xml",
            "unidad_contenido.csv",
            parse_unidad_contenido_xml_to_csv,
        ),
        (
            "DICCIONARIO_VIAS_ADMINISTRACION.xml",
            "vias_administracion.csv",
            parse_via_administracion_xml_to_csv,
        ),
        // Note: Prescripcion.xml is handled separately below (generates multiple CSVs)
    ];

    // 3. Process dictionary files in parallel using tokio streams
    tracing::info!(
        file_count = mapping.len(),
        concurrency,
        "Parsing dictionary files"
    );

    let results: Vec<_> = stream::iter(mapping)
        .map(|(xml_name, csv_name, parser_fn)| {
            let xml_path = work_dir.join(xml_name);
            let csv_path = output_dir.join(csv_name);
            let xml_name = xml_name.to_string();
            let csv_name = csv_name.to_string();

            async move {
                if !xml_path.exists() {
                    tracing::warn!(file = %xml_name, "File not found, skipping");
                    return Ok((xml_name, csv_name, false));
                }

                // Spawn blocking task for CPU-bound XML parsing
                tracing::debug!(xml = %xml_name, csv = %csv_name, "Starting parse task");
                let result =
                    tokio::task::spawn_blocking(move || parser_fn(xml_path, csv_path)).await;

                match result {
                    Ok(Ok(())) => {
                        tracing::info!(xml = %xml_name, csv = %csv_name, "Completed parse");
                        Ok((xml_name, csv_name, true))
                    }
                    Ok(Err(e)) => {
                        tracing::error!(xml = %xml_name, error = %e, "Parse failed");
                        Err(e)
                    }
                    Err(e) => {
                        tracing::error!(xml = %xml_name, error = %e, "Task join failed");
                        Err(anyhow::anyhow!("Task join error: {}", e))
                    }
                }
            }
        })
        .buffer_unordered(concurrency)
        .collect()
        .await;

    // 4. Handle Prescription XML separately (generates multiple CSVs)
    let prescription_result = {
        let xml_path = work_dir.join("Prescripcion.xml");
        if xml_path.exists() {
            tracing::info!("Parsing Prescripcion.xml to 7 CSV files");
            match parse_prescription_xml_to_csvs(&xml_path, &output_dir) {
                Ok(()) => {
                    tracing::info!("Completed all prescription CSV files");
                    println!("✓ Completed: prescriptions.csv");
                    println!("✓ Completed: prescription_forms.csv");
                    println!("✓ Completed: prescription_active_ingredients.csv");
                    println!("✓ Completed: prescription_admin_routes.csv");
                    println!("✓ Completed: prescription_atc.csv");
                    println!("✓ Completed: prescription_atc_duplicates.csv");
                    println!("✓ Completed: prescription_supply_problems.csv");
                    Ok(())
                }
                Err(e) => {
                    tracing::error!(error = ?e, "Failed to parse Prescripcion.xml");
                    // Print full error chain for debugging
                    eprintln!("Prescription parse error: {:#}", e);
                    Err(e)
                }
            }
        } else {
            tracing::warn!("Prescripcion.xml not found, skipping");
            Ok(())
        }
    };

    // 5. Report results
    let successful = results.iter().filter(|r| r.is_ok()).count();
    let failed = results.iter().filter(|r| r.is_err()).count();
    let prescription_success = prescription_result.is_ok();

    tracing::info!(
        successful,
        failed,
        prescription_success,
        "CSV parsing completed"
    );

    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
    println!("Summary:");
    println!("  ✓ Dictionary files successful: {}", successful);
    if failed > 0 {
        println!("  ✗ Dictionary files failed: {}", failed);
    }
    if prescription_success {
        println!("  ✓ Prescription parsing: Success (7 CSV files)");
    } else {
        println!("  ✗ Prescription parsing: Failed");
    }
    println!("  📁 Output directory: {:?}", output_dir);
    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");

    if failed > 0 || !prescription_success {
        anyhow::bail!("Some files failed to parse");
    }

    Ok(())
}

async fn process_api(api_command: ApiCommands) -> anyhow::Result<()> {
    tracing::debug!("Creating CIMA client for API query");
    let client = CimaClient::new()?;

    match api_command {
        ApiCommands::Medicamento {
            nregistro,
            cn,
            presentaciones,
            activos,
        } => {
            let med = client
                .get_medication(nregistro.as_deref(), cn.as_deref())
                .await?;

            println!("=== Medicamento ===");
            println!("Nº Registro: {}", med.nregistro);
            println!("Nombre: {}", med.name);
            println!("Laboratorio: {}", med.labtitular);
            println!("Principios Activos: {}", med.pactivos);
            println!("Condiciones de prescripción: {}", med.cpresc);

            if let Some(comerc) = med.commercialized {
                println!("Comercializado: {}", if comerc { "" } else { "No" });
            }

            if let Some(triangulo) = med.black_triangle
                && triangulo
            {
                println!("⚠️  Triángulo negro (medicamento bajo vigilancia adicional)");
            }

            if let Some(huerfano) = med.orphan
                && huerfano
            {
                println!("💊 Medicamento huérfano");
            }

            if activos && !med.active_ingredients.is_empty() {
                println!("\n=== Principios Activos ===");
                for pa in &med.active_ingredients {
                    print!("- {}", pa.name);
                    if let (Some(cantidad), Some(unidad)) = (&pa.amount, &pa.unit) {
                        print!(": {} {}", cantidad, unidad);
                    }
                    println!();
                }
            }

            if presentaciones && !med.presentations.is_empty() {
                println!("\n=== Presentaciones ===");
                for pres in &med.presentations {
                    println!("- CN: {} - {}", pres.cn, pres.name);
                    if pres.commercialized {
                        println!("  ✓ Comercializada");
                    }
                }
            }

            if !med.docs.is_empty() {
                println!("\n=== Documentos Disponibles ===");
                for doc in &med.docs {
                    let tipo = match doc.doc_type {
                        1 => "Ficha Técnica",
                        2 => "Prospecto",
                        3 => "Informe Público Evaluación",
                        4 => "Plan de gestión de riesgos",
                        _ => "Otro",
                    };
                    println!("- {}: {}", tipo, doc.url);
                }
            }
        }
        ApiCommands::SearchMedicamentos {
            nombre,
            laboratorio,
            principio_activo,
            atc,
            comercializados,
            huerfanos,
            triangulo,
            limit,
        } => {
            let params = SearchMedicationsParams {
                name: nombre,
                laboratory: laboratorio,
                active_ingredient_1: principio_activo,
                atc,
                commercialized: if comercializados { Some(1) } else { None },
                orphan: if huerfanos { Some(1) } else { None },
                black_triangle: if triangulo { Some(1) } else { None },
                ..Default::default()
            };

            let response = client.search_medications(&params).await?;

            tracing::info!(
                "Found {} total medications (page {} of {}, showing {} results)",
                response.total_rows,
                response.page,
                response.total_rows.div_ceil(response.page_size),
                response.results.len()
            );

            for (i, med) in response.results.iter().enumerate().take(limit) {
                println!("{}. {} ({})", i + 1, med.name, med.nregistro);
                println!("   Laboratorio: {}", med.labtitular);
                if let Some(comerc) = med.commercialized {
                    println!("   Comercializado: {}", if comerc { "" } else { "No" });
                }
                println!();
            }

            if response.results.len() > limit {
                tracing::info!(
                    "Showing {} of {} results from page",
                    limit,
                    response.results.len()
                );
            }
        }
        ApiCommands::Presentacion { cn } => {
            let pres = client.get_presentation(&cn).await?;

            println!("=== Presentación ===");
            println!("Código Nacional: {}", pres.cn);
            println!("Nombre: {}", pres.name);
            println!(
                "Comercializada: {}",
                if pres.commercialized { "" } else { "No" }
            );
        }
        ApiCommands::SearchPresentaciones {
            nregistro,
            vmp,
            comercializados,
            limit,
        } => {
            let params = SearchPresentationsParams {
                registration_number: nregistro,
                vmp,
                commercialized: if comercializados { Some(1) } else { None },
                ..Default::default()
            };

            let response = client.search_presentations(&params).await?;

            tracing::info!(
                "Found {} total presentations (page {} of {}, showing {} results)",
                response.total_rows,
                response.page,
                response.total_rows.div_ceil(response.page_size),
                response.results.len()
            );

            for (i, p) in response.results.iter().enumerate().take(limit) {
                println!("{}. CN: {} - {}", i + 1, p.cn, p.name);
                if p.commercialized {
                    println!("   ✓ Comercializada");
                }
                println!();
            }

            if response.results.len() > limit {
                tracing::info!(
                    "Showing {} of {} results from page",
                    limit,
                    response.results.len()
                );
            }
        }
        ApiCommands::SupplyProblems { cn } => {
            if let Some(codigo) = cn {
                let response = client.get_supply_problems(&codigo).await?;
                tracing::info!(
                    "Found {} supply problems for CN {} (page {} of {})",
                    response.total_rows,
                    codigo,
                    response.page,
                    response.total_rows.div_ceil(response.page_size)
                );

                for (i, prob) in response.results.iter().enumerate() {
                    println!("{}. CN: {} - {}", i + 1, prob.cn, prob.name);
                    println!("   Activo: {}", if prob.active { "" } else { "No" });
                    if let Some(obs) = &prob.observations {
                        println!("   Observaciones: {}", obs);
                    }
                    println!();
                }
            } else {
                let response = client.get_all_supply_problems().await?;
                tracing::info!(
                    "Found {} total supply problems (page {} of {})",
                    response.total_rows,
                    response.page,
                    response.total_rows.div_ceil(response.page_size)
                );

                for (i, prob) in response.results.iter().enumerate() {
                    println!("{}. CN: {} - {}", i + 1, prob.cn, prob.name);
                    println!("   Activo: {}", if prob.active { "" } else { "No" });
                    if let Some(obs) = &prob.observations {
                        println!("   Observaciones: {}", obs);
                    }
                    println!();
                }
            }
        }
        ApiCommands::SafetyNotes { nregistro } => {
            let notas = client.get_safety_notes(&nregistro).await?;

            println!("Notas de Seguridad: {}\n", notas.len());

            for (i, nota) in notas.iter().enumerate() {
                println!("{}. {} - {}", i + 1, nota.num, nota.subject);
                println!("   URL: {}", nota.url);
                println!();
            }
        }
        ApiCommands::Changes { desde, nregistro } => {
            let nregs: Vec<&str> = nregistro.iter().map(|s| s.as_str()).collect();
            let nregs_opt = if nregs.is_empty() {
                None
            } else {
                Some(nregs.as_slice())
            };

            let response = client.get_change_log(&desde, nregs_opt).await?;

            tracing::info!(
                "Found {} total changes since {} (page {} of {})",
                response.total_rows,
                desde,
                response.page,
                response.total_rows.div_ceil(response.page_size)
            );

            for (i, cambio) in response.results.iter().enumerate() {
                println!("{}. Nº Registro: {}", i + 1, cambio.nregistro);
                let tipo = match cambio.change_type {
                    1 => "Nuevo",
                    2 => "Baja",
                    3 => "Modificado",
                    _ => "Desconocido",
                };
                println!("   Tipo: {}", tipo);
                if !cambio.changes.is_empty() {
                    println!("   Cambios: {}", cambio.changes.join(", "));
                }
                println!();
            }
        }
        ApiCommands::Maestra {
            tipo,
            nombre,
            limit,
        } => {
            // Validate that at least one filter parameter is provided (API requires this)
            if nombre.is_none() {
                tracing::warn!(
                    "No filter parameters provided. The CIMA API requires at least one filter parameter (nombre, id, codigo, etc.)"
                );
                tracing::warn!(
                    "The maestra CLI currently only supports --nombre. Other parameters can be used via the library API."
                );
                eprintln!("Error: The --nombre parameter is required for this command");
                eprintln!(
                    "(The API supports id, codigo, estupefaciente, etc., but the CLI currently only exposes --nombre)"
                );
                eprintln!("Example: nomenclator api maestra --tipo pa --nombre 'paracetamol'");
                std::process::exit(1);
            }

            let tipo_maestra = match tipo.as_str() {
                "pa" => MasterDataType::ActiveIngredients,
                "ff" => MasterDataType::PharmaceuticalForms,
                "va" => MasterDataType::AdministrationRoutes,
                "lab" => MasterDataType::Laboratories,
                "atc" => MasterDataType::AtcCodes,
                _ => anyhow::bail!(
                    "Tipo de maestra desconocido: {}. Use: pa, ff, va, lab, atc",
                    tipo
                ),
            };

            let params = MasterDataParams {
                name: nombre,
                ..Default::default()
            };

            let response = client.get_master_data(tipo_maestra, &params).await?;

            tracing::info!(
                "Found {} total items (page {} of {})",
                response.total_rows,
                response.page,
                response.total_rows.div_ceil(response.page_size)
            );

            for (i, item) in response.results.iter().enumerate().take(limit) {
                print!("{}. {}", i + 1, item.name);
                if let Some(codigo) = &item.code {
                    print!(" ({})", codigo);
                } else if let Some(id) = item.id {
                    print!(" (ID: {})", id);
                }
                println!();
            }

            if response.results.len() > limit {
                tracing::info!(
                    "Showing {} of {} results from page",
                    limit,
                    response.results.len()
                );
            }
        }
    }

    Ok(())
}