Skip to content

Commit

Permalink
Merge branch 'develop' into OH2-242-update-the-demo-data-file-with-th…
Browse files Browse the repository at this point in the history
…e-new-permission
  • Loading branch information
ArnaudFonzam committed Oct 16, 2023
2 parents 68781a2 + 917c155 commit e3ac07a
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private String formatLastNote(PatientExamination lastPatientExamination) {
}

private void buildAuscultationHashMap() {
auscultationHashMap = new LinkedHashMap<>();
auscultationHashMap = new LinkedHashMap<>(6);
auscultationHashMap.put("normal", MessageBundle.getMessage("angal.examination.auscultation.normal.txt"));
auscultationHashMap.put("wheezes", MessageBundle.getMessage("angal.examination.auscultation.wheezes.txt"));
auscultationHashMap.put("rhonchi", MessageBundle.getMessage("angal.examination.auscultation.rhonchi.txt"));
Expand Down Expand Up @@ -148,9 +148,9 @@ public String getAuscultationKey(String description) {
* @param patex - the PatientExamination to save
* @throws OHServiceException
*/
public void saveOrUpdate(PatientExamination patex) throws OHServiceException {
public PatientExamination saveOrUpdate(PatientExamination patex) throws OHServiceException {
validateExamination(patex);
ioOperations.saveOrUpdate(patex);
return ioOperations.saveOrUpdate(patex);
}

public PatientExamination getByID(int id) throws OHServiceException {
Expand All @@ -159,14 +159,13 @@ public PatientExamination getByID(int id) throws OHServiceException {

public PatientExamination getLastByPatID(int patID) throws OHServiceException {
List<PatientExamination> patExamination = getByPatID(patID);

return !patExamination.isEmpty() ? patExamination.get(0) : null;
}

public List<PatientExamination> getLastNByPatID(int patID, int number) throws OHServiceException {
return ioOperations.getLastNByPatID(patID, number);
}

public PagedResponse<PatientExamination> getLastNByPatIDPageable(int patID, int number) throws OHServiceException {
return ioOperations.getLastNByPatIDPageable(patID, number);
}
Expand All @@ -193,20 +192,20 @@ public String getBMIdescription(double bmi) {
if (bmi >= 18.5 && bmi < 24.5) {
return MessageBundle.getMessage("angal.examination.bmi.normalweight.txt");
}
if (bmi >= 24.5 && bmi < 30) {
if (bmi >= 24.5 && bmi < 30.0) {
return MessageBundle.getMessage("angal.examination.bmi.overweight.txt");
}
if (bmi >= 30 && bmi < 35) {
if (bmi >= 30.0 && bmi < 35.0) {
return MessageBundle.getMessage("angal.examination.bmi.obesityclassilight.txt");
}
if (bmi >= 35 && bmi < 40) {
if (bmi >= 35.0 && bmi < 40.0) {
return MessageBundle.getMessage("angal.examination.bmi.obesityclassiimedium.txt");
}
return MessageBundle.getMessage("angal.examination.bmi.obesityclassiiisevere.txt");
}

private void buildDiuresisDescriptionHashMap() {
diuresisDescriptionHashMap = new HashMap<>();
diuresisDescriptionHashMap = new HashMap<>(8);
diuresisDescriptionHashMap.put("physiological", MessageBundle.getMessage("angal.examination.diuresis.physiological.txt"));
diuresisDescriptionHashMap.put("oliguria", MessageBundle.getMessage("angal.examination.diuresis.oliguria.txt"));
diuresisDescriptionHashMap.put("anuria", MessageBundle.getMessage("angal.examination.diuresis.anuria.txt"));
Expand All @@ -218,7 +217,7 @@ private void buildDiuresisDescriptionHashMap() {
}

private void buildBowelDescriptionHashMap() {
bowelDescriptionHashMap = new HashMap<>();
bowelDescriptionHashMap = new HashMap<>(4);
bowelDescriptionHashMap.put("regular", MessageBundle.getMessage("angal.examination.bowel.regular.txt"));
bowelDescriptionHashMap.put("irregular", MessageBundle.getMessage("angal.examination.bowel.irregular.txt"));
bowelDescriptionHashMap.put("constipation", MessageBundle.getMessage("angal.examination.bowel.constipation.txt"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public ExaminationOperations() {
}

/**
* Get from last PatientExamination (only height, weight & note)
* Get from last PatientExamination
*/
public PatientExamination getFromLastPatientExamination(PatientExamination lastPatientExamination) {
return new PatientExamination(TimeTools.getNow(),
Expand All @@ -77,8 +77,8 @@ public PatientExamination getFromLastPatientExamination(PatientExamination lastP
* - the PatientExamination to save
* @throws OHServiceException
*/
public void saveOrUpdate(PatientExamination patex) throws OHServiceException {
repository.save(patex);
public PatientExamination saveOrUpdate(PatientExamination patex) throws OHServiceException {
return repository.save(patex);
}

public PatientExamination getByID(int id) throws OHServiceException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,29 @@ public class HospitalBrowsingManager {
private HospitalIoOperations ioOperations;

/**
* Reads from database hospital information
* Reads from the database the {@link Hospital} information.
*
* @return {@link Hospital} object
* @return the {@link Hospital} object
* @throws OHServiceException
*/
public Hospital getHospital() throws OHServiceException {
return ioOperations.getHospital();
}

/**
* Reads from database currency cod
* Reads from the database the currency code.
*
* @return currency cod
* @return the currency code
* @throws OHServiceException
*/
public String getHospitalCurrencyCod() throws OHServiceException {
return ioOperations.getHospitalCurrencyCod();
}

/**
* Updates hospital information
* Updates the {@link Hospital} information.
*
* @return <code>true</code> if the hospital information has been updated, <code>false</code> otherwise
* @return return the updated {@link Hospital} object.
* @throws OHServiceException
*/
public Hospital updateHospital(Hospital hospital) throws OHServiceException {
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/isf/hospital/service/HospitalIoOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public class HospitalIoOperations {
private HospitalIoOperationRepository repository;

/**
* Reads from database hospital information
* Reads from database {@link Hospital} information.
*
* @return {@link Hospital} object
* @return the {@link Hospital} object.
* @throws OHServiceException
*/
public Hospital getHospital() throws OHServiceException {
Expand All @@ -57,8 +57,8 @@ public Hospital getHospital() throws OHServiceException {
}

/**
* Reads from database currency cod
* @return currency cod
* Reads from the database the currency code.
* @return the currency code
* @throws OHServiceException
*/
public String getHospitalCurrencyCod() throws OHServiceException {
Expand All @@ -67,9 +67,9 @@ public String getHospitalCurrencyCod() throws OHServiceException {
}

/**
* Updates hospital information
* Updates the {@link Hospital} information.
*
* @return <code>true</code> if the hospital information has been updated, <code>false</code> otherwise
* @return the updated {@link Hospital} object.
* @throws OHServiceException
*/
public Hospital updateHospital(Hospital hospital) throws OHServiceException {
Expand All @@ -80,7 +80,7 @@ public Hospital updateHospital(Hospital hospital) throws OHServiceException {
* Sanitize the given {@link String} value.
* This method is maintained only for backward compatibility.
* @param value the value to sanitize.
* @return the sanitized value or <code>null</code> if the passed value is <code>null</code>.
* @return the sanitized value or {@code null} if the passed value is {@code null}.
*/
protected String sanitize(String value) {
if (value == null) {
Expand Down
39 changes: 24 additions & 15 deletions src/test/java/org/isf/hospital/test/Tests.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,30 +72,33 @@ public void testHospitalSets() throws Exception {
@Test
public void testIoGetHospital() throws Exception {
String code = setupTestHospital(false);
Hospital foundHospital = hospitalIoOperationRepository.findById(code).get();
Hospital foundHospital = hospitalIoOperationRepository.findById(code).orElse(null);
assertThat(foundHospital).isNotNull();
Hospital getHospital = hospitalIoOperation.getHospital();
assertThat(getHospital).isEqualTo(foundHospital);
}

@Test
public void testIoUpdateHospital() throws Exception {
String code = setupTestHospital(false);
Hospital foundHospital = hospitalIoOperationRepository.findById(code).get();
Hospital foundHospital = hospitalIoOperationRepository.findById(code).orElse(null);
assertThat(foundHospital).isNotNull();
foundHospital.setDescription("Update");
Hospital updateHospital = hospitalIoOperation.updateHospital(foundHospital);
assertThat(updateHospital.getDescription()).isEqualTo("Update");
Hospital updatedHospital = hospitalIoOperation.updateHospital(foundHospital);
assertThat(updatedHospital.getDescription()).isEqualTo("Update");
}

@Test
public void testIoGetHospitalCurrencyCod() throws Exception {
String code = setupTestHospital(false);
Hospital foundHospital = hospitalIoOperationRepository.findById(code).get();
Hospital foundHospital = hospitalIoOperationRepository.findById(code).orElse(null);
assertThat(foundHospital).isNotNull();
String cod = hospitalIoOperation.getHospitalCurrencyCod();
assertThat(foundHospital.getCurrencyCod()).isEqualTo(cod);

foundHospital.setCurrencyCod(null);
Hospital updateHospital = hospitalIoOperation.updateHospital(foundHospital);
assertThat(updateHospital.getCurrencyCod()).isNull();
Hospital updatedHospital = hospitalIoOperation.updateHospital(foundHospital);
assertThat(updatedHospital.getCurrencyCod()).isNull();
}

@Test
Expand All @@ -110,24 +113,27 @@ public void testIoHospitalSanitize() throws Exception {
@Test
public void testMgrGetHospital() throws Exception {
String code = setupTestHospital(false);
Hospital foundHospital = hospitalIoOperationRepository.findById(code).get();
Hospital foundHospital = hospitalIoOperationRepository.findById(code).orElse(null);
assertThat(foundHospital).isNotNull();
Hospital getHospital = hospitalBrowsingManager.getHospital();
assertThat(getHospital).isEqualTo(foundHospital);
}

@Test
public void testMgrUpdateHospital() throws Exception {
String code = setupTestHospital(false);
Hospital foundHospital = hospitalIoOperationRepository.findById(code).get();
Hospital foundHospital = hospitalIoOperationRepository.findById(code).orElse(null);
assertThat(foundHospital).isNotNull();
foundHospital.setDescription("Update");
Hospital updateHospital = hospitalBrowsingManager.updateHospital(foundHospital);
assertThat(updateHospital.getDescription()).isEqualTo("Update");
Hospital updatedHospital = hospitalBrowsingManager.updateHospital(foundHospital);
assertThat(updatedHospital.getDescription()).isEqualTo("Update");
}

@Test
public void testMgrGetHospitalCurrencyCod() throws Exception {
String code = setupTestHospital(false);
Hospital foundHospital = hospitalIoOperationRepository.findById(code).get();
Hospital foundHospital = hospitalIoOperationRepository.findById(code).orElse(null);
assertThat(foundHospital).isNotNull();
String cod = hospitalBrowsingManager.getHospitalCurrencyCod();
assertThat(foundHospital.getCurrencyCod()).isEqualTo(cod);

Expand All @@ -139,7 +145,8 @@ public void testMgrGetHospitalCurrencyCod() throws Exception {
@Test
public void testHospitalGetterSetter() throws Exception {
String code = setupTestHospital(false);
Hospital hospital = hospitalIoOperationRepository.findById(code).get();
Hospital hospital = hospitalIoOperationRepository.findById(code).orElse(null);
assertThat(hospital).isNotNull();

hospital.getLock();
hospital.setLock(-1);
Expand All @@ -149,7 +156,8 @@ public void testHospitalGetterSetter() throws Exception {
@Test
public void testHospitalHashToString() throws Exception {
String code = setupTestHospital(false);
Hospital hospital = hospitalIoOperationRepository.findById(code).get();
Hospital hospital = hospitalIoOperationRepository.findById(code).orElse(null);
assertThat(hospital).isNotNull();

assertThat(hospital.hashCode()).isPositive();

Expand All @@ -163,7 +171,8 @@ private String setupTestHospital(boolean usingSet) throws OHException {
}

private void checkHospitalIntoDb(String code) throws OHException {
Hospital foundHospital = hospitalIoOperationRepository.findById(code).get();
Hospital foundHospital = hospitalIoOperationRepository.findById(code).orElse(null);
assertThat(foundHospital).isNotNull();
testHospital.check(foundHospital);
}
}

0 comments on commit e3ac07a

Please sign in to comment.