Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93c1709af7 |
No files matched your search
File diff suppressed because it is too large
Load diff
@@ -98,16 +98,21 @@ type Patient struct {
|
|||||||
BirthDate sql.NullTime `json:"birth_date,omitempty" db:"birth_date"`
|
BirthDate sql.NullTime `json:"birth_date,omitempty" db:"birth_date"`
|
||||||
Address sql.NullString `json:"address,omitempty" db:"address"`
|
Address sql.NullString `json:"address,omitempty" db:"address"`
|
||||||
Active sql.NullBool `json:"active,omitempty" db:"active"`
|
Active sql.NullBool `json:"active,omitempty" db:"active"`
|
||||||
FKSdProvinsiID models.NullableInt32 `json:"fk_sd_provinsi_id,omitempty" db:"fk_sd_provinsi_id"`
|
FKSdProvinsiID sql.NullInt64 `json:"fk_sd_provinsi_id,omitempty" db:"fk_sd_provinsi_id"`
|
||||||
FKSdKabupatenKotaID models.NullableInt32 `json:"fk_sd_kabupaten_kota_id,omitempty" db:"fk_sd_kabupaten_kota_id"`
|
FKSdKabupatenKotaID sql.NullInt64 `json:"fk_sd_kabupaten_kota_id,omitempty" db:"fk_sd_kabupaten_kota_id"`
|
||||||
FKSdKecamatanID models.NullableInt32 `json:"fk_sd_kecamatan_id,omitempty" db:"fk_sd_kecamatan_id"`
|
FKSdKecamatanID sql.NullInt64 `json:"fk_sd_kecamatan_id,omitempty" db:"fk_sd_kecamatan_id"`
|
||||||
FKSdKelurahanID models.NullableInt32 `json:"fk_sd_kelurahan_id,omitempty" db:"fk_sd_kelurahan_id"`
|
FKSdKelurahanID sql.NullInt64 `json:"fk_sd_kelurahan_id,omitempty" db:"fk_sd_kelurahan_id"`
|
||||||
DsSdProvinsi sql.NullString `json:"ds_sd_provinsi,omitempty" db:"ds_sd_provinsi"`
|
DsSdProvinsi sql.NullString `json:"ds_sd_provinsi,omitempty" db:"ds_sd_provinsi"`
|
||||||
DsSdKabupatenKota sql.NullString `json:"ds_sd_kabupaten_kota,omitempty" db:"ds_sd_kabupaten_kota"`
|
DsSdKabupatenKota sql.NullString `json:"ds_sd_kabupaten_kota,omitempty" db:"ds_sd_kabupaten_kota"`
|
||||||
DsSdKecamatan sql.NullString `json:"ds_sd_kecamatan,omitempty" db:"ds_sd_kecamatan"`
|
DsSdKecamatan sql.NullString `json:"ds_sd_kecamatan,omitempty" db:"ds_sd_kecamatan"`
|
||||||
DsSdKelurahan sql.NullString `json:"ds_sd_kelurahan,omitempty" db:"ds_sd_kelurahan"`
|
DsSdKelurahan sql.NullString `json:"ds_sd_kelurahan,omitempty" db:"ds_sd_kelurahan"`
|
||||||
|
// ProvinsiName sql.NullString `json:"Provinsi,omitempty" db:"Provinsi"`
|
||||||
|
// KabupatenKotaName sql.NullString `json:"Kabupaten_kota,omitempty" db:"Kabupaten_kota"`
|
||||||
|
// KecamatanName sql.NullString `json:"Kecamatan,omitempty" db:"Kecamatan"`
|
||||||
|
// KelurahanName sql.NullString `json:"Desa_kelurahan,omitempty" db:"Desa_kelurahan"`
|
||||||
Attachments []PatientAttachment `json:"attachments,omitempty"`
|
Attachments []PatientAttachment `json:"attachments,omitempty"`
|
||||||
PaymentTypes []PatientPaymentType `json:"payment_types,omitempty"`
|
PaymentTypes []PatientPaymentType `json:"payment_types,omitempty"`
|
||||||
|
Visits []PatientVisit `json:"visits,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PatientPaymentType struct {
|
type PatientPaymentType struct {
|
||||||
@@ -128,6 +133,17 @@ type PatientAttachment struct {
|
|||||||
FKMsPatientID models.NullableInt32 `json:"fk_ms_patient_id,omitempty" db:"fk_ms_patient_id"`
|
FKMsPatientID models.NullableInt32 `json:"fk_ms_patient_id,omitempty" db:"fk_ms_patient_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PatientVisit struct {
|
||||||
|
ID int64 `json:"id" db:"id"`
|
||||||
|
Barcode models.NullableInt32 `json:"barcode,omitempty" db:"barcode"`
|
||||||
|
RegistrationDate sql.NullTime `json:"registration_date,omitempty" db:"registration_date"`
|
||||||
|
ServiceDate sql.NullTime `json:"service_date,omitempty" db:"service_date"`
|
||||||
|
CheckInDate sql.NullTime `json:"check_in_date,omitempty" db:"check_in_date"`
|
||||||
|
CheckIn sql.NullBool `json:"check_in,omitempty" db:"check_in"`
|
||||||
|
Active sql.NullBool `json:"active,omitempty" db:"active"`
|
||||||
|
FKMsPatientID models.NullableInt32 `json:"fk_ms_patient_id,omitempty" db:"fk_ms_patient_id"`
|
||||||
|
}
|
||||||
|
|
||||||
// Custom JSON marshaling untuk Patient agar NULL values tidak muncul di response
|
// Custom JSON marshaling untuk Patient agar NULL values tidak muncul di response
|
||||||
func (r Patient) MarshalJSON() ([]byte, error) {
|
func (r Patient) MarshalJSON() ([]byte, error) {
|
||||||
type Alias Patient
|
type Alias Patient
|
||||||
@@ -139,10 +155,10 @@ func (r Patient) MarshalJSON() ([]byte, error) {
|
|||||||
BirthDate *string `json:"birth_date,omitempty"`
|
BirthDate *string `json:"birth_date,omitempty"`
|
||||||
Address *string `json:"address,omitempty"`
|
Address *string `json:"address,omitempty"`
|
||||||
Active *bool `json:"active,omitempty"`
|
Active *bool `json:"active,omitempty"`
|
||||||
FKSdProvinsiID *int32 `json:"fk_sd_provinsi_id,omitempty"`
|
FKSdProvinsiID *int `json:"fk_sd_provinsi_id,omitempty"`
|
||||||
FKSdKabupatenKotaID *int32 `json:"fk_sd_kabupaten_kota_id,omitempty"`
|
FKSdKabupatenKotaID *int `json:"fk_sd_kabupaten_kota_id,omitempty"`
|
||||||
FKSdKecamatanID *int32 `json:"fk_sd_kecamatan_id,omitempty"`
|
FKSdKecamatanID *int `json:"fk_sd_kecamatan_id,omitempty"`
|
||||||
FKSdKelurahanID *int32 `json:"fk_sd_kelurahan_id,omitempty"`
|
FKSdKelurahanID *int `json:"fk_sd_kelurahan_id,omitempty"`
|
||||||
DsSdProvinsi *string `json:"ds_sd_provinsi,omitempty"`
|
DsSdProvinsi *string `json:"ds_sd_provinsi,omitempty"`
|
||||||
DsSdKabupatenKota *string `json:"ds_sd_kabupaten_kota,omitempty"`
|
DsSdKabupatenKota *string `json:"ds_sd_kabupaten_kota,omitempty"`
|
||||||
DsSdKecamatan *string `json:"ds_sd_kecamatan,omitempty"`
|
DsSdKecamatan *string `json:"ds_sd_kecamatan,omitempty"`
|
||||||
@@ -175,19 +191,19 @@ func (r Patient) MarshalJSON() ([]byte, error) {
|
|||||||
aux.Active = &r.Active.Bool
|
aux.Active = &r.Active.Bool
|
||||||
}
|
}
|
||||||
if r.FKSdProvinsiID.Valid {
|
if r.FKSdProvinsiID.Valid {
|
||||||
fksp := int32(r.FKSdProvinsiID.Int32)
|
fksp := int(r.FKSdProvinsiID.Int64)
|
||||||
aux.FKSdProvinsiID = &fksp
|
aux.FKSdProvinsiID = &fksp
|
||||||
}
|
}
|
||||||
if r.FKSdKabupatenKotaID.Valid {
|
if r.FKSdKabupatenKotaID.Valid {
|
||||||
fksk := int32(r.FKSdKabupatenKotaID.Int32)
|
fksk := int(r.FKSdKabupatenKotaID.Int64)
|
||||||
aux.FKSdKabupatenKotaID = &fksk
|
aux.FKSdKabupatenKotaID = &fksk
|
||||||
}
|
}
|
||||||
if r.FKSdKecamatanID.Valid {
|
if r.FKSdKecamatanID.Valid {
|
||||||
fksc := int32(r.FKSdKecamatanID.Int32)
|
fksc := int(r.FKSdKecamatanID.Int64)
|
||||||
aux.FKSdKecamatanID = &fksc
|
aux.FKSdKecamatanID = &fksc
|
||||||
}
|
}
|
||||||
if r.FKSdKelurahanID.Valid {
|
if r.FKSdKelurahanID.Valid {
|
||||||
fksl := int32(r.FKSdKelurahanID.Int32)
|
fksl := int(r.FKSdKelurahanID.Int64)
|
||||||
aux.FKSdKelurahanID = &fksl
|
aux.FKSdKelurahanID = &fksl
|
||||||
}
|
}
|
||||||
if r.DsSdProvinsi.Valid {
|
if r.DsSdProvinsi.Valid {
|
||||||
@@ -271,6 +287,50 @@ func (r PatientAttachment) MarshalJSON() ([]byte, error) {
|
|||||||
return json.Marshal(aux)
|
return json.Marshal(aux)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r PatientVisit) MarshalJSON() ([]byte, error) {
|
||||||
|
type Alias PatientVisit
|
||||||
|
aux := &struct {
|
||||||
|
*Alias
|
||||||
|
Barcode *int `json:"barcode,omitempty"`
|
||||||
|
RegistrationDate *string `json:"registration_date,omitempty"`
|
||||||
|
ServiceDate *string `json:"service_date,omitempty"`
|
||||||
|
CheckInDate *string `json:"check_in_date,omitempty"`
|
||||||
|
CheckIn *bool `json:"check_in,omitempty"`
|
||||||
|
Active *bool `json:"active,omitempty"`
|
||||||
|
FKMsPatientID *int `json:"fk_ms_patient_id,omitempty"`
|
||||||
|
}{
|
||||||
|
Alias: (*Alias)(&r),
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.Barcode.Valid {
|
||||||
|
barcode := int(r.Barcode.Int32)
|
||||||
|
aux.Barcode = &barcode
|
||||||
|
}
|
||||||
|
if r.RegistrationDate.Valid {
|
||||||
|
regDateStr := r.RegistrationDate.Time.Format(time.RFC3339)
|
||||||
|
aux.RegistrationDate = ®DateStr
|
||||||
|
}
|
||||||
|
if r.ServiceDate.Valid {
|
||||||
|
svcDateStr := r.ServiceDate.Time.Format(time.RFC3339)
|
||||||
|
aux.ServiceDate = &svcDateStr
|
||||||
|
}
|
||||||
|
if r.CheckInDate.Valid {
|
||||||
|
checkInDateStr := r.CheckInDate.Time.Format(time.RFC3339)
|
||||||
|
aux.CheckInDate = &checkInDateStr
|
||||||
|
}
|
||||||
|
if r.CheckIn.Valid {
|
||||||
|
aux.CheckIn = &r.CheckIn.Bool
|
||||||
|
}
|
||||||
|
if r.Active.Valid {
|
||||||
|
aux.Active = &r.Active.Bool
|
||||||
|
}
|
||||||
|
if r.FKMsPatientID.Valid {
|
||||||
|
fkmp := int(r.FKMsPatientID.Int32)
|
||||||
|
aux.FKMsPatientID = &fkmp
|
||||||
|
}
|
||||||
|
return json.Marshal(aux)
|
||||||
|
}
|
||||||
|
|
||||||
// Helper methods untuk mendapatkan nilai yang aman
|
// Helper methods untuk mendapatkan nilai yang aman
|
||||||
func (r *Patient) GetName() string {
|
func (r *Patient) GetName() string {
|
||||||
if r.Name.Valid {
|
if r.Name.Valid {
|
||||||
@@ -303,20 +363,41 @@ type PatientCreateRequest struct {
|
|||||||
BirthDate *time.Time `json:"birth_date"`
|
BirthDate *time.Time `json:"birth_date"`
|
||||||
Address *string `json:"address" validate:"min=1,max=255"`
|
Address *string `json:"address" validate:"min=1,max=255"`
|
||||||
Active *bool `json:"active"`
|
Active *bool `json:"active"`
|
||||||
FKSdProvinsiID *int32 `json:"fk_sd_provinsi_id"`
|
FKSdProvinsiID *int `json:"fk_sd_provinsi_id"`
|
||||||
FKSdKabupatenKotaID *int32 `json:"fk_sd_kabupaten_kota_id"`
|
FKSdKabupatenKotaID *int `json:"fk_sd_kabupaten_kota_id"`
|
||||||
FKSdKecamatanID *int32 `json:"fk_sd_kecamatan_id"`
|
FKSdKecamatanID *int `json:"fk_sd_kecamatan_id"`
|
||||||
FKSdKelurahanID *int32 `json:"fk_sd_kelurahan_id"`
|
FKSdKelurahanID *int `json:"fk_sd_kelurahan_id"`
|
||||||
DsSdProvinsi *string `json:"ds_sd_provinsi" validate:"min=1,max=255"`
|
DsSdProvinsi *string `json:"ds_sd_provinsi"`
|
||||||
DsSdKabupatenKota *string `json:"ds_sd_kabupaten_kota" validate:"min=1,max=255"`
|
DsSdKabupatenKota *string `json:"ds_sd_kabupaten_kota"`
|
||||||
DsSdKecamatan *string `json:"ds_sd_kecamatan" validate:"min=1,max=255"`
|
DsSdKecamatan *string `json:"ds_sd_kecamatan"`
|
||||||
DsSdKelurahan *string `json:"ds_sd_kelurahan" validate:"min=1,max=255"`
|
DsSdKelurahan *string `json:"ds_sd_kelurahan"`
|
||||||
Attachments []PatientAttachmentCreateRequest `json:"attachments,omitempty"`
|
Attachments []PatientAttachmentCreateRequest `json:"attachments,omitempty"`
|
||||||
Payments []PatientPaymentTypeCreateRequest `json:"payment_types,omitempty"`
|
Payments []PatientPaymentTypeCreateRequest `json:"payment_types,omitempty"`
|
||||||
|
Visits []VisitCreateRequest `json:"visits,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type VisitCreateRequest struct {
|
||||||
|
// ID *int `json:"id"`
|
||||||
|
Barcode *int32 `json:"barcode" validate:"omitempty,min=1"`
|
||||||
|
RegistrationDate *time.Time `json:"registration_date" validate:"omitempty"`
|
||||||
|
ServiceDate *time.Time `json:"service_date" validate:"omitempty"`
|
||||||
|
CheckInDate *time.Time `json:"check_in_date" validate:"omitempty"`
|
||||||
|
CheckIn *bool `json:"check_in" validate:"omitempty"`
|
||||||
|
Active *bool `json:"active" validate:"omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type VisitUpdateRequest struct {
|
||||||
|
ID *int `json:"id" validate:"required"`
|
||||||
|
Barcode *int32 `json:"barcode" validate:"omitempty,min=1"`
|
||||||
|
RegistrationDate *time.Time `json:"registration_date" validate:"omitempty"`
|
||||||
|
ServiceDate *time.Time `json:"service_date" validate:"omitempty"`
|
||||||
|
CheckInDate *time.Time `json:"check_in_date" validate:"omitempty"`
|
||||||
|
CheckIn *bool `json:"check_in" validate:"omitempty"`
|
||||||
|
Active *bool `json:"active" validate:"omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PatientPostRequest struct {
|
type PatientPostRequest struct {
|
||||||
// ID int64 `json:"id" validate:"required,min=1"`
|
// ID int64 `json:"id" validate:"required"`
|
||||||
MedicalRecordNumber string `json:"medical_record_number" validate:"required,min=1"`
|
MedicalRecordNumber string `json:"medical_record_number" validate:"required,min=1"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,24 +409,25 @@ type PatientCreateResponse struct {
|
|||||||
|
|
||||||
// Update request
|
// Update request
|
||||||
type PatientUpdateRequest struct {
|
type PatientUpdateRequest struct {
|
||||||
ID *int `json:"-" validate:"required,min=1"`
|
// ID *int `json:"-" validate:"required,min=1"`
|
||||||
Name *string `json:"name" validate:"min=1,max=100"`
|
Name *string `json:"name"`
|
||||||
MedicalRecordNumber *string `json:"medical_record_number" validate:"min=1,max=20"`
|
MedicalRecordNumber *string `json:"medical_record_number" validate:"required,min=1,max=20"`
|
||||||
PhoneNumber *string `json:"phone_number" validate:"min=1,max=20"`
|
PhoneNumber *string `json:"phone_number"`
|
||||||
Gender *string `json:"gender" validate:"max=1"`
|
Gender *string `json:"gender"`
|
||||||
BirthDate *time.Time `json:"birth_date"`
|
BirthDate *time.Time `json:"birth_date"`
|
||||||
Address *string `json:"address" validate:"min=1,max=255"`
|
Address *string `json:"address"`
|
||||||
Active *bool `json:"active"`
|
Active *bool `json:"active"`
|
||||||
FKSdProvinsiID *int32 `json:"fk_sd_provinsi_id"`
|
FKSdProvinsiID *int `json:"fk_sd_provinsi_id"`
|
||||||
FKSdKabupatenKotaID *int32 `json:"fk_sd_kabupaten_kota_id"`
|
FKSdKabupatenKotaID *int `json:"fk_sd_kabupaten_kota_id"`
|
||||||
FKSdKecamatanID *int32 `json:"fk_sd_kecamatan_id"`
|
FKSdKecamatanID *int `json:"fk_sd_kecamatan_id"`
|
||||||
FKSdKelurahanID *int32 `json:"fk_sd_kelurahan_id"`
|
FKSdKelurahanID *int `json:"fk_sd_kelurahan_id"`
|
||||||
DsSdProvinsi *string `json:"ds_sd_provinsi" validate:"max=255"`
|
DsSdProvinsi *string `json:"ds_sd_provinsi"`
|
||||||
DsSdKabupatenKota *string `json:"ds_sd_kabupaten_kota" validate:"max=255"`
|
DsSdKabupatenKota *string `json:"ds_sd_kabupaten_kota"`
|
||||||
DsSdKecamatan *string `json:"ds_sd_kecamatan" validate:"max=255"`
|
DsSdKecamatan *string `json:"ds_sd_kecamatan"`
|
||||||
DsSdKelurahan *string `json:"ds_sd_kelurahan" validate:"max=255"`
|
DsSdKelurahan *string `json:"ds_sd_kelurahan"`
|
||||||
Attachments []PatientAttachmentCreateRequest `json:"attachments,omitempty"`
|
Attachments []PatientAttachmentUpdateRequest `json:"attachments,omitempty"`
|
||||||
Payments []PatientPaymentTypeCreateRequest `json:"payment_types,omitempty"`
|
Payments []PatientPaymentTypeUpdateRequest `json:"payment_types,omitempty"`
|
||||||
|
Visits []VisitUpdateRequest `json:"visits,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PatientAttachmentCreateRequest struct {
|
type PatientAttachmentCreateRequest struct {
|
||||||
@@ -361,7 +443,7 @@ type PatientPaymentTypeCreateRequest struct {
|
|||||||
Name *string `json:"name" validate:"omitempty,min=1,max=20"`
|
Name *string `json:"name" validate:"omitempty,min=1,max=20"`
|
||||||
Number *string `json:"number" validate:"omitempty,min=1,max=20"`
|
Number *string `json:"number" validate:"omitempty,min=1,max=20"`
|
||||||
Active *bool `json:"active" validate:"omitempty"`
|
Active *bool `json:"active" validate:"omitempty"`
|
||||||
FkRefPaymentType *int `json:"fk_ref_payment_type" validate:"omitempty,min=1"`
|
FKRefPaymentType *int `json:"fk_ref_payment_type" validate:"omitempty,min=1"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PatientAttachmentUpdateRequest struct {
|
type PatientAttachmentUpdateRequest struct {
|
||||||
|
|||||||
@@ -195,12 +195,11 @@ func RegisterRoutes(cfg *config.Config) *gin.Engine {
|
|||||||
patientMspatientHandler := patientMspatientHandlers.NewPatientHandler()
|
patientMspatientHandler := patientMspatientHandlers.NewPatientHandler()
|
||||||
patientMspatientGroup := v1.Group("/patient")
|
patientMspatientGroup := v1.Group("/patient")
|
||||||
{
|
{
|
||||||
// patientMspatientGroup.GET("/", patientMspatientHandler.GetMs_patient)
|
patientMspatientGroup.PUT("/:medical_record_number", patientMspatientHandler.UpdatePatient)
|
||||||
// patientMspatientGroup.POST("/", patientMspatientHandler.CreateMs_patient)
|
patientMspatientGroup.DELETE("/:medical_record_number", patientMspatientHandler.DeletePatient)
|
||||||
// patientMspatientGroup.PUT("/:medical_record_number", patientMspatientHandler.UpdateMs_patient)
|
|
||||||
// patientMspatientGroup.DELETE("/:medical_record_number", patientMspatientHandler.DeleteMs_patient)
|
|
||||||
patientMspatientGroup.GET("/", patientMspatientHandler.GetPatient)
|
patientMspatientGroup.GET("/", patientMspatientHandler.GetPatient)
|
||||||
patientMspatientGroup.POST("/detail", patientMspatientHandler.GetPatientByIDPost)
|
patientMspatientGroup.POST("/detail", patientMspatientHandler.GetPatientByMedicalRecordNumberPost)
|
||||||
|
patientMspatientGroup.POST("/", patientMspatientHandler.CreatePatient)
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user