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


Java IBaseResource类代码示例

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


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

示例1: toJson

import org.hl7.fhir.instance.model.api.IBaseResource; //导入依赖的package包/类
/**
 * Converts a set of FHIR resources to JSON.
 *
 * @param dataset a dataset containing FHIR resources
 * @param resourceType the FHIR resource type
 * @return a dataset of JSON strings for the FHIR resources
 */
public static Dataset<String> toJson(Dataset<?> dataset, String resourceType) {

  Dataset<IBaseResource> resourceDataset =
      dataset.as(FhirEncoders.forStu3()
          .getOrCreate()
          .of(resourceType));

  return resourceDataset.map(new ToJson(), Encoders.STRING());
}
 
开发者ID:cerner,项目名称:bunsen,代码行数:17,代码来源:Functions.java

示例2: deleteServerResources

import org.hl7.fhir.instance.model.api.IBaseResource; //导入依赖的package包/类
private static void deleteServerResources(IGenericClient client, Iterable<Object> resources, String dataType){
	for(Object obj : resources){
		IBaseResource resource = (IBaseResource) obj;
		try{
			//delete existing
			client.delete()
				.resourceConditionalByType(resource.getClass())
				.where(new TokenClientParam("identifier").exactly()
					.systemAndCode("http://mcm.usciitg-prep.org", resource.getIdElement().getIdPart()))
				.execute();
			System.out.println(dataType + ":" + resource.getIdElement().getValue() + " deleted ID:" + resource.getIdElement().getIdPart());
		}catch(Exception e){
			System.out.println(dataType + ":" + resource.getIdElement().getValue() + " deleted: failure" + " ID:" + resource.getIdElement().getIdPart());
		}			
	}
}
 
开发者ID:Discovery-Research-Network-SCCM,项目名称:FHIR-CQL-ODM-service,代码行数:17,代码来源:UsciitgFhirDataProviderHL7IT.java

示例3: of

import org.hl7.fhir.instance.model.api.IBaseResource; //导入依赖的package包/类
/**
 * Returns an encoder for the given FHIR resource.
 *
 * @param type the type of the resource to encode.
 * @param <T> the type of the resource to be encoded.
 * @return an encoder for the resource.
 */
public <T extends IBaseResource> ExpressionEncoder<T> of(Class<T> type) {

  BaseRuntimeElementCompositeDefinition definition =
      context.getResourceDefinition(type);

  synchronized (encoderCache) {

    ExpressionEncoder<T> encoder = encoderCache.get(type);

    if (encoder == null) {

      encoder = (ExpressionEncoder<T>)
          EncoderBuilder.of(definition,
              context,
              new SchemaConverter(context));

      encoderCache.put(type, encoder);
    }

    return encoder;
  }
}
 
开发者ID:cerner,项目名称:bunsen,代码行数:30,代码来源:FhirEncoders.java

示例4: extractEntry

import org.hl7.fhir.instance.model.api.IBaseResource; //导入依赖的package包/类
/**
 * Extracts the given resource type from the RDD of bundles and returns
 * it as a Dataset of that type.
 *
 * @param spark the spark session
 * @param bundles an RDD of FHIR Bundles
 * @param resourceName the FHIR name of the resource type to extract
 *     (e.g., condition, patient. etc).
 * @param encoders the Encoders instance defining how the resources are encoded.
 * @param <T> the type of the resource being extracted from the bundles.
 * @return a dataset of the given resource
 */
public static <T extends IBaseResource> Dataset<T> extractEntry(SparkSession spark,
    JavaRDD<Bundle> bundles,
    String resourceName,
    FhirEncoders encoders) {

  RuntimeResourceDefinition def = context.getResourceDefinition(resourceName);

  JavaRDD<T> resourceRdd = bundles.flatMap(new ToResource<T>(def.getName()));

  Encoder<T> encoder = encoders.of((Class<T>) def.getImplementingClass());

  return spark.createDataset(resourceRdd.rdd(), encoder);
}
 
开发者ID:cerner,项目名称:bunsen,代码行数:26,代码来源:Bundles.java

示例5: fetchResource

import org.hl7.fhir.instance.model.api.IBaseResource; //导入依赖的package包/类
@Override
public <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri) {
	String resName = myCtx.getResourceDefinition(theClass).getName();
	ourLog.info("Attempting to fetch {} at URL: {}", resName, theUri);
	
	myCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
	IGenericClient client = myCtx.newRestfulGenericClient("http://example.com");
	
	T result;
	try {
		result = client.read(theClass, theUri);
	} catch (BaseServerResponseException e) {
		throw new CommandFailureException("FAILURE: "+theUri+" Received HTTP " + e.getStatusCode() + ": " + e.getMessage());
	}
	ourLog.info("Successfully loaded resource");
	return result;
}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:18,代码来源:LoadingValidationSupportDstu3.java

示例6: accept

import org.hl7.fhir.instance.model.api.IBaseResource; //导入依赖的package包/类
@Override
public void accept(CSVRecord theRecord) {

    for (IBaseResource resource : resources) {
        if (resource instanceof AllergyIntolerance) {
            AllergyIntolerance allergy = (AllergyIntolerance) resource;
            if (allergy.getIdentifier().size()>0 && theRecord.get("allergy.identifier").equals(allergy.getIdentifier().get(0).getValue())) {
                AllergyIntolerance.AllergyIntoleranceReactionComponent reaction = allergy.addReaction();
                reaction.addManifestation().addCoding()
                        .setSystem(CareConnectSystem.SNOMEDCT)
                        .setDisplay(theRecord.get("reaction.manifestation.display"))
                        .setCode(theRecord.get("reaction.manifestation"));
           //     System.out.println(ctx.newJsonParser().setPrettyPrint(true).encodeResourceToString(allergy));
            }
        }
    }

}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:19,代码来源:UploadExamples.java

示例7: extractValues

import org.hl7.fhir.instance.model.api.IBaseResource; //导入依赖的package包/类
protected List<Object> extractValues(String paths, IBaseResource instance) {
	List<Object> values = new ArrayList<Object>();
	String[] nextPathsSplit = paths.split("\\|");
	FhirTerser t = this.ctx.newTerser();
	for (String nextPath : nextPathsSplit) {
		String nextPathTrimmed = nextPath.trim();
		try {
			values.addAll(t.getValues(instance, nextPathTrimmed));
		} catch (Exception e) {
			RuntimeResourceDefinition def = this.ctx.getResourceDefinition(instance);
			logger.warn("Failed to index values from path[{}] in resource type[{}]: {}",
					new Object[] { nextPathTrimmed, def.getName(), e.toString(), e });
		}
	}
	return values;
}
 
开发者ID:jmiddleton,项目名称:cassandra-fhir-index,代码行数:17,代码来源:AbstractSearchParameterExtractor.java

示例8: loadObservationData

import org.hl7.fhir.instance.model.api.IBaseResource; //导入依赖的package包/类
public void loadObservationData() throws Exception {
	IParser parser = ctx.newJsonParser();

	FileReader fileReader = new FileReader(
			new File(this.getClass().getClassLoader().getResource("fhir/observation_example001.json").getPath()));
	IBaseResource resource = parser.parseResource(fileReader);

	for (int i = 0; i < 1; i++) {

		resource.getIdElement().setValue("obs_" + i);
		((Observation) resource).getIdentifier().get(0).setValue("urn:uuid:187e0c12-8dd2-67e2-99b2-bf273c1111" + i);

		String json = parser.encodeResourceToString(resource);

		long timestamp = Calendar.getInstance().getTimeInMillis();
		session.execute(
				"INSERT INTO test.FHIR_RESOURCES (resource_id, version, resource_type, state, lastupdated, format, author, content)"
						+ " VALUES ('" + resource.getIdElement().getValue() + "', 1, '"
						+ resource.getClass().getSimpleName() + "', 'active', " + timestamp + ", 'json', 'dr who',"
						+ "'" + json + "')");

		System.out.println(resource.getClass().getSimpleName() + ": " + resource.getIdElement().getValue());
	}
}
 
开发者ID:jmiddleton,项目名称:cassandra-fhir-index,代码行数:25,代码来源:FhirTestDataTest.java

示例9: validateFhirRequest

import org.hl7.fhir.instance.model.api.IBaseResource; //导入依赖的package包/类
private FhirValidationResult validateFhirRequest(Contents contents) {
    FhirValidationResult result = new FhirValidationResult();
    FhirValidator validator = fhirContext.newValidator();

    IParser parser = newParser(contents.contentType);
    IBaseResource resource = parser.parseResource(contents.content);
    ValidationResult vr = validator.validateWithResult(resource);

    if (vr.isSuccessful()) {
        result.passed = true;
    } else {
        result.passed = false;
        result.operationOutcome = vr.toOperationOutcome();
    }

    return result;
}
 
开发者ID:jembi,项目名称:openhim-mediator-fhir-proxy,代码行数:18,代码来源:FhirProxyHandler.java

示例10: convertBodyForUpstream

import org.hl7.fhir.instance.model.api.IBaseResource; //导入依赖的package包/类
private Contents convertBodyForUpstream(Contents contents) {
    String targetContentType = determineTargetContentType(contents.contentType);

    if ("Client".equalsIgnoreCase(upstreamFormat) || isUpstreamAndClientFormatsEqual(contents.contentType)) {
        return new Contents(targetContentType, contents.content);
    }

    log.info("[" + openhimTrxID + "] Converting request body to " + targetContentType);

    IParser inParser = newParser(contents.contentType);
    IBaseResource resource = inParser.parseResource(contents.content);

    if ("JSON".equalsIgnoreCase(upstreamFormat) || "XML".equalsIgnoreCase(upstreamFormat)) {
        IParser outParser = newParser(targetContentType);
        String converted = outParser.setPrettyPrint(true).encodeResourceToString(resource);
        return new Contents(targetContentType, converted);
    } else {
        requestHandler.tell(new ExceptError(new RuntimeException("Unknown upstream format specified " + upstreamFormat)), getSelf());
        return null;
    }
}
 
开发者ID:jembi,项目名称:openhim-mediator-fhir-proxy,代码行数:22,代码来源:FhirProxyHandler.java

示例11: evaluatePatientListMeasure

import org.hl7.fhir.instance.model.api.IBaseResource; //导入依赖的package包/类
private MeasureReport evaluatePatientListMeasure(Measure measure, String practitioner) {
        SearchParameterMap map = new SearchParameterMap();
        map.add("general-practitioner", new ReferenceParam(practitioner));
        IBundleProvider patientProvider = ((PatientResourceProvider) provider.resolveResourceProvider("Patient")).getDao().search(map);
        List<IBaseResource> patientList = patientProvider.getResources(0, patientProvider.size());

        if (patientList.isEmpty()) {
            throw new IllegalArgumentException("No patients were found with practitioner reference " + practitioner);
        }

        List<Patient> patients = new ArrayList<>();
        patientList.forEach(x -> patients.add((Patient) x));

//        context.setContextValue("Population", patients);

        report = evaluator.evaluate(context, measure, patients, measurementPeriod, MeasureReport.MeasureReportType.PATIENTLIST);
        validateReport();
        return report;
    }
 
开发者ID:DBCG,项目名称:cqf-ruler,代码行数:20,代码来源:FHIRMeasureResourceProvider.java

示例12: onMessage

import org.hl7.fhir.instance.model.api.IBaseResource; //导入依赖的package包/类
@OnWebSocketMessage
public void onMessage(String theMsg) {
	ourLog.info("Got msg: {}", theMsg);
	if (theMsg.startsWith("bound ")) {
		myGotBound = true;
		mySubsId = (theMsg.substring("bound ".length()));
		myPingCount++;
	} else if (myGotBound && theMsg.startsWith("add " + mySubsId + "\n")) {
		String text = theMsg.substring(("add " + mySubsId + "\n").length());
		IBaseResource res = myEncoding.newParser(myFhirCtx).parseResource(text);
		myReceived.add(res);
		myPingCount++;
	} else {
		myError = "Unexpected message: " + theMsg;
	}
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:17,代码来源:SubscriptionsDstu2Test.java

示例13: handleMessage

import org.hl7.fhir.instance.model.api.IBaseResource; //导入依赖的package包/类
public void handleMessage(RestOperationTypeEnum theOperationType, IIdType theId, final IBaseResource theSubscription) throws MessagingException {

		switch (theOperationType) {
			case DELETE:
				mySubscriptionInterceptor.unregisterSubscription(theId);
				return;
			case CREATE:
			case UPDATE:
				if (!theId.getResourceType().equals("Subscription")) {
					return;
				}
				TransactionTemplate txTemplate = new TransactionTemplate(myTransactionManager);
				txTemplate.execute(new TransactionCallbackWithoutResult() {
					@Override
					protected void doInTransactionWithoutResult(TransactionStatus status) {
						activateAndRegisterSubscriptionIfRequired(theSubscription);
					}
				});
				break;
			default:
				break;
		}

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

示例14: addCommonParams

import org.hl7.fhir.instance.model.api.IBaseResource; //导入依赖的package包/类
protected IBaseResource addCommonParams(HttpServletRequest theServletRequest, final HomeRequest theRequest, final ModelMap theModel) {
	if (myConfig.getDebugTemplatesMode()) {
		myTemplateEngine.getCacheManager().clearAllCaches();
	}

	final String serverId = theRequest.getServerIdWithDefault(myConfig);
	final String serverBase = theRequest.getServerBase(theServletRequest, myConfig);
	final String serverName = theRequest.getServerName(myConfig);
	final String apiKey = theRequest.getApiKey(theServletRequest, myConfig);
	theModel.put("serverId", serverId);
	theModel.put("base", serverBase);
	theModel.put("baseName", serverName);
	theModel.put("apiKey", apiKey);
	theModel.put("resourceName", defaultString(theRequest.getResource()));
	theModel.put("encoding", theRequest.getEncoding());
	theModel.put("pretty", theRequest.getPretty());
	theModel.put("_summary", theRequest.get_summary());
	theModel.put("serverEntries", myConfig.getIdToServerName());

	return loadAndAddConf(theServletRequest, theRequest, theModel);
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:22,代码来源:BaseController.java

示例15: testResources

import org.hl7.fhir.instance.model.api.IBaseResource; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testResources() throws IOException, ClassNotFoundException {
	FhirContext ctx = FhirContext.forDstu2Hl7Org();

	Properties prop = new Properties();
	prop.load(ctx.getVersion().getFhirVersionPropertiesFile());
	for (Entry<Object, Object> next : prop.entrySet()) {
		if (next.getKey().toString().startsWith("resource.")) {
			Class<? extends IBaseResource> clazz = (Class<? extends IBaseResource>) Class.forName(next.getValue().toString());
			RuntimeResourceDefinition res = ctx.getResourceDefinition(clazz);

			scanChildren(new HashSet<Class<?>>(), clazz, res);
		}
	}
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:17,代码来源:InstantiationTest.java


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