public SpecimenType getFirstSpecimenTypeForResultSpecimenType(ResultSpecimenTypes resultSpecimenType) { if (resultSpecimenType==null) return null; DomainFactory factory = getDomainFactory(); String query = "select rst.specimenType from ResultSpecimenTypes as rst left join rst.alternateSpecimenTypes as ast left join ast.instance as ins left join rst.specimenType as l3_1"; query+=" where ins.id = :type"; List<?> list =factory.find(query,new String[]{"type"},new Object[]{resultSpecimenType.getID()}); if (list!=null && list.size()>0) { LookupInstance li=(LookupInstance)list.get(0); return new SpecimenType(li.getId(),li.getText(),li.isActive()); } return null; }
private IfOrderInvestigationVo populatePATHInvestigationVoFromOBR(OBR obr, String sendingApplication, IfOrderSpecimenVo specimen, HashMap<String, Object> fillerSpecimens, IfOrderSpecimenVoCollection specColl, ProviderSystemVo providerSystem,boolean isResultMessage) throws Exception { IfOrderInvestigationVo orderInvVo = new IfOrderInvestigationVo(); String providerInvCode = obr.getUniversalServiceIdentifier().getIdentifier().getValue(); // wdev-5526 - method created and called from here now IfInvestigationLiteVo invVo = getInvestigation(obr, sendingApplication, providerSystem, providerInvCode,true,isResultMessage); if (invVo == null) throw new HL7Exception("Investigation not found for provider system and providerInvCode = " + providerInvCode); fillPATHInvestigationFromOBR(orderInvVo, obr, invVo,providerSystem); // OBR-27 Quantity/timing // wdev-2746 - If obr-27 is not populated, we can check obr-5 String priority = obr.getQuantityTiming(0).getPriority().getValue(); if (priority == null) priority = obr.getPriority().getValue(); if (priority != null) { orderInvVo.setOrderPriority((OrderPriority) svc.getLocalLookup(OrderPriority.class, OrderPriority.TYPE_ID, providerSystem.getCodeSystem().getText(), priority)); } orderInvVo.setWasOrdered(Boolean.FALSE); // Specimens only for Pathology orders // OBR-3 Filler order number // WDEV-1354 // We hold onto the specimens for each fillerOrderNumber in case // the same specimen is required again String fillerOrderNum = obr.getFillerOrderNumber().getEntityIdentifier().getValue(); if (fillerSpecimens.containsKey(fillerOrderNum)&&!ConfigFlag.HL7.UNSOLICTED_NEW_SPECIMEN_PER_INVESTIGATION.getValue()) specimen = (IfOrderSpecimenVo) fillerSpecimens.get(fillerOrderNum); else { specimen = new IfOrderSpecimenVo(); populateSpecimenVoFromOBR(specimen, orderInvVo.getInvestigation(), obr,providerSystem); specimen.getInvestigations(); if(InvEventType.TIME_SERIES.equals(orderInvVo.getInvestigation().getEventType())) { specimen.setWasProcessed(true); // specimen.setPlacerOrdNum(value); } if(!specimen.getInvestigationsIsNotNull()) { specimen.setInvestigations(new IfOrderInvestigationVoCollection()); } specimen.getInvestigations().add(orderInvVo); specColl.add(specimen); if (!fillerSpecimens.containsKey(specimen.getFillerOrdNum())) { fillerSpecimens.put(specimen.getFillerOrdNum(), specimen); } } if(orderInvVo.getSpecimen()==null&&!ConfigFlag.HL7.UNSOLICTED_NEW_SPECIMEN_PER_INVESTIGATION.getValue()) { orderInvVo.setSpecimen(specColl); } else { orderInvVo.setSpecimen(new IfOrderSpecimenVoCollection()); orderInvVo.getSpecimen().add(specimen); } //WDEV-15552 SPS sps = obr.getSpecimenSource(); LookupInstVo resultSpecimenSource=svc.getLocalLookup(LookupInstVo.class, ResultSpecimenTypes.TYPE_ID, providerSystem.getCodeSystem().getText(), sps.getSpecimenSourceNameOrCode().getIdentifier().getValue().trim()); orderInvVo.setResultSpecimenType(resultSpecimenSource); return orderInvVo; }
private void fillPATHInvestigationFromOBR(IfOrderInvestigationVo invVo, OBR obr, IfInvestigationLiteVo cfgInv,ProviderSystemVo providerSystem) throws Exception { LOG.debug("R01VoMapper fillPATHInvestigationFromOBR: entry"); invVo.setInvestigation(cfgInv); invVo.setFillerOrdNum(obr.getFillerOrderNumber().getEntityIdentifier().getValue()); invVo.setResultStatus((ResultStatus) svc.getLocalLookup(ResultStatus.class, ResultStatus.TYPE_ID, providerSystem.getCodeSystem().getText(), obr.getResultStatus().getValue())); //http://jira/browse/WDEV-15552 SPS sps = obr.getSpecimenSource(); LookupInstVo resultSpecimenSource=svc.getLocalLookup(LookupInstVo.class, ResultSpecimenTypes.TYPE_ID, providerSystem.getCodeSystem().getText(), sps.getSpecimenSourceNameOrCode().getIdentifier().getValue().trim()); invVo.setResultSpecimenType(resultSpecimenSource); //End http://jira/browse/WDEV-15552 // wdev-2746 ResultStatus must map to a valid lookup value if (obr.getResultStatus().getValue() != null && !invVo.getResultStatusIsNotNull()) throw new HL7Exception("ResultStatus (OBR-25) does not map to a valid local lookup (ResultStatus) - Message Rejected"); if (obr.getRequestedDateTime() != null && obr.getRequestedDateTime().getTimeOfAnEvent().getValue() != null) { invVo.setDisplayDateTime(populateDateTimeVoFromTS(obr.getRequestedDateTime())); invVo.setDisplayTimeSupplied( Boolean.valueOf(isTimeSupplied(obr.getRequestedDateTime()))); invVo.setDisplayFlag(OcsDisplayFlag.REQUESTED); } if (obr.getResultsRptStatusChngDateTime() != null && obr.getResultsRptStatusChngDateTime().getTimeOfAnEvent().getValue() != null) { DateTime dt = populateDateTimeVoFromTS(obr.getResultsRptStatusChngDateTime()); //JME: 20061205: Change to handle WinPath sending 189912300000 in OBR.22 instead of a null date/time if (!dt.equals(new DateTime("189912300000"))) { invVo.setDisplayDateTime(dt); invVo.setRepDateTime(dt); invVo.setResultSortDate(dt);//http://jira/browse/WDEV-18025 invVo.setRepTimeSupplied( Boolean.valueOf(isTimeSupplied(obr.getResultsRptStatusChngDateTime()))); invVo.setDisplayFlag(OcsDisplayFlag.REPORTED); invVo.setDisplayTimeSupplied(invVo.getRepTimeSupplied()); } } if (obr.getSpecimenReceivedDateTime() != null && obr.getSpecimenReceivedDateTime().getTimeOfAnEvent().getValue() != null) { invVo.setDisplayDateTime(populateDateTimeVoFromTS(obr.getSpecimenReceivedDateTime())); invVo.setDisplayFlag(OcsDisplayFlag.SPEC_RECVD); invVo.setDisplayTimeSupplied( Boolean.valueOf(isTimeSupplied(obr.getSpecimenReceivedDateTime()))); // WDEV-16384 - Check if expected turnaround values configured. If they are, calculated the expected result datetime invVo.setExpectedDateTime(ocsIfInbound.calculateExpectedDateTime(invVo.getInvestigation(), invVo.getDisplayDateTime())); } if (obr.getObservationDateTime() != null && obr.getObservationDateTime().getTimeOfAnEvent().getValue() != null) { invVo.setDisplayDateTime(populateDateTimeVoFromTS(obr.getObservationDateTime())); invVo.setDisplayFlag(OcsDisplayFlag.SPEC_COLL); invVo.setDisplayTimeSupplied( Boolean.valueOf(isTimeSupplied(obr.getObservationDateTime()))); } /* * etc investVo.setOrderPriority(); investVo.setOrdInvCurrentStatus(); */ LOG.debug("R01VoMapper fillPATHInvestigationFromOBR: exit"); }