package com.healthcare.ohctech.controller; import com.healthcare.ohctech.dto.EmployeeAppointmentDto; import com.healthcare.ohctech.entity.*; import com.healthcare.ohctech.repository.*; import com.healthcare.ohctech.service.impl.AuthServiceImpl; import com.healthcare.ohctech.service.impl.EmployeeAppointmentServiceImpl; import com.healthcare.ohctech.util.PaginationUtil; import jakarta.validation.Valid; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.util.*; import java.util.stream.Collectors; @RestController @RequestMapping("/employee-appointments") public class EmployeeAppointmentController { @Autowired private EmployeeAppointmentServiceImpl employeeAppointmentServiceImpl; @Autowired private AuthServiceImpl authServiceImpl; @Autowired private ComplaintRepo complaintRepo; @Autowired private ExaminationFindingsRepo examinationFindingsRepo; @Autowired private AilmentRepo ailmentRepo; @Autowired private SaltMasterRepo saltMasterRepo; @Autowired private InjuryTypeRepo injuryTypeRepo; @Autowired private InjuryPartRepo injuryPartRepo; @Autowired private InjuryClassRepo injuryClassRepo; @Autowired private InjuryMechanismRepo injuryMechanismRepo; @Autowired private HealthAdviceRepo healthAdviceRepo; @Autowired private CheckupFormSectionRepo checkupFormSectionRepo; @Autowired private CheckupParameterRepo checkupParameterRepo; @Autowired private ReferralPointRepo referralPointRepo; @Autowired private ReferredByRepo referredByRepo; @Autowired private PrescriptionMasterRepo prescriptionMasterRepo; @Autowired private PatientRepo patientRepo; @Autowired private OhcTypeRepo ohcTypeRepo; @GetMapping("/opd/{empId}") public ResponseEntity getEmployeeAppointmentsByEmpId(@PathVariable Long empId) { // Fetch all appointments for the given employee ID List appointments = employeeAppointmentServiceImpl.getAppointmentsByPatientId(empId); // Filter appointments where appointment_type is 'o' List filteredAppointments = appointments.stream() .filter(appointment -> "o".equals(appointment.getAppointmentType())) .collect(Collectors.toList()); List> responseList = new ArrayList<>(); for (EmployeeAppointment appointment : filteredAppointments) { List> complaintsDetails = appointment.getComplaintIds() != null ? Arrays.stream(appointment.getComplaintIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> complaintRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(complaint -> { Map map = new LinkedHashMap<>(); map.put("id", complaint.getId()); map.put("label", complaint.getComplaint()); return map; }) .collect(Collectors.toList()) : new ArrayList<>(); List> recommendedTestsDetails = appointment.getCheckupFormSectionIds() != null ? Arrays.stream(appointment.getCheckupFormSectionIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> checkupFormSectionRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(recommendedTest -> { Map map = new LinkedHashMap<>(); map.put("id", recommendedTest.getId()); map.put("label", recommendedTest.getSectionName()); return map; }) .collect(Collectors.toList()) : new ArrayList<>(); Map response = new LinkedHashMap<>(); response.put("id", appointment.getId()); response.put("ticketNo", appointment.getTicketNo()); response.put("complaints", complaintsDetails); response.put("appointmentDate", appointment.getAppointmentDate()); response.put("recommendedTests", recommendedTestsDetails); responseList.add(response); } return new ResponseEntity<>(responseList, HttpStatus.OK); } @GetMapping("/injury/{empId}") public ResponseEntity getEmployeeInquiryAppointmentsByEmpId(@PathVariable Long empId) { // Fetch all appointments for the given employee ID List appointments = employeeAppointmentServiceImpl.getAppointmentsByPatientId(empId); // Filter appointments where appointment_type is 'i' List filteredAppointments = appointments.stream() .filter(appointment -> "i".equals(appointment.getAppointmentType())) .collect(Collectors.toList()); List> responseList = new ArrayList<>(); for (EmployeeAppointment appointment : filteredAppointments) { List> complaintsDetails = appointment.getComplaintIds() != null ? Arrays.stream(appointment.getComplaintIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> complaintRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(complaint -> { Map map = new LinkedHashMap<>(); map.put("id", complaint.getId()); map.put("label", complaint.getComplaint()); return map; }) .collect(Collectors.toList()) : new ArrayList<>(); List> recommendedTestsDetails = appointment.getCheckupFormSectionIds() != null ? Arrays.stream(appointment.getCheckupFormSectionIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> checkupFormSectionRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(recommendedTest -> { Map map = new LinkedHashMap<>(); map.put("id", recommendedTest.getId()); map.put("label", recommendedTest.getSectionName()); return map; }) .collect(Collectors.toList()) : new ArrayList<>(); Map response = new LinkedHashMap<>(); response.put("id", appointment.getId()); response.put("ticketNo", appointment.getTicketNo()); response.put("complaints", complaintsDetails); response.put("appointmentDate", appointment.getAppointmentDate()); response.put("recommendedTests", recommendedTestsDetails); responseList.add(response); } return new ResponseEntity<>(responseList, HttpStatus.OK); } @GetMapping("/{appointmentId}") public ResponseEntity getEmployeeAppointmentById(@PathVariable Long appointmentId) { EmployeeAppointment appointment = employeeAppointmentServiceImpl.getEmployeeAppointmentById(appointmentId); List> complaintsDetails = appointment.getComplaintIds() != null ? Arrays.stream(appointment.getComplaintIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> complaintRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(complaint -> { Map map = new LinkedHashMap<>(); map.put("id", complaint.getId()); map.put("label", complaint.getComplaint()); return map; }) .collect(Collectors.toList()) : new ArrayList<>(); List> examinationRemarksDetails = appointment.getExaminationRemarkIds() != null ? Arrays.stream(appointment.getExaminationRemarkIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> examinationFindingsRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(examinationRemark -> { Map map = new LinkedHashMap<>(); map.put("id", examinationRemark.getId()); map.put("label", examinationRemark.getExaminationFinding()); return map; }) .collect(Collectors.toList()) : new ArrayList<>(); List> ailmentsNewDetails = appointment.getAilmentIds() != null ? Arrays.stream(appointment.getAilmentIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> ailmentRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(ailmentNew -> { Map map = new LinkedHashMap<>(); map.put("id", ailmentNew.getId()); map.put("label", ailmentNew.getAilmentName()); return map; }) .collect(Collectors.toList()) : new ArrayList<>(); List> drugAllergyDetails = appointment.getSaltIds() != null ? Arrays.stream(appointment.getSaltIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> saltMasterRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(drugAllergy -> { Map map = new LinkedHashMap<>(); map.put("id", drugAllergy.getId()); map.put("label", drugAllergy.getSaltName()); return map; }) .collect(Collectors.toList()) : new ArrayList<>(); List> injuryTypesDetails = appointment.getInjuryTypeIds() != null ? Arrays.stream(appointment.getInjuryTypeIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> injuryTypeRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(injuryType -> { Map map = new LinkedHashMap<>(); map.put("id", injuryType.getId()); map.put("label", injuryType.getInjuryTypeName()); return map; }) .collect(Collectors.toList()) : new ArrayList<>(); List> injuryPartsDetails = appointment.getInjuryPartIds() != null ? Arrays.stream(appointment.getInjuryPartIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> injuryPartRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(injuryPart -> { Map map = new LinkedHashMap<>(); map.put("id", injuryPart.getId()); map.put("label", injuryPart.getName()); return map; }) .collect(Collectors.toList()) : new ArrayList<>(); List> injuryClassesDetails = appointment.getInjuryClassIds() != null ? Arrays.stream(appointment.getInjuryClassIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> injuryClassRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(injuryClass -> { Map map = new LinkedHashMap<>(); map.put("id", injuryClass.getId()); map.put("label", injuryClass.getInjClassName()); return map; }) .collect(Collectors.toList()) : new ArrayList<>(); List> injuryMechsDetails = appointment.getInjuryMechIds() != null ? Arrays.stream(appointment.getInjuryMechIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> injuryMechanismRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(injuryMech -> { Map map = new LinkedHashMap<>(); map.put("id", injuryMech.getId()); map.put("label", injuryMech.getInjuryMechName()); return map; }) .collect(Collectors.toList()) : new ArrayList<>(); List> healthAdvicesDetails = appointment.getHealthAdviceIds() != null ? Arrays.stream(appointment.getHealthAdviceIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> healthAdviceRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(healthAdvice -> { Map map = new LinkedHashMap<>(); map.put("id", healthAdvice.getId()); map.put("label", healthAdvice.getHealthAdviceName()); return map; }) .collect(Collectors.toList()) : new ArrayList<>(); List> recommendedTestsDetails = appointment.getCheckupFormSectionIds() != null ? Arrays.stream(appointment.getCheckupFormSectionIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> checkupFormSectionRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(recommendedTest -> { Map map = new LinkedHashMap<>(); map.put("id", recommendedTest.getId()); map.put("label", recommendedTest.getSectionName()); return map; }) .collect(Collectors.toList()) : new ArrayList<>(); List> recommendedTestParamsDetails = appointment.getCheckupParameterIds() != null ? Arrays.stream(appointment.getCheckupParameterIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> checkupParameterRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(recommendedTestParam -> { Map map = new LinkedHashMap<>(); map.put("id", recommendedTestParam.getId()); map.put("label", recommendedTestParam.getParameterName()); return map; }) .collect(Collectors.toList()) : new ArrayList<>(); List> abnormalityDetails = appointment.getPrescriptionMasterIds() != null ? Arrays.stream(appointment.getPrescriptionMasterIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> prescriptionMasterRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(abnormality -> { Map map = new LinkedHashMap<>(); map.put("id", abnormality.getId()); map.put("label", abnormality.getChronicIllness()); return map; }) .collect(Collectors.toList()) : new ArrayList<>(); Map referredByDetails = appointment.getReferredBy() != null ? referredByRepo.findById(appointment.getReferredBy().getId()) .map(doctor -> { Map map = new LinkedHashMap<>(); map.put("id", doctor.getId()); map.put("label", doctor.getReferredBy()); return map; }) .orElseGet(() -> { Map map = new LinkedHashMap<>(); map.put("id", " "); map.put("label", " "); return map; }) : new LinkedHashMap<>(); Map referralDetails = appointment.getReferralPoint() != null ? referralPointRepo.findById(appointment.getReferralPoint().getId()) .map(doctor -> { Map map = new LinkedHashMap<>(); map.put("id", doctor.getId()); map.put("label", doctor.getReferralPointName()); return map; }) .orElseGet(() -> { Map map = new LinkedHashMap<>(); map.put("id", " "); map.put("label", " "); return map; }) : new LinkedHashMap<>(); Map ohcTypeDetails = appointment.getOhcType() != null ? ohcTypeRepo.findById(appointment.getOhcType().getId()) .map(ohcType -> { Map map = new LinkedHashMap<>(); map.put("id", ohcType.getId()); map.put("label", ohcType.getOhcName()); return map; }) .orElseGet(() -> { Map map = new LinkedHashMap<>(); map.put("id", " "); map.put("label", " "); return map; }) : new LinkedHashMap<>(); Map empDetails = appointment.getOhcType() != null ? patientRepo.findById(appointment.getPatient().getId()) .map(ohcType -> { Map map = new LinkedHashMap<>(); map.put("id", ohcType.getId()); map.put("label", ohcType.getPatientName()); return map; }) .orElseGet(() -> { Map map = new LinkedHashMap<>(); map.put("id", " "); map.put("label", " "); return map; }) : new LinkedHashMap<>(); Map response = new LinkedHashMap<>(); response.put("id", appointment.getId()); response.put("weight", appointment.getWeight()); response.put("height", appointment.getHeight()); response.put("bmi", appointment.getBmi()); response.put("bpSbp", appointment.getBpSbp()); response.put("bpDbp", appointment.getBpDbp()); response.put("temperature", appointment.getTemperature()); response.put("respiratoryRate", appointment.getRespiratoryRate()); response.put("pulseOutput", appointment.getPulseOutput()); response.put("spo2Percent", appointment.getSpo2Percent()); response.put("glasgowComaScale", appointment.getGlasgowComaScale()); response.put("ticketNo", appointment.getTicketNo()); response.put("appointmentDate", appointment.getAppointmentDate()); response.put("appointmentType",appointment.getAppointmentType()); response.put("clearanceTime", appointment.getClearanceTime()); response.put("caseType", appointment.getCaseType()); response.put("followupToOpd", appointment.getFollowupToOpd()); response.put("referredBy", referredByDetails); response.put("complaints", complaintsDetails); response.put("examinationRemarks", examinationRemarksDetails); response.put("ailmentsNew", ailmentsNewDetails); response.put("injuryTime", appointment.getInjuryTime()); response.put("injuryAreaCat", appointment.getInjuryAreaCat()); response.put("injuryAreaType", appointment.getInjuryAreaType()); response.put("incidentLocation", appointment.getIncidentLocation()); response.put("diseaseType", appointment.getDiseaseType()); response.put("drugAllergies", drugAllergyDetails); response.put("docComment", appointment.getDocComment()); response.put("injuryTypes", injuryTypesDetails); response.put("injuryParts", injuryPartsDetails); response.put("injuryClasses", injuryClassesDetails); response.put("injuryMechs", injuryMechsDetails); response.put("injuryProcedure", appointment.getInjuryProcedure()); response.put("anyMedication", appointment.getAnyMedication()); response.put("abnormalitys", abnormalityDetails); response.put("doctorDiscussed", appointment.getDoctorDiscussed()); response.put("healthAdvices", healthAdvicesDetails); response.put("recommendedTests", recommendedTestsDetails); response.put("recommendedTestParams", recommendedTestParamsDetails); response.put("status", appointment.getStatus()); response.put("remarksRece", appointment.getRemarksRece()); response.put("followup", appointment.getFollowup()); response.put("followupRemarks", appointment.getFollowupRemarks()); response.put("restFromTime", appointment.getRestFromTime()); response.put("restToTime", appointment.getRestToTime()); response.put("injuryRemarks", appointment.getInjuryRemarks()); response.put("referralId", referralDetails); response.put("referralDoc", appointment.getReferralDoc()); response.put("ambulanceUsed", appointment.getAmbulanceUsed()); response.put("dischargeTime", appointment.getDischargeTime()); response.put("empId", empDetails); response.put("ohcTypeId", ohcTypeDetails); response.put("modifiedBy", appointment.getModifiedBy()); response.put("lastModified", appointment.getLastModified()); return new ResponseEntity<>(response, HttpStatus.OK); } @GetMapping public ResponseEntity getAllEmployeeAppointments(@RequestParam(required = false) Integer page, @RequestParam(required = false) Integer size, @RequestParam(required = false) String sortBy, @RequestParam(required = false) String sortOrder) { Pageable pageable = PaginationUtil.getPageableWithDefaults(page, size, sortBy, sortOrder); Page appointmentPage = employeeAppointmentServiceImpl.getAllEmployeeAppointments(pageable); Page> dtoPage = appointmentPage.map(appointment -> { List complaintsNames = appointment.getComplaintIds() != null ? Arrays.stream(appointment.getComplaintIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> complaintRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(Complaint::getComplaint) .collect(Collectors.toList()) : Collections.emptyList(); List examinationRemarksNames = appointment.getExaminationRemarkIds() != null ? Arrays.stream(appointment.getExaminationRemarkIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> examinationFindingsRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(ExaminationFindings::getExaminationFinding) .collect(Collectors.toList()) : Collections.emptyList(); List ailmentsNames = appointment.getAilmentIds() != null ? Arrays.stream(appointment.getAilmentIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> ailmentRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(Ailment::getAilmentName) .collect(Collectors.toList()) : Collections.emptyList(); List drugAllergiesNames = appointment.getSaltIds() != null ? Arrays.stream(appointment.getSaltIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> saltMasterRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(SaltMaster::getSaltName) .collect(Collectors.toList()) : Collections.emptyList(); List injuryTypesNames = appointment.getInjuryTypeIds() != null ? Arrays.stream(appointment.getInjuryTypeIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> injuryTypeRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(InjuryType::getInjuryTypeName) .collect(Collectors.toList()) : Collections.emptyList(); List injuryPartsNames = appointment.getInjuryPartIds() != null ? Arrays.stream(appointment.getInjuryPartIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> injuryPartRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(InjuryPart::getName) .collect(Collectors.toList()) : Collections.emptyList(); List injuryClassesNames = appointment.getInjuryClassIds() != null ? Arrays.stream(appointment.getInjuryClassIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> injuryClassRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(InjuryClass::getInjClassName) .collect(Collectors.toList()) : Collections.emptyList(); List injuryMechsNames = appointment.getInjuryMechIds() != null ? Arrays.stream(appointment.getInjuryMechIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> injuryMechanismRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(InjuryMechanism::getInjuryMechName) .collect(Collectors.toList()) : Collections.emptyList(); List healthAdvicesNames = appointment.getHealthAdviceIds() != null ? Arrays.stream(appointment.getHealthAdviceIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> healthAdviceRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(HealthAdvice::getHealthAdviceName) .collect(Collectors.toList()) : Collections.emptyList(); List recommendedTestsNames = appointment.getCheckupFormSectionIds() != null ? Arrays.stream(appointment.getCheckupFormSectionIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> checkupFormSectionRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(CheckupFormSection::getSectionName) .collect(Collectors.toList()) : Collections.emptyList(); List recommendedTestParamsNames = appointment.getCheckupParameterIds() != null ? Arrays.stream(appointment.getCheckupParameterIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> checkupParameterRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(CheckupParameter::getParameterName) .collect(Collectors.toList()) : Collections.emptyList(); List abnormalityNames = appointment.getPrescriptionMasterIds() != null ? Arrays.stream(appointment.getPrescriptionMasterIds().split(",")) .filter(id -> !id.trim().isEmpty()) .map(Long::valueOf) .map(id -> prescriptionMasterRepo.findById(id).orElse(null)) .filter(Objects::nonNull) .map(PrescriptionMaster::getChronicIllness) .collect(Collectors.toList()) : Collections.emptyList(); String referredByName = appointment.getReferredBy() != null ? referredByRepo.findById(appointment.getReferredBy().getId()) .map(ReferredBy::getReferredBy) .orElse("Unknown") : null ; String referralName = appointment.getReferralPoint() != null ? referralPointRepo.findById(appointment.getReferralPoint().getId()) .map(ReferralPoint::getReferralPointName) .orElse("Unknown") : null ; String ohcName = appointment.getOhcType() != null ? ohcTypeRepo.findById(appointment.getOhcType().getId()) .map(OhcType::getOhcName) .orElse("Unknown") : null ; String empName = appointment.getPatient() != null ? patientRepo.findById(appointment.getPatient().getId()) .map(Patient::getPatientName) .orElse("Unknown") : null ; Map map = new LinkedHashMap<>(); map.put("id", appointment.getId()); map.put("weight", appointment.getWeight()); map.put("height", appointment.getHeight()); map.put("bmi", appointment.getBmi()); map.put("bpSbp", appointment.getBpSbp()); map.put("bpDbp", appointment.getBpDbp()); map.put("temperature", appointment.getTemperature()); map.put("respiratoryRate", appointment.getRespiratoryRate()); map.put("pulseOutput", appointment.getPulseOutput()); map.put("spo2Percent", appointment.getSpo2Percent()); map.put("glasgowComaScale", appointment.getGlasgowComaScale()); map.put("ticketNo", appointment.getTicketNo()); map.put("appointmentDate", appointment.getAppointmentDate()); map.put("appointmentType",appointment.getAppointmentType()); map.put("clearanceTime", appointment.getClearanceTime()); map.put("caseType", appointment.getCaseType()); map.put("followupToOpd", appointment.getFollowupToOpd()); map.put("referredBy", referredByName); map.put("complaints", complaintsNames); map.put("examinationRemarks", examinationRemarksNames); map.put("ailmentsNew", ailmentsNames); map.put("injuryTime", appointment.getInjuryTime()); map.put("injuryAreaCat", appointment.getInjuryAreaCat()); map.put("injuryAreaType", appointment.getInjuryAreaType()); map.put("incidentLocation", appointment.getIncidentLocation()); map.put("diseaseType", appointment.getDiseaseType()); map.put("drugAllergies", drugAllergiesNames); map.put("docComment", appointment.getDocComment()); map.put("injuryTypes", injuryTypesNames); map.put("injuryParts", injuryPartsNames); map.put("injuryClasses", injuryClassesNames); map.put("injuryMechs", injuryMechsNames); map.put("injuryProcedure", appointment.getInjuryProcedure()); map.put("anyMedication", appointment.getAnyMedication()); map.put("abnormalitys", abnormalityNames); map.put("doctorDiscussed", appointment.getDoctorDiscussed()); map.put("healthAdvices", healthAdvicesNames); map.put("recommendedTests", recommendedTestsNames); map.put("recommendedTestParams", recommendedTestParamsNames); map.put("status", appointment.getStatus()); map.put("remarksRece", appointment.getRemarksRece()); map.put("followup", appointment.getFollowup()); map.put("followupRemarks", appointment.getFollowupRemarks()); map.put("restFromTime", appointment.getRestFromTime()); map.put("restToTime", appointment.getRestToTime()); map.put("injuryRemarks", appointment.getInjuryRemarks()); map.put("referralId", referralName); map.put("referralDoc", appointment.getReferralDoc()); map.put("ambulanceUsed", appointment.getAmbulanceUsed()); map.put("dischargeTime", appointment.getDischargeTime()); map.put("empId", empName); map.put("ohcTypeId", ohcName); map.put("modifiedBy", appointment.getModifiedBy()); map.put("lastModified", appointment.getLastModified()); return map; }); Map response = PaginationUtil.getPageResponse(dtoPage); return new ResponseEntity<>(response, HttpStatus.OK); } @PostMapping public ResponseEntity> addEmployeeAppointment(@Valid @RequestBody EmployeeAppointmentDto employeeAppointmentDto) { Long userId = authServiceImpl.getCurrentUserId(); EmployeeAppointment savedAppointment = employeeAppointmentServiceImpl.addEmployeeAppointment(employeeAppointmentDto, userId); Map response = new HashMap<>(); response.put("appointmentId", savedAppointment.getId()); response.put("message", "Saved Successfully"); return new ResponseEntity<>(response, HttpStatus.CREATED); } @PutMapping("/{appointmentId}") public ResponseEntity updateEmployeeAppointment(@Valid @RequestBody EmployeeAppointmentDto employeeAppointmentDto) { Long userId = authServiceImpl.getCurrentUserId(); employeeAppointmentServiceImpl.updateEmployeeAppointment(employeeAppointmentDto, userId); return new ResponseEntity<>("Updated Successfully", HttpStatus.OK); } @DeleteMapping("/{appointmentId}") public ResponseEntity deleteEmployeeAppointment(@PathVariable Long appointmentId) { employeeAppointmentServiceImpl.deleteEmployeeAppointment(appointmentId); return new ResponseEntity<>(HttpStatus.OK); } }