예제 #1
0
        public async Task AddRequestTest()
        {
            var URL           = BaseURL + "/doctors/addRequest";
            var doctorRequest = new DoctorRequestViewModel
            {
                BloodType      = "O1",
                Rh             = "NEGATIV",
                EmergencyLevel = "RIDICAT",
                Component      = "BloodBag"
            };
            var payload = HttpUtils.CreateContent(doctorRequest);
            var client  = await AccountUtils.LoginUserAndGetClient(doctor1, Password);

            var response = await client.PostAsync(URL, payload);

            Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.OK);
        }
예제 #2
0
        public static Request ToDoctorRequestDb(DoctorRequestViewModel requestViewModel)
        {
            var request = new Request()
            {
                BloodType         = (BloodTypes)Enum.Parse(typeof(BloodTypes), requestViewModel.BloodType.ToUpper()),
                EmergencyLevel    = (EmergencyLevel)Enum.Parse(typeof(EmergencyLevel), requestViewModel.EmergencyLevel.ToUpper()),
                Status            = RequestStatus.Waiting,
                RequestedQuantity = requestViewModel.RequestedQuantity,
                Component         = (ComponentType)Enum.Parse(typeof(ComponentType), requestViewModel.Component)
            };

            if (requestViewModel.Rh != null)
            {
                request.Rh = (RhTypes)Enum.Parse(typeof(RhTypes), requestViewModel.Rh.ToUpper());
            }
            return(request);
        }
예제 #3
0
        public IActionResult AddDoctorRequest([FromBody] DoctorRequestViewModel doctorRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Can't add request"));
            }

            try
            {
                Patient patient = new Patient();
                if (doctorRequest.Patient.LastName == null)
                {
                    patient        = patientService.GetPatientByCNP(doctorRequest.Patient.CNP);
                    patient.Status = PatientStatus.INTERNAT;
                }
                else
                {
                    Address address = Mappers.MapperPatient.ToAddressDb(doctorRequest.Patient);
                    patient        = Mappers.MapperPatient.ToPatientDb(doctorRequest.Patient);
                    patient.Status = PatientStatus.INTERNAT;
                    var    id     = Request.Cookies["UserId"];
                    Doctor doctor = doctorsService.GetDoctorById(id);
                    patient.IdDoctor = doctor.Id;
                    patientService.AddPatient(patient, address);
                }

                Request request = Mappers.MapperDoctorRequest.ToDoctorRequestDb(doctorRequest);
                request.IdPatient = patient.Id;
                request           = doctorsService.AddRequest(request);

                doctorRequest.dateOfRequest = request.DateOfRequest;
                doctorRequest.id            = request.Id;

                EmployeeRequestModelView employeeRequest = Mappers.MapperDoctorRequest.ToEmployeeRequest(request);
                this.broadcaster.Clients.Group("DonationCenterDoctor").SendRequest(employeeRequest);

                return(Ok(request));
            }catch (Exception ex)
            {
                return(BadRequest("Can't add request"));
            }
        }
예제 #4
0
        public static DoctorRequestViewModel ToDoctorRequestViewModel(Request request)
        {
            var requestViewModel = new DoctorRequestViewModel()
            {
                BloodType         = request.BloodType.ToString(),
                EmergencyLevel    = request.EmergencyLevel.ToString(),
                Patient           = MapperPatient.ToPatientAdd(request.Patient),
                Rh                = request.Rh.ToString(),
                Status            = request.Status.ToString(),
                RequestedQuantity = request.RequestedQuantity,
                dateOfRequest     = request.DateOfRequest,
                currentQuantity   = request.ReceivedQuantity,
                id                = request.Id
            };

            switch (request.Component)
            {
            case ComponentType.BloodBag:
                requestViewModel.Component = "Sange neseparat";
                break;

            case ComponentType.Thrombocyte:
                requestViewModel.Component = "Trombocite";
                break;

            case ComponentType.Plasma:
                requestViewModel.Component = "Plasma";
                break;

            case ComponentType.RedBloodCells:
                requestViewModel.Component = "Celule rosii";
                break;

            default:
                break;
            }

            return(requestViewModel);
        }