Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 8373e041 authored by Franck Desaize's avatar Franck Desaize
Browse files

Add java doc and fix bug

parent a9381944
No related branches found
No related tags found
1 merge request!1Release
......@@ -12,14 +12,16 @@ public enum Namespaces {
/**
* Default constructor for the class. Defines the value of the value in the JNDI context. This aims to be used by the Preferences Module.
* @param value value of the value in the JNDI context.
*
* @param value value of the value in the JNDI context.
*/
Namespaces(String value){
Namespaces(String value) {
this.value = value;
}
/**
* Getter for the value property.
*
* @return the value of the value property.
*/
public String getValue() {
......
......@@ -11,7 +11,7 @@ public class OperationalPreferencesPIXm implements OperationalPreferencesClientA
@Override
public Map<String, List<String>> wantedMandatoryPreferences() {
Map<String, List<String>> mandatoryPreferences = new HashMap<>();
List<String> deploymentPreferences = new ArrayList<>() ;
List<String> deploymentPreferences = new ArrayList<>();
deploymentPreferences.add(Preferences.XREF_PATREG.toString());
......
package net.ihe.gazelle.adapter.preferences;
public enum Preferences {
XREF_PATREG(Namespaces.DEPLOYMENT,"xrefpatientregistry.url"),
PATIENT_PATREG(Namespaces.DEPLOYMENT,"patientregistry.url");
XREF_PATREG(Namespaces.DEPLOYMENT, "xrefpatientregistry.url"),
PATIENT_PATREG(Namespaces.DEPLOYMENT, "patientregistry.url");
private Namespaces namespace;
private String key;
......@@ -10,16 +10,18 @@ public enum Preferences {
/**
* Default constructor for the class. Defines the value of the Preference's key. It can then be used throughout the application to retrieve the
* preference value.
* @param namespace value of the namespace where the Preference is defined.
* @param key value of the Preference's key.
*
* @param namespace value of the namespace where the Preference is defined.
* @param key value of the Preference's key.
*/
Preferences(Namespaces namespace, String key){
Preferences(Namespaces namespace, String key) {
this.namespace = namespace;
this.key = key;
}
/**
* Getter for the namespace property.
*
* @return the value of the namespace property.
*/
public Namespaces getNamespace() {
......@@ -28,6 +30,7 @@ public enum Preferences {
/**
* Getter for the key property.
*
* @return the value of the key property.
*/
public String getKey() {
......
......@@ -108,7 +108,7 @@ public class PatientRegistryXRefSearchClient {
throw new SearchCrossReferenceException("Can't connect to patient registry !");
}
}
if (serverUrl==null){
if (serverUrl == null) {
getUrlOfServer();
}
......@@ -116,10 +116,11 @@ public class PatientRegistryXRefSearchClient {
/**
* Proceed to the request using the XReferencePatientRegistry client and prepare the fhir response
*
* @param sourceIdentifier Identity of the patient
* @param targetSystemList targetSystem we want to retrieve through PatientRegistry
* @return Fhir response that contain the target identity
* @throws SearchCrossReferenceException if the client can not be initialized
* @throws SearchCrossReferenceException if the client can not be initialized
*/
public Parameters process(EntityIdentifier sourceIdentifier, List<String> targetSystemList) throws SearchCrossReferenceException {
initializeSearchClient();
......@@ -130,12 +131,14 @@ public class PatientRegistryXRefSearchClient {
switch (searchCrossReferenceException.getCause().getMessage()) {
case ERROR_IN_THE_SOURCE_IDENTIFIER_SYSTEM_DOES_NOT_EXIT:
case THE_SYSTEM_IDENTIFIER_FROM_SOURCE_IDENTIFIER_CANNOT_BE_NULL_OR_EMPTY:
throw new InvalidRequestException(SOURCE_IDENTIFIER_ASSIGNING_AUTHORITY_NOT_FOUND, generateOperationOutcome("code-invalid",SOURCE_IDENTIFIER_ASSIGNING_AUTHORITY_NOT_FOUND));
throw new InvalidRequestException(SOURCE_IDENTIFIER_ASSIGNING_AUTHORITY_NOT_FOUND, generateOperationOutcome("code-invalid",
SOURCE_IDENTIFIER_ASSIGNING_AUTHORITY_NOT_FOUND));
case ERROR_IN_THE_SOURCE_IDENTIFIER_IT_DOES_NOT_MATCH_ANY_PATIENT:
case ERROR_IN_THE_SOURCE_IDENTIFIER_IT_DOES_NOT_MATCH_ANY_IDENTITY:
throw new ResourceNotFoundException(SOURCE_IDENTIFIER_PATIENT_IDENTIFIER_NOT_FOUND, generateOperationOutcome("not-found",SOURCE_IDENTIFIER_PATIENT_IDENTIFIER_NOT_FOUND));
throw new ResourceNotFoundException(SOURCE_IDENTIFIER_PATIENT_IDENTIFIER_NOT_FOUND, generateOperationOutcome("not-found",
SOURCE_IDENTIFIER_PATIENT_IDENTIFIER_NOT_FOUND));
case ONE_OF_THE_TARGET_DOMAIN_DOES_NOT_EXIST:
throw new ForbiddenOperationException(TARGET_SYSTEM_NOT_FOUND, generateOperationOutcome("code-invalid",TARGET_SYSTEM_NOT_FOUND));
throw new ForbiddenOperationException(TARGET_SYSTEM_NOT_FOUND, generateOperationOutcome("code-invalid", TARGET_SYSTEM_NOT_FOUND));
default:
throw new InternalErrorException("An internal error occurred", searchCrossReferenceException);
}
......@@ -166,7 +169,7 @@ public class PatientRegistryXRefSearchClient {
Parameters.ParametersParameterComponent targetId = new Parameters.ParametersParameterComponent();
targetId.setName("targetId");
Reference ref = new Reference();
ref.setReference("https://"+serverUrl+"/pixm-connector/fhir_ihe/Patient/" + pat.getUuid());
ref.setReference("https://" + serverUrl + "/pixm-connector/fhir_ihe/Patient/" + pat.getUuid());
targetId.setValue(ref);
parameters.addParameter(targetId);
......@@ -179,6 +182,7 @@ public class PatientRegistryXRefSearchClient {
/**
* Method to construct the fhir response, return true if the entityIdentifier match a targetSystem and false otherwise
* It returns true is the targetSystem list is empty.
*
* @param targetSystemList
* @param entityIdentifierSystem
* @return boolean
......@@ -198,11 +202,12 @@ public class PatientRegistryXRefSearchClient {
/**
* Method to generate the Error outcome in the response
* @param codeString Code of the error catch
*
* @param codeString Code of the error catch
* @param diagnostics origin of the issue
* @return generated Operation outcome for the Fhir response
*/
private OperationOutcome generateOperationOutcome(String codeString,String diagnostics) {
private OperationOutcome generateOperationOutcome(String codeString, String diagnostics) {
OperationOutcome code = new OperationOutcome();
OperationOutcome.OperationOutcomeIssueComponent issue = new OperationOutcome.OperationOutcomeIssueComponent();
issue.setSeverity(OperationOutcome.IssueSeverity.ERROR);
......@@ -215,7 +220,7 @@ public class PatientRegistryXRefSearchClient {
/**
* The method is used to retrieve the url of the current server.
*/
private void getUrlOfServer(){
private void getUrlOfServer() {
InetAddress ip;
try {
ip = InetAddress.getLocalHost();
......
......@@ -9,10 +9,7 @@ import ca.uhn.fhir.rest.param.StringOrListParam;
import ca.uhn.fhir.rest.param.StringParam;
import ca.uhn.fhir.rest.param.TokenParam;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
import ca.uhn.fhir.rest.server.exceptions.*;
import net.ihe.gazelle.app.patientregistryapi.application.SearchCrossReferenceException;
import net.ihe.gazelle.app.patientregistryapi.business.EntityIdentifier;
import net.ihe.gazelle.app.patientregistryapi.business.PersonName;
......@@ -171,7 +168,7 @@ public class ChPatientResourceProvider implements IResourceProvider {
try {
parametersResults = patientRegistryXRefSearchClient.process(sourceIdentifier, targetSystemList);
} catch (SearchCrossReferenceException e) {
e.printStackTrace();
throw new InternalErrorException(e);
}
return parametersResults;
}
......
......@@ -8,11 +8,11 @@ import ca.uhn.fhir.rest.param.StringParam;
import ca.uhn.fhir.rest.param.TokenParam;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import net.ihe.gazelle.app.patientregistryapi.application.SearchCrossReferenceException;
import net.ihe.gazelle.app.patientregistryapi.business.EntityIdentifier;
import net.ihe.gazelle.app.patientregistryxrefsearchclient.adapter.XRefSearchProcessResponseException;
import net.ihe.gazelle.application.PatientRegistryXRefSearchClient;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4.model.Parameters;
......@@ -68,7 +68,7 @@ public class IhePatientResourceProvider implements IResourceProvider {
try {
parametersResults = patientRegistryXRefSearchClient.process(sourceIdentifier, targetSystemList);
} catch (SearchCrossReferenceException e) {
e.printStackTrace();
throw new InternalErrorException(e);
}
return parametersResults;
......
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