@SuppressWarnings("unchecked") public PatientMedicationLiteVoCollection getPresentationReferralSummaryMedication(CatsReferralRefVo catsRefVo) { if(catsRefVo != null) { DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer("select presRS.medicationOnReferral from PresentationReferralSummary presRS where "); String andStr = " "; ArrayList<String> markers = new ArrayList<String>(); ArrayList<Serializable> values = new ArrayList<Serializable>(); hql.append(andStr + " presRS.catsReferral.id = :cats"); markers.add("cats"); values.add(catsRefVo.getID_CatsReferral()); List listAdditional = factory.find(hql.toString(), markers,values); if(listAdditional != null && listAdditional.size() > 0) { return PatientMedicationLiteVoAssembler.createPatientMedicationLiteVoCollectionFromPatientMedication(listAdditional); } } return null; }
public PatientMedicationLiteVoCollection listPatientLastMedication(PatientShort patient, DateTime startDateTime) { if (patient == null || !patient.getID_PatientIsNotNull()) return null; // Get last care context (of type INPATIET) StringBuilder ccQuery = new StringBuilder(); ccQuery.append("select cc from PatientMedication as pmed join pmed.careContext as cc where pmed.patient.id = :PAT_ID and cc.context.id = :CC_TYPE and (pmed.isRIE is null or pmed.isRIE = 0) and (pmed.isDiscontinued is null or pmed.isDiscontinued = 0)"); ArrayList<String> paramCCNames = new ArrayList<String>(); ArrayList<Object> paramCCValues = new ArrayList<Object>(); paramCCNames.add("PAT_ID"); paramCCNames.add("CC_TYPE"); paramCCValues.add(patient.getID_Patient()); paramCCValues.add(ContextType.INPATIENT.getID()); if (startDateTime != null) { ccQuery.append(" and cc.startDateTime <= :DATE"); paramCCNames.add("DATE"); paramCCValues.add(startDateTime.getJavaDate()); } ccQuery.append(" order by cc.startDateTime desc"); CareContextLiteVo careContext = CareContextLiteVoAssembler.create((CareContext) getDomainFactory().findFirst(ccQuery.toString(), paramCCNames, paramCCValues)); if (careContext == null || !careContext.getID_CareContextIsNotNull()) return null; String hqlQuery = "select pmed from PatientMedication as pmed where pmed.patient.id = :PAT_ID and pmed.careContext.id = :CC_ID"; ArrayList<String> paramPMedNames = new ArrayList<String>(); ArrayList<Object> paramPMedValues = new ArrayList<Object>(); paramPMedNames.add("PAT_ID"); paramPMedNames.add("CC_ID"); paramPMedValues.add(patient.getID_Patient()); paramPMedValues.add(careContext.getID_CareContext()); return PatientMedicationLiteVoAssembler.createPatientMedicationLiteVoCollectionFromPatientMedication(getDomainFactory().find(hqlQuery, paramPMedNames, paramPMedValues)); }