int admissionPartNightListSize = Integer.parseInt(admissionPartTokens[j + 1]);
if (nextFirstNightIndex >= nightListSize || admissionPartNightListSize == 0) {
nextFirstNightIndex += admissionPartNightListSize;
continue;
}
AdmissionPart admissionPart = new AdmissionPart();
admissionPart.setId(admissionPartId);
admissionPart.setPatient(patient);
Specialism specialism = (specialismId == 0) ? null : idToSpecialismMap.get(specialismId);
if (specialism == null) {
throw new IllegalArgumentException("Read line (" + line
+ ") has a non existing specialismId (" + specialismId + ").");
}
admissionPart.setSpecialism(specialism);
int admissionPartFirstNightIndex = nextFirstNightIndex;
Night admissionPartFirstNight = indexToNightMap.get(admissionPartFirstNightIndex);
if (admissionPartFirstNight == null) {
throw new IllegalStateException(
"The admissionPartFirstNight was not found for admissionPartFirstNightIndex("
+ admissionPartFirstNightIndex + ").");
}
admissionPart.setFirstNight(admissionPartFirstNight);
int admissionPartLastNightIndex = nextFirstNightIndex + admissionPartNightListSize - 1;
// TODO Instead of ensureEnoughNights(lastNightIndex);
// the official score function ignores any broken constraints after the planning horizon
if (admissionPartLastNightIndex >= nightListSize) {
admissionPartLastNightIndex = nightListSize - 1;
}
Night admissionPartLastNight = indexToNightMap.get(admissionPartLastNightIndex);
if (admissionPartLastNight == null) {
throw new IllegalStateException(
"The admissionPartLastNight was not found for admissionPartLastNightIndex("
+ admissionPartLastNightIndex + ").");
}
admissionPart.setLastNight(admissionPartLastNight);
admissionPartList.add(admissionPart);
admissionPartId++;
nextFirstNightIndex += admissionPartNightListSize;
}
int admissionPartNightListSizeSum = nextFirstNightIndex - firstNightIndex;