Skip to content

Commit

Permalink
chore: change pubsub to v2, remove encounter check
Browse files Browse the repository at this point in the history
  • Loading branch information
Muchogoc committed Apr 25, 2023
1 parent 0474090 commit b0b755e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 33 deletions.
6 changes: 4 additions & 2 deletions pkg/clinical/infrastructure/services/pubsub/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const (

// TestTopicName is a topic that is used for testing purposes
TestTopicName = "pubsub.testing.topic"

TopicVersion = "v2"
)

// BaseExtension is an interface that represents some methods in base
Expand Down Expand Up @@ -66,7 +68,7 @@ func (ps ServicePubSubMessaging) AddPubSubNamespace(topicName, serviceName strin
serviceName,
topicName,
environment,
common.TopicVersion,
TopicVersion,
)
}

Expand Down Expand Up @@ -102,7 +104,7 @@ func (ps ServicePubSubMessaging) PublishToPubsub(
topicID,
environment,
common.ClinicalServiceName,
common.TopicVersion,
TopicVersion,
payload,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestServicePubSubMessaging_AddPubSubNamespace(t *testing.T) {
common.ClinicalServiceName,
topicName,
environment,
common.TopicVersion,
pubsubmessaging.TopicVersion,
),
wantErr: false,
},
Expand Down
48 changes: 20 additions & 28 deletions pkg/clinical/usecases/clinical/patient.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,6 @@ func (c *UseCasesClinicalImpl) GetMedicalData(ctx context.Context, patientID str
continue
}

if edge.Encounter == nil {
continue
}

if edge.Encounter.ID == nil {
continue
}

if edge.Code == nil {
continue
}
Expand Down Expand Up @@ -217,14 +209,6 @@ func hasNilInObservation(observation *domain.FHIRObservationRelayEdge) bool {
return true
}

if observation.Node.Encounter == nil {
return true
}

if observation.Node.Encounter.ID == nil {
return true
}

return false
}

Expand All @@ -242,11 +226,14 @@ func mapFHIRMedicationStatementToMedicationStatementDTO(fhirAllergyIntolerance *

func mapFHIRAllergyIntoleranceToAllergyIntoleranceDTO(fhirAllergyIntolerance domain.FHIRAllergyIntolerance) *dto.Allergy {
allergyIntolerance := &dto.Allergy{
ID: *fhirAllergyIntolerance.ID,
PatientID: *fhirAllergyIntolerance.Patient.ID,
EncounterID: *fhirAllergyIntolerance.Encounter.ID,
Code: string(fhirAllergyIntolerance.Code.Coding[0].Code),
System: string(*fhirAllergyIntolerance.Code.Coding[0].System),
ID: *fhirAllergyIntolerance.ID,
PatientID: *fhirAllergyIntolerance.Patient.ID,
Code: string(fhirAllergyIntolerance.Code.Coding[0].Code),
System: string(*fhirAllergyIntolerance.Code.Coding[0].System),
}

if fhirAllergyIntolerance.Encounter != nil && fhirAllergyIntolerance.Encounter.ID != nil {
allergyIntolerance.EncounterID = *fhirAllergyIntolerance.Encounter.ID
}

if fhirAllergyIntolerance.OnsetPeriod != nil {
Expand Down Expand Up @@ -322,14 +309,19 @@ func mapFHIRObservationToObservationDTO(fhirObservation *domain.FHIRObservation)
value = fmt.Sprintf("%v - %v", fhirObservation.ValuePeriod.Start, fhirObservation.ValuePeriod.End)
}

return &dto.Observation{
ID: *fhirObservation.ID,
Status: dto.ObservationStatus(*fhirObservation.Status),
Name: fhirObservation.Code.Coding[0].Display,
Value: value,
PatientID: *fhirObservation.Subject.ID,
EncounterID: *fhirObservation.Encounter.ID,
obs := &dto.Observation{
ID: *fhirObservation.ID,
Status: dto.ObservationStatus(*fhirObservation.Status),
Name: fhirObservation.Code.Coding[0].Display,
Value: value,
PatientID: *fhirObservation.Subject.ID,
}

if fhirObservation.Encounter != nil && fhirObservation.Encounter.ID != nil {
obs.EncounterID = *fhirObservation.Encounter.ID
}

return obs
}

// CreatePatient creates a new patient
Expand Down
5 changes: 3 additions & 2 deletions pkg/clinical/usecases/clinical/timeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package clinical
import (
"context"
"fmt"
"github.com/savannahghi/clinical/pkg/clinical/application/common/helpers"
"sync"

linq "github.com/ahmetb/go-linq/v3"
Expand Down Expand Up @@ -125,11 +126,11 @@ func (c *UseCasesClinicalImpl) PatientTimeline(ctx context.Context, patientID st
continue
}

if edge.Node.EffectiveDateTime == nil {
if edge.Node.EffectiveInstant == nil {
continue
}

instant := edge.Node.EffectiveDateTime.AsTime()
instant := helpers.ParseDate(string(*edge.Node.EffectiveInstant))
date, err := scalarutils.NewDate(instant.Day(), int(instant.Month()), instant.Year())

if err != nil {
Expand Down

0 comments on commit b0b755e

Please sign in to comment.