@Test public void shouldSaveSuccess() throws Exception { when(mockRequisitionPeriodService.generateNextPeriod(anyString(), any(Date.class))).thenReturn(new Period(new DateTime("2016-12-27"), new DateTime("2017-01-20"))); RnRForm initForm = mmiaRepository.initNormalRnrForm(null); List<RegimenItem> regimenItemListWrapper = initForm.getRegimenItemListWrapper(); for (int i = 0; i < regimenItemListWrapper.size(); i++) { RegimenItem item = regimenItemListWrapper.get(i); item.setAmount((long) i); } List<BaseInfoItem> baseInfoItemListWrapper = initForm.getBaseInfoItemListWrapper(); for (int i = 0; i < baseInfoItemListWrapper.size(); i++) { BaseInfoItem item = baseInfoItemListWrapper.get(i); item.setValue(String.valueOf(i)); } mmiaRepository.createOrUpdateWithItems(initForm); List<RnRForm> list = mmiaRepository.list(); RnRForm DBForm = list.get(list.size() - 1); long expectRegimeTotal = RnRForm.calculateTotalRegimenAmount(initForm.getRegimenItemListWrapper(), MMIARegimeList.COUNTTYPE.AMOUNT); long regimenTotal = RnRForm.calculateTotalRegimenAmount(DBForm.getRegimenItemListWrapper(), MMIARegimeList.COUNTTYPE.AMOUNT); assertThat(expectRegimeTotal, is(regimenTotal)); assertThat(mmiaRepository.getTotalPatients(initForm), is(mmiaRepository.getTotalPatients(DBForm))); }
public long getTotalPatients(RnRForm form) { for (BaseInfoItem item : form.getBaseInfoItemListWrapper()) { if (ATTR_TABLE_PROPHYLAXIS_TOTAL.equals(item.getName())) { return Long.parseLong(item.getValue()); } } return 0L; }
MMIARepository extends RnrFormRepository { public long getTotalPatients(RnRForm form) { for (BaseInfoItem item : form.getBaseInfoItemListWrapper()) { if (ATTR_TABLE_PROPHYLAXIS_TOTAL.equals(item.getName())) { return Long.parseLong(item.getValue()); } } return 0L; } }
MMIARepository extends RnrFormRepository { public long getTotalPatients(RnRForm form) { for (BaseInfoItem item : form.getBaseInfoItemListWrapper()) { if (ATTR_TABLE_PROPHYLAXIS_TOTAL.equals(item.getName())) { return Long.parseLong(item.getValue()); } } return 0L; } @Inject  MMIARepository(Context context); }
MMIARepository extends RnrFormRepository { public long getTotalPatients(RnRForm form) { for (BaseInfoItem item : form.getBaseInfoItemListWrapper()) { if (ATTR_TABLE_PROPHYLAXIS_TOTAL.equals(item.getName())) { return Long.parseLong(item.getValue()); } } return 0L; } @Inject  MMIARepository(Context context); long getTotalPatients(RnRForm form); @Override List<RnrFormItem> generateRnrFormItems(RnRForm form, List<StockCard> stockCards); }
MMIARepository extends RnrFormRepository { public long getTotalPatients(RnRForm form) { for (BaseInfoItem item : form.getBaseInfoItemListWrapper()) { if (ATTR_TABLE_PROPHYLAXIS_TOTAL.equals(item.getName())) { return Long.parseLong(item.getValue()); } } return 0L; } @Inject  MMIARepository(Context context); long getTotalPatients(RnRForm form); @Override List<RnrFormItem> generateRnrFormItems(RnRForm form, List<StockCard> stockCards); @InjectResource(R.string.table_trav)
    public String ATTR_TABLE_TRAV; @InjectResource(R.string.table_trav_label_new)
    public String ATTR_TABLE_TRAV_NEW; @InjectResource(R.string.table_trav_label_maintenance)
    public String ATTR_TABLE_TRAV_MAINTENANCE; @InjectResource(R.string.table_trav_label_alteration)
    public String ATTR_TABLE_TRAV_ALTERATION; @InjectResource(R.string.table_trav_label_transit)
    public String ATTR_TABLE_TRAV_TRANSIT; @InjectResource(R.string.table_trav_label_transfers)
    public String ATTR_TABLE_TRAV_TRANSFER; @InjectResource(R.string.table_dispensed)
    public String ATTR_TABLE_DISPENSED; @InjectResource(R.string.table_dispensed_label_dt)
    public String ATTR_TABLE_DISPENSED_DT; @InjectResource(R.string.table_dispensed_label_dm)
    public String ATTR_TABLE_DISPENSED_DM; @InjectResource(R.string.table_dispensed_label_therapeutic)
    public String ATTR_TABLE_DISPENSED_THERAPEUTIC; @InjectResource(R.string.table_dispensed_label_ds)
    public String ATTR_TABLE_DISPENSED_DS; @InjectResource(R.string.table_patients)
    public String ATTR_TABLE_PATIENTS; @InjectResource(R.string.table_patients_adults)
    public String ATTR_TABLE_PATIENTS_ADULTS; @InjectResource(R.string.table_patients_0to4)
    public String ATTR_TABLE_PATIENTS_0TO4; @InjectResource(R.string.table_patients_5to9)
    public String ATTR_TABLE_PATIENTS_5TO9; @InjectResource(R.string.table_patients_10to14)
    public String ATTR_TABLE_PATIENTS_10TO14; @InjectResource(R.string.table_prophylaxis)
    public String ATTR_TABLE_PROPHYLAXIS; @InjectResource(R.string.table_prophylaxis_ppe)
    public String ATTR_TABLE_PROPHYLAXIS_PPE; @InjectResource(R.string.table_prophylaxis_prep)
    public String ATTR_TABLE_PROPHYLAXIS_PREP; @InjectResource(R.string.table_prophylaxis_child)
    public String ATTR_TABLE_PROPHYLAXIS_CHILD; @InjectResource(R.string.table_prophylaxis_total)
    public String ATTR_TABLE_PROPHYLAXIS_TOTAL; @InjectResource(R.string.mmia_1stline)
    public String ATTR_REGIME_TYPE_FIRST_LINE; @InjectResource(R.string.mmia_2ndline)
    public String ATTR_REGIME_TYPE_SECOND_LINE; @InjectResource(R.string.mmia_3rdline)
    public String ATTR_REGIME_TYPE_THIRD_LINE; @InjectResource(R.string.label_new_patients)
    public String ATTR_NEW_PATIENTS; @InjectResource(R.string.label_sustaining)
    public String ATTR_SUSTAINING; @InjectResource(R.string.label_alteration)
    public String ATTR_ALTERATION; @InjectResource(R.string.label_total_month_dispense)
    public String ATTR_TOTAL_MONTH_DISPENSE; @InjectResource(R.string.label_total_patients)
    public String ATTR_TOTAL_PATIENTS; @InjectResource(R.string.label_ptv)
    public String ATTR_PTV; @InjectResource(R.string.label_ppe)
    public String ATTR_PPE; }