Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ public void createConsultReply(ManagerPrincipal managerPrincipal, ConsultReplyCr
NursingFacility nursingFacility = nursingFacilityRepository.findById(managerPrincipal.getFacilityId())
.orElseThrow(FacilityNotFoundException::new);

User user;
Long consultId;
ConsultCategory consultCategory;

if (req.getCategory().equals(ConsultCategory.GRADE)) {
Consult consult = consultRepository.findById(req.getConsultId())
.orElseThrow(ConsultNotFoundException::new);
Expand All @@ -203,6 +207,9 @@ public void createConsultReply(ManagerPrincipal managerPrincipal, ConsultReplyCr
if (consultReplyRepository.existsByConsult_Id(req.getConsultId())) {
throw new ConsultReplyAlreadyExistsException();
}
user = consult.getUser();
consultId = consult.getId();
consultCategory = ConsultCategory.GRADE;

ConsultReply reply = ConsultReply.toEntity(req.getContent(), consult, null);

Expand Down Expand Up @@ -234,7 +241,18 @@ public void createConsultReply(ManagerPrincipal managerPrincipal, ConsultReplyCr
consult.updateConfirmation(confirmReq);

consult.consultReply(reply);

user = consult.getUser();
consultId = consult.getId();
consultCategory = ConsultCategory.GENERAL;
}
Notification notification = Notification.createConsultStatusChanged(
user,
consultId,
consultCategory,
true
);
notificationRepository.save(notification);
}

@Override
Expand Down