/** * Gets the value(s) for <b>content</b> (). * creating it if it does * not exist. This method may return <code>null</code>. * * <p> * <b>Definition:</b> * The actual content, base64 encoded * </p> */ public byte[] getContent() { return getContentElement().getValue(); }
/** * Gets the value(s) for <b>contentType</b> (). * creating it if it does * not exist. This method may return <code>null</code>. * * <p> * <b>Definition:</b> * MimeType of the binary content represented as a standard MimeType (BCP 13) * </p> */ public String getContentType() { return getContentTypeElement().getValue(); }
public byte[] getContent() { if (content == null) { content = reference.getContentFirstRep().getData(); if (content == null || content.length == 0) { Binary binary = ClientUtil.getFhirClient().read(Binary.class, reference.getContentFirstRep().getUrl()); content = binary.getContent(); } if (content == null) { content = EMPTY_CONTENT; } } return content; }
@Test public void test() throws URISyntaxException { IDomainFactory<BaseResource> factory = DomainFactory.getInstance(); Patient pat1 = factory.fetchObject(Patient.class, "1"); assertNotNull(pat1); for (ExtensionDt extension : pat1.getAllUndeclaredExtensions()) { System.out.println(extension.getUrlAsString() + "=" + extension.getValue()); } List<Patient> patients = factory.fetchObjects(Patient.class, PAT_IDS); assertNotNull(patients); assertEquals(2, patients.size()); DocumentReference dr = factory.fetchObject(DocumentReference.class, "1"); assertNotNull(dr); UriDt uri = dr.getContentFirstRep().getUrlElement(); IGenericClient client = ClientUtil.getFhirClient(); Binary result = (Binary) client.read(uri); assertNotNull(result); byte[] text = result.getContent(); System.out.println(new String(text)); Condition cond = factory.fetchObject(Condition.class, "1"); assertNotNull(cond); testException(client, ROOT + "Patient/309349993439"); }
@Override public Binary setContentAsBase64(String theContent) { getContentElement().setValueAsString(theContent); return this; }
@Override public String getContentAsBase64() { return getContentElement().getValueAsString(); }