@Override public IPrimitiveType<Date> getLastUpdated(IBaseResource theResource) { return ResourceMetadataKeyEnum.UPDATED.get((IResource) theResource); }
protected static <T> List<T> extractMetadataListNotNull(IResource resource, ResourceMetadataKeyEnum<List<T>> key) { List<? extends T> securityLabels = key.get(resource); if (securityLabels == null) { securityLabels = Collections.emptyList(); } return new ArrayList<>(securityLabels); }
public static IPrimitiveType<Date> extractLastUpdatedFromResource(IBaseResource theResource) { IPrimitiveType<Date> lastUpdated = null; if (theResource instanceof IResource) { lastUpdated = ResourceMetadataKeyEnum.UPDATED.get((IResource) theResource); } else if (theResource instanceof IAnyResource) { lastUpdated = new InstantDt(theResource.getMeta().getLastUpdated()); } return lastUpdated; }
if (resource instanceof IResource) { IResource iResource = (IResource) resource; InstantDt existing = ResourceMetadataKeyEnum.UPDATED.get(iResource); if (existing == null || existing.isEmpty()) { InstantDt lmValue = new InstantDt(headerDateValue);
@SuppressWarnings("unused") public void getResourceTags() { // START SNIPPET: getResourceTags IGenericClient client = FhirContext.forDstu2().newRestfulGenericClient("http://fhir.healthintersections.com.au/open"); Patient p = client.read(Patient.class, "1"); // Retrieve the list of tags from the resource metadata TagList tags = ResourceMetadataKeyEnum.TAG_LIST.get(p); // tags may be null if no tags were read in if (tags == null) { System.out.println("No tags!"); } else { // You may iterate over all the tags for (Tag next : tags) { System.out.println(next.getScheme() + " - " + next.getTerm()); } // You may also get a list of tags matching a given scheme List<Tag> someTags = tags.getTagsWithScheme("http://hl7.org/fhir/tag"); // Or a specific tag (by scheme and term) Tag specificTag = tags.getTag("http://hl7.org/fhir/tag", "http://foo"); } // END SNIPPET: getResourceTags }
protected TagList getMetaTagsForEncoding(IResource theIResource) { TagList tags = ResourceMetadataKeyEnum.TAG_LIST.get(theIResource); if (shouldAddSubsettedTag()) { tags = new TagList(tags); tags.add(new Tag(getSubsettedCodeSystem(), Constants.TAG_SUBSETTED_CODE, subsetDescription())); } return tags; }
@Override public List<IBaseResource> getResources(int theFromIndex, int theToIndex) { List<IBaseResource> retVal = resources.getResources(theFromIndex, theToIndex); int index = theFromIndex; for (IBaseResource nextResource : retVal) { if (nextResource.getIdElement() == null || isBlank(nextResource.getIdElement().getIdPart())) { throw new InternalErrorException("Server provided resource at index " + index + " with no ID set (using IResource#setId(IdDt))"); } if (isBlank(nextResource.getIdElement().getVersionIdPart()) && nextResource instanceof IResource) { //TODO: Use of a deprecated method should be resolved. IdDt versionId = (IdDt) ResourceMetadataKeyEnum.VERSION_ID.get((IResource) nextResource); if (versionId == null || versionId.isEmpty()) { throw new InternalErrorException("Server provided resource at index " + index + " with no Version ID set (using IResource#setId(IdDt))"); } } index++; } return retVal; }
TagList tagList = ResourceMetadataKeyEnum.TAG_LIST.get(res); if (tagList != null) { tag = tagList.getTag(Constants.TAG_SUBSETTED_SYSTEM_DSTU3, Constants.TAG_SUBSETTED_CODE); totalMetaCount += tagList.size(); List<IdDt> profileList = ResourceMetadataKeyEnum.PROFILES.get(res); if (profileList != null) { totalMetaCount += profileList.size();
private void extractTagsHapi(IResource theResource, ResourceTable theEntity, Set<ResourceTag> allDefs) { TagList tagList = ResourceMetadataKeyEnum.TAG_LIST.get(theResource); if (tagList != null) { for (Tag next : tagList) { List<BaseCodingDt> securityLabels = ResourceMetadataKeyEnum.SECURITY_LABELS.get(theResource); if (securityLabels != null) { for (BaseCodingDt next : securityLabels) { List<IdDt> profiles = ResourceMetadataKeyEnum.PROFILES.get(theResource); if (profiles != null) { for (IIdType next : profiles) {
private static void handleTransactionCreateOrUpdateOutcome(Map<IdDt, IdDt> idSubstitutions, Map<IdDt, DaoMethodOutcome> idToPersistedOutcome, IdDt nextResourceId, DaoMethodOutcome outcome, Entry newEntry, String theResourceType, IResource theRes) { IdDt newId = (IdDt) outcome.getId().toUnqualifiedVersionless(); IdDt resourceId = isPlaceholder(nextResourceId) ? nextResourceId : nextResourceId.toUnqualifiedVersionless(); if (newId.equals(resourceId) == false) { idSubstitutions.put(resourceId, newId); if (isPlaceholder(resourceId)) { /* * The correct way for substitution IDs to be is to be with no resource type, but we'll accept the qualified kind too just to be lenient. */ idSubstitutions.put(new IdDt(theResourceType + '/' + resourceId.getValue()), newId); } } idToPersistedOutcome.put(newId, outcome); if (outcome.getCreated().booleanValue()) { newEntry.getResponse().setStatus(toStatusString(Constants.STATUS_HTTP_201_CREATED)); } else { newEntry.getResponse().setStatus(toStatusString(Constants.STATUS_HTTP_200_OK)); } newEntry.getResponse().setLastModified(ResourceMetadataKeyEnum.UPDATED.get(theRes)); }
Date lastModified = null; if (responseResource instanceof IResource) { InstantDt lastModifiedDt = ResourceMetadataKeyEnum.UPDATED.get((IResource) responseResource); if (lastModifiedDt != null) { lastModified = lastModifiedDt.getValue();
String versionIdPart = resourceId.getVersionIdPart(); if (isBlank(versionIdPart)) { versionIdPart = ResourceMetadataKeyEnum.VERSION.get(resource);
@Override public void addRootPropertiesToBundle(String theId, String theServerBase, String theLinkSelf, String theLinkPrev, String theLinkNext, Integer theTotalResults, BundleTypeEnum theBundleType, IPrimitiveType<Date> theLastUpdated) { myBase = theServerBase; if (myBundle.getIdElement().isEmpty()) { myBundle.setId(theId); } if (myBundle.getId().isEmpty()) { myBundle.setId(UUID.randomUUID().toString()); } if (ResourceMetadataKeyEnum.UPDATED.get(myBundle) == null) { ResourceMetadataKeyEnum.UPDATED.put(myBundle, (InstantDt) theLastUpdated); } if (!hasLink(Constants.LINK_SELF, myBundle) && isNotBlank(theLinkSelf)) { myBundle.addLink().setRelation(Constants.LINK_SELF).setUrl(theLinkSelf); } if (!hasLink(Constants.LINK_NEXT, myBundle) && isNotBlank(theLinkNext)) { myBundle.addLink().setRelation(Constants.LINK_NEXT).setUrl(theLinkNext); } if (!hasLink(Constants.LINK_PREVIOUS, myBundle) && isNotBlank(theLinkPrev)) { myBundle.addLink().setRelation(Constants.LINK_PREVIOUS).setUrl(theLinkPrev); } if (myBundle.getTypeElement().isEmpty() && theBundleType != null) { myBundle.getTypeElement().setValueAsString(theBundleType.getCode()); } if (myBundle.getTotalElement().isEmpty() && theTotalResults != null) { myBundle.getTotalElement().setValue(theTotalResults); } }
@Override public List<? extends IBaseCoding> getTag() { ArrayList<IBaseCoding> retVal = new ArrayList<IBaseCoding>(); for (Tag next : ResourceMetadataKeyEnum.TAG_LIST.get(BaseResource.this)) { retVal.add(next); } return Collections.unmodifiableList(retVal); }
@Override public Date getLastUpdated() { InstantDt lu = ResourceMetadataKeyEnum.UPDATED.get(BaseResource.this); if (lu != null) { return lu.getValue(); } return null; }
String versionIdPart = resourceId.getVersionIdPart(); if (isBlank(versionIdPart)) { versionIdPart = ResourceMetadataKeyEnum.VERSION.get(resource);
@Override public IBaseCoding addSecurity() { List<BaseCodingDt> tagList = ResourceMetadataKeyEnum.SECURITY_LABELS.get(BaseResource.this); if (tagList == null) { tagList = new ArrayList<BaseCodingDt>(); ResourceMetadataKeyEnum.SECURITY_LABELS.put(BaseResource.this, tagList); } CodingDt tag = new CodingDt(); tagList.add(tag); return asBaseCoding(tag); }
@Override public IBaseCoding getSecurity(String theSystem, String theCode) { for (BaseCodingDt next : ResourceMetadataKeyEnum.SECURITY_LABELS.get(BaseResource.this)) { if (theSystem.equals(next.getSystemElement().getValue()) && theCode.equals(next.getCodeElement().getValue())) { return asBaseCoding(next); } } return null; }
public static IPrimitiveType<Date> extractLastUpdatedFromResource(IBaseResource theResource) { IPrimitiveType<Date> lastUpdated = null; if (theResource instanceof IResource) { lastUpdated = ResourceMetadataKeyEnum.UPDATED.get((IResource) theResource); } else if (theResource instanceof IAnyResource) { lastUpdated = new InstantDt(theResource.getMeta().getLastUpdated()); } return lastUpdated; }
protected TagList getMetaTagsForEncoding(IResource theIResource, EncodeContext theEncodeContext) { TagList tags = ResourceMetadataKeyEnum.TAG_LIST.get(theIResource); if (shouldAddSubsettedTag(theEncodeContext)) { tags = new TagList(tags); tags.add(new Tag(getSubsettedCodeSystem(), Constants.TAG_SUBSETTED_CODE, subsetDescription())); } return tags; }