[HttpGet("getForPatient/{patientID}")] // GET /api/medicalRecord/getForPatient/{id} public IActionResult GetMedicalRecordForPatient(int patientID) { MedicalRecord medicalRecord = App.Instance().MedicalRecordService.GetMedicalRecordForPatient(patientID); if (medicalRecord == null) { return(NotFound()); } else { return(Ok(MedicalRecordMapper.MedicalRecordToMedicalRecordDto(medicalRecord))); } }
public IActionResult GetMedicalRecordByPatient() { try { string id = User.Identity.Name; MedicalRecord medicalRecord = _medicalRecordService.GetMedicalRecordByPatient(id); MedicalRecordDTO medicalRecordDTO = MedicalRecordMapper.MedicalRecordToMedicalRecordDTO(medicalRecord); return(Ok(medicalRecordDTO)); } catch (EntityNotFound) { return(BadRequest("Medical record not found.")); } catch (Exception) { return(BadRequest("Inner system error.")); } }
[HttpPost] // POST /api/medicalRecord public IActionResult RegisterPatient(MedicalRecordDto dto) { MedicalRecordValidation medicalRecordValidation = new MedicalRecordValidation(); if (!medicalRecordValidation.ValidateMedicalRecord(dto)) { return(BadRequest("The data which were entered are incorrect!")); } App.Instance().MedicalRecordService.CreatePatientMedicalRecord(new MailAddress(dto.Patient.EMail), MedicalRecordMapper.MedicalRecordDtoToMedicalRecord(dto)); App.Instance().MedicalRecordService.WritePatientProfilePictureInFile(dto.Patient.Username, dto.ProfilePicture); return(Ok(200)); }