Skip to content

Commit

Permalink
feat: record VIA test
Browse files Browse the repository at this point in the history
  • Loading branch information
Muchogoc committed Jan 29, 2024
1 parent c35a4fb commit ec02292
Show file tree
Hide file tree
Showing 8 changed files with 245 additions and 17 deletions.
45 changes: 45 additions & 0 deletions pkg/clinical/application/dto/enums.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,48 @@ func (c *ConsentProvisionTypeEnum) UnmarshalGQL(v interface{}) error {

return nil
}

// VIAOutcomeEnum a type enum that represents the results of a VIA test
// VIA (Visual Inspection with Acetic Acid)
type VIAOutcomeEnum string

const (
VIAOutcomeNegative = "negative"
VIAOutcomePositive = "positive"
VIAOutcomePositiveInvasiveCancer = "positive_invasive_cancer"
)

// IsValid checks validity of a VIAOutcomeEnum enum
func (c VIAOutcomeEnum) IsValid() bool {
switch c {
case VIAOutcomeNegative, VIAOutcomePositive, VIAOutcomePositiveInvasiveCancer:
return true
}

return false
}

// String converts VIA to string
func (c VIAOutcomeEnum) String() string {
return string(c)
}

// MarshalGQL writes the VIA as a quoted string
func (c VIAOutcomeEnum) MarshalGQL(w io.Writer) {
fmt.Fprint(w, strconv.Quote(c.String()))
}

// UnmarshalGQL reads a json and converts it to a VIA enum
func (c *VIAOutcomeEnum) UnmarshalGQL(v interface{}) error {
str, ok := v.(string)
if !ok {
return fmt.Errorf("enums must be a string")
}

*c = VIAOutcomeEnum(str)
if !c.IsValid() {
return fmt.Errorf("%s is not a valid VIAOutcomeEnum Enum", str)
}

return nil
}
2 changes: 2 additions & 0 deletions pkg/clinical/application/dto/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ type ObservationInput struct {
Status ObservationStatus `json:"status,omitempty" validate:"required"`
EncounterID string `json:"encounterID,omitempty" validate:"required"`
Value string `json:"value,omitempty" validate:"required"`

Interpretation string
}

func (o ObservationInput) Validate() error {
Expand Down
2 changes: 2 additions & 0 deletions pkg/clinical/presentation/graph/clinical.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ extend type Mutation {
recordLastMenstrualPeriod(input: ObservationInput!): Observation!
recordDiastolicBloodPressure(input: ObservationInput!): Observation!
recordColposcopy(input: ObservationInput!): Observation!
# Visual Inspection with Acetic Acid
recordVIA(input: ObservationInput!): Observation!

# Patient
createPatient(input: PatientInput!): Patient!
Expand Down
6 changes: 6 additions & 0 deletions pkg/clinical/presentation/graph/clinical.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

109 changes: 109 additions & 0 deletions pkg/clinical/presentation/graph/generated/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ec02292

Please sign in to comment.