Code Monkey home page Code Monkey logo

viepovsky / medical-laboratory-service Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 456 KB

Spring, Hibernate & other frameworks used to make backend for lab diagnostic service. Allowing patients to access their test results online. Powered by PostgreSQL, with Flyway for db migration.

Java 99.92% Dockerfile 0.08%
flyway hibernate junit5 lombok maven mockito postgresql spring-boot spring-validation spring-web jwt jwt-authentication docker docker-compose

medical-laboratory-service's Introduction

Medical Laboratory Service

GitHub Workflow Status Codecov test coverage

Medical Laboratory Service is a secure RESTful application that allows patients to access their laboratory test results online. The application's endpoints are protected using JSON Web Tokens, ensuring that only authorized users can access sensitive medical data. The application stores user personal data, as well as diagnostic results. Users after authorization can simply view and download their results online. In addition, the application allows patients to browse available examinations that are offered by the laboratory. This application is specifically designed to be used by medical laboratories.

Note: This is a backend of such service.

Technnologies

The application currently uses the following frameworks and technologies:

  • Spring Boot: Web, Data JPA, Test, Validation
  • Endpoints secured using Spring Security with JSON Web Tokens (JWT)
  • Hibernate
  • Unit tests with: JUnit, Mockito, AssertJ
  • PostgreSQL + H2 for unit tests
  • Flyway
  • Lombok
  • Maven
  • Swagger

In this service I have used my own PESEL validation library to ensure the correctness of PESEL numbers. The library has been published on Maven Central Repository and is accessible for everyone to use. You can check out the library's code here.

How to run

Using Docker

If Docker is installed and running you can simply run the entire application by executing docker compose up -d in the terminal. Wait for containers to start then you can send requests to http://localhost:8080 to test the application.

Without Docker

To run the application, you need to have Postgres installed. You have to create a database named medical, or use a different one by updating the configuration in application.yml. Make sure to also check the username and password for the database.

Before starting the application, you need to set an environment variable named MEDICAL_SECRET_KEY with a 256-bit hex encryption key or copy the one from application-test.yml and paste it into application.yml.

To start the application, you can either run the MedicalLaboratoryApplication class, or type ./mvnw spring-boot:run in your IDE terminal.

Once the application is running, you can test it by sending requests to the endpoints using tools like Postman. The application runs on http://localhost:8080/

Keep in mind that the application is secured with JWT token. To access the endpoints, you need to either register a new user at http://localhost:8080/medical/auth/register, or use the provided test user with user privileges (login: testuser, password: testpassword) or the test admin user (login: testadmin, password: testpassword).

Future plans for the application

Next, I plan to add user and admin views to the application using HTML, CSS, and JavaScript.

Example usage

1. Logging to service as ADMIN(testadmin)

POST to http://localhost:8080/medical/auth/authenticate

With body:

{
    "login":"testadmin",
    "password":"testpassword"
}

You will receive in response authorization token, keep it.

2. Uploading medical results for specific USER(testuser)

POST to http://localhost:8080/medical/results

With body:

{
    "userLogin": "testuser",
    "status":"AWAITING_RESULT",
    "registration":"2020-11-15T20:11:10",
    "type":"URINE",
    "resultsPdf": <PLEASE SEE BELOW>
}

Link to GitHub gist with byte array to paste in resultsPdf

Don't forget to put authentication code that you have received before as Bearer Token

3. Login as USER(testuser)

POST to http://localhost:8080/medical/auth/authenticate

With body:

{
    "login":"testuser",
    "password":"testpassword"
}

You will receive in response authorization token, keep it.

4. Get all diagnostic results for USER(testuser)

GET to http://localhost:8080/medical/results with parameter login

for example http://localhost:8080/medical/results?login=testuser

Don't forget to put authentication code that you have received before for the testuser as Bearer Token

In response you will receive a list of diagnostic results, keep the listed ID.

5. Get PDF for diagnostic result for USER(testuser)

GET to http://localhost:8080/medical/results/{id} with parameter login

for example http://localhost:8080/medical/results/501?login=testuser

Don't forget to put authentication code that you have received before for the testuser as Bearer Token

In response you should receive a dummy PDF file, as shown below: Postman screenshot

Screenshots

Swagger screenshot

Test coverage screenshot

medical-laboratory-service's People

Contributors

viepovsky avatar

Watchers

Kostas Georgiou avatar  avatar

Forkers

mahboobali

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.