本文整理汇总了Java中ca.uhn.fhir.model.primitive.IdDt类的典型用法代码示例。如果您正苦于以下问题:Java IdDt类的具体用法?Java IdDt怎么用?Java IdDt使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IdDt类属于ca.uhn.fhir.model.primitive包,在下文中一共展示了IdDt类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deletePractitioner
import ca.uhn.fhir.model.primitive.IdDt; //导入依赖的package包/类
public static void deletePractitioner(FhirContext oContext,List<IdDt> listIdsPractitioner, String serverUrl, String logFileName)
{
try
{
IGenericClient client=oContext.newRestfulGenericClient(serverUrl);
for(IdDt idToDelete:listIdsPractitioner)
{
IBaseOperationOutcome resp=client.delete()
.resourceById(idToDelete)
.execute();
if(resp!=null)
{
OperationOutcome outcome = (OperationOutcome) resp;
System.out.println(outcome.getIssueFirstRep().getDetailsElement().getValue());
}
}
}
catch (Exception exc)
{
FhirMediatorUtilities.writeInLogFile(logFileName,
exc.getMessage(),"Error");
}
}
示例2: deleteSpecimen
import ca.uhn.fhir.model.primitive.IdDt; //导入依赖的package包/类
public static void deleteSpecimen(FhirContext oContext,List<IdDt> listIdsSpecimen, String serverUrl, String logFileName)
{
try
{
IGenericClient client=oContext.newRestfulGenericClient(serverUrl);
for(IdDt idToDelete:listIdsSpecimen)
{
IBaseOperationOutcome resp=client.delete()
.resourceById(idToDelete)
.execute();
if(resp!=null)
{
OperationOutcome outcome = (OperationOutcome) resp;
System.out.println(outcome.getIssueFirstRep().getDetailsElement().getValue());
}
}
}
catch (Exception exc)
{
FhirMediatorUtilities.writeInLogFile(logFileName,
exc.getMessage(),"Error");
}
}
示例3: deleteBundle
import ca.uhn.fhir.model.primitive.IdDt; //导入依赖的package包/类
public static void deleteBundle(FhirContext oContext, IdDt idBundle, String serverUrl, String logFileName)
{
try
{
IGenericClient client=oContext.newRestfulGenericClient(serverUrl);
IBaseOperationOutcome resp=client.delete().resourceById(idBundle)
.execute();
if(resp!=null)
{
OperationOutcome outcome = (OperationOutcome) resp;
System.out.println(outcome.getIssueFirstRep().getDetailsElement().getValue());
}
}
catch (Exception exc)
{
FhirMediatorUtilities.writeInLogFile(logFileName,
exc.getMessage(),"Error");
}
}
示例4: tCD2Substance
import ca.uhn.fhir.model.primitive.IdDt; //导入依赖的package包/类
public Substance tCD2Substance(CD cdaSubstanceCode) {
if(cdaSubstanceCode == null || cdaSubstanceCode.isSetNullFlavor())
return null;
Substance fhirSubstance = new Substance();
// resource id
fhirSubstance.setId(new IdDt("Substance", getUniqueId()));
// meta.profile
if(Config.isGenerateDafProfileMetadata())
fhirSubstance.getMeta().addProfile(Constants.PROFILE_DAF_SUBSTANCE);
// code -> code
fhirSubstance.setCode(dtt.tCD2CodeableConcept(cdaSubstanceCode));
return fhirSubstance;
}
示例5: testHistoryByForcedId
import ca.uhn.fhir.model.primitive.IdDt; //导入依赖的package包/类
@Test
public void testHistoryByForcedId() {
IdDt idv1;
IdDt idv2;
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("testHistoryByForcedId");
patient.addName().addFamily("Tester").addGiven("testHistoryByForcedId");
patient.setId("Patient/testHistoryByForcedId");
idv1 = ourPatientDao.update(patient).getId();
patient.addName().addFamily("Tester").addGiven("testHistoryByForcedIdName2");
patient.setId(patient.getId().toUnqualifiedVersionless());
idv2 = ourPatientDao.update(patient).getId();
}
List<Patient> patients = toList(ourPatientDao.history(idv1.toVersionless(), null));
assertTrue(patients.size() == 2);
// Newest first
assertEquals("Patient/testHistoryByForcedId/_history/2", patients.get(0).getId().toUnqualified().getValue());
assertEquals("Patient/testHistoryByForcedId/_history/1", patients.get(1).getId().toUnqualified().getValue());
assertNotEquals(idv1, idv2);
}
示例6: testUpdateWithClientSuppliedIdWhichDoesntExist
import ca.uhn.fhir.model.primitive.IdDt; //导入依赖的package包/类
@Test
public void testUpdateWithClientSuppliedIdWhichDoesntExist() {
deleteToken("Patient", Patient.SP_IDENTIFIER, "urn:system", "testUpdateWithClientSuppliedIdWhichDoesntExist");
Patient p1 = new Patient();
p1.addIdentifier().setSystem("urn:system").setValue("testUpdateWithClientSuppliedIdWhichDoesntExist");
MethodOutcome outcome = ourClient.update().resource(p1).withId("testUpdateWithClientSuppliedIdWhichDoesntExist").execute();
assertEquals(true, outcome.getCreated().booleanValue());
IdDt p1Id = outcome.getId();
assertThat(p1Id.getValue(), containsString("Patient/testUpdateWithClientSuppliedIdWhichDoesntExist/_history"));
Bundle actual = ourClient.search().forResource(Patient.class).where(Patient.IDENTIFIER.exactly().systemAndCode("urn:system", "testUpdateWithClientSuppliedIdWhichDoesntExist")).encodedJson().prettyPrint().execute();
assertEquals(1, actual.size());
assertEquals(p1Id.getIdPart(), actual.getEntries().get(0).getId().getIdPart());
}
示例7: testGetAllTagsPatientIdVersion
import ca.uhn.fhir.model.primitive.IdDt; //导入依赖的package包/类
@Test
public void testGetAllTagsPatientIdVersion() throws Exception {
TagList tagList = new TagList();
tagList.add(new Tag("CCC", "AAA", "BBB"));
String ser = ctx.newXmlParser().encodeTagListToString(tagList);
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
when(httpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(ser), Charset.forName("UTF-8")));
IClient client = ctx.newRestfulClient(IClient.class, "http://foo");
TagList response = client.getAllTagsPatientId(new IdDt("Patient", "111", "222"));
assertEquals(tagList, response);
assertEquals(HttpGet.class, capt.getValue().getClass());
HttpGet get = (HttpGet) capt.getValue();
assertEquals("http://foo/Patient/111/_history/222/_tags", get.getURI().toString());
}
示例8: testTransactionDeleteNoMatchUrl
import ca.uhn.fhir.model.primitive.IdDt; //导入依赖的package包/类
@Test
public void testTransactionDeleteNoMatchUrl() {
String methodName = "testTransactionDeleteNoMatchUrl";
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.setId("Patient/" + methodName);
IdDt id = ourPatientDao.update(p).getId();
ourLog.info("Created patient, got it: {}", id);
Bundle request = new Bundle();
request.addEntry().getTransaction().setMethod(HTTPVerbEnum.DELETE).setUrl("Patient?identifier=urn%3Asystem%7C" + methodName);
Bundle res = ourSystemDao.transaction(request);
assertEquals(2, res.getEntry().size());
assertEquals(Constants.STATUS_HTTP_204_NO_CONTENT + "", res.getEntry().get(1).getTransactionResponse().getStatus());
try {
ourPatientDao.read(id.toVersionless());
fail();
} catch (ResourceGoneException e) {
// ok
}
}
示例9: testGetAllTagsPatientIdVersionOld
import ca.uhn.fhir.model.primitive.IdDt; //导入依赖的package包/类
@Test
public void testGetAllTagsPatientIdVersionOld() throws Exception {
TagList tagList = new TagList();
tagList.add(new Tag("CCC", "AAA", "BBB"));
String ser = ctx.newXmlParser().encodeTagListToString(tagList);
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
when(httpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(ser), Charset.forName("UTF-8")));
IClient client = ctx.newRestfulClient(IClient.class, "http://foo");
TagList response = client.getAllTagsPatientIdVersion(new IdDt("111"), new IdDt("222"));
assertEquals(tagList, response);
assertEquals(HttpGet.class, capt.getValue().getClass());
HttpGet get = (HttpGet) capt.getValue();
assertEquals("http://foo/Patient/111/_history/222/_tags", get.getURI().toString());
}
示例10: testTransactionFromBundle
import ca.uhn.fhir.model.primitive.IdDt; //导入依赖的package包/类
@Test
public void testTransactionFromBundle() throws Exception {
InputStream bundleRes = SystemProviderTest.class.getResourceAsStream("/transaction_link_patient_eve.xml");
String bundleStr = IOUtils.toString(bundleRes);
Bundle bundle = ourFhirContext.newXmlParser().parseResource(Bundle.class, bundleStr);
Bundle resp = ourSystemDao.transaction(bundle);
ourLog.info(ourFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp));
OperationOutcome oo = (OperationOutcome) resp.getEntry().get(0).getResource();
assertThat(oo.getIssue().get(0).getDetailsElement().getValue(), containsString("Transaction completed"));
assertThat(resp.getEntry().get(1).getTransactionResponse().getLocation(), startsWith("Patient/a555-44-4444/_history/"));
assertThat(resp.getEntry().get(2).getTransactionResponse().getLocation(), startsWith("Patient/temp6789/_history/"));
assertThat(resp.getEntry().get(3).getTransactionResponse().getLocation(), startsWith("Organization/GHH/_history/"));
Patient p = ourPatientDao.read(new IdDt("Patient/a555-44-4444/_history/1"));
assertEquals("Patient/temp6789", p.getLink().get(0).getOther().getReference().getValue());
}
示例11: updatePatient
import ca.uhn.fhir.model.primitive.IdDt; //导入依赖的package包/类
/**
* The "@Update" annotation indicates that this method supports replacing an existing
* resource (by ID) with a new instance of that resource.
*
* @param theId
* This is the ID of the patient to update
* @param thePatient
* This is the actual resource to save
* @return This method returns a "MethodOutcome"
*/
@Update()
public MethodOutcome updatePatient(@IdParam IdDt theId, @ResourceParam Patient thePatient) {
validateResource(thePatient);
Long id;
try {
id = theId.getIdPartAsLong();
} catch (DataFormatException e) {
throw new InvalidRequestException("Invalid ID " + theId.getValue() + " - Must be numeric");
}
/*
* Throw an exception (HTTP 404) if the ID is not known
*/
if (!myIdToPatientVersions.containsKey(id)) {
throw new ResourceNotFoundException(theId);
}
addNewVersion(thePatient, id);
return new MethodOutcome();
}
示例12: testUpdateWithClientSuppliedIdWhichDoesntExist
import ca.uhn.fhir.model.primitive.IdDt; //导入依赖的package包/类
@Test
public void testUpdateWithClientSuppliedIdWhichDoesntExist() {
deleteToken("Patient", Patient.SP_IDENTIFIER, "urn:system", "testUpdateWithClientSuppliedIdWhichDoesntExistRpDstu2");
Patient p1 = new Patient();
p1.addIdentifier().setSystem("urn:system").setValue("testUpdateWithClientSuppliedIdWhichDoesntExistRpDstu2");
MethodOutcome outcome = ourClient.update().resource(p1).withId("testUpdateWithClientSuppliedIdWhichDoesntExistRpDstu2").execute();
assertEquals(true, outcome.getCreated().booleanValue());
IdDt p1Id = outcome.getId();
assertThat(p1Id.getValue(), containsString("Patient/testUpdateWithClientSuppliedIdWhichDoesntExistRpDstu2/_history"));
Bundle actual = ourClient.search().forResource(Patient.class).where(Patient.IDENTIFIER.exactly().systemAndCode("urn:system", "testUpdateWithClientSuppliedIdWhichDoesntExistRpDstu2")).encodedJson().prettyPrint().execute();
assertEquals(1, actual.size());
assertEquals(p1Id.getIdPart(), actual.getEntries().get(0).getResource().getId().getIdPart());
}
示例13: testFail500WithPlainMessage
import ca.uhn.fhir.model.primitive.IdDt; //导入依赖的package包/类
@Test
public void testFail500WithPlainMessage() throws Exception {
String msg = "Help I'm a bug";
String contentType = Constants.CT_TEXT;
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 500, "Internal Error"));
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", contentType + "; charset=UTF-8"));
when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");
try {
client.read(Patient.class, new IdDt("Patient/1234"));
fail();
} catch (InternalErrorException e) {
assertThat(e.getMessage(), StringContains.containsString("HTTP 500 Internal Error"));
assertThat(e.getMessage(), StringContains.containsString("Help I'm a bug"));
}
}
示例14: testReadFailureInternalError
import ca.uhn.fhir.model.primitive.IdDt; //导入依赖的package包/类
@Test
public void testReadFailureInternalError() throws Exception {
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
when(httpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 500, "INTERNAL"));
Header[] headers = new Header[1];
headers[0] = new BasicHeader(Constants.HEADER_LAST_MODIFIED, "2011-01-02T22:01:02");
when(httpResponse.getAllHeaders()).thenReturn(headers);
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_TEXT));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader("Internal Failure"), Charset.forName("UTF-8")));
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
try {
client.getPatientById(new IdDt("111"));
fail();
} catch (InternalErrorException e) {
assertThat(e.getMessage(), containsString("INTERNAL"));
assertThat(e.getResponseBody(), containsString("Internal Failure"));
}
}
示例15: testUpdateWithEmptyResponse
import ca.uhn.fhir.model.primitive.IdDt; //导入依赖的package包/类
/**
* Return a FHIR content type, but no content and make sure we handle this without crashing
*/
@Test
public void testUpdateWithEmptyResponse() throws Exception {
Patient patient = new Patient();
patient.addIdentifier("urn:foo", "123");
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
when(httpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 201, "OK"));
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Content-Location", "http://example.com/fhir/Patient/100/_history/200"));
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
client.updatePatient(new IdDt("Patient/100/_history/200"), patient);
assertEquals(HttpPut.class, capt.getValue().getClass());
HttpPut post = (HttpPut) capt.getValue();
assertEquals("http://foo/Patient/100", post.getURI().toASCIIString());
Header h = post.getFirstHeader("content-location");
assertEquals("Patient/100/_history/200", h.getValue());
}