emr_demo
@ 2
emr_demo / web_emr - Copy / src / main / java / com / bestray / security / service / FacilityMasterService.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
package com.bestray.security.service; import java.util.Optional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.bestray.model.security.DepartmentMaster; import com.bestray.model.security.PharmacyMaster; import com.bestray.model.security.SpecialityMaster; import com.bestray.model.security.User; import com.bestray.security.controller.ExceptionHandler_delete; import com.bestray.security.controller.ExceptionHandler_update; import com.bestray.security.repository.DepartmentRepository; import com.bestray.security.repository.PharmacyRepository; import com.bestray.security.repository.SpecialityRepository; @Service public class FacilityMasterService { @Autowired private SpecialityRepository specialityRepository; @Autowired private DepartmentRepository departmentRepository; @Autowired private PharmacyRepository pharmacyRepository; //save public void saveDepartment(DepartmentMaster departmentMaster) throws ExceptionHandler_update { String dept_name=departmentMaster.getDepartmentName(); DepartmentMaster userExists =departmentRepository.findByDepartmentName(dept_name); System.out.println("1@@@>"+dept_name); if (userExists != null) { throw new ExceptionHandler_update(); }else{ departmentMaster.setEnabled(true); departmentRepository.save(departmentMaster); System.out.println("2@@@@@"); } } //edit public void editDepartment(DepartmentMaster departmentMaster,String id) throws ExceptionHandler_update { Optional<DepartmentMaster> userExists =departmentRepository.findById(id); if (userExists.isPresent()){ DepartmentMaster dept_new = userExists.get(); if (dept_new != null) { dept_new.setDepartmentName(departmentMaster.getDepartmentName()); dept_new.setDepartmentAddress(departmentMaster.getDepartmentAddress()); dept_new.setDepartmentphoneno(departmentMaster.getDepartmentphoneno()); dept_new.setDepartmentZipcode(departmentMaster.getDepartmentZipcode()); departmentRepository.save(dept_new); System.out.println("2@@@@@"); }else{ throw new ExceptionHandler_update(); } } } //delete public void deleteDepartment(String id) throws ExceptionHandler_delete { Optional<DepartmentMaster> userExists =departmentRepository.findById(id); if (userExists.isPresent()) { DepartmentMaster dept_new = userExists.get(); if(dept_new!=null){ dept_new.setEnabled(false); departmentRepository.save(dept_new); }else{ throw new ExceptionHandler_delete(); } } } //saveSpeciality public void saveSpeciality(SpecialityMaster speciality) throws ExceptionHandler_update { String speciality_name=speciality.getSpecialityName(); SpecialityMaster userExists =specialityRepository.findBySpecialityName(speciality_name); System.out.println("1@@@@@@@@"+speciality_name); System.out.println("2@@@@@"+userExists); if (userExists != null) { System.out.println("4@@@@@"); throw new ExceptionHandler_update(); }else{ speciality.setEnabled(true); System.out.println("3@@@@@"); specialityRepository.save(speciality); } } //editSpeciality public void editSpeciality(SpecialityMaster speciality,String id) throws ExceptionHandler_update { Optional<SpecialityMaster> userExists =specialityRepository.findById(id); if (userExists.isPresent()){ SpecialityMaster spec_new = userExists.get(); if (spec_new != null) { spec_new.setSpecialityName(speciality.getSpecialityName()); specialityRepository.save(spec_new); System.out.println("2@@@@@"); }else{ throw new ExceptionHandler_update(); } } } //deleteSpeciality public void daleteSpeciality(String id) throws ExceptionHandler_delete { Optional<SpecialityMaster> userExists =specialityRepository.findById(id); if (userExists.isPresent()) { SpecialityMaster spec_new = userExists.get(); if(spec_new!=null){ spec_new.setEnabled(false); specialityRepository.save(spec_new); }else{ throw new ExceptionHandler_delete(); } } } //savePharmacy public void savePharmacy(PharmacyMaster pharmacyMaster) throws ExceptionHandler_update { String pharmacy_new=pharmacyMaster.getPharmacyName(); PharmacyMaster userExists =pharmacyRepository.findByPharmacyName(pharmacy_new); System.out.println("1@@@>"+pharmacy_new); if (userExists != null) { throw new ExceptionHandler_update(); }else{ pharmacyMaster.setEnabled(true); pharmacyRepository.save(pharmacyMaster); System.out.println("2@@@@@"); } } //editPharmacy public void editPharmacy(PharmacyMaster pharmacyMaster,String id) throws ExceptionHandler_update { Optional<PharmacyMaster> userExists =pharmacyRepository.findById(id); if (userExists.isPresent()){ PharmacyMaster pharmacy_new = userExists.get(); if (pharmacy_new != null) { pharmacy_new.setPharmacyName(pharmacyMaster.getPharmacyName()); pharmacy_new.setPharmacyAddress(pharmacyMaster.getPharmacyAddress()); pharmacy_new.setPharmacyPhonenumber(pharmacyMaster.getPharmacyPhonenumber()); pharmacy_new.setPharmacyZipcode(pharmacyMaster.getPharmacyZipcode()); pharmacyRepository.save(pharmacy_new); System.out.println("2@@@@@"); }else{ throw new ExceptionHandler_update(); } } } //deletePharmacy public void daletePharmacy(String id) throws ExceptionHandler_delete { Optional<PharmacyMaster> userExists =pharmacyRepository.findById(id); if (userExists.isPresent()) { PharmacyMaster pharmacy_new = userExists.get(); if(pharmacy_new!=null){ pharmacy_new.setEnabled(false); pharmacyRepository.save(pharmacy_new); }else{ throw new ExceptionHandler_delete(); } } } } |
Commits for emr_demo/web_emr - Copy/src/main/java/com/bestray/security/service/FacilityMasterService.java
Revision | Author | Commited | Message |
---|---|---|---|
2 | girijabapi | Thu 11 Oct, 2018 04:44:08 +0000 | initial commit |