本文整理汇总了Java中ca.uhn.fhir.model.dstu2.resource.Patient类的典型用法代码示例。如果您正苦于以下问题:Java Patient类的具体用法?Java Patient怎么用?Java Patient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Patient类属于ca.uhn.fhir.model.dstu2.resource包,在下文中一共展示了Patient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBindViewHolder
import ca.uhn.fhir.model.dstu2.resource.Patient; //导入依赖的package包/类
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
Patient patient = data.get(position);
StringBuilder b = new StringBuilder("Identifier");
for (IdentifierDt i : patient.getIdentifier()) {
if (i.isEmpty()) {
continue;
}
b.append(" ").append(i.getValue());
}
holder.header.setText(b.toString().trim());
String html = patient.getText().getDiv().getValueAsString();
if (html != null && html.length() > 0) {
holder.content.setText(Html.fromHtml(html));
}
}
示例2: testServiceCallInRHS
import ca.uhn.fhir.model.dstu2.resource.Patient; //导入依赖的package包/类
@Test
public void testServiceCallInRHS() {
Assert.assertNotNull(kBase);
KieSession kSession = kBase.newKieSession();
kSession.setGlobal("myConditionsProviderService", new MyConditionsProviderServiceImpl());
System.out.println(" ---- Starting testServiceCallInRHS() Test ---");
Patient patient = (Patient) new Patient().setId("Patient/1");
FactHandle patientHandle = kSession.insert(patient);
Assert.assertEquals(50, kSession.fireAllRules());
//A modification of the patient will execute the service
patient.addName(new HumanNameDt().addFamily("Richards"));
kSession.update(patientHandle, patient);
Assert.assertEquals(50, kSession.fireAllRules());
System.out.println(" ---- Finished testServiceCallInRHS() Test ---");
kSession.dispose();
}
示例3: testObservationAndPatientRelated
import ca.uhn.fhir.model.dstu2.resource.Patient; //导入依赖的package包/类
@Test
public void testObservationAndPatientRelated() {
Assert.assertNotNull(kBase);
KieSession kSession = kBase.newKieSession();
System.out.println(" ---- Starting testObservationAndPatientRelated() Test ---");
Patient patient = (Patient) new Patient().setId("Patient/1");
Observation observation = (Observation) new Observation().setId("Observation/1");
observation.setSubject(new ResourceReferenceDt(patient));
kSession.insert(observation);
Assert.assertEquals(0, kSession.fireAllRules());
System.out.println(" ---- Finished testObservationAndPatientRelated() Test ---");
kSession.dispose();
}
示例4: testPatientAndAnRelatedObservation
import ca.uhn.fhir.model.dstu2.resource.Patient; //导入依赖的package包/类
@Test
public void testPatientAndAnRelatedObservation() {
Assert.assertNotNull(kBase);
KieSession kSession = kBase.newKieSession();
System.out.println(" ---- Starting testRoomAndHouseRelated() Test ---");
Patient patient = (Patient) new Patient().setId("Patient/1");
kSession.insert(patient);
kSession.insert(new Observation()
.setSubject(new ResourceReferenceDt(patient))
.setId("Observation/1")
);
Assert.assertEquals(2, kSession.fireAllRules());
System.out.println(" ---- Finished testRoomAndHouseRelated() Test ---");
kSession.dispose();
}
示例5: testPersistSearchParamDate
import ca.uhn.fhir.model.dstu2.resource.Patient; //导入依赖的package包/类
@Test
public void testPersistSearchParamDate() {
List<Patient> found = toList(ourPatientDao.search(Patient.SP_BIRTHDATE, new DateParam(QuantityCompararatorEnum.GREATERTHAN, "2000-01-01")));
int initialSize2000 = found.size();
found = toList(ourPatientDao.search(Patient.SP_BIRTHDATE, new DateParam(QuantityCompararatorEnum.GREATERTHAN, "2002-01-01")));
int initialSize2002 = found.size();
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.setBirthDate(new DateDt("2001-01-01"));
ourPatientDao.create(patient);
found = toList(ourPatientDao.search(Patient.SP_BIRTHDATE, new DateParam(QuantityCompararatorEnum.GREATERTHAN, "2000-01-01")));
assertEquals(1 + initialSize2000, found.size());
found = toList(ourPatientDao.search(Patient.SP_BIRTHDATE, new DateParam(QuantityCompararatorEnum.GREATERTHAN, "2002-01-01")));
assertEquals(initialSize2002, found.size());
// If this throws an exception, that would be an acceptable outcome as well..
found = toList(ourPatientDao.search(Patient.SP_BIRTHDATE + "AAAA", new DateParam(QuantityCompararatorEnum.GREATERTHAN, "2000-01-01")));
assertEquals(0, found.size());
}
示例6: test20PatientsInALocation
import ca.uhn.fhir.model.dstu2.resource.Patient; //导入依赖的package包/类
@Test
public void test20PatientsInALocation() {
Assert.assertNotNull(kBase);
KieSession kSession = kBase.newKieSession();
System.out.println(" ---- Starting test20PatientsInALocation() Test ---");
Location location = (Location) new FixedCapacityLocation()
.setCapacity(15)
.setId("Location/1");
List<Patient> patients = generatePatients(20);
for(Patient p : patients){
kSession.insert(p);
}
kSession.insert(location);
Assert.assertEquals(1, kSession.fireAllRules());
System.out.println(" ---- Finished test20PatientsInALocation() Test ---");
kSession.dispose();
}
示例7: testUpdateWithIfMatch
import ca.uhn.fhir.model.dstu2.resource.Patient; //导入依赖的package包/类
@Test
public void testUpdateWithIfMatch() throws Exception {
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue("001");
String resBody = ourCtx.newXmlParser().encodeResourceToString(p);
HttpPut http;
http = new HttpPut("http://localhost:" + ourPort + "/Patient/2");
http.setEntity(new StringEntity(resBody, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
http.addHeader(Constants.HEADER_IF_MATCH, "\"221\"");
CloseableHttpResponse status = ourClient.execute(http);
IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
assertEquals("Patient/2/_history/221", ourLastId.toUnqualified().getValue());
}
示例8: testOutOfBoundsDate
import ca.uhn.fhir.model.dstu2.resource.Patient; //导入依赖的package包/类
/**
* See issue #50
*/
@Test
public void testOutOfBoundsDate() {
Patient p = new Patient();
p.setBirthDate(new DateDt("2000-15-31"));
String encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(p);
ourLog.info(encoded);
assertThat(encoded, StringContains.containsString("2000-15-31"));
p = ourCtx.newXmlParser().parseResource(Patient.class, encoded);
assertEquals("2000-15-31", p.getBirthDateElement().getValueAsString());
assertEquals("2001-03-31", new SimpleDateFormat("yyyy-MM-dd").format(p.getBirthDate()));
ValidationResult result = ourCtx.newValidator().validateWithResult(p);
String resultString = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result.getOperationOutcome());
ourLog.info(resultString);
assertEquals(2, result.getOperationOutcome().getIssue().size());
assertThat(resultString, StringContains.containsString("cvc-pattern-valid: Value '2000-15-31'"));
}
示例9: main
import ca.uhn.fhir.model.dstu2.resource.Patient; //导入依赖的package包/类
@SuppressWarnings("unused")
public static void main(String[] args) throws DataFormatException, IOException {
Patient patient = new Patient();
patient.addIdentifier().setUse(IdentifierUseEnum.OFFICIAL).setSystem("urn:fake:mrns").setValue("7000135");
patient.addIdentifier().setUse(IdentifierUseEnum.SECONDARY).setSystem("urn:fake:otherids").setValue("3287486");
patient.addName().addFamily("Smith").addGiven("John").addGiven("Q").addSuffix("Junior");
patient.setGender(AdministrativeGenderEnum.MALE);
FhirContext ctx = new FhirContext();
String xmlEncoded = ctx.newXmlParser().encodeResourceToString(patient);
String jsonEncoded = ctx.newJsonParser().encodeResourceToString(patient);
MyClientInterface client = ctx.newRestfulClient(MyClientInterface.class, "http://foo/fhir");
IdentifierDt searchParam = new IdentifierDt("urn:someidentifiers", "7000135");
List<Patient> clients = client.findPatientsByIdentifier(searchParam);
}
示例10: opInstance
import ca.uhn.fhir.model.dstu2.resource.Patient; //导入依赖的package包/类
@Operation(name="$OP_INSTANCE")
public Parameters opInstance(
@IdParam IdDt theId,
@OperationParam(name="PARAM1") StringDt theParam1,
@OperationParam(name="PARAM2") Patient theParam2
) {
//@formatter:on
ourLastMethod = "$OP_INSTANCE";
ourLastId = theId;
ourLastParam1 = theParam1;
ourLastParam2 = theParam2;
Parameters retVal = new Parameters();
retVal.addParameter().setName("RET1").setValue(new StringDt("RETVAL1"));
return retVal;
}
示例11: testEncodeBundleNewBundleNoText
import ca.uhn.fhir.model.dstu2.resource.Patient; //导入依赖的package包/类
@Test
public void testEncodeBundleNewBundleNoText() {
ca.uhn.fhir.model.dstu2.resource.Bundle b = new ca.uhn.fhir.model.dstu2.resource.Bundle();
b.getText().setDiv("");
b.getText().getStatus().setValueAsString("");
;
Entry e = b.addEntry();
e.setResource(new Patient());
String val = new FhirContext().newJsonParser().setPrettyPrint(false).encodeResourceToString(b);
ourLog.info(val);
assertThat(val, not(containsString("text")));
val = new FhirContext().newXmlParser().setPrettyPrint(false).encodeResourceToString(b);
ourLog.info(val);
assertThat(val, not(containsString("text")));
}
示例12: codes
import ca.uhn.fhir.model.dstu2.resource.Patient; //导入依赖的package包/类
@SuppressWarnings("unused")
public static void codes() {
// START SNIPPET: codes
Patient patient = new Patient();
// You can set this code using a String if you want. Note that
// for "closed" valuesets (such as the one used for Patient.gender)
// you must use one of the strings defined by the FHIR specification.
// You must not define your own.
patient.getGenderElement().setValue("male");
// HAPI also provides Java enumerated types which make it easier to
// deal with coded values. This code achieves the exact same result
// as the code above.
patient.setGender(AdministrativeGenderEnum.MALE);
// You can also retrieve coded values the same way
String genderString = patient.getGenderElement().getValueAsString();
AdministrativeGenderEnum genderEnum = patient.getGenderElement().getValueAsEnum();
// The following is a shortcut to create
patient.setMaritalStatus(MaritalStatusCodesEnum.M);
// END SNIPPET: codes
}
示例13: testSearchByString
import ca.uhn.fhir.model.dstu2.resource.Patient; //导入依赖的package包/类
@Test
public void testSearchByString() throws Exception {
String msg = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}";
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), 200, "OK"));
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_JSON + "; 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");
//@formatter:off
Bundle response = client.search()
.forResource("Patient")
.where(Patient.NAME.matches().value("james"))
.execute();
//@formatter:on
assertEquals("http://example.com/fhir/Patient?name=james", capt.getValue().getURI().toString());
assertEquals(Patient.class, response.getEntries().get(0).getResource().getClass());
}
示例14: testIIncludedResourcesNonContainedInExtensionJson
import ca.uhn.fhir.model.dstu2.resource.Patient; //导入依赖的package包/类
@Test
public void testIIncludedResourcesNonContainedInExtensionJson() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=extInclude&_pretty=true&_format=json");
HttpResponse status = ourClient.execute(httpGet);
String responseContent = IOUtils.toString(status.getEntity().getContent());
IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
Bundle bundle = ourCtx.newJsonParser().parseBundle(responseContent);
ourLog.info(responseContent);
assertEquals(3, bundle.size());
assertEquals(new IdDt("Patient/p1"), bundle.toListOfResources().get(0).getId().toUnqualifiedVersionless());
assertEquals(new IdDt("Patient/p2"), bundle.toListOfResources().get(1).getId().toUnqualifiedVersionless());
assertEquals(new IdDt("Organization/o1"), bundle.toListOfResources().get(2).getId().toUnqualifiedVersionless());
assertEquals(BundleEntrySearchModeEnum.INCLUDE, bundle.getEntries().get(2).getSearchMode().getValueAsEnum());
Patient p1 = (Patient) bundle.toListOfResources().get(0);
assertEquals(0, p1.getContained().getContainedResources().size());
Patient p2 = (Patient) bundle.toListOfResources().get(1);
assertEquals(0, p2.getContained().getContainedResources().size());
}
示例15: 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;
}