@Override public boolean canConvert(DosageWrapper dosage) { if (dosage.getStructures() == null) return false; if (dosage.getStructures().getStructures().size() != 1) return false; StructureWrapper structure = dosage.getStructures().getStructures().first(); if (structure.getIterationInterval() != 0) return false; if (structure.getDays().size() != 1) return false; DayWrapper day = structure.getDays().first(); if (!day.containsAccordingToNeedDosesOnly()) return false; if (day.getAccordingToNeedDoses().size() > 1) return false; return true; }
@Override public String doConvert(DosageWrapper dosage) { StructureWrapper structure = dosage.getStructures().getStructures().first(); StringBuilder text = new StringBuilder(); DayWrapper day = structure.getDays().first(); text.append(toValue(day.getAllDoses().get(0), dosage.getStructures().getUnitOrUnits())); text.append(" efter behov"); if (structure.getSupplText() != null) text.append(TextHelper.maybeAddSpace(structure.getSupplText())) .append(structure.getSupplText()); return text.toString(); }
public static DailyDosis calculate(DosageWrapper dosage) { if (dosage.isAdministrationAccordingToSchema()) return new DailyDosis(); else if (dosage.isFreeText()) return new DailyDosis(); else return calculateFromStructures(dosage.getStructures()); }