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

Commit

Permalink
Merge branch 'develop' into OH2-243-fix-user-setting-controller
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudFonzam authored Nov 6, 2023
2 parents 861a786 + 68f0b54 commit 2218555
Show file tree
Hide file tree
Showing 19 changed files with 271 additions and 325 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.19.4</version>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
26 changes: 0 additions & 26 deletions src/main/java/org/isf/examination/dto/Ausculation.java

This file was deleted.

26 changes: 0 additions & 26 deletions src/main/java/org/isf/examination/dto/Bowel.java

This file was deleted.

26 changes: 0 additions & 26 deletions src/main/java/org/isf/examination/dto/Diurese.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@

import javax.validation.constraints.NotNull;

import org.isf.examination.model.Ausculation;
import org.isf.examination.model.Bowel;
import org.isf.examination.model.Diurese;

import com.drew.lang.annotations.Nullable;

import io.swagger.v3.oas.annotations.media.Schema;
Expand Down
256 changes: 132 additions & 124 deletions src/main/java/org/isf/examination/rest/ExaminationController.java

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions src/main/java/org/isf/lab/rest/LaboratoryController.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ public class LaboratoryController {
private static String draft = LaboratoryStatus.DRAFT.toString();

private static String open = LaboratoryStatus.OPEN.toString();

private static String done = LaboratoryStatus.DONE.toString();


private static String deleted = LaboratoryStatus.DELETED.toString();

private static String invalid = LaboratoryStatus.INVALID.toString();
Expand Down Expand Up @@ -148,12 +146,11 @@ public ResponseEntity<Boolean> newLaboratory(@RequestBody LabWithRowsDTO labWith
if (labRow != null) {
labRows = new ArrayList<>(labRow);
}
boolean inserted = laboratoryManager.newLaboratory(labToInsert, labRows);

if (!inserted) {
try {
laboratoryManager.newLaboratory(labToInsert, labRows);
} catch (OHServiceException serviceException) {
throw new OHAPIException(new OHExceptionMessage("Laboratory not created."));
}

return ResponseEntity.status(HttpStatus.CREATED).body(true);
}

Expand Down Expand Up @@ -192,19 +189,17 @@ public ResponseEntity<Boolean> newExamRequest(@RequestBody LaboratoryDTO laborat

if (!(labList == null || labList.isEmpty())) {
for (Laboratory lab : labList) {
if (lab.getExam() == exam) {
throw new OHAPIException(
new OHExceptionMessage("Exam Request already exists."));
if (lab.getExam().equals(exam)) {
throw new OHAPIException(new OHExceptionMessage("Exam Request already exists."));
}
}
}

boolean inserted = laboratoryManager.newExamRequest(labToInsert);

if (!inserted) {
try {
laboratoryManager.newExamRequest(labToInsert);
} catch (OHServiceException serviceException) {
throw new OHAPIException(new OHExceptionMessage("Laboratory not created."));
}

return ResponseEntity.status(HttpStatus.CREATED).body(true);
}

Expand Down Expand Up @@ -253,9 +248,9 @@ public ResponseEntity<Boolean> newLaboratory2(@RequestBody List<LabWithRowsDTO>
}
}

boolean inserted = laboratoryManager.newLaboratory2(labsToInsert, labsRowsToInsert);

if (!inserted) {
try {
laboratoryManager.newLaboratory2(labsToInsert, labsRowsToInsert);
} catch (OHServiceException serviceException) {
throw new OHAPIException(new OHExceptionMessage("Laboratory not created."));
}
return ResponseEntity.status(HttpStatus.CREATED).body(true);
Expand Down Expand Up @@ -311,9 +306,9 @@ public ResponseEntity<Boolean> updateLaboratory(@PathVariable Integer code,
labToInsert.setStatus(LaboratoryStatus.DONE.toString());
}

boolean updated = laboratoryManager.updateLaboratory(labToInsert, labRows);

if (!updated) {
try {
laboratoryManager.updateLaboratory(labToInsert, labRows);
} catch (OHServiceException serviceException) {
throw new OHAPIException(new OHExceptionMessage("Laboratory not updated."));
}
return ResponseEntity.ok(true);
Expand All @@ -333,9 +328,10 @@ public ResponseEntity<Boolean> updateExamRequest(@PathVariable Integer code, @Re
throws OHServiceException {
LOGGER.info("Update exam request code: {}", code);
LaboratoryStatus stat = LaboratoryStatus.valueOf(status);
if (stat!= null) {
boolean updated = laboratoryManager.updateExamRequest(code, status);
if (!updated) {
if (stat != null) {
try {
laboratoryManager.updateExamRequest(code, status);
} catch (OHServiceException serviceException) {
throw new OHAPIException(new OHExceptionMessage("Laboratory not updated."));
}
return ResponseEntity.ok(true);
Expand Down Expand Up @@ -364,7 +360,9 @@ public ResponseEntity<Boolean> deleteExam(@PathVariable Integer code) throws OHS
} else {
return ResponseEntity.status(HttpStatus.NO_CONTENT).body(null);
}
if (!laboratoryManager.updateExamRequest(code, deleted)) {
try {
laboratoryManager.updateExamRequest(code, deleted);
} catch (OHServiceException serviceException) {
throw new OHAPIException(new OHExceptionMessage("Exam is not deleted."));
}
return ResponseEntity.ok(true);
Expand Down Expand Up @@ -732,7 +730,9 @@ public ResponseEntity<Boolean> deleteExamRequest(@PathVariable Integer code) thr
} else {
return ResponseEntity.status(HttpStatus.NO_CONTENT).body(null);
}
if (!laboratoryManager.updateExamRequest(code, invalid)) {
try {
laboratoryManager.updateExamRequest(code, invalid);
} catch (OHServiceException serviceException) {
throw new OHAPIException(new OHExceptionMessage("Exam request is not deleted."));
}
return ResponseEntity.ok(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ public ResponseEntity<Boolean> deleteMalnutrition(@RequestParam int code) throws
if (matchedMalnutritions.isEmpty()) {
throw new OHAPIException(new OHExceptionMessage("Malnutrition control not found."));
}
boolean isDeleted = manager.deleteMalnutrition(matchedMalnutritions.get(0));
return ResponseEntity.ok(isDeleted);
try {
manager.deleteMalnutrition(matchedMalnutritions.get(0));
} catch (OHServiceException serviceException) {
throw new OHAPIException(new OHExceptionMessage("Malnutrition not deleted."));
}
return ResponseEntity.ok(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,12 @@ public ResponseEntity<Boolean> deleteMedicalType(@PathVariable("code") String co
.filter(item -> item.getCode().equals(code))
.collect(Collectors.toList());
if (!matchedMedicalTypes.isEmpty()) {
return ResponseEntity.ok(medicalTypeBrowserManager.deleteMedicalType(matchedMedicalTypes.get(0)));
try {
medicalTypeBrowserManager.deleteMedicalType(matchedMedicalTypes.get(0));
} catch (OHServiceException serviceException) {
throw new OHAPIException(new OHExceptionMessage("Medical type not deleted."));
}
return ResponseEntity.ok(true);
} else {
throw new OHAPIException(new OHExceptionMessage("Medical type not found."));
}
Expand Down
22 changes: 10 additions & 12 deletions src/main/java/org/isf/opd/rest/OpdController.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.stream.Collectors;

import org.isf.distype.manager.DiseaseTypeBrowserManager;
import org.isf.generaldata.MessageBundle;
import org.isf.opd.dto.OpdDTO;
import org.isf.opd.dto.OpdWithOperationRowDTO;
import org.isf.opd.manager.OpdBrowserManager;
Expand Down Expand Up @@ -181,7 +182,7 @@ ResponseEntity<OpdWithOperationRowDTO> newOpdWithOperationRow(@RequestBody OpdWi
ResponseEntity<OpdDTO> updateOpd(@PathVariable("code") int code, @RequestBody OpdDTO opdDTO)
throws OHServiceException {
LOGGER.info("Update opds code: {}", opdDTO.getCode());
if (opdManager.getOpdById(code) == null) {
if (opdManager.getOpdById(code).isEmpty()) {
throw new OHAPIException(new OHExceptionMessage("Opd not found."));
}

Expand Down Expand Up @@ -215,7 +216,7 @@ ResponseEntity<OpdWithOperationRowDTO> updateOpdWithOperationRow(@PathVariable("
throws OHServiceException {
LOGGER.info("Update opds code: {}", code);
OpdWithOperationRowDTO opdWithOperatioRow = new OpdWithOperationRowDTO();
if (opdManager.getOpdById(code) == null) {
if (opdManager.getOpdById(code).isEmpty()) {
throw new OHAPIException(new OHExceptionMessage("Opd not found."));
}

Expand Down Expand Up @@ -317,20 +318,16 @@ public ResponseEntity<Page<OpdDTO>> getOpdByDates(
ward = wardManager.findWard(wardCode);
}
if (paged) {
PagedResponse<Opd> opdsPaged = opdManager.getOpdPageable(ward, diseaseTypeCode, diseaseTypeCode, dateFrom, dateTo, ageFrom, ageTo, sex, newPatient, page,size);
opdDTOs = opdsPaged.getData().stream().map(opd -> {
return mapper.map2DTO(opd);
}).collect(Collectors.toList());
PagedResponse<Opd> opdsPaged = opdManager.getOpdPageable(ward, diseaseTypeCode, MessageBundle.getMessage(diseaseTypeCode), dateFrom, dateTo, ageFrom, ageTo, sex, newPatient, page,size);
opdDTOs = opdsPaged.getData().stream().map(opd -> mapper.map2DTO(opd)).collect(Collectors.toList());
opdPageable.setPageInfo(mapper.setParameterPageInfo(opdsPaged.getPageInfo()));
} else {
if (patientCode != 0) {
opds = opdManager.getOpdList(patientCode);
} else {
opds = opdManager.getOpd(ward, diseaseTypeCode, diseaseCode, dateFrom, dateTo, ageFrom, ageTo, sex, newPatient, null);
}
opdDTOs = opds.stream().map(opd -> {
return mapper.map2DTO(opd);
}).collect(Collectors.toList());
opdDTOs = opds.stream().map(opd -> mapper.map2DTO(opd)).collect(Collectors.toList());
}
opdPageable.setData(opdDTOs);
if (opdDTOs.isEmpty()) {
Expand Down Expand Up @@ -390,11 +387,12 @@ public ResponseEntity<Boolean> deleteOpd(@PathVariable("code") int code) throws
LOGGER.info("Delete Opd code: {}", code);
Opd toDelete = new Opd();
toDelete.setCode(code);
boolean isDeleted = opdManager.deleteOpd(toDelete);
if (!isDeleted) {
try {
opdManager.deleteOpd(toDelete);
} catch (OHServiceException serviceException) {
throw new OHAPIException(new OHExceptionMessage("Opd not deleted."));
}
return ResponseEntity.ok(isDeleted);
return ResponseEntity.ok(true);
}

/**
Expand Down
35 changes: 21 additions & 14 deletions src/main/java/org/isf/opetype/rest/OperationTypeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,26 @@ public OperationTypeController(OperationTypeBrowserManager opeTypeManager, Opera
/**
* Create a new {@link OperationType}.
* @param operationTypeDTO
* @return {@code true} if the operation type has been stored, {@code false} otherwise.
* @return the newly stored {@link OperationType} object.
* @throws OHServiceException
*/
@PostMapping(value = "/operationtypes", produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<OperationTypeDTO> newOperationType(@RequestBody OperationTypeDTO operationTypeDTO) throws OHServiceException {
String code = operationTypeDTO.getCode();
LOGGER.info("Create operation Type {}", code);
OperationType isCreatedOperationType = opeTypeManager.newOperationType(mapper.map2Model(operationTypeDTO));
if (isCreatedOperationType == null) {
LOGGER.info("Create Operation Type {}", code);
OperationType newOperationType;
try {
newOperationType = opeTypeManager.newOperationType(mapper.map2Model(operationTypeDTO));
} catch (OHServiceException serviceException) {
throw new OHAPIException(new OHExceptionMessage("Operation Type not created."));
}
return ResponseEntity.status(HttpStatus.CREATED).body(mapper.map2DTO(isCreatedOperationType));
return ResponseEntity.status(HttpStatus.CREATED).body(mapper.map2DTO(newOperationType));
}

/**
* Updates the specified {@link OperationType}.
* @param operationTypeDTO
* @return {@code true} if the operation type has been updated, {@code false} otherwise.
* @return the newly updated {@link OperationType} object.
* @throws OHServiceException
*/
@PutMapping(value = "/operationtypes/{code}", produces = MediaType.APPLICATION_JSON_VALUE)
Expand All @@ -97,11 +99,13 @@ ResponseEntity<OperationTypeDTO> updateOperationTypes(@PathVariable String code,
if (!opeTypeManager.isCodePresent(code)) {
throw new OHAPIException(new OHExceptionMessage("Operation Type not found."));
}
OperationType isUpdatedOperationType = opeTypeManager.updateOperationType(opeType);
if (isUpdatedOperationType == null) {
OperationType updatedOperationType;
try {
updatedOperationType = opeTypeManager.updateOperationType(opeType);
} catch (OHServiceException serviceException) {
throw new OHAPIException(new OHExceptionMessage("Operation Type not updated."));
}
return ResponseEntity.ok(mapper.map2DTO(isUpdatedOperationType));
return ResponseEntity.ok(mapper.map2DTO(updatedOperationType));
}

/**
Expand Down Expand Up @@ -129,20 +133,23 @@ public ResponseEntity<List<OperationTypeDTO>> getOperationTypes() throws OHServi
*/
@DeleteMapping(value = "/operationtypes/{code}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Boolean> deleteOperationType(@PathVariable("code") String code) throws OHServiceException {
LOGGER.info("Delete operation Type code: {}", code);
boolean isDeleted = false;
LOGGER.info("Delete Operation Type code: {}", code);
if (opeTypeManager.isCodePresent(code)) {
List<OperationType> opeTypes = opeTypeManager.getOperationType();
List<OperationType> opeTypeFounds = opeTypes.stream().filter(ad -> ad.getCode().equals(code))
.collect(Collectors.toList());
if (!opeTypeFounds.isEmpty()) {
isDeleted = opeTypeManager.deleteOperationType(opeTypeFounds.get(0));
try {
opeTypeManager.deleteOperationType(opeTypeFounds.get(0));
} catch (OHServiceException serviceException) {
LOGGER.error("Delete Operation Type code: {} failed.", code);
return ResponseEntity.ok(false);
}
}
} else {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
}

return ResponseEntity.ok(isDeleted);
return ResponseEntity.ok(true);
}

}
Loading

0 comments on commit 2218555

Please sign in to comment.