コード例 #1
0
  private void fillPreviousNCsInLineItems(
      Rnr requisition, Integer numberOfMonths, Date trackingDate) {
    if (numberOfMonths >= 3 && !(requisition.isEmergency() || requisition.isForVirtualFacility())) {
      return;
    }

    for (RnrLineItem lineItem : requisition.getFullSupplyLineItems()) {
      List<RnrLineItem> previousLineItems =
          requisitionRepository.getAuthorizedRegularUnSkippedLineItems(
              lineItem.getProductCode(),
              requisition,
              getNumberOfPreviousNCToTrack(numberOfMonths),
              trackingDate);
      List<Integer> nNormalizedConsumptions =
          (List<Integer>)
              collect(
                  previousLineItems,
                  new Transformer() {
                    @Override
                    public Object transform(Object o) {
                      return ((RnrLineItem) o).getNormalizedConsumption();
                    }
                  });
      lineItem.setPreviousNormalizedConsumptions(nNormalizedConsumptions);
    }
  }
コード例 #2
0
  private void calculateForNonFullSupply(Rnr requisition) {
    for (RnrLineItem lineItem : requisition.getNonFullSupplyLineItems()) {
      lineItem.validateNonFullSupply();

      lineItem.calculatePacksToShip();

      requisition.addToNonFullSupplyCost(lineItem.calculateCost());
    }
  }
コード例 #3
0
  private void calculateForFullSupply(Rnr requisition, ProgramRnrTemplate template) {
    List<LossesAndAdjustmentsType> lossesAndAdjustmentsTypes =
        requisitionRepository.getLossesAndAdjustmentsTypes();

    for (RnrLineItem lineItem : requisition.getNonSkippedLineItems()) {

      lineItem.validateMandatoryFields(template);
      lineItem.calculateForFullSupply(template, requisition.getStatus(), lossesAndAdjustmentsTypes);
      lineItem.validateCalculatedFields(template);

      requisition.addToFullSupplyCost(lineItem.calculateCost());
    }
  }
コード例 #4
0
  public void fillReportingDays(Rnr requisition) {
    Date startDate = requisition.getPeriod().getStartDate();
    Integer numberOfMonths = requisition.getPeriod().getNumberOfMonths();

    List<ProcessingPeriod> twoPreviousPeriods =
        processingScheduleService.getNPreviousPeriodsInDescOrder(requisition.getPeriod(), 2);

    if (twoPreviousPeriods.size() != 0) {
      numberOfMonths = twoPreviousPeriods.get(0).getNumberOfMonths();
      startDate =
          (numberOfMonths < 3 && twoPreviousPeriods.size() != 1)
              ? twoPreviousPeriods.get(1).getStartDate()
              : twoPreviousPeriods.get(0).getStartDate();
    }

    for (RnrLineItem lineItem : requisition.getNonSkippedLineItems()) {
      Integer reportingDays =
          getReportingDaysBasedOnRequisition(
              requisition, lineItem.getProductCode(), startDate, numberOfMonths);
      lineItem.setReportingDays(reportingDays);
    }
  }
コード例 #5
0
        @Override
        public RnrLineItem instantiate(PropertyLookup<RnrLineItem> lookup) {
          RnrLineItem rnrLineItem = new RnrLineItem();
          rnrLineItem.setProductCode(lookup.valueOf(productCode, PRODUCT_CODE));
          rnrLineItem.setProductCategory(lookup.valueOf(productCategory, PRODUCT_CATEGORY));
          rnrLineItem.setBeginningBalance(
              lookup.valueOf(beginningBalance, DEFAULT_BEGINNING_BALANCE));
          rnrLineItem.setQuantityReceived(lookup.valueOf(quantityReceived, QUANTITY_RECEIVED));

          rnrLineItem.addLossesAndAdjustments(lookup.valueOf(lossesAndAdjustments, ONE_LOSS));
          rnrLineItem.setTotalLossesAndAdjustments(
              lookup.valueOf(totalLossesAndAdjustments, TOTAL_LOSSES_AND_ADJUSTMENTS));
          rnrLineItem.setStockInHand(lookup.valueOf(stockInHand, DEFAULT_STOCK_IN_HAND));
          rnrLineItem.setQuantityDispensed(
              lookup.valueOf(quantityDispensed, DEFAULT_QUANTITY_DISPENSED));

          rnrLineItem.setDispensingUnit("tablet");
          rnrLineItem.setMaxMonthsOfStock(1);
          rnrLineItem.setPrice(new Money("2"));
          rnrLineItem.setQuantityApproved(lookup.valueOf(quantityApproved, QUANTITY_APPROVED));

          rnrLineItem.setFullSupply(lookup.valueOf(fullSupply, true));
          rnrLineItem.setStockOutDays(lookup.valueOf(stockOutDays, STOCK_OUT_DAYS));
          rnrLineItem.setNewPatientCount(lookup.valueOf(newPatientCount, NEW_PATIENT_COUNT));
          rnrLineItem.setDosesPerMonth(30);
          rnrLineItem.setDosesPerDispensingUnit(10);
          rnrLineItem.setNormalizedConsumption(37);
          rnrLineItem.setAmc(37);
          rnrLineItem.setMaxMonthsOfStock(2);
          rnrLineItem.setMaxStockQuantity(74);
          rnrLineItem.setCalculatedOrderQuantity(70);
          rnrLineItem.setPackSize(lookup.valueOf(packSize, 6));
          rnrLineItem.setPacksToShip(12);
          rnrLineItem.setPackRoundingThreshold(lookup.valueOf(packRoundingThreshold, 3));
          rnrLineItem.setRoundToZero(lookup.valueOf(roundToZero, ROUND_To_ZERO));
          rnrLineItem.setPrice(new Money("4"));
          rnrLineItem.setQuantityRequested(lookup.valueOf(quantityRequested, QUANTITY_REQUESTED));
          rnrLineItem.setReasonForRequestedQuantity(
              lookup.valueOf(reasonForRequestedQuantity, REASON_FOR_REQUESTED_QUANTITY));
          rnrLineItem.setPacksToShip(lookup.valueOf(packsToShip, PACKS_TO_SHIP));
          rnrLineItem.setRemarks(lookup.valueOf(remarks, REMARKS));
          rnrLineItem.setProductCategoryDisplayOrder(
              lookup.valueOf(productCategoryDisplayOrder, PRODUCT_CATEGORY_DISPLAY_ORDER));
          rnrLineItem.setProductDisplayOrder(
              lookup.valueOf(productDisplayOrder, PRODUCT_DISPLAY_ORDER));
          rnrLineItem.setSkipped(lookup.valueOf(skipped, SKIPPED));
          return rnrLineItem;
        }