当前位置: 首页>>代码示例>>Java>>正文


Java Patient.setId方法代码示例

本文整理汇总了Java中ca.uhn.fhir.model.dstu2.resource.Patient.setId方法的典型用法代码示例。如果您正苦于以下问题:Java Patient.setId方法的具体用法?Java Patient.setId怎么用?Java Patient.setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ca.uhn.fhir.model.dstu2.resource.Patient的用法示例。


在下文中一共展示了Patient.setId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: manualContained

import ca.uhn.fhir.model.dstu2.resource.Patient; //导入方法依赖的package包/类
public static void manualContained() {
   // START SNIPPET: manualContained
   // Create an organization, and give it a local ID
   Organization org = new Organization();
   org.setId("#localOrganization");
   org.getNameElement().setValue("Contained Test Organization");

   // Create a patient
   Patient patient = new Patient();
   patient.setId("Patient/1333");
   patient.addIdentifier().setSystem("urn:mrns").setValue("253345");

   // Set the reference, and manually add the contained resource
   patient.getManagingOrganization().setReference("#localOrganization");
   patient.getContained().getContainedResources().add(org);

   String encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
   System.out.println(encoded);
   // END SNIPPET: manualContained
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:21,代码来源:ResourceRefs.java

示例2: testTransactionCreateNoMatchUrl

import ca.uhn.fhir.model.dstu2.resource.Patient; //导入方法依赖的package包/类
@Test
public void testTransactionCreateNoMatchUrl() {
	String methodName = "testTransactionCreateNoMatchUrl";
	Bundle request = new Bundle();

	Patient p = new Patient();
	p.addIdentifier().setSystem("urn:system").setValue(methodName);
	p.setId("Patient/" + methodName);
	request.addEntry().setResource(p).getTransaction().setMethod(HTTPVerbEnum.POST).setIfNoneExist("Patient?identifier=urn%3Asystem%7C" + methodName);

	Bundle resp = ourSystemDao.transaction(request);
	assertEquals(2, resp.getEntry().size());

	Entry respEntry = resp.getEntry().get(1);
	assertEquals(Constants.STATUS_HTTP_201_CREATED + "", respEntry.getTransactionResponse().getStatus());
	String patientId = respEntry.getTransactionResponse().getLocation();
	assertThat(patientId, not(containsString("test")));
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:19,代码来源:FhirSystemDaoDstu2Test.java

示例3: getAllPatients

import ca.uhn.fhir.model.dstu2.resource.Patient; //导入方法依赖的package包/类
@Search
public List<Patient> getAllPatients() {
   ArrayList<Patient> retVal = new ArrayList<Patient>();
   
   // Create a patient to return
   Patient patient = new Patient();
   patient.setId("Patient/123");
   patient.addName().addFamily("Smith").addGiven("John");
   
   // Create a tag list and add it to the resource
   TagList tags = new TagList();
   ResourceMetadataKeyEnum.TAG_LIST.put(patient, tags);

   // Add some tags to the list
   tags.addTag(Tag.HL7_ORG_FHIR_TAG, "http://foo/tag1.html", "Some tag");
   tags.addTag(Tag.HL7_ORG_FHIR_TAG, "http://foo/tag2.html", "Another tag");
   
   return retVal;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:20,代码来源:TagsExamples.java

示例4: searchForPatients

import ca.uhn.fhir.model.dstu2.resource.Patient; //导入方法依赖的package包/类
@Search
private List<IResource> searchForPatients() {
   // Create an organization
   Organization org = new Organization();
   org.setId("Organization/65546");
   org.setName("Test Organization");

   // Create a patient
   Patient patient = new Patient();
   patient.setId("Patient/1333");
   patient.addIdentifier().setSystem("urn:mrns").setValue("253345");
   patient.getManagingOrganization().setResource(org);

   // Here we return only the patient object, which has links to other resources
   List<IResource> retVal = new ArrayList<IResource>();
   retVal.add(patient);
   return retVal;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:19,代码来源:IncludesExamples.java

示例5: testParseAndEncodeBundleWithDeletedEntry

import ca.uhn.fhir.model.dstu2.resource.Patient; //导入方法依赖的package包/类
@Test
public void testParseAndEncodeBundleWithDeletedEntry() {

	Patient res = new Patient();
	res.setId(new IdDt("Patient", "111", "222"));
	ResourceMetadataKeyEnum.DELETED_AT.put(res, new InstantDt("2011-01-01T12:12:22Z"));

	Bundle bundle = new Bundle();
	bundle.addResource(res, ourCtx, "http://foo/base");

	String actual = ourCtx.newJsonParser().encodeBundleToString(bundle);
	ourLog.info(actual);

	String expected = "{\"resourceType\":\"Bundle\",\"entry\":[{\"deleted\":{\"type\":\"Patient\",\"resourceId\":\"111\",\"versionId\":\"222\",\"instant\":\"2011-01-01T12:12:22Z\"}}]}";
	assertEquals(expected, actual);

}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:18,代码来源:JsonParserDstu2Test.java

示例6: testHistoryByForcedId

import ca.uhn.fhir.model.dstu2.resource.Patient; //导入方法依赖的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);
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:24,代码来源:FhirResourceDaoDstu2Test.java

示例7: testTransactionDeleteNoMatchUrl

import ca.uhn.fhir.model.dstu2.resource.Patient; //导入方法依赖的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
	}
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:26,代码来源:FhirSystemDaoDstu2Test.java

示例8: containedInclude

import ca.uhn.fhir.model.dstu2.resource.Patient; //导入方法依赖的package包/类
@Search(queryName = "containedInclude")
public List<Patient> containedInclude() {
	Organization o1 = new Organization();
	o1.getNameElement().setValue("o1");

	Patient p1 = new Patient();
	p1.setId("p1");
	p1.addIdentifier().setValue("p1");
	p1.getManagingOrganization().setResource(o1);

	Patient p2 = new Patient();
	p2.setId("p2");
	p2.addIdentifier().setValue("p2");
	p2.getManagingOrganization().setResource(o1);

	return Arrays.asList(p1, p2);
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:18,代码来源:IncludeDstu2Test.java

示例9: testHapiFHIRInitializationDSTU2

import ca.uhn.fhir.model.dstu2.resource.Patient; //导入方法依赖的package包/类
@Test
public void testHapiFHIRInitializationDSTU2() {
    PatientFhirHelper gcm = new PatientFhirHelper();

    Patient p = new Patient();
    p.setId("Patient/"+UUID.randomUUID().toString());
    p.setActive(true);
    p.addName().addFamily("HapiFhirAndroidTest").addGiven("Patient");
    Observation o = new Observation();
    o.setId("Observation/"+UUID.randomUUID().toString());
    o.addIdentifier().setValue(o.getId().getIdPart());
    o.setComments("HapiFhirAndroidTestObservation");
    o.setSubject(new ResourceReferenceDt(p));
    //Test transaction create
    gcm.getClient().update().resource(p).execute();
    gcm.getClient().update().resource(o).execute();
    //Test search
    Observation obs = getObservation(o.getId(), gcm.getClient());
    Assert.assertNotNull(obs);
    Assert.assertNotNull(obs.getSubject().getResource());
    Patient patient = ((Patient)obs.getSubject().getResource());
    Assert.assertEquals(p.getId().getIdPart(), patient.getId().getIdPart());
    Assert.assertEquals(o.getComments(), obs.getComments());
    Assert.assertEquals(o.getId().getIdPart(), obs.getId().getIdPart());
    //Test and use delete
    gcm.getClient().delete().resourceById(o.getId()).execute();
    gcm.getClient().delete().resourceById(p.getId()).execute();
    //Test the they are deleted.
    try {
        gcm.getClient().read().resource(Observation.class).withId(o.getId()).execute();
        fail();
    } catch (ResourceGoneException e) {
        // good
    }
}
 
开发者ID:hapifhir,项目名称:hapi-fhir-android-integration-test,代码行数:36,代码来源:TestFHIRRobolectric.java

示例10: getAllPatients

import ca.uhn.fhir.model.dstu2.resource.Patient; //导入方法依赖的package包/类
@Search
public List<Patient> getAllPatients() {
   ArrayList<Patient> retVal = new ArrayList<Patient>();
   
   // Create a patient to return
   Patient patient = new Patient();
   retVal.add(patient);
   patient.setId("Patient/123");
   patient.addName().addFamily("Smith").addGiven("John");
   
   // Create a tag list and add it to the resource
   TagList tags = new TagList();
   tags.addTag(Tag.HL7_ORG_FHIR_TAG, "http://foo/tag1.html", "Some tag");
   tags.addTag(Tag.HL7_ORG_FHIR_TAG, "http://foo/tag2.html", "Another tag");
   ResourceMetadataKeyEnum.TAG_LIST.put(patient, tags);
   
   // Set some links (these can be provided as relative links or absolute)
   // and the server will convert to absolute as appropriate
   String linkAlternate = "Patient/7736";
   ResourceMetadataKeyEnum.LINK_ALTERNATE.put(patient, linkAlternate);
   String linkSearch = "Patient?name=smith&name=john";
   ResourceMetadataKeyEnum.LINK_SEARCH.put(patient, linkSearch);
   
   // Set the published and updated dates
   InstantDt pubDate = new InstantDt("2011-02-22");
   ResourceMetadataKeyEnum.PUBLISHED.put(patient, pubDate);
   InstantDt updatedDate = new InstantDt("2014-07-12T11:22:27Z");
   ResourceMetadataKeyEnum.UPDATED.put(patient, updatedDate);
   
   // Set the resource title (note that if you are using HAPI's narrative
   // generation capability, the narrative generator will often create
   // useful titles automatically, and the server will create a default
   // title if none is provided)
   String title = "Patient John SMITH";
   ResourceMetadataKeyEnum.TITLE.put(patient, title);
   
   return retVal;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:39,代码来源:ServerMetadataExamples.java

示例11: findPatient

import ca.uhn.fhir.model.dstu2.resource.Patient; //导入方法依赖的package包/类
@Read(version = true)
public Patient findPatient(@IdParam IdDt theId) {
	Patient patient = new Patient();
	ResourceMetadataKeyEnum.UPDATED.put(patient, new InstantDt(ourLastModifiedDate));
	patient.addIdentifier().setSystem(theId.getIdPart()).setValue(theId.getVersionIdPart());
	patient.setId(theId.withVersion("222"));
	return patient;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:9,代码来源:ETagServerTest.java

示例12: searchByLastName

import ca.uhn.fhir.model.dstu2.resource.Patient; //导入方法依赖的package包/类
@Search()
public List<Patient> searchByLastName(@RequiredParam(name=Patient.SP_FAMILY) StringParam theFamily) {
   String valueToMatch = theFamily.getValue();
   
   if (theFamily.isExact()) {
	   // Do an exact match search
   } else {
	   // Do a fuzzy search if possible
   }
   
   // ...populate...
   Patient patient = new Patient();
   patient.addIdentifier().setSystem("urn:mrns").setValue("12345");
   patient.addName().addFamily("Smith").addGiven("Tester").addGiven("Q");
   // ...etc...

   //  Every returned resource must have its logical ID set. If the server
   //  supports versioning, that should be set too
   String logicalId = "4325";
   String versionId = "2"; // optional
   patient.setId(new IdDt("Patient", logicalId, versionId));
   
   /*
    * This is obviously a fairly contrived example since we are always
    * just returning the same hardcoded patient, but in a real scenario
    * you could return as many resources as you wanted, and they
    * should actually match the given search criteria.
    */
   List<Patient> retVal = new ArrayList<Patient>();
   retVal.add(patient);
   
   return retVal;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:34,代码来源:RestfulPatientResourceProviderMore.java

示例13: testParseResourceType

import ca.uhn.fhir.model.dstu2.resource.Patient; //导入方法依赖的package包/类
/**
 * See #163
 */
@Test
public void testParseResourceType() {
	IParser xmlParser = ourCtx.newXmlParser().setPrettyPrint(true);

	// Patient
	Patient patient = new Patient();
	String patientId = UUID.randomUUID().toString();
	patient.setId(new IdDt("Patient", patientId));
	patient.addName().addGiven("John").addFamily("Smith");
	patient.setGender(AdministrativeGenderEnum.MALE);
	patient.setBirthDate(new DateDt("1987-04-16"));

	// Bundle
	ca.uhn.fhir.model.dstu2.resource.Bundle bundle = new ca.uhn.fhir.model.dstu2.resource.Bundle();
	bundle.setType(BundleTypeEnum.COLLECTION);
	bundle.addEntry().setResource(patient);

	String bundleText = xmlParser.encodeResourceToString(bundle);
	ourLog.info(bundleText);
	
	ca.uhn.fhir.model.dstu2.resource.Bundle reincarnatedBundle = xmlParser.parseResource (ca.uhn.fhir.model.dstu2.resource.Bundle.class, bundleText);
	Patient reincarnatedPatient = reincarnatedBundle.getAllPopulatedChildElementsOfType(Patient.class).get(0); 
	
	assertEquals("Patient", patient.getId().getResourceType());
	assertEquals("Patient", reincarnatedPatient.getId().getResourceType());
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:30,代码来源:XmlParserDstu2Test.java

示例14: testParseResourceType

import ca.uhn.fhir.model.dstu2.resource.Patient; //导入方法依赖的package包/类
/**
 * See #163
 */
@Test
public void testParseResourceType() {
	IParser jsonParser = ourCtx.newJsonParser().setPrettyPrint(true);

	// Patient
	Patient patient = new Patient();
	String patientId = UUID.randomUUID().toString();
	patient.setId(new IdDt("Patient", patientId));
	patient.addName().addGiven("John").addFamily("Smith");
	patient.setGender(AdministrativeGenderEnum.MALE);
	patient.setBirthDate(new DateDt("1987-04-16"));

	// Bundle
	ca.uhn.fhir.model.dstu2.resource.Bundle bundle = new ca.uhn.fhir.model.dstu2.resource.Bundle();
	bundle.setType(BundleTypeEnum.COLLECTION);
	bundle.addEntry().setResource(patient);

	String bundleText = jsonParser.encodeResourceToString(bundle);
	ourLog.info(bundleText);
	
	ca.uhn.fhir.model.dstu2.resource.Bundle reincarnatedBundle = jsonParser.parseResource (ca.uhn.fhir.model.dstu2.resource.Bundle.class, bundleText);
	Patient reincarnatedPatient = reincarnatedBundle.getAllPopulatedChildElementsOfType(Patient.class).get(0); 
	
	assertEquals("Patient", patient.getId().getResourceType());
	assertEquals("Patient", reincarnatedPatient.getId().getResourceType());
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:30,代码来源:JsonParserDstu2Test.java

示例15: testCreateTextIdFails

import ca.uhn.fhir.model.dstu2.resource.Patient; //导入方法依赖的package包/类
@Test
public void testCreateTextIdFails() {
	Patient p = new Patient();
	p.addIdentifier().setSystem("urn:system").setValue("testCreateTextIdFails");
	p.addName().addFamily("Hello");
	p.setId("Patient/ABC");
	try {
		ourPatientDao.create(p);
		fail();
	} catch (InvalidRequestException e) {
		assertThat(e.getMessage(), containsString("Can not create resource with ID[ABC], ID must not be supplied"));
	}
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:14,代码来源:FhirResourceDaoDstu2Test.java


注:本文中的ca.uhn.fhir.model.dstu2.resource.Patient.setId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。