Skip to content

Commit

Permalink
feat: create FHIR allergy intolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
Salaton committed Mar 25, 2022
1 parent a019ae4 commit dd844db
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
runs-on: ${{ matrix.os }}
timeout-minutes: 80
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: google-github-actions/setup-gcloud@v0
with:
project_id: ${{ secrets.GOOGLE_CLOUD_PROJECT }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
language: ["go"]
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
environment:
name: test # run this only in test environment for now
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@v0
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
needs: [build_and_push_image]
steps:
- name: Checkout working branches
uses: actions/checkout@v2
uses: actions/checkout@v3

# Deploy to Google Cloud Run Serverless
- name: Get GCP project credential
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
needs: [build_and_push_image]
steps:
- name: Checkout working branches
uses: actions/checkout@v2
uses: actions/checkout@v3

# Deploy to Google Cloud Run Serverless
- name: Get GCP project credential
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
needs: [build_and_push_image]
steps:
- name: Checkout working branches
uses: actions/checkout@v2
uses: actions/checkout@v3

# Deploy to Google Cloud Run Serverless
- name: Get GCP project credential
Expand Down Expand Up @@ -210,7 +210,7 @@ jobs:
needs: [deploy_to_test]
steps:
- name: Checkout working branches
uses: actions/checkout@v2
uses: actions/checkout@v3

# Install Go
- name: Install Go
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gitguardian.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0 # fetch all history so multiple commits can be scanned
- name: GitGuardian scan
Expand Down
23 changes: 23 additions & 0 deletions pkg/clinical/application/dto/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,26 @@ type CreateVitalSignPubSubMessage struct {
Value string `json:"value"`
Date time.Time `json:"date"`
}

// CreatePatientAllergyPubSubMessage contains allergy details for a patient
type CreatePatientAllergyPubSubMessage struct {
PatientID string `json:"patientID"`
OrganizationID string `json:"organizationID"`
Name string `json:"name"`
ConceptID *string `json:"conceptID"`
Date time.Time `json:"date"`
Reaction AllergyReaction `json:"reaction"`
Severity AllergySeverity `json:"severity"`
}

// AllergyReaction ...
type AllergyReaction struct {
Name string `json:"name"`
ConceptID *string `json:"conceptID"`
}

// AllergySeverity ...
type AllergySeverity struct {
Name string `json:"name"`
ConceptID *string `json:"conceptID"`
}
108 changes: 107 additions & 1 deletion pkg/clinical/infrastructure/services/pubsub/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (ps ServicePubSubMessaging) ReceivePubSubPushMessages(

value, _ := strconv.ParseFloat(data.Value, 64)
system := "http://terminology.hl7.org/CodeSystem/observation-category"
subjectReference := fmt.Sprintf("patient/%v", data.PatientID)
subjectReference := fmt.Sprintf("Patient/%v", data.PatientID)
status := domain.ObservationStatusEnumPreliminary
input := domain.FHIRObservationInput{
Status: &status,
Expand Down Expand Up @@ -220,6 +220,112 @@ func (ps ServicePubSubMessaging) ReceivePubSubPushMessages(
}, http.StatusBadRequest)
return
}

case ps.AddPubSubNamespace(common.AllergyTopicName, ClinicalServiceName):
var data dto.CreatePatientAllergyPubSubMessage
err := json.Unmarshal(message.Message.Data, &data)
if err != nil {
serverutils.WriteJSONResponse(w, errorcodeutil.CustomError{
Err: err,
Message: err.Error(),
}, http.StatusBadRequest)
return
}

response, err := ps.ocl.GetConcept(
ctx,
"CIEL",
"CIEL",
*data.ConceptID,
false,
false,
)
if err != nil {
serverutils.WriteJSONResponse(w, errorcodeutil.CustomError{
Err: err,
Message: err.Error(),
}, http.StatusBadRequest)
return
}

var ConceptPayload domain.Concept
err = mapstructure.Decode(response, &ConceptPayload)
if err != nil {
serverutils.WriteJSONResponse(w, errorcodeutil.CustomError{
Err: err,
Message: err.Error(),
}, http.StatusBadRequest)
return
}

allergyType := domain.AllergyIntoleranceTypeEnumAllergy
allergyCategory := domain.AllergyIntoleranceCategoryEnumMedication
year, month, day := data.Date.Date()
subjectReference := fmt.Sprintf("Patient/%v", data.PatientID)
severity := data.Severity.Name
input := domain.FHIRAllergyIntoleranceInput{
Type: &allergyType,
RecordedDate: &scalarutils.Date{
Year: year,
Month: int(month),
Day: day,
},
Category: []*domain.AllergyIntoleranceCategoryEnum{&allergyCategory},
ClinicalStatus: domain.FHIRCodeableConceptInput{
Coding: []*domain.FHIRCodingInput{
{
System: (*scalarutils.URI)(&ConceptPayload.URL),
Code: scalarutils.Code(ConceptPayload.ID),
Display: ConceptPayload.DisplayName,
},
},
Text: ConceptPayload.DisplayName,
},
VerificationStatus: domain.FHIRCodeableConceptInput{},
Patient: &domain.FHIRReferenceInput{
Reference: &subjectReference,
Display: data.PatientID,
},
Reaction: []*domain.FHIRAllergyintoleranceReactionInput{
{
Substance: &domain.FHIRCodeableConceptInput{
// TODO: Change this to the reaction coding
Coding: []*domain.FHIRCodingInput{
{
System: (*scalarutils.URI)(&ConceptPayload.URL),
Code: scalarutils.Code(ConceptPayload.ID),
Display: ConceptPayload.DisplayName,
},
},
Text: ConceptPayload.DisplayName,
},
Manifestation: []*domain.FHIRCodeableConceptInput{
{
Coding: []*domain.FHIRCodingInput{
{
System: (*scalarutils.URI)(&ConceptPayload.URL),
Code: "512",
Display: "Rash",
},
},
Text: "Rash",
},
},
Description: &data.Name,
Severity: (*domain.AllergyIntoleranceReactionSeverityEnum)(&severity),
},
},
}

_, err = ps.fhir.CreateFHIRAllergyIntolerance(ctx, input)
if err != nil {
serverutils.WriteJSONResponse(w, errorcodeutil.CustomError{
Err: err,
Message: err.Error(),
}, http.StatusBadRequest)
return
}

}

resp := map[string]string{"Status": "Success"}
Expand Down

0 comments on commit dd844db

Please sign in to comment.