udpate insert patient
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user