penambahan data lis
This commit is contained in:
No files matched your search
@@ -0,0 +1,14 @@
|
||||
package simrs
|
||||
|
||||
import "log"
|
||||
|
||||
func (s *DatabaseService) GetDiagnosa(idxDaftar string) (string, error) {
|
||||
var diagnosa string
|
||||
querySelect := `SELECT diagnosa from t_diagnosadanterapi where "idxdaftar"=? order by tanggal DESC limit 1`
|
||||
errSelect := s.DB.Debug().Raw(querySelect, idxDaftar).Scan(&diagnosa).Error
|
||||
if errSelect != nil {
|
||||
log.Println(errSelect)
|
||||
return "", errSelect
|
||||
}
|
||||
return diagnosa, nil
|
||||
}
|
||||
@@ -11,6 +11,16 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// SendDataLISMikro godoc
|
||||
// @Summary Send Data LIS Mikro
|
||||
// @Description Send Data LIS Mikro
|
||||
// @Tags LIS Mikro
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param request body mikrobiologi.RequestPasienMikrobiologi true "Pasien Mikrobiologi request"
|
||||
// @Success 202 {object} mikrobiologi.ResponseLISMikro
|
||||
// @Failure 400 "Bad request"
|
||||
// @Router /mikrobiologi/sendmikro [post]
|
||||
func SendDataLISMikro(c *gin.Context) {
|
||||
db := database.New().GetDB("simrs")
|
||||
if db == nil {
|
||||
@@ -30,7 +40,7 @@ func SendDataLISMikro(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
log.Println("REQUEST", req)
|
||||
log.Println("REQUEST dari frontend:", req)
|
||||
|
||||
dataMikro, errData := simrsDB.GetDataMikroBiologiByNoMR(req)
|
||||
if errData != nil {
|
||||
@@ -61,6 +71,7 @@ func SendDataLISMikro(c *gin.Context) {
|
||||
|
||||
var responseMikro []*mikrobiologi.ResponseLISMikro
|
||||
var dataLisMikro *mikrobiologi.RequestLISMikro
|
||||
|
||||
tglLahirString := tglLahir.Format("2006-01-02")
|
||||
for _, dataMikroMain := range dataMikro {
|
||||
dataLabMikro, exist, errDiagnosa := simrsDB.GetDataLabMikro(dataMikroMain.NoLab)
|
||||
@@ -77,14 +88,6 @@ func SendDataLISMikro(c *gin.Context) {
|
||||
continue
|
||||
}
|
||||
|
||||
namaDokter, errDokter := simrsDB.GetNamaDokter(dataMikroMain.DokterPengirim)
|
||||
if errDokter != nil {
|
||||
log.Println(errDokter)
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": errDokter,
|
||||
})
|
||||
return
|
||||
}
|
||||
poli, errDokter := simrsDB.GetNamaRuang(dataMikroMain.KodePoli)
|
||||
if errDokter != nil {
|
||||
log.Println(errDokter)
|
||||
@@ -102,6 +105,57 @@ func SendDataLISMikro(c *gin.Context) {
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
diagnosa, errDiagnosa := simrsDB.GetDiagnosa(dataMikroMain.IdxDaftar)
|
||||
if errDiagnosa != nil {
|
||||
log.Println(errDiagnosa)
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": errDiagnosa,
|
||||
})
|
||||
}
|
||||
|
||||
var dokterPengirim string
|
||||
if dataMikroMain.DrOrder != "0" && dataMikroMain.DrOrder != "" {
|
||||
dokterPengirim, errDokter = simrsDB.GetNamaDokter(dataMikroMain.DrOrder)
|
||||
log.Println("DokterOrder kode-nama:", dataMikroMain.DrOrder, " - ", dokterPengirim)
|
||||
if errDokter != nil {
|
||||
log.Println(errDokter)
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": errDokter,
|
||||
})
|
||||
return
|
||||
}
|
||||
//return
|
||||
} else if dataMikroMain.DokterPengirim != "" && dataMikroMain.DokterPengirim != "0" {
|
||||
dokterPengirim, errDokter = simrsDB.GetNamaDokter(dataMikroMain.DokterPengirim)
|
||||
log.Println("DokterPengirim kode-nama:", dataMikroMain.DokterPengirim, " - ", dokterPengirim)
|
||||
if errDokter != nil {
|
||||
log.Println(errDokter)
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": errDokter,
|
||||
})
|
||||
return
|
||||
}
|
||||
//return
|
||||
} else if dataMikroMain.DokterLab1 != "0" && dataMikroMain.DokterLab1 != "" {
|
||||
dokterPengirim, errDokter = simrsDB.GetNamaDokter(dataMikroMain.DokterLab1)
|
||||
log.Println("DokterLab kode-nama:", dataMikroMain.DokterLab1, " - ", dokterPengirim)
|
||||
if errDokter != nil {
|
||||
log.Println(errDokter)
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": errDokter,
|
||||
})
|
||||
return
|
||||
}
|
||||
//return
|
||||
} else if dataMikroMain.Pengirim != "" && dataMikroMain.Pengirim != "0" {
|
||||
dokterPengirim = dataMikroMain.Pengirim
|
||||
log.Println("Pengirim kode-nama:", dataMikroMain.Pengirim, " - ", dokterPengirim)
|
||||
} else {
|
||||
dokterPengirim = ""
|
||||
log.Println("dokterPengirim : null")
|
||||
}
|
||||
|
||||
for _, value := range dataLabMikro {
|
||||
dataLisMikro = &mikrobiologi.RequestLISMikro{
|
||||
NoRM: dataMikroMain.NoMR,
|
||||
@@ -113,13 +167,13 @@ func SendDataLISMikro(c *gin.Context) {
|
||||
Kelamin: dataPasien.JenisKelamin,
|
||||
NIK: dataPasien.NoKTP,
|
||||
NoBPJS: dataPasien.NoKartu,
|
||||
DokterPeminta: namaDokter,
|
||||
DokterPeminta: dokterPengirim,
|
||||
AsalPasien: poli.NamaPoli,
|
||||
Layanan: value.NamaPemeriksaan,
|
||||
StatusBayar: "",
|
||||
NoTransaksi: dataMikroMain.NoLab,
|
||||
Asuransi: caraBayar,
|
||||
Klinis: "",
|
||||
Klinis: diagnosa,
|
||||
KodeSpesimen: value.NamaField,
|
||||
NamaSpesimen: value.JenisKelompok,
|
||||
Pengambilan: "",
|
||||
|
||||
@@ -124,6 +124,9 @@ type OrderLabMikroMain struct {
|
||||
NoNota string `gorm:"column:nonota" json:"nonota"`
|
||||
StatusRajal string `gorm:"column:st_rajal" json:"st_rajal"`
|
||||
StatusAPS string `gorm:"column:st_aps" json:"st_aps"`
|
||||
Pengirim string `gorm:"column:pengirim" json:"pengirim"`
|
||||
DrOrder string `gorm:"column:dr_order" json:"dr_order"`
|
||||
DokterLab1 string `gorm:"column:dokterlab1" json:"dokterlab1"`
|
||||
}
|
||||
|
||||
type OrderLabMikro struct {
|
||||
|
||||
Reference in New Issue
Block a user