feat/things-munaja: adjust prescription
This commit is contained in:
No files matched your search
@@ -0,0 +1,25 @@
|
|||||||
|
package prescriptionitem
|
||||||
|
|
||||||
|
import (
|
||||||
|
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||||
|
em "simrs-vx/internal/domain/main-entities/medicine"
|
||||||
|
emm "simrs-vx/internal/domain/main-entities/medicine-mix"
|
||||||
|
|
||||||
|
erc "simrs-vx/internal/domain/references/common"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PrescriptionItem struct {
|
||||||
|
ecore.Main // adjust this according to the needs
|
||||||
|
Prescription_Id *uint `json:"prescription_id"`
|
||||||
|
IsMix bool `json:"isMix"`
|
||||||
|
Medicine_Code *string `json:"medicine_code"`
|
||||||
|
Medicine *em.Medicine `json:"medicine,omitempty" gorm:"foreignKey:Medicine_Code;references:Code"`
|
||||||
|
MedicineMix_Id *uint `json:"medicineMix_id"`
|
||||||
|
MedicineMix *emm.MedicineMix `json:"medicineMix,omitempty" gorm:"foreignKey:MedicineMix_Id;references:Id"`
|
||||||
|
Frequency *uint16 `json:"frequency"`
|
||||||
|
Dose float64 `json:"dose"`
|
||||||
|
Usage string `json:"usage" gorm:"size:255"`
|
||||||
|
Interval uint8 `json:"interval"`
|
||||||
|
IntervalUnit_Code erc.TimeUnitCode `json:"intervalUnit_code"`
|
||||||
|
Quantity float64 `json:"quantity"`
|
||||||
|
}
|
||||||
@@ -27,6 +27,7 @@ type ReadListDto struct {
|
|||||||
FilterDto
|
FilterDto
|
||||||
Includes string `json:"includes"`
|
Includes string `json:"includes"`
|
||||||
Pagination ecore.Pagination
|
Pagination ecore.Pagination
|
||||||
|
Sort string `json:"sort"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FilterDto struct {
|
type FilterDto struct {
|
||||||
|
|||||||
@@ -2,26 +2,12 @@ package prescriptionitem
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||||
em "simrs-vx/internal/domain/main-entities/medicine"
|
|
||||||
emm "simrs-vx/internal/domain/main-entities/medicine-mix"
|
|
||||||
ep "simrs-vx/internal/domain/main-entities/prescription"
|
ep "simrs-vx/internal/domain/main-entities/prescription"
|
||||||
|
epib "simrs-vx/internal/domain/main-entities/prescription-item/base"
|
||||||
erc "simrs-vx/internal/domain/references/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type PrescriptionItem struct {
|
type PrescriptionItem struct {
|
||||||
ecore.Main // adjust this according to the needs
|
ecore.Main // adjust this according to the needs
|
||||||
Prescription_Id *uint `json:"prescription_id"`
|
epib.PrescriptionItem
|
||||||
Prescription *ep.Prescription `json:"prescription,omitempty" gorm:"foreignKey:Prescription_Id;references:Id"`
|
Prescription *ep.Prescription `json:"prescription,omitempty" gorm:"foreignKey:Prescription_Id;references:Id"`
|
||||||
IsMix bool `json:"isMix"`
|
|
||||||
Medicine_Code *string `json:"medicine_code"`
|
|
||||||
Medicine *em.Medicine `json:"medicine,omitempty" gorm:"foreignKey:Medicine_Code;references:Code"`
|
|
||||||
MedicineMix_Id *uint `json:"medicineMix_id"`
|
|
||||||
MedicineMix *emm.MedicineMix `json:"medicineMix,omitempty" gorm:"foreignKey:MedicineMix_Id;references:Id"`
|
|
||||||
Frequency *uint16 `json:"frequency"`
|
|
||||||
Dose float64 `json:"dose"`
|
|
||||||
Usage string `json:"usage" gorm:"size:255"`
|
|
||||||
Interval uint8 `json:"interval"`
|
|
||||||
IntervalUnit_Code erc.TimeUnitCode `json:"intervalUnit_code"`
|
|
||||||
Quantity float64 `json:"quantity"`
|
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||||
|
epi "simrs-vx/internal/domain/main-entities/prescription-item/base"
|
||||||
|
|
||||||
pa "simrs-vx/internal/lib/auth"
|
pa "simrs-vx/internal/lib/auth"
|
||||||
|
|
||||||
@@ -56,12 +57,13 @@ type MetaDto struct {
|
|||||||
|
|
||||||
type ResponseDto struct {
|
type ResponseDto struct {
|
||||||
ecore.Main
|
ecore.Main
|
||||||
Encounter_Id *uint `json:"encounter_id"`
|
Encounter_Id *uint `json:"encounter_id"`
|
||||||
Encounter *ee.Encounter `json:"encounter,omitempty"`
|
Encounter *ee.Encounter `json:"encounter,omitempty"`
|
||||||
Doctor_Code *string `json:"doctor_code"`
|
Doctor_Code *string `json:"doctor_code"`
|
||||||
Doctor *ed.Doctor `json:"doctor,omitempty"`
|
Doctor *ed.Doctor `json:"doctor,omitempty"`
|
||||||
IssuedAt *time.Time `json:"issuedAt"`
|
IssuedAt *time.Time `json:"issuedAt"`
|
||||||
Status_Code erc.DataStatusCode `json:"status_code"`
|
Status_Code erc.DataStatusCode `json:"status_code"`
|
||||||
|
Items []epi.PrescriptionItem `json:"items" gorm:"foreignKey:Prescription_Id;references:Id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d Prescription) ToResponse() ResponseDto {
|
func (d Prescription) ToResponse() ResponseDto {
|
||||||
@@ -72,6 +74,7 @@ func (d Prescription) ToResponse() ResponseDto {
|
|||||||
Doctor: d.Doctor,
|
Doctor: d.Doctor,
|
||||||
IssuedAt: d.IssuedAt,
|
IssuedAt: d.IssuedAt,
|
||||||
Status_Code: d.Status_Code,
|
Status_Code: d.Status_Code,
|
||||||
|
Items: d.Items,
|
||||||
}
|
}
|
||||||
resp.Main = d.Main
|
resp.Main = d.Main
|
||||||
return resp
|
return resp
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||||
|
epi "simrs-vx/internal/domain/main-entities/prescription-item/base"
|
||||||
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -11,13 +12,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Prescription struct {
|
type Prescription struct {
|
||||||
ecore.Main // adjust this according to the needs
|
ecore.Main // adjust this according to the needs
|
||||||
Encounter_Id *uint `json:"encounter_id"`
|
Encounter_Id *uint `json:"encounter_id"`
|
||||||
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||||
Doctor_Code *string `json:"doctor_code" gorm:"size:20"`
|
Doctor_Code *string `json:"doctor_code" gorm:"size:20"`
|
||||||
Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"`
|
Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"`
|
||||||
IssuedAt *time.Time `json:"issuedAt"`
|
IssuedAt *time.Time `json:"issuedAt"`
|
||||||
Status_Code erc.DataStatusCode `json:"status_code"`
|
Status_Code erc.DataStatusCode `json:"status_code"`
|
||||||
|
Items []epi.PrescriptionItem `json:"items" gorm:"foreignKey:Prescription_Id;references:Id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d Prescription) IsNotNew() bool {
|
func (d Prescription) IsNotNew() bool {
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
dto := e.ReadDetailDto{}
|
dto := e.ReadDetailDto{}
|
||||||
|
sf.UrlQueryParam(&dto, *r.URL)
|
||||||
dto.Id = uint(id)
|
dto.Id = uint(id)
|
||||||
res, err := u.ReadDetail(dto)
|
res, err := u.ReadDetail(dto)
|
||||||
rw.DataResponse(w, res, err)
|
rw.DataResponse(w, res, err)
|
||||||
|
|||||||
@@ -47,13 +47,13 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Pr
|
|||||||
tx = dg.I
|
tx = dg.I
|
||||||
}
|
}
|
||||||
|
|
||||||
tx = tx.
|
tx = tx.Debug().
|
||||||
Model(&e.PrescriptionItem{}).
|
Model(&e.PrescriptionItem{}).
|
||||||
Scopes(gh.Preload(input.Includes)).
|
Scopes(gh.Preload(input.Includes)).
|
||||||
Scopes(gh.Filter(input.FilterDto)).
|
Scopes(gh.Filter(input.FilterDto)).
|
||||||
Count(&count).
|
Count(&count).
|
||||||
Scopes(gh.Paginate(input, &pagination)).
|
Scopes(gh.Paginate(input, &pagination)).
|
||||||
Order("\"CreatedAt\" DESC")
|
Scopes(gh.Sort(input.Sort))
|
||||||
|
|
||||||
if err := tx.Find(&data).Error; err != nil {
|
if err := tx.Find(&data).Error; err != nil {
|
||||||
if err == gorm.ErrRecordNotFound {
|
if err == gorm.ErrRecordNotFound {
|
||||||
|
|||||||
Reference in New Issue
Block a user