本文整理汇总了Java中ca.uhn.fhir.model.dstu2.resource.Patient.setBirthDate方法的典型用法代码示例。如果您正苦于以下问题:Java Patient.setBirthDate方法的具体用法?Java Patient.setBirthDate怎么用?Java Patient.setBirthDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca.uhn.fhir.model.dstu2.resource.Patient
的用法示例。
在下文中一共展示了Patient.setBirthDate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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'"));
}
示例2: 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());
}
示例3: 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());
}
示例4: 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());
}
示例5: testGeneratePatient
import ca.uhn.fhir.model.dstu2.resource.Patient; //导入方法依赖的package包/类
@Test
public void testGeneratePatient() throws DataFormatException {
Patient value = new Patient();
value.addIdentifier().setSystem("urn:names").setValue("123456");
value.addName().addFamily("blow").addGiven("joe").addGiven(null).addGiven("john");
value.getAddressFirstRep().addLine("123 Fake Street").addLine("Unit 1");
value.getAddressFirstRep().setCity("Toronto").setState("ON").setCountry("Canada");
value.setBirthDate(new Date(), TemporalPrecisionEnum.DAY);
NarrativeDt narrative = new NarrativeDt();
myGen.generateNarrative(value, narrative);
String output = narrative.getDiv().getValueAsString();
ourLog.info(output);
assertThat(output, StringContains.containsString("<div class=\"hapiHeaderText\"> joe john <b>BLOW </b></div>"));
String title = myGen.generateTitle(value);
assertEquals("joe john BLOW (123456)", title);
// ourLog.info(title);
value.getIdentifierFirstRep().setValue("FOO MRN 123");
title = myGen.generateTitle(value);
assertEquals("joe john BLOW (FOO MRN 123)", title);
// ourLog.info(title);
}