Exemplo n.º 1
0
 public AnalysisController(AnalysisNurse view)
 {
     this.view               = view;
     this.patientModel       = new Models.Patient();
     this.patientChartModel  = new Models.PatientChart();
     this.chartDocumentModel = new Models.ChartDocument();
 }
 public PatientChartsController(OperatorPatientCharts view)
 {
     this.view               = view;
     this.patientModel       = new Models.Patient();
     this.patientChartModel  = new Models.PatientChart();
     this.chartDocumentModel = new Models.ChartDocument();
     this.allergenModel      = new Models.Allergen();
     this.counter            = 0;
     this.pageCount          = 1;
 }
        private async void printChart(object sender, PrintPageEventArgs e)
        {
            try {
                Cursor.Current = Cursors.WaitCursor;

                List <Models.Allergen> allergens = await this.readAllergens(this.selectedChart.Id);

                List <Models.ChartDocument> docs = await this.readPatientChartDocs(this.selectedChart.Id);

                string allergensResult = "";

                allergens.ForEach((item) => {
                    allergensResult = $"{allergensResult}{(allergensResult.Length > 0 ? ", " : "")}{item.Medicament.Name}";
                });

                // Printing

                int startY         = 50;
                int margin         = 30;
                int keyX           = 80;
                int valueX         = 400;
                int itemFontSize   = 10;
                int headerFontSize = 14;

                if (this.pageCount == 1)
                {
                    e.Graphics.DrawString(
                        "EPacient - Kartela e pacientit",
                        new Font(Fonts.primary, 20, FontStyle.Bold),
                        Brushes.SaddleBrown,
                        new Point(250, startY)
                        );
                    e.Graphics.DrawString(
                        "Gjeneralitetet",
                        new Font(Fonts.primary, headerFontSize, FontStyle.Bold),
                        Brushes.DarkBlue,
                        new Point(keyX, (startY + (int)(2.5 * margin)))
                        );
                    e.Graphics.DrawString(
                        "ID",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Regular),
                        Brushes.Gray,
                        new Point(keyX, (startY + 4 * margin))
                        );
                    e.Graphics.DrawString(
                        $"{this.view.SelectedPatient.Id}",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Bold),
                        Brushes.Black,
                        new Point(valueX, (startY + 4 * margin))
                        );
                    e.Graphics.DrawString(
                        "Emri",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Regular),
                        Brushes.Gray,
                        new Point(keyX, (startY + 5 * margin))
                        );
                    e.Graphics.DrawString(
                        $"{this.view.SelectedPatient.FirstName}",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Bold),
                        Brushes.Black,
                        new Point(valueX, (startY + 5 * margin))
                        );
                    e.Graphics.DrawString(
                        "Mbiemri",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Regular),
                        Brushes.Gray,
                        new Point(keyX, (startY + 6 * margin))
                        );
                    e.Graphics.DrawString(
                        $"{this.view.SelectedPatient.LastName}",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Bold),
                        Brushes.Black,
                        new Point(valueX, (startY + 6 * margin))
                        );
                    e.Graphics.DrawString(
                        "Gjinia",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Regular),
                        Brushes.Gray,
                        new Point(keyX, (startY + 7 * margin))
                        );
                    e.Graphics.DrawString(
                        $"{this.view.SelectedPatient.Gender}",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Bold),
                        Brushes.Black,
                        new Point(valueX, (startY + 7 * margin))
                        );
                    e.Graphics.DrawString(
                        "Datëlindja",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Regular),
                        Brushes.Gray,
                        new Point(keyX, (startY + 8 * margin))
                        );
                    e.Graphics.DrawString(
                        $"{this.view.SelectedPatient.DateOfBirth.ToString(DateTimeFormats.SQ_DATE)}",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Bold),
                        Brushes.Black,
                        new Point(valueX, (startY + 8 * margin))
                        );
                    e.Graphics.DrawString(
                        "Celular",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Regular),
                        Brushes.Gray,
                        new Point(keyX, (startY + 9 * margin))
                        );
                    e.Graphics.DrawString(
                        $"{this.view.SelectedPatient.PhoneNumber}",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Bold),
                        Brushes.Black,
                        new Point(valueX, (startY + 9 * margin))
                        );
                    e.Graphics.DrawString(
                        "Adresa",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Regular),
                        Brushes.Gray,
                        new Point(keyX, (startY + 10 * margin))
                        );
                    e.Graphics.DrawString(
                        $"{this.view.SelectedPatient.Address}",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Bold),
                        Brushes.Black,
                        new Point(valueX, (startY + 10 * margin))
                        );
                    e.Graphics.DrawString(
                        "Alergjitë e pacientit",
                        new Font(Fonts.primary, headerFontSize, FontStyle.Bold),
                        Brushes.DarkBlue,
                        new Point(keyX, (startY + (int)(12.5 * margin)))
                        );
                    e.Graphics.DrawString(
                        "Medikamente alergenë",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Regular),
                        Brushes.Gray,
                        new Point(keyX, (startY + 14 * margin))
                        );
                    e.Graphics.DrawString(
                        $"{(allergensResult.Length > 0 ? allergensResult : "-")}",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Bold),
                        Brushes.Black,
                        new Point(valueX, (startY + 14 * margin))
                        );
                    e.Graphics.DrawString(
                        "Dokumentacioni dhe historiku i pacientit",
                        new Font(Fonts.primary, headerFontSize, FontStyle.Bold),
                        Brushes.DarkBlue,
                        new Point(keyX, (startY + (int)(16.5 * margin)))
                        );
                }

                int nextY = this.pageCount == 1 ? 18 : 0;

                for (int i = this.counter; i < docs.Count; i += 1)
                {
                    Models.ChartDocument item = docs[i];

                    e.Graphics.DrawString(
                        "Lloji i dokumentit",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Regular),
                        Brushes.Gray,
                        new Point(keyX, (startY + nextY * margin))
                        );
                    e.Graphics.DrawString(
                        $"{item.Type}",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Bold),
                        Brushes.Black,
                        new Point(valueX, (startY + nextY * margin))
                        );
                    e.Graphics.DrawString(
                        "Emri",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Regular),
                        Brushes.Gray,
                        new Point(keyX, (startY + (1 + nextY) * margin))
                        );
                    e.Graphics.DrawString(
                        $"{item.Name}",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Bold),
                        Brushes.Black,
                        new Point(valueX, (startY + (1 + nextY) * margin))
                        );
                    e.Graphics.DrawString(
                        "Data e krijimit",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Regular),
                        Brushes.Gray,
                        new Point(keyX, (startY + (2 + nextY) * margin))
                        );
                    e.Graphics.DrawString(
                        $"{item.DateCreated.ToString(DateTimeFormats.SQ_DATE_TIME)}",
                        new Font(Fonts.primary, itemFontSize, FontStyle.Bold),
                        Brushes.Black,
                        new Point(valueX, (startY + (2 + nextY) * margin))
                        );

                    if (this.pageCount == 1 && this.counter == 3)
                    {
                        e.HasMorePages  = true;
                        this.pageCount += 1;
                        nextY           = 0;

                        break;
                    }
                    else if (this.counter == (3 + (this.pageCount - 1) * this.pageSize))
                    {
                        e.HasMorePages  = true;
                        this.pageCount += 1;
                        nextY           = 0;

                        break;
                    }
                    else
                    {
                        nextY += 4;
                    }

                    this.counter += 1;
                }

                this.counter   = 0;
                Cursor.Current = Cursors.Arrow;
            } catch (Exception ex) {
                string caption = "Problem në lexim";
                MessageBox.Show(ex.Message, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }