{"action":"created","issue":{"url":"https://api.github.com/repos/jamesagnew/hapi-fhir/issues/242","labels_url":"https://api.github.com/repos/jamesagnew/hapi-fhir/issues/242/labels{/name}","comments_url":"https://api.github.com/repos/jamesagnew/hapi-fhir/issues/242/comments","events_url":"https://api.github.com/repos/jamesagnew/hapi-fhir/issues/242/events","html_url":"https://github.com/jamesagnew/hapi-fhir/issues/242","id":111225885,"number":242,"title":"Can't use read and compartment search in same provider","user":{"login":"am202","id":11576978,"avatar_url":"https://avatars.githubusercontent.com/u/11576978?v=3","gravatar_id":"","url":"https://api.github.com/users/am202","html_url":"https://github.com/am202","followers_url":"https://api.github.com/users/am202/followers","following_url":"https://api.github.com/users/am202/following{/other_user}","gists_url":"https://api.github.com/users/am202/gists{/gist_id}","starred_url":"https://api.github.com/users/am202/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/am202/subscriptions","organizations_url":"https://api.github.com/users/am202/orgs","repos_url":"https://api.github.com/users/am202/repos","events_url":"https://api.github.com/users/am202/events{/privacy}","received_events_url":"https://api.github.com/users/am202/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-13T17:09:03Z","updated_at":"2015-10-21T15:59:48Z","closed_at":null,"body":"I'm trying to create a resource provider with a read and with compartment searches, but I can't get it to work.  I can get either to work by itself, but the server seems to pick the wrong method when I try to support both.  This is my provider:\r\n```\r\npublic class TempPatientResourceProvider implements IResourceProvider {\r\n    @Override\r\n    public Class<Patient> getResourceType() {\r\n        return Patient.class;\r\n    }\r\n    \r\n    @Read()\r\n    public Patient getResourceById(final @IdParam IdDt id) {\r\n        System.out.println(\"Patient read\");\r\n        Patient patient = new Patient();\r\n        patient.setId(id);\r\n        return patient;\r\n    }\r\n    \r\n    @Search(compartmentName=\"Encounter\")\r\n    public List<Encounter> searchEncounter(final @IdParam IdDt id) {\r\n        System.out.println(\"Encounter compartment search\");\r\n        List<Encounter> encounters = new ArrayList<Encounter>();\r\n        Encounter encounter = new Encounter();\r\n        encounter.setId(\"1\");\r\n        encounter.setPatient(new ResourceReferenceDt(id));\r\n        encounters.add(encounter);\r\n        return encounters;\r\n    }\r\n}\r\n```\r\n\r\nThis is my client code:\r\n```\r\n        FhirContext ctx = FhirContext.forDstu2();\r\n        IGenericClient client = ctx.newRestfulGenericClient(\"http://localhost:8081/hapi-fhir/fhir\");\r\n        Bundle bundle = client\r\n            .search()\r\n            .forResource(Patient.class)\r\n            .withIdAndCompartment(\"1\", \"Encounter\")\r\n            .execute();\r\n```\r\n\r\nIt calls this URL like I expected:\r\n```\r\n.../fhir/Patient/1/Encounter\r\n```\r\n\r\nBut the server output shows that it entered the read method instead of the compartment search:\r\n```\r\nPatient read\r\n```\r\n\r\nAnd the client gets this error:\r\n```\r\nExpecting outer element called 'Bundle', found: Patient\r\n```\r\n\r\nAm I doing something wrong, or is there a bug causing the server to pick the wrong method to handle the request?"},"comment":{"url":"https://api.github.com/repos/jamesagnew/hapi-fhir/issues/comments/149942790","html_url":"https://github.com/jamesagnew/hapi-fhir/issues/242#issuecomment-149942790","issue_url":"https://api.github.com/repos/jamesagnew/hapi-fhir/issues/242","id":149942790,"user":{"login":"jamesagnew","id":3465117,"avatar_url":"https://avatars.githubusercontent.com/u/3465117?v=3","gravatar_id":"","url":"https://api.github.com/users/jamesagnew","html_url":"https://github.com/jamesagnew","followers_url":"https://api.github.com/users/jamesagnew/followers","following_url":"https://api.github.com/users/jamesagnew/following{/other_user}","gists_url":"https://api.github.com/users/jamesagnew/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesagnew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesagnew/subscriptions","organizations_url":"https://api.github.com/users/jamesagnew/orgs","repos_url":"https://api.github.com/users/jamesagnew/repos","events_url":"https://api.github.com/users/jamesagnew/events{/privacy}","received_events_url":"https://api.github.com/users/jamesagnew/received_events","type":"User","site_admin":false},"created_at":"2015-10-21T15:59:48Z","updated_at":"2015-10-21T15:59:48Z","body":"Hi @am202 , thanks for reporting, I was able to reproduce so this is fixed now. The fix will appear in the next snapshot build."}}