tags.addTag(Tag.HL7_ORG_FHIR_TAG, "http://foo/tag1.html", "Some tag"); tags.addTag(Tag.HL7_ORG_FHIR_TAG, "http://foo/tag2.html", "Another tag"); ResourceMetadataKeyEnum.TAG_LIST.put(patient, tags); ResourceMetadataKeyEnum.LINK_ALTERNATE.put(patient, linkAlternate); String linkSearch = "Patient?name=smith&name=john"; ResourceMetadataKeyEnum.LINK_SEARCH.put(patient, linkSearch); ResourceMetadataKeyEnum.PUBLISHED.put(patient, pubDate); InstantDt updatedDate = new InstantDt("2014-07-12T11:22:27Z"); ResourceMetadataKeyEnum.UPDATED.put(patient, updatedDate); ResourceMetadataKeyEnum.TITLE.put(patient, title);
ResourceMetadataKeyEnum.VERSION.put((IResource) theResource, versionIdPart); } else { BaseRuntimeChildDefinition metaChild = myFhirContext.getResourceDefinition(myResourceType).getChildByName("meta");
@Search public List<Patient> getAllPatients() { ArrayList<Patient> retVal = new ArrayList<Patient>(); // Create a patient to return Patient patient = new Patient(); patient.setId("Patient/123"); patient.addName().addFamily("Smith").addGiven("John"); // Create a tag list and add it to the resource TagList tags = new TagList(); ResourceMetadataKeyEnum.TAG_LIST.put(patient, tags); // Add some tags to the list tags.addTag(Tag.HL7_ORG_FHIR_TAG, "http://foo/tag1.html", "Some tag"); tags.addTag(Tag.HL7_ORG_FHIR_TAG, "http://foo/tag2.html", "Another tag"); return retVal; } // END SNIPPET: serverMethod
ResourceMetadataKeyEnum.VERSION.put(res, Long.toString(theEntity.getVersion())); ResourceMetadataKeyEnum.PUBLISHED.put(res, theEntity.getPublished()); ResourceMetadataKeyEnum.UPDATED.put(res, theEntity.getUpdated()); IDao.RESOURCE_PID.put(res, theEntity.getId()); ResourceMetadataKeyEnum.TAG_LIST.put(res, tagList); ResourceMetadataKeyEnum.SECURITY_LABELS.put(res, toBaseCodingList(securityLabels)); ResourceMetadataKeyEnum.PROFILES.put(res, profiles);
@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); } }
protected void updateResourceMetadata(IBaseResourceEntity theEntity, IBaseResource theResource) { IIdType id = theEntity.getIdDt(); if (getContext().getVersion().getVersion().isRi()) { id = getContext().getVersion().newIdType().setValue(id.getValue()); } if (id.hasResourceType() == false) { id = id.withResourceType(theEntity.getResourceType()); } theResource.setId(id); if (theResource instanceof IResource) { ResourceMetadataKeyEnum.VERSION.put((IResource) theResource, id.getVersionIdPart()); ResourceMetadataKeyEnum.UPDATED.put((IResource) theResource, theEntity.getUpdated()); } else { IBaseMetaType meta = theResource.getMeta(); meta.setVersionId(id.getVersionIdPart()); meta.setLastUpdated(theEntity.getUpdatedDate()); } }
@Override public IBaseMetaType setLastUpdated(Date theHeaderDateValue) { ResourceMetadataKeyEnum.UPDATED.put(BaseResource.this, new InstantDt(theHeaderDateValue)); return this; }
@Override public IBaseMetaType addProfile(String theProfile) { ArrayList<IdDt> newTagList = new ArrayList<IdDt>(); List<IdDt> existingTagList = ResourceMetadataKeyEnum.PROFILES.get(BaseResource.this); if (existingTagList != null) { newTagList.addAll(existingTagList); } ResourceMetadataKeyEnum.PROFILES.put(BaseResource.this, newTagList); IdDt tag = new IdDt(theProfile); newTagList.add(tag); return this; }
@Override public IBaseMetaType addProfile(String theProfile) { ArrayList<IdDt> newTagList = new ArrayList<IdDt>(); List<IdDt> existingTagList = ResourceMetadataKeyEnum.PROFILES.get(BaseResource.this); if (existingTagList != null) { newTagList.addAll(existingTagList); } ResourceMetadataKeyEnum.PROFILES.put(BaseResource.this, newTagList); IdDt tag = new IdDt(theProfile); newTagList.add(tag); return this; }
@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 tag; }
ResourceMetadataKeyEnum.PUBLISHED.put(myBundle, InstantDt.withCurrentTime());
@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 IBaseMetaType setLastUpdated(Date theHeaderDateValue) { if (theHeaderDateValue == null) { getResourceMetadata().remove(ResourceMetadataKeyEnum.UPDATED); } else { ResourceMetadataKeyEnum.UPDATED.put(BaseResource.this, new InstantDt(theHeaderDateValue)); } return this; }
@Override public IBaseCoding addTag() { TagList tagList = ResourceMetadataKeyEnum.TAG_LIST.get(BaseResource.this); if (tagList == null) { tagList = new TagList(); ResourceMetadataKeyEnum.TAG_LIST.put(BaseResource.this, tagList); } Tag tag = new Tag(); tagList.add(tag); return tag; }
@Override public IBaseCoding addTag() { TagList tagList = ResourceMetadataKeyEnum.TAG_LIST.get(BaseResource.this); if (tagList == null) { tagList = new TagList(); ResourceMetadataKeyEnum.TAG_LIST.put(BaseResource.this, tagList); } Tag tag = new Tag(); tagList.add(tag); return tag; }
ResourceMetadataKeyEnum.VERSION.put((IResource) theResource, versionIdPart); } else { BaseRuntimeChildDefinition metaChild = myFhirContext.getResourceDefinition(myResourceType).getChildByName("meta");
private void addProfileIfNeeded(IRestfulServer<?> theServer, String theServerBase, IBaseResource nextRes) { RuntimeResourceDefinition def = theServer.getFhirContext().getResourceDefinition(nextRes); if (theServer.getAddProfileTag() == AddProfileTagEnum.ALWAYS || !def.isStandardType()) { TagList tl = ResourceMetadataKeyEnum.TAG_LIST.get((IResource) nextRes); if (tl == null) { tl = new TagList(); ResourceMetadataKeyEnum.TAG_LIST.put((IResource) nextRes, tl); } RuntimeResourceDefinition nextDef = myContext.getResourceDefinition(nextRes); String profile = nextDef.getResourceProfile(theServerBase); if (isNotBlank(profile)) { tl.add(new Tag(Tag.HL7_ORG_PROFILE_TAG, profile, null)); } } }
protected void updateResourceMetadata(IBaseResourceEntity theEntity, IBaseResource theResource) { IIdType id = theEntity.getIdDt(); if (getContext().getVersion().getVersion().isRi()) { id = getContext().getVersion().newIdType().setValue(id.getValue()); } if (id.hasResourceType() == false) { id = id.withResourceType(theEntity.getResourceType()); } theResource.setId(id); if (theResource instanceof IResource) { ResourceMetadataKeyEnum.VERSION.put((IResource) theResource, id.getVersionIdPart()); ResourceMetadataKeyEnum.UPDATED.put((IResource) theResource, theEntity.getUpdated()); } else { IBaseMetaType meta = theResource.getMeta(); meta.setVersionId(id.getVersionIdPart()); meta.setLastUpdated(theEntity.getUpdatedDate()); } }
@Override public void addRootPropertiesToBundle(String theId, String theServerBase, String theLinkSelf, String theLinkPrev, String theLinkNext, Integer theTotalResults, BundleTypeEnum theBundleType, IPrimitiveType<Date> theLastUpdated) { ensureBundle(); 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); } }
ResourceMetadataKeyEnum.PUBLISHED.put(myBundle, InstantDt.withCurrentTime());