Skip to content

Commit

Permalink
chore: add graphql medication statement and medication types
Browse files Browse the repository at this point in the history
  • Loading branch information
Muchogoc committed Mar 29, 2022
1 parent b5ad947 commit 2f211d8
Show file tree
Hide file tree
Showing 7 changed files with 4,496 additions and 692 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
cloud.google.com/go/pubsub v1.19.0
cloud.google.com/go/trace v1.2.0 // indirect
firebase.google.com/go v3.13.0+incompatible
github.com/99designs/gqlgen v0.13.0
github.com/99designs/gqlgen v0.14.0
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
github.com/aws/aws-sdk-go v1.40.0 // indirect
github.com/brianvoe/gofakeit v3.18.0+incompatible
Expand Down Expand Up @@ -38,7 +38,7 @@ require (
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.7.0
github.com/tj/assert v0.0.3
github.com/vektah/gqlparser/v2 v2.1.0
github.com/vektah/gqlparser/v2 v2.2.0
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
google.golang.org/api v0.70.0
gopkg.in/yaml.v2 v2.4.0
Expand Down
12 changes: 10 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ contrib.go.opencensus.io/exporter/stackdriver v0.13.8/go.mod h1:huNtlWx75MwO7qMs
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
firebase.google.com/go v3.13.0+incompatible h1:3TdYC3DDi6aHn20qoRkxwGqNgdjtblwVAyRLQwGn/+4=
firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIwjt8toICdV5Wh9ptHs=
github.com/99designs/gqlgen v0.13.0 h1:haLTcUp3Vwp80xMVEg5KRNwzfUrgFdRmtBY8fuB8scA=
github.com/99designs/gqlgen v0.13.0/go.mod h1:NV130r6f4tpRWuAI+zsrSdooO/eWUv+Gyyoi3rEfXIk=
github.com/99designs/gqlgen v0.14.0 h1:Wg8aNYQUjMR/4v+W3xD+7SizOy6lSvVeQ06AobNQAXI=
github.com/99designs/gqlgen v0.14.0/go.mod h1:S7z4boV+Nx4VvzMUpVrY/YuHjFX4n7rDyuTqvAkuoRE=
github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
Expand All @@ -96,6 +97,7 @@ github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAE
github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0=
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
github.com/agnivade/levenshtein v1.0.3/go.mod h1:4SFRZbbXWLF4MU1T9Qg0pGgH3Pjs+t6ie5efyrwRJXs=
github.com/agnivade/levenshtein v1.1.0/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8=
github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
Expand Down Expand Up @@ -188,6 +190,7 @@ github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/E
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
Expand Down Expand Up @@ -325,6 +328,7 @@ github.com/kataras/pio v0.0.2/go.mod h1:hAoW0t9UmXi4R5Oyq5Z4irTbaTsOemSrDGUtaTl7
github.com/kataras/sitemap v0.0.5/go.mod h1:KY2eugMKiPwsJgx7+U103YZehfvNGOXURubcGyk0Bz8=
github.com/kevinburke/go.uuid v1.2.0 h1:+1qP8NdkJfgOSTrrrUuA7h0djr1VY77HFXYjR+zUcUo=
github.com/kevinburke/go.uuid v1.2.0/go.mod h1:9gVngk1Hq1FjwewVAjsWEUT+xc6jP+p62CASaGmQ0NQ=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
Expand Down Expand Up @@ -483,8 +487,9 @@ github.com/valyala/fasttemplate v1.0.1 h1:tY9CJiPnMXf1ERmG2EyK7gNUd+c6RKGD0IfU8W
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U=
github.com/vektah/gqlparser/v2 v2.1.0 h1:uiKJ+T5HMGGQM2kRKQ8Pxw8+Zq9qhhZhz/lieYvCMns=
github.com/vektah/gqlparser/v2 v2.1.0/go.mod h1:SyUiHgLATUR8BiYURfTirrTcGpcE+4XkV2se04Px1Ms=
github.com/vektah/gqlparser/v2 v2.2.0 h1:bAc3slekAAJW6sZTi07aGq0OrfaCjj4jxARAaC7g2EM=
github.com/vektah/gqlparser/v2 v2.2.0/go.mod h1:i3mQIGIrbK2PD1RrCeMTlVbkF2FJ6WkU1KJlJlC+3F4=
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
Expand Down Expand Up @@ -779,6 +784,7 @@ golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roY
golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
Expand All @@ -787,6 +793,7 @@ golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
Expand Down Expand Up @@ -1004,4 +1011,5 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k=
59 changes: 59 additions & 0 deletions pkg/clinical/domain/complex_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2922,3 +2922,62 @@ func (e MedicationStatementStatusEnum) MarshalGQL(w io.Writer) {
log.Printf("%v\n", err)
}
}

// MedicationStatusEnum indicates the medication status
type MedicationStatusEnum string

const (
// MedicationStatusEnumActive is The medication is available for use
MedicationStatusEnumActive MedicationStatusEnum = "active"

// MedicationStatusEnumInActive is The medication is not available for use.
MedicationStatusEnumInActive MedicationStatusEnum = "inactive"

// MedicationStatusEnumEnteredInError is The medication was entered in error.
MedicationStatusEnumEnteredInError MedicationStatusEnum = "entered-in-error"
)

// AllMedicationStatusEnum is a list of all possible medication status
var AllMedicationStatusEnum = []MedicationStatusEnum{
MedicationStatusEnumActive,
MedicationStatusEnumInActive,
MedicationStatusEnumEnteredInError,
}

// IsValid ...
func (e MedicationStatusEnum) IsValid() bool {
switch e {
case MedicationStatusEnumActive,
MedicationStatusEnumInActive,
MedicationStatusEnumEnteredInError:
return true
}
return false
}

// String ...
func (e MedicationStatusEnum) String() string {
return string(e)
}

// UnmarshalGQL ...
func (e *MedicationStatusEnum) UnmarshalGQL(v interface{}) error {
str, ok := v.(string)
if !ok {
return fmt.Errorf("enums must be strings")
}

*e = MedicationStatusEnum(str)
if !e.IsValid() {
return fmt.Errorf("%s is not a valid Patient_LinkTypeEnum", str)
}
return nil
}

// MarshalGQL writes the patient link type to the supplied writer as a quoted string
func (e MedicationStatusEnum) MarshalGQL(w io.Writer) {
_, err := fmt.Fprint(w, strconv.Quote(e.String()))
if err != nil {
log.Printf("%v\n", err)
}
}
44 changes: 15 additions & 29 deletions pkg/clinical/domain/medication.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,6 @@ import (
"github.com/savannahghi/scalarutils"
)

// FHIRMedicationStatus indicates the medication status
type FHIRMedicationStatus string

const (
// FHIRMedicationStatusActive is The medication is available for use
FHIRMedicationStatusActive FHIRMedicationStatus = "active"

// FHIRMedicationStatusInActive is The medication is not available for use.
FHIRMedicationStatusInActive FHIRMedicationStatus = "inactive"

// FHIRMedicationStatusEnteredInError is The medication was entered in error.
FHIRMedicationStatusEnteredInError FHIRMedicationStatus = "entered-in-error"
)

// FHIRMedication definition:
type FHIRMedication struct {
ID *string `json:"id,omitempty"`
Expand All @@ -29,28 +15,28 @@ type FHIRMedication struct {

Code *FHIRCodeableConcept `json:"code,omitempty"`

Status FHIRMedicationStatus `json:"status,omitempty"`
Status MedicationStatusEnum `json:"status,omitempty"`

Manufacturer *FHIROrganization `json:"manufacturer,omitempty"`

Form *FHIRCodeableConcept `json:"form,omitempty"`

Amount *FHIRRatio `json:"amount,omitempty"`

Ingredient []*FHIRMedicationIngredient `json:"ingredient,omitempty"`
Ingredient []*MedicationIngredient `json:"ingredient,omitempty"`

Batch *FHIRMedicationBatch `json:"batch,omitempty"`
Batch *MedicationBatch `json:"batch,omitempty"`
}

// FHIRMedicationBatch definition:
type FHIRMedicationBatch struct {
// MedicationBatch definition:
type MedicationBatch struct {
LotNumber string `json:"lotNumber,omitempty"`

ExpirationDate *scalarutils.Date `json:"expirationDate,omitempty"`
}

// FHIRMedicationIngredient definition:
type FHIRMedicationIngredient struct {
// MedicationIngredient definition:
type MedicationIngredient struct {
ItemCodelabConcept *FHIRCodeableConcept `json:"itemCodelabConcept,omitempty"`

ItemReference *FHIRReference `json:"itemReference,omitempty"`
Expand All @@ -70,28 +56,28 @@ type FHIRMedicationInput struct {

Code *FHIRCodeableConceptInput `json:"code,omitempty"`

Status FHIRMedicationStatus `json:"status,omitempty"`
Status MedicationStatusEnum `json:"status,omitempty"`

Manufacturer *FHIROrganizationInput `json:"manufacturer,omitempty"`

Form *FHIRCodeableConceptInput `json:"form,omitempty"`

Amount *FHIRRatioInput `json:"amount,omitempty"`

Ingredient []*FHIRMedicationIngredientInput `json:"ingredient,omitempty"`
Ingredient []*MedicationIngredientInput `json:"ingredient,omitempty"`

Batch *FHIRMedicationBatchInput `json:"batch,omitempty"`
Batch *MedicationBatchInput `json:"batch,omitempty"`
}

// FHIRMedicationBatchInput ...
type FHIRMedicationBatchInput struct {
// MedicationBatchInput ...
type MedicationBatchInput struct {
LotNumber string `json:"lotNumber,omitempty"`

ExpirationDate *scalarutils.Date `json:"expirationDate,omitempty"`
}

// FHIRMedicationIngredientInput definition:
type FHIRMedicationIngredientInput struct {
// MedicationIngredientInput definition:
type MedicationIngredientInput struct {
ItemCodelabConcept *FHIRCodeableConceptInput `json:"itemCodelabConcept,omitempty"`

ItemReference *FHIRReferenceInput `json:"itemReference,omitempty"`
Expand All @@ -101,7 +87,7 @@ type FHIRMedicationIngredientInput struct {
Strength *FHIRRatioInput `json:"strength,omitempty"`
}

// FHIRMedicationRelayConnection is a Relay connection for MedicationStatement
// FHIRMedicationRelayConnection is a Relay connection for Medication
type FHIRMedicationRelayConnection struct {
Edges []*FHIRMedicationRelayEdge `json:"edges,omitempty"`

Expand Down
125 changes: 125 additions & 0 deletions pkg/clinical/presentation/graph/fhir/Medication.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
"""
MedicationStatusEnum
"""
enum MedicationStatusEnum {
active
inactive
entered_in_error # `original: entered-in-error`
}

"""
FHIRMedicationInput
"""
input FHIRMedicationInput {
ID: ID

Text: FHIRNarrativeInput

Identifier: [FHIRIdentifierInput]

Code: FHIRCodeableConceptInput

Status: MedicationStatusEnum

Manufacturer: FHIROrganizationInput

Form: FHIRCodeableConceptInput

Amount: FHIRRatioInput

Ingredient: [MedicationIngredientInput]

Batch: MedicationBatchInput
}

"""
MedicationBatchInput
"""
input MedicationBatchInput {
LotNumber: String

ExpirationDate: Date
}

"""
MedicationIngredientInput
"""
input MedicationIngredientInput {
ItemCodelabConcept: FHIRCodeableConceptInput

ItemReference: FHIRReferenceInput

IsActive: Boolean

Strength: FHIRRatioInput
}

"""
FHIRMedication
"""
type FHIRMedication {
ID: ID

Text: FHIRNarrative

Identifier: [FHIRIdentifier]

Code: FHIRCodeableConcept

Status: MedicationStatusEnum

Manufacturer: FHIROrganization

Form: FHIRCodeableConcept

Amount: FHIRRatio

Ingredient: [MedicationIngredient]

Batch: MedicationBatch
}

"""
MedicationBatch
"""
type MedicationBatch {
LotNumber: String

ExpirationDate: Date
}

"""
MedicationIngredient
"""
type MedicationIngredient {
ItemCodelabConcept: FHIRCodeableConcept

ItemReference: FHIRReference

IsActive: Boolean

Strength: FHIRRatio
}

"""
FHIRMedicationRelayConnection is a Relay connection for MedicationStatement
"""
type FHIRMedicationRelayConnection {
edges: [FHIRMedicationRelayEdge]
pageInfo: PageInfo
}

"""
FHIRMedicationRelayEdge is a Relay edge for Medication
"""
type FHIRMedicationRelayEdge {
cursor: String
node: FHIRMedication
}

"""
FHIRMedicationRelayPayload is used to return single instances of Medication
"""
type FHIRMedicationRelayPayload {
resource: FHIRMedication
}
Loading

0 comments on commit 2f211d8

Please sign in to comment.