Skip to content

Commit

Permalink
feat: add composition resource
Browse files Browse the repository at this point in the history
  • Loading branch information
EspiraMarvin committed Oct 10, 2023
1 parent 8786680 commit 61ef7a1
Show file tree
Hide file tree
Showing 20 changed files with 1,601 additions and 52 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/ahmetb/go-linq/v3 v3.2.0
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2
github.com/brianvoe/gofakeit v3.18.0+incompatible
github.com/chenyahui/gin-cache v1.8.1
github.com/getsentry/sentry-go v0.23.0
github.com/gin-contrib/cors v1.4.0
github.com/gin-gonic/gin v1.9.1
Expand Down Expand Up @@ -55,7 +56,6 @@ require (
github.com/bytedance/sonic v1.10.1 // indirect
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenyahui/gin-cache v1.8.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
Expand Down
24 changes: 6 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ github.com/brianvoe/gofakeit v3.18.0+incompatible h1:wDOmHc9DLG4nRjUVVaxA+CEglKO
github.com/brianvoe/gofakeit v3.18.0+incompatible/go.mod h1:kfwdRA90vvNhPutZWfH7WPaDzUjz+CZFqG+rPkOjGOc=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
github.com/bytedance/sonic v1.10.0 h1:qtNZduETEIWJVIyDl01BeNxur2rW9OwTQ/yBqFRkKEk=
github.com/bytedance/sonic v1.10.0/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
github.com/bytedance/sonic v1.10.1 h1:7a1wuFXL1cMy7a3f7/VFcEtriuXQnUBhtoVfOZiaysc=
github.com/bytedance/sonic v1.10.1/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
Expand Down Expand Up @@ -175,6 +173,7 @@ github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBd
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc=
Expand Down Expand Up @@ -218,8 +217,6 @@ github.com/go-playground/validator v9.31.0+incompatible h1:UA72EPEogEnq76ehGdEDp
github.com/go-playground/validator v9.31.0+incompatible/go.mod h1:yrEkQXlcI+PugkyDjY2bRrL/UBU4f3rvrgkN3V8JEig=
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
github.com/go-playground/validator/v10 v10.15.1 h1:BSe8uhN+xQ4r5guV/ywQI4gO59C2raYcGffYWZEjZzM=
github.com/go-playground/validator/v10 v10.15.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-playground/validator/v10 v10.15.5 h1:LEBecTWb/1j5TNY1YYG2RcOUN3R7NLylN+x8TTueE24=
github.com/go-playground/validator/v10 v10.15.5/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
Expand Down Expand Up @@ -433,21 +430,22 @@ github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzE
github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo=
github.com/pelletier/go-toml/v2 v2.0.9 h1:uH2qQXheeefCCkuBBSLi7jCiSmj3VRh2+Goq2N7Xxu0=
github.com/pelletier/go-toml/v2 v2.0.9/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
Expand Down Expand Up @@ -630,9 +628,8 @@ go.opentelemetry.io/otel/trace v1.16.0 h1:8JRpaObFoW0pxuVPapkgH8UhHQj+bJW8jJsCZE
go.opentelemetry.io/otel/trace v1.16.0/go.mod h1:Yt9vYq1SdNz3xdjZZK7wcXv1qv2pwLkqr2QVwea0ef0=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.4.0 h1:A8WCeEWhLwPBKNbFi5Wv5UTCBx5zzubnXDlMOFAzFMc=
golang.org/x/arch v0.4.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.5.0 h1:jpGode6huXQxcskEIpOCvrU+tzo81b6+oFLUYXWtH/Y=
golang.org/x/arch v0.5.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
Expand All @@ -646,8 +643,6 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand Down Expand Up @@ -733,8 +728,6 @@ golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qx
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos=
golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand Down Expand Up @@ -765,8 +758,6 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=
golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -833,8 +824,6 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand All @@ -851,8 +840,6 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down Expand Up @@ -1068,6 +1055,7 @@ gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8
gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y=
gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
6 changes: 6 additions & 0 deletions pkg/clinical/application/common/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ const (

// AddFHIRIDToProgram is the topic where details to update a program's fhir ID will be published to
AddFHIRIDToProgram = "program.fhirid.update"

// LOINCProgressNoteCode defines LOINC progress note terminology code
LOINCProgressNoteCode = "81216-4"

// LOINCAssessmentPlanCode defines LOINC assessment plan note terminology code
LOINCAssessmentPlanCode = "51847-2"
)

// DefaultIdentifier assigns a patient a code to function as their
Expand Down
51 changes: 51 additions & 0 deletions pkg/clinical/application/dto/composition_output.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package dto

import (
"github.com/savannahghi/scalarutils"
)

// Composition is a minimal representation of a fhir Composition
type Composition struct {
ID string `json:"id,omitempty"`
Text string `json:"text,omitempty"`
Type CompositionType `json:"type,omitempty"`
Category CompositionCategory `json:"category,omitempty"`
Status CompositionStatusEnum `json:"status,omitempty"`
PatientID string `json:"patientID,omitempty"`
EncounterID string `json:"encounterID,omitempty"`
Date *scalarutils.Date `json:"date"`
Author string `json:"author,omitempty"`
}

// CompositionEdge is a composition edge
type CompositionEdge struct {
Node Composition
Cursor string
}

// CompositionConnection is a Composition Connection Type
type CompositionConnection struct {
TotalCount int
Edges []CompositionEdge
PageInfo PageInfo
}

// CreateConditionConnection creates a connection that follows the GraphQl Cursor Connection Specification
func CreateCompositionConnection(compositions []Composition, pageInfo PageInfo, total int) CompositionConnection {
connection := CompositionConnection{
TotalCount: total,
Edges: []CompositionEdge{},
PageInfo: pageInfo,
}

for _, composition := range compositions {
edge := CompositionEdge{
Node: composition,
Cursor: composition.ID,
}

connection.Edges = append(connection.Edges, edge)
}

return connection
}
34 changes: 33 additions & 1 deletion pkg/clinical/application/dto/enums.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const (
ConditionStatusUnknown ConditionStatus = "UNKNOWN"
)

// ConditionStatus represents status of a FHIR condition
// ConditionCategory represents status of a FHIR condition
type ConditionCategory string

const (
Expand All @@ -133,3 +133,35 @@ const (
TerminologySourceSNOMEDCT TerminologySource = "SNOMED_CT"
TerminologySourceLOINC TerminologySource = "LOINC"
)

// LOINCCodes represents LOINC assessment codes
type LOINCCodes string

const (
LOINCPlanOfCareCode LOINCCodes = "18776-5"
LOINCAssessmentPlanCode LOINCCodes = "51847-2"
)

// CompositionCategory enum represents category composition attribute
type CompositionCategory string

const (
AssessmentAndPlan CompositionCategory = "ASSESSMENT_PLAN"
)

// Type enum represents type composition attribute
type CompositionType string

const (
ProgressNote CompositionType = "PROGRESS_NOTE"
)

// CompositionStatus enum represents status composition attribute
type CompositionStatusEnum string

const (
CompositionStatuEnumPreliminary CompositionStatusEnum = "PRELIMINARY"
CompositionStatuEnumFinal CompositionStatusEnum = "FINAL"
CompositionStatuEnumAmended CompositionStatusEnum = "AMENDED"
CompositionStatuEnumEnteredInErrorPreliminary CompositionStatusEnum = "ENTERED_IN_ERROR"
)
9 changes: 9 additions & 0 deletions pkg/clinical/application/dto/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,12 @@ type MediaInput struct {
EncounterID string `json:"encounterID"`
File map[string][]*multipart.FileHeader `form:"file" json:"file"`
}

// CompositionInput models the composition input
type CompositionInput struct {
EncounterID string `json:"encounterID"`
Type CompositionType `json:"type"`
Category CompositionCategory `json:"category"`
Status CompositionStatusEnum `json:"status"`
Note string `json:"note"`
}
1 change: 1 addition & 0 deletions pkg/clinical/domain/complex_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2099,6 +2099,7 @@ type CompositionStatusEnum string
const (
// CompositionStatusEnumPreliminary ...
CompositionStatusEnumPreliminary CompositionStatusEnum = "preliminary"
CompositionStatusEnumRegistered CompositionStatusEnum = "registered"
// CompositionStatusEnumFinal ...
CompositionStatusEnumFinal CompositionStatusEnum = "final"
// CompositionStatusEnumAmended ...
Expand Down
4 changes: 2 additions & 2 deletions pkg/clinical/domain/composition.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ type FHIRCompositionSection struct {
Title *string `json:"title,omitempty"`

// A code identifying the kind of content contained within the section. This must be consistent with the section title.
Code *scalarutils.Code `json:"code,omitempty"`
Code *FHIRCodeableConceptInput `json:"code,omitempty"`

// Identifies who is responsible for the information in this section, not necessarily who typed it in.
Author []*FHIRReference `json:"author,omitempty"`
Expand Down Expand Up @@ -259,7 +259,7 @@ type FHIRCompositionSectionInput struct {
Title *string `json:"title,omitempty"`

// A code identifying the kind of content contained within the section. This must be consistent with the section title.
Code *scalarutils.Code `json:"code,omitempty"`
Code *FHIRCodeableConceptInput `json:"code,omitempty"`

// Identifies who is responsible for the information in this section, not necessarily who typed it in.
Author []*FHIRReferenceInput `json:"author,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/brianvoe/gofakeit"
"github.com/google/uuid"
"github.com/savannahghi/clinical/pkg/clinical/application/common"
"github.com/savannahghi/clinical/pkg/clinical/application/dto"
"github.com/savannahghi/clinical/pkg/clinical/domain"
"github.com/savannahghi/firebasetools"
Expand Down Expand Up @@ -652,7 +653,103 @@ func NewFHIRMock() *FHIRMock {
return &domain.FHIRCompositionRelayConnection{}, nil
},
MockCreateFHIRCompositionFn: func(ctx context.Context, input domain.FHIRCompositionInput) (*domain.FHIRCompositionRelayPayload, error) {
return &domain.FHIRCompositionRelayPayload{}, nil
UUID := uuid.New().String()
compositionTitle := gofakeit.Name() + "assessment note"
typeSystem := scalarutils.URI("http://hl7.org/fhir/ValueSet/doc-typecodes")
categorySystem := scalarutils.URI("http://hl7.org/fhir/ValueSet/referenced-item-category")
category := "Assessment + plan"
compositionType := "Progress note"
treatmentPlan := "Treatment Plan"
compositionStatus := "active"
note := scalarutils.Markdown("Fever Fever")
PatientRef := "Patient/" + uuid.NewString()
patientType := "Patient"
organizationRef := "Organization/" + uuid.NewString()
compositionSectionTextStatus := "generated"

return &domain.FHIRCompositionRelayPayload{
Resource: &domain.FHIRComposition{
ID: &UUID,
Text: &domain.FHIRNarrative{},
Identifier: &domain.FHIRIdentifier{},
Status: (*domain.CompositionStatusEnum)(&compositionStatus),
Type: &domain.FHIRCodeableConcept{
ID: new(string),
Coding: []*domain.FHIRCoding{
{
ID: &UUID,
System: &typeSystem,
Code: scalarutils.Code(string(common.LOINCProgressNoteCode)),
Display: compositionType,
},
},
Text: "Progress note",
},
Category: []*domain.FHIRCodeableConcept{
{
// ID: new(string),
Coding: []*domain.FHIRCoding{
{
ID: &UUID,
System: &categorySystem,
Version: new(string),
Code: scalarutils.Code(string(common.LOINCAssessmentPlanCode)),
Display: category,
},
},
Text: "Assessment + plan",
},
},
Subject: &domain.FHIRReference{
ID: &UUID,
Reference: &PatientRef,
Type: (*scalarutils.URI)(&patientType),
},
Encounter: &domain.FHIRReference{
ID: &UUID,
},
Date: &scalarutils.Date{
Year: 2023,
Month: 9,
Day: 25,
},
Author: []*domain.FHIRReference{
{
Reference: &organizationRef,
},
},
Title: &compositionTitle,
Section: []*domain.FHIRCompositionSection{
{
ID: &UUID,
Title: &treatmentPlan,
Code: &domain.FHIRCodeableConceptInput{
ID: new(string),
Coding: []*domain.FHIRCodingInput{
{
ID: &UUID,
System: &categorySystem,
Version: new(string),
Code: scalarutils.Code(string(common.LOINCAssessmentPlanCode)),
Display: category,
},
},
Text: "Assessment + plan",
},
Author: []*domain.FHIRReference{
{
Reference: new(string),
},
},
Text: &domain.FHIRNarrative{
ID: &UUID,
Status: (*domain.NarrativeStatusEnum)(&compositionSectionTextStatus),
Div: scalarutils.XHTML(note),
},
},
},
},
}, nil
},
MockUpdateFHIRCompositionFn: func(ctx context.Context, input domain.FHIRCompositionInput) (*domain.FHIRCompositionRelayPayload, error) {
return &domain.FHIRCompositionRelayPayload{}, nil
Expand Down

0 comments on commit 61ef7a1

Please sign in to comment.