Search in sources :

Example 96 with Organization

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;
}
Also used : Address(org.hl7.fhir.dstu3.model.Address) LocationDetails(uk.gov.hscic.model.location.LocationDetails)

Example 97 with Organization

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;
}
Also used : Organization(com.onelogin.saml2.model.Organization) ByteArrayInputStream(java.io.ByteArrayInputStream) Metadata(com.onelogin.saml2.settings.Metadata) URL(java.net.URL) X509Certificate(java.security.cert.X509Certificate)

Example 98 with Organization

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][])));
}
Also used : Organization(org.hl7.fhir.dstu3.model.Organization) List(java.util.List) Bundle(org.hl7.fhir.dstu3.model.Bundle) FlipTable(com.jakewharton.fliptables.FlipTable) AbstractAttributionCommand(gov.cms.dpc.api.cli.AbstractAttributionCommand) Bootstrap(io.dropwizard.setup.Bootstrap) Namespace(net.sourceforge.argparse4j.inf.Namespace) Subparser(net.sourceforge.argparse4j.inf.Subparser) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Collectors(java.util.stream.Collectors) Organization(org.hl7.fhir.dstu3.model.Organization) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Bundle(org.hl7.fhir.dstu3.model.Bundle)

Example 99 with Organization

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));
            }
        }
    }
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) HttpPost(org.apache.http.client.methods.HttpPost) Parameters(org.hl7.fhir.dstu3.model.Parameters) Organization(org.hl7.fhir.dstu3.model.Organization) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) UUID(java.util.UUID) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 100 with Organization

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);
}
Also used : Path(java.nio.file.Path) Bundle(org.hl7.fhir.dstu3.model.Bundle) File(java.io.File) FileInputStream(java.io.FileInputStream) IParser(ca.uhn.fhir.parser.IParser)

Aggregations

Test (org.junit.jupiter.api.Test)101 Organization (org.hl7.fhir.dstu3.model.Organization)90 Organization (org.hl7.fhir.r4.model.Organization)69 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)41 Resource (org.hl7.fhir.r4.model.Resource)38 ArrayList (java.util.ArrayList)34 List (java.util.List)33 Reference (org.hl7.fhir.r4.model.Reference)33 Identifier (org.hl7.fhir.r4.model.Identifier)30 Bundle (org.hl7.fhir.dstu3.model.Bundle)27 UUID (java.util.UUID)26 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)25 Patient (org.hl7.fhir.r4.model.Patient)25 IdType (org.hl7.fhir.dstu3.model.IdType)24 Bundle (org.hl7.fhir.r4.model.Bundle)24 Coding (org.hl7.fhir.r4.model.Coding)24 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)19 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)17 Reference (org.hl7.fhir.dstu3.model.Reference)16 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)16