Skip to content

Commit

Permalink
Merge pull request #37 from LabGraphTeam/dev/refactoring_patterns
Browse files Browse the repository at this point in the history
dev/refactoring patterns
  • Loading branch information
LeonardoMeireles55 authored Feb 2, 2025
2 parents d07818c + 87ab0a6 commit a0f67e6
Show file tree
Hide file tree
Showing 28 changed files with 383 additions and 456 deletions.
109 changes: 30 additions & 79 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# QualityLab Pro-API RESTful for internal laboratory quality control.

[![Docker Image CI/CD](https://github.com/LabGraphTeam/LabGraph-Back-End/actions/workflows/backend-deploy.yml/badge.svg?branch=master)](https://github.com/LabGraphTeam/LabGraph-Back-End/actions/workflows/backend-deploy.yml)
<p align="center">

<img src="https://img.shields.io/static/v1?label=STATUS&message=In%20progress&color=RED&style=for-the-badge" alt="Em desenvolvimento"/>
</p>

## Technologies

Expand All @@ -22,39 +18,33 @@ monitoring and controlling the quality of their processes. This API provides end
control standards, test results, statistical analyses, and other activities essential for ensuring the accuracy and
reliability of laboratory data.

## Implemented functionalities

The API efficiently manages package insert values and test values, offering simple and intuitive CRUD operations.

## Project Structure

```
.
├── .github/workflows # GitHub Actions workflow configurations
├── src
│ ├── main
│ │ ├── java/leonardo/labutilities/qualitylabpro
│ │ │ ├── configs # Application configurations
│ │ │ │ ├── date # Date/time configurations
│ │ │ │ ├── docs # API documentation configs
│ │ │ │ ├── rest # REST configurations
│ │ │ │ └── security # Security configurations
│ │ │ ├── constants # Constant definitions
│ │ │ ├── controllers # REST controllers
│ │ │ ├── dtos # Data Transfer Objects
│ │ │ ├── entities # Domain entities
│ │ │ ├── enums # Enumerations
│ │ │ ├── repositories # Data access layer
│ │ │ ├── services # Business logic
│ │ │ └── utils # Utility classes
│ │ └── resources
│ │ ├── db/migration # Flyway migrations
│ │ └── application*.properties
│ └── test
│ └── java # Test classes
├── database # Database scripts
├── nginx # Nginx configurations
└── docker-compose*.yml # Docker compose files
├── src/
│ ├── main/
│ │ ├── java/leonardo/labutilities/qualitylabpro/
│ │ │ ├── configs/ # Application configurations
│ │ │ │ ├── date/ # Date/time configurations
│ │ │ │ ├── docs/ # API documentation
│ │ │ │ ├── rest/ # REST configurations
│ │ │ │ └── security/ # Security settings
│ │ │ ├── controllers/ # REST endpoints
│ │ │ ├── dtos/ # Data Transfer Objects
│ │ │ ├── entities/ # Domain entities
│ │ │ ├── repositories/ # Data access layer
│ │ │ ├── services/ # Business logic
│ │ │ └── utils/ # Helper classes
│ │ └── resources/
│ │ ├── db/migration/ # Flyway migrations
│ │ └── application.properties
│ └── test/
│ └── java/ # Test classes
├── database/ # Database scripts
├── nginx/ # Nginx configurations
├── docker-compose.yml # Docker compose files
└── pom.xml # Maven configuration
```

### Key Components:
Expand Down Expand Up @@ -93,15 +83,15 @@ You can view the workflow configurations in the `.github/workflows` directory.
Run the command below in Git Bash or Terminal to clone the repository:

```
git clone https://github.com/LeonardoMeireles55/QualityLabPro.git
git clone https://github.com/LabGraphTeam/LabGraph-Back-End.git
```

#### Step 2. Running with docker-compose

In the project root directory, run the command:

```
docker-compose up or docker compose up
docker compose -f docker-compose-dev.yml up --build
```

## Usage
Expand All @@ -128,61 +118,22 @@ For even more detailed test output:
./mvnw test -X
```

### With Docker

When running with docker-compose, you can view test output in real-time:

```bash
docker-compose logs -f app
```

To see test execution during build:

```bash
docker-compose up --build --force-recreate
```

## Services

### CoagulationAnalyticsService

Handles analytic related to coagulation tests.

### BiochemistryAnalyticsService

Handles analytic related to biochemistry tests.

### HematologyAnalyticsService

Handles analytic related to hematology tests.

## Controllers

### CoagulationAnalyticsController

Manages endpoints for coagulation analytic.

### BiochemistryAnalyticsController

Manages endpoints for biochemistry analytic.

### HematologyAnalyticsController

Manages endpoints for hematology analytic.

## React Recharts.js Front-end

<img width="1470" alt="Screenshot 2024-12-06 at 18 01 35" src="https://github.com/user-attachments/assets/4fca9580-c012-48ef-a3d7-bf264593ccf2">

## Contributing

1. Fork the repository.
2. Create a new branch (`git checkout -b feature-branch`).
2. Create a new branch (`git checkout -b feature/branch`).
3. Make your changes.
4. Commit your changes (`git commit -m 'Add some feature'`).
5. Push to the branch (`git push origin feature-branch`).
5. Push to the branch (`git push origin feature/branch`).
6. Open a pull request.

## Misc
[![DigitalOcean Referral Badge](https://web-platforms.sfo2.cdn.digitaloceanspaces.com/WWW/Badge%203.svg)](https://www.digitalocean.com/?refcode=c961dfd401d8&utm_campaign=Referral_Invite&utm_medium=Referral_Program&utm_source=badge)

## License

This project is licensed under the GNU General Public License v3.0 (GPL-3.0) - see the [LICENSE](LICENSE) file for
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import leonardo.labutilities.qualitylabpro.dtos.analytics.AnalyticsDTO;
import leonardo.labutilities.qualitylabpro.dtos.analytics.MeanAndStdDeviationDTO;
import leonardo.labutilities.qualitylabpro.services.analytics.AnalyticHelperService;
import leonardo.labutilities.qualitylabpro.services.analytics.AbstractAnalyticHelperService;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand All @@ -26,9 +26,9 @@
@SecurityRequirement(name = "bearer-key")
@RequestMapping("/generic-analytics")
@RestController()
public abstract class AnalyticsController extends AnalyticsHelperController {
public abstract class AbstractAnalyticsController extends AnalyticsHelperController {

protected AnalyticsController(AnalyticHelperService analyticHelperService) {
protected AbstractAnalyticsController(AbstractAnalyticHelperService analyticHelperService) {
super(analyticHelperService);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import leonardo.labutilities.qualitylabpro.dtos.analytics.GroupedMeanAndStdByLevelDTO;
import leonardo.labutilities.qualitylabpro.dtos.analytics.GroupedResultsByLevelDTO;
import leonardo.labutilities.qualitylabpro.dtos.analytics.UpdateAnalyticsMeanDTO;
import leonardo.labutilities.qualitylabpro.services.analytics.AnalyticHelperService;
import leonardo.labutilities.qualitylabpro.services.analytics.AbstractAnalyticHelperService;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand All @@ -27,9 +27,9 @@
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;

public class AnalyticsHelperController {
private final AnalyticHelperService analyticHelperService;
private final AbstractAnalyticHelperService analyticHelperService;

public AnalyticsHelperController(AnalyticHelperService analyticHelperService) {
public AnalyticsHelperController(AbstractAnalyticHelperService analyticHelperService) {
this.analyticHelperService = analyticHelperService;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@SecurityRequirement(name = "bearer-key")
@RequestMapping("biochemistry-analytics")
@RestController()
public class BiochemistryAnalyticsController extends AnalyticsController {
public class BiochemistryAnalyticsController extends AbstractAnalyticsController {

private static final List<String> names =
new AvailableBiochemistryAnalytics().availableBioAnalytics();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@SecurityRequirement(name = "bearer-key")
@RequestMapping("coagulation-analytics")
@RestController()
public class CoagulationAnalyticsController extends AnalyticsController {
public class CoagulationAnalyticsController extends AbstractAnalyticsController {

private static final List<String> names =
new AvailableCoagulationAnalytics().availableCoagulationAnalytics();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@SecurityRequirement(name = "bearer-key")
@RequestMapping("/hematology-analytics")
@RestController()
public class HematologyAnalyticsController extends AnalyticsController {
public class HematologyAnalyticsController extends AbstractAnalyticsController {

private static final List<String> names =
new AvailableHematologyAnalytics().availableHematologyAnalytics();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import jakarta.persistence.*;
import leonardo.labutilities.qualitylabpro.dtos.analytics.AnalyticsDTO;
import leonardo.labutilities.qualitylabpro.utils.components.RulesValidatorComponent;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.springframework.hateoas.RepresentationModel;
Expand All @@ -11,64 +12,62 @@

@Getter
@Setter
@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = false)
@Entity(name = "generic_analytics")
public class Analytic extends RepresentationModel<Analytic> {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private LocalDateTime date;
@Column(name = "level_lot")
private String levelLot;
@Column(name = "test_lot")
private String testLot;
private String name;
private String level;
private double value;
private double mean;
private double sd;
@Column(name = "unit_value")
private String unitValue;
private String rules;
private String description;
@Transient
private RulesValidatorComponent rulesValidatorComponent;

LocalDateTime date;
@Column(name = "level_lot")
String levelLot;
@Column(name = "test_lot")
String testLot;
String name;
String level;
double value;
double mean;
double sd;
@Column(name = "unit_value")
String unitValue;
String rules;
String description;
@Transient
RulesValidatorComponent rulesValidatorComponent;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
public Analytic() {}

public Analytic() {
}
public Analytic(Long id, LocalDateTime date, String levelLot, String testLot, String name,
String level, double value, double mean, double sd, String unitValue, String rules,
String description, RulesValidatorComponent rulesValidatorComponent) {
this.id = id;
this.date = date;
this.levelLot = levelLot;
this.testLot = testLot;
this.name = name;
this.level = level;
this.value = value;
this.mean = mean;
this.sd = sd;
this.unitValue = unitValue;
this.rules = rules;
this.description = description;
this.rulesValidatorComponent = rulesValidatorComponent;
}

public Analytic(Long id, LocalDateTime date, String levelLot, String testLot,
String name, String level, double value, double mean, double sd, String unitValue,
String rules, String description, RulesValidatorComponent rulesValidatorComponent) {
this.id = id;
this.date = date;
this.levelLot = levelLot;
this.testLot = testLot;
this.name = name;
this.level = level;
this.value = value;
this.mean = mean;
this.sd = sd;
this.unitValue = unitValue;
this.rules = rules;
this.description = description;
this.rulesValidatorComponent = rulesValidatorComponent;
}

public Analytic(AnalyticsDTO values,
RulesValidatorComponent rulesValidatorComponent) {
this.date = values.date();
this.levelLot = values.level_lot();
this.testLot = values.test_lot();
this.name = values.name();
this.level = values.level();
this.value = values.value();
this.mean = values.mean();
this.sd = values.sd();
this.unitValue = values.unit_value();
this.rulesValidatorComponent = rulesValidatorComponent;
rulesValidatorComponent.validator(value, mean, sd);
this.rules = rulesValidatorComponent.getRules();
this.description = rulesValidatorComponent.getDescription();
}
public Analytic(AnalyticsDTO values, RulesValidatorComponent rulesValidatorComponent) {
this.date = values.date();
this.levelLot = values.level_lot();
this.testLot = values.test_lot();
this.name = values.name();
this.level = values.level();
this.value = values.value();
this.mean = values.mean();
this.sd = values.sd();
this.unitValue = values.unit_value();
this.rulesValidatorComponent = rulesValidatorComponent;
rulesValidatorComponent.validator(value, mean, sd);
this.rules = rulesValidatorComponent.getRules();
this.description = rulesValidatorComponent.getDescription();
}
}
Loading

0 comments on commit a0f67e6

Please sign in to comment.