Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
OP-1321: Rename checkMedical into validateMedical (informatici#1385)
Browse files Browse the repository at this point in the history
* OP-1321: Rename checkMedical into validateMedical

* OP-1321: Rename checkMedical into validateMedical
  • Loading branch information
dbmalkovsky authored Aug 7, 2024
1 parent 0a5e423 commit 28fc273
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
32 changes: 16 additions & 16 deletions src/main/java/org/isf/medicals/manager/MedicalBrowsingManager.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Open Hospital (www.open-hospital.org)
* Copyright © 2006-2023 Informatici Senza Frontiere ([email protected])
* Copyright © 2006-2024 Informatici Senza Frontiere ([email protected])
*
* Open Hospital is a free and open source software for healthcare data management.
*
Expand Down Expand Up @@ -169,7 +169,7 @@ public Medical newMedical(Medical medical) throws OHServiceException {
* @throws OHServiceException
*/
public Medical newMedical(Medical medical, boolean ignoreSimilar) throws OHServiceException {
checkMedicalForInsert(medical, ignoreSimilar);
validateMedicalForInsert(medical, ignoreSimilar);
return ioOperations.newMedical(medical);
}

Expand All @@ -193,7 +193,7 @@ public Medical updateMedical(Medical medical) throws OHServiceException {
* @throws OHServiceException
*/
public Medical updateMedical(Medical medical, boolean ignoreSimilar) throws OHServiceException {
checkMedicalForUpdate(medical, ignoreSimilar);
validateMedicalForUpdate(medical, ignoreSimilar);
return ioOperations.updateMedical(medical);
}

Expand All @@ -218,7 +218,7 @@ public void deleteMedical(Medical medical) throws OHServiceException {
* @param medical - the {@link Medical} to insert or update
* @return list of {@link OHExceptionMessage}
*/
private List<OHExceptionMessage> checkMedicalCommon(Medical medical) {
private List<OHExceptionMessage> validateMedicalCommon(Medical medical) {
List<OHExceptionMessage> errors = new ArrayList<>();
if (medical.getMinqty() < 0) {
errors.add(new OHExceptionMessage(MessageBundle.getMessage("angal.medicals.minquantitycannotbelessthan0.msg")));
Expand All @@ -233,42 +233,42 @@ private List<OHExceptionMessage> checkMedicalCommon(Medical medical) {
}

/**
* Perform several checks on the provided medical, useful for insert
* Perform several validation checks on the provided medical, useful for insert
*
* @param medical - the {@link Medical} to check
* @param medical - the {@link Medical} to validate
* @param ignoreSimilar - if {@code true}, it will not perform a similarity check.
* {@code warning}: same Medical description in the same {@link MedicalType} category is not allowed anyway
* @throws OHServiceException
*/
private void checkMedicalForInsert(Medical medical, boolean ignoreSimilar) throws OHServiceException {
checkMedical(medical, ignoreSimilar, false);
private void validateMedicalForInsert(Medical medical, boolean ignoreSimilar) throws OHServiceException {
validateMedical(medical, ignoreSimilar, false);
}

/**
* Perform several checks on the provided medical, useful for update
* Perform several validation checks on the provided medical, useful for update
*
* @param medical - the {@link Medical} to check
* @param medical - the {@link Medical} to validate
* @param ignoreSimilar - if {@code true}, it will not perform a similarity check.
* {@code warning}: same Medical description in the same {@link MedicalType} category is not allowed anyway
* @throws OHServiceException
*/
public void checkMedicalForUpdate(Medical medical, boolean ignoreSimilar) throws OHServiceException {
checkMedical(medical, ignoreSimilar, true);
public void validateMedicalForUpdate(Medical medical, boolean ignoreSimilar) throws OHServiceException {
validateMedical(medical, ignoreSimilar, true);
}

/**
* Perform several checks on the provided medical, useful for update
* Perform several validation checks on the provided medical, useful for update
*
* @param medical - the {@link Medical} to check
* @param medical - the {@link Medical} to validate
* @param ignoreSimilar - if {@code true}, it will not perform a similarity check.
* {@code warning}: same Medical description in the same {@link MedicalType} category is not allowed anyway
* @param update - if {@code true}, it will not consider the actual {@link Medical}
* @throws OHServiceException
*/
public void checkMedical(Medical medical, boolean ignoreSimilar, boolean update) throws OHServiceException {
public void validateMedical(Medical medical, boolean ignoreSimilar, boolean update) throws OHServiceException {

//check commons
List<OHExceptionMessage> errors = new ArrayList<>(checkMedicalCommon(medical));
List<OHExceptionMessage> errors = new ArrayList<>(validateMedicalCommon(medical));

//check existing data
boolean productCodeExists = !medical.getProdCode().isEmpty() && ioOperations.productCodeExists(medical, update);
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/org/isf/medicals/Tests.java
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ void testMgrCheckMedicalCommonBadMinQty() throws Exception {
MedicalType medicalType = testMedicalType.setup(false);
Medical medical = testMedical.setup(medicalType, false);
medical.setMinqty(-1);
medicalBrowsingManager.checkMedical(medical, false, false);
medicalBrowsingManager.validateMedical(medical, false, false);
})
.isInstanceOf(OHDataValidationException.class);
}
Expand All @@ -507,7 +507,7 @@ void testMgrCheckMedicalCommonBadPcsperpck() throws Exception {
MedicalType medicalType = testMedicalType.setup(false);
Medical medical = testMedical.setup(medicalType, false);
medical.setPcsperpck(-1);
medicalBrowsingManager.checkMedical(medical, false, false);
medicalBrowsingManager.validateMedical(medical, false, false);
})
.isInstanceOf(OHDataValidationException.class);
}
Expand All @@ -518,7 +518,7 @@ void testMgrCheckMedicalCommonMissingDescription() throws Exception {
MedicalType medicalType = testMedicalType.setup(false);
Medical medical = testMedical.setup(medicalType, false);
medical.setDescription("");
medicalBrowsingManager.checkMedical(medical, false, false);
medicalBrowsingManager.validateMedical(medical, false, false);
})
.isInstanceOf(OHDataValidationException.class);
}
Expand All @@ -529,7 +529,7 @@ void testMgrCheckMedicalProductCodeExists() throws Exception {
int medicalCode = setupTestMedical(false);
Medical medical = medicalsIoOperationRepository.findById(medicalCode).orElse(null);
assertThat(medical).isNotNull();
medicalBrowsingManager.checkMedical(medical, false, false);
medicalBrowsingManager.validateMedical(medical, false, false);
})
.isInstanceOf(OHDataValidationException.class);
}
Expand All @@ -541,7 +541,7 @@ void testMgrCheckMedicalMedicalExists() throws Exception {
Medical medical = medicalsIoOperationRepository.findById(medicalCode).orElse(null);
assertThat(medical).isNotNull();
medical.setProdCode("");
medicalBrowsingManager.checkMedical(medical, false, false);
medicalBrowsingManager.validateMedical(medical, false, false);
})
.isInstanceOf(OHDataValidationException.class);
}
Expand All @@ -556,7 +556,7 @@ void testMgrCheckMedicalNotIgnoreSimilarNotSimilarMedicalsEmpty() throws Excepti
MedicalType medicalType = new MedicalType("code", "description");
medicalTypeIoOperationRepository.saveAndFlush(medicalType);
medical.setType(medicalType);
medicalBrowsingManager.checkMedical(medical, false, false);
medicalBrowsingManager.validateMedical(medical, false, false);
})
.isInstanceOf(OHDataValidationException.class);
}
Expand Down

0 comments on commit 28fc273

Please sign in to comment.