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


Java Patient.setBirthDate方法代码示例

本文整理汇总了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'"));
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:25,代码来源:ResourceValidatorDstu2Test.java

示例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());

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

示例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());
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:30,代码来源:XmlParserDstu2Test.java

示例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());
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:30,代码来源:JsonParserDstu2Test.java

示例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);

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


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