-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathCareContextLinkingController.java
More file actions
63 lines (55 loc) · 2.31 KB
/
Copy pathCareContextLinkingController.java
File metadata and controls
63 lines (55 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.wipro.fhir.controller.v3.careContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wipro.fhir.service.v3.careContext.CareContextLinkingService;
import com.wipro.fhir.utils.exception.FHIRException;
import com.wipro.fhir.utils.response.OutputResponse;
import io.swagger.v3.oas.annotations.Operation;
@RestController
@RequestMapping(value = "/careContext", headers = "Authorization")
public class CareContextLinkingController {
@Autowired
private CareContextLinkingService careContextLinkingService;
private final Logger logger = LoggerFactory.getLogger(this.getClass().getName());
@Operation(summary = "Generate token for care context linking")
@PostMapping(value = { "/generateCareContextToken" })
public String requestOtpForEnrollment(@RequestBody String request) {
logger.info("Generate token for care context API request " + request);
OutputResponse response = new OutputResponse();
try {
if (request != null) {
String s = careContextLinkingService.generateTokenForCareContext(request);
response.setResponse(s);
} else
throw new FHIRException("NDHM_FHIR Empty request object");
} catch (FHIRException e) {
response.setError(5000, e.getMessage());
logger.error(e.toString());
}
logger.info("NDHM_FHIR generate token for care context API response " + response.toString());
return response.toString();
}
@Operation(summary = "link care context")
@PostMapping(value = { "/linkCareContext" })
public String add(@RequestBody String request) {
logger.info("link care context API request " + request);
OutputResponse response = new OutputResponse();
try {
if (request != null) {
String s = careContextLinkingService.linkCareContext(request);
response.setResponse(s);
} else
throw new FHIRException("NDHM_FHIR Empty request object");
} catch (FHIRException e) {
response.setError(5000, e.getMessage());
logger.error(e.toString());
}
logger.info("link care context API response " + response.toString());
return response.toString();
}
}