/// <summary>
        ///
        /// </summary>
        /// <param name="updateAttribute"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public TestTemplateAttributeDto UpdateAttribute(TestResultDto updateAttribute, UserDto user)
        {
            MapperConfig.ConfigAutoMapper();

            if ((updateAttribute != null) && (user != null))
            {
                PatientTestResultHelper Resulthelp = new PatientTestResultHelper();

                // Attribute set according to the visit ID
                IList <TestResultDto> ResultAttributes = Resulthelp.GetTestResults(updateAttribute.VisitID);

                //updateAttribute.AttrID = Resulthelp.GetResultByVisitID(updateAttribute.VisitID).AttrID;

                updateAttribute.ModifiedDate = DateTime.Now;

                updateAttribute.VisitID = Resulthelp.GetResultByID(updateAttribute.ID).VisitID;

                updateAttribute.AttrID = Resulthelp.GetResultByID(updateAttribute.ID).AttrID;

                updateAttribute.CreatedBy = Resulthelp.GetResultByVisitID(updateAttribute.VisitID).CreatedBy;

                updateAttribute.CreatedDate = Resulthelp.GetResultByVisitID(updateAttribute.VisitID).CreatedDate;

                updateAttribute.ModifiedBy = user.Username;

                ResultRepo.Update(Mapper.Map <TestResult>(updateAttribute));
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Null Attribute ! /  Null User ");
            }

            return(null);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="attribute"></param>
        /// <returns></returns>
        ///
        public TestResultDto DeleteAttribute(TestResultDto attribute)
        {
            PatientTestResultHelper visitHelper = new PatientTestResultHelper();

            MapperConfig.ConfigAutoMapper();

            if (attribute != null)
            {
                attribute.ModifiedDate = DateTime.Now;
                attribute.CreatedDate  = new DateTime(2017, 7, 6);
                attribute.CreatedBy    = "EMP01";
                attribute.ModifiedBy   = null;

                IList <TestResultDto> TestRes = visitHelper.GetTestResults(attribute.VisitID);

                TestResult Del = context.TestResults.SingleOrDefault(item => item.ID == attribute.ID);
                context.TestResults.Remove(Mapper.Map <TestResult>(Del));
                context.SaveChanges();


                return(null);
            }
            else
            {
                throw new NullReferenceException("null attrib");
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="Patient"></param>
        /// <returns></returns>
        ///
        public Patient Getresults(PatientDto Patient)
        {
            MapperConfig.ConfigAutoMapper();

            if (patient.GetPatient(Patient.ContactNo) != null)
            {
                int PatientID = patient.GetPatient(Patient.ContactNo).PatientId;

                int visitID = visitHelper.GetVisitByPatientID(PatientID).PatientVisitId;

                IList <TestResultDto> TestAttribute = helper.GetTestResults(visitID);

                System.Diagnostics.Debug.WriteLine("Result set Found !");

                System.Diagnostics.Debug.WriteLine(TestAttribute);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Patient Not Found !");
            }
            return(null);
        }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="printreport"></param>
        /// <returns></returns>
        public TestResultDto PrintReport(TestResultDto printreport)
        {
            MapperConfig.ConfigAutoMapper();



            if (printreport != null)
            {
                int patientid = visit.GetVisit(printreport.VisitID).PatientID;
                var patient   = base.context.Patients.AsNoTracking().FirstOrDefault(p => p.PatientId.Equals(patientid));

                String name    = patient.Name;
                int    age     = patient.Age;
                string sex     = patient.Gender;
                string address = patient.Address;
                string number  = patient.ContactNo;

                DateTime arrivedate = visit.GetVisit(printreport.VisitID).ArriveDate;
                DateTime ExpDelDate = visit.GetVisit(printreport.VisitID).ExpectedDeliveryDate;

                int TesTID       = test.GetTest(printreport.VisitID).TemplateID;
                var testTemplate = base.context.TestTemplates.FirstOrDefault(p => p.TestTemplateId.Equals(TesTID));


                string  templatename = testTemplate.TemplateName;
                int     temID        = testTemplate.TestTemplateId;
                decimal price        = testTemplate.Price;


                IList <TestResultDto>            results = resultSet.GetTestResults(printreport.VisitID);
                IList <TestTemplateAttributeDto> Attribs = VisitHelper.GetTestTemplateAttributes(temID);
                string path     = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments);
                string fileName = "" + path + "\\Report.docx";

                var doc = DocX.Create(fileName);

                doc.InsertParagraph(" __________________________________________________________________________________________________                                  ");
                doc.InsertParagraph("");
                doc.InsertParagraph("                      MEDICAL LAB REPORT MANAGEMENT SYSTEM  |  FINAL TEST REPORT ");
                doc.InsertParagraph("");
                doc.InsertParagraph(" __________________________________________________________________________________________________                                  ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("     Patient Name : " + name + "                                    Gender : " + sex + "                                             ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("     Patient Age : " + age + "                                                        Address:" + address + "   Payment : RS: " + price + "");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("     Contact Number : " + number + "                                    Test : " + templatename + "                                  ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph("");

                doc.InsertParagraph("     Arrived Date: " + arrivedate + "                      Deliver Date:" + ExpDelDate + "                                           ");
                doc.InsertParagraph("                                                                                                                                     ");
                doc.InsertParagraph(" __________________________________________________________________________________________________                                  ");

                doc.InsertParagraph("");
                doc.InsertParagraph("     Patients Results ");
                doc.InsertParagraph("");
                doc.InsertParagraph("");

                int seq = 1;
                foreach (var x in results)
                {
                    doc.InsertParagraph("     " + seq + "           Value: " + x.Value + "              Status : " + x.Status + "");
                    doc.InsertParagraph("");
                    seq++;

                    if (seq > Attribs.Count)
                    {
                        break;
                    }
                }

                doc.InsertParagraph("");
                doc.InsertParagraph("");
                doc.InsertParagraph("    Reffer below Information. ");
                doc.InsertParagraph("");
                doc.InsertParagraph("");

                int NextSeq = 1;
                foreach (var x in Attribs)
                {
                    doc.InsertParagraph("     " + NextSeq + " . " + x.Attribute + " --> " + x.PrefferedLimit + "");
                    doc.InsertParagraph("");
                    doc.InsertParagraph("");
                    NextSeq++;
                }

                doc.Save();

                /*Open as html format*/
                SautinSoft.RtfToHtml z = new SautinSoft.RtfToHtml();
                string docxFile        = Path.GetFullPath(fileName);
                string htmlFile        = Path.ChangeExtension(docxFile, ".html");

                z.OpenDocx(docxFile);
                z.ToHtml(htmlFile);
                System.Diagnostics.Process.Start(htmlFile);

                return(null);
            }

            else
            {
                throw new ArgumentNullException("Provided information is not valid.");
            }
        }