@Test public void shouldInsertRnrAndItsLineItems() throws Exception { rnr.setId(1L); requisitionRepository.insert(rnr); assertThat(rnr.getStatus(), is(INITIATED)); verify(requisitionMapper).insert(rnr); verify(rnrLineItemMapper, times(2)).insert(any(RnrLineItem.class), anyString()); verify(lossesAndAdjustmentsMapper, never()).insert(any(RnrLineItem.class), any(LossesAndAdjustments.class)); verify(regimenLineItemMapper, times(1)).insert(any(RegimenLineItem.class)); RnrLineItem rnrLineItem = rnr.getFullSupplyLineItems().get(0); assertThat(rnrLineItem.getRnrId(), is(1L)); assertThat(regimenLineItem.getRnrId(), is(1L)); }
public void insert(Rnr requisition) { requisition.setStatus(INITIATED); requisitionMapper.insert(requisition); insertLineItems(requisition, requisition.getFullSupplyLineItems()); insertLineItems(requisition, requisition.getNonFullSupplyLineItems()); insertRegimenLineItems(requisition, requisition.getRegimenLineItems()); insertEquipmentStatus(requisition, requisition.getEquipmentLineItems()); }
RequisitionRepository { public void insert(Rnr requisition) { requisition.setStatus(INITIATED); requisitionMapper.insert(requisition); insertLineItems(requisition, requisition.getFullSupplyLineItems()); insertLineItems(requisition, requisition.getNonFullSupplyLineItems()); insertRegimenLineItems(requisition, requisition.getRegimenLineItems()); insertEquipmentStatus(requisition, requisition.getEquipmentLineItems()); } }
RequisitionRepository { public void insert(Rnr requisition) { requisition.setStatus(INITIATED); requisitionMapper.insert(requisition); insertLineItems(requisition, requisition.getFullSupplyLineItems()); insertLineItems(requisition, requisition.getNonFullSupplyLineItems()); insertRegimenLineItems(requisition, requisition.getRegimenLineItems()); insertEquipmentStatus(requisition, requisition.getEquipmentLineItems()); }  }
RequisitionRepository { public void insert(Rnr requisition) { requisition.setStatus(INITIATED); requisitionMapper.insert(requisition); insertLineItems(requisition, requisition.getFullSupplyLineItems()); insertLineItems(requisition, requisition.getNonFullSupplyLineItems()); insertRegimenLineItems(requisition, requisition.getRegimenLineItems()); insertEquipmentStatus(requisition, requisition.getEquipmentLineItems()); }  void insert(Rnr requisition); void insertPatientQuantificationLineItems(Rnr rnr); void update(Rnr rnr); void approve(Rnr rnr); Rnr getRequisitionWithLineItems(Facility facility, Program program, ProcessingPeriod period); Rnr getRequisitionWithoutLineItems(Long facilityId, Long programId, Long periodId); Rnr getRegularRequisitionWithLineItems(Facility facility, Program program, ProcessingPeriod period); List<Rnr> getInitiatedOrSubmittedEmergencyRequisitions(Long facilityId, Long programId); List<LossesAndAdjustmentsType> getLossesAndAdjustmentsTypes(); Rnr getById(Long rnrId); @Deprecated List<Rnr> getAuthorizedRequisitions(RoleAssignment roleAssignment); List<RnrDTO> getAuthorizedRequisitionsDTOs(RoleAssignment roleAssignment); Rnr getLastRegularRequisitionToEnterThePostSubmitFlow(Long facilityId, Long programId); List<Rnr> getPostSubmitRequisitions(Facility facility, Program program, List<ProcessingPeriod> periods); Integer getCategoryCount(Rnr requisition, boolean fullSupply); List<Comment> getCommentsByRnrID(Long rnrId); void insertComment(Comment comment); void logStatusChange(Rnr requisition, String name); Date getOperationDateFor(Long rnrId, String status); Rnr getLWById(Long rnrId); List<Rnr> getApprovedRequisitionsForCriteriaAndPageNumber(String searchType, String searchVal, Integer pageNumber,
                                                                   Integer pageSize, Long userId, String rightName, String sortBy,
                                                                   String sortDirection); Integer getCountOfApprovedRequisitionsForCriteria(String searchType, String searchVal, Long userId, String rightName); Long getFacilityId(Long id); Rnr getLastRegularRequisition(Facility facility, Program program); Date getAuthorizedDateForPreviousLineItem(Rnr rnr, String productCode, Date periodStartDate); List<RnrLineItem> getAuthorizedRegularUnSkippedLineItems(String productCode, Rnr rnr, Integer n, Date startDate); RnrLineItem getNonSkippedLineItem(Long rnrId, String productCode); Long getProgramId(Long rnrId); String deleteRnR(Long rnrId); void updateClientFields(Rnr rnr); List<Rnr> getRequisitionDetailsByFacility(Facility facility); void insertRnrSignatures(Rnr rnr); }
RequisitionRepository { public void insert(Rnr requisition) { requisition.setStatus(INITIATED); requisitionMapper.insert(requisition); insertLineItems(requisition, requisition.getFullSupplyLineItems()); insertLineItems(requisition, requisition.getNonFullSupplyLineItems()); insertRegimenLineItems(requisition, requisition.getRegimenLineItems()); insertEquipmentStatus(requisition, requisition.getEquipmentLineItems()); }  void insert(Rnr requisition); void insertPatientQuantificationLineItems(Rnr rnr); void update(Rnr rnr); void approve(Rnr rnr); Rnr getRequisitionWithLineItems(Facility facility, Program program, ProcessingPeriod period); Rnr getRequisitionWithoutLineItems(Long facilityId, Long programId, Long periodId); Rnr getRegularRequisitionWithLineItems(Facility facility, Program program, ProcessingPeriod period); List<Rnr> getInitiatedOrSubmittedEmergencyRequisitions(Long facilityId, Long programId); List<LossesAndAdjustmentsType> getLossesAndAdjustmentsTypes(); Rnr getById(Long rnrId); @Deprecated List<Rnr> getAuthorizedRequisitions(RoleAssignment roleAssignment); List<RnrDTO> getAuthorizedRequisitionsDTOs(RoleAssignment roleAssignment); Rnr getLastRegularRequisitionToEnterThePostSubmitFlow(Long facilityId, Long programId); List<Rnr> getPostSubmitRequisitions(Facility facility, Program program, List<ProcessingPeriod> periods); Integer getCategoryCount(Rnr requisition, boolean fullSupply); List<Comment> getCommentsByRnrID(Long rnrId); void insertComment(Comment comment); void logStatusChange(Rnr requisition, String name); Date getOperationDateFor(Long rnrId, String status); Rnr getLWById(Long rnrId); List<Rnr> getApprovedRequisitionsForCriteriaAndPageNumber(String searchType, String searchVal, Integer pageNumber,
                                                                   Integer pageSize, Long userId, String rightName, String sortBy,
                                                                   String sortDirection); Integer getCountOfApprovedRequisitionsForCriteria(String searchType, String searchVal, Long userId, String rightName); Long getFacilityId(Long id); Rnr getLastRegularRequisition(Facility facility, Program program); Date getAuthorizedDateForPreviousLineItem(Rnr rnr, String productCode, Date periodStartDate); List<RnrLineItem> getAuthorizedRegularUnSkippedLineItems(String productCode, Rnr rnr, Integer n, Date startDate); RnrLineItem getNonSkippedLineItem(Long rnrId, String productCode); Long getProgramId(Long rnrId); String deleteRnR(Long rnrId); void updateClientFields(Rnr rnr); List<Rnr> getRequisitionDetailsByFacility(Facility facility); void insertRnrSignatures(Rnr rnr);  }