Merge pull request #186 from dikstub-rssa/feat/sync-vanili
Feat/sync vanili
This commit is contained in:
@@ -15,7 +15,7 @@ type Patient struct {
|
||||
RegisteredAt *time.Time `json:"registeredAt"`
|
||||
RegisteredBy_User_Name *string `json:"registeredBy_user_name" gorm:"size:100"`
|
||||
Status_Code erc.ActiveStatusCode `json:"status_code" gorm:"not null;size:10"`
|
||||
Number *string `json:"number" gorm:"unique;size:15"`
|
||||
Number *string `json:"number" gorm:"size:15;unique"`
|
||||
Parent_Number *string `json:"parent_number"`
|
||||
Parent *Patient `json:"parent,omitempty" gorm:"foreignKey:Parent_Number;references:Number"`
|
||||
}
|
||||
|
||||
@@ -11,29 +11,29 @@ type TDiagnosaDanTerapi struct {
|
||||
GolonganDarah string `json:"golongan_darah" gorm:"column:golongan_darah"`
|
||||
TinggiBadan float64 `json:"tinggi_badan" gorm:"column:tinggi_badan"`
|
||||
BeratBadan float64 `json:"berat_badan" gorm:"column:berat_badan"`
|
||||
Diagnosa string `json:"diagnosa" gorm:"column:diagnosa"`
|
||||
Komplikasi string `json:"komplikasi" gorm:"column:komplikasi"`
|
||||
Terapi string `json:"terapi" gorm:"column:terapi"`
|
||||
Anamnesa string `json:"anamnesa" gorm:"column:anamnesa"`
|
||||
Diagnosa *string `json:"diagnosa" gorm:"column:diagnosa"`
|
||||
Komplikasi *string `json:"komplikasi" gorm:"column:komplikasi"`
|
||||
Terapi *string `json:"terapi" gorm:"column:terapi"`
|
||||
Anamnesa *string `json:"anamnesa" gorm:"column:anamnesa"`
|
||||
Kdpoly uint `json:"kdpoly" gorm:"column:kdpoly"`
|
||||
Kddokter uint `json:"kddokter" gorm:"column:kddokter"`
|
||||
Kdtujuanrujuk uint `json:"kdtujuanrujuk" gorm:"column:kdtujuanrujuk"`
|
||||
Kdtujuanrujuk *uint `json:"kdtujuanrujuk" gorm:"column:kdtujuanrujuk"`
|
||||
Nip string `json:"nip" gorm:"column:nip"`
|
||||
IcdCode string `json:"icd_code" gorm:"column:icd_code"`
|
||||
IcdCode *string `json:"icd_code" gorm:"column:icd_code"`
|
||||
KunjunganBl uint `json:"kunjungan_bl" gorm:"column:kunjungan_bl"`
|
||||
KasusBl uint `json:"kasus_bl" gorm:"column:kasus_bl"`
|
||||
Icdcm string `json:"icdcm" gorm:"column:icdcm"`
|
||||
Icd9 string `json:"icd_9" gorm:"column:icd_9"`
|
||||
Klb uint `json:"klb" gorm:"column:klb"`
|
||||
Bedah uint `json:"bedah" gorm:"column:bedah"`
|
||||
Jenis uint `json:"jenis" gorm:"column:jenis"`
|
||||
Perawat string `json:"perawat" gorm:"column:perawat"`
|
||||
Status string `json:"status" gorm:"column:status"`
|
||||
PemeriksaanFisik string `json:"pemeriksaan_fisik" gorm:"column:pemeriksaan_fisik"`
|
||||
RiwayatPasien string `json:"riwayat_pasien" gorm:"column:riwayat_pasien"`
|
||||
TindakanMedis string `json:"tindakan_medis" gorm:"column:tindakan_medis"`
|
||||
Icdcm *string `json:"icdcm" gorm:"column:icdcm"`
|
||||
Icd9 *string `json:"icd_9" gorm:"column:icd_9"`
|
||||
Klb *uint `json:"klb" gorm:"column:klb"`
|
||||
Bedah *uint `json:"bedah" gorm:"column:bedah"`
|
||||
Jenis *uint `json:"jenis" gorm:"column:jenis"`
|
||||
Perawat *string `json:"perawat" gorm:"column:perawat"`
|
||||
Status *string `json:"status" gorm:"column:status"`
|
||||
PemeriksaanFisik *string `json:"pemeriksaan_fisik" gorm:"column:pemeriksaan_fisik"`
|
||||
RiwayatPasien *string `json:"riwayat_pasien" gorm:"column:riwayat_pasien"`
|
||||
TindakanMedis *string `json:"tindakan_medis" gorm:"column:tindakan_medis"`
|
||||
Rajal uint `json:"rajal" gorm:"column:rajal"`
|
||||
UserBatal string `json:"user_batal" gorm:"column:user_batal"`
|
||||
UserBatal *string `json:"user_batal" gorm:"column:user_batal"`
|
||||
TglBatal *time.Time `json:"tgl_batal" gorm:"column:tgl_batal"`
|
||||
SudahVaksin string `json:"sudah_vaksin" gorm:"column:sudah_vaksin"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"column:created_at"`
|
||||
@@ -41,7 +41,7 @@ type TDiagnosaDanTerapi struct {
|
||||
Pernapasan string `json:"pernapasan" gorm:"column:pernapasan"`
|
||||
Suhu string `json:"suhu" gorm:"column:suhu"`
|
||||
Sp02 string `json:"sp02" gorm:"column:sp02"`
|
||||
TujuanPerawatan string `json:"tujuan_perawatan" gorm:"column:tujuan_perawatan"`
|
||||
TujuanPerawatan *string `json:"tujuan_perawatan" gorm:"column:tujuan_perawatan"`
|
||||
TargetCapaian string `json:"target_capaian" gorm:"column:target_capaian"`
|
||||
}
|
||||
|
||||
|
||||
@@ -7,15 +7,15 @@ type TIcdCm struct {
|
||||
Nomr string `json:"nomr" gorm:"column:nomr"`
|
||||
Idxdaftar uint `json:"idxdaftar" gorm:"column:idxdaftar"`
|
||||
Kddokter uint `json:"kddokter" gorm:"column:kddokter"`
|
||||
Icd string `json:"icd" gorm:"column:icd"`
|
||||
IcdVerified string `json:"icd_verified" gorm:"column:icd_verified"`
|
||||
Icd *string `json:"icd" gorm:"column:icd"`
|
||||
IcdVerified *string `json:"icd_verified" gorm:"column:icd_verified"`
|
||||
StatusRajal uint16 `json:"status_rajal" gorm:"column:status_rajal"`
|
||||
Tanggal time.Time `json:"tanggal" gorm:"column:tanggal"`
|
||||
StatusVerif uint16 `json:"status_verif" gorm:"column:status_verif"`
|
||||
IcdVerifiedOrder uint16 `json:"icd_verified_order" gorm:"column:icd_verified_order"`
|
||||
IcdVerifBy string `json:"icd_verif_by" gorm:"column:icd_verif_by"`
|
||||
StatusVerif *uint16 `json:"status_verif" gorm:"column:status_verif"`
|
||||
IcdVerifiedOrder *uint16 `json:"icd_verified_order" gorm:"column:icd_verified_order"`
|
||||
IcdVerifBy *string `json:"icd_verif_by" gorm:"column:icd_verif_by"`
|
||||
IcdVerifDate *time.Time `json:"icd_verif_date" gorm:"column:icd_verif_date"`
|
||||
IcdActive uint16 `json:"icd_active" gorm:"column:icd_active"`
|
||||
IcdActive *uint16 `json:"icd_active" gorm:"column:icd_active"`
|
||||
}
|
||||
|
||||
func (TIcdCm) TableName() string {
|
||||
|
||||
@@ -8,15 +8,15 @@ type TIcd struct {
|
||||
Idxdaftar uint `json:"idxdaftar" gorm:"column:idxdaftar"`
|
||||
Kddokter uint `json:"kddokter" gorm:"column:kddokter"`
|
||||
Icd string `json:"icd" gorm:"column:icd"`
|
||||
IcdVerified string `json:"icd_verified" gorm:"column:icd_verified"`
|
||||
IcdVerified *string `json:"icd_verified" gorm:"column:icd_verified"`
|
||||
StatusRajal uint16 `json:"status_rajal" gorm:"column:status_rajal"`
|
||||
Tanggal time.Time `json:"tanggal" gorm:"column:tanggal"`
|
||||
StatusVerif uint16 `json:"status_verif" gorm:"column:status_verif"`
|
||||
IcdVerifiedOrder uint16 `json:"icd_verified_order" gorm:"column:icd_verified_order"`
|
||||
IcdVerifBy string `json:"icd_verif_by" gorm:"column:icd_verif_by"`
|
||||
StatusVerif *uint16 `json:"status_verif" gorm:"column:status_verif"`
|
||||
IcdVerifiedOrder *uint16 `json:"icd_verified_order" gorm:"column:icd_verified_order"`
|
||||
IcdVerifBy *string `json:"icd_verif_by" gorm:"column:icd_verif_by"`
|
||||
IcdVerifDate *time.Time `json:"icd_verif_date" gorm:"column:icd_verif_date"`
|
||||
IcdActive uint16 `json:"icd_active" gorm:"column:icd_active"`
|
||||
StSebabMati uint16 `json:"st_sebab_mati" gorm:"column:st_sebab_mati"`
|
||||
IcdActive *uint16 `json:"icd_active" gorm:"column:icd_active"`
|
||||
StSebabMati *uint16 `json:"st_sebab_mati" gorm:"column:st_sebab_mati"`
|
||||
}
|
||||
|
||||
func (TIcd) TableName() string {
|
||||
|
||||
@@ -51,7 +51,7 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
||||
// get detail for sync
|
||||
soapiData, err := ReadDetailData(e.ReadDetailDto{
|
||||
Id: data.Id,
|
||||
Includes: "Encounter,Employee"}, &event)
|
||||
Includes: "Encounter,Employee.User"}, &event, tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
||||
mwRunner.setMwType(pu.MWTPre)
|
||||
// Run pre-middleware
|
||||
if err = mwRunner.ExecuteIfSyncOn(func() error {
|
||||
return mwRunner.RunCreateMiddleware(createPostMw, soapiData)
|
||||
return mwRunner.RunCreateMiddleware(createPreMw, soapiData)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import plugin "simrs-vx/internal/use-case/simgos-sync-plugin/new/soapi"
|
||||
|
||||
func init() {
|
||||
createPreMw = append(createPreMw,
|
||||
createMw{Name: "sync-update-soapi", Func: plugin.Create})
|
||||
createMw{Name: "sync-create-soapi", Func: plugin.Create})
|
||||
|
||||
createSimxLogMw = append(createSimxLogMw,
|
||||
createLogMw{Name: "create-sync-log", Func: plugin.CreateLog})
|
||||
|
||||
@@ -32,5 +32,5 @@ func Delete(input *e.DeleteDto) error {
|
||||
}
|
||||
|
||||
func getPrefixEndpoint() string {
|
||||
return fmt.Sprintf("%s%s/v1/encounter", sync.O.TargetHost, sync.O.Prefix)
|
||||
return fmt.Sprintf("%s%s/v1/soapi", sync.O.TargetHost, sync.O.Prefix)
|
||||
}
|
||||
|
||||
@@ -135,6 +135,11 @@ func Update(input e.Encounter) (*d.Data, error) {
|
||||
|
||||
tx := db.NewTx()
|
||||
err = tx.Simgos.Transaction(func(tx *gorm.DB) error {
|
||||
// SET LOCAL
|
||||
if err = tx.Exec(`SET LOCAL simx.sync_source = 'new'`).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Step 2: Update Simgos
|
||||
if err = UpdateTPendaftaranData(input, simgos, "update", &event, tx); err != nil {
|
||||
return err
|
||||
@@ -238,6 +243,11 @@ func CheckIn(input e.Encounter) (*d.Data, error) {
|
||||
|
||||
tx := db.NewTx()
|
||||
err = tx.Simgos.Transaction(func(tx *gorm.DB) error {
|
||||
// SET LOCAL
|
||||
if err = tx.Exec(`SET LOCAL simx.sync_source = 'new'`).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Step 2: Update Simgos
|
||||
if err = UpdateTPendaftaranData(input, simgos, "check-in", &event, tx); err != nil {
|
||||
return err
|
||||
@@ -280,6 +290,11 @@ func CheckOut(input e.Encounter) (*d.Data, error) {
|
||||
|
||||
tx := db.NewTx()
|
||||
err = tx.Simgos.Transaction(func(tx *gorm.DB) error {
|
||||
// SET LOCAL
|
||||
if err = tx.Exec(`SET LOCAL simx.sync_source = 'new'`).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Step 2: Update Simgos
|
||||
if err = UpdateTPendaftaranData(input, simgos, "check-out", &event, tx); err != nil {
|
||||
return err
|
||||
@@ -322,6 +337,11 @@ func UpdateStatus(input e.Encounter) (*d.Data, error) {
|
||||
|
||||
tx := db.NewTx()
|
||||
err = tx.Simgos.Transaction(func(tx *gorm.DB) error {
|
||||
// SET LOCAL
|
||||
if err = tx.Exec(`SET LOCAL simx.sync_source = 'new'`).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Step 2: Update TPendaftaran
|
||||
if err = UpdateTPendaftaranData(input, simgos, "update-status", &event, tx); err != nil {
|
||||
return err
|
||||
@@ -434,6 +454,11 @@ func ApproveSwitchUnit(input e.ApproveCancelUnitDto) (*d.Data, error) {
|
||||
|
||||
tx := db.NewTx()
|
||||
err = tx.Simgos.Transaction(func(tx *gorm.DB) error {
|
||||
// SET LOCAL
|
||||
if err = tx.Exec(`SET LOCAL simx.sync_source = 'new'`).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Step 3: Update TPemeriksaanHist
|
||||
if err := utph.UpdateSimgosData(input, tPemeriksaanHist, "approve", &event, tx); err != nil {
|
||||
return err
|
||||
@@ -476,6 +501,11 @@ func CancelSwitchUnit(input e.ApproveCancelUnitDto) (*d.Data, error) {
|
||||
|
||||
tx := db.NewTx()
|
||||
err = tx.Simgos.Transaction(func(tx *gorm.DB) error {
|
||||
// SET LOCAL
|
||||
if err = tx.Exec(`SET LOCAL simx.sync_source = 'new'`).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Step 3: Update TPemeriksaanHist
|
||||
if err := utph.UpdateSimgosData(input, tPemeriksaanHist, "cancel", &event, tx); err != nil {
|
||||
return err
|
||||
|
||||
@@ -122,6 +122,11 @@ func Update(input e.Patient) (*d.Data, error) {
|
||||
|
||||
tx := db.NewTx()
|
||||
err = tx.Simgos.Transaction(func(tx *gorm.DB) error {
|
||||
// SET LOCAL
|
||||
if err = tx.Exec(`SET LOCAL simx.sync_source = 'new'`).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Step 3: Update Simgos
|
||||
if err = UpdateSimgosData(input, patientData, &event, tx); err != nil {
|
||||
return err
|
||||
|
||||
@@ -66,16 +66,16 @@ func setEarlyMedicTDT(input es.Soapi, data *etdt.TDiagnosaDanTerapi) {
|
||||
|
||||
data.TinggiBadan = float64(value.Height)
|
||||
data.BeratBadan = float64(value.Weight)
|
||||
data.Diagnosa = value.EarlyMedicDiagnose
|
||||
data.Terapi = value.Therapy
|
||||
data.Anamnesa = value.PrimaryComplain
|
||||
data.Diagnosa = &value.EarlyMedicDiagnose
|
||||
data.Terapi = &value.Therapy
|
||||
data.Anamnesa = &value.PrimaryComplain
|
||||
|
||||
// TODO : status, tindakan_mdeis (?)
|
||||
data.KunjunganBl = uint(value.EncounterStatus)
|
||||
data.KasusBl = uint(value.CaseStatus)
|
||||
|
||||
data.PemeriksaanFisik = value.PhysicalExamination
|
||||
data.RiwayatPasien = value.CurrentDiseaseHistory
|
||||
data.PemeriksaanFisik = &value.PhysicalExamination
|
||||
data.RiwayatPasien = &value.CurrentDiseaseHistory
|
||||
|
||||
if value.Vaccinated {
|
||||
data.SudahVaksin = "YA"
|
||||
@@ -93,7 +93,8 @@ func setEarlyMedicTDT(input es.Soapi, data *etdt.TDiagnosaDanTerapi) {
|
||||
for _, v := range o {
|
||||
expectedOutput = append(expectedOutput, v.Name)
|
||||
}
|
||||
jsonData, _ := json.MarshalIndent(value.ExpectedOutcome, "", " ")
|
||||
|
||||
jsonData, _ := json.Marshal(expectedOutput)
|
||||
data.TargetCapaian = string(jsonData)
|
||||
}
|
||||
return
|
||||
@@ -155,7 +156,7 @@ func setDataIcdCm(input es.Soapi, enc *etp.TPendaftaran) (data []eicdcm.TIcdCm)
|
||||
Nomr: enc.Nomr,
|
||||
Idxdaftar: enc.Idxdaftar,
|
||||
Kddokter: enc.Kddokter,
|
||||
Icd: v.Code,
|
||||
Icd: &v.Code,
|
||||
StatusRajal: ambulatory,
|
||||
Tanggal: visitDate,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user