feat/things-munaja: adjust prescription
This commit is contained in:
@@ -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
|
||||
Includes string `json:"includes"`
|
||||
Pagination ecore.Pagination
|
||||
Sort string `json:"sort"`
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
|
||||
@@ -2,26 +2,12 @@ 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"
|
||||
ep "simrs-vx/internal/domain/main-entities/prescription"
|
||||
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
epib "simrs-vx/internal/domain/main-entities/prescription-item/base"
|
||||
)
|
||||
|
||||
type PrescriptionItem struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
Prescription_Id *uint `json:"prescription_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"`
|
||||
ecore.Main // adjust this according to the needs
|
||||
epib.PrescriptionItem
|
||||
Prescription *ep.Prescription `json:"prescription,omitempty" gorm:"foreignKey:Prescription_Id;references:Id"`
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
epi "simrs-vx/internal/domain/main-entities/prescription-item/base"
|
||||
|
||||
pa "simrs-vx/internal/lib/auth"
|
||||
|
||||
@@ -56,12 +57,13 @@ type MetaDto struct {
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.Main
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty"`
|
||||
Doctor_Code *string `json:"doctor_code"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty"`
|
||||
IssuedAt *time.Time `json:"issuedAt"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code"`
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty"`
|
||||
Doctor_Code *string `json:"doctor_code"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty"`
|
||||
IssuedAt *time.Time `json:"issuedAt"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code"`
|
||||
Items []epi.PrescriptionItem `json:"items" gorm:"foreignKey:Prescription_Id;references:Id"`
|
||||
}
|
||||
|
||||
func (d Prescription) ToResponse() ResponseDto {
|
||||
@@ -72,6 +74,7 @@ func (d Prescription) ToResponse() ResponseDto {
|
||||
Doctor: d.Doctor,
|
||||
IssuedAt: d.IssuedAt,
|
||||
Status_Code: d.Status_Code,
|
||||
Items: d.Items,
|
||||
}
|
||||
resp.Main = d.Main
|
||||
return resp
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
ed "simrs-vx/internal/domain/main-entities/doctor"
|
||||
ee "simrs-vx/internal/domain/main-entities/encounter"
|
||||
epi "simrs-vx/internal/domain/main-entities/prescription-item/base"
|
||||
|
||||
"time"
|
||||
|
||||
@@ -11,13 +12,14 @@ import (
|
||||
)
|
||||
|
||||
type Prescription struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
Doctor_Code *string `json:"doctor_code" gorm:"size:20"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"`
|
||||
IssuedAt *time.Time `json:"issuedAt"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code"`
|
||||
ecore.Main // adjust this according to the needs
|
||||
Encounter_Id *uint `json:"encounter_id"`
|
||||
Encounter *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
|
||||
Doctor_Code *string `json:"doctor_code" gorm:"size:20"`
|
||||
Doctor *ed.Doctor `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"`
|
||||
IssuedAt *time.Time `json:"issuedAt"`
|
||||
Status_Code erc.DataStatusCode `json:"status_code"`
|
||||
Items []epi.PrescriptionItem `json:"items" gorm:"foreignKey:Prescription_Id;references:Id"`
|
||||
}
|
||||
|
||||
func (d Prescription) IsNotNew() bool {
|
||||
|
||||
@@ -46,6 +46,7 @@ func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
dto := e.ReadDetailDto{}
|
||||
sf.UrlQueryParam(&dto, *r.URL)
|
||||
dto.Id = uint(id)
|
||||
res, err := u.ReadDetail(dto)
|
||||
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 = tx.
|
||||
tx = tx.Debug().
|
||||
Model(&e.PrescriptionItem{}).
|
||||
Scopes(gh.Preload(input.Includes)).
|
||||
Scopes(gh.Filter(input.FilterDto)).
|
||||
Count(&count).
|
||||
Scopes(gh.Paginate(input, &pagination)).
|
||||
Order("\"CreatedAt\" DESC")
|
||||
Scopes(gh.Sort(input.Sort))
|
||||
|
||||
if err := tx.Find(&data).Error; err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
|
||||
Reference in New Issue
Block a user