mastering bridging

This commit is contained in:
gigihshs
2025-11-24 09:13:08 +07:00
commit e1b99f8f38
115 changed files with 12298 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
package handler
import (
"net/http"
"satusehat-rssa/internal/integration"
"satusehat-rssa/internal/model"
"satusehat-rssa/pkg/common"
"github.com/gin-gonic/gin"
)
type OrganizationHandler struct {
Organization integration.OrganizationInterface
}
func NewOrganizationHandler(organization integration.OrganizationInterface) *OrganizationHandler {
return &OrganizationHandler{Organization: organization}
}
func (o OrganizationHandler) CreateOrganization(c *gin.Context) {
var bodyParam model.OrganizationRequest
if err := c.ShouldBindJSON(&bodyParam); err != nil {
c.JSON(http.StatusBadRequest, err)
return
}
bodyParam.Identifier = append(bodyParam.Identifier, common.GetIdentifier("organization"))
res, err := o.Organization.CreateOrganization(bodyParam)
if err != nil {
if res != nil {
c.JSON(http.StatusInternalServerError, res)
return
}
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, res)
}
func (o OrganizationHandler) GetOrganizationPatient(c *gin.Context) {
id := c.Query("subject")
if id == "" {
c.JSON(http.StatusBadRequest, "Patient ID is required")
return
}
res, err := o.Organization.GetOrganizationPatient(id)
if err != nil {
c.JSON(http.StatusInternalServerError, err)
return
}
c.JSON(http.StatusOK, res)
}