本文整理汇总了Java中org.hl7.fhir.instance.model.Resource类的典型用法代码示例。如果您正苦于以下问题:Java Resource类的具体用法?Java Resource怎么用?Java Resource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Resource类属于org.hl7.fhir.instance.model包,在下文中一共展示了Resource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: isNewMessage
import org.hl7.fhir.instance.model.Resource; //导入依赖的package包/类
public boolean isNewMessage(Resource resource) {
boolean isNew = false;
final ResourceType resType = resource.getResourceType();
if (resType == ResourceType.Bundle) {
Bundle bundle = (Bundle) resource;
LOG.debug("bundle id: {}, type: {} ", bundle.getId(), bundle.getType());
if (BundleType.MESSAGE.equals(bundle.getType())) {
// First Entry is expected to be a message header
final String msgId = bundle.getEntry().get(0).getResource().getId();
if (!msgIds.contains(msgId)) {
msgIds.add(msgId);
isNew = true;
LOG.info("NEW MESSAGE! id: {} ", msgId);
} else {
LOG.info("REPEAT MESSAGE id: {} ", msgId);
}
}
}
return isNew;
}
开发者ID:mitre,项目名称:ptmatchadapter,代码行数:23,代码来源:DuplicateMessageFilter.java
示例2: splitBundle
import org.hl7.fhir.instance.model.Resource; //导入依赖的package包/类
/**
* Breaks apart the given bundle into a list of Resources.
*
* @param bundle
* the payload of the incoming message
* @return a list containing each resource in the Bundle
*/
public List<Resource> splitBundle(Bundle bundle) {
final List<Resource> resources = new LinkedList<Resource>();
if (bundle != null) {
final List<BundleEntryComponent> entries = bundle.getEntry();
for (BundleEntryComponent entry : entries) {
Resource r = entry.getResource();
if (r != null) {
LOG.debug("processing resource: " + r.getId());
resources.add(r);
} else {
LOG.warn("Entry does not have a resource, fullUrl: {}",
entry.getFullUrl());
}
}
}
return resources;
}
开发者ID:mitre,项目名称:ptmatchadapter,代码行数:28,代码来源:SearchResultSplitter.java
示例3: loadCache
import org.hl7.fhir.instance.model.Resource; //导入依赖的package包/类
private void loadCache() throws FHIRFormatError, IOException {
File[] files = new File(cacheFolder).listFiles();
for (File f : files) {
if (f.getName().endsWith(".xml")) {
final FileInputStream is = new FileInputStream(f);
try {
Resource r = context.newXmlParser().setOutputStyle(IParser.OutputStyle.PRETTY).parse(is);
if (r instanceof OperationOutcome) {
OperationOutcome oo = (OperationOutcome) r;
expansions.put(ToolingExtensions.getExtension(oo,VS_ID_EXT).getValue().toString(),
new ValueSetExpander.ValueSetExpansionOutcome(new XhtmlComposer(true, false).composePlainText(oo.getText().getDiv())));
} else {
ValueSet vs = (ValueSet) r;
expansions.put(vs.getUrl(), new ValueSetExpander.ValueSetExpansionOutcome(vs, null));
}
} catch (Exception theE) {
throw new FHIRFormatError(theE);
} finally {
IOUtils.closeQuietly(is);
}
}
}
}
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:24,代码来源:ValueSetExpansionCache.java
示例4: getProfile
import org.hl7.fhir.instance.model.Resource; //导入依赖的package包/类
public StructureDefinition getProfile(StructureDefinition source, String url) {
StructureDefinition profile;
String code;
if (url.startsWith("#")) {
profile = source;
code = url.substring(1);
} else {
String[] parts = url.split("\\#");
profile = context.fetchResource(StructureDefinition.class, parts[0]);
code = parts.length == 1 ? null : parts[1];
}
if (profile == null)
return null;
if (code == null)
return profile;
for (Resource r : profile.getContained()) {
if (r instanceof StructureDefinition && r.getId().equals(code))
return (StructureDefinition) r;
}
return null;
}
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:22,代码来源:ProfileUtilities.java
示例5: makeFeedWithNarratives
import org.hl7.fhir.instance.model.Resource; //导入依赖的package包/类
/**
*
* @param result
* @param manager
* @return
* @throws MapperException
*/
private AtomFeed makeFeedWithNarratives(EObject result, FHIRSearchManager manager) throws MapperException
{
// convert the result into an instance of the FHIR reference model
EPackage classModel = getMappedStructure(serverName, resourceName).getClassModelRoot();
EcoreReferenceBridge bridge = new EcoreReferenceBridge(classModel);
AtomFeed feed = bridge.getReferenceModelFeed(result);
feed.setTitle(serverName);
// set the narratives of all the resources in the feed
for (Iterator<AtomEntry<?>> it = feed.getEntryList().iterator();it.hasNext();)
{
AtomEntry<?> entry = it.next();
Resource resource = entry.getResource();
Narrative narrative = manager.getNarrative(entry.getId());
if (narrative != null) resource.setText(narrative);
}
return feed;
}
开发者ID:openmapsoftware,项目名称:mappingtools,代码行数:26,代码来源:FHIRServlet.java
示例6: getResourceUrl
import org.hl7.fhir.instance.model.Resource; //导入依赖的package包/类
/**
* Returns the resourceUrl parameter from the Parameters resource.
*
*/
private String getResourceUrl(Parameters params) {
String resourceUrl = null;
final List<ParametersParameterComponent> paramList = params.getParameter();
final ParametersParameterComponent p = ParametersUtil.findByName(paramList,
SEARCH_EXPR);
if (p != null) {
final Resource r = p.getResource();
if (ResourceType.Parameters.equals(r.getResourceType())) {
final Parameters searchExprParams = (Parameters) r;
final List<ParametersParameterComponent> searchExprParamList = searchExprParams
.getParameter();
final ParametersParameterComponent ppc = ParametersUtil
.findByName(searchExprParamList, RESOURCE_URL);
resourceUrl = ppc.getValue().toString();
if (resourceUrl == null) {
LOG.warn(
"Required parameter, resourceUrl, is missing from record-match request!");
}
}
} else {
LOG.warn("Unable to find search expression in message parameters");
}
return resourceUrl;
}
开发者ID:mitre,项目名称:ptmatchadapter,代码行数:33,代码来源:RecordMatchRequestProcessor.java
示例7: isRecordMatchRequest
import org.hl7.fhir.instance.model.Resource; //导入依赖的package包/类
/**
*
* @param resource
* @return true when the given resource is a MessageHeader with the event-code
* that corresponds to a record-match request.
*/
public boolean isRecordMatchRequest(Resource resource) {
boolean isRecordMatch = false;
final ResourceType resType = resource.getResourceType();
if (resType == ResourceType.Bundle) {
final Bundle bundle = (Bundle) resource;
LOG.debug("bundle id: {}, type: {} ", bundle.getId(), bundle.getType());
if (BundleType.MESSAGE.equals(bundle.getType())) {
try {
final MessageHeader msgHdr = (MessageHeader) bundle.getEntry().get(0).getResource();
// Verify this message is not a response
if (msgHdr.getResponse().isEmpty()) {
final Coding evtCoding = msgHdr.getEvent();
/// if event code and name space match expected values
if (recordMatchEventCode.equals(evtCoding.getCode())
&& recordMatchEventSpace.equals(evtCoding.getSystem())) {
isRecordMatch = true;
LOG.debug("PASS Record-Match Request");
} else {
LOG.info("Unsupported Msg Type: event: {}, space: {}", evtCoding.getCode(), evtCoding.getSystem());
}
} else {
LOG.trace("Msg Hdr Response is not empty {}", msgHdr.getResponse());
LOG.trace("Msg Hdr Response identifier: {}", msgHdr.getResponse().getIdentifier());
}
} catch (Exception e) {
LOG.error(String.format("Unexpected resource type: %s, bundle id: %s",
bundle.getEntry().get(0).getResource().getResourceType(), bundle.getId()));
return false;
}
}
}
return isRecordMatch;
}
开发者ID:mitre,项目名称:ptmatchadapter,代码行数:42,代码来源:RecordMatchRequestPassFilter.java
示例8: build
import org.hl7.fhir.instance.model.Resource; //导入依赖的package包/类
/**
* Construct a record-match results message using data provided to this builder.
*
* @return
* @throws IOException
*/
public Bundle build() throws IOException {
// check parameters are valid; exception will be thrown, if invalid found
checkParameters();
final Bundle resultMsg = new Bundle();
ObjectId id = new ObjectId();
resultMsg.setId(id.toHexString());
resultMsg.setType(BundleType.MESSAGE);
// Add the Message Header to the response
final BundleEntryComponent msgHdrEntry = new BundleEntryComponent();
msgHdrEntry.setFullUrl("urn:uuid:" + UUID.randomUUID().toString());
final MessageHeader msgHdr = buildMessageHeader(requestMsg);
msgHdrEntry.setResource(msgHdr);
resultMsg.addEntry(msgHdrEntry);
// Add an Operation Outcome Entry
final BundleEntryComponent opOutcomeEntry = new BundleEntryComponent();
opOutcomeEntry.setFullUrl("urn:uuid:" + UUID.randomUUID().toString());
final OperationOutcome opOutcome = buildOperationOutcome();
opOutcomeEntry.setResource(opOutcome);
resultMsg.addEntry(opOutcomeEntry);
// TODO Add the Request Parameters
final List<BundleEntryComponent> bundleEntries = requestMsg.getEntry();
for (BundleEntryComponent entry : bundleEntries) {
Resource resource = entry.getResource();
if (ResourceType.Parameters.equals(resource.getResourceType())) {
// Add the Parameter entry to the response
resultMsg.addEntry(entry);
}
}
return resultMsg;
}
开发者ID:mitre,项目名称:ptmatchadapter,代码行数:44,代码来源:BasicRecordMatchResultsBuilder.java
示例9: buildBundle
import org.hl7.fhir.instance.model.Resource; //导入依赖的package包/类
public static AtomFeed buildBundle(List<Patient> patientList, String fhirBase) {
DateAndTime now = new DateAndTime(new Date());
AtomFeed feed = new AtomFeed();
feed.setTitle("Patient matches");
feed.setId("urn:uuid:"+CDAUUID.generateUUIDString());
feed.setTotalResults(patientList.size());
feed.setUpdated(now);
feed.setAuthorName("PDS");
List<AtomEntry<? extends Resource>> list = feed.getEntryList();
for (Patient patient : patientList) {
String nhsNo = patient.getIdentifier().get(0).getValueSimple();
AtomEntry entry = new AtomEntry();
entry.setResource(patient);
entry.setTitle("PDS Patient match: " + nhsNo);
entry.setId(fhirBase + "Patient/" + nhsNo);
// FHIR requires an updated date for the resource - we don't get this back from PDS simple trace...
// TODO: Establish what we should use for the last updated date
entry.setUpdated(now);
// We also don't get an author back from a simple trace...
// TODO: Establish what we should use for the author
entry.setPublished(now);
entry.setAuthorName("PDS");
list.add(entry);
}
return feed;
}
开发者ID:nhs-ciao,项目名称:ciao-pds-fhir,代码行数:29,代码来源:PatientResultBundle.java
示例10: testEncodeNonContained
import org.hl7.fhir.instance.model.Resource; //导入依赖的package包/类
@Test
public void testEncodeNonContained() {
// Create an organization
Organization org = new Organization();
org.setId("Organization/65546");
org.getNameElement().setValue("Contained Test Organization");
// Create a patient
Patient patient = new Patient();
patient.setId("Patient/1333");
patient.addIdentifier().setSystem("urn:mrns").setValue("253345");
patient.getManagingOrganization().setResource(org);
// Create a list containing both resources. In a server method, you might just
// return this list, but here we will create a bundle to encode.
List<Resource> resources = new ArrayList<Resource>();
resources.add(org);
resources.add(patient);
// Create a bundle with both
Bundle b = new Bundle();
b.addEntry().setResource(org);
b.addEntry().setResource(patient);
// Encode the buntdle
String encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(b);
ourLog.info(encoded);
assertThat(encoded, not(containsString("<contained>")));
assertThat(encoded, containsString("<reference value=\"Organization/65546\"/>"));
encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
ourLog.info(encoded);
assertThat(encoded, not(containsString("<contained>")));
assertThat(encoded, containsString("<reference value=\"Organization/65546\"/>"));
}
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:38,代码来源:XmlParserTest.java
示例11: execute
import org.hl7.fhir.instance.model.Resource; //导入依赖的package包/类
private List<Base> execute(ExecutionContext context, Base item, ExpressionNode exp, boolean atEntry) {
List<Base> result = new ArrayList<Base>();
if (atEntry && Character.isUpperCase(exp.getName().charAt(0))) {// special case for start up
if (item instanceof Resource && ((Resource) item).getResourceType().toString().equals(exp.getName()))
result.add(item);
} else
getChildrenByName(item, exp.getName(), result);
return result;
}
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:10,代码来源:FHIRPathEngine.java
示例12: initializeBundleFromResourceList
import org.hl7.fhir.instance.model.Resource; //导入依赖的package包/类
@Override
public void initializeBundleFromResourceList(String theAuthor, List<? extends IBaseResource> theResources,
String theServerBase, String theCompleteUrl, int theTotalResults, BundleTypeEnum theBundleType) {
ensureBundle();
myBundle.setId(UUID.randomUUID().toString());
myBundle.getMeta().setLastUpdatedElement(InstantType.withCurrentTime());
myBundle.addLink().setRelation(Constants.LINK_FHIR_BASE).setUrl(theServerBase);
myBundle.addLink().setRelation(Constants.LINK_SELF).setUrl(theCompleteUrl);
myBundle.getTypeElement().setValueAsString(theBundleType.getCode());
if (theBundleType.equals(BundleTypeEnum.TRANSACTION)) {
for (IBaseResource nextBaseRes : theResources) {
IBaseResource next = (IBaseResource) nextBaseRes;
BundleEntryComponent nextEntry = myBundle.addEntry();
nextEntry.setResource((Resource) next);
if (next.getIdElement().isEmpty()) {
nextEntry.getRequest().setMethod(HTTPVerb.POST);
} else {
nextEntry.getRequest().setMethod(HTTPVerb.PUT);
if (next.getIdElement().isAbsolute()) {
nextEntry.getRequest().setUrl(next.getIdElement().getValue());
} else {
String resourceType = myContext.getResourceDefinition(next).getName();
nextEntry.getRequest().setUrl(new IdType(theServerBase, resourceType, next.getIdElement().getIdPart(),
next.getIdElement().getVersionIdPart()).getValue());
}
}
}
} else {
addResourcesForSearch(theResources);
}
myBundle.getTotalElement().setValue(theTotalResults);
}
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:39,代码来源:Dstu2Hl7OrgBundleFactory.java
示例13: testEncodeNonContained
import org.hl7.fhir.instance.model.Resource; //导入依赖的package包/类
@Test
public void testEncodeNonContained() {
// Create an organization
Organization org = new Organization();
org.setId("Organization/65546");
org.getNameElement().setValue("Contained Test Organization");
// Create a patient
Patient patient = new Patient();
patient.setId("Patient/1333");
patient.addIdentifier().setSystem("urn:mrns").setValue("253345");
patient.getManagingOrganization().setResource(org);
// Create a list containing both resources. In a server method, you might
// just
// return this list, but here we will create a bundle to encode.
List<Resource> resources = new ArrayList<Resource>();
resources.add(org);
resources.add(patient);
// Create a bundle with both
Bundle b = new Bundle();
b.addEntry().setResource(org);
b.addEntry().setResource(patient);
// Encode the buntdle
String encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(b);
ourLog.info(encoded);
assertThat(encoded, not(containsString("<contained>")));
assertThat(encoded, stringContainsInOrder("<Organization", "<id value=\"65546\"/>", "</Organization>"));
assertThat(encoded, containsString("<reference value=\"Organization/65546\"/>"));
assertThat(encoded, stringContainsInOrder("<Patient", "<id value=\"1333\"/>", "</Patient>"));
encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
ourLog.info(encoded);
assertThat(encoded, not(containsString("<contained>")));
assertThat(encoded, containsString("<reference value=\"Organization/65546\"/>"));
}
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:40,代码来源:XmlParserHl7OrgDstu2Test.java
示例14: compose
import org.hl7.fhir.instance.model.Resource; //导入依赖的package包/类
/**
* Compose a resource to a stream, possibly using pretty presentation for a human reader (used in the spec, for example, but not normally in production)
*/
@Override
public void compose(OutputStream stream, Resource resource, boolean pretty) throws Exception {
XMLWriter writer = new XMLWriter(stream, "UTF-8");
writer.setPretty(pretty);
writer.start();
compose(writer, resource, pretty);
writer.close();
}
开发者ID:cqframework,项目名称:ProfileGenerator,代码行数:12,代码来源:XmlComposerBase.java
示例15: parse
import org.hl7.fhir.instance.model.Resource; //导入依赖的package包/类
/**
* Parse content that is known to be a resource
*/
@Override
public Resource parse(InputStream input) throws Exception {
XmlPullParser xpp = loadXml(input);
if (xpp.getNamespace() == null)
throw new Exception("This does not appear to be a FHIR resource (no namespace '"+xpp.getNamespace()+"') (@ /) "+Integer.toString(xpp.getEventType()));
if (!xpp.getNamespace().equals(FHIR_NS))
throw new Exception("This does not appear to be a FHIR resource (wrong namespace '"+xpp.getNamespace()+"') (@ /)");
return parseResource(xpp);
}
开发者ID:cqframework,项目名称:ProfileGenerator,代码行数:14,代码来源:XmlParserBase.java
示例16: parseBinary
import org.hl7.fhir.instance.model.Resource; //导入依赖的package包/类
protected Resource parseBinary(XmlPullParser xpp) throws Exception {
Binary res = new Binary();
parseElementAttributes(xpp, res);
res.setContentType(xpp.getAttributeValue(null, "contentType"));
int eventType = next(xpp);
if (eventType == XmlPullParser.TEXT) {
res.setContent(Base64.decodeBase64(xpp.getText().getBytes()));
eventType = next(xpp);
}
if (eventType != XmlPullParser.END_TAG)
throw new Exception("Bad String Structure");
next(xpp);
return res;
}
开发者ID:cqframework,项目名称:ProfileGenerator,代码行数:15,代码来源:XmlParserBase.java
示例17: parse
import org.hl7.fhir.instance.model.Resource; //导入依赖的package包/类
/**
* Parse content that is known to be a resource
*/
@Override
public Resource parse(InputStream input) throws Exception {
JsonObject json = loadJson(input);
return parseResource(json);
}
开发者ID:cqframework,项目名称:ProfileGenerator,代码行数:10,代码来源:JsonParserBase.java
示例18: parseBinary
import org.hl7.fhir.instance.model.Resource; //导入依赖的package包/类
protected Resource parseBinary(JsonObject json) throws Exception {
Binary res = new Binary();
parseResourceProperties(json, res);
res.setContentType(json.get("contentType").getAsString());
res.setContent(Base64.decodeBase64(json.get("content").getAsString().getBytes()));
return res;
}
开发者ID:cqframework,项目名称:ProfileGenerator,代码行数:8,代码来源:JsonParserBase.java
示例19: parseEntry
import org.hl7.fhir.instance.model.Resource; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T extends Resource> AtomEntry<T> parseEntry(JsonObject json) throws Exception {
AtomEntry<T> res = new AtomEntry<T>();
if (json.has("title") && !json.get("title").isJsonNull())
res.setTitle(json.get("title").getAsString());
if (json.has("id") && !json.get("id").isJsonNull())
res.setId(json.get("id").getAsString());
if (json.has("updated") && !json.get("updated").isJsonNull())
res.setUpdated(new DateAndTime(json.get("updated").getAsString()));
if (json.has("published") && !json.get("published").isJsonNull())
res.setPublished(new DateAndTime(json.get("published").getAsString()));
if (json.has("link") && !json.get("link").isJsonNull()) {
JsonArray array = json.getAsJsonArray("link");
for (int i = 0; i < array.size(); i++) {
parseLink(res.getLinks(), array.get(i).getAsJsonObject());
}
}
if (json.has("author") && !json.get("author").isJsonNull()) {
JsonObject author = json.getAsJsonArray("author").get(0).getAsJsonObject();
if (author.has("name") && !author.get("name").isJsonNull())
res.setAuthorName(author.get("name").getAsString());
if (author.has("uri") && !author.get("uri").isJsonNull())
res.setAuthorUri(author.get("uri").getAsString());
}
if (json.has("category") && !json.get("category").isJsonNull()) {
for (JsonElement t : json.getAsJsonArray("category")) {
JsonObject cat = t.getAsJsonObject();
if (cat.has("term") && cat.has("scheme") && !cat.get("term").isJsonNull() && !cat.get("scheme").isJsonNull())
res.getTags().add(new AtomCategory(cat.get("scheme").getAsString(), cat.get("term").getAsString(), cat.has("label") ? cat.get("label").getAsString() : null));
}
}
if (json.has("summary") && !json.get("summary").isJsonNull())
res.setSummary(new XhtmlParser().parse(json.get("summary").getAsString(), "div").getChildNodes().get(0));
if (json.has("content") && !json.get("content").isJsonNull())
res.setResource((T)new JsonParser().parse(json.getAsJsonObject("content")));//TODO Architecture needs to be refactor to prevent this unsafe cast and better support generics
return res;
}
开发者ID:cqframework,项目名称:ProfileGenerator,代码行数:38,代码来源:JsonParserBase.java
示例20: compose
import org.hl7.fhir.instance.model.Resource; //导入依赖的package包/类
/**
* Compose a resource to a stream, possibly using pretty presentation for a human reader (used in the spec, for example, but not normally in production)
*/
@Override
public void compose(OutputStream stream, Resource resource, boolean pretty) throws Exception {
OutputStreamWriter osw = new OutputStreamWriter(stream, "UTF-8");
JsonWriter writer = new JsonWriter(osw);
writer.setIndent(pretty ? " ":"");
writer.beginObject();
compose(writer, resource);
writer.endObject();
osw.flush();
}
开发者ID:cqframework,项目名称:ProfileGenerator,代码行数:15,代码来源:JsonComposerBase.java
注:本文中的org.hl7.fhir.instance.model.Resource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论