@Override
public List<RecipeData> getRecipeDataList(Date begin, Date end) throws ClipsServerException {
ConfigBeanRemoteM conf = getBean(ConfigBeanM.class);
Collaborator collaborator = findEntity(Collaborator.class, getCollaborator().getId());
Lpu lpu = collaborator.getLpu();
String lpuTFOMScode = lpu.getLpuCode() != null ? lpu.getLpuCode() : "";
List<RecipeData> res = new ArrayList<RecipeData>();
Field[] f = new Field[]{
new Field("date", begin, Field.OPERATOR_EQUAL_OR_MORE),
new Field("date", end, Field.OPERATOR_EQUAL_OR_LESS),
};
List<PrescriptionDlo> recipeList = findEntityList(PrescriptionDlo.class, f);
for (PrescriptionDlo pr : recipeList) {
if (!pr.getServiceRender().isRendered()) {
continue;
}
RecipeData data = new RecipeData();
data.id = pr.getId();
Client cl = pr.getServiceRender().getPolis().getClient();
data.snils = cl.getSnils();
data.lpuTFOMScode = lpuTFOMScode;
String sql = "SELECT fc FROM FacilityClient fc " +
"WHERE fc.surname = :surname " +
"AND fc.name = :name " +
"AND fc.pathronymic = :pathronymic " +
"AND fc.snils = :snils";
Query query = manager.createQuery(sql);
query.setParameter("surname", cl.getSurname());
query.setParameter("name", cl.getName());
query.setParameter("pathronymic", cl.getPathronymic());
query.setParameter("snils", cl.getSnils());
List<FacilityClient> fcList = query.getResultList();
if (!fcList.isEmpty()) {
FacilityClient fc = fcList.get(0);
Excemption ex = fc.getExcemption1();
if (ex == null) {
ex = fc.getExcemption2();
}
if (ex != null) {
data.exemptionID = ex.getExtKey();
}
}
Polis polisOMI = clientPolisMap.get(cl.getId());
if (polisOMI != null) {
String polisSN ="";
if (polisOMI.getSeries() != null) {
polisSN = polisOMI.getSeries();
}
if (polisOMI.getNumber() != null) {
polisSN = polisSN + " " + polisOMI.getNumber();
}
data.polisSN = polisSN.trim();
}
data.lpuOGRN = lpu.getOgrn() != null ? lpu.getOgrn() : "";
Collaborator collab = pr.getServiceRender().getFunctions().getCollaborator();
data.collabCode = lpuTFOMScode + " " + collab.getCode();
data.mkbCode = pr.getDiagnosis().getMkb10().getCode();
String recipeSN ="";
if (pr.getSeries() != null) {