using System.Collections.Generic;
using System.Text.RegularExpressions;
DiagnosticWorkflow workflow = new DiagnosticWorkflow();
public int Id { get; set; }
public string PatientName { get; set; }
public string TestType { get; set; }
public DateTime Date { get; set; }
public string Status { get; set; } = "Scheduled";
public string Finding { get; set; }
public string ImageFileName { get; set; }
public string ReportDeliveryMethod { get; set; }
public float? Hemoglobin { get; set; }
public float? WBC { get; set; }
public float? RBC { get; set; }
List<Appointment> appointments = new List<Appointment>();
Console.WriteLine("=== Diagnostic Workflow System ===");
Console.WriteLine("\n1. Schedule Test");
Console.WriteLine("2. Complete Diagnostic Report");
Console.WriteLine("3. View All Appointments");
Console.WriteLine("4. Exit");
Console.Write("Choose an option: ");
string choice = Console.ReadLine();
Console.WriteLine("Exiting...");
Console.WriteLine("Invalid option.");
Console.Write("Enter patient name: ");
string name = Console.ReadLine();
while (string.IsNullOrWhiteSpace(name) || !Regex.IsMatch(name, @"^[A-Za-z\s]+$"))
Console.Write("Invalid name. Use alphabets only: ");
name = Console.ReadLine();
Console.WriteLine("Select Test Type:\n1. Blood Test\n2. Imaging Test (MRI, CT, etc.)");
string testChoice = Console.ReadLine();
else if (testChoice == "2")
testType = "Imaging Test";
Console.WriteLine("Invalid choice. Test not scheduled.");
Console.Write("Enter appointment date (yyyy-mm-dd): ");
string dateInput = Console.ReadLine();
while (!DateTime.TryParse(dateInput, out date) || date.Date < DateTime.Today)
Console.Write("Invalid or past date. Enter again (yyyy-mm-dd): ");
dateInput = Console.ReadLine();
Appointment appt = new Appointment
Console.WriteLine($"{testType} scheduled with ID: {appt.Id}");
void CompleteAppointment()
Console.Write("Enter appointment ID to complete: ");
while (!int.TryParse(Console.ReadLine(), out id))
Console.Write("Invalid ID. Enter numeric: ");
Appointment appt = appointments.Find(a => a.Id == id);
Console.WriteLine("Appointment not found.");
if (appt.Status == "Completed")
Console.WriteLine("Already completed.");
Console.Write("Enter findings: ");
string finding = Console.ReadLine();
while (string.IsNullOrWhiteSpace(finding))
Console.Write("Finding cannot be empty: ");
finding = Console.ReadLine();
if (appt.TestType == "Imaging Test")
Console.Write("Enter image file name (.jpg/.jpeg/.png): ");
string file = Console.ReadLine();
while (string.IsNullOrWhiteSpace(file) || !Regex.IsMatch(file, @"\.(jpg|jpeg|png)$", RegexOptions.IgnoreCase))
Console.Write("Invalid image file name: ");
file = Console.ReadLine();
appt.ImageFileName = file;
else if (appt.TestType == "Blood Test")
appt.Hemoglobin = ReadFloat("Enter Hemoglobin value (g/dL): ");
appt.WBC = ReadFloat("Enter WBC count (10^9/L): ");
appt.RBC = ReadFloat("Enter RBC count (10^12/L): ");
Console.WriteLine("Select report delivery: 1. Printed Copy 2. Patient Portal");
string method = Console.ReadLine();
while (method != "1" && method != "2")
Console.Write("Invalid choice. Select 1 or 2: ");
method = Console.ReadLine();
appt.ReportDeliveryMethod = method == "1" ? "Printed Copy" : "Patient Portal";
appt.Status = "Completed";
Console.WriteLine("\n--- Diagnostic Report ---");
Console.WriteLine($"ID: {appt.Id}");
Console.WriteLine($"Patient: {appt.PatientName}");
Console.WriteLine($"Type: {appt.TestType}");
Console.WriteLine($"Date: {appt.Date:yyyy-MM-dd}");
Console.WriteLine($"Finding: {appt.Finding}");
if (appt.TestType == "Imaging Test")
Console.WriteLine($"Image File: {appt.ImageFileName}");
Console.WriteLine($"Hemoglobin: {appt.Hemoglobin} g/dL");
Console.WriteLine($"WBC: {appt.WBC} x10^9/L");
Console.WriteLine($"RBC: {appt.RBC} x10^12/L");
Console.WriteLine($"Delivery: {appt.ReportDeliveryMethod}");
Console.WriteLine($"Status: {appt.Status}");
float ReadFloat(string prompt)
while (!float.TryParse(Console.ReadLine(), out value))
Console.Write("Invalid input. Enter numeric value: ");
Console.WriteLine("\n--- Appointments ---");
if (appointments.Count == 0)
Console.WriteLine("No appointments found.");
foreach (var a in appointments)
Console.WriteLine($"ID: {a.Id}, Patient: {a.PatientName}, Date: {a.Date:yyyy-MM-dd}, Type: {a.TestType}, Status: {a.Status}");