-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from onaio/fix-gateway-plugin
Various Enhancements and Fixes
- Loading branch information
Showing
15 changed files
with
304 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
plugins/src/main/java/org/smartregister/fhir/gateway/plugins/BaseEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.smartregister.fhir.gateway.plugins; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import javax.servlet.http.HttpServlet; | ||
|
||
import org.hl7.fhir.r4.model.Bundle; | ||
import org.hl7.fhir.r4.model.Resource; | ||
|
||
public abstract class BaseEndpoint extends HttpServlet { | ||
public Bundle createBundle(List<Resource> resourceList) { | ||
Bundle responseBundle = new Bundle(); | ||
List<Bundle.BundleEntryComponent> bundleEntryComponentList = new ArrayList<>(); | ||
|
||
for (Resource resource : resourceList) { | ||
bundleEntryComponentList.add(new Bundle.BundleEntryComponent().setResource(resource)); | ||
} | ||
|
||
responseBundle.setEntry(bundleEntryComponentList); | ||
responseBundle.setTotal(bundleEntryComponentList.size()); | ||
return responseBundle; | ||
} | ||
|
||
public Bundle createEmptyBundle(String requestURL) { | ||
Bundle responseBundle = new Bundle(); | ||
responseBundle.setId(UUID.randomUUID().toString()); | ||
Bundle.BundleLinkComponent linkComponent = new Bundle.BundleLinkComponent(); | ||
linkComponent.setRelation(Bundle.LINK_SELF); | ||
linkComponent.setUrl(requestURL); | ||
responseBundle.setLink(Collections.singletonList(linkComponent)); | ||
responseBundle.setType(Bundle.BundleType.SEARCHSET); | ||
responseBundle.setTotal(0); | ||
return responseBundle; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 23 additions & 21 deletions
44
plugins/src/main/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.