Skip to content

Commit

Permalink
Merge pull request informatici#189 from emecas/OP-242-find-ward-by-code
Browse files Browse the repository at this point in the history
OP-242 Adding findWard(id) Functionality
  • Loading branch information
mwithi authored Aug 31, 2020
2 parents 5aee424 + d46e56c commit fa9749e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 6 deletions.
17 changes: 13 additions & 4 deletions src/org/isf/ward/manager/WardBrowserManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@

import org.isf.admission.manager.AdmissionBrowserManager;
import org.isf.generaldata.MessageBundle;
import org.isf.menu.manager.Context;
import org.isf.utils.exception.OHDataIntegrityViolationException;
import org.isf.utils.exception.OHServiceException;
import org.isf.utils.exception.OHOperationNotAllowedException;
import org.isf.utils.exception.OHDataValidationException;
import org.isf.utils.exception.OHOperationNotAllowedException;
import org.isf.utils.exception.OHServiceException;
import org.isf.utils.exception.model.OHExceptionMessage;
import org.isf.utils.exception.model.OHSeverityLevel;
import org.isf.ward.model.Ward;
Expand Down Expand Up @@ -233,5 +232,15 @@ public boolean maternityControl(boolean createIfNotExists) throws OHServiceExcep
public int getCurrentOccupation(Ward ward) throws OHServiceException {
return ioOperations.getCurrentOccupation(ward);
}


/**
* returns the {@link Ward} based on ward code
*
* @param code - the {@link Ward} code.
* @return the {@link Ward}
*/
public Ward findVaccine(String code) throws OHServiceException {
return ioOperations.findWard(code);
}

}
18 changes: 16 additions & 2 deletions src/org/isf/ward/service/WardIoOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.isf.utils.exception.OHServiceException;
import org.isf.ward.model.Ward;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand Down Expand Up @@ -166,5 +165,20 @@ public boolean isMaternityPresent() throws OHServiceException

return result;
}


/**
* returns the {@link Ward} based on code
*
* @param code - the code, must not be {@literal null}
* @return the {@link Ward} or {@literal null} if none found
* @throws OHServiceException
* @throws IllegalArgumentException if {@code code} is {@literal null}
*/
public Ward findWard(String code) throws OHServiceException
{
if (code != null) {
return repository.findOne(code);
}else
throw new IllegalArgumentException("code must not be null");
}
}
23 changes: 23 additions & 0 deletions src/org/isf/ward/test/Tests.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;

import java.util.ArrayList;

Expand Down Expand Up @@ -319,6 +321,27 @@ public void testIoIsMaternityPresent()
return;
}

@Test
public void testFindWard()
{
String code = "";
Ward result;

try
{
code = _setupTestWard(false);
result = wardIoOperation.findWard(code);

assertNotNull(result);
assertEquals(code,result.getCode());
}
catch (Exception e)
{
e.printStackTrace();
fail();
}
}

private void _saveContext() throws OHException
{
testWardContext.saveAll(jpa);
Expand Down

0 comments on commit fa9749e

Please sign in to comment.