GithubHelp home page GithubHelp logo

upstacapplication's Introduction

UpstacApplication

package org.upgrad.upstac.testrequests.consultation;

import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import lombok.ToString; import org.upgrad.upstac.testrequests.TestRequest; import org.upgrad.upstac.users.User;

import javax.persistence.*; import java.time.LocalDate;

@Data @Entity public class Consultation {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Long id;

@OneToOne(fetch = FetchType.LAZY)
@JsonIgnore
@ToString.Exclude
private TestRequest request;

private DoctorSuggestion suggestion;


private String comments;

private LocalDate updatedOn;

@ManyToOne
User doctor;

import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import org.upgrad.upstac.config.security.UserLoggedInService; import org.upgrad.upstac.exception.AppException; import org.upgrad.upstac.testrequests.RequestStatus; import org.upgrad.upstac.testrequests.TestRequest; import org.upgrad.upstac.testrequests.TestRequestQueryService; import org.upgrad.upstac.testrequests.TestRequestUpdateService; import org.upgrad.upstac.testrequests.flow.TestRequestFlowService; import org.upgrad.upstac.users.User;

import javax.validation.ConstraintViolationException; import java.util.List;

import static org.upgrad.upstac.exception.UpgradResponseStatusException.asBadRequest; import static org.upgrad.upstac.exception.UpgradResponseStatusException.asConstraintViolation;

@RestController @RequestMapping("/api/labrequests") public class LabRequestController {

Logger log = LoggerFactory.getLogger(LabRequestController.class);

@Autowired
private TestRequestUpdateService testRequestUpdateService;

@Autowired
private TestRequestQueryService testRequestQueryService;

@Autowired
private TestRequestFlowService testRequestFlowService;

@Autowired
private UserLoggedInService userLoggedInService;

// It helps fetching all the Test Requests with Status as INITIATED, in the Tester's bucket
@GetMapping("/to-be-tested")
@PreAuthorize("hasAnyRole('TESTER')")
public List<TestRequest> getForTests() {

   return testRequestQueryService.findBy(RequestStatus.INITIATED);

}

// It helps fetching all the assigned Test Requests for the logged-in Tester
@GetMapping
@PreAuthorize("hasAnyRole('TESTER')")
public List<TestRequest> getForTester() {

    User tester = userLoggedInService.getLoggedInUser();
    return testRequestQueryService.findByTester(tester);

}

// It helps fetching all the assigned Test Requests for the logged-in Tester
@PreAuthorize("hasAnyRole('TESTER')")
@PutMapping("/assign/{id}")
public TestRequest assignForLabTest(@PathVariable Long id) {

    User tester = userLoggedInService.getLoggedInUser();
    return testRequestUpdateService.assignForLabTest(id,tester);

}

// It helps updating the assigned Test Requests
@PreAuthorize("hasAnyRole('TESTER')")
@

upstacapplication's People

Contributors

sukanya1201 avatar

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.