Search in sources :

Example 1 with BundleLinkComponent

use of org.hl7.fhir.r4b.model.Bundle.BundleLinkComponent in project org.hl7.fhir.core by hapifhir.

the class Bundle method copy.

public Bundle copy() {
    Bundle dst = new Bundle();
    copyValues(dst);
    dst.type = type == null ? null : type.copy();
    dst.total = total == null ? null : total.copy();
    if (link != null) {
        dst.link = new ArrayList<BundleLinkComponent>();
        for (BundleLinkComponent i : link) dst.link.add(i.copy());
    }
    ;
    if (entry != null) {
        dst.entry = new ArrayList<BundleEntryComponent>();
        for (BundleEntryComponent i : entry) dst.entry.add(i.copy());
    }
    ;
    dst.signature = signature == null ? null : signature.copy();
    return dst;
}
Also used : IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle)

Example 2 with BundleLinkComponent

use of org.hl7.fhir.r4b.model.Bundle.BundleLinkComponent in project org.hl7.fhir.core by hapifhir.

the class Bundle method copy.

public Bundle copy() {
    Bundle dst = new Bundle();
    copyValues(dst);
    dst.type = type == null ? null : type.copy();
    dst.total = total == null ? null : total.copy();
    if (link != null) {
        dst.link = new ArrayList<BundleLinkComponent>();
        for (BundleLinkComponent i : link) dst.link.add(i.copy());
    }
    ;
    if (entry != null) {
        dst.entry = new ArrayList<BundleEntryComponent>();
        for (BundleEntryComponent i : entry) dst.entry.add(i.copy());
    }
    ;
    dst.signature = signature == null ? null : signature.copy();
    return dst;
}
Also used : IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle)

Example 3 with BundleLinkComponent

use of org.hl7.fhir.r4b.model.Bundle.BundleLinkComponent in project org.hl7.fhir.core by hapifhir.

the class GraphQLEngineTests method search.

@Override
public Bundle search(Object appInfo, String type, List<Argument> searchParams) throws FHIRException {
    try {
        Bundle bnd = new Bundle();
        BundleLinkComponent bl = bnd.addLink();
        bl.setRelation("next");
        bl.setUrl("http://test.fhir.org/r4/Patient?_format=text/xhtml&search-id=77c97e03-8a6c-415f-a63d-11c80cf73f&&active=true&_sort=_id&search-offset=50&_count=50");
        bl = bnd.addLink();
        bl.setRelation("self");
        bl.setUrl("http://test.fhir.org/r4/Patient?_format=text/xhtml&search-id=77c97e03-8a6c-415f-a63d-11c80cf73f&&active=true&_sort=_id&search-offset=0&_count=50");
        BundleEntryComponent be = bnd.addEntry();
        be.setFullUrl("http://hl7.org/fhir/Patient/example");
        be.setResource(new XmlParser().parse(new FileInputStream(Utilities.path(TestingUtilities.resourceNameToFile("patient-example.xml")))));
        be = bnd.addEntry();
        be.setFullUrl("http://hl7.org/fhir/Patient/example");
        be.setResource(new XmlParser().parse(new FileInputStream(Utilities.path(TestingUtilities.resourceNameToFile("patient-example-xds.xml")))));
        be.getSearch().setScore(0.5);
        be.getSearch().setMode(SearchEntryMode.MATCH);
        bnd.setTotal(50);
        return bnd;
    } catch (Exception e) {
        throw new FHIRException(e);
    }
}
Also used : XmlParser(org.hl7.fhir.r4.formats.XmlParser) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r4.model.Bundle) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException) FHIRException(org.hl7.fhir.exceptions.FHIRException) BundleLinkComponent(org.hl7.fhir.r4.model.Bundle.BundleLinkComponent)

Example 4 with BundleLinkComponent

use of org.hl7.fhir.r4b.model.Bundle.BundleLinkComponent in project geoprism-registry by terraframe.

the class FhirResourceImporter method synchronize.

public void synchronize() {
    this.processor.configure(this.connection.getExternalSystem());
    IGenericClient client = this.connection.getClient();
    Bundle bundle = client.search().forResource(Location.class).count(2000).lastUpdated(new DateRangeParam(this.since, null)).include(new Include("Location:organization")).returnBundle(Bundle.class).execute();
    this.history.appLock();
    this.history.setWorkTotal(Long.valueOf(bundle.getTotal() * 2));
    this.history.apply();
    while (bundle != null) {
        this.process(bundle);
        BundleLinkComponent link = bundle.getLink(Bundle.LINK_NEXT);
        if (link != null) {
            // The link may come back with the local url instead of the global url
            // As such replace the base local url with the base global url
            // String localUrl = link.getUrl();
            // String[] split = localUrl.split("\\?");
            // String globalUrl = this.connection.getExternalSystem().getUrl() + "?"
            // + split[1];
            // 
            // link.setUrl(globalUrl);
            // 
            bundle = client.loadPage().next(bundle).execute();
        } else {
            bundle = null;
        }
    }
}
Also used : DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Bundle(org.hl7.fhir.r4.model.Bundle) Include(ca.uhn.fhir.model.api.Include) Location(org.hl7.fhir.r4.model.Location) BundleLinkComponent(org.hl7.fhir.r4.model.Bundle.BundleLinkComponent)

Example 5 with BundleLinkComponent

use of org.hl7.fhir.r4b.model.Bundle.BundleLinkComponent in project org.hl7.fhir.core by hapifhir.

the class GraphQLEngineTests method search.

@Override
public Bundle search(Object appInfo, String type, List<Argument> searchParams) throws FHIRException {
    try {
        Bundle bnd = new Bundle();
        BundleLinkComponent bl = bnd.addLink();
        bl.setRelation("next");
        bl.setUrl("http://test.fhir.org/r4/Patient?_format=text/xhtml&search-id=77c97e03-8a6c-415f-a63d-11c80cf73f&&active=true&_sort=_id&search-offset=50&_count=50");
        bl = bnd.addLink();
        bl.setRelation("self");
        bl.setUrl("http://test.fhir.org/r4/Patient?_format=text/xhtml&search-id=77c97e03-8a6c-415f-a63d-11c80cf73f&&active=true&_sort=_id&search-offset=0&_count=50");
        BundleEntryComponent be = bnd.addEntry();
        be.setFullUrl("http://hl7.org/fhir/Patient/example");
        be.setResource(new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", "patient-example.xml")));
        be = bnd.addEntry();
        be.setFullUrl("http://hl7.org/fhir/Patient/example");
        be.setResource(new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", "patient-example-xds.xml")));
        be.getSearch().setScore(0.5);
        be.getSearch().setMode(SearchEntryMode.MATCH);
        bnd.setTotal(50);
        return bnd;
    } catch (Exception e) {
        throw new FHIRException(e);
    }
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) BundleEntryComponent(org.hl7.fhir.r5.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r5.model.Bundle) FHIRException(org.hl7.fhir.exceptions.FHIRException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException) FHIRException(org.hl7.fhir.exceptions.FHIRException) BundleLinkComponent(org.hl7.fhir.r5.model.Bundle.BundleLinkComponent)

Aggregations

IOException (java.io.IOException)3 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)3 FHIRException (org.hl7.fhir.exceptions.FHIRException)3 IBaseBundle (org.hl7.fhir.instance.model.api.IBaseBundle)3 SAXException (org.xml.sax.SAXException)3 Bundle (org.hl7.fhir.r4.model.Bundle)2 BundleLinkComponent (org.hl7.fhir.r4.model.Bundle.BundleLinkComponent)2 Include (ca.uhn.fhir.model.api.Include)1 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)1 DateRangeParam (ca.uhn.fhir.rest.param.DateRangeParam)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 XmlParser (org.hl7.fhir.r4.formats.XmlParser)1 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)1 Location (org.hl7.fhir.r4.model.Location)1 XmlParser (org.hl7.fhir.r4b.formats.XmlParser)1 Bundle (org.hl7.fhir.r4b.model.Bundle)1 BundleEntryComponent (org.hl7.fhir.r4b.model.Bundle.BundleEntryComponent)1 BundleLinkComponent (org.hl7.fhir.r4b.model.Bundle.BundleLinkComponent)1 XmlParser (org.hl7.fhir.r5.formats.XmlParser)1