コード例 #1
0
  public void addGroupOwnership(StepsovcCase stepsovcCase) {
    Beneficiary beneficiary =
        allBeneficiaries.findBeneficiaryByCode(stepsovcCase.getBeneficiary_code());

    if (beneficiary != null) {
      commcareGateway.addGroupOwnership(
          populateBeneficiaryCase(stepsovcCase, beneficiary), stepsovcCase.getFacility_code());
    }
  }
コード例 #2
0
  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());
    }
  }
コード例 #3
0
  private CaseOwnershipInformation populateBeneficiaryCase(
      StepsovcCase stepsovcCase, Beneficiary beneficiary) {
    stepsovcCase.setCaregiver_code(beneficiary.getCaregiverCode());
    stepsovcCase.setCase_id(beneficiary.getCaseId());

    Caregiver caregiver = allCaregivers.findCaregiverByCode(beneficiary.getCaregiverCode());
    stepsovcCase.setCaregiver_name(caregiver.getFirstName());
    stepsovcCase.setUser_id(caregiver.getCgId());
    stepsovcCase.setOwner_id(caregiver.getCgId());

    return new BeneficiaryMapper().createOwnershipInfo(stepsovcCase);
  }
コード例 #4
0
  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));
    }
  }