Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 98583ca0 authored by romuald dubourg's avatar romuald dubourg
Browse files

[Update] Refactor + cleain comments

parent 3a54bff5
No related branches found
No related tags found
No related merge requests found
Showing
with 14 additions and 85 deletions
......@@ -18,57 +18,32 @@ import org.eclipse.microprofile.config.ConfigProvider;
import java.util.ArrayList;
import java.util.List;
/**
* This servlet is the actual FHIR server itself
*/
public class MDHRestfullServer extends RestfulServer {
private static final long serialVersionUID = 1L;
/**
* Constructor
*/
public MDHRestfullServer() {
super(FhirContext.forR4Cached()); // This is an R4 server
super(FhirContext.forR4Cached());
}
/**
* This method is called automatically when the
* servlet is initializing.
*/
@Override
public void initialize() {
/*
* Two resource providers are defined. Each one handles a specific
* type of resource.
*/
List<IResourceProvider> providers = new ArrayList<>();
providers.add(new DocumentReferencesResourceProvider(new DocumentReferencesProviderServiceImpl()));
providers.add(new ListResourceProvider(new ListProviderServiceImpl()));
setResourceProviders(providers);
/*
* Use a narrative generator. This is a completely optional step,
* but can be useful as it causes HAPI to generate narratives for
* resources which don't otherwise have one.
*/
INarrativeGenerator narrativeGen = new DefaultThymeleafNarrativeGenerator();
getFhirContext().setNarrativeGenerator(narrativeGen);
/*
* Use nice coloured HTML when a browser is used to request the content
*/
String evsEndpoint = ConfigProvider.getConfig().getValue("evs.endpoint", String.class);
if (Boolean.TRUE.equals(ConfigProvider.getConfig().getValue("activate.http.validator", Boolean.class))) {
String httpValidationName = ConfigProvider.getConfig().getValue("http.validation.name", String.class);
String httpValidationSchematronName = ConfigProvider.getConfig().getValue("http.validation.schematron.name", String.class);
registerInterceptor(new HTTPValidatorInterceptor(new ValidationConfiguration().setEvsEndpoint(evsEndpoint).setValidationService(new ValidationService().setValidator(httpValidationName).setName(httpValidationSchematronName))));
}
if (Boolean.TRUE.equals(ConfigProvider.getConfig().getValue("activate.fhir.validator", Boolean.class))) {
......@@ -76,11 +51,8 @@ public class MDHRestfullServer extends RestfulServer {
String fhirValidationSchematronName = ConfigProvider.getConfig().getValue("fhir.validation.schematron.name", String.class);
registerInterceptor(new FhirValidatorInterceptor(new ValidationConfiguration().setEvsEndpoint(evsEndpoint).setValidationService(new ValidationService().setValidator(fhirValidationName).setName(fhirValidationSchematronName))));
}
}
}
......@@ -2,7 +2,6 @@ package net.ihe.gazelle.fhir.simulator.server.interlay.loader;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.DocumentReference;
......
......@@ -10,8 +10,6 @@ import org.eclipse.microprofile.config.ConfigProvider;
import org.hl7.fhir.instance.model.api.IBaseBundle;
import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.DocumentReference;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -30,7 +28,6 @@ public class DocumentReferencesProviderServiceImpl implements DocumentReferences
public DocumentReference getDocumentReference(String id) {
// Use the FHIR client to send a request to the other server
return client.read()
.resource(DocumentReference.class)
.withId(id)
......@@ -41,15 +38,10 @@ public class DocumentReferencesProviderServiceImpl implements DocumentReferences
public List<DocumentReference> searchDocumentReferences(RequestDetails request) {
Map<String, String[]> parameterMap = request.getParameters();
Map<String, String> singleValueMap = new HashMap<>();
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
singleValueMap.put(entry.getKey(), entry.getValue()[0]);
}
// Use the FHIR client to send a request to the other server
IQuery<IBaseBundle> query = client.search().forResource(DocumentReference.class);
for (Map.Entry<String, String> entry : singleValueMap.entrySet()) {
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
String value = entry.getValue()[0];
query = query.where(new StringClientParam(key).matches().value(value));
}
return query.returnBundle(org.hl7.fhir.r4.model.Bundle.class)
......@@ -63,9 +55,6 @@ public class DocumentReferencesProviderServiceImpl implements DocumentReferences
@Override
public Bundle createBundleResource(Bundle bundleDocument) {
// Use the FHIR client to send a request to the other server
return client.transaction()
.withBundle(bundleDocument)
.execute();
......
package net.ihe.gazelle.fhir.simulator.server.interlay.loader;
import ca.uhn.fhir.rest.api.MethodOutcome;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4.model.ListResource;
import java.util.List;
......
......@@ -9,8 +9,6 @@ import jakarta.enterprise.context.ApplicationScoped;
import org.eclipse.microprofile.config.ConfigProvider;
import org.hl7.fhir.instance.model.api.IBaseBundle;
import org.hl7.fhir.r4.model.ListResource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -31,15 +29,10 @@ public class ListProviderServiceImpl implements ListProviderService {
public List<ListResource> searchListResource(RequestDetails request) {
Map<String, String[]> parameterMap = request.getParameters();
Map<String, String> singleValueMap = new HashMap<>();
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
singleValueMap.put(entry.getKey(), entry.getValue()[0]);
}
// Use the FHIR client to send a request to the other server
IQuery<IBaseBundle> query = client.search().forResource(ListResource.class);
for (Map.Entry<String, String> entry : singleValueMap.entrySet()) {
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
String value = entry.getValue()[0];
query = query.where(new StringClientParam(key).matches().value(value));
}
return query.returnBundle(org.hl7.fhir.r4.model.Bundle.class)
......
......@@ -2,28 +2,18 @@ package net.ihe.gazelle.fhir.simulator.server.interlay.provider;
import ca.uhn.fhir.rest.annotation.*;
import ca.uhn.fhir.rest.api.MethodOutcome;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.param.DateParam;
import ca.uhn.fhir.rest.param.StringParam;
import ca.uhn.fhir.rest.param.TokenParam;
import ca.uhn.fhir.rest.server.BundleProviders;
import ca.uhn.fhir.rest.server.IResourceProvider;
import jakarta.inject.Inject;
import jakarta.servlet.http.HttpServletRequest;
import net.ihe.gazelle.fhir.simulator.server.interlay.loader.DocumentReferencesProviderService;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.r4.model.*;
import java.net.http.HttpRequest;
import java.util.ArrayList;
import java.util.List;
/**
* This is a resource provider that retrieves Patient resources from a PatientResourceProviderService.
*/
public class DocumentReferencesResourceProvider implements IResourceProvider {
......@@ -41,13 +31,11 @@ public class DocumentReferencesResourceProvider implements IResourceProvider {
}
//IT-68
@Read
public DocumentReference readDocumentReference( @IdParam IIdType theId) {
return documentReferencesProviderService.getDocumentReference(theId.getValue());
}
//IT-67
@Search()
public List<DocumentReference> findDocumentReference(
@OptionalParam(name = DocumentReference.SP_PATIENT) TokenParam thePatient,
......@@ -67,8 +55,6 @@ public class DocumentReferencesResourceProvider implements IResourceProvider {
return documentReferencesProviderService.searchDocumentReferences(requestDetails);
}
//IT-65
@Transaction()
public Bundle createDocumentReference(@TransactionParam Bundle bundle) {
return documentReferencesProviderService.createBundleResource(bundle);
......
package net.ihe.gazelle.fhir.simulator.server.interlay.provider;
import ca.uhn.fhir.rest.annotation.Create;
import ca.uhn.fhir.rest.annotation.OptionalParam;
import ca.uhn.fhir.rest.annotation.ResourceParam;
import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.rest.api.MethodOutcome;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.param.DateParam;
import ca.uhn.fhir.rest.param.TokenParam;
......@@ -13,15 +10,12 @@ import ca.uhn.fhir.rest.server.IResourceProvider;
import jakarta.inject.Inject;
import net.ihe.gazelle.fhir.simulator.server.interlay.loader.ListProviderService;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.ListResource;
import java.util.List;
/**
* This is a resource provider that retrieves Patient resources from a PatientResourceProviderService.
*/
public class ListResourceProvider implements IResourceProvider {
......@@ -37,8 +31,6 @@ public class ListResourceProvider implements IResourceProvider {
public Class<? extends IBaseResource> getResourceType() {
return ListResource.class;
}
//IT-66
@Search()
public List<ListResource> findListResource(@OptionalParam(name = ListResource.SP_CODE) TokenParam code,
@OptionalParam(name = ListResource.SP_DATE) DateParam date,
......@@ -46,7 +38,6 @@ public class ListResourceProvider implements IResourceProvider {
@OptionalParam(name = ListResource.SP_SOURCE) TokenParam source,
@OptionalParam(name = ListResource.SP_STATUS) String status,
@OptionalParam(name = ListResource.SP_SUBJECT) TokenParam subject,
@OptionalParam(name = "designationType") String designationType,
RequestDetails requestDetails
) {
return listProviderService.searchListResource(requestDetails);
......
nist.fhir.toolkit.endpoint=http://localhost:7080/fhir
activate.http.validator=false
http.validation.name=CH-ITI-78-Patient-Mobile Patient Demographics Query-ValidationProfile
http.validation.schematron.name=a
http.validation.name=Validator
http.validation.schematron.name=Schematron-Validator
activate.fhir.validator=false
fhir.validation.name=a
fhir.validation.schematron.name=a
fhir.validation.name=Validator
fhir.validation.schematron.name=Scheme-Validator
evs.endpoint=http://localhost:8080/evs
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment