@Override public List<Bundle.BundleEntryComponent> getEntries(Bundle theRequest) { return theRequest.getEntry(); }
public org.hl7.fhir.dstu3.model.Bundle convertBundle(org.hl7.fhir.instance.model.Bundle src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Bundle tgt = new org.hl7.fhir.dstu3.model.Bundle(); copyResource(src, tgt); tgt.setType(convertBundleType(src.getType())); if (src.hasTotal()) tgt.setTotal(src.getTotal()); for (org.hl7.fhir.instance.model.Bundle.BundleLinkComponent t : src.getLink()) tgt.addLink(convertBundleLinkComponent(t)); for (org.hl7.fhir.instance.model.Bundle.BundleEntryComponent t : src.getEntry()) tgt.addEntry(convertBundleEntryComponent(t)); tgt.setSignature(convertSignature(src.getSignature())); return tgt; }
public org.hl7.fhir.instance.model.Bundle convertBundle(org.hl7.fhir.dstu3.model.Bundle src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.instance.model.Bundle tgt = new org.hl7.fhir.instance.model.Bundle(); copyResource(src, tgt); tgt.setType(convertBundleType(src.getType())); if (src.hasTotal()) tgt.setTotal(src.getTotal()); for (org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent t : src.getLink()) tgt.addLink(convertBundleLinkComponent(t)); for (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent t : src.getEntry()) tgt.addEntry(convertBundleEntryComponent(t)); if (src.hasSignature()) tgt.setSignature(convertSignature(src.getSignature())); return tgt; }
@Override public String getBundleType(Bundle theRequest) { if (theRequest.getType() == null) { return null; } return theRequest.getTypeElement().getValue().toCode(); }
@Test public void testSendManualPdqmWithCount() { Bundle page1 = sendManuallyWithCount(familyParameters(), 2); assertEquals(Bundle.BundleType.SEARCHSET, page1.getType()); assertEquals(ResourceType.Bundle, page1.getResourceType()); assertTrue(page1.hasEntry()); assertEquals(3, page1.getTotal()); assertEquals(2, page1.getEntry().size()); Bundle page2 = nextPage(page1); assertEquals(Bundle.BundleType.SEARCHSET, page2.getType()); assertEquals(ResourceType.Bundle, page2.getResourceType()); assertTrue(page2.hasEntry()); assertEquals(3, page2.getTotal()); assertEquals(1, page2.getEntry().size()); } }
@Override public Object evaluate(Exchange exchange) { if (returnError) throw new InternalErrorException("Something went wrong"); Bundle requestBundle = exchange.getIn().getBody(Bundle.class); Bundle responseBundle = new Bundle() .setType(Bundle.BundleType.TRANSACTIONRESPONSE) .setTotal(requestBundle.getTotal()); for (Bundle.BundleEntryComponent requestEntry : requestBundle.getEntry()) { Bundle.BundleEntryResponseComponent response = new Bundle.BundleEntryResponseComponent() .setStatus("201 Created") .setLastModified(new Date()) .setLocation(requestEntry.getResource().getClass().getSimpleName() + "/" + 4711); responseBundle.addEntry() .setResponse(response) .setResource(responseResource(requestEntry.getResource())); } return responseBundle; }
@SuppressWarnings("unchecked") private org.hl7.fhir.dstu3.model.Bundle getBundleFromFileDstu3(Integer limit, File inputFile, FhirContext ctx) throws IOException, UnsupportedEncodingException { org.hl7.fhir.dstu3.model.Bundle bundle = new org.hl7.fhir.dstu3.model.Bundle(); bundle.setType(BundleType.TRANSACTION); BundleEntryComponent entry = bundle.addEntry(); entry.getRequest().setMethod(HTTPVerb.POST); entry.setResource((Resource) nextResource); continue; BundleEntryComponent entry = bundle.addEntry(); entry.getRequest().setMethod(HTTPVerb.POST); entry.setResource((Resource) parsed);
@Override public Base setProperty(int hash, String name, Base value) throws FHIRException { switch (hash) { case -1618432855: // identifier this.identifier = castToIdentifier(value); // Identifier return value; case 3575610: // type value = new BundleTypeEnumFactory().fromType(castToCode(value)); this.type = (Enumeration) value; // Enumeration<BundleType> return value; case 110549828: // total this.total = castToUnsignedInt(value); // UnsignedIntType return value; case 3321850: // link this.getLink().add((BundleLinkComponent) value); // BundleLinkComponent return value; case 96667762: // entry this.getEntry().add((BundleEntryComponent) value); // BundleEntryComponent return value; case 1073584312: // signature this.signature = castToSignature(value); // Signature return value; default: return super.setProperty(hash, name, value); } }
@Override public void initializeBundleFromResourceList(String theAuthor, List<? extends IBaseResource> theResources, String theServerBase, String theCompleteUrl, int theTotalResults, BundleTypeEnum theBundleType) { myBundle = new Bundle(); myBundle.setId(UUID.randomUUID().toString()); myBundle.getMeta().setLastUpdated(new Date()); myBundle.addLink().setRelation(Constants.LINK_FHIR_BASE).setUrl(theServerBase); myBundle.addLink().setRelation(Constants.LINK_SELF).setUrl(theCompleteUrl); myBundle.getTypeElement().setValueAsString(theBundleType.getCode()); BundleEntryComponent nextEntry = myBundle.addEntry(); myBundle.getTotalElement().setValue(theTotalResults);
protected Bundle provideAndRegister() throws Exception { Bundle bundle = new Bundle().setType(Bundle.BundleType.TRANSACTION); bundle.getMeta().addProfile(Iti65Constants.ITI65_PROFILE); manifest.addContent() .setP(new Reference(REFERENCE_FULL_URL)); bundle.addEntry() .setFullUrl(MANIFEST_FULL_URL) .setRequest( .setUrl(BINARY_FULL_URL)) .setFormat(new Coding("urn:oid:1.3.6.1.4.1.19376.1.2.3", "urn:ihe:pcc:handp:2008", null)); bundle.addEntry() .setFullUrl(REFERENCE_FULL_URL) .setRequest( binary.getMeta().setLastUpdated(timestamp); bundle.addEntry() .setFullUrl(BINARY_FULL_URL) .setRequest(new Bundle.BundleEntryRequestComponent()
public Bundle convert(InputStream stream) throws Exception { cda = new CDAUtilities(stream); doc = cda.getElement(); cda.checkTemplateId(doc, "2.16.840.1.113883.10.20.22.1.1"); convert = new Convert(cda, ucumSvc, "Z"); // check it's a CDA/CCD feed = new Bundle(); feed.setMeta(new Meta().setLastUpdatedElement(InstantType.now())); feed.setId(makeUUIDReference()); feed.getMeta().getTag().add(new Coding()); // todo-bundle ("http://hl7.org/fhir/tag", "http://hl7.org/fhir/tag/document", "Document")); // process the header makeDocument(); composition.setSubject(Factory.makeReference(makeSubject())); for (Element e : cda.getChildren(doc, "author")) composition.getAuthor().add(Factory.makeReference(makeAuthor(e))); // todo: data enterer & informant goes in provenance composition.setCustodian(Factory.makeReference(makeOrganization( cda.getDescendent(doc, "custodian/assignedCustodian/representedCustodianOrganization"), "Custodian"))); // todo: informationRecipient for (Element e : cda.getChildren(doc, "legalAuthenticator")) composition.getAttester().add(makeAttester(e, CompositionAttestationMode.LEGAL, "Legal Authenticator")); for (Element e : cda.getChildren(doc, "authenticator")) composition.getAttester().add(makeAttester(e, CompositionAttestationMode.PROFESSIONAL, "Authenticator")); // process the contents // we do this by section - keep the original section order Element body = cda.getDescendent(doc, "component/structuredBody"); processComponentSections(composition.getSection(), body); return feed; }
/** * This method is a Patient search, but HAPI can not automatically * determine the resource type so it must be explicitly stated. */ @Search(type=Patient.class) public Bundle searchForPatients(@RequiredParam(name=Patient.SP_NAME) StringDt theName) { Bundle retVal = new Bundle(); // perform search return retVal; }
public static void main(String[] theArgs) { FhirContext ctx = FhirContext.forDstu3(); IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu3"); // Build a search and execute it Bundle response = client.search() .forResource(Patient.class) .where(Patient.NAME.matches().value("Test")) .and(Patient.BIRTHDATE.before().day("2014-01-01")) .count(100) .returnBundle(Bundle.class) .execute(); // How many resources did we find? System.out.println("Responses: " + response.getTotal()); // Print the ID of the first one System.out.println("First response ID: " + response.getEntry().get(0).getResource().getId()); } }
@Override public void addEntry(Bundle theBundle, Bundle.BundleEntryComponent theEntry) { theBundle.addEntry(theEntry); }
@Test public void testClient() { FhirContext ctx = new FhirContext(FhirVersionEnum.DSTU3); GenericClient client = (GenericClient) ctx.newRestfulGenericClient(FHIR_EP); //client.registerInterceptor(new BasicAuthInterceptor("user123", "user321$")); client.setDontValidateConformance(true); Bundle bundle = client.search().forResource(Patient.class).count(1).returnBundle(Bundle.class).execute(); assertTrue("No patient resources returned.", bundle.getEntry().size() > 0); Patient patient = (Patient) bundle.getEntryFirstRep().getResource(); String patient_id = patient.getIdElement().getIdPart(); Patient patient1 = client.read(Patient.class, "Patient/" + patient_id); assertEquals(patient_id, patient1.getIdElement().getIdPart()); bundle = client.search().byUrl("Patient?_id=" + patient_id).returnBundle(Bundle.class).execute(); assertEquals(1, bundle.getEntry().size()); Patient patient2 = (Patient) bundle.getEntry().get(0).getResource(); assertEquals(patient_id, patient2.getIdElement().getIdPart()); }
/** * {@inheritDoc} */ @Override public Bundle createResource( final JCas jCas, final TOP nullified, final FhirPractitioner practitioner, final FhirNoteSpecs noteSpecs ) { final Bundle bundle = new Bundle(); final String noteTime = DATE_FORMAT.format( new Date() ); bundle.setId( FhirElementFactory.createId( jCas, CTAKES_BUNDLE_ID, noteTime ) ); // The bundle is a collection; created for ease of distribution. bundle.setType( Bundle.BundleType.COLLECTION ); return bundle; }