public EpisodeOfCareWithPrimaryDiagnosisVoCollection listOpenEpisodesForPatient(PatientRefVo patient) { if (patient == null || patient.getID_Patient() == null) throw new CodingRuntimeException("patient is null or id not provided in method listOpenEpisodesForPatient"); EpisodeOfCareWithPrimaryDiagnosisVoCollection voCollEpisodes = null; String hql = "from EpisodeOfCare as epis left join fetch epis.responsibleHCP as hcp left join fetch hcp.mos as mos left join fetch epis.careSpell as cs where epis.endDate is null and cs.patient.id = " + patient.getID_Patient(); List episodes = getDomainFactory().find(hql); if(episodes != null) { voCollEpisodes = EpisodeOfCareWithPrimaryDiagnosisVoAssembler.createEpisodeOfCareWithPrimaryDiagnosisVoCollectionFromEpisodeOfCare(episodes); for(EpisodeOfCareWithPrimaryDiagnosisVo voEpis : voCollEpisodes) { //get the primary diagnosis if it exists String primaryHql = "select distinct primary.diagnosisDescription from CsPrimaryDiagnosis as csp left join csp.diagnosis as primary where (csp.episodeOfCare.id = :episId and csp.isActive = :status)"; List diagnosisNames = getDomainFactory().find(primaryHql, new String[]{"episId", "status"}, new Object[]{ voEpis.getID_EpisodeOfCare(), Boolean.TRUE}); if(diagnosisNames != null && diagnosisNames.size() > 0) { String strDisplay = ""; int i=0; Iterator it = diagnosisNames.iterator(); while(it.hasNext()) { if(i > 0) strDisplay += ","; strDisplay += (String)it.next(); i++; } if(strDisplay.equals("")) strDisplay = "unknown"; voEpis.setPrimaryDiagnosisName(" - " + strDisplay + " - "); } else voEpis.setPrimaryDiagnosisName(" - unknown - "); } } return voCollEpisodes; }
public EpisodeOfCareWithPrimaryDiagnosisVoCollection listOpenEpisodesForPatient(PatientRefVo patient) { if (patient == null || patient.getID_Patient() == null) throw new CodingRuntimeException("patient is null or id not provided in method listOpenEpisodesForPatient"); EpisodeOfCareWithPrimaryDiagnosisVoCollection voCollEpisodes = null; String hql = "from EpisodeOfCare as epis left join fetch epis.responsibleHCP as hcp left join fetch hcp.mos as mos left join fetch epis.careSpell as cs where epis.endDate is null and cs.patient.id = " + patient.getID_Patient(); List episodes = getDomainFactory().find(hql); if(episodes != null) { voCollEpisodes = EpisodeOfCareWithPrimaryDiagnosisVoAssembler.createEpisodeOfCareWithPrimaryDiagnosisVoCollectionFromEpisodeOfCare(episodes); for(EpisodeOfCareWithPrimaryDiagnosisVo voEpis : voCollEpisodes) { //get the primary diagnosis if it exists String primaryHql = "select distinct primary.diagnosisDescription from CsPrimaryDiagnosis as csp left join csp.diagnosis as primary where (csp.episodeOfCare.id = :episId and csp.isActive = :status)"; List diagnosisNames = getDomainFactory().find(primaryHql, new String[]{"episId", "status"}, new Object[]{ voEpis.getID_EpisodeOfCare(), Boolean.TRUE}); if(diagnosisNames != null && diagnosisNames.size() > 0) { StringBuilder strDisplay = new StringBuilder(""); int i=0; Iterator it = diagnosisNames.iterator(); while(it.hasNext()) { if(i > 0) strDisplay.append(","); strDisplay.append((String)it.next()); i++; } if (strDisplay.toString().equals("")) strDisplay.append("unknown"); voEpis.setPrimaryDiagnosisName(" - " + strDisplay + " - "); } else voEpis.setPrimaryDiagnosisName(" - unknown - "); } } return voCollEpisodes; }