add fisik

This commit is contained in:
Hanan Askarim
2024-06-13 18:59:24 +07:00
parent ac0c6dfc21
commit ac1547699e
6 changed files with 335 additions and 1 deletions

View File

@@ -13,6 +13,7 @@ import (
type KesimpulanService interface {
GetListKesimpulanLab(id string) ([]models.ModelKesimpulanLab, error)
GetListKesimpulanNonLab(id string) ([]models.ModelKesimpulanLab, error)
GetListKesimpulanFisik(id string) ([]models.ModelKesimpulanLab, error)
}
func NewKesimpulanHandler(us KesimpulanService) *KesimpulanHandler {
@@ -30,6 +31,7 @@ func (h *KesimpulanHandler) HandleShowKesimpulanScreen(c echo.Context) error {
tableID := utils.GenerateRandomID("tablebody")
tableIDNonLab := utils.GenerateRandomID("tablebody")
tableIDFisik := utils.GenerateRandomID("tablebody")
id := c.Param("id")
// table component
@@ -63,10 +65,27 @@ func (h *KesimpulanHandler) HandleShowKesimpulanScreen(c echo.Context) error {
zap.Any("data lab", dataNonLab))
tableComponentNonLab := dev_kesimpulan.CardTableKesimpulanNonLab("3 Kelainan Pemeriksaan Non Lab terbesar :", dataNonLab, tableIDNonLab)
// table component fisik
dataFisik, err := h.KesimpulanService.GetListKesimpulanFisik(id)
if err != nil {
defer logger.Sync()
logger.Info("ERROR GET LIST FISIK",
zap.Any("error", err),
)
fmt.Println(dataFisik)
return err
}
logger.Info("CEK DATA",
zap.Any("data lab", dataFisik))
tableComponentFisik := dev_kesimpulan.CardTableKesimpulanFisik("3 Kelainan Pemeriksaan Fisik terbesar :", dataFisik, tableIDFisik)
content := dev_kesimpulan.MainKesimpulan(tableID,
tableIDNonLab,
tableIDFisik,
tableComponentLab,
tableComponentNonLab)
tableComponentNonLab,
tableComponentFisik)
view := dev_kesimpulan.ShowKesimpulan("KESIMPULAN", content, dev_kesimpulan.CssKesimpulan(), dev_kesimpulan.JsKesimpulan())
return utils.View(c, view)

View File

@@ -162,3 +162,71 @@ func (k *KesimpulanServices) GetListKesimpulanNonLab(id string) ([]models.ModelK
)
return listNonLab, nil
}
func (k *KesimpulanServices) GetListKesimpulanFisik(id string) ([]models.ModelKesimpulanLab, error) {
logger, _ := zap.NewProduction()
var listFisik []models.ModelKesimpulanLab
var dataTot []models.ModelKesimpulanLab
qryTot := `select '' as nomor,
'' as Test, sum(total) as total
from(
select count(*) as total
FROM mgm_header
join mgm_detail on Mgm_DetailMgm_HeaderID = Mgm_HeaderID and Mgm_DetailIsActive = 'Y'
join mcu_kelainan on Mgm_DetailMcu_KelainanID = Mcu_KelainanID
join mcu_kelainangroup on Mgm_DetailMcu_KelainanGroupID = Mcu_KelainanGroupID
left join nat_test on Nat_TestCode = Mgm_HeaderNat_TestCode
where Mgm_HeaderIsActive = 'Y' and Mgm_HeaderMgm_McuID = ? AND Mgm_HeaderType = 'F'
and Mgm_HeaderIsNormal = 'N'
group by Mgm_DetailMcu_KelainanID, Mgm_HeaderType ) x`
err := dbx.Handlex.Select(&dataTot, qryTot, id)
if err != nil {
defer logger.Sync()
logger.Error("Error get total",
zap.Any("id", id),
zap.Any("total data", dataTot),
)
// return dataTot, fmt.Errorf("QUERY_FAILED")
}
// Extracting the Total value
var totalFisik string
if len(dataTot) > 0 {
totalFisik = dataTot[0].Total
}
logger.Info("data",
zap.Any("id", id),
zap.Any("cek total", totalFisik),
)
query := `SELECT ROW_NUMBER() OVER () AS nomor,
ifnull(Nat_TestName ,Mcu_KelainanGroupName) as Test,
cast(count(Mgm_HeaderT_OrderHeaderID)/?*100 as decimal(2,0)) as total
FROM mgm_header
join mgm_detail on Mgm_DetailMgm_HeaderID = Mgm_HeaderID and Mgm_DetailIsActive = 'Y'
join mcu_kelainan on Mgm_DetailMcu_KelainanID = Mcu_KelainanID
join mcu_kelainangroup on Mgm_DetailMcu_KelainanGroupID = Mcu_KelainanGroupID
left join nat_test on Nat_TestCode = Mgm_HeaderNat_TestCode
where Mgm_HeaderIsActive = 'Y' and Mgm_HeaderMgm_McuID = ? AND Mgm_HeaderType = 'F'
and Mgm_HeaderIsNormal = 'N'
group by Mgm_DetailMcu_KelainanID, Mgm_HeaderType ORDER BY count(Mgm_HeaderT_OrderHeaderID) DESC
LIMIT 3`
err = dbx.Handlex.Select(&listFisik, query, totalFisik, id)
if err != nil {
defer logger.Sync()
logger.Error("Error get data fisik",
zap.Any("id", id),
zap.Any("list data", listFisik),
)
return listFisik, fmt.Errorf("QUERY_FAILED")
}
return listFisik, nil
}

View File

@@ -9,8 +9,10 @@ import (
templ MainKesimpulan(
tableID string,
tableIDNonLab string,
tableIDFisik string,
tablecontent templ.Component,
tablecontentnonlab templ.Component,
tablecontentfisik templ.Component,
) {
<div class="container-fluid">
@customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "tableID",
@@ -21,11 +23,16 @@ templ MainKesimpulan(
Name: "tableIDNonLab",
Type: "hidden",
Value: tableIDNonLab})
@customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "tableIDFisik",
Name: "tableIDFisik",
Type: "hidden",
Value: tableIDFisik})
<div class="d-flex justify-content-center pt-10 pb-10">
<h2 class="title" style="margin-bottom: 0">Kesimpulan</h2>
</div>
@tablecontent
@tablecontentnonlab
@tablecontentfisik
</div>
}

View File

@@ -19,8 +19,10 @@ import (
func MainKesimpulan(
tableID string,
tableIDNonLab string,
tableIDFisik string,
tablecontent templ.Component,
tablecontentnonlab templ.Component,
tablecontentfisik templ.Component,
) templ.Component {
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
@@ -52,6 +54,13 @@ func MainKesimpulan(
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "tableIDFisik",
Name: "tableIDFisik",
Type: "hidden",
Value: tableIDFisik}).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"d-flex justify-content-center pt-10 pb-10\"><h2 class=\"title\" style=\"margin-bottom: 0\">Kesimpulan</h2></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
@@ -64,6 +73,10 @@ func MainKesimpulan(
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = tablecontentfisik.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err

View File

@@ -0,0 +1,46 @@
package dev_kesimpulan
import (
"cpone/component/table"
"cpone/models"
)
templ CardTableKesimpulanFisik(title string, data []models.ModelKesimpulanLab, tableIDFisik string) {
<div class="card card-custom gutter-b" style="border-radius: 20px">
<div style="padding-top: 12px">
<h3 class="card-label dot-text text-black">
{ title }
</h3>
</div>
<div class="card-body">
<div>
@TableKesimpulanFisik(data, tableIDFisik)
</div>
</div>
</div>
}
templ TableKesimpulanFisik(data []models.ModelKesimpulanLab,
tableIDFisik string) {
<div id={ tableIDFisik } hx-swap-oob="true">
@tablecomponent.TableV3([]string{"NO", "PEMERIKSAAN", "PERSENTASE"},
[]string{"5%", "70%", "25%"},
RowKesimpulanFisik(data),
)
</div>
}
templ RowKesimpulanFisik(data []models.ModelKesimpulanLab) {
if len(data) == 0 {
<tr>
<td colspan="3" class="text-center">Data Tidak Ditemukan</td>
</tr>
}
for _, v := range data {
<tr>
<td>{ v.Nomor }</td>
<td>{ v.Test }</td>
<td>{ v.Total } %</td>
</tr>
}
}

View File

@@ -0,0 +1,181 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.663
package dev_kesimpulan
//lint:file-ignore SA4006 This context is only used if a nested component is present.
import "github.com/a-h/templ"
import "context"
import "io"
import "bytes"
import (
"cpone/component/table"
"cpone/models"
)
func CardTableKesimpulanFisik(title string, data []models.ModelKesimpulanLab, tableIDFisik string) templ.Component {
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
if !templ_7745c5c3_IsBuffer {
templ_7745c5c3_Buffer = templ.GetBuffer()
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
if templ_7745c5c3_Var1 == nil {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"card card-custom gutter-b\" style=\"border-radius: 20px\"><div style=\"padding-top: 12px\"><h3 class=\"card-label dot-text text-black\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\kesimpulan\tablekesimpulanfisik.templ`, Line: 12, Col: 11}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h3></div><div class=\"card-body\"><div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = TableKesimpulanFisik(data, tableIDFisik).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if !templ_7745c5c3_IsBuffer {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
}
return templ_7745c5c3_Err
})
}
func TableKesimpulanFisik(data []models.ModelKesimpulanLab,
tableIDFisik string) templ.Component {
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
if !templ_7745c5c3_IsBuffer {
templ_7745c5c3_Buffer = templ.GetBuffer()
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var3 := templ.GetChildren(ctx)
if templ_7745c5c3_Var3 == nil {
templ_7745c5c3_Var3 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div id=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(tableIDFisik)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\kesimpulan\tablekesimpulanfisik.templ`, Line: 25, Col: 23}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-swap-oob=\"true\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = tablecomponent.TableV3([]string{"NO", "PEMERIKSAAN", "PERSENTASE"},
[]string{"5%", "70%", "25%"},
RowKesimpulanFisik(data),
).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if !templ_7745c5c3_IsBuffer {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
}
return templ_7745c5c3_Err
})
}
func RowKesimpulanFisik(data []models.ModelKesimpulanLab) templ.Component {
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
if !templ_7745c5c3_IsBuffer {
templ_7745c5c3_Buffer = templ.GetBuffer()
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var5 := templ.GetChildren(ctx)
if templ_7745c5c3_Var5 == nil {
templ_7745c5c3_Var5 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
if len(data) == 0 {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<tr><td colspan=\"3\" class=\"text-center\">Data Tidak Ditemukan</td></tr>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
for _, v := range data {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<tr><td>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(v.Nomor)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\kesimpulan\tablekesimpulanfisik.templ`, Line: 41, Col: 16}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(v.Test)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\kesimpulan\tablekesimpulanfisik.templ`, Line: 42, Col: 15}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td><td>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(v.Total)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\kesimpulan\tablekesimpulanfisik.templ`, Line: 43, Col: 16}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" %</td></tr>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if !templ_7745c5c3_IsBuffer {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
}
return templ_7745c5c3_Err
})
}