private void listAndPopulateInvestigationsGrid(PatientRefVo patient, CareContextRefVo careContext) { form.lblNoKnownInvestigation().setTooltip(getInvestigationsNotRecordedDetails(form.getLocalContext().getAttendDiagInvTreatStatus())); form.chkNoKnownInvestigations().setValue(form.getLocalContext().getAttendDiagInvTreatStatus() != null ? form.getLocalContext().getAttendDiagInvTreatStatus().getInvestigationNotRecorded() : null); form.chkNoneInvestigations().setValue(form.getLocalContext().getAttendDiagInvTreatStatus() != null ? form.getLocalContext().getAttendDiagInvTreatStatus().getNoInvestigations() : null); if(Boolean.TRUE.equals(form.getLocalContext().getAddedDuringCoding())) { EmergencyAttendanceInvestigationCodingVo investigationSequenceVo = domain.getInvestigationSequence(form.getLocalContext().getCareContext()); if (investigationSequenceVo != null && investigationSequenceVo.getInvestigationSequenceCodingItemsIsNotNull()) { form.getLocalContext().setEmergencyInvestigationSequence(investigationSequenceVo); showOrderedInvestigations(patient, careContext, investigationSequenceVo); return; } } String orderInvestigationIDSAlreadyAdded = populateInvestigationsGrid(); OrderInvestigationForAttendenceNotesCcVoCollection orderInvestigations = domain.listOrderInvestigations(patient, careContext, orderInvestigationIDSAlreadyAdded); if(createAndSaveInvestigationsAttendenceDetail(orderInvestigations)) { refresh(); } if(form.grdInvestigations().getRows().size() > 0 && (form.chkNoKnownInvestigations().getValue() || form.chkNoneInvestigations().getValue()))//workaround when OrderInvestigations are created outside Emergency module { saveAttendDiagInvTreatStatus(false, false, null, null, null, null); refresh(); return; } }
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)); }
private boolean createAndSaveInvestigationsAttendenceDetail(OrderInvestigationForAttendenceNotesCcVoCollection orderInvestigations) { if(orderInvestigations == null || orderInvestigations.size() == 0) return false; InvestigationsForAttendVo invForAtt = form.getLocalContext().getSelectedInvestigationsForAttend(); if(invForAtt == null) { invForAtt = new InvestigationsForAttendVo(); invForAtt.setPatient(form.getLocalContext().getPatient()); invForAtt.setEpisode(form.getLocalContext().getEpisodeOfCare()); invForAtt.setAttendance(form.getLocalContext().getCareContext()); } if(invForAtt.getInvestigations() == null) { invForAtt.setInvestigations(new InvestigationAttendenceDetailVoCollection()); } for(OrderInvestigationForAttendenceNotesCcVo inv : orderInvestigations) { invForAtt.getInvestigations().add(createInvestigationAttendanceDetails(inv)); } String[] errors = invForAtt.validate(); if(errors != null && errors.length > 0) { engine.showErrors(errors); return false; } try { form.getLocalContext().setSelectedInvestigationsForAttend(domain.save(invForAtt)); } catch (StaleObjectException e) { e.printStackTrace(); engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue()); refresh(); return false; } return true; }
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)); }