udpate insert patient

This commit is contained in:
2025-04-21 13:58:28 +07:00
parent cdfd8da59d
commit 8c04a222ba
4 changed files with 176 additions and 22 deletions

View File

@@ -2,12 +2,12 @@ package patient
import (
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"net/http"
"os"
"template_blueprint/internal/database"
"template_blueprint/pkg/database/mongo"
"template_blueprint/pkg/models/patient"
"time"
)
func InsertPatient(c *gin.Context) {
@@ -18,14 +18,18 @@ func InsertPatient(c *gin.Context) {
return
}
mongoDB := mongo.NewDatabaseService(db)
var reqInsert *patient.Patient
err := c.Bind(&reqInsert)
var req *patient.Patient
err := c.Bind(&req)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"message": err.Error()})
return
}
reqInsert.ID = uuid.New().String()
errInsert := mongoDB.InsertPatient(reqInsert)
dateCreated := time.Now().Format("2006-01-02 15:04:05")
req.ResourceType = "Patient"
req.CreatedAt = dateCreated
errInsert := mongoDB.InsertPatient(req)
if errInsert != nil {
c.JSON(http.StatusInternalServerError, gin.H{"message": errInsert.Error()})
return