@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 }