public OrderInvestigationForAttendenceNotesCcVoCollection listOrderInvestigations(PatientRefVo patient, CareContextRefVo careContext) { if (patient == null || patient.getID_Patient() == null) throw new CodingRuntimeException("Patient parameter can not be null when listing OrderInvestigations."); DomainFactory factory = getDomainFactory(); java.util.Date fromDate = null; java.util.Date dateTo = null; if(careContext != null && careContext.getID_CareContext() != null) { CareContext doCareContext = (CareContext) factory.getDomainObject(CareContext.class, careContext.getID_CareContext()); if(doCareContext != null) { if(doCareContext.getStartDateTime() != null) { fromDate = doCareContext.getStartDateTime(); } if(doCareContext.getEndDateTime() != null) { dateTo = doCareContext.getEndDateTime(); } else { dateTo = new java.util.Date(); } } } StringBuilder query = new StringBuilder(); ArrayList<String> paramNames = new ArrayList<String>(); ArrayList<Object> paramValues = new ArrayList<Object>(); query.append("SELECT orderInv FROM OrderInvestigation AS orderInv "); query.append(" LEFT JOIN FETCH orderInv.orderDetails AS details LEFT JOIN details.patient AS patient left join orderInv.investigation as inv left join inv.investigationIndex as invIndex left join orderInv.ordInvCurrentStatus.ordInvStatus as ordStatus "); query.append("WHERE patient.id = :PATIENT_ID and ordStatus.id <> :cancelledStatusId and ordStatus.id <> :cancelRequestStatusId"); paramNames.add("PATIENT_ID"); paramValues.add(patient.getID_Patient()); //WDEV-17303 paramNames.add("cancelledStatusId"); paramValues.add(OrderInvStatus.CANCELLED.getID()); paramNames.add("cancelRequestStatusId"); paramValues.add(OrderInvStatus.CANCEL_REQUEST.getID()); if (fromDate != null && dateTo != null) { query.append(" AND orderInv.displayDateTime BETWEEN :FROM_DATE AND :END_DATE "); paramNames.add("FROM_DATE"); paramValues.add(fromDate); paramNames.add("END_DATE"); paramValues.add(dateTo); } query.append(" order by UPPER(invIndex.name) asc"); return OrderInvestigationForAttendenceNotesCcVoAssembler.createOrderInvestigationForAttendenceNotesCcVoCollectionFromOrderInvestigation(factory.find(query.toString(), paramNames, paramValues)); }
public OrderInvestigationForAttendenceNotesCcVoCollection listOrderInvestigations(PatientRefVo patient, CareContextRefVo careContext, String investigationsAlreadyAdded) { if (patient == null || patient.getID_Patient() == null) throw new CodingRuntimeException("Patient parameter can not be null when listing OrderInvestigations."); DomainFactory factory = getDomainFactory(); java.util.Date fromDate = null; java.util.Date dateTo = null; if(careContext != null && careContext.getID_CareContext() != null) { CareContext doCareContext = (CareContext) factory.getDomainObject(CareContext.class, careContext.getID_CareContext()); if(doCareContext != null) { if(doCareContext.getStartDateTime() != null) { fromDate = doCareContext.getStartDateTime(); } if(doCareContext.getEndDateTime() != null) { return null; } dateTo = new java.util.Date(); } } StringBuilder query = new StringBuilder(); ArrayList<String> paramNames = new ArrayList<String>(); ArrayList<Object> paramValues = new ArrayList<Object>(); query.append("SELECT orderInv FROM OrderInvestigation AS orderInv "); query.append(" LEFT JOIN FETCH orderInv.orderDetails AS details LEFT JOIN details.patient AS patient left join orderInv.investigation as inv left join inv.investigationIndex as invIndex left join orderInv.ordInvCurrentStatus.ordInvStatus as ordStatus "); query.append("WHERE patient.id = :PATIENT_ID and ordStatus.id <> :cancelledStatusId and ordStatus.id <> :cancelRequestStatusId"); paramNames.add("PATIENT_ID"); paramValues.add(patient.getID_Patient()); //WDEV-17303 paramNames.add("cancelledStatusId"); paramValues.add(OrderInvStatus.CANCELLED.getID()); paramNames.add("cancelRequestStatusId"); paramValues.add(OrderInvStatus.CANCEL_REQUEST.getID()); if (fromDate != null && dateTo != null) { query.append(" AND orderInv.systemInformation.creationDateTime BETWEEN :FROM_DATE AND :END_DATE "); paramNames.add("FROM_DATE"); paramValues.add(fromDate); paramNames.add("END_DATE"); paramValues.add(dateTo); } if(investigationsAlreadyAdded != null && investigationsAlreadyAdded.length() > 0) { query.append(" AND orderInv.id not in ("); query.append(investigationsAlreadyAdded); query.append(") "); } query.append(" order by UPPER(invIndex.name) asc"); return OrderInvestigationForAttendenceNotesCcVoAssembler.createOrderInvestigationForAttendenceNotesCcVoCollectionFromOrderInvestigation(factory.find(query.toString(), paramNames, paramValues)); }