public void createBeneficiary(StepsovcCase stepsovcCase) { logger.info("Handling beneficiary registration for " + stepsovcCase.getBeneficiary_name()); Beneficiary oldBeneficiary = allBeneficiaries.findBeneficiaryByCode(stepsovcCase.getBeneficiary_code()); if (oldBeneficiary == null) allBeneficiaries.add(new BeneficiaryMapper().map(stepsovcCase)); else { logger.error( "Updating as Beneficiary already present in database, " + stepsovcCase.getBeneficiary_code()); allBeneficiaries.remove(oldBeneficiary); allBeneficiaries.add(new BeneficiaryMapper().map(stepsovcCase)); } }
public String getBeneficiaryId(String beneficiaryCode) { Beneficiary beneficiary = allBeneficiaries.findBeneficiaryByCode(beneficiaryCode); if (beneficiary == null) { throw new BeneficiaryNotFoundException(beneficiaryCode); } return beneficiary.getCaseId(); }
public void addGroupOwnership(StepsovcCase stepsovcCase) { Beneficiary beneficiary = allBeneficiaries.findBeneficiaryByCode(stepsovcCase.getBeneficiary_code()); if (beneficiary != null) { commcareGateway.addGroupOwnership( populateBeneficiaryCase(stepsovcCase, beneficiary), stepsovcCase.getFacility_code()); } }
public void addUserOwnership(StepsovcCase stepsovcCase) { Beneficiary beneficiary = allBeneficiaries.findBeneficiaryByCode(stepsovcCase.getBeneficiary_code()); Caregiver caregiver = allCaregivers.findCaregiverByCode(stepsovcCase.getCaregiver_code()); if (beneficiary != null && caregiver != null) { commcareGateway.addUserOwnership( populateBeneficiaryCase(stepsovcCase, beneficiary), caregiver.getCgId()); } }
public boolean beneficiaryExists(String beneficiaryCode) { return allBeneficiaries.findBeneficiaryByCode(beneficiaryCode) != null; }