diff --git a/Frontend/patient_manager/lib/objects/perscription.dart b/Frontend/patient_manager/lib/objects/perscription.dart new file mode 100644 index 00000000..795c484b --- /dev/null +++ b/Frontend/patient_manager/lib/objects/perscription.dart @@ -0,0 +1,65 @@ +class Perscription { + final String name; + final String unit; + final String form; + final String fullForm; + final String quantity; + final String dosage; + final String times; + final String days; + final String repeats; + + const Perscription({ + required this.name, + required this.unit, + required this.form, + required this.fullForm, + required this.quantity, + required this.dosage, + required this.times, + required this.days, + required this.repeats, + }); + + factory Perscription.fromJson(Map json) { + return switch (json) { + { + "name": String name, + 'unit': String unit, + 'form': String form, + 'fullForm': String fullForm, + 'quantity': String quantity, + 'dosage': String dosage, + 'times': String times, + 'days': String days, + 'repeats': String repeats, + } => + Perscription( + name: name, + unit: unit, + form: form, + fullForm: fullForm, + quantity: quantity, + dosage: dosage, + times: times, + days: days, + repeats: repeats, + ), + _ => throw const FormatException('Failed to load album.'), + }; + } + + Map toJson() { + return { + "name": name, + 'unit': unit, + 'form': form, + 'fullForm': fullForm, + 'quantity': quantity, + 'dosage': dosage, + 'times': times, + 'days': days, + 'repeats': repeats, + }; + } +}