use of org.motechproject.mots.domain.enums.Language in project mots by motech-implementations.
the class CommunityHealthWorkerService method saveHealthWorker.
/**
* Update CHW and IVR Subscriber.
* @param chw CHW to update
* @return saved CHW
*/
@PreAuthorize(RoleNames.HAS_CHW_WRITE_ROLE)
public CommunityHealthWorker saveHealthWorker(CommunityHealthWorker chw) {
String ivrId = chw.getIvrId();
String phoneNumber = chw.getPhoneNumber();
String name = chw.getCombinedName();
Language preferredLanguage = chw.getPreferredLanguage();
try {
ivrService.updateSubscriber(ivrId, phoneNumber, name, preferredLanguage);
} catch (IvrException ex) {
String message = "Could not update CHW, because of IVR subscriber update error. \n\n" + ex.getClearVotoInfo();
throw new ChwException(message, ex);
}
return healthWorkerRepository.save(chw);
}
use of org.motechproject.mots.domain.enums.Language in project mots by motech-implementations.
the class CommunityHealthWorkerService method selectHealthWorker.
/**
* Select CHW, create IVR Subscriber and assign it to CHW. Initiate empty AssignedModules
* instance for selected CHW.
* @param healthWorker CHW to be selected
* @return saved CHW
*/
@PreAuthorize(RoleNames.HAS_CHW_WRITE_ROLE)
public CommunityHealthWorker selectHealthWorker(CommunityHealthWorker healthWorker) {
if (healthWorker.getSelected()) {
throw new ChwException("Could not select CHW, because already selected");
}
healthWorker.setSelected(true);
String phoneNumber = healthWorker.getPhoneNumber();
String name = healthWorker.getCombinedName();
Language preferredLanguage = healthWorker.getPreferredLanguage();
try {
String ivrId = ivrService.createSubscriber(phoneNumber, name, preferredLanguage);
healthWorker.setIvrId(ivrId);
} catch (IvrException ex) {
String message = "Could not select CHW, because of IVR subscriber creation error. \n\n" + ex.getClearVotoInfo();
throw new ChwException(message, ex);
}
healthWorkerRepository.save(healthWorker);
AssignedModules emptyAssignedModulesInstance = new AssignedModules(healthWorker);
assignedModulesRepository.save(emptyAssignedModulesInstance);
return healthWorker;
}
Aggregations