add dialog cetak mcu

This commit is contained in:
2024-06-15 15:52:56 +07:00
parent 3bc13d64bc
commit e1200fae61
14 changed files with 1644 additions and 55 deletions

View File

@@ -1,15 +1,93 @@
package corporate_services
import "cpone/db"
import (
"cpone/db"
"cpone/models"
dbx "cpone/package/database"
"fmt"
"math"
type ServicesPatient struct {
"go.uber.org/zap"
)
type PatientServices struct {
PatientStore db.AppStore
}
func NewServicesPatient(uStore db.AppStore) *ServicesPatient {
func NewPatientServices(uStore db.AppStore) *PatientServices {
return &ServicesPatient{
return &PatientServices{
PatientStore: uStore,
}
}
func (sp *PatientServices) GetDashboardPatientBreadcrumb(title string) (models.BreadCrumbV1, error) {
breadcrumb := models.BreadCrumbV1{
Title: title,
Item: []models.ItemBreadCrumbV1{
{
Item: "Dashboard",
Url: "/corp/dashboard_pat",
},
{
Item: "PT. ABC",
Url: "",
},
{
Item: title,
Url: "",
},
},
}
return breadcrumb, nil
}
func (sp *PatientServices) ListingData(search string, date string, patID string, corpId string, currentpage int, rowperpage int) ([]models.DashboardPatient, int, error) {
logger, _ := zap.NewProduction()
var ret []models.DashboardPatient
var totalData int
if len(date) == 0 {
date = ""
}
prmSearch := "%" + search + "%"
offset := (currentpage - 1) * rowperpage
q := `
SELECT COUNT(*)
FROM t_orderheader
WHERE T_OrderHeaderIsActive = 'Y'
AND T_OrderHeaderLabNumber LIKE ?
AND T_OrderHeaderM_PatientID = ?
AND T_OrderHeaderCorporateID = ?
`
if err := dbx.Handlex.Get(&totalData, q, prmSearch, patID, corpId); err != nil {
return nil, 0, fmt.Errorf("error query get total data: %v", err)
}
q = `
SELECT
T_OrderHeaderID,
DATE_FORMAT(T_OrderHeaderDate, '%d/%m/%Y') AS T_OrderHeaderDate,
T_OrderHeaderLabNumber,
T_OrderHeaderM_PatientID,
T_OrderHeaderCorporateID,
T_OrderHeaderMgm_McuID,
T_OrderHeaderIsActive
FROM t_orderheader
WHERE T_OrderHeaderIsActive = 'Y'
AND T_OrderHeaderLabNumber LIKE ?
AND T_OrderHeaderM_PatientID = ?
AND T_OrderHeaderCorporateID = ?
LIMIT ? OFFSET ?
`
if err := dbx.Handlex.Select(&ret, q, prmSearch, patID, corpId, rowperpage, offset); err != nil {
return nil, 0, fmt.Errorf("error query get data: %v", err)
}
logger.Info("response", zap.Any("data", ret))
totalPage := int(math.Ceil(float64(totalData) / float64(rowperpage)))
return ret, totalPage, nil
}