private async Task <string> UpdateHealthCard(HealthCardUpdateModel healthCardUpdateModel) { var identificationNum = Request.QueryString["identificationNumber"]; var patientToUpdate = await PatientFacade.GetPatientByIdentificationNumberAsync(identificationNum); var healthCard = await HealthCardFacade.GetHealthCardAsync(patientToUpdate.Id); if (healthCard == null) { var healthCardDto = new HealthCardDto { Id = patientToUpdate.Id, LastUpdate = DateTime.Now }; await HealthCardFacade.CreateHealthCardAsync(healthCardDto); healthCard = await HealthCardFacade.GetHealthCardAsync(patientToUpdate.Id); } if (healthCardUpdateModel.BloodType != HospitalISDBContext.Enums.BloodType.Unknown) { healthCard.BloodType = healthCardUpdateModel.BloodType; } if (healthCardUpdateModel.DiseaseId != Guid.Empty) { await MatchDiseaseAndHealthCard(await DiseaseFacade.GetDiseaseAsync(healthCardUpdateModel.DiseaseId), healthCard); } healthCard.LastUpdate = DateTime.Now; await HealthCardFacade.EditHealthCardAsync(healthCard); return(identificationNum); }
private async Task <ActionResult> GetPatientInfo(PatientDto patient) { PatientInfoModel model = new PatientInfoModel { Name = patient.Name, Surname = patient.Surname, DateOfBirth = patient.DateOfBirth, Email = patient.Email, IdentificationNumber = patient.IdentificationNumber, ProfileCreationDate = patient.ProfileCreationDate, Doctors = await PatientFacade.GetDoctorsForPatientAsync(patient.Id), }; patient.HealthCard = await PatientFacade.GetPatientWithHealthCardAsync(patient.Id); if (patient.HealthCard != null) { model.Diseases = await HealthCardFacade.GetDiseasesForHealthCard(patient.Id); model.BloodType = patient.HealthCard.BloodType; } return(View("PatientAskForGetInfo", model)); }