public InpatientEpisodeEDischargeVo getInpatientEpisodeByCareContext(CareContextRefVo careContext) { if (careContext == null || careContext.getID_CareContext() == null) throw new CodingRuntimeException("careContext is null or id not provided in method getInpatientEpisodeByCareContext"); List items = getDomainFactory().find(" select cc.pasEvent.id from CareContext as cc where cc.id = " + careContext.getID_CareContext()); if(items != null && items.size() > 0) { Integer eventId = (Integer) items.get(0); if(eventId!= null && eventId > 0) { List ieItems = getDomainFactory().find(" from InpatientEpisode ie where ie.pasEvent.id = " + eventId); if(ieItems != null && ieItems.size() > 0) return InpatientEpisodeEDischargeVoAssembler.create((InpatientEpisode) ieItems.get(0)); } } return null; }