public async Task <PrescriptionDto> GetPrescriptionAsync(int id) { var wantedPrescription = await context.Prescription.FindAsync(id); if (wantedPrescription == null) { return(null); } PrescriptionDto prescriptionDto = await context .Prescription .Where(e => e.IdPrescription == id) .Select(e => new PrescriptionDto { PrescriptionDate = e.Date, PrescriptionDueDate = e.DueDate, PatientFirstName = e.IdPatientNav.FirstName, PatientLastName = e.IdPatientNav.LastName, PatientBirthDate = e.IdPatientNav.BirthDate, DoctorFirstName = e.IdDoctorNav.FirstName, DoctorLastName = e.IdDoctorNav.LastName, DoctorEmail = e.IdDoctorNav.Email, Medicaments = e.PrescriptionMedicaments.Select(e => new MedicamentDto { Name = e.IdMedicamentNav.Name, Details = e.Details, Dose = e.Dose }) }).FirstAsync(); return(prescriptionDto); }
public async Task CreatePrescriptionAsync_ShouldReturnCreatedResult() { int count = UnitOfWork.Prescriptions.Get().ToList().Count; var drug = UnitOfWork.Drugs.Get(1); var patient = UnitOfWork.Patients.Get(1); var rxDto = new PrescriptionDto() { Dose = "Once a day", Duration = 90, DrugId = drug.Id, PatientId = patient.Id, WrittenDate = DateTime.Now.AddDays(-30), //Drug = new DrugDto() { Id = drug.Id, BrandName = drug.BrandName, GenericName = drug.GenericName, NdcId = drug.NdcId, Price = drug.Price, Strength = drug.Strength}, //Patient = new PatientDto() { Id = patient.Id, FirstName = patient.FirstName, LastName = patient.LastName, DateOfBirth = patient.DateOfBirth, Gender = patient.Gender} }; PrescriptionController.Validate(rxDto); var result = await PrescriptionController.CreatePrescriptionAsync(rxDto) as CreatedNegotiatedContentResult <PrescriptionDto>; Assert.IsNotNull(result); Assert.AreEqual(UnitOfWork.Prescriptions.Get().ToList().Count, count + 1); }
[HttpPost("advancedSearchPrescriptionsForPatient")] // POST /api/prescription/advancedSearchPrescriptionsForPatient public IActionResult FindPrescriptionsForPatient(PrescriptionDto dto) { List <PrescriptionDto> result = new List <PrescriptionDto>(); App.Instance().PrescriptionService.FindPrescriptionsUsingAdvancedSearch(dto.PatientId, dto.SearchParams, dto.LogicOperators).ToList().ForEach(prescription => result.Add(PrescriptionMapper.PrescriptionToPrescriptionDto(prescription))); return(Ok(result)); }
public PrescriptionDto GetPrescription(int id) { var prescr = _context.Prescriptions.SingleOrDefault(p => p.IdPrescription == id); var prescrmeds = _context.PrescriptionMedicaments.Where(p => p.IdPrescription == id).Select(p => p.IdMedicament).ToList(); var meds = _context.Medicaments.Where(p => prescrmeds.Contains(p.IdMedicament)); PrescriptionDto prescrDto = new PrescriptionDto { IdDoctor = prescr.IdDoctor, IdPatient = prescr.IdPatient, IdPrescription = prescr.IdPrescription, Date = prescr.Date, DueDate = prescr.DueDate, Medicaments = new List <MedicamentDto>() }; foreach (Medicament m in meds) { prescrDto.Medicaments.Add(new MedicamentDto { IdMedicament = m.IdMedicament, Description = m.Description, Name = m.Name, Type = m.Type }); } return(prescrDto); }
public bool AddPrescription(int doctorId, PrescriptionDto prescription) { var entity = mapper.Map(prescription); entity.DoctorId = doctorId; return(prescriptionRepository.Add(entity)); }
/// <summary> /// Updates the specified prescription. /// </summary> /// <param name="item">The item.</param> public void Update(PrescriptionDto item) { var entity = this.Session.Get <Prescription>(item.Id); Mapper.Map <PrescriptionDto, Prescription>(item, entity); this.Session.Update(entity); }
public void IsInvalid_NoDrug() { var item = new PrescriptionDto() { Notes = Guid.NewGuid().ToString(), }; Assert.IsFalse(item.IsValid()); }
private PrescriptionInfoResultInfo getResult(PrescriptionDto lymb_prescription) { var resultInfo = new PrescriptionInfoResultInfo(); resultInfo.abcd = lymb_prescription.abcd; resultInfo.prescriptionid = lymb_prescription.prescriptionid; DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); resultInfo.time= (long)(DateTime.Now - startTime).TotalSeconds * 1000; return resultInfo; }
public void IsInvalid_NoNotes() { var item = new PrescriptionDto() { Drug = new DrugDto(), Notes = string.Empty, }; Assert.IsFalse(item.IsValid()); }
public static PrescriptionDto PrescriptionToDto(Prescription prescription) { var prescriptionDto = new PrescriptionDto(); prescriptionDto.InjectFrom(prescription); prescriptionDto.MedicationName = prescription.Medication.GenericName; prescriptionDto.MedicationCode = prescription.Medication.Code; prescriptionDto.PatientName = prescription.Patient.FirstName + " " + prescription.Patient.LastName; return(prescriptionDto); }
public async Task <IHttpActionResult> CreatePrescriptionAsync(PrescriptionDto rx) { try { if (ModelState.IsValid) { Drug dbDrug = await _unitOfWork.Drugs.GetAsync(rx.DrugId); if (dbDrug == null) { _logger.Warn($"Invalid Drug Id {rx.DrugId}"); return(BadRequest("Invalid drugId")); } Patient dbPatient = await _unitOfWork.Patients.GetAsync(rx.PatientId); if (dbPatient == null) { _logger.Warn($"Invalid Patient Id {rx.PatientId}"); return(BadRequest("Invalid patientId")); } Prescription dbRx = new Prescription() { Drug = dbDrug, Patient = dbPatient, Dose = rx.Dose, Duration = rx.Duration, WrittenDate = rx.WrittenDate }; _unitOfWork.Prescriptions.Add(dbRx); await _unitOfWork.CompleteAsync(); rx.Id = dbRx.Id; return(Created(new Uri(Request.RequestUri + "/" + rx.Id), rx)); } //If model state is not valid then log all the validation warnings _logger.Warn(string.Join(" | ", ModelState.Values.SelectMany(e => e.Errors.Take(1)).Select(e => e.ErrorMessage))); //If model state is not valid then return all the validation messages return(BadRequest(ModelState)); } catch (Exception ex) { if (_logger.IsDebugEnabled) { _logger.Debug(ex); return(InternalServerError(ex)); } return(InternalServerError()); } }
public async Task <IHttpActionResult> UpdatePrescriptionAsync(PrescriptionDto rx) { try { if (ModelState.IsValid) { Drug dbDrug = await _unitOfWork.Drugs.GetAsync(rx.DrugId); Prescription dbRx = await _unitOfWork.Prescriptions.GetAsync(rx.Id); if (dbRx == null) { _logger.Warn($"Invalid Rx Id {rx.Id}"); return(NotFound()); } if (dbDrug == null) { _logger.Warn($"Invalid Drug Id {rx.DrugId}"); return(NotFound()); } Patient dbPatient = await _unitOfWork.Patients.GetAsync(rx.PatientId); if (dbPatient == null) { _logger.Warn($"Invalid Patient Id {rx.PatientId}"); return(NotFound()); } dbRx.Drug = dbDrug; dbRx.Dose = rx.Dose; dbRx.Duration = rx.Duration; dbRx.WrittenDate = rx.WrittenDate; dbRx.Patient = dbPatient; await _unitOfWork.CompleteAsync(); return(Ok(rx)); } _logger.Warn(string.Join(" | ", ModelState.Values.SelectMany(e => e.Errors.Take(1)).Select(e => e.ErrorMessage))); return(BadRequest(ModelState)); } catch (Exception ex) { if (_logger.IsDebugEnabled) { _logger.Debug(ex); return(InternalServerError(ex)); } return(InternalServerError()); } }
public void IsValid() { var item = new PrescriptionDto() { Drug = new DrugDto(), Notes = Guid.NewGuid().ToString(), Tag = new TagDto(TagCategory.Appointment) { Id = 14 }, }; Assert.IsTrue(item.IsValid()); }
public static PrescriptionDto PrescriptionToPrescriptionDto(Prescription prescription) { PrescriptionDto dto = new PrescriptionDto(); dto.Id = prescription.Id; dto.Comment = prescription.Comment; dto.PublishingDate = prescription.PublishingDate.ToString("dd.MM.yyyy."); dto.Doctor = prescription.MedicalExamination.Doctor.Name + " " + prescription.MedicalExamination.Doctor.Surname; List <Medicament> medicaments = new List <Medicament>(); prescription.Medicaments.ToList().ForEach(medicament => medicaments.Add(medicament)); dto.Medicaments = medicaments; return(dto); }
private List <EstimateDto> RxStreamEstimate() { string url = ConfigurationSettings.AppSettings["url"].ToString(); string tenantId = ConfigurationSettings.AppSettings["tenantId"].ToString(); string apiKey = ConfigurationSettings.AppSettings["apiKey"].ToString(); //get the methods you are going to call var client = new RestClient(url); var request = new RestRequest("Prescription/Estimate", Method.POST); //Add the keys to the request header, these are requred for ever call request.AddHeader("TenantId", tenantId); request.AddHeader("ApiKey", apiKey); //Start building the Prescripton Dto //put together the header with the minimal info var prescriptionDto = new PrescriptionDto { ClientId = Guid.NewGuid().ToString(), PatZip = "80012", DocZip = "80012", PharmacyId = "" }; //Create / Add a prescription line item prescriptionDto.LineItems.Add(new PrescriptionItemDto { PrescriptionNumber = Guid.NewGuid().ToString(), //Normally this would come from the client and you would use it to match back in the response Ndc = "00378362793", Quantity = 30 }); //Add the Json body var json = JsonConvert.SerializeObject(prescriptionDto); request.AddParameter("application/json; charset=utf-8", json, ParameterType.RequestBody); request.RequestFormat = DataFormat.Json; //Call RxStream var restResponse = client.Execute(request); //try to make the call and report any errors //Deserialize object var responseList = JsonConvert.DeserializeObject <List <EstimateDto> >(restResponse.Content); return(responseList); }
public async Task CreatePrescriptionAsync_ShouldReturnBadRequest() { var rxDto = new PrescriptionDto() { Dose = "Once a day", Duration = 30, WrittenDate = DateTime.Now }; PrescriptionController.Validate(rxDto); var result = await PrescriptionController.CreatePrescriptionAsync(rxDto); Assert.IsInstanceOfType(result, typeof(BadRequestErrorMessageResult)); }
public Object PostUpdate([FromBody] PrescriptionDto lymb_prescription) { var result = getResult(lymb_prescription); using (var db = new BloggingContext()) { try { PrescriptionInfo preInfo = lymb_prescription.GetNewprescriptionInfo(); db.prescriptionInfo.Add(preInfo); try { db.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { throw ex; } var details = lymb_prescription.GetNewPrescriptionDetail(); db.prescriptionDetail.AddRange(details); db.SaveChanges(); var pharmacyId = lymb_prescription.pharmacyId; int state = 1; if (!String.IsNullOrEmpty(pharmacyId)) { state = db.Database.SqlQuery<int>("select state from lymb_prescription_state where pharmacyId='" + pharmacyId+"'").FirstOrDefault(); if (state != 2) { state = 1; } } result.state = state; return result; ; } catch (Exception e) { result.message = e.Message; //return JsonConvert.SerializeObject(result); return result; } } }
public void CreatePrescription_WithTwiceSameDrug_NoError() { var user = new PatientSessionComponent(this.Session).GetPatientsByNameLight("*", SearchOn.FirstAndLastName)[0]; var drugs = this.ComponentUnderTest.GetDrugsByName("*"); var document = new PrescriptionDocumentDto(); var prescription = new PrescriptionDto(); document.Prescriptions.Add(new PrescriptionDto() { Drug = drugs[0] }); document.Prescriptions.Add(new PrescriptionDto() { Drug = drugs[0] }); this.WrapInTransaction(() => this.ComponentUnderTest.Create(document, user)); }
public async Task Given_Prescription_Posts_And_Returns_201_Code() { var entity = new PrescriptionDto { Description = "DEDEDE", StartDate = DateTime.Now, EndDate = DateTime.Now, ConsultationId = _constulatations[0].Id, PatientId = _patients[0].Id }; var lengthBefore = _fakeEntities.Count; var result = await FakeController.Post(entity); var objActionResult = (CreatedAtActionResult)result.Result; Assert.Equal(lengthBefore + 1, _fakeEntities.Count); Assert.Equal(201, objActionResult.StatusCode); }
public async Task UpdatePrescriptionAsync_ShouldReturnOkResult() { var rx = UnitOfWork.Prescriptions.Get(1); var rxDto = new PrescriptionDto() { Id = rx.Id, Dose = rx.Dose, Duration = 90, WrittenDate = DateTime.Now.AddDays(-30), DrugId = rx.DrugId, PatientId = rx.PatientId //Drug = new DrugDto() { Id = rx.Drug.Id, BrandName = rx.Drug.BrandName, GenericName = rx.Drug.GenericName }, //Patient = new PatientDto() { Id = rx.Patient.Id, FirstName = rx.Patient.FirstName, LastName = rx.Patient.LastName } }; var result = await PrescriptionController.UpdatePrescriptionAsync(rxDto) as OkNegotiatedContentResult <PrescriptionDto>; Assert.IsNotNull(result); Assert.AreEqual(result.Content.Duration, rxDto.Duration); Assert.AreEqual(result.Content.WrittenDate, rxDto.WrittenDate); }
public void Given_Valid_Post_Data_Posts() { var tokenEnvironmentVariable = Environment.GetEnvironmentVariable("Token"); _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenEnvironmentVariable); var resultPatient = _client.GetAsync("/api/patients/").Result; var readAsStringAsyncPatient = resultPatient.Content.ReadAsStringAsync(); var jsonPatient = readAsStringAsyncPatient.Result; var jArray = JArray.Parse(jsonPatient); var patientList = jArray.ToObject <List <Patient> >(); var constulMessage = _client.GetAsync("/api/consultations/").Result; var consuAsStringAsync = constulMessage.Content.ReadAsStringAsync(); var jsonResult = consuAsStringAsync.Result; var jArrayr = JArray.Parse(jsonResult); var consulList = jArrayr.ToObject <List <Consultation> >(); var prescriptionDto = new PrescriptionDto { Description = "descriptie", StartDate = new DateTime(2020, 1, 1), EndDate = new DateTime(2021, 1, 1), PatientId = patientList[0].Id, ConsultationId = consulList[0].Id }; var serialize = JsonConvert.SerializeObject(prescriptionDto); var content = new StringContent(serialize, Encoding.UTF8, "application/json"); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var result = _client.PostAsync("/api/prescriptions/", content).Result; Assert.Equal(HttpStatusCode.Created, result.StatusCode); }
public async Task UpdatePrescriptionAsync_ShouldReturnNotFound() { var rx = UnitOfWork.Prescriptions.Get(1); var rxDto = new PrescriptionDto() { Dose = rx.Dose, Duration = rx.Duration, WrittenDate = rx.WrittenDate, Drug = new DrugDto() { Id = rx.Drug.Id, BrandName = rx.Drug.BrandName, GenericName = rx.Drug.GenericName }, Patient = new PatientDto() { Id = rx.Patient.Id, FirstName = rx.Patient.FirstName, LastName = rx.Patient.LastName } }; var result = await PrescriptionController.UpdatePrescriptionAsync(rxDto); Assert.IsInstanceOfType(result, typeof(NotFoundResult)); }
public DrugPrescriptionEntity DrugPrescriptionRaised(PrescriptionDto entity) { var prescribeMessage = new DrugPrescriptionEntity() { MESSAGE_HEADER = { SENDING_APPLICATION = "IQCARE", SENDING_FACILITY = "13050", RECEIVING_APPLICATION = "IL", RECEIVING_FACILITY = "", MESSAGE_DATETIME = "201709221034",// entity.CommonOrderDetails.TransactionDatetime, SECURITY = "", MESSAGE_TYPE = "RDE^001", PROCESSING_ID = "P" }, PATIENT_IDENTIFICATION = { INTERNAL_PATIENT_ID = new List <INTERNALPATIENTID>() }, COMMON_ORDER_DETAILS = { ORDER_CONTROL = entity.CommonOrderDetails.OrderControl, PLACER_ORDER_NUMBER = { NUMBER = entity.CommonOrderDetails.PlacerOrderNumber.Number.ToString(), ENTITY = "IQCARE" }, ORDER_STATUS = entity.CommonOrderDetails.OrderStatus, ORDERING_PHYSICIAN = { FIRST_NAME = entity.CommonOrderDetails.OrderingPhysician.FirstName, MIDDLE_NAME = entity.CommonOrderDetails.OrderingPhysician.MiddleName, LAST_NAME = entity.CommonOrderDetails.OrderingPhysician.LastName }, TRANSACTION_DATETIME = entity.CommonOrderDetails.TransactionDatetime.ToShortDateString() }, PHARMACY_ENCODED_ORDER = new List <PHARMACYENCODEDORDER>() }; // return prescribeMessage; throw new NotImplementedException(); }
/// <summary> /// Updates the specified prescription. /// </summary> /// <param name="item">The item.</param> public void Update(PrescriptionDto item) { new Updator(this.Session).Update(item); }
/// <summary> /// Removes the specified prescription. /// </summary> /// <param name="item">The item.</param> public void Remove(PrescriptionDto item) { this.Remove <Prescription>(item); }
public Prescription Map(PrescriptionDto prescription) => mMapper.Map <Prescription>(prescription);
public Prescription Map(PrescriptionDto prescription) { return(mapper.Map <Prescription>(prescription)); }
public bool DeletePrescription(PrescriptionDto prescription) { var entity = mapper.Map(prescription); return(prescriptionRepository.Delete(entity)); }
public void Remove(PrescriptionDto prescription) { this.Prescriptions.Remove(prescription); }
public PrescriptionViewModel Map(PrescriptionDto prescription) => _Mapper.Map <PrescriptionViewModel>(prescription);