-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAIFAController.java
More file actions
64 lines (52 loc) · 2.07 KB
/
Copy pathAIFAController.java
File metadata and controls
64 lines (52 loc) · 2.07 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
64
package com.medexpress.controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.GetMapping;
import com.medexpress.service.AIFAService;
import com.medexpress.dto.AIFAAutocompleteResponse;
import com.medexpress.dto.AIFADrugsResponse;
import com.medexpress.dto.CommonDrug;
import reactor.core.publisher.Mono;
@RestController
@RequestMapping("/api/v1/aifa")
public class AIFAController {
private final AIFAService aifaService;
public AIFAController(AIFAService aifaService) {
this.aifaService = aifaService;
}
// autocomplete return list of drugs
// https://api.aifa.gov.it/aifa-bdf-eif-be/1.0.0/autocomplete?query=tac&nos=5
// {
// "status": 200,
// "data": [
// "TACALCITOLO (ATC)",
// "TACALCITOLO MONOIDRATO (PRINCIPIO ATTIVO)",
// "TACFORIUS (MEDICINALE)",
// "TACHICAF (MEDICINALE)",
// "TACHIDOL (MEDICINALE)"
// ]
// }
@GetMapping("/autocomplete")
public Mono<AIFAAutocompleteResponse> getAutocomplete(@RequestParam String query,
@RequestParam(defaultValue = "5") int nos) {
return aifaService.getAutocompleteResults(query, nos);
}
// https://api.aifa.gov.it/aifa-bdf-eif-be/1.0.0/formadosaggio/ricerca?query=Tachipirina&spellingCorrection=true&page=0
@GetMapping("/drugs")
public Mono<AIFADrugsResponse> getDrugs(
@RequestParam String query,
@RequestParam(defaultValue = "true") boolean spellingCorrection,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "10") int size) {
return aifaService.getDrugs(query, spellingCorrection, page, size);
}
// get package
@GetMapping("/package")
public Mono<CommonDrug> getPackage(
// iddrug and idpackage
@RequestParam String drugId,
@RequestParam String packageId) {
return aifaService.getPackage(drugId, packageId);
}
}