private void open() { OrderSpecimenVoCollection potentialSpecimens = form.getGlobalContext().OCRR.getMyOrderPotentialSpecimens(); // Sort potential specimens potentialSpecimens.sort(); // Build alternative containers hash map HashMap<OrderSpecimenVo, HashMap<PathSpecimenContainerDetailVo, OrderInvestigationVoCollection>> alternativeContainers = buildHashMapOfAlternativeContainers(potentialSpecimens); // Check for alternative options if (!choicesAvailable(alternativeContainers)) { engine.close(DialogResult.CANCEL); return; } populateSpecimensWithAlternateContainers(potentialSpecimens, alternativeContainers); }
private void populateSpecimensWithAlternateContainers(OrderSpecimenVoCollection potentialSpecimens, HashMap<OrderSpecimenVo, HashMap<PathSpecimenContainerDetailVo, OrderInvestigationVoCollection>> alternativeContainers) { // Clear grid form.grdItems().getRows().clear(); if (potentialSpecimens == null) return; for (OrderSpecimenVo specimen : potentialSpecimens) { HashMap<PathSpecimenContainerDetailVo, OrderInvestigationVoCollection> specimenAlternateContainers = alternativeContainers.get(specimen); if (specimenHasOptions(specimenAlternateContainers)) { // Create Specimen parent row grdItemsRow specimenRow = form.grdItems().getRows().newRow(); // Add investigation rows float totalRequiredVolume = addInvestigationsWithAlternates(specimen.getInvestigations(), specimenRow, specimenAlternateContainers); // Set specimen text specimenRow.setColText(getSpecimenDisplayText(specimen, totalRequiredVolume)); // Expand Specimen parent row specimenRow.setExpanded(true); } } }
private void populateSpecimenInstanceData(OcsOrderVo voOcsOrder) { OrderSpecimenVoCollection voCollSpecimen = new OrderSpecimenVoCollection(); populateSpecimenInstanceDataFromGrid(voOcsOrder, form.lyrDetails().tabPathDetails().lyrPathology().tabNow().dyngrdNow(), voCollSpecimen); populateSpecimenInstanceDataFromGrid(voOcsOrder, form.lyrDetails().tabPathDetails().lyrPathology().tabPatient().dyngrdPatient(), voCollSpecimen); populateSpecimenInstanceDataFromGrid(voOcsOrder, form.lyrDetails().tabPathDetails().lyrPathology().tabOther().dyngrdOther(), voCollSpecimen); populateSpecimenInstanceDataFromGrid(voOcsOrder, form.lyrDetails().tabPathDetails().lyrPathology().tabPhlebotomy().dyngrdInpat(), voCollSpecimen); populateSpecimenInstanceDataFromGrid(voOcsOrder, form.lyrDetails().tabPathDetails().lyrPathology().tabPhlebotomy().dyngrdOutPat(), voCollSpecimen); populateSpecimenInstanceDataFromGrid(voOcsOrder, form.lyrDetails().tabPathDetails().lyrPathology().tabSpecAlreadyCollected().dyngrdSpecAlreadyCollected(), voCollSpecimen); voOcsOrder.setSpecimens(voCollSpecimen); }
/** * Build a hash map with OderSpecimen as key, configured SpecimenContainer as secondary key, and OrderInvestigation collection as values * * Instead of comparing every specimen container from every investigation with every specimen from other investigations, build a hash map with OrderSpecimen primary key, * SpecimenContainer secondary key and add all investigations from an OrderSpecimen that have SpecimenContainer configured. If there are more than one investigation * in the collection, then that SpecimenContainer is common to more than one investigation for the OrderSpecimen */ private HashMap<OrderSpecimenVo, HashMap<PathSpecimenContainerDetailVo, OrderInvestigationVoCollection>> buildHashMapOfAlternativeContainers(OrderSpecimenVoCollection myOrderPotentialSpecimens) { if (myOrderPotentialSpecimens == null || myOrderPotentialSpecimens.size() == 0) return null; HashMap<OrderSpecimenVo, HashMap<PathSpecimenContainerDetailVo, OrderInvestigationVoCollection>> generalAlternativeContainers = new HashMap<OrderSpecimenVo, HashMap<PathSpecimenContainerDetailVo,OrderInvestigationVoCollection>>(); for (OrderSpecimenVo specimen : myOrderPotentialSpecimens) { HashMap<PathSpecimenContainerDetailVo, OrderInvestigationVoCollection> specimenAlternativeContainers = new HashMap<PathSpecimenContainerDetailVo, OrderInvestigationVoCollection>(); for (int i = 0; i < specimen.getInvestigations().size(); i++) { OrderInvestigationVo investigation = (OrderInvestigationVo) specimen.getInvestigations().get(i); // Unsafe upcast due to performance reasons PathInvDetailsVo pathologyDetails = null; if (investigation.getInvestigation().getParentInvestigationPathDetails() != null) { pathologyDetails = investigation.getInvestigation().getParentInvestigationPathDetails(); } else { pathologyDetails = investigation.getInvestigation().getPathInvDetails(); } SpecimenVo specimenVo = pathologyDetails.getSpecimens().get(0); PathSpecimenContainerDetailVo pediatricContainer = specimenVo.getPaediatricContainers().get(0).getSpecContainer(); addSpecimenInvestigationToMap(specimenAlternativeContainers, investigation, pediatricContainer); for (SpecimenContainerVo containers : specimenVo.getAlternativePaediatricContainers()) { addSpecimenInvestigationToMap(specimenAlternativeContainers, investigation, containers.getSpecContainer()); } } generalAlternativeContainers.put(specimen, specimenAlternativeContainers); } return generalAlternativeContainers; }
/** * Remove OrderSpecimens from OrderInvestigation created in error for DFT * @param state */ private void clearOrderSpecimensFromOrderInvestigationsDFT(OcsOrderVo ocsOrder, ORDERSTATE state) { OrderSpecimenVoCollection specimens = new OrderSpecimenVoCollection(); OrderInvestigationRefVoCollection investigationsDFT = new OrderInvestigationRefVoCollection(); for (OrderInvestigationVo investigation : ocsOrder.getInvestigations()) { if (InvEventType.TIME_SERIES.equals(investigation.getInvestigation().getEventType())) { investigation.setSpecimen(null); investigationsDFT.add(investigation); // Do not change the status of Cancelled or Cancel Requests orders if (investigation.getOrdInvCurrentStatus() == null || (!OrderInvStatus.CANCEL_REQUEST.equals(investigation.getOrdInvCurrentStatus().getOrdInvStatus()) && !OrderInvStatus.CANCELLED.equals(investigation.getOrdInvCurrentStatus().getOrdInvStatus()))) { // Set status as requested if (ORDERSTATE.AUTHORISING.equals(state)) { investigation.getOrdInvCurrentStatus().setOrdInvStatus(OrderInvStatus.ORDERED); investigation.setDisplayFlag(OcsDisplayFlag.REQUESTED); } else { investigation.getOrdInvCurrentStatus().setOrdInvStatus(OrderInvStatus.AWAITING_AUTHORISATION); investigation.setDisplayFlag(OcsDisplayFlag.REQUESTED); } } } } for (OrderSpecimenVo specimen : ocsOrder.getSpecimens()) { OrderInvestigationRefVoCollection investigationNonDFT = getNonDFTInvestigation(specimen, investigationsDFT); if (investigationNonDFT != null && investigationNonDFT.size() > 0) { specimen.setInvestigations(investigationNonDFT); specimens.add(specimen); } } ocsOrder.setSpecimens(specimens); }