Пример #1
0
        public ActionResult GetReport(long id, string lang, string t)
        {
            string       token   = t.Replace("xMl3Jkaaswss", "+").Replace("Por21Ld105sE78", "/").Replace("Ml32XXASsd1dd", "=");
            SessionModel session = DB.SessionsDAO.ReadSessionByToken(token);

            if (session == null)
            {
                return(throwValidateError());
            }

            EmployeeModel employee = DB.EmployeesDAO.ReadEmployeeByUserId(session.IdUser, lang);

            if (employee == null || employee.IdEmployee == null || employee.IdPosition != (long)PositionTypeEnum.Doctor)
            {
                return(throwValidateError());
            }

            ReportGenerator rg = new ReportGenerator();

            StudyModel study = getStudyModel(id, lang);

            if (study == null)
            {
                return(throwBadRequest());
            }

            byte[] report = rg.createPdf(study, lang);
            return(File(report, "application/pdf"));
        }
Пример #2
0
        private StudyModel getStudyModel(long id, string lang)
        {
            StudyModel study = DB.StudiesDAO.ReadStudyById(id, lang);

            study.OrderedTest = DB.TestsDAO.ReadFullOrderedTestByStudyId((long)study.IdStudy, lang);

            if (study.IdStatus != (long)StatusTypeEnum.Ordered)
            {
                if (study.IdStatus != (long)StatusTypeEnum.TakenSample)
                {
                    EmployeeModel lab = DB.EmployeesDAO.ReadEmployeeByStudyId((long)study.IdStudy, lang);
                    if (lab != null)
                    {
                        study.IdLab = lab.IdEmployee;
                        study.Lab   = lab.FirstName + " " + lab.Surname;
                    }
                    if (study.IdStatus != (long)StatusTypeEnum.InProgress)
                    {
                        try
                        {
                            study.Result = DB.ResultsDAO.ReadResultByStudyId((long)study.IdStudy);
                            EmployeeModel resultLab = DB.EmployeesDAO.ReadEmployeeById((long)study.Result.IdEmployee, lang);
                            study.Result.EmployeeName = resultLab.FirstName + " " + resultLab.Surname;
                        }
                        catch (Exception)
                        {
                            return(study);
                        }
                    }
                }
            }
            return(study);
        }
Пример #3
0
        public ActionResult StartStudy(StudyModel study)
        {
            ActionResult wrongAuthorization = checkEmployeeAutorization((long)PositionTypeEnum.Lab);

            if (wrongAuthorization != null)
            {
                return(wrongAuthorization);
            }

            if (study != null)
            {
                try
                {
                    EmployeeModel employee = getEmployeeByUserId();
                    study.IdDoctor    = (long)employee.IdEmployee;
                    study.IdStatus    = (long)StatusTypeEnum.InProgress;
                    study.DateOfStudy = DateTime.Now;
                    DB.StudiesDAO.UpdateStudy(study);
                    return(Json(study.IdStudy));
                }
                catch (Exception)
                {
                    return(throwBadRequest());
                }
            }
            return(throwValidateError());
        }
Пример #4
0
        private long repeatStudy(StudyModel study, EmployeeModel employee)
        {
            study.IdRepeatEmployee = (long)employee.IdEmployee;
            DB.StudiesDAO.SetReorederDataOfStudy(study);
            study.PreviousId = study.IdStudy;

            long idStudy = (long)DB.StudiesDAO.InsertStudy(study);

            foreach (TestModel test in study.OrderedTest)
            {
                DB.TestsDAO.InsertOrderedTest(idStudy, test.IdTest);
            }

            if ((bool)study.NeedNewSample)
            {
                DB.StudiesDAO.ChangeStudyStatus(idStudy, (long)StatusTypeEnum.Ordered);
            }
            else
            {
                study.Sample.IdStudy = idStudy;

                long idSample = (long)DB.SamplesDAO.InsertSample(study.Sample);
                study.Sample.IdSample = idSample;
                DB.SamplesDAO.UpdateSample(study.Sample);

                DB.StudiesDAO.ChangeStudyStatus(idStudy, (long)StatusTypeEnum.TakenSample);
            }
            return(idStudy);
        }
        public IActionResult Study([FromBody] StudyModel model)
        {
            StudyDTO dto = Mapping.Mapper.Map <StudyModel, StudyDTO>(model);

            _curriculumService.AddOrUpdateSectionBlock <StudyDTO>(dto, model.FormMode, SectionNames.Study);

            return(Ok(new { id = model.StudyId }));
        }
Пример #6
0
        public long?InsertStudy(StudyModel study)
        {
            string query = $@"
                insert into Studies(IdOrder, IdProfile, IdStatus, Actual, PreviousId) 
                    output INSERTED.IdStudy
                    values({study.IdOrder}, {study.IdProfile}, {(long)StatusTypeEnum.Ordered}, 1, {BaseDAO.SetNullableLong(study.PreviousId)});
            ";

            return(BaseDAO.InsertOrUpdate(query, true));
        }
Пример #7
0
        public ActionResult GetStudy()
        {
            try
            {
                if (pagemanager.IsPageValid((int)Session["BOGroupId"], 7))
                {
                    return(View("PageError"));
                }
                else
                {
                    int UserID = (int)Session["AccessUserId"];
                    var user   = usermanager.GetUserByID(UserID);

                    var studyperm = studymanager.GetStudiesByUserId(UserID);
                    GrantDenyStudyModel.studymodelDenied  = new List <StudyModel>();
                    GrantDenyStudyModel.studymodelGranted = new List <StudyModel>();
                    foreach (var item in studyperm)
                    {
                        StudyModel studymodel = new StudyModel();
                        Study      std        = new Study();
                        std = studymanager.GetStudyByStudyId(item.StudyID);
                        studymodel.StudyID   = std.StudyID;
                        studymodel.StudyName = std.StudyName;
                        studymodel.StudyCode = std.StudyCode;
                        Sponsor spnr = new Sponsor();
                        spnr = sponsormanager.GetSponsorById(item.SponsorID.ToString());
                        studymodel.SponsorName = spnr.SponsorName;
                        if (item.Status == true)
                        {
                            studymodel.Status   = item.Status;
                            studymodel.Selected = false;
                            GrantDenyStudyModel.studymodelGranted.Add(studymodel);
                        }
                        if (item.Status == false)
                        {
                            studymodel.Status   = item.Status;
                            studymodel.Selected = false;
                            GrantDenyStudyModel.studymodelDenied.Add(studymodel);
                        }
                    }

                    return(PartialView("_StudyList", GrantDenyStudyModel));
                }
            }
            catch (NullReferenceException ex)
            {
                return(Redirect(FormsAuthentication.LoginUrl));
            }
            catch (Exception e)
            {
                ViewBag.message = e.Message;
                return(View("Error"));
            }
        }
Пример #8
0
        public void SetReorederDataOfStudy(StudyModel study)
        {
            string query = $@"
                update Studies set IdRepeatEmployee={study.IdRepeatEmployee}, IdStatus={(long)StatusTypeEnum.ReOrdered},
                ReasonForRepeat={BaseDAO.SetString(study.ReasonForRepeat)}, Actual={BaseDAO.SetBool(false)}, 
                DateOfEnd={BaseDAO.SetDate(DateTime.Now)}
                where IdStudy={study.IdStudy}
            ";

            BaseDAO.InsertOrUpdate(query, false);
        }
Пример #9
0
        public void UpdateStudy(StudyModel study)
        {
            string query = $@"
                update Studies set IdEmployee={study.IdDoctor}, IdStatus={study.IdStatus}, DateOfStudy={BaseDAO.SetDate(study.DateOfStudy)},
                ReasonForRepeat={BaseDAO.SetString(study.ReasonForRepeat)}, Actual={BaseDAO.SetBool(study.Actual)}, 
                PreviousId={BaseDAO.SetNullableLong(study.PreviousId)}, DateOfEnd={BaseDAO.SetDate(study.DateOfEnd)},
                IdRepeatEmployee={BaseDAO.SetNullableLong(study.IdRepeatEmployee)}
                where IdStudy={study.IdStudy}
            ";

            BaseDAO.InsertOrUpdate(query, false);
        }
        public ActionResult Index()
        {
            List <PatientModel> list     = DB.PatientsDAO.ReadPatientsList();
            PatientModel        Janeczek = DB.PatientsDAO.ReadPatientById(1L);

            DictionaryModel        dic     = DB.DictionaryDAO.ReadDictionaryById(Enums.DictionaryTypesEnum.Positions, 1L, "pl");
            List <DictionaryModel> dicList = DB.DictionaryDAO.ReadDictionaryListByType(Enums.DictionaryTypesEnum.Positions, "pl");

            DictionaryModel        dic2     = DB.DictionaryDAO.ReadDictionaryById(Enums.DictionaryTypesEnum.Ward, 1L, "en");
            List <DictionaryModel> dicList2 = DB.DictionaryDAO.ReadDictionaryListByType(Enums.DictionaryTypesEnum.Ward, "en");

            DictionaryModel        dic3     = DB.DictionaryDAO.ReadDictionaryById(Enums.DictionaryTypesEnum.Status, 1L, "pl");
            List <DictionaryModel> dicList3 = DB.DictionaryDAO.ReadDictionaryListByType(Enums.DictionaryTypesEnum.Status, "pl");

            DictionaryModel        dic4     = DB.DictionaryDAO.ReadDictionaryById(Enums.DictionaryTypesEnum.Priorities, 1L, "en");
            List <DictionaryModel> dicList4 = DB.DictionaryDAO.ReadDictionaryListByType(Enums.DictionaryTypesEnum.Priorities, "en");

            List <EmployeeModel> empList = DB.EmployeesDAO.ReadEmployeesList();
            EmployeeModel        emp     = DB.EmployeesDAO.ReadEmployeeById(1L);

            List <UserModel> userList = DB.UserDAO.ReadUsersList();
            UserModel        user     = DB.UserDAO.ReadUserById(2L);

            List <OrderModel> orderList = DB.OrderDAO.ReadOrdersList();
            OrderModel        order     = DB.OrderDAO.ReadOrderById(1L);

            List <ProfileModel> profilesList = DB.ProfilesDAO.ReadProfilesList("pl");
            ProfileModel        profile      = DB.ProfilesDAO.ReadProfileById(1, "pl");

            List <StudyModel> studiesList = DB.StudiesDAO.ReadStudiesList();
            StudyModel        study       = DB.StudiesDAO.ReadStudyById(1L);

            List <SampleModel> samplesList = DB.SamplesDAO.ReadSamplesList();
            SampleModel        sample      = DB.SamplesDAO.ReadSampleById(1L);

            List <TestModel> testsList = DB.TestsDAO.ReadTestsList("pl");
            TestModel        test      = DB.TestsDAO.ReadTestById(1L, "pl");

            List <VerificationModel> verifList          = DB.VerificationsDAO.ReadVerificationsList();
            VerificationModel        verificationModel  = DB.VerificationsDAO.ReadVerificationById(1L);
            VerificationModel        verification2Model = DB.VerificationsDAO.ReadVerificationByResultId(1L);

            List <ResultModel> resList  = DB.ResultsDAO.ReadResultsList();
            ResultModel        resModel = DB.ResultsDAO.ReadResultById(1L);

            List <ResultUnitModel> resUnitList   = DB.ResultUnitsDAO.ReadResultUnitsList();
            ResultUnitModel        resUnitModel  = DB.ResultUnitsDAO.ReadResultUnitModelById(1L);
            List <ResultUnitModel> resUnit2Model = DB.ResultUnitsDAO.ReadResultUnitModelByResultId(1L);

            return(View());
            //return Json(Janeczek, JsonRequestBehavior.AllowGet);
        }
Пример #11
0
        public ActionResult GetStudy(long id)
        {
            ActionResult wrongAuthorization = checkEmployeeAutorization((long)PositionTypeEnum.Lab);

            if (wrongAuthorization != null)
            {
                return(wrongAuthorization);
            }

            StudyModel study = DB.StudiesDAO.ReadStudyById(id, Lang);

            if (study.IdStatus == (long)StatusTypeEnum.Ordered || study.IdStatus == (long)StatusTypeEnum.Ended)
            {
                return(null);
            }

            if (study.IdStatus != (long)StatusTypeEnum.Ordered)
            {
                study.Sample = DB.SamplesDAO.ReadSampleByStudyId((long)study.IdStudy);

                study.OrderedTest = DB.TestsDAO.ReadFullOrderedTestByStudyId((long)study.IdStudy, Lang);

                if (study.IdStatus != (long)StatusTypeEnum.TakenSample)
                {
                    EmployeeModel lab = DB.EmployeesDAO.ReadEmployeeByStudyId((long)study.IdStudy, Lang);
                    if (lab != null)
                    {
                        study.IdLab = lab.IdEmployee;
                        study.Lab   = lab.FirstName + " " + lab.Surname;
                    }
                    if (study.IdStatus != (long)StatusTypeEnum.InProgress)
                    {
                        try
                        {
                            study.Result = DB.ResultsDAO.ReadResultByStudyId((long)study.IdStudy);
                            EmployeeModel resultLab = DB.EmployeesDAO.ReadEmployeeById((long)study.Result.IdEmployee, Lang);
                            study.Result.EmployeeName = resultLab.FirstName + " " + resultLab.Surname;
                            study.Result.Verification = new VerificationModel();
                        }
                        catch (Exception)
                        {
                            return(new CustomJsonResult {
                                Data = new { data = study }
                            });
                        }
                    }
                }
            }
            return(new CustomJsonResult {
                Data = new { data = study }
            });
        }
Пример #12
0
        public ActionResult GetStudy(long id)
        {
            ActionResult wrongAuthorization = checkEmployeeAutorization((long)PositionTypeEnum.Nurse);

            if (wrongAuthorization != null)
            {
                return(wrongAuthorization);
            }

            StudyModel study = GetStudyById(id);

            return(new CustomJsonResult {
                Data = new { data = study }
            });
        }
Пример #13
0
        private StudyModel GetStudyById(long id)
        {
            StudyModel study = DB.StudiesDAO.ReadStudyById(id, Lang);

            if (study.IdStatus != (long)StatusTypeEnum.Ordered && study.IdStatus != (long)StatusTypeEnum.TakenSample)
            {
                return(null);
            }

            if (study.IdStatus == (long)StatusTypeEnum.TakenSample)
            {
                study.Sample = DB.SamplesDAO.ReadSampleByStudyId((long)study.IdStudy);
            }

            return(study);
        }
Пример #14
0
        public ActionResult AddVerify(StudyModel study)
        {
            ActionResult wrongAuthorization = checkEmployeeAutorization((long)PositionTypeEnum.Lab);

            if (wrongAuthorization != null)
            {
                return(wrongAuthorization);
            }

            if (study != null)
            {
                try
                {
                    EmployeeModel employee = getEmployeeByUserId();
                    study.Result.Verification.IdEmployee = (long)employee.IdEmployee;
                    study.Result.Verification.IdResult   = (long)study.Result.IdResult;
                    if (study.Result.Verification.Positive)
                    {
                        DB.VerificationsDAO.InsertVerify(study.Result.Verification);

                        DB.StudiesDAO.ChangeStudyStatus((long)study.IdStudy, (long)StatusTypeEnum.Verified);

                        List <StudyModel> otherStudies = DB.StudiesDAO.ReadNotVerifiedStudiesListByOrderId((long)study.IdOrder);
                        if (otherStudies.Count == 0)
                        {
                            DB.OrderDAO.ChangeOrderStatus((long)study.IdOrder, (long)StatusTypeEnum.Ended);
                        }

                        return(Json(study));
                    }
                    else
                    {
                        study.Result.Verification.Description = "-";
                        DB.VerificationsDAO.InsertVerify(study.Result.Verification);

                        long idStudy = repeatStudy(study, employee);

                        return(Json(idStudy));
                    }
                }
                catch (Exception)
                {
                    return(throwBadRequest());
                }
            }
            return(throwValidateError());
        }
Пример #15
0
        public ActionResult GetStudy(long id)
        {
            ActionResult wrongAuthorization = checkEmployeeAutorization((long)PositionTypeEnum.Doctor);

            if (wrongAuthorization != null)
            {
                return(wrongAuthorization);
            }

            StudyModel study = getStudyModel(id, Lang);

            if (study == null)
            {
                return(throwBadRequest());
            }
            return(new CustomJsonResult {
                Data = new { data = study }
            });
        }
Пример #16
0
        public ActionResult AddResult(StudyModel study)
        {
            ActionResult wrongAuthorization = checkEmployeeAutorization((long)PositionTypeEnum.Lab);

            if (wrongAuthorization != null)
            {
                return(wrongAuthorization);
            }

            if (study != null)
            {
                try
                {
                    EmployeeModel employee = getEmployeeByUserId();
                    study.Result.IdEmployee = (long)employee.IdEmployee;
                    study.Result.IdStudy    = (long)study.IdStudy;

                    long idResult = (long)DB.ResultsDAO.InsertResult(study.Result);
                    foreach (TestModel test in study.OrderedTest)
                    {
                        ResultUnitModel resultUnit = new ResultUnitModel();
                        resultUnit.IdResult      = idResult;
                        resultUnit.IdOrderedTest = (long)test.IdOrderedTest;
                        NumberFormatInfo provider = new NumberFormatInfo();
                        provider.NumberDecimalSeparator = ".";
                        resultUnit.Value = Convert.ToDouble(test.Result, provider);

                        DB.ResultUnitsDAO.InsertResultUnit(resultUnit);
                    }

                    DB.StudiesDAO.ChangeStudyStatus((long)study.IdStudy, (long)StatusTypeEnum.ToVerify);

                    return(Json(study.IdStudy));
                }
                catch (Exception)
                {
                    return(throwBadRequest());
                }
            }
            return(throwValidateError());
        }
Пример #17
0
        public ActionResult RegisterSample(StudyModel study)
        {
            ActionResult wrongAuthorization = checkEmployeeAutorization((long)PositionTypeEnum.Nurse);

            if (wrongAuthorization != null)
            {
                return(wrongAuthorization);
            }

            if (study != null)
            {
                try
                {
                    EmployeeModel employee = getEmployeeByUserId();
                    SampleModel   sample   = new SampleModel();
                    sample.IdEmployee       = (long)employee.IdEmployee;
                    sample.IdStudy          = (long)study.IdStudy;
                    sample.DateOfCollection = DateTime.Now;

                    long idSample = (long)DB.SamplesDAO.InsertSample(sample);
                    sample.Code     = study.IdOrder + "-" + study.IdStudy + "-" + idSample;
                    sample.IdSample = idSample;
                    DB.SamplesDAO.UpdateSample(sample);

                    DB.OrderDAO.ChangeOrderStatus(study.IdOrder, (long)StatusTypeEnum.InProgress);
                    DB.StudiesDAO.ChangeStudyStatus((long)study.IdStudy, (long)StatusTypeEnum.TakenSample);

                    study = GetStudyById((long)study.IdStudy);
                    return(new CustomJsonResult {
                        Data = new { data = study }
                    });
                }
                catch (Exception)
                {
                    return(throwBadRequest());
                }
            }
            return(throwValidateError());
        }
Пример #18
0
        public ActionResult GetReport(long id, string lang, string t)
        {
            //ActionResult wrongAuthorization = checkPatient();
            //if (wrongAuthorization != null)
            //    return wrongAuthorization;

            //PatientModel patient = getPatientByUserId();

            string       token   = t.Replace("xMl3Jkaaswss", "+").Replace("Por21Ld105sE78", "/").Replace("Ml32XXASsd1dd", "=");
            SessionModel session = DB.SessionsDAO.ReadSessionByToken(token);

            if (session == null)
            {
                return(throwValidateError());
            }

            PatientModel patient = DB.PatientsDAO.ReadPatientByUserId(session.IdUser);

            if (patient == null || patient.IdPatient == null)
            {
                return(throwValidateError());
            }

            ReportGenerator rg = new ReportGenerator();

            StudyModel study = getStudyModel(id, lang);

            if (study == null)
            {
                return(throwBadRequest());
            }
            if (patient.IdPatient != study.IdPatient)
            {
                return(throwValidateError());
            }

            byte[] report = rg.createPdf(study, lang);
            return(File(report, "application/pdf"));
        }
Пример #19
0
        public ActionResult RepeatStudy(StudyModel study)
        {
            ActionResult wrongAuthorization = checkEmployeeAutorization((long)PositionTypeEnum.Lab);

            if (wrongAuthorization != null)
            {
                return(wrongAuthorization);
            }

            if (study != null)
            {
                try
                {
                    EmployeeModel employee    = getEmployeeByUserId();
                    long          oldStatusId = study.IdStatus;

                    long idStudy = repeatStudy(study, employee);

                    if (oldStatusId.Equals((long)StatusTypeEnum.ToVerify))
                    {
                        study.Result.Verification.Positive   = false;
                        study.Result.Verification.IdEmployee = (long)employee.IdEmployee;
                        study.Result.Verification.IdResult   = (long)study.Result.IdResult;

                        study.Result.Verification.Description = "-";
                        DB.VerificationsDAO.InsertVerify(study.Result.Verification);
                    }

                    return(Json(idStudy));
                }
                catch (Exception)
                {
                    return(throwBadRequest());
                }
            }
            return(throwValidateError());
        }
Пример #20
0
        public ActionResult GetStudy(long id)
        {
            ActionResult wrongAuthorization = checkPatient();

            if (wrongAuthorization != null)
            {
                return(wrongAuthorization);
            }

            PatientModel patient = getPatientByUserId();
            StudyModel   study   = getStudyModel(id, Lang);

            if (study == null)
            {
                return(throwBadRequest());
            }
            if (patient.IdPatient != study.IdPatient)
            {
                return(throwValidateError());
            }
            return(new CustomJsonResult {
                Data = new { data = study }
            });
        }
Пример #21
0
 // PUT: api/Study/5
 public void Put(int id, StudyModel model)
 {
 }
Пример #22
0
        public void BuildCondition(ConditionModelTemplate template, ConditionModel model, StudyModel studyModel)
        {
            model.Method = template.Method;

            switch (template.Position)
            {
            case ConditionPosition.Left:
                model.PrimaryTaskContainer = PrimaryTaskContainerLeft;
                break;

            case ConditionPosition.Right:
                model.PrimaryTaskContainer = PrimaryTaskContainerRight;
                break;

            case ConditionPosition.Center:
                model.PrimaryTaskContainer = PrimaryTaskContainerCenter;
                break;
            }

            switch (template.PrimaryTask)
            {
            case PrimaryTaskType.High:
                model.PrimaryTask       = PrimaryTaskHigh;
                model.ConditionLocation = "count down with 17.";
                break;

            case PrimaryTaskType.Mid:
                model.PrimaryTask       = PrimaryTaskMid;
                model.ConditionLocation = "icon search.";
                break;

            case PrimaryTaskType.Low:
                model.PrimaryTask       = PrimaryTaskLow;
                model.ConditionLocation = "count down with 2.";
                break;
            }

            switch (template.SecondaryTask)
            {
            case SecondaryTaskType.Email:
                model.SecondayTask       = SecondaryTaskModelEmail;
                model.AllQuestionIndices = QuestionsEmailAll;
                break;

            case SecondaryTaskType.Break:
                model.SecondayTask       = SecondaryTaskModelBreak;
                model.AllQuestionIndices = QuestionsBreakAll;
                break;

            case SecondaryTaskType.Ideation:
                model.SecondayTask       = SecondaryTaskModelIdeation;
                model.AllQuestionIndices = QuestionsIdeationAll;
                break;
            }
        }
Пример #23
0
        public StudyModel Get(int id)
        {
            using (var srepo = _factory.GetStudyRepo())
                using (var strepo = _factory.GetStageRepo())
                    using (var usrepo = _factory.GetUserStudyRelationRepo())
                        using (var urepo = _factory.GetUserRepo())
                            using (var rrepo = _factory.GetStudyRoleRepo())
                            {
                                var study = new StudyModel();

                                // Add basic study information
                                var studyDto = srepo.Read(id);
                                study.Id          = studyDto.Id;
                                study.Name        = studyDto.Name;
                                study.Description = studyDto.Description;

                                // Add stages
                                var stageDtos = strepo.GetAll().Where(dto => dto.Study_Id == id);
                                study.Stages = new List <StageOverviewModel>();
                                foreach (var dto in stageDtos)
                                {
                                    study.Stages.Add(new StageOverviewModel()
                                    {
                                        Id   = dto.Id,
                                        Name = dto.Name
                                    });
                                }

                                // Add persons
                                var relationDtos            = usrepo.GetAll().Where(us => us.Study_Id == id);
                                var userStudyRoleDictionary = new Dictionary <int, List <StudyRole> >();
                                foreach (var dto in relationDtos)
                                {
                                    if (userStudyRoleDictionary.ContainsKey(dto.Id))
                                    {
                                        userStudyRoleDictionary[id].Add(new StudyRole()
                                        {
                                            Id   = dto.StudyRole_Id,
                                            Name = rrepo.Read(dto.StudyRole_Id).Name
                                        });
                                    }
                                    else
                                    {
                                        userStudyRoleDictionary.Add(dto.Id, new List <StudyRole>()
                                        {
                                            new StudyRole()
                                            {
                                                Id   = dto.StudyRole_Id,
                                                Name = rrepo.Read(dto.StudyRole_Id).Name
                                            }
                                        });
                                    }
                                }
                                study.Persons = new Dictionary <UserModel, List <StudyRole> >();
                                foreach (var userPair in userStudyRoleDictionary)
                                {
                                    // TODO build dictionary in one iteration
                                    var userDto = urepo.Read(userPair.Key);
                                    study.Persons.Add(new UserModel()
                                    {
                                        Id        = userDto.Id,
                                        FirstName = userDto.FirstName,
                                        LastName  = userDto.LastName,
                                        Metadata  = userDto.Metadata
                                    }, userPair.Value);
                                }

                                return(study);
                            }
        }
Пример #24
0
        public byte[] createPdf(StudyModel study, string Lang)
        {
            MemoryStream stream = new MemoryStream();
            PdfWriter    writer = new PdfWriter(stream);

            var pdf      = new PdfDocument(writer);
            var document = new Document(pdf);
            var font     = PdfFontFactory.CreateFont(FontConstants.HELVETICA, "cp1250", true);
            //var font2 = PdfFontFactory.CreateFont(FontConstants.TIMES_ROMAN);
            var bold = PdfFontFactory.CreateFont(FontConstants.HELVETICA_BOLD, "cp1250", true);

            //PdfFontFactory.
            //doc.Add(new Paragraph("Tekst do wyświetlenia", myFont));

            document.Add(new Paragraph(Lang == "pl" ? "WYNIKI BADAŃ LABORATORYJNYCH" : "LABORATORY RESULTS")
                         .SetTextAlignment(TextAlignment.CENTER)
                         .SetFontSize(14)
                         .SetMarginBottom(20)
                         .SetFont(font));
            document.SetFont(bold).Add(new Paragraph((Lang == "pl" ? "Pacjent: " : "Patient: ") + study.Patient)).SetBottomMargin(10);

            document.SetFont(font).Add(new Paragraph((Lang == "pl" ? "Id zlecenia: " : "Id order: ") + study.IdOrder));
            document.Add(new Paragraph((Lang == "pl" ? "Data zlecenia: " : "Date of order: ") + study.DateOfOrder));
            document.Add(new Paragraph((Lang == "pl" ? "Lekarz: " : "Doctor: ") + study.Doctor)).SetFont(font).SetBottomMargin(10);


            document.Add(new Paragraph((Lang == "pl" ? "Id badania: " : "Id study: ") + study.IdStudy)).SetFont(font);
            document.Add(new Paragraph((Lang == "pl" ? "Typ badania: " : "Type of study: ") + study.Profile)).SetFont(font);

            var table = new Table(new float[] { 13, 3, 3, 3, 3 });

            table.SetWidth(UnitValue.CreatePercentValue(100));
            table.AddHeaderCell(new Cell().Add(new Paragraph("Test"))).SetFont(bold);
            table.AddHeaderCell(new Cell().Add(new Paragraph((Lang == "pl" ? "Wynik: " : "Result: ")))).SetFont(bold);
            table.AddHeaderCell(new Cell().Add(new Paragraph((Lang == "pl" ? "Jednostka: " : "Unit: ")))).SetFont(bold);
            table.AddHeaderCell(new Cell().Add(new Paragraph((Lang == "pl" ? "Wskaźnik: " : "Indicator: ")))).SetFont(bold);
            table.AddHeaderCell(new Cell().Add(new Paragraph((Lang == "pl" ? "Norma: " : "Norm: ")))).SetFont(bold);


            foreach (TestModel test in study.OrderedTest)
            {
                table.AddCell(new Cell().Add(new Paragraph(test.Name))).SetFont(font);
                table.AddCell(new Cell().Add(new Paragraph(test.Result))).SetFont(font);
                table.AddCell(new Cell().Add(new Paragraph(test.Unit))).SetFont(font);

                NumberFormatInfo provider = new NumberFormatInfo();
                provider.NumberDecimalSeparator = ".";

                if (study.PatientSex == "M")
                {
                    if (Convert.ToDouble(test.Result, provider) < test.NormMinM)
                    {
                        table.AddCell(new Cell().Add(new Paragraph("(v) " + (Lang == "pl" ? "Za niski" : "Too low")))).SetFont(font).SetTextAlignment(TextAlignment.CENTER);
                    }
                    else if (Convert.ToDouble(test.Result, provider) > test.NormMaxM)
                    {
                        table.AddCell(new Cell().Add(new Paragraph("(^) " + (Lang == "pl" ? "Za wysoki" : "Too high")))).SetFont(font).SetTextAlignment(TextAlignment.CENTER);
                    }
                    else
                    {
                        table.AddCell(new Cell().Add(new Paragraph("W normie"))).SetFont(font).SetTextAlignment(TextAlignment.CENTER);
                    }
                }
                else
                {
                    if (Convert.ToDouble(test.Result, provider) < test.NormMinF)
                    {
                        table.AddCell(new Cell().Add(new Paragraph("(v) " + (Lang == "pl" ? "Za niski" : "Too low")))).SetFont(font).SetTextAlignment(TextAlignment.CENTER);
                    }
                    else if (Convert.ToDouble(test.Result, provider) > test.NormMaxF)
                    {
                        table.AddCell(new Cell().Add(new Paragraph("(^) " + (Lang == "pl" ? "Za wysoki" : "Too high")))).SetFont(font).SetTextAlignment(TextAlignment.CENTER);
                    }
                    else
                    {
                        table.AddCell(new Cell().Add(new Paragraph((Lang == "pl" ? "W normie" : "Normal")))).SetFont(font).SetTextAlignment(TextAlignment.CENTER);
                    }
                }

                if (study.PatientSex == "M")
                {
                    if (test.NormMinM == test.NormMaxM && test.NormMinM == 0)
                    {
                        table.AddCell(new Cell().Add(new Paragraph("0"))).SetFont(font);
                    }
                    else
                    {
                        table.AddCell(new Cell().Add(new Paragraph(test.NormMinM + "-" + test.NormMaxM))).SetFont(font);
                    }
                }
                else
                {
                    if (test.NormMinF == test.NormMaxF && test.NormMinF == 0)
                    {
                        table.AddCell(new Cell().Add(new Paragraph("0"))).SetFont(font);
                    }
                    else
                    {
                        table.AddCell(new Cell().Add(new Paragraph(test.NormMinF + "-" + test.NormMaxF))).SetFont(font);
                    }
                }
            }
            document.Add(table);

            document.Add(new Paragraph((Lang == "pl" ? "Opis: " : "Description: ") + study.Result.Description)).SetFont(font);
            document.Add(new Paragraph((Lang == "pl" ? "Twórca opisu: " : "Creator of the description: ") + study.Lab)).SetFont(font);


            document.Close();

            return(stream.ToArray());
        }