From 5614d3b156ddd652eebe6ca1f5e2de5e9d8a7f9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Sun, 7 Jul 2019 22:29:13 +0100 Subject: Get and set the patient name on supported meters. This includes the command line extensions to include the get/set patient name, as well as the driver support for all FreeStyle devices with the shared HID protocol, although not all will support this properly. --- glucometerutils/glucometer.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'glucometerutils/glucometer.py') diff --git a/glucometerutils/glucometer.py b/glucometerutils/glucometer.py index 8cf2555..8f222bc 100755 --- a/glucometerutils/glucometer.py +++ b/glucometerutils/glucometer.py @@ -58,6 +58,12 @@ def main(): '--set', action='store', nargs='?', const='now', default=None, help='Set the date rather than just reading it from the device.') + parser_patient = subparsers.add_parser( + 'patient', help='Reads or sets the patient information.') + parser_patient.add_argument( + '--set_name', action='store', required=False, + help='Set the patient name, if the meter supports it.') + args = parser.parse_args() logging.basicConfig(level=args.vlog) @@ -124,6 +130,22 @@ def main(): print(device.set_datetime(new_date)) else: print(device.get_datetime()) + elif args.action == 'patient': + if args.set_name != None: + try: + device.set_patient_name(args.set_name) + except NotImplementedError: + print( + 'The glucometer does not support setting patient name.') + try: + patient_name = device.get_patient_name() + if patient_name is None: + patient_name = '[N/A]' + print('Patient Name: {patient_name}'.format( + patient_name=patient_name)) + except NotImplementedError: + print( + 'The glucometer does not support retrieving patient name.') elif args.action == 'zero': confirm = input('Delete the device data log? (y/N) ') if confirm.lower() in ['y', 'ye', 'yes']: -- cgit v1.2.3