FhirSystemDaoDstu2 extends BaseFhirSystemDao<Bundle> { @Override public MetaDt metaGetOperation() { String sql = "SELECT d FROM TagDefinition d WHERE d.myId IN (SELECT DISTINCT t.myTagId FROM ResourceTag t)"; TypedQuery<TagDefinition> q = myEntityManager.createQuery(sql, TagDefinition.class); List<TagDefinition> tagDefinitions = q.getResultList(); MetaDt retVal = super.toMetaDt(tagDefinitions); return retVal; }  @SuppressWarnings("unchecked") @Transactional(propagation = Propagation.REQUIRED) @Override Bundle transaction(Bundle theResources); @Override MetaDt metaGetOperation();  }
@Test public void testSystemMetaOperation() { deleteEverything(); MetaDt meta = ourSystemDao.metaGetOperation(); List<CodingDt> published = meta.getTag(); assertEquals(0, published.size()); String methodName = "testSystemMetaOperation"; IdDt id1; { Patient patient = new Patient(); patient.addIdentifier().setSystem("urn:system").setValue(methodName); patient.addName().addFamily("Tester").addGiven("Joe"); TagList tagList = new TagList(); tagList.addTag(null, "Dog", "Puppies"); ResourceMetadataKeyEnum.TAG_LIST.put(patient, tagList); List<BaseCodingDt> securityLabels = new ArrayList<BaseCodingDt>(); securityLabels.add(new CodingDt().setSystem("seclabel:sys:1").setCode("seclabel:code:1").setDisplay("seclabel:dis:1")); ResourceMetadataKeyEnum.SECURITY_LABELS.put(patient, securityLabels); ArrayList<IdDt> profiles = new ArrayList<IdDt>(); profiles.add(new IdDt("http: ResourceMetadataKeyEnum.PROFILES.put(patient, profiles); id1 = ourPatientDao.create(patient).getId(); } { Patient patient = new Patient(); patient.addIdentifier().setSystem("urn:system").setValue(methodName); patient.addName().addFamily("Tester").addGiven("Joe"); TagList tagList = new TagList(); tagList.addTag("http: ResourceMetadataKeyEnum.TAG_LIST.put(patient, tagList); List<BaseCodingDt> securityLabels = new ArrayList<BaseCodingDt>(); securityLabels.add(new CodingDt().setSystem("seclabel:sys:2").setCode("seclabel:code:2").setDisplay("seclabel:dis:2")); ResourceMetadataKeyEnum.SECURITY_LABELS.put(patient, securityLabels); ArrayList<IdDt> profiles = new ArrayList<IdDt>(); profiles.add(new IdDt("http: ResourceMetadataKeyEnum.PROFILES.put(patient, profiles); ourPatientDao.create(patient); } meta = ourSystemDao.metaGetOperation(); published = meta.getTag(); assertEquals(2, published.size()); assertEquals(null, published.get(0).getSystem()); assertEquals("Dog", published.get(0).getCode()); assertEquals("Puppies", published.get(0).getDisplay()); assertEquals("http: assertEquals("Cat", published.get(1).getCode()); assertEquals("Kittens", published.get(1).getDisplay()); List<CodingDt> secLabels = meta.getSecurity(); assertEquals(2, secLabels.size()); assertEquals("seclabel:sys:1", secLabels.get(0).getSystemElement().getValue()); assertEquals("seclabel:code:1", secLabels.get(0).getCodeElement().getValue()); assertEquals("seclabel:dis:1", secLabels.get(0).getDisplayElement().getValue()); assertEquals("seclabel:sys:2", secLabels.get(1).getSystemElement().getValue()); assertEquals("seclabel:code:2", secLabels.get(1).getCodeElement().getValue()); assertEquals("seclabel:dis:2", secLabels.get(1).getDisplayElement().getValue()); List<UriDt> profiles = meta.getProfile(); assertEquals(2, profiles.size()); assertEquals("http: assertEquals("http: ourPatientDao.removeTag(id1, TagTypeEnum.TAG, null, "Dog"); ourPatientDao.removeTag(id1, TagTypeEnum.SECURITY_LABEL, "seclabel:sys:1", "seclabel:code:1"); ourPatientDao.removeTag(id1, TagTypeEnum.PROFILE, BaseFhirDao.NS_JPA_PROFILE, "http: meta = ourSystemDao.metaGetOperation(); published = meta.getTag(); assertEquals(1, published.size()); assertEquals("http: assertEquals("Cat", published.get(0).getCode()); assertEquals("Kittens", published.get(0).getDisplay()); secLabels = meta.getSecurity(); assertEquals(1, secLabels.size()); assertEquals("seclabel:sys:2", secLabels.get(0).getSystemElement().getValue()); assertEquals("seclabel:code:2", secLabels.get(0).getCodeElement().getValue()); assertEquals("seclabel:dis:2", secLabels.get(0).getDisplayElement().getValue()); profiles = meta.getProfile(); assertEquals(1, profiles.size()); assertEquals("http: }