mastering bridging
This commit is contained in:
58
internal/handler/allergancytoleran_handler.go
Normal file
58
internal/handler/allergancytoleran_handler.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type AllergancyToleranHandler struct {
|
||||
AllergancyToleran integration.AllergancyToleranInterface
|
||||
}
|
||||
|
||||
func NewAllergancyToleranHandler(AllergancyToleran integration.AllergancyToleranInterface) *AllergancyToleranHandler {
|
||||
return &AllergancyToleranHandler{AllergancyToleran: AllergancyToleran}
|
||||
}
|
||||
|
||||
func (a AllergancyToleranHandler) CreateAllergancyToleran(c *gin.Context) {
|
||||
var bodyParam model.AllergancyToleranRequest
|
||||
if err := c.ShouldBindJSON(&bodyParam); err != nil {
|
||||
c.JSON(http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
res, err := a.AllergancyToleran.CreateAllergancyToleran(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 (a AllergancyToleranHandler) UpdateAllergancyToleran(c *gin.Context) {
|
||||
var bodyParam model.AllergancyToleranRequest
|
||||
if err := c.ShouldBindJSON(&bodyParam); err != nil {
|
||||
c.JSON(http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
bodyParam.Id = c.Param("id")
|
||||
res, err := a.AllergancyToleran.UpdateAllergancyToleran(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)
|
||||
}
|
||||
58
internal/handler/careplan_handler.go
Normal file
58
internal/handler/careplan_handler.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type CarePlanHandler struct {
|
||||
CarePlan integration.CarePlanInterface
|
||||
}
|
||||
|
||||
func NewCarePlanHandler(CarePlan integration.CarePlanInterface) *CarePlanHandler {
|
||||
return &CarePlanHandler{CarePlan: CarePlan}
|
||||
}
|
||||
|
||||
func (h CarePlanHandler) CreateCarePlan(c *gin.Context) {
|
||||
var req model.CarePlanRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
res, err := h.CarePlan.CreateCarePlan(req)
|
||||
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 (h CarePlanHandler) UpdateCarePlan(c *gin.Context) {
|
||||
var req model.CarePlanRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
req.Id = c.Param("id")
|
||||
res, err := h.CarePlan.CreateCarePlan(req)
|
||||
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)
|
||||
}
|
||||
62
internal/handler/clinicalImpression_handler.go
Normal file
62
internal/handler/clinicalImpression_handler.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
"satusehat-rssa/pkg/common"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ClinicalImpressionHandler struct {
|
||||
// Define fields for ClinicalImpressionHandler
|
||||
ClinicalImpression integration.ClinicalImppressionInterface
|
||||
}
|
||||
|
||||
func NewClinicalImpressionHandler(ClinicalImpression integration.ClinicalImppressionInterface) *ClinicalImpressionHandler {
|
||||
return &ClinicalImpressionHandler{ClinicalImpression: ClinicalImpression}
|
||||
}
|
||||
|
||||
func (c *ClinicalImpressionHandler) CreateClinicalImpression(ctx *gin.Context) {
|
||||
var bodyParam model.ClinicalImpressionRequest
|
||||
if err := ctx.ShouldBindJSON(&bodyParam); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
bodyParam.Identifier = append(bodyParam.Identifier, common.GetIdentifier("clinicalImpression"))
|
||||
|
||||
res, err := c.ClinicalImpression.CreateClinicalImpression(bodyParam)
|
||||
if err != nil {
|
||||
if res != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, res)
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK, res)
|
||||
}
|
||||
|
||||
func (c *ClinicalImpressionHandler) UpdateClinicalImpression(ctx *gin.Context) {
|
||||
var bodyParam model.ClinicalImpressionRequest
|
||||
if err := ctx.ShouldBindJSON(&bodyParam); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
bodyParam.Id = ctx.Param("id")
|
||||
bodyParam.Identifier = append(bodyParam.Identifier, common.GetIdentifier("clinicalImpression"))
|
||||
|
||||
res, err := c.ClinicalImpression.UpdateClinicalImpression(bodyParam)
|
||||
if err != nil {
|
||||
if res != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, res)
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK, res)
|
||||
}
|
||||
62
internal/handler/composition_handler.go
Normal file
62
internal/handler/composition_handler.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
"satusehat-rssa/pkg/common"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type CompositionHandler struct {
|
||||
Composition integration.CompositionInterface
|
||||
}
|
||||
|
||||
func NewCompositionHandler(composition integration.CompositionInterface) *CompositionHandler {
|
||||
return &CompositionHandler{
|
||||
Composition: composition,
|
||||
}
|
||||
}
|
||||
|
||||
func (ch *CompositionHandler) CreateComposition(c *gin.Context) {
|
||||
var req model.CompositionRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
req.Identifier = common.GetIdentifier("composition")
|
||||
resp, err := ch.Composition.CreateComposition(req)
|
||||
if err != nil {
|
||||
if resp != nil {
|
||||
c.JSON(http.StatusInternalServerError, resp)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func (ch *CompositionHandler) UpdateComposition(c *gin.Context) {
|
||||
var req model.CompositionRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
req.Identifier = common.GetIdentifier("composition")
|
||||
req.Id = c.Param("id")
|
||||
resp, err := ch.Composition.UpdateComposition(req)
|
||||
if err != nil {
|
||||
if resp != nil {
|
||||
c.JSON(http.StatusInternalServerError, resp)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
75
internal/handler/condition_handler.go
Normal file
75
internal/handler/condition_handler.go
Normal file
@@ -0,0 +1,75 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ConditionHandler struct {
|
||||
// Define fields for ConditionHandler
|
||||
Condition integration.ConditionInterface
|
||||
}
|
||||
|
||||
func NewConditionHandler(condition integration.ConditionInterface) *ConditionHandler {
|
||||
return &ConditionHandler{Condition: condition}
|
||||
}
|
||||
func (c *ConditionHandler) CreateCondition(ctx *gin.Context) {
|
||||
var bodyParam model.ConditionRequest
|
||||
if err := ctx.ShouldBindJSON(&bodyParam); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
res, err := c.Condition.CreateCondition(bodyParam)
|
||||
if err != nil {
|
||||
if res != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, res)
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK, res)
|
||||
}
|
||||
|
||||
func (c *ConditionHandler) GetConditionByPatient(ctx *gin.Context) {
|
||||
patientId := ctx.Query("subject")
|
||||
if patientId == "" {
|
||||
ctx.JSON(http.StatusBadRequest, "patientId is required")
|
||||
return
|
||||
}
|
||||
|
||||
res, err := c.Condition.GetConditionByPatient(patientId)
|
||||
if err != nil {
|
||||
if res != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, res)
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, res)
|
||||
}
|
||||
|
||||
func (c *ConditionHandler) UpdateCondition(ctx *gin.Context) {
|
||||
var bodyParam model.ConditionRequest
|
||||
if err := ctx.ShouldBindJSON(&bodyParam); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
bodyParam.Id = ctx.Param("id")
|
||||
res, err := c.Condition.UpdateCondition(bodyParam)
|
||||
if err != nil {
|
||||
if res != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, res)
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK, res)
|
||||
}
|
||||
62
internal/handler/diagnosisreport_handler.go
Normal file
62
internal/handler/diagnosisreport_handler.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
"satusehat-rssa/pkg/common"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type DiagnosisReportHandler struct {
|
||||
DiagnosisReport integration.DiagnosisReportInterface
|
||||
}
|
||||
|
||||
func NewDiagnosisReportHandler(diagnosisReport integration.DiagnosisReportInterface) *DiagnosisReportHandler {
|
||||
return &DiagnosisReportHandler{DiagnosisReport: diagnosisReport}
|
||||
}
|
||||
|
||||
func (d *DiagnosisReportHandler) CreateDiagnosisReport(c *gin.Context) {
|
||||
var req model.DiagnosticReportRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
identifier := common.GetIdentifier("diagnostic")
|
||||
identifier.System += "/lab"
|
||||
req.Identifier = append(req.Identifier, identifier)
|
||||
res, err := d.DiagnosisReport.CreateDiagnosisReport(req)
|
||||
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 (d *DiagnosisReportHandler) UpdateDiagnosisReport(c *gin.Context) {
|
||||
var req model.DiagnosticReportRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
req.Id = c.Param("id")
|
||||
identifier := common.GetIdentifier("diagnostic")
|
||||
identifier.System += "/lab"
|
||||
req.Identifier = append(req.Identifier, identifier)
|
||||
res, err := d.DiagnosisReport.UpdateDiagnosisReport(req)
|
||||
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)
|
||||
}
|
||||
81
internal/handler/encounter_handler.go
Normal file
81
internal/handler/encounter_handler.go
Normal file
@@ -0,0 +1,81 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type EncounterHandler struct {
|
||||
// Define any dependencies needed for the handler
|
||||
Encounter integration.EncounterInterface
|
||||
}
|
||||
|
||||
func NewEncounterHandler(encounter integration.EncounterInterface) *EncounterHandler {
|
||||
return &EncounterHandler{Encounter: encounter}
|
||||
}
|
||||
|
||||
// Add methods for handling encounter-related requests here
|
||||
func (e *EncounterHandler) CreateEncounter(c *gin.Context) {
|
||||
var req model.EncounterRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
res, err := e.Encounter.CreateEncounter(req)
|
||||
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 (e *EncounterHandler) GetEncounterByPatient(c *gin.Context) {
|
||||
id := c.Query("subject")
|
||||
if id == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Subject is required"})
|
||||
return
|
||||
}
|
||||
|
||||
encounter, err := e.Encounter.GetEncounterByPatient(id)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if encounter == nil {
|
||||
c.JSON(http.StatusNotFound, gin.H{"message": "Encounter not found"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, encounter)
|
||||
}
|
||||
|
||||
func (e *EncounterHandler) UpdateEncounter(c *gin.Context) {
|
||||
var req model.EncounterUpdateRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
// set id for param
|
||||
id := c.Param("id")
|
||||
req.ID = id
|
||||
|
||||
res, err := e.Encounter.UpdateEncounter(req)
|
||||
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)
|
||||
}
|
||||
80
internal/handler/episodeofcare_handler.go
Normal file
80
internal/handler/episodeofcare_handler.go
Normal file
@@ -0,0 +1,80 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
"satusehat-rssa/pkg/common"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type EpisodeOfCareHandler struct {
|
||||
// Define any dependencies needed for the handler
|
||||
EpisodeOfCare integration.EpisodeOfCareInterface
|
||||
}
|
||||
|
||||
func NewEpisodeOfCareHandler(episodeOfCare integration.EpisodeOfCareInterface) *EpisodeOfCareHandler {
|
||||
return &EpisodeOfCareHandler{EpisodeOfCare: episodeOfCare}
|
||||
}
|
||||
|
||||
// Add methods for handling episode of care-related requests here
|
||||
func (e *EpisodeOfCareHandler) CreateEpisodeOfCare(c *gin.Context) {
|
||||
var req model.EpisodeOfCareRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
req.Identifier = append(req.Identifier, common.GetIdentifier("episode-of-care"))
|
||||
res, err := e.EpisodeOfCare.CreateEpisodeOfCare(req)
|
||||
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 (e *EpisodeOfCareHandler) GetEpisodeOfCareByPatient(c *gin.Context) {
|
||||
id := c.Query("patient")
|
||||
if id == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Patient is required"})
|
||||
return
|
||||
}
|
||||
|
||||
episodeOfCare, err := e.EpisodeOfCare.GetEpisodeOfCareByPatient(id)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if episodeOfCare == nil {
|
||||
c.JSON(http.StatusNotFound, gin.H{"message": "Episode of care not found"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, episodeOfCare)
|
||||
}
|
||||
|
||||
func (e *EpisodeOfCareHandler) UpdateEpisodeOfCare(c *gin.Context) {
|
||||
var req model.EpisodeOfCareRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
req.Id = c.Param("id")
|
||||
req.Identifier = append(req.Identifier, common.GetIdentifier("episode-of-care"))
|
||||
res, err := e.EpisodeOfCare.UpdateEpisodeOfCare(req)
|
||||
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)
|
||||
}
|
||||
58
internal/handler/goal_handler.go
Normal file
58
internal/handler/goal_handler.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type GoalHandler struct {
|
||||
Goal integration.GoalInterface
|
||||
}
|
||||
|
||||
func NewGoalHandler(Goal integration.GoalInterface) *GoalHandler {
|
||||
return &GoalHandler{Goal: Goal}
|
||||
}
|
||||
|
||||
func (h GoalHandler) CreateGoal(c *gin.Context) {
|
||||
var req model.GoalRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
res, err := h.Goal.CreateGoal(req)
|
||||
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 (h GoalHandler) UpdateGoal(c *gin.Context) {
|
||||
var req model.GoalRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
req.Id = c.Param("id")
|
||||
res, err := h.Goal.CreateGoal(req)
|
||||
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)
|
||||
}
|
||||
97
internal/handler/imagingstudy_handler.go
Normal file
97
internal/handler/imagingstudy_handler.go
Normal file
@@ -0,0 +1,97 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ImagingStudyHandler struct {
|
||||
ImagingStudy integration.ImagingStudyInterface
|
||||
}
|
||||
|
||||
func NewImagingStudyHandler(ImagingStudy integration.ImagingStudyInterface) *ImagingStudyHandler {
|
||||
return &ImagingStudyHandler{ImagingStudy: ImagingStudy}
|
||||
}
|
||||
|
||||
func (h ImagingStudyHandler) CreateImagingStudy(c *gin.Context) {
|
||||
var req model.ImagingStudyRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if len(req.Identifier) < 1 {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "identifier is required."})
|
||||
return
|
||||
}
|
||||
|
||||
if len(req.Identifier) > 0 {
|
||||
for k, i := range req.Identifier {
|
||||
if k == 0 && i.Value == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("identifier[%d].value (ACSN) required", k)})
|
||||
return
|
||||
}
|
||||
|
||||
// if k == 1 && i.Value == "" {
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("identifier[%d].value (urn:dicom:uid) required", k)})
|
||||
// return
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
res, err := h.ImagingStudy.CreateImagingStudy(req)
|
||||
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 (h ImagingStudyHandler) UpdateImagingStudy(c *gin.Context) {
|
||||
var req model.ImagingStudyRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if len(req.Identifier) < 1 {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "identifier is required."})
|
||||
return
|
||||
}
|
||||
|
||||
if len(req.Identifier) > 0 {
|
||||
for k, i := range req.Identifier {
|
||||
if k == 0 && i.Value == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("identifier[%d].value (ACSN) required", k)})
|
||||
return
|
||||
}
|
||||
|
||||
// if k == 1 && i.Value == "" {
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("identifier[%d].value (urn:dicom:uid) required", k)})
|
||||
// return
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
req.Id = c.Param("id")
|
||||
res, err := h.ImagingStudy.CreateImagingStudy(req)
|
||||
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)
|
||||
}
|
||||
58
internal/handler/immunization_handler.go
Normal file
58
internal/handler/immunization_handler.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ImmunizationHandler struct {
|
||||
Immunization integration.ImmunizationInterface
|
||||
}
|
||||
|
||||
func NewImmunizationHandler(Immunization integration.ImmunizationInterface) *ImmunizationHandler {
|
||||
return &ImmunizationHandler{Immunization: Immunization}
|
||||
}
|
||||
|
||||
func (h ImmunizationHandler) CreateImmunization(c *gin.Context) {
|
||||
var req model.ImmunizationRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
res, err := h.Immunization.CreateImmunization(req)
|
||||
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 (h ImmunizationHandler) UpdateImmunization(c *gin.Context) {
|
||||
var req model.ImmunizationRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
req.Id = c.Param("id")
|
||||
res, err := h.Immunization.CreateImmunization(req)
|
||||
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)
|
||||
}
|
||||
58
internal/handler/medicationdispense_handler.go
Normal file
58
internal/handler/medicationdispense_handler.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type MedicationDispenseHandler struct {
|
||||
MedicationDispense integration.MedicationDispenseInterface
|
||||
}
|
||||
|
||||
func NewMedicationDispenseHandler(MedicationDispense integration.MedicationDispenseInterface) *MedicationDispenseHandler {
|
||||
return &MedicationDispenseHandler{MedicationDispense: MedicationDispense}
|
||||
}
|
||||
|
||||
func (h MedicationDispenseHandler) CreateMedicationDispense(c *gin.Context) {
|
||||
var req model.MedicationDispenseRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
res, err := h.MedicationDispense.CreateMedicationDispense(req)
|
||||
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 (h MedicationDispenseHandler) UpdateMedicationDispense(c *gin.Context) {
|
||||
var req model.MedicationDispenseRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
req.Id = c.Param("id")
|
||||
res, err := h.MedicationDispense.CreateMedicationDispense(req)
|
||||
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)
|
||||
}
|
||||
58
internal/handler/medicationrequest_handler.go
Normal file
58
internal/handler/medicationrequest_handler.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type MedicationRequestHandler struct {
|
||||
MedicationRequest integration.MedicationRequestInterface
|
||||
}
|
||||
|
||||
func NewMedicationRequestHandler(MedicationRequest integration.MedicationRequestInterface) *MedicationRequestHandler {
|
||||
return &MedicationRequestHandler{MedicationRequest: MedicationRequest}
|
||||
}
|
||||
|
||||
func (h MedicationRequestHandler) CreateMedicationRequest(c *gin.Context) {
|
||||
var req model.MedicationRequestRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
res, err := h.MedicationRequest.CreateMedicationRequest(req)
|
||||
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 (h MedicationRequestHandler) UpdateMedicationRequest(c *gin.Context) {
|
||||
var req model.MedicationRequestRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
req.Id = c.Param("id")
|
||||
res, err := h.MedicationRequest.CreateMedicationRequest(req)
|
||||
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)
|
||||
}
|
||||
60
internal/handler/medicationstatement_handler.go
Normal file
60
internal/handler/medicationstatement_handler.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type MedicationStatementHandler struct {
|
||||
MedicationStatement integration.MedicationStatementInterface
|
||||
}
|
||||
|
||||
func NewMedicationStatementHandler(MedicationStatement integration.MedicationStatementInterface) *MedicationStatementHandler {
|
||||
return &MedicationStatementHandler{MedicationStatement: MedicationStatement}
|
||||
}
|
||||
|
||||
func (h MedicationStatementHandler) CreateMedicationStatement(c *gin.Context) {
|
||||
var req model.MedicationStatementRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
fmt.Println(err)
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
res, err := h.MedicationStatement.CreateMedicationStatement(req)
|
||||
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 (h MedicationStatementHandler) UpdateMedicationStatement(c *gin.Context) {
|
||||
var req model.MedicationStatementRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
req.Id = c.Param("id")
|
||||
res, err := h.MedicationStatement.CreateMedicationStatement(req)
|
||||
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)
|
||||
}
|
||||
40
internal/handler/medicine_handler.go
Normal file
40
internal/handler/medicine_handler.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type MedicineHandler struct {
|
||||
Medicine integration.MedicineIntegrationInterface
|
||||
}
|
||||
|
||||
func NewMedicineHandler(medicine integration.MedicineIntegrationInterface) *MedicineHandler {
|
||||
return &MedicineHandler{Medicine: medicine}
|
||||
}
|
||||
func (m MedicineHandler) GetMedicineKfa(c *gin.Context) {
|
||||
var req model.MedicineKfaRequest
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
res, err := m.Medicine.GetMedicineKfa(req)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, res)
|
||||
}
|
||||
|
||||
func (m MedicineHandler) GetMedicineByKfaCode(c *gin.Context) {
|
||||
kfaCode := c.Param("kfa_code")
|
||||
res, err := m.Medicine.GetMedicineByKfaCode(kfaCode)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, res)
|
||||
}
|
||||
33
internal/handler/oauth_handler.go
Normal file
33
internal/handler/oauth_handler.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type OauthHandler struct {
|
||||
Oauth integration.OauthInterface
|
||||
}
|
||||
|
||||
func NewOuathHandler(Oauth integration.OauthInterface) *OauthHandler {
|
||||
return &OauthHandler{Oauth: Oauth}
|
||||
}
|
||||
|
||||
func (oh OauthHandler) GenerateToken(c *gin.Context) {
|
||||
var bodyParam model.OauthRequest
|
||||
if err := c.ShouldBindJSON(&bodyParam); err != nil {
|
||||
c.JSON(http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
res, err := oh.Oauth.GenerateToken(bodyParam)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, res)
|
||||
}
|
||||
78
internal/handler/observation_handler.go
Normal file
78
internal/handler/observation_handler.go
Normal file
@@ -0,0 +1,78 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ObservationHandler struct {
|
||||
// Define any dependencies needed for the handler
|
||||
Observation integration.ObservationInterface
|
||||
}
|
||||
|
||||
func NewObservationHandler(observation integration.ObservationInterface) *ObservationHandler {
|
||||
return &ObservationHandler{Observation: observation}
|
||||
}
|
||||
|
||||
// Add methods for handling observation-related requests here
|
||||
func (o *ObservationHandler) CreateObservation(c *gin.Context) {
|
||||
var req model.ObservationRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
res, err := o.Observation.CreateObservation(req)
|
||||
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 *ObservationHandler) GetObservationByPatient(c *gin.Context) {
|
||||
id := c.Query("subject")
|
||||
if id == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Subject is required"})
|
||||
return
|
||||
}
|
||||
|
||||
observation, err := o.Observation.GetObservationByPatient(id)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if observation == nil {
|
||||
c.JSON(http.StatusNotFound, gin.H{"message": "Observation not found"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, observation)
|
||||
}
|
||||
|
||||
func (o *ObservationHandler) UpdateObservation(c *gin.Context) {
|
||||
var req model.ObservationRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
req.Id = c.Param("id")
|
||||
res, err := o.Observation.UpdateObservation(req)
|
||||
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)
|
||||
}
|
||||
54
internal/handler/organization_handler.go
Normal file
54
internal/handler/organization_handler.go
Normal 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)
|
||||
}
|
||||
47
internal/handler/patient_handler.go
Normal file
47
internal/handler/patient_handler.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type PatientHandler struct {
|
||||
// Define any dependencies or services needed for the PatientHandler
|
||||
Patient integration.PatientInterface
|
||||
}
|
||||
|
||||
func NewPatientHandler(patient integration.PatientInterface) *PatientHandler {
|
||||
return &PatientHandler{Patient: patient}
|
||||
}
|
||||
|
||||
// Add methods for handling patient-related requests here
|
||||
func (p *PatientHandler) GetPatientByNIK(c *gin.Context) {
|
||||
param := c.Query("identifier")
|
||||
res, err := p.Patient.GetPatientByNIK(param)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, res)
|
||||
}
|
||||
|
||||
func (p *PatientHandler) CreatePatient(c *gin.Context) {
|
||||
var req model.PatientRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
res, err := p.Patient.CreataPatient(req)
|
||||
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)
|
||||
}
|
||||
37
internal/handler/practitioner_handler.go
Normal file
37
internal/handler/practitioner_handler.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type PracticionerHandler struct {
|
||||
Practicioner integration.PracticionerInterface
|
||||
}
|
||||
|
||||
func NewPracticionerHandler(practicioner integration.PracticionerInterface) *PracticionerHandler {
|
||||
return &PracticionerHandler{Practicioner: practicioner}
|
||||
}
|
||||
|
||||
func (p PracticionerHandler) GetPracticionerByNik(c *gin.Context) {
|
||||
nik := c.Query("identifier")
|
||||
if nik == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "identifier is required"})
|
||||
return
|
||||
}
|
||||
|
||||
practicioner, err := p.Practicioner.GetPracticionerByNIK(nik)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if practicioner == nil {
|
||||
c.JSON(http.StatusNotFound, gin.H{"message": "Practicioner not found"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, practicioner)
|
||||
}
|
||||
71
internal/handler/procedure_handler.go
Normal file
71
internal/handler/procedure_handler.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ProcedureHandler struct {
|
||||
Procedure integration.ProcedureInterface
|
||||
}
|
||||
|
||||
func NewProcedureHandler(procedure integration.ProcedureInterface) *ProcedureHandler {
|
||||
return &ProcedureHandler{
|
||||
Procedure: procedure,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ProcedureHandler) CreateProcedure(c *gin.Context) {
|
||||
var req model.ProcedureRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
result, err := p.Procedure.CreateProcedure(req)
|
||||
if err != nil {
|
||||
if result != nil {
|
||||
c.JSON(http.StatusInternalServerError, result)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func (p *ProcedureHandler) GetProcedure(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
|
||||
result, err := p.Procedure.GetProcedure(id)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func (p *ProcedureHandler) UpdateProcedure(c *gin.Context) {
|
||||
var req model.ProcedureRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
result, err := p.Procedure.UpdateProcedure(req)
|
||||
if err != nil {
|
||||
if result != nil {
|
||||
c.JSON(http.StatusInternalServerError, result)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, result)
|
||||
}
|
||||
58
internal/handler/questionnaireresponse_handler.go
Normal file
58
internal/handler/questionnaireresponse_handler.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type QuestionnaireResponseHandler struct {
|
||||
QuestionnaireResponse integration.QuestionnaireResponseInterface
|
||||
}
|
||||
|
||||
func NewQuestionnaireResponseHandler(QuestionnaireResponse integration.QuestionnaireResponseInterface) *QuestionnaireResponseHandler {
|
||||
return &QuestionnaireResponseHandler{QuestionnaireResponse: QuestionnaireResponse}
|
||||
}
|
||||
|
||||
func (h QuestionnaireResponseHandler) CreateQuestionnaireResponse(c *gin.Context) {
|
||||
var req model.QuestionnaireResponseRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
res, err := h.QuestionnaireResponse.CreateQuestionnaireResponse(req)
|
||||
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 (h QuestionnaireResponseHandler) UpdateQuestionnaireResponse(c *gin.Context) {
|
||||
var req model.QuestionnaireResponseRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
req.Id = c.Param("id")
|
||||
res, err := h.QuestionnaireResponse.CreateQuestionnaireResponse(req)
|
||||
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)
|
||||
}
|
||||
77
internal/handler/servicerequest_handler.go
Normal file
77
internal/handler/servicerequest_handler.go
Normal file
@@ -0,0 +1,77 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
"satusehat-rssa/pkg/common"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ServiceRequestHandler struct {
|
||||
repo integration.ServiceRequestInterface
|
||||
}
|
||||
|
||||
func NewServiceRequestHandler(repo integration.ServiceRequestInterface) *ServiceRequestHandler {
|
||||
return &ServiceRequestHandler{repo: repo}
|
||||
}
|
||||
|
||||
func (h *ServiceRequestHandler) CreateServiceRequest(c *gin.Context) {
|
||||
var req model.ServiceRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
req.Identifier = append(req.Identifier, common.GetIdentifier("servicerequest"))
|
||||
data, err := h.repo.CreateServiceRequest(req)
|
||||
if err != nil {
|
||||
if data != nil {
|
||||
c.JSON(http.StatusInternalServerError, data)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, data)
|
||||
}
|
||||
|
||||
func (h *ServiceRequestHandler) GetServiceRequestByPatient(c *gin.Context) {
|
||||
id := c.Query("subject")
|
||||
if id == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Patient ID is required"})
|
||||
return
|
||||
}
|
||||
|
||||
data, err := h.repo.GetServiceRequestByPatient(id)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, data)
|
||||
}
|
||||
|
||||
func (h *ServiceRequestHandler) UpdateServiceRequest(c *gin.Context) {
|
||||
var req model.ServiceRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
req.Id = c.Param("id")
|
||||
req.Identifier = append(req.Identifier, common.GetIdentifier("servicerequest"))
|
||||
data, err := h.repo.UpdateServiceRequest(req)
|
||||
if err != nil {
|
||||
if data != nil {
|
||||
c.JSON(http.StatusInternalServerError, data)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, data)
|
||||
}
|
||||
77
internal/handler/specimen_handler.go
Normal file
77
internal/handler/specimen_handler.go
Normal file
@@ -0,0 +1,77 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"satusehat-rssa/internal/integration"
|
||||
"satusehat-rssa/internal/model"
|
||||
"satusehat-rssa/pkg/common"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type SpecimenHandler struct {
|
||||
Specimen integration.SpecimenInterface
|
||||
}
|
||||
|
||||
func NewSpecimenHandler(specimen integration.SpecimenInterface) *SpecimenHandler {
|
||||
return &SpecimenHandler{Specimen: specimen}
|
||||
}
|
||||
func (s *SpecimenHandler) CreateSpecimen(c *gin.Context) {
|
||||
var req model.SpecimenRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
req.Identifier = append(req.Identifier, common.GetIdentifier("specimen"))
|
||||
res, err := s.Specimen.CreateSpecimen(req)
|
||||
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 (s *SpecimenHandler) GetSpecimenByPatient(c *gin.Context) {
|
||||
id := c.Query("subject")
|
||||
if id == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Subject is required"})
|
||||
return
|
||||
}
|
||||
|
||||
specimen, err := s.Specimen.GetSpecimenByPatient(id)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if specimen == nil {
|
||||
c.JSON(http.StatusNotFound, gin.H{"message": "Specimen not found"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, specimen)
|
||||
}
|
||||
|
||||
func (s *SpecimenHandler) UpdateSpecimen(c *gin.Context) {
|
||||
var req model.SpecimenRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
req.Id = c.Param("id")
|
||||
req.Identifier = append(req.Identifier, common.GetIdentifier("specimen"))
|
||||
res, err := s.Specimen.UpdateSpecimen(req)
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user