use of org.hl7.fhir.r4.model.Organization in project gpconnect-demonstrator by nhsconnect.
the class OrganizationResourceProvider method getValidAddress.
private Address getValidAddress(Organization organization) {
List<LocationDetails> locationsDetails = locationSearch.findAllLocations();
LocationDetails location = null;
for (LocationDetails locationDetails : locationsDetails) {
if (locationDetails.getOrgOdsCode().equals(organization.getIdentifierFirstRep().getValue())) {
location = locationDetails;
break;
}
}
Address orgAddress = null;
if (location != null) {
orgAddress = new Address();
orgAddress.setUse(AddressUse.WORK);
// #152
// this looks very odd but is deliberate, there's a similar issue in locationResourceProvider.createAddress
// They result from a change to spec to remove the state attribute from the address
// See the commit cd26528 by James Cox 6/3/18
orgAddress.addLine(location.getAddressLine());
orgAddress.addLine(location.getAddressCity());
orgAddress.setCity(location.getAddressDistrict());
orgAddress.setDistrict(location.getAddressState());
orgAddress.setPostalCode(location.getAddressPostalCode());
}
return orgAddress;
}
use of org.hl7.fhir.r4.model.Organization in project oxTrust by GluuFederation.
the class UpdateTrustRelationshipAction method generateMetadata.
public void generateMetadata() throws MalformedURLException, CertificateException {
if (spAssertionConsumerServiceUrlStr != null && !spAssertionConsumerServiceUrlStr.isEmpty())
saml2Settings.setSpAssertionConsumerServiceUrlSub(new URL(spAssertionConsumerServiceUrlStr));
if (spSingleLogoutServiceUrlStr != null && !spSingleLogoutServiceUrlStr.isEmpty())
saml2Settings.setSpSingleLogoutServiceUrlSub(new URL(spSingleLogoutServiceUrlStr));
if (spX509certStr != null && !spX509certStr.isEmpty()) {
spX509certStr = Util.formatCert(spX509certStr, true);
X509Certificate cert = (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(spX509certStr.getBytes()));
saml2Settings.setSpX509certSub(cert);
}
Organization organization = new Organization(orgName, orgDisplayName, orgUrl);
saml2Settings.setOrganizationSub(organization);
Metadata metadataObj = new Metadata(saml2Settings);
metadataStr = metadataObj.getMetadataString();
log.info(metadataStr);
// return true;
}
use of org.hl7.fhir.r4.model.Organization in project dpc-app by CMSgov.
the class OrganizationList method run.
@Override
public void run(Bootstrap<?> bootstrap, Namespace namespace) {
System.out.println("Listing");
final String attributionService = namespace.getString(ATTR_HOSTNAME);
System.out.println(String.format("Connecting to Attribution service at: %s", attributionService));
final IGenericClient client = ctx.newRestfulGenericClient(attributionService);
final Bundle organizations = client.search().forResource(Organization.class).encodedJson().returnBundle(Bundle.class).execute();
// Generate the table
final String[] headers = { "ID", "NPI", "NAME" };
// noinspection FuseStreamOperations Fusing the operation here actually causes an issue with the print output
final List<String[]> collect = organizations.getEntry().stream().filter(Bundle.BundleEntryComponent::hasResource).map(Bundle.BundleEntryComponent::getResource).map(resource -> (Organization) resource).map(resource -> List.of(resource.getId(), resource.getIdentifierFirstRep().getValue(), resource.getName())).map(values -> values.toArray(new String[0])).collect(Collectors.toList());
System.out.println(FlipTable.of(headers, collect.toArray(new String[0][])));
}
use of org.hl7.fhir.r4.model.Organization in project dpc-app by CMSgov.
the class OrganizationRegistration method registerOrganization.
private void registerOrganization(Bundle organization, String attributionService, boolean noToken, String apiService) throws IOException, URISyntaxException {
System.out.println(String.format("Connecting to Attribution service at: %s", attributionService));
final IGenericClient client = ctx.newRestfulGenericClient(attributionService);
final Parameters parameters = new Parameters();
parameters.addParameter().setResource(organization);
UUID organizationID = null;
try {
final Organization createdOrg = client.operation().onType(Organization.class).named("submit").withParameters(parameters).returnResourceType(Organization.class).encodedJson().execute();
organizationID = UUID.fromString(createdOrg.getIdElement().getIdPart());
System.out.println(String.format("Registered organization: %s", organizationID));
} catch (Exception e) {
System.err.println(String.format("Unable to register organization. %s", e.getMessage()));
System.exit(1);
}
// Now, create a token, unless --no-token has been passed
if (!noToken) {
System.out.println(String.format("Connecting to API service at: %s", apiService));
try (final CloseableHttpClient httpClient = HttpClients.createDefault()) {
final URIBuilder builder = new URIBuilder(String.format("%s/generate-token", apiService));
builder.setParameter("organization", organizationID.toString());
final HttpPost httpPost = new HttpPost(builder.build());
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
final String token = EntityUtils.toString(response.getEntity());
System.out.println(String.format("Organization token: %s", token));
}
}
}
}
use of org.hl7.fhir.r4.model.Organization in project dpc-app by CMSgov.
the class OrganizationRegistration method run.
@Override
public void run(Bootstrap<?> bootstrap, Namespace namespace) throws Exception {
System.out.println("Registering Organization");
// Read the file and parse it
final Path filePath = FileSystems.getDefault().getPath(namespace.getString(ORG_FILE)).normalize().toAbsolutePath();
Bundle organization;
try (FileInputStream fileInputStream = new FileInputStream(new File(filePath.toUri()))) {
final IParser parser = ctx.newJsonParser();
organization = (Bundle) parser.parseResource(fileInputStream);
}
final boolean noToken = Boolean.parseBoolean(namespace.getString("no-token"));
final String apiService = namespace.getString("api-service");
registerOrganization(organization, namespace.getString(ATTR_HOSTNAME), noToken, apiService);
}
Aggregations