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 String getSpecimenDisplayText(OrderSpecimenVo specimen, float totalRequiredVolume) { // If the specimen doesn't have any investigations then display nothing if (specimen == null || specimen.getInvestigations() == null || specimen.getInvestigations().size() == 0) return ""; StringBuilder displayText = new StringBuilder(); // Get the first investigation OrderInvestigationVo firstInvestigation = (OrderInvestigationVo) specimen.getInvestigations().get(0); // Display the service name from first investigation displayText.append(firstInvestigation.getInvestigation().getProviderService().getLocationService().getService().getServiceName()); // Display specimen type displayText.append(" (").append(firstInvestigation.getInvestigation().getPathInvDetails().getSpecimens().get(0).getType().getText()).append(") "); if (specimen.getSiteCd() != null) { displayText.append(specimen.getSiteCd().getText()); } displayText.append(" - ").append(String.valueOf(totalRequiredVolume)).append(" mls"); return displayText.toString(); }
/** * go through all the order investigations for this specimen and get each investigations helptext collection - if we find a helptext item with category set to HelpTextCategory.INSTRUCTIONSTOCOLLECTOR append the text of the item to the invest name and then to the returned string * * @param voSpecimen * @return String */ private String buildInstructionsToCollector(OrderSpecimenVo voSpecimen) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < voSpecimen.getInvestigations().size(); i++) { InvestigationUnderSpecimenVo voInvestItem = getInvestUnderSpecimenVoFromContextByOrderInvestigation(voSpecimen.getInvestigations().get(i)); if (voInvestItem != null && voInvestItem.getHelpTextIsNotNull()) { for (int p = 0; p < voInvestItem.getHelpText().size(); p++) { if (voInvestItem.getHelpText().get(p).getTextCategory().equals(HelpTextCategory.INSTRUCTIONSTOCOLLECTOR)) { sb.append(voInvestItem.getInvestigationIndex().getName() + PhlebotomyHelper.INSTRUCTION_TO_COLLECTOR + voInvestItem.getHelpText().get(p).getHelpText()); } } } } return sb.toString().length() > 0 ? sb.toString() : null; }
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 boolean choicesAvailable(HashMap<OrderSpecimenVo, HashMap<PathSpecimenContainerDetailVo, OrderInvestigationVoCollection>> alternativeContainers) { Collection<HashMap<PathSpecimenContainerDetailVo, OrderInvestigationVoCollection>> specimenMaps = alternativeContainers.values(); for (HashMap<PathSpecimenContainerDetailVo, OrderInvestigationVoCollection> specimenMap : specimenMaps) { if (specimenHasOptions(specimenMap)) return true; } return false; }
private DateTime getRequiredByDate(OrderSpecimenVo voOrderSpecimen) { if(voOrderSpecimen == null) return new DateTime(); if(SpecimenCollectionType.NOW.equals(voOrderSpecimen.getRequestedType()) || SpecimenCollectionType.PATIENT.equals(voOrderSpecimen.getRequestedType()) || SpecimenCollectionType.SPECIMEN_ALREADY_COLLECTED.equals(voOrderSpecimen.getRequestedType())) return new DateTime(); if(SpecimenCollectionType.PHLEBOTOMY_OUTPATIENT.equals(voOrderSpecimen.getRequestedType()) || SpecimenCollectionType.PHLEBOTOMY_INPATIENT.equals(voOrderSpecimen.getRequestedType()) || SpecimenCollectionType.OTHER.equals(voOrderSpecimen.getRequestedType()) || SpecimenCollectionType.SPECIMEN_COLLECTION_CLINIC.equals(voOrderSpecimen.getRequestedType())) return createDateTimeFromSpecimenWorklistItem(voOrderSpecimen.getSpecimenWorklistItem()); return new DateTime(); }
private OrderInvestigationRefVoCollection getNonDFTInvestigation(OrderSpecimenVo specimen, OrderInvestigationRefVoCollection investigationsDFT) { OrderInvestigationRefVoCollection nonDFTInvestigations = new OrderInvestigationRefVoCollection(); if (specimen.getInvestigations() != null) { for (OrderInvestigationRefVo investigation : specimen.getInvestigations()) { if (investigationsDFT == null || !investigationsDFT.contains(investigation)) nonDFTInvestigations.add(investigation); } } return nonDFTInvestigations; }
/** * 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; }
private void addOrEditSpecimenContainerChildRow(DynamicGridRow row, DynamicGrid grid, OrderInvestigationVo voOrderInvestigation, SpecimenVo specimen, boolean bProfileProcessed, boolean bUsePaediatricContainer, SpecimenContainerVo specimenContainer, Float requiredVal) { if (specimenContainer == null) { engine.showMessage("Config Error - No Container specified"); return; } // WDEV-11747 if (specimenContainer.getVolumeIsNotNull()) requiredVal = specimenContainer.getVolume(); Float containerVal = specimenContainer.getSpecContainer().getVolume(); boolean isAddNew = row.getRows().size() == 0; for (int i = 0; i < row.getRows().size(); i++) { DynamicGridRow childRow = row.getRows().get(i); DynamicGridCell specimenCell = childRow.getCells().get(grid.getColumns().getByIdentifier(SPECIMENTYPE_COLUMN)); if (specimenCell.getIdentifier() != null && ((SpecimenContainerVo)specimenCell.getIdentifier()).getSpecContainer().equals(specimenContainer.getSpecContainer())) { editChildRow(grid, requiredVal, containerVal, childRow, voOrderInvestigation, bProfileProcessed); isAddNew = false; break; } else { isAddNew = true; } } if (isAddNew == true) { addChildRow(row, grid, voOrderInvestigation, specimen, bUsePaediatricContainer, specimenContainer, containerVal, requiredVal); } // adding the orderinvestigation to the collection of // orderinvestigations for the parent(OrderSpecimen) row OrderSpecimenVo voOrderSpecimen = (OrderSpecimenVo) row.getValue(); // Test if the oder investigation is DFT // Test if the investigation OrderSpecimen collection was created if (voOrderInvestigation.getSpecimen() == null) voOrderInvestigation.setSpecimen(new OrderSpecimenRefVoCollection()); voOrderInvestigation.getSpecimen().add(voOrderSpecimen); voOrderSpecimen.getInvestigations().add(voOrderInvestigation); voOrderSpecimen.setOrder(form.getLocalContext().getOcsOrder()); row.setValue(voOrderSpecimen); // WDEV-11542 updating the total required for specimen updateSpecimenRowTotal(row, grid); }
private void updateSpecimenRowTotal(DynamicGridRow row, DynamicGrid grid) { // WDEV-12280 if (!ConfigFlag.UI.OCS_ORDERING_DISPLAY_BLOOD_VOLUMES.getValue()) return; DynamicGridCell cellHeaderDiscipline = row.getCells().get(grid.getColumns().getByIdentifier(DISCIPLINE_COLUMN)); // Get total volume required for specimen Float thisval = 0.0f; for (int i = 0; i < row.getRows().size(); i++) { DynamicGridCell cellDiscipline = row.getRows().get(i).getCells().get(grid.getColumns().getByIdentifier(DISCIPLINE_COLUMN)); thisval += (Float) cellDiscipline.getIdentifier(); } StringBuilder cellHeaderDisciplineValue = new StringBuilder(); if (row.getIdentifier() instanceof OrderInvestigationVoCollection) { OrderInvestigationVoCollection investigations = (OrderInvestigationVoCollection) row.getIdentifier(); if (investigations.size() == 1 && InvEventType.TIME_SERIES.equals(investigations.get(0).getInvestigation().getEventType())) { cellHeaderDisciplineValue.append(investigations.get(0).getInvestigation().getInvestigationIndex().getName()); } else if (cellHeaderDiscipline.getIdentifier() instanceof ServiceVo) { cellHeaderDisciplineValue.append(((ServiceVo) cellHeaderDiscipline.getIdentifier()).getServiceName()); } } DynamicGridCell cellSpecimenType = row.getCells().get(grid.getColumns().getByIdentifier(SPECIMENTYPE_COLUMN)); if (cellSpecimenType.getIdentifier() instanceof SpecimenType) { cellHeaderDisciplineValue.append(" (").append(((SpecimenType) cellSpecimenType.getIdentifier()).getText()).append(") "); } if (row.getValue() instanceof OrderSpecimenVo) { OrderSpecimenVo orderSpecimen = (OrderSpecimenVo) row.getValue(); if (orderSpecimen.getSiteCd() != null) { cellHeaderDisciplineValue.append(" ").append(orderSpecimen.getSiteCd().getText()); } } cellHeaderDisciplineValue.append(" - ").append(thisval).append(" mls"); cellHeaderDiscipline.setValue(cellHeaderDisciplineValue.toString()); }
/** * 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); }
public SpecimenWorkListItemListVo saveWorkListItemRecord(SpecimenWorkListItemVo record, OrderSpecimenVo specimenVo) throws StaleObjectException { DomainFactory factory = getDomainFactory(); SpecimenWorkListItem newBo = null; SpecimenWorkListItem bo = SpecimenWorkListItemVoAssembler.extractSpecimenWorkListItem(factory, record); bo.getSpecimen().setCollectorComment(specimenVo.getCollectorComment()); if(record.getCollectionStatus().equals(SpecimenCollectionStatus.COULDNOTCOLLECT)) { SpecimenWorkListItemVo newItem = new SpecimenWorkListItemVo(); newItem.setListType(SpecimenCollectionMethod.WARDCOLLECTION); newItem.setDateToCollect(new Date()); newItem.setTimeToCollect(new Time()); newItem.setCollectionStatus(SpecimenCollectionStatus.PHLEBCOULDNOTCOLLECT); newBo = SpecimenWorkListItemVoAssembler.extractSpecimenWorkListItem(factory, newItem); newBo.setSpecimen(bo.getSpecimen()); } else if(record.getCollectionStatus().equals(SpecimenCollectionStatus.COLLECTIONCOMPLETE)) { bo.getSpecimen().setCollDateTimePlacer(specimenVo.getCollDateTimePlacer().getJavaDate()); bo.getSpecimen().setCollectingMos((MemberOfStaff) factory.getDomainObject(MemberOfStaff.class, specimenVo.getCollectingMos().getID_MemberOfStaff())); java.util.Set investigations = bo.getSpecimen().getInvestigations(); for (java.util.Iterator iter = investigations.iterator(); iter.hasNext();) { Object obj = iter.next(); if (obj instanceof OrderInvestigation) { OrderInvestigation element = (OrderInvestigation) obj; element.setDisplayDateTime(bo.getSpecimen().getCollDateTimePlacer()); element.setDisplayFlag(getDomLookup(OcsDisplayFlag.SPEC_COLL)); } } } factory.save(bo); if(newBo != null) factory.save(newBo); return SpecimenWorkListItemListVoAssembler.create(bo); }
public OrderSpecimenVo getSpecimentRecord(OrderSpecimenRefVo refId) { return OrderSpecimenVoAssembler.create( (OrderSpecimen)getDomainFactory().getDomainObject(OrderSpecimen.class, refId.getID_OrderSpecimen())); }