October 20, 2026
Structuring of RESTful APIs in a legacy pathology system: applied study in laboratory modules.
Structuring Restful APIs in a Legacy Pathology System: Applied Study in Laboratory Modules.
Vinicius Mendonça de Oliveira; Arthur Pinheiro De Araújo Costa
DOI: 10.22167/2675-6528-202603542
Article derived from a Course Conclusion Work (TCC), with content based on the student’s original work and adapted to the editorial format of the E&S Magazine with the support of the ResumeAI tool, an artificial intelligence solution developed by Instituto Pecege for textual synthesis and organization.
Summary
The advancement of information technologies has driven the need to modernize legacy systems to meet the demands of integration, scalability, and maintenance. The study aimed to develop an Application Programming Interface (API) based on the Representational State Transfer (REST) standard, focusing on restructuring the Registration module of a legacy pathology laboratory system, originally built on the Model-View-Controller (MVC) architecture. The methodology employed the analysis of the legacy system, identification of improvements and limitations, and implementation of a new solution with best practices in development. ASP .NET, C#, and Data Transfer Objects (DTOs) were used to standardize communication. The API was structured in layers, separating responsibilities between controller, services, and repositories, and used the HTTP protocol and JSON format for data exchange. As the main result, an improvement was observed in code organization, decoupling between application layers, and the ability to integrate with external systems. It was concluded that adopting an architecture based on RESTful APIs proved to be an efficient development approach for modernizing legacy systems, offering greater flexibility, maintenance, and interoperability.
Keywords: RESTful APIs; Back-end; Model-View-Controller; Pathology systems; Legacy systems.
1. Introduction
Pathology is a complex area of medicine that involves various health professionals, such as pharmacists, biomedical scientists, biologists, chemists, and specialized physicians. In this field, the main objective is to provide laboratory support for diagnosis, the development of conduct guidelines, the determination of new tests, the establishment of prognoses, and the detection of pathologies to monitor therapy (BORGES, 2007). These tests and analyses are fundamental for diagnosing diseases, confirming diagnoses, and guiding appropriate treatment for each patient.
The laboratory process in pathology, although involving detailed manual steps, has been progressively optimized by technology. Initially, the registration of material and patient, screening, fragment handling, staining, storage in cassettes, paraffin embedding, millimeter cutting, and slide preparation are critical phases that culminate in analysis by pathologists for a specific diagnosis (BANCROFT; GAMBLE, 2008). Administrative, financial, and exam release routines, which were previously manual, have been computerized and automated with specific systems (O’BRIEN; MARAKAS, 2013). The automation and computerization of clinical laboratories have resulted in significant improvements in productivity and cost control (Mugnol and Ferraz, 2006).
The digitalization of services and the integration of data in healthcare are essential pillars of the Health Digital Transformation Plan, according to the Ministry of Health (BRASIL, 2020). This initiative aims to expand access to medical information, ensure continuity of care, and optimize resources, ensuring greater diagnostic safety and the agile availability of results and exams throughout the system. Such systems perform various functions, from patient and material registration to the issuance of reports and the control of exams.
However, the complexity and detail of the workflow in pathology represent a considerable challenge for technology. Many existing systems have not kept up with user needs and technological advancements, becoming legacy systems. Although they partially meet demands, these systems present critical limitations regarding integration with other platforms, maintaining many laboratory activities manually. The fragmentation of information among the various modules of the system itself also constitutes a significant obstacle.
In this scenario of obsolescence, modernizing legacy systems through Application Programming Interfaces (APIs) is of paramount importance. APIs are vital components for communication in the universe of software systems, acting as the backbone that connects different applications (PITA, 2024). Developers design APIs to enable integration between applications, creating a digitally interconnected ecosystem, facilitating data access, and ensuring the security and efficiency of offered resources. The use of APIs in the Representational State Transfer (RESTful) model can provide effective solutions to the aforementioned problems, optimizing flows, queries, and enabling new functionalities that streamline laboratory operations, modernizing it with new tools. APIs are seen as a competitive advantage and not just a technical detail (Pinto, 2015).
Given the need for modernization and the relevance of RESTful APIs for system integration and optimization, the present study is justified by the search for solutions that improve the technological infrastructure in pathology laboratories. The research objective is to investigate, through an applied study, how the integration of laboratory modules through RESTful APIs can contribute to the improvement of these legacy systems, providing an enhancement of operational efficiency, data reliability, and user experience in pathology systems.
2. Material and Methods
The research methodology adopted was characterized as a qualitative approach of an applied nature, with a technical case study design. The main objective of the research was to investigate how the integration of laboratory modules, through RESTful Application Programming Interfaces (APIs), can enhance legacy systems in pathology laboratories, aiming for improvements in operational efficiency, data reliability, and user experience.
The object of analysis consisted of the source code of a legacy pathology system, used in a laboratory, focusing on the restructuring of the Registration module. This system, originally developed under the Model-View-Controller (MVC) architecture, served as a basis for demonstrating the modernization proposal and the architectural transition to a model based on RESTful APIs.
For the project development, ASP.NET Web API with C# technologies were employed, using Data Transfer Objects (DTOs) to standardize communication between client and server. The API was structured in layers, separating responsibilities between “controller”, services, and repositories, and used the HTTP (Hypertext Transfer Protocol) and JSON (JavaScript Object Notation) format for data exchange. To ensure ethical compliance and data protection, a functional prototype inspired by the legacy code was used, with synthetic data, without violating copyrights or institutional confidentiality.
The methodological procedures began with the analysis of the legacy system, aiming to understand its architecture and identify limitations. In this phase, the Registration module was selected as the main object of study, due to its centrality in the laboratory workflow and its relationships with other entities, such as exams, patients, and users. It was observed that the legacy system’s MVC architecture presented strong coupling between the presentation and control layers, with extensive use of ViewModels.
After the analysis, the modeling of the new architecture based on RESTful APIs was performed. The main “endpoints”, domain entities, and DTOs were defined, establishing a clear separation between input and output data. The objects RegistroRequest, to represent the data needed for creating a laboratory record, and RegistroResponse, to return data from the database after a request, were created, promoting objectivity and control of the information flow.
The implementation stage involved the development of REST “endpoints” using ASP.NET Web API. Three main “endpoints” were developed: Registration, Editing, and Query. The API architecture was organized into “controller”, services, and repositories layers, following the principle of separation of responsibilities. The “controller” layer acted as the entry point, the service layer concentrated business rules and entity mapping, and the repository layer communicated directly with the database, using SQL Server for data management.
Subsequently, functional tests were performed using tools like Swagger. These tests aimed to validate the behavior of the “endpoints” and the consistency of the data sent and received, verifying if the API met the requirements defined in the modeling phase. Swagger allowed visualization and testing of the API’s requests and responses, facilitating the understanding of the contracts defined between client and server.
Finally, a comparative analysis was performed between the legacy model and the new architecture developed. Aspects such as code organization, decoupling between layers, ease of maintenance, and integration capacity were analyzed. This stage sought to evaluate the improvements achieved with the adoption of the RESTful API-based architecture compared to the legacy MVC system.
3. Results and Discussion
The analysis of the legacy system revealed that the Model-View-Controller (MVC) architecture, although functional for web application development, presented significant limitations in the context of a pathology laboratory, especially regarding integration, scalability, and maintenance. A strong coupling was found between the control layer and the graphical interface, a characteristic that manifested in the extensive use of ViewModels. These ViewModels, which were supposed to represent data for the interface, ended up assuming multiple responsibilities, making the code more complex and heavy, as observed in the original system.
This excessive dependence on the presentation layer made it difficult to reuse business logic in other contexts and prevented efficient integration with external systems. The data types used in the return of the “endpoints” were intrinsically linked to the graphical interface, which limited the system’s flexibility and interoperability. Such a scenario highlighted the need for an architectural modernization that could overcome these barriers, aligning the system with contemporary demands for greater connectivity and efficiency, as emphasized by Pinto (2015) on the competitive advantage of APIs.
Given these observations, the restructuring of the Registration module through the implementation of RESTful APIs proved to be an effective approach to mitigate the identified deficiencies. The main improvement observed was the substantial reduction in coupling between the application and controller layers. In the new model, the controller began to act exclusively as an entry point for HTTP requests, decoupling itself from the presentation layer and allowing business logic to be reused independently of the graphical interface.
The adoption of the RESTful standard and the use of Data Transfer Objects (DTOs) were crucial for this transformation. Specific objects, such as RegistroRequest and RegistroResponse, were defined to manage input and output data, respectively. The RegistroRequest was designed to contain only the attributes necessary for creating a laboratory record, while the RegistroResponse was structured to return relevant data to the user after a request, whether for creation, listing, or consultation, avoiding unnecessary exposure of internal information.
This separation of responsibilities, with distinct DTOs for request and response, established well-defined contracts for client-server communication. This not only standardized data exchange, using the JSON format, but also contributed to the system’s security and organization, ensuring that only consolidated and necessary information was transferred. The approach contrasted with the legacy system, where a single “ViewModel” accumulated input and output functions, generating complexity and coupling.
The developed API architecture was structured in distinct layers: “controller”, services, and repositories. The “controller” is responsible for receiving HTTP requests, validating input data, converting DTOs, and orchestrating calls to the service layers. This organization promoted a clear separation of responsibilities, which is fundamental for code maintainability and evolution, according to software development best practices (CARMO, 2023).
The service layer, in turn, concentrates the application’s business rules. It processes the data received from the “controller”, performs additional validations, and maps RequestDto type entities to domain entities (“Entities”) that will be persisted in the database. Furthermore, the service layer is responsible for mapping entities originating from the database to ResponseDto type entities, ensuring that the presentation layer receives only the necessary data for display.
Complementarily, the repository layer performs the function of direct communication with the database, using frameworks like Entity Framework to persist the data mapped by the service layer. This approach avoids the data layer logic being directly exposed in the “controller”, promoting greater decoupling and adherence to modern software architecture principles. The use of these layers resulted in a more modular, scalable, and easily maintainable system.
The API implementation included the development of three main “endpoints” for the Registration module: Creation, Editing, and Query. These “endpoints” were designed to be accessible via HTTP protocol, using verbs such as POST for creating new records and GET for querying. The documentation of these “endpoints” was carried out using Swagger, a tool that allowed visualizing and testing API requests and responses, facilitating the understanding of communication contracts.
The Swagger interface demonstrated the execution of the “endpoint” for registration, where the request was sent in JSON format, following the structure of the RegistroRequestDTO. In cases of success, the API returned the HTTP code 200 (Ok), indicating that the operation was processed successfully. In error situations, codes such as 400 (Bad Request) or 500 (Internal Server Error) were returned, providing clear feedback on the request status, which is essential for the application’s robustness.
The comparison between the structure of the “ViewModel” of the legacy system and the DTO classes of the new API evidenced a significant evolution. While the “ViewModel” concentrated multiple attributes for input and output, often containing unnecessary fields and exposing internal data, the DTOs were designed to be lean and focused on their specific responsibilities. This reorganization promoted greater clarity in the definition of application flows and in the handling of business rules.
The architecture based on RESTful APIs prioritizes communication and data transfer through DTOs, promoting decoupling between application layers and focusing on data manipulation according to business rules. This approach allows the system to integrate with multiple clients, regardless of the technology used, significantly expanding the possibilities of application use and its adaptability to different platforms, such as mobile applications or other services.
In the healthcare context, the use of APIs as data integration tools represents a remarkable advance in how information is shared among various systems. This approach enables the agile and standardized transmission of critical data, such as exam results and diagnoses, contributing to better clinical decision-making, and reducing errors and delays in care. The biggest beneficiary of this modernization is the patient, who receives more efficient and safer care.
In summary, the comparison between the traditional MVC model of the legacy system and the RESTful API-based approach revealed striking structural and functional differences. The MVC model, with its strong dependence on ViewModels and coupling with the presentation layer, concentrated logic in the “controller” and hindered external integration. In contrast, the RESTful API, with communication via DTOs, layer decoupling, and a focus on data and services, proved to be a more flexible, scalable, and interoperable solution, aligned with the modernization needs of legacy systems.
Although the restructuring was applied to a specific module of the legacy system, which limits the generalization of the results to the entire application, the findings confirm the feasibility and benefits of adopting an architecture based on RESTful APIs. The research demonstrated that this approach is efficient for modernizing legacy systems in pathology laboratories, improving operational efficiency, data reliability, and user experience, fulfilling the objective of investigating the contribution of RESTful APIs to the improvement of these systems.
4. Conclusion
This study investigated how the integration of laboratory modules through Application Programming Interfaces (APIs) based on the Representational State Transfer (REST) standard can enhance legacy systems in pathology, aiming for greater operational efficiency, data reliability, and user experience. It was found that the traditional Model-View-Controller (MVC) architecture of the legacy system presented strong coupling between layers and dependence on the graphical interface, limiting the reuse of business logic and integration with external systems. The restructuring of the Registration module, with the implementation of a RESTful API and the use of Data Transfer Objects (DTOs), demonstrated a substantial reduction in coupling, with the “controller” acting as the entry point for HTTP requests and the business logic separated into service and repository layers. This approach standardized communication via JSON, improved code organization and security, and allowed integration with multiple clients, representing a significant advancement in the modernization of health systems and the optimization of critical patient data sharing.
As a limitation, the restructuring was applied to only one specific module of the legacy system, which restricts the generalization of the results to the entire application. For future studies, it is suggested to extend the implementation of the RESTful architecture to other modules of the system, as well as to incorporate automatic tests and performance monitoring. Furthermore, comparative analyses with other architectures are recommended to deepen the understanding of legacy system modernization in the healthcare area.
Bibliographic References
BANCROFT, J. D.; GAMBLE, M. Theory and practice of histological techniques. 6. ed. Philadelphia: Churchill Livingstone, 2008.
BORGES, Mauricio Ribeiro. Contribuição ao estudo do uso da imagem digital em anatomia patológica, através de um modelo diagnóstico em neuropatologia: proposta de protocolo de rotina. 2007. Dissertação de Mestrado.
BRASIL. Ministério da Saúde. Plano de Transformação Digital da Saúde. Brasília: DATASUS, 2020.
CARMO, Klayver Ximenes. Um estudo comparativo entre tecnologias de back-end: Node. js, Django REST Framework e ASP. NET Core. 2023
MUGNOL, Katia Cristina Ugolini; FERRAZ, Marcos Bosi. Sistema de informação como ferramenta de cálculo e gestão de custos em laboratórios de análises clínicas. Jornal Brasileiro de Patologia e Medicina Laboratorial, v. 42, p. 95-102, 2006.
O’BRIEN, James A.; MARAKAS, George M. Administração de sistemas de informação. 15. ed. Porto Alegre: AMGH, 2013.
PINTO, José Luís Caldeira. API RESTful para Sistema de Gestão de Desempenho de Redes de Telecomunicações. 2015. Dissertação de Mestrado. Universidade de Aveiro (Portugal).
PITA, Pedro Henrique Mendes. Guia Técnico para Apoio no desenvolvimento de API RESTFul seguras. 2024. Dissertação de Mestrado. Instituto Politecnico de Beja (Portugal).
Article originating from the Final Course Work of the Specialization in Software Engineering of the MBA USP/Esalq
To learn more about the course, click here and access the MBX Academy platform