• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java QuantityDt类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中ca.uhn.fhir.model.dstu2.composite.QuantityDt的典型用法代码示例。如果您正苦于以下问题:Java QuantityDt类的具体用法?Java QuantityDt怎么用?Java QuantityDt使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

QuantityDt类属于ca.uhn.fhir.model.dstu2.composite包,在下文中一共展示了QuantityDt类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: mapValueToFHIRType

点赞 3

import ca.uhn.fhir.model.dstu2.composite.QuantityDt; //导入依赖的package包/类
private static IDatatype mapValueToFHIRType(Object value, String unit) {
  if (value == null) {
    return null;
    
  } else if (value instanceof Condition) {
    Code conditionCode = ((HealthRecord.Entry) value).codes.get(0);
    return mapCodeToCodeableConcept(conditionCode, SNOMED_URI);
    
  } else if (value instanceof Code) {
    return mapCodeToCodeableConcept((Code) value, SNOMED_URI);
    
  } else if (value instanceof String) {
    return new StringDt((String) value);
    
  } else if (value instanceof Number) {
    return new QuantityDt().setValue(((Number) value).doubleValue())
        .setCode(unit).setSystem("http://unitsofmeasure.org/")
        .setUnit(unit);
    
  } else {
    throw new IllegalArgumentException("unexpected observation value class: "
        + value.getClass().toString() + "; " + value);
  }
}
 

开发者ID:synthetichealth,
项目名称:synthea_java
代码行数:25,
代码来源:FhirDstu2.java

示例2: main

点赞 3

import ca.uhn.fhir.model.dstu2.composite.QuantityDt; //导入依赖的package包/类
public static void main(String[] args) {
   datatypes();

   // START SNIPPET: observation
   Observation observation = new Observation();
   
   // Create a quantity datatype
   QuantityDt q = new QuantityDt();
   q.setValue(185);
   q.setSystem("http://unitsofmeasure.org");
   q.setCode("lbs");
   
   // Put the datatype in the observation
   observation.setValue(q);
   
   // Set the reference range
   observation.getReferenceRangeFirstRep().setLow(new QuantityDt(100));
   observation.getReferenceRangeFirstRep().setHigh(new QuantityDt(200));
   
   // END SNIPPET: observation
   
   
}
 

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

示例3: testPersistSearchParamQuantity

点赞 3

import ca.uhn.fhir.model.dstu2.composite.QuantityDt; //导入依赖的package包/类
@Test
public void testPersistSearchParamQuantity() {
	Observation obs = new Observation();
	obs.getCode().addCoding().setSystem("foo").setCode("testPersistSearchParamQuantity");
	obs.setValue(new QuantityDt(111));

	ourObservationDao.create(obs);

	List<Observation> found = toList(ourObservationDao.search("value-quantity", new QuantityDt(111)));
	assertEquals(1, found.size());

	found = toList(ourObservationDao.search("value-quantity", new QuantityDt(112)));
	assertEquals(1, found.size());

	found = toList(ourObservationDao.search("value-quantity", new QuantityDt(212)));
	assertEquals(0, found.size());

}
 

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

示例4: testEncodeExtensionFromDifferentVersion

点赞 3

import ca.uhn.fhir.model.dstu2.composite.QuantityDt; //导入依赖的package包/类
@Test
public void testEncodeExtensionFromDifferentVersion() {
	Patient p = new Patient();
	p.addIdentifier().setSystem("urn:sys").setValue("001");
	p.addUndeclaredExtension(false, "http://foo#ext", new QuantityDt(QuantityComparatorEnum.LESS_THAN, 2.2, "g/L"));

	String str;
	str = ourCtxDstu2.newXmlParser().encodeResourceToString(p);
	ourLog.info(str);
	assertThat(str, Matchers.stringContainsInOrder("<extension url=\"http://foo#ext\"><valueQuantity><value value=\"2.2\"", "<comparator value=\"&lt;\"", "<unit value=\"g/L\"",
			"</valueQuantity></extension>"));

	try {
		FhirContext.forDstu3().newXmlParser().encodeResourceToString(p);
		fail();
	} catch (IllegalArgumentException e) {
		assertEquals("This parser is for FHIR version DSTU3 - Can not encode a structure for version DSTU2", e.getMessage());
	}
}
 

开发者ID:jamesagnew,
项目名称:hapi-fhir,
代码行数:20,
代码来源:MultiVersionXmlParserTest.java

示例5: testCloneIntoCompositeMismatchedFields

点赞 3

import ca.uhn.fhir.model.dstu2.composite.QuantityDt; //导入依赖的package包/类
@Test
	public void testCloneIntoCompositeMismatchedFields() {
		QuantityDt source = new QuantityDt();
		source.setSystem("SYSTEM");
		source.setUnit("UNIT");
		IdentifierDt target = new IdentifierDt();

		ourCtx.newTerser().cloneInto(source, target, true);

		assertEquals("SYSTEM", target.getSystem());

		try {
			ourCtx.newTerser().cloneInto(source, target, false);
			fail();
		} catch (DataFormatException e) {
			// good
		}
}
 

开发者ID:jamesagnew,
项目名称:hapi-fhir,
代码行数:19,
代码来源:FhirTerserDstu2Test.java

示例6: testPQ2Quantity

点赞 2

import ca.uhn.fhir.model.dstu2.composite.QuantityDt; //导入依赖的package包/类
@Test
public void testPQ2Quantity() {
    // simple instance test
    PQ pq = DatatypesFactory.eINSTANCE.createPQ();
    pq.setValue(120.0);
    pq.setUnit("mg");
    QuantityDt quantity = dtt.tPQ2Quantity(pq);

    Assert.assertEquals("PQ.value was not transformed", 120.0, quantity.getValue().doubleValue(), 0.001);
    Assert.assertEquals("PQ.unit was not transformed", "mg", quantity.getUnit());

    // null instance test
    PQ pq2 = null;
    QuantityDt quantity2 = dtt.tPQ2Quantity(pq2);
    Assert.assertNull("PQ null instance transform failed", quantity2);

    // nullFlavor instance test
    PQ pq3 = DatatypesFactory.eINSTANCE.createPQ();
    pq3.setNullFlavor(NullFlavor.NI);
    QuantityDt quantity3 = dtt.tPQ2Quantity(pq3);
    Assert.assertNull("PQ.nullFlavor set instance transform failed", quantity3);
    
    PQ pq4=DatatypesFactory.eINSTANCE.createPQ();
    pq4.setValue(25.0);
    pq4.setUnit(null);
    
    QuantityDt quantity4=dtt.tPQ2Quantity(pq4);
    Assert.assertEquals("PQ.value was not transformed", 25.0,quantity4.getValue().doubleValue(),0.001);
    Assert.assertNull("PQ.unit null was not transformed",quantity4.getUnit());
}
 

开发者ID:srdc,
项目名称:cda2fhir,
代码行数:31,
代码来源:DataTypesTransformerTest.java

示例7: resolveReturnType

点赞 2

import ca.uhn.fhir.model.dstu2.composite.QuantityDt; //导入依赖的package包/类
protected Class resolveReturnType(Class clazz, Object target, String path) {
    if (target instanceof PeriodDt) {
        if (path.equals("start") || path.equals("end")) {
            return DateTimeDt.class;
        }
    }
    else if (target instanceof QuantityDt) {
        if (path.equals("value")) {
            return DecimalDt.class;
        }
        else if (path.equals("unit")) {
            return StringDt.class;
        }
    }
    else if (target instanceof CodingDt) {
        if (path.equals("code")) {
            return CodeDt.class;
        }
        else if (path.equals("system")) {
            return UriDt.class;
        }
        else if (path.equals("version") || path.equals("display")) {
            return StringDt.class;
        }
    }
    else if (target instanceof CodeableConceptDt) {
        if (path.equals("text")) {
            return StringDt.class;
        }
    }
    return clazz;
}
 

开发者ID:DBCG,
项目名称:cql_engine,
代码行数:33,
代码来源:FhirDataProviderDstu2.java

示例8: testSearchValueQuantity

点赞 2

import ca.uhn.fhir.model.dstu2.composite.QuantityDt; //导入依赖的package包/类
@Test
public void testSearchValueQuantity() {
	String methodName = "testSearchValueQuantity";

	QuantityParam param;
	Set<Long> found;
	param = new QuantityParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), null, null);
	found = ourObservationDao.searchForIds("value-quantity", param);
	int initialSize = found.size();

	Observation o = new Observation();
	o.getCode().addCoding().setSystem("urn:foo").setCode(methodName + "code");
	QuantityDt q = new QuantityDt().setSystem("urn:bar:" + methodName).setCode(methodName + "units").setValue(100);
	o.setValue(q);

	ourObservationDao.create(o);

	param = new QuantityParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), null, null);
	found = ourObservationDao.searchForIds("value-quantity", param);
	assertEquals(1 + initialSize, found.size());

	param = new QuantityParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), null, methodName + "units");
	found = ourObservationDao.searchForIds("value-quantity", param);
	assertEquals(1, found.size());

	param = new QuantityParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), "urn:bar:" + methodName, null);
	found = ourObservationDao.searchForIds("value-quantity", param);
	assertEquals(1, found.size());

	param = new QuantityParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), "urn:bar:" + methodName, methodName + "units");
	found = ourObservationDao.searchForIds("value-quantity", param);
	assertEquals(1, found.size());

}
 

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

示例9: testEncodeExtensionFromDifferentVersion

点赞 2

import ca.uhn.fhir.model.dstu2.composite.QuantityDt; //导入依赖的package包/类
@Test
public void testEncodeExtensionFromDifferentVersion() {
	Patient p = new Patient();
	p.addIdentifier().setSystem("urn:sys").setValue("001");
	p.addUndeclaredExtension(false, "http://foo#ext", new QuantityDt(2.2));
	
	try {
		FhirContext.forDstu3().newJsonParser().encodeResourceToString(p);
		fail();
	} catch (IllegalArgumentException e) {
		assertEquals("This parser is for FHIR version DSTU3 - Can not encode a structure for version DSTU2", e.getMessage());
	}
}
 

开发者ID:jamesagnew,
项目名称:hapi-fhir,
代码行数:14,
代码来源:MultiVersionJsonParserTest.java

示例10: testEncodeWithCustomType

点赞 2

import ca.uhn.fhir.model.dstu2.composite.QuantityDt; //导入依赖的package包/类
@Test
public void testEncodeWithCustomType() {

	MyCustomPatient patient = new MyCustomPatient();

	patient.addIdentifier().setSystem("urn:system").setValue("1234");
	patient.addName().addFamily("Rossi").addGiven("Mario");
	patient.setInsulinLevel(new QuantityDt());
	patient.setGlucoseLevel(new QuantityDt());
	patient.setHbA1c(new QuantityDt());
	patient.setBloodPressure(new QuantityDt());
	patient.setCholesterol(new QuantityDt());
	patient.setWeight(new StringDt("80 kg"));
	patient.setWeight(new StringDt("185 cm"));
	patient.setCheckDates(new ArrayList<DateTimeDt>());
	patient.getCheckDates().add(new DateTimeDt("2014-01-26T11:11:11"));

	IParser p = ourCtx.newXmlParser().setPrettyPrint(true);
	String messageString = p.encodeResourceToString(patient);

	ourLog.info(messageString);

	//@formatter:off
	assertThat(messageString, stringContainsInOrder(
		"<meta>", 
		"<profile value=\"http://example.com/foo\"/>", 
		"</meta>"));
	//@formatter:on

	//@formatter:off
	assertThat(messageString, not(stringContainsInOrder(
		"<meta>", 
		"<profile value=\"http://example.com/foo\"", "/>", 
		"<profile value=\"http://example.com/foo\"/>", 
		"</meta>")));
	//@formatter:on
}
 

开发者ID:jamesagnew,
项目名称:hapi-fhir,
代码行数:38,
代码来源:CustomTypeDstu2Test.java

示例11: testCloneIntoComposite

点赞 2

import ca.uhn.fhir.model.dstu2.composite.QuantityDt; //导入依赖的package包/类
@Test
public void testCloneIntoComposite() {
	QuantityDt source = new QuantityDt();
	source.setCode("CODE");
	MoneyDt target = new MoneyDt();

	ourCtx.newTerser().cloneInto(source, target, true);

	assertEquals("CODE", target.getCode());
}
 

开发者ID:jamesagnew,
项目名称:hapi-fhir,
代码行数:11,
代码来源:FhirTerserDstu2Test.java

示例12: extractSearchParamQuantity

点赞 2

import ca.uhn.fhir.model.dstu2.composite.QuantityDt; //导入依赖的package包/类
@Override
public List<ResourceIndexedSearchParamQuantity> extractSearchParamQuantity(ResourceTable theEntity, IResource theResource) {
	ArrayList<ResourceIndexedSearchParamQuantity> retVal = new ArrayList<ResourceIndexedSearchParamQuantity>();

	RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
	for (RuntimeSearchParam nextSpDef : def.getSearchParams()) {
		if (nextSpDef.getParamType() != RestSearchParameterTypeEnum.QUANTITY) {
			continue;
		}

		String nextPath = nextSpDef.getPath();
		if (isBlank(nextPath)) {
			continue;
		}

		for (Object nextObject : extractValues(nextPath, theResource)) {
			if (nextObject == null || ((IDatatype) nextObject).isEmpty()) {
				continue;
			}

			String resourceName = nextSpDef.getName();
			boolean multiType = false;
			if (nextPath.endsWith("[x]")) {
				multiType = true;
			}

			if (nextObject instanceof QuantityDt) {
				QuantityDt nextValue = (QuantityDt) nextObject;
				if (nextValue.getValueElement().isEmpty()) {
					continue;
				}

				ResourceIndexedSearchParamQuantity nextEntity = new ResourceIndexedSearchParamQuantity(resourceName, nextValue.getValueElement().getValue(), nextValue.getSystemElement().getValueAsString(), nextValue.getCode());
				nextEntity.setResource(theEntity);
				retVal.add(nextEntity);
			} else {
				if (!multiType) {
					throw new ConfigurationException("Search param " + resourceName + " is of unexpected datatype: " + nextObject.getClass());
				} else {
					continue;
				}
			}
		}
	}

	theEntity.setParamsNumberPopulated(retVal.size() > 0);

	return retVal;
}
 

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

示例13: conditionalCreate

点赞 2

import ca.uhn.fhir.model.dstu2.composite.QuantityDt; //导入依赖的package包/类
private static void conditionalCreate() {
   
   //START SNIPPET: conditional
   // Create a patient object
   Patient patient = new Patient();
   patient.addIdentifier()
      .setSystem("http://acme.org/mrns")
      .setValue("12345");
   patient.addName()
      .addFamily("Jameson")
      .addGiven("J")
      .addGiven("Jonah");
   patient.setGender(AdministrativeGenderEnum.MALE);
   
   // Give the patient a temporary UUID so that other resources in
   // the transaction can refer to it
   patient.setId(IdDt.newRandomUuid());
   
   // Create an observation object
   Observation observation = new Observation();
   observation.setStatus(ObservationStatusEnum.FINAL);
   observation
      .getCode()
         .addCoding()
            .setSystem("http://loinc.org")
            .setCode("789-8")
            .setDisplay("Erythrocytes [#/volume] in Blood by Automated count");
   observation.setValue(
      new QuantityDt()
         .setValue(4.12)
         .setUnit("10 trillion/L")
         .setSystem("http://unitsofmeasure.org")
         .setCode("10*12/L"));

   // The observation refers to the patient using the ID, which is already
   // set to a temporary UUID  
   observation.setSubject(new ResourceReferenceDt(patient.getId().getValue()));

   // Create a bundle that will be used as a transaction
   Bundle bundle = new Bundle();
   bundle.setType(BundleTypeEnum.TRANSACTION);
   
   // Add the patient as an entry. This entry is a POST with an 
   // If-None-Exist header (conditional create) meaning that it
   // will only be created if there isn't already a Patient with
   // the identifier 12345
   bundle.addEntry()
      .setFullUrl(patient.getId().getValue())
      .setResource(patient)
      .getRequest()
         .setUrl("Patient")
         .setIfNoneExist("identifier=http://acme.org/mrns|12345")
         .setMethod(HTTPVerbEnum.POST);
   
   // Add the observation. This entry is a POST with no header
   // (normal create) meaning that it will be created even if
   // a similar resource already exists.
   bundle.addEntry()
      .setResource(observation)
      .getRequest()
         .setUrl("Observation")
         .setMethod(HTTPVerbEnum.POST);
   
   // Log the request
   FhirContext ctx = FhirContext.forDstu2();
   System.out.println(ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(bundle));
   
   // Create a client and post the transaction to the server
   IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu2");
   Bundle resp = client.transaction().withBundle(bundle).execute();

   // Log the response
   System.out.println(ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp));
   //END SNIPPET: conditional
   
}
 

开发者ID:jamesagnew,
项目名称:hapi-fhir,
代码行数:77,
代码来源:ClientTransactionExamples.java

示例14: testParserJson

点赞 2

import ca.uhn.fhir.model.dstu2.composite.QuantityDt; //导入依赖的package包/类
@Test
public void testParserJson() {

	FhirContext ctx = FhirContext.forDstu2();

	Observation o = new Observation();
	o.getCode().setText("TEXT");
	o.setValue(new QuantityDt(123));
	o.addIdentifier().setSystem("system");

	String str = ctx.newJsonParser().encodeResourceToString(o);
	Observation p2 = ctx.newJsonParser().parseResource(Observation.class, str);

	assertEquals("TEXT", p2.getCode().getText());

	QuantityDt dt = (QuantityDt) p2.getValue();
	dt.getComparatorElement().getValueAsEnum();

}
 

开发者ID:jamesagnew,
项目名称:hapi-fhir,
代码行数:20,
代码来源:BuiltJarDstu2ShadeIT.java

示例15: testEncodeWithCustomTypeAndAutoInsertedProfile

点赞 2

import ca.uhn.fhir.model.dstu2.composite.QuantityDt; //导入依赖的package包/类
@Test
public void testEncodeWithCustomTypeAndAutoInsertedProfile() {

	MyCustomPatient patient = new MyCustomPatient();

	patient.getMeta().addProfile("http://example.com/foo");
	patient.getMeta().addProfile("http://example.com/bar");

	patient.addIdentifier().setSystem("urn:system").setValue("1234");
	patient.addName().addFamily("Rossi").addGiven("Mario");
	patient.setInsulinLevel(new QuantityDt());
	patient.setGlucoseLevel(new QuantityDt());
	patient.setHbA1c(new QuantityDt());
	patient.setBloodPressure(new QuantityDt());
	patient.setCholesterol(new QuantityDt());
	patient.setWeight(new StringDt("80 kg"));
	patient.setWeight(new StringDt("185 cm"));
	patient.setCheckDates(new ArrayList<DateTimeDt>());
	patient.getCheckDates().add(new DateTimeDt("2014-01-26T11:11:11"));

	ourCtx.setAddProfileTagWhenEncoding(AddProfileTagEnum.ONLY_FOR_CUSTOM);
	IParser p = ourCtx.newXmlParser().setPrettyPrint(true);
	String messageString = p.encodeResourceToString(patient);

	ourLog.info(messageString);

	//@formatter:off
	assertThat(messageString, stringContainsInOrder(
		"<meta>", 
		"<profile value=\"http://example.com/foo\"/>", 
		"<profile value=\"http://example.com/bar\"/>", 
		"</meta>"));
	//@formatter:on

	//@formatter:off
	assertThat(messageString, not(stringContainsInOrder(
		"<meta>", 
		"<profile value=\"http://example.com/foo\"", "/>", 
		"<profile value=\"http://example.com/foo\"/>", 
		"</meta>")));
	//@formatter:on
}
 

开发者ID:jamesagnew,
项目名称:hapi-fhir,
代码行数:43,
代码来源:CustomTypeDstu2Test.java

示例16: setBloodPressure

点赞 2

import ca.uhn.fhir.model.dstu2.composite.QuantityDt; //导入依赖的package包/类
public void setBloodPressure(QuantityDt bloodPressure) {
	myBloodPressure = bloodPressure;
	myBloodPressure.setValue(110);
	myBloodPressure.setSystem("http://unitsofmeasure.org");
	myBloodPressure.setCode("mmHg");
}
 

开发者ID:jamesagnew,
项目名称:hapi-fhir,
代码行数:7,
代码来源:CustomTypeDstu2Test.java

示例17: setCholesterol

点赞 2

import ca.uhn.fhir.model.dstu2.composite.QuantityDt; //导入依赖的package包/类
public void setCholesterol(QuantityDt cholesterol) {
	myCholesterol = cholesterol;
	myCholesterol.setValue(2);
	myCholesterol.setSystem("http://unitsofmeasure.org");
	myCholesterol.setCode("mmol/l");
}
 

开发者ID:jamesagnew,
项目名称:hapi-fhir,
代码行数:7,
代码来源:CustomTypeDstu2Test.java

示例18: setGlucoseLevel

点赞 2

import ca.uhn.fhir.model.dstu2.composite.QuantityDt; //导入依赖的package包/类
public void setGlucoseLevel(QuantityDt glucoseLevel) {
	myGlucoseLevel = glucoseLevel;
	myGlucoseLevel.setValue(95);
	myGlucoseLevel.setSystem("http://unitsofmeasure.org");
	myGlucoseLevel.setCode("mg/dl");
}
 

开发者ID:jamesagnew,
项目名称:hapi-fhir,
代码行数:7,
代码来源:CustomTypeDstu2Test.java

示例19: setHbA1c

点赞 2

import ca.uhn.fhir.model.dstu2.composite.QuantityDt; //导入依赖的package包/类
public void setHbA1c(QuantityDt hba1c) {
	myHbA1c = hba1c;
	myHbA1c.setValue(48);
	myHbA1c.setSystem("http://unitsofmeasure.org");
	myHbA1c.setCode("mmol/mol");
}
 

开发者ID:jamesagnew,
项目名称:hapi-fhir,
代码行数:7,
代码来源:CustomTypeDstu2Test.java

示例20: setInsulinLevel

点赞 2

import ca.uhn.fhir.model.dstu2.composite.QuantityDt; //导入依赖的package包/类
public void setInsulinLevel(QuantityDt insulinLevel) {
	myInsulinLevel = insulinLevel;
	myInsulinLevel.setValue(125);
	myInsulinLevel.setSystem("http://unitsofmeasure.org");
	myInsulinLevel.setCode("pmol/l");
}
 

开发者ID:jamesagnew,
项目名称:hapi-fhir,
代码行数:7,
代码来源:CustomTypeDstu2Test.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)