-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMedicalGuideLineService.java
More file actions
128 lines (107 loc) · 4.21 KB
/
Copy pathMedicalGuideLineService.java
File metadata and controls
128 lines (107 loc) · 4.21 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package com.spirit.DMRE;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.Observation;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Table;
import com.spirit.DMRE.Utils.ObservationResource;
import com.spirit.DMRE.Utils.SampleResourceParseTest2;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.parser.IParser;
import javax.ws.rs.core.Application;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.MediaType;
import com.spirit.DMRE.Provarules.ExecuteProvaRules;
import com.spirit.DMRE.Provarules.ProvaTest2;
import com.spirit.DMRE.Utils.*;
@Path("/MedicalGuideLineService")
public class MedicalGuideLineService{
private static Logger logger = Logger.getLogger("com.spirit.DMRE.MedicalGuideLineService");
private static List<Object> returnList = new ArrayList<Object>();
private static int returnListCount = 0;
@Context
private UriInfo context;
@Context
private Request request;
/**
* The DistributedMedicalServiceEngine is the core server, which allows to start different services, as needed in the DMRE Distributed environment
* @throws Exception
*/
@GET
@Path("{name}")
public String getMsg(@PathParam("name") String name, @Context HttpServletResponse servletResponse) {
StringBuilder sb = null;
String output = null;
System.out.println("SysOut: " + this.getClass().getName() + ": " + name);
if(name.isEmpty()) {
System.out.println("request is empty");
}else {
System.out.println("request is not empty");
System.out.println("Request value: " + name);
}
return "MedicalGuideLineService GET-Done";
}
@POST
@Path("{name}")
public Response MedicalGuideLineExecution(String jsonrequest,@PathParam("ExecuteMedicalGuideline") String medicalGuideLineParameter){
logger.info("Hitting the medical GuidelineService: the Post-part");
System.out.println("MedicalGuideLineService: " + medicalGuideLineParameter);
System.out.println("[MedicalGuideLineService] now in POST for a SPARQL-Query");
System.out.println("[MedicalGuideLineService] JSON-Request: " + jsonrequest);
// ProvaTest2 test = new ProvaTest2();
// test.runNow();
try {
Map<String,Object> inputMap = new ObjectMapper().readValue(jsonrequest, LinkedHashMap.class);
for(Map.Entry<String, Object> entry : inputMap.entrySet()) {
System.out.println(entry.getKey() + " : " + entry.getValue().toString());
}
ExecuteProvaRules executor = new ExecuteProvaRules(inputMap);
//ProvaTest2 test = new ProvaTest2();
executor.runNow();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonProcessingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(returnListCount>1) {
return Response.ok("ResponseFromMedicalGuidelineExecution - more than one results\n" + returnList, new MediaType("text","plain")).build();
}else {
return Response.ok("ResponseFromMedicalGuidelineExecution\n" + returnList, new MediaType("text","plain")).build();
}
}
public static void Response(int errorCounterSend, List<Object> returnListFromProva) {
System.out.println("MedicalGuideLineService - Response");
System.out.println("errorCounterSend: " + errorCounterSend);
System.out.println("returnList: " + returnListFromProva);
returnList = returnListFromProva;
returnListCount = errorCounterSend;
}
}