fixing issue optimasi
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"satusehat-rssa/internal/integration"
|
"satusehat-rssa/internal/integration"
|
||||||
"satusehat-rssa/internal/model"
|
"satusehat-rssa/internal/model"
|
||||||
"satusehat-rssa/pkg/common"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
@@ -22,7 +21,6 @@ func (s *SpecimenHandler) CreateSpecimen(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.Identifier = append(req.Identifier, common.GetIdentifier("specimen"))
|
|
||||||
res, err := s.Specimen.CreateSpecimen(req)
|
res, err := s.Specimen.CreateSpecimen(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if res != nil {
|
if res != nil {
|
||||||
@@ -63,7 +61,6 @@ func (s *SpecimenHandler) UpdateSpecimen(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.Id = c.Param("id")
|
req.Id = c.Param("id")
|
||||||
req.Identifier = append(req.Identifier, common.GetIdentifier("specimen"))
|
|
||||||
res, err := s.Specimen.UpdateSpecimen(req)
|
res, err := s.Specimen.UpdateSpecimen(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if res != nil {
|
if res != nil {
|
||||||
|
|||||||
@@ -86,6 +86,10 @@ func (c *CompositionRepository) CreateComposition(req model.CompositionRequest)
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Text: &model.SectionText{
|
||||||
|
Status: "additional",
|
||||||
|
Div: "statis",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
if allergyId != "" {
|
if allergyId != "" {
|
||||||
section.Entry = []model.Reference{
|
section.Entry = []model.Reference{
|
||||||
@@ -344,6 +348,10 @@ func (c *CompositionRepository) CreateComposition(req model.CompositionRequest)
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Text: &model.SectionText{
|
||||||
|
Status: "additional",
|
||||||
|
Div: "statis",
|
||||||
|
},
|
||||||
Entry: entryCondition,
|
Entry: entryCondition,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -365,6 +373,10 @@ func (c *CompositionRepository) CreateComposition(req model.CompositionRequest)
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Text: &model.SectionText{
|
||||||
|
Status: "additional",
|
||||||
|
Div: "statis",
|
||||||
|
},
|
||||||
Entry: entryProcedure,
|
Entry: entryProcedure,
|
||||||
})
|
})
|
||||||
var medication []model.Reference
|
var medication []model.Reference
|
||||||
@@ -562,7 +574,7 @@ func (c *CompositionRepository) setupEncounter(req *model.CompositionRequest, pa
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if encounterExist {
|
if encounterExist && encounterId != "" {
|
||||||
req.Encounter.Reference = "Encounter/" + encounterId
|
req.Encounter.Reference = "Encounter/" + encounterId
|
||||||
} else {
|
} else {
|
||||||
//Buat dulu encounter
|
//Buat dulu encounter
|
||||||
@@ -601,7 +613,7 @@ func (c *CompositionRepository) setupAllergyIntollerance(patient string) string
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if allergyExist {
|
if allergyExist && len(allergyId) > 0 {
|
||||||
return allergyId[0]
|
return allergyId[0]
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
@@ -616,7 +628,7 @@ func (c *CompositionRepository) setupObservation(patient string) []model.Referen
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if observationExist {
|
if observationExist && len(observationId) > 0 {
|
||||||
var references []model.Reference
|
var references []model.Reference
|
||||||
|
|
||||||
for _, id := range observationId {
|
for _, id := range observationId {
|
||||||
@@ -636,7 +648,7 @@ func (c *CompositionRepository) setupClinicalImpression(patient string) string {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if clinicalExist {
|
if clinicalExist && len(clinicalId) > 0 {
|
||||||
return clinicalId[0]
|
return clinicalId[0]
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
@@ -651,7 +663,7 @@ func (c *CompositionRepository) setupGoal(patient string) string {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if goalExist {
|
if goalExist && len(goalId) > 0 {
|
||||||
return goalId[0]
|
return goalId[0]
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
@@ -666,7 +678,7 @@ func (c *CompositionRepository) setupCarePlan(patient string) string {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if careplanExist {
|
if careplanExist && len(careplanId) > 0 {
|
||||||
return careplanId[0]
|
return careplanId[0]
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
@@ -686,7 +698,7 @@ func (c *CompositionRepository) setupServiceRequestCategory(patient string, cate
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if serviceRequestExist {
|
if serviceRequestExist && len(serviceRequestId) > 0 {
|
||||||
return serviceRequestId[0]
|
return serviceRequestId[0]
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
@@ -702,7 +714,7 @@ func (c *CompositionRepository) setupSpecimenCategory(patient string) string {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if specimenExist {
|
if specimenExist && len(specimenId) > 0 {
|
||||||
return specimenId[0]
|
return specimenId[0]
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
@@ -718,7 +730,7 @@ func (c *CompositionRepository) setupImagingStudy(patient string) string {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if imagingExist {
|
if imagingExist && len(imagingId) > 0 {
|
||||||
return imagingId[0]
|
return imagingId[0]
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
@@ -738,7 +750,7 @@ func (c *CompositionRepository) setupObservationCategory(patient string, categor
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if observationExist {
|
if observationExist && len(observationId) > 0 {
|
||||||
return observationId[0]
|
return observationId[0]
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
@@ -758,7 +770,7 @@ func (c *CompositionRepository) setupDiagnosticCategory(patient string, category
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if observationExist {
|
if observationExist && len(observationId) > 0 {
|
||||||
return observationId[0]
|
return observationId[0]
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
@@ -774,7 +786,7 @@ func (c *CompositionRepository) setupCondition(patient string) string {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if conditionExist {
|
if conditionExist && len(conditionId) > 0 {
|
||||||
return conditionId
|
return conditionId
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
@@ -790,7 +802,7 @@ func (c *CompositionRepository) setupProcedure(patient string) string {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if procedureExist {
|
if procedureExist && len(procedureId) > 0 {
|
||||||
return procedureId[0]
|
return procedureId[0]
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
@@ -806,7 +818,7 @@ func (c *CompositionRepository) setupMedicationRequest(patient string) string {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if medicationRequestExist {
|
if medicationRequestExist && len(medicationRequestId) > 0 {
|
||||||
return medicationRequestId[0]
|
return medicationRequestId[0]
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
@@ -822,7 +834,7 @@ func (c *CompositionRepository) setupMedicationDispense(patient string) string {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if medicationDispenseExist {
|
if medicationDispenseExist && len(medicationDispenseId) > 0 {
|
||||||
return medicationDispenseId[0]
|
return medicationDispenseId[0]
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"satusehat-rssa/internal/constant"
|
"satusehat-rssa/internal/constant"
|
||||||
"satusehat-rssa/internal/model"
|
"satusehat-rssa/internal/model"
|
||||||
"satusehat-rssa/pkg/httputil"
|
"satusehat-rssa/pkg/httputil"
|
||||||
@@ -93,6 +94,12 @@ func (s *SpecimenRepository) CreateSpecimen(req model.SpecimenRequest) (map[stri
|
|||||||
var data map[string]interface{}
|
var data map[string]interface{}
|
||||||
|
|
||||||
req.ResourceType = constant.SpecimenResourceType
|
req.ResourceType = constant.SpecimenResourceType
|
||||||
|
req.Identifier = []model.IdentifierSpecimen{}
|
||||||
|
req.Identifier = append(req.Identifier, model.IdentifierSpecimen{
|
||||||
|
System: "http://sys-ids.kemkes.go.id/specimen/" + os.Getenv("ORGANIZATION_ID"), // Set this if needed, or remove if not present in IdentifierObject
|
||||||
|
Value: "00001",
|
||||||
|
Assigner: model.AssignerSpecimen{Reference: "Organization/" + os.Getenv("ORGANIZATION_ID")},
|
||||||
|
})
|
||||||
// Setup Patient
|
// Setup Patient
|
||||||
var patient string
|
var patient string
|
||||||
if req.Subject.Reference != "" {
|
if req.Subject.Reference != "" {
|
||||||
@@ -287,6 +294,12 @@ func (s *SpecimenRepository) HandleCheckSpecimen(id string) ([]string, bool, err
|
|||||||
|
|
||||||
func (s *SpecimenRepository) UpdateSpecimen(req model.SpecimenRequest) (map[string]interface{}, error) {
|
func (s *SpecimenRepository) UpdateSpecimen(req model.SpecimenRequest) (map[string]interface{}, error) {
|
||||||
req.ResourceType = constant.SpecimenResourceType
|
req.ResourceType = constant.SpecimenResourceType
|
||||||
|
req.Identifier = []model.IdentifierSpecimen{}
|
||||||
|
req.Identifier = append(req.Identifier, model.IdentifierSpecimen{
|
||||||
|
System: "http://sys-ids.kemkes.go.id/specimen/" + os.Getenv("ORGANIZATION_ID"), // Set this if needed, or remove if not present in IdentifierObject
|
||||||
|
Value: "00001",
|
||||||
|
Assigner: model.AssignerSpecimen{Reference: "Organization/" + os.Getenv("ORGANIZATION_ID")},
|
||||||
|
})
|
||||||
// Setup Patient
|
// Setup Patient
|
||||||
var patient string
|
var patient string
|
||||||
if req.Subject.Reference != "" {
|
if req.Subject.Reference != "" {
|
||||||
|
|||||||
+20
-10
@@ -1,16 +1,16 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
type SpecimenRequest struct {
|
type SpecimenRequest struct {
|
||||||
Id string `json:"id,omitempty"`
|
Id string `json:"id,omitempty"`
|
||||||
ResourceType string `json:"resourceType"`
|
ResourceType string `json:"resourceType"`
|
||||||
Identifier []Identifier `json:"identifier"`
|
Identifier []IdentifierSpecimen `json:"identifier"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Type SpecimenType `json:"type"`
|
Type SpecimenType `json:"type"`
|
||||||
Collection SpecimenCollection `json:"collection"`
|
Collection SpecimenCollection `json:"collection"`
|
||||||
Subject Reference `json:"subject"`
|
Subject Reference `json:"subject"`
|
||||||
Request []Reference `json:"request"`
|
Request []Reference `json:"request"`
|
||||||
ReceivedTime string `json:"receivedTime"`
|
ReceivedTime string `json:"receivedTime"`
|
||||||
Extension []SpecimenExtension `json:"extension"`
|
Extension []SpecimenExtension `json:"extension"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SpecimenType struct {
|
type SpecimenType struct {
|
||||||
@@ -31,3 +31,13 @@ type SpecimenExtension struct {
|
|||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
ValueDateTime string `json:"valueDateTime,omitempty"`
|
ValueDateTime string `json:"valueDateTime,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IdentifierSpecimen struct {
|
||||||
|
Value string `json:"value,omitempty"`
|
||||||
|
System string `json:"system,omitempty"`
|
||||||
|
Assigner AssignerSpecimen `json:"assigner"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AssignerSpecimen struct {
|
||||||
|
Reference string `json:"reference"`
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user