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


Java Observation.setSubject方法代码示例

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


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

示例1: testPatientWith3Observations

import ca.uhn.fhir.model.dstu2.resource.Observation; //导入方法依赖的package包/类
@Test
public void testPatientWith3Observations() {
    Assert.assertNotNull(kBaseCrossProduct);
    KieSession kSession = kBaseCrossProduct.newKieSession();
    System.out.println(" ---- Starting testPatientWith3Observations() Test ---");

    Patient patient = (Patient) new Patient().setId("Patient/1");
    
    Observation observation1 = (Observation) new Observation().setId("Observation/1");
    observation1.setSubject(new ResourceReferenceDt(patient));
    
    Observation observation2 = (Observation) new Observation().setId("Observation/2");
    observation2.setSubject(new ResourceReferenceDt(patient));
    
    Observation observation3 = (Observation) new Observation().setId("Observation/3");
    observation3.setSubject(new ResourceReferenceDt(patient));

    kSession.insert(patient);
    kSession.insert(observation1);
    kSession.insert(observation2);
    kSession.insert(observation3);

    Assert.assertEquals(3, kSession.fireAllRules());
    System.out.println(" ---- Finished testPatientWith3Observations() Test ---");
    kSession.dispose();
}
 
开发者ID:Salaboy,项目名称:drools-workshop,代码行数:27,代码来源:CrossProductRulesJUnitTest.java

示例2: testObservationAndPatientRelated

import ca.uhn.fhir.model.dstu2.resource.Observation; //导入方法依赖的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();
    
}
 
开发者ID:Salaboy,项目名称:drools-workshop,代码行数:18,代码来源:NonFactsRulesJUnitTest.java

示例3: createObservation

import ca.uhn.fhir.model.dstu2.resource.Observation; //导入方法依赖的package包/类
@Test
public void createObservation() throws Exception {
	Observation observation = new Observation();
	CodeableConceptDt cc = new CodeableConceptDt();
	observation.setCode(cc);
	CodingDt coding = cc.addCoding();
	coding.setCode("82313006");
	coding.setSystem("SNOMED-CT");
	ResourceReferenceDt reference = new ResourceReferenceDt();
	reference.setReference("Patient/" + myPatientId);
	observation.setSubject(reference);
	observation.setStatus(ObservationStatusEnum.FINAL);

	MethodOutcome methodOutcome2 = ourClient.create().resource(observation).execute();
	String observationId = methodOutcome2.getId().getIdPart();
	observation.setId(observationId);

	ourLog.info("Observation id generated by server is: " + observationId);

	ourLog.info("WS Messages: {}", mySocketImplementation.getMessages());
	waitForSize(2, mySocketImplementation.getMessages());
	assertThat(mySocketImplementation.getMessages(), contains("bound " + mySubscriptionId, "ping " + mySubscriptionId));
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:24,代码来源:WebsocketWithCriteriaDstu2Test.java

示例4: createObservationThatDoesNotMatch

import ca.uhn.fhir.model.dstu2.resource.Observation; //导入方法依赖的package包/类
@Test
public void createObservationThatDoesNotMatch() throws Exception {
	Observation observation = new Observation();
	CodeableConceptDt cc = new CodeableConceptDt();
	observation.setCode(cc);
	CodingDt coding = cc.addCoding();
	coding.setCode("8231");
	coding.setSystem("SNOMED-CT");
	ResourceReferenceDt reference = new ResourceReferenceDt();
	reference.setReference("Patient/" + myPatientId);
	observation.setSubject(reference);
	observation.setStatus(ObservationStatusEnum.FINAL);

	MethodOutcome methodOutcome2 = ourClient.create().resource(observation).execute();
	String observationId = methodOutcome2.getId().getIdPart();
	observation.setId(observationId);

	ourLog.info("Observation id generated by server is: " + observationId);

	waitForSize(2, mySocketImplementation.getMessages());
	ourLog.info("WS Messages: {}", mySocketImplementation.getMessages());
	assertThat(mySocketImplementation.getMessages(), contains("bound " + mySubscriptionId));
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:24,代码来源:WebsocketWithCriteriaDstu2Test.java

示例5: createObservationThatDoesNotMatch

import ca.uhn.fhir.model.dstu2.resource.Observation; //导入方法依赖的package包/类
@Test
public void createObservationThatDoesNotMatch() throws Exception {
	Observation observation = new Observation();
	CodeableConceptDt cc = new CodeableConceptDt();
	observation.setCode(cc);
	CodingDt coding = cc.addCoding();
	coding.setCode("8231");
	coding.setSystem("SNOMED-CT");
	ResourceReferenceDt reference = new ResourceReferenceDt();
	reference.setReference("Patient/" + myPatientId);
	observation.setSubject(reference);
	observation.setStatus(ObservationStatusEnum.FINAL);

	MethodOutcome methodOutcome2 = ourClient.create().resource(observation).execute();
	String observationId = methodOutcome2.getId().getIdPart();
	observation.setId(observationId);

	ourLog.info("Observation id generated by server is: " + observationId);

	ourLog.info("WS Messages: {}", mySocketImplementation.getMessages());
	waitForSize(1, mySocketImplementation.getMessages());
	assertThat(mySocketImplementation.getMessages(), contains("bound " + mySubscriptionId));
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:24,代码来源:WebsocketWithSubscriptionIdDstu2Test.java

示例6: testHapiFHIRInitializationDSTU2

import ca.uhn.fhir.model.dstu2.resource.Observation; //导入方法依赖的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

示例7: testPersistResourceLink

import ca.uhn.fhir.model.dstu2.resource.Observation; //导入方法依赖的package包/类
@Test
public void testPersistResourceLink() {
	Patient patient = new Patient();
	patient.addIdentifier().setSystem("urn:system").setValue("testPersistResourceLink01");
	IdDt patientId01 = ourPatientDao.create(patient).getId();

	Patient patient02 = new Patient();
	patient02.addIdentifier().setSystem("urn:system").setValue("testPersistResourceLink02");
	IdDt patientId02 = ourPatientDao.create(patient02).getId();

	Observation obs01 = new Observation();
	obs01.setApplies(new DateTimeDt(new Date()));
	obs01.setSubject(new ResourceReferenceDt(patientId01));
	IdDt obsId01 = ourObservationDao.create(obs01).getId();

	Observation obs02 = new Observation();
	obs02.setApplies(new DateTimeDt(new Date()));
	obs02.setSubject(new ResourceReferenceDt(patientId02));
	IdDt obsId02 = ourObservationDao.create(obs02).getId();

	// Create another type, that shouldn't be returned
	DiagnosticReport dr01 = new DiagnosticReport();
	dr01.setSubject(new ResourceReferenceDt(patientId01));
	IdDt drId01 = ourDiagnosticReportDao.create(dr01).getId();

	ourLog.info("P1[{}] P2[{}] O1[{}] O2[{}] D1[{}]", new Object[] { patientId01, patientId02, obsId01, obsId02, drId01 });

	List<Observation> result = toList(ourObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam(patientId01.getIdPart())));
	assertEquals(1, result.size());
	assertEquals(obsId01.getIdPart(), result.get(0).getId().getIdPart());

	result = toList(ourObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam(patientId02.getIdPart())));
	assertEquals(1, result.size());
	assertEquals(obsId02.getIdPart(), result.get(0).getId().getIdPart());

	result = toList(ourObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam("999999999999")));
	assertEquals(0, result.size());

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

示例8: testSearchResourceLinkWithChainWithMultipleTypes

import ca.uhn.fhir.model.dstu2.resource.Observation; //导入方法依赖的package包/类
@Test
public void testSearchResourceLinkWithChainWithMultipleTypes() {
	Patient patient = new Patient();
	patient.addName().addFamily("testSearchResourceLinkWithChainWithMultipleTypes01");
	patient.addName().addFamily("testSearchResourceLinkWithChainWithMultipleTypesXX");
	IdDt patientId01 = ourPatientDao.create(patient).getId();

	Location loc01 = new Location();
	loc01.getNameElement().setValue("testSearchResourceLinkWithChainWithMultipleTypes01");
	IdDt locId01 = ourLocationDao.create(loc01).getId();

	Observation obs01 = new Observation();
	obs01.setApplies(new DateTimeDt(new Date()));
	obs01.setSubject(new ResourceReferenceDt(patientId01));
	IdDt obsId01 = ourObservationDao.create(obs01).getId();

	Observation obs02 = new Observation();
	obs02.setApplies(new DateTimeDt(new Date()));
	obs02.setSubject(new ResourceReferenceDt(locId01));
	IdDt obsId02 = ourObservationDao.create(obs02).getId();

	ourLog.info("P1[{}] L1[{}] Obs1[{}] Obs2[{}]", new Object[] { patientId01, locId01, obsId01, obsId02 });

	List<Observation> result = toList(ourObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam(Patient.SP_NAME, "testSearchResourceLinkWithChainWithMultipleTypes01")));
	assertEquals(2, result.size());

	result = toList(ourObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam(Patient.SP_NAME, "testSearchResourceLinkWithChainWithMultipleTypesXX")));
	assertEquals(1, result.size());

	result = toList(ourObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam(Patient.SP_NAME, "testSearchResourceLinkWithChainWithMultipleTypesYY")));
	assertEquals(0, result.size());

	result = toList(ourObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam("Patient", Patient.SP_NAME, "testSearchResourceLinkWithChainWithMultipleTypes01")));
	assertEquals(1, result.size());
	assertEquals(obsId01.getIdPart(), result.get(0).getId().getIdPart());

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

示例9: method2SearchCompartment2

import ca.uhn.fhir.model.dstu2.resource.Observation; //导入方法依赖的package包/类
@Search(compartmentName = "Observation")
public List<Observation> method2SearchCompartment2(final @IdParam IdDt theId) {
	ourLastId = theId;
	ourLastMethod = "searchObservationCompartment";
	System.out.println("Encounter compartment search");
	List<Observation> encounters = new ArrayList<Observation>();
	Observation obs = new Observation();
	obs.setId("1");
	obs.setSubject(new ResourceReferenceDt(theId));
	encounters.add(obs);
	return encounters;
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:13,代码来源:CompartmentDstu2Test.java

示例10: test2PatientsWith3Observations

import ca.uhn.fhir.model.dstu2.resource.Observation; //导入方法依赖的package包/类
@Test
public void test2PatientsWith3Observations() {
    Assert.assertNotNull(kBaseCrossProduct);
    KieSession kSession = kBaseCrossProduct.newKieSession();
    System.out.println(" ---- Starting test2PatientsWith3Observations() Test ---");

    //1 Patient with 3 Observations
    Patient patient1 = (Patient) new Patient().setId("Patient/1");
    
    Observation observation1 = (Observation) new Observation().setId("Observation/1");
    observation1.setSubject(new ResourceReferenceDt(patient1));
    
    Observation observation2 = (Observation) new Observation().setId("Observation/2");
    observation2.setSubject(new ResourceReferenceDt(patient1));
    
    Observation observation3 = (Observation) new Observation().setId("Observation/3");
    observation3.setSubject(new ResourceReferenceDt(patient1));

    kSession.insert(patient1);
    kSession.insert(observation1);
    kSession.insert(observation2);
    kSession.insert(observation3);
    

    //Another Patient with 3 Observations
    Patient patient2 = (Patient) new Patient().setId("Patient/2");
    
    Observation observation4 = (Observation) new Observation().setId("Observation/4");
    observation4.setSubject(new ResourceReferenceDt(patient2));
    
    Observation observation5 = (Observation) new Observation().setId("Observation/5");
    observation5.setSubject(new ResourceReferenceDt(patient2));
    
    Observation observation6 = (Observation) new Observation().setId("Observation/6");
    observation6.setSubject(new ResourceReferenceDt(patient2));

    kSession.insert(patient2);
    kSession.insert(observation4);
    kSession.insert(observation5);
    kSession.insert(observation6);
    
    Assert.assertEquals(12, kSession.fireAllRules());
    System.out.println(" ---- Finished test2PatientsWith3Observations() Test ---");
    kSession.dispose();
}
 
开发者ID:Salaboy,项目名称:drools-workshop,代码行数:46,代码来源:CrossProductRulesJUnitTest.java

示例11: test2PatientsWith3ObservationsChecked

import ca.uhn.fhir.model.dstu2.resource.Observation; //导入方法依赖的package包/类
@Test
public void test2PatientsWith3ObservationsChecked() {
    Assert.assertNotNull(kBaseCrossProductSolution);
    KieSession kSession = kBaseCrossProductSolution.newKieSession();
    System.out.println(" ---- Starting test2PatientsWith3ObservationsChecked() Test ---");

    //1 Patient with 3 Observations
    Patient patient1 = (Patient) new Patient().setId("Patient/1");
    
    Observation observation1 = (Observation) new Observation().setId("Observation/1");
    observation1.setSubject(new ResourceReferenceDt(patient1));
    
    Observation observation2 = (Observation) new Observation().setId("Observation/2");
    observation2.setSubject(new ResourceReferenceDt(patient1));
    
    Observation observation3 = (Observation) new Observation().setId("Observation/3");
    observation3.setSubject(new ResourceReferenceDt(patient1));

    kSession.insert(patient1);
    kSession.insert(observation1);
    kSession.insert(observation2);
    kSession.insert(observation3);
    

    //Another Patient with 3 Observations
    Patient patient2 = (Patient) new Patient().setId("Patient/2");
    
    Observation observation4 = (Observation) new Observation().setId("Observation/4");
    observation4.setSubject(new ResourceReferenceDt(patient2));
    
    Observation observation5 = (Observation) new Observation().setId("Observation/5");
    observation5.setSubject(new ResourceReferenceDt(patient2));
    
    Observation observation6 = (Observation) new Observation().setId("Observation/6");
    observation6.setSubject(new ResourceReferenceDt(patient2));

    kSession.insert(patient2);
    kSession.insert(observation4);
    kSession.insert(observation5);
    kSession.insert(observation6);

    Assert.assertEquals(6, kSession.fireAllRules());
    System.out.println(" ---- Finished test2PatientsWith3ObservationsChecked() Test ---");
    kSession.dispose();
}
 
开发者ID:Salaboy,项目名称:drools-workshop,代码行数:46,代码来源:CrossProductRulesJUnitTest.java

示例12: testSearchResourceLinkWithChain

import ca.uhn.fhir.model.dstu2.resource.Observation; //导入方法依赖的package包/类
@Test
public void testSearchResourceLinkWithChain() {
	Patient patient = new Patient();
	patient.addIdentifier().setSystem("urn:system").setValue("testSearchResourceLinkWithChainXX");
	patient.addIdentifier().setSystem("urn:system").setValue("testSearchResourceLinkWithChain01");
	IdDt patientId01 = ourPatientDao.create(patient).getId();

	Patient patient02 = new Patient();
	patient02.addIdentifier().setSystem("urn:system").setValue("testSearchResourceLinkWithChainXX");
	patient02.addIdentifier().setSystem("urn:system").setValue("testSearchResourceLinkWithChain02");
	IdDt patientId02 = ourPatientDao.create(patient02).getId();

	Observation obs01 = new Observation();
	obs01.setApplies(new DateTimeDt(new Date()));
	obs01.setSubject(new ResourceReferenceDt(patientId01));
	IdDt obsId01 = ourObservationDao.create(obs01).getId();

	Observation obs02 = new Observation();
	obs02.setApplies(new DateTimeDt(new Date()));
	obs02.setSubject(new ResourceReferenceDt(patientId02));
	IdDt obsId02 = ourObservationDao.create(obs02).getId();

	// Create another type, that shouldn't be returned
	DiagnosticReport dr01 = new DiagnosticReport();
	dr01.setSubject(new ResourceReferenceDt(patientId01));
	IdDt drId01 = ourDiagnosticReportDao.create(dr01).getId();

	ourLog.info("P1[{}] P2[{}] O1[{}] O2[{}] D1[{}]", new Object[] { patientId01, patientId02, obsId01, obsId02, drId01 });

	List<Observation> result = toList(ourObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam(Patient.SP_IDENTIFIER, "urn:system|testSearchResourceLinkWithChain01")));
	assertEquals(1, result.size());
	assertEquals(obsId01.getIdPart(), result.get(0).getId().getIdPart());

	result = toList(ourObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam(Patient.SP_IDENTIFIER, "999999999999")));
	assertEquals(0, result.size());

	result = toList(ourObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam(Patient.SP_IDENTIFIER, "urn:system|testSearchResourceLinkWithChainXX")));
	assertEquals(2, result.size());

	result = toList(ourObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam(Patient.SP_IDENTIFIER, "testSearchResourceLinkWithChainXX")));
	assertEquals(2, result.size());

	result = toList(ourObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam(Patient.SP_IDENTIFIER, "|testSearchResourceLinkWithChainXX")));
	assertEquals(0, result.size());

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

示例13: testSearchResourceLinkWithTextLogicalId

import ca.uhn.fhir.model.dstu2.resource.Observation; //导入方法依赖的package包/类
@Test
public void testSearchResourceLinkWithTextLogicalId() {
	Patient patient = new Patient();
	patient.setId("testSearchResourceLinkWithTextLogicalId01");
	patient.addIdentifier().setSystem("urn:system").setValue("testSearchResourceLinkWithTextLogicalIdXX");
	patient.addIdentifier().setSystem("urn:system").setValue("testSearchResourceLinkWithTextLogicalId01");
	IdDt patientId01 = ourPatientDao.update(patient).getId();

	Patient patient02 = new Patient();
	patient02.setId("testSearchResourceLinkWithTextLogicalId02");
	patient02.addIdentifier().setSystem("urn:system").setValue("testSearchResourceLinkWithTextLogicalIdXX");
	patient02.addIdentifier().setSystem("urn:system").setValue("testSearchResourceLinkWithTextLogicalId02");
	IdDt patientId02 = ourPatientDao.update(patient02).getId();

	Observation obs01 = new Observation();
	obs01.setApplies(new DateTimeDt(new Date()));
	obs01.setSubject(new ResourceReferenceDt(patientId01));
	IdDt obsId01 = ourObservationDao.create(obs01).getId();

	Observation obs02 = new Observation();
	obs02.setApplies(new DateTimeDt(new Date()));
	obs02.setSubject(new ResourceReferenceDt(patientId02));
	IdDt obsId02 = ourObservationDao.create(obs02).getId();

	// Create another type, that shouldn't be returned
	DiagnosticReport dr01 = new DiagnosticReport();
	dr01.setSubject(new ResourceReferenceDt(patientId01));
	IdDt drId01 = ourDiagnosticReportDao.create(dr01).getId();

	ourLog.info("P1[{}] P2[{}] O1[{}] O2[{}] D1[{}]", new Object[] { patientId01, patientId02, obsId01, obsId02, drId01 });

	List<Observation> result = toList(ourObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam("testSearchResourceLinkWithTextLogicalId01")));
	assertEquals(1, result.size());
	assertEquals(obsId01.getIdPart(), result.get(0).getId().getIdPart());

	try {
		ourObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam("testSearchResourceLinkWithTextLogicalId99"));
		fail();
	} catch (ResourceNotFoundException e) {
		// good
	}

	/*
	 * TODO: it's kind of weird that we throw a 404 for textual IDs that don't exist, but just return an empty list for numeric IDs that don't exist
	 */

	result = toList(ourObservationDao.search(Observation.SP_SUBJECT, new ReferenceParam("999999999999999")));
	assertEquals(0, result.size());

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


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