use of org.hl7.fhir.r4.model.Endpoint in project Gravity-SDOH-Exchange-RI by FHIR.
the class AuthorizationClient method getTokenResponse.
/**
* Extract token endpoint url from the Authorization Server metadata endpoint and return token response after
* successful authentication.
*
* @param authServerUrl Authorization Server Base URL
* @param clientId OAuth2 Client ID
* @param secret OAuth2 Client Secret
* @param scope OAuth2 Client Scope
* @return {@link TokenResponse} entity
* @throws AuthClientException will be thrown if token retrieval fails
*/
public TokenResponse getTokenResponse(URI authServerUrl, String clientId, String secret, String scope) throws AuthClientException {
HttpEntity<MultiValueMap<String, String>> entity = createRequestEntity(clientId, secret, scope);
String tokenEndpoint = getTokenEndpoint(authServerUrl);
try {
return restTemplate.exchange(tokenEndpoint, HttpMethod.POST, entity, TokenResponse.class).getBody();
} catch (RestClientException e) {
throw new AuthClientException(e.getMessage(), e);
}
}
use of org.hl7.fhir.r4.model.Endpoint in project Gravity-SDOH-Exchange-RI by FHIR.
the class CpService method create.
public void create(final Task ehrTask, final Endpoint endpoint) throws CpClientException {
Task cpTask = externalizeResource(ehrTask.copy(), identifierSystem);
// TODO: Remove this after Logica bug response
cpTask.setMeta(null);
cpTask.addIdentifier().setSystem(identifierSystem).setValue(ehrTask.getIdElement().getIdPart());
try {
cpClient(endpoint).create().resource(cpTask).execute();
} catch (BaseServerResponseException exc) {
throw new CpClientException(String.format("Could not create a Task with identifier '%s' in CP at '%s'. Reason: %s.", identifierSystem + "|" + ehrTask.getIdElement().getIdPart(), endpoint.getAddress(), exc.getMessage()), exc);
}
}
use of org.hl7.fhir.r4.model.Endpoint in project Gravity-SDOH-Exchange-RI by FHIR.
the class CpService method read.
public TaskInfoHolder read(final String id, final Endpoint endpoint) throws CpClientException {
try {
Bundle taskBundle = cpClient(endpoint).search().forResource(Task.class).where(Task.IDENTIFIER.exactly().systemAndValues(identifierSystem, id)).include(Task.INCLUDE_FOCUS).returnBundle(Bundle.class).execute();
// Additional validation
int tasksSize = FhirUtil.getFromBundle(taskBundle, Task.class).size();
if (tasksSize == 0) {
throw new CpClientException(String.format("No Task is present at '%s' for identifier '%s'.", endpoint.getAddress(), identifierSystem + "|" + id));
} else if (tasksSize > 1) {
throw new CpClientException(String.format("More than one Task is present at '%s' for identifier '%s'.", endpoint.getAddress(), identifierSystem + "|" + id));
}
return new TaskInfoBundleExtractor().extract(taskBundle).stream().findFirst().get();
} catch (BaseServerResponseException exc) {
throw new CpClientException(String.format("Task retrieval failed for identifier '%s' at CP location '%s'. Reason: %s.", identifierSystem + "|" + id, endpoint.getAddress(), exc.getMessage()), exc);
}
}
use of org.hl7.fhir.r4.model.Endpoint in project integration-adaptor-111 by nhsconnect.
the class MessageHeaderServiceTest method shouldCreateMessageHeader.
@Test
public void shouldCreateMessageHeader() {
ItkReportHeader itkReportHeader = new ItkReportHeader();
itkReportHeader.setSpecKey(SPECIFICATION_KEY);
itkReportHeader.setSpecVal(SPECIFICATION_VALUE);
itkReportHeader.setAddressList(Arrays.asList(ADDRESS));
MessageHeader messageHeader = messageHeaderService.createMessageHeader(itkReportHeader, MESSAGEID, EFFECTIVE_TIME);
assertThat(messageHeader.getId()).isEqualTo(MESSAGEID);
Coding event = messageHeader.getEvent();
assertThat(event.getSystem()).isEqualTo(MessageHeaderEvent.SYSTEM);
assertThat(event.getCode()).isEqualTo(DISCHARGE_DETAILS.getCode());
assertThat(event.getDisplay()).isEqualTo(DISCHARGE_DETAILS.getDisplay());
MessageSourceComponent source = messageHeader.getSource();
assertThat(source.getName()).isEqualTo(MESSAGE_SOURCE_NAME);
assertThat(source.getEndpoint()).isEqualTo(ENDPOINT);
assertThat(messageHeader.getReason().getCodingFirstRep().getSystem()).isEqualTo(SPECIFICATION_KEY);
assertThat(messageHeader.getReason().getCodingFirstRep().getCode()).isEqualTo(SPECIFICATION_VALUE);
assertThat(messageHeader.getDestinationFirstRep().getEndpoint()).isEqualTo(ADDRESS);
assertThat(messageHeader.getTimestampElement()).isEqualToComparingFieldByField(DateUtil.parseToInstantType(EFFECTIVE_TIME));
}
use of org.hl7.fhir.r4.model.Endpoint in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeConformanceConformanceMessagingEndpointComponent.
protected void composeConformanceConformanceMessagingEndpointComponent(Complex parent, String parentType, String name, Conformance.ConformanceMessagingEndpointComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "endpoint", name, element, index);
if (element.hasProtocol())
composeCoding(t, "Conformance", "protocol", element.getProtocol(), -1);
if (element.hasAddressElement())
composeUri(t, "Conformance", "address", element.getAddressElement(), -1);
}
Aggregations