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
//! # NHS Number command line interface (cli)
//!
//! A National Health Service (NHS) Number is a unique number allocated in a shared
//! numbering scheme to registered users of the three public health services in
//! England, Wales, and the Isle of Man.
//!
//! This tool is a command line interface that parses each standard input line into
//! an NHS number, then validates the check digit is correct.
//!
//! * If the line is a valid NHS number, then print it.
//!
//! * If the line is an invalid NHS Number, or is unparseable, then print an error message.
//!
//! * If the line is blank, then skip it.
//!
//! References:
//!
//! * [National Health Service (NHS)](https://en.wikipedia.org/wiki/National_Health_Service)
//!
//! * [NHS Number](https://en.wikipedia.org/wiki/NHS_number)
//!
//! ## Examples
//!
//! Suppose you have a text file `input.txt` that contains one NNS Number per line,
//! and some may be valid or invalid:
//!
//!
//! ```txt
//! 999 123 4560
//! 999 123 4561
//! ```
//!
//! You can parse each line and validate it:
//!
//! ```sh
//! cat input.txt | nhs-number-cli
//! ```
//!
//! The output is one stdout line and one stderr line:
//!
//! ```stdout
//! 999 123 4560
//! ```
//!
//! ```stderr
//! Error invalid line 1. Error: validate check digit failed. NHS Number: 999 123 4561
//! ```
use ;
use NHSNumber;
use FromStr;