Skip to content

Commit

Permalink
Merge pull request #1 from recare/encrypted_fields
Browse files Browse the repository at this point in the history
adding duplicate models for encrypted fields
  • Loading branch information
samshaw-recare authored Oct 19, 2021
2 parents 15deb56 + 1c05127 commit c6fc5d8
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 0 deletions.
18 changes: 18 additions & 0 deletions fhir-models/fhir/humanName.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,21 @@ type HumanName struct {
Suffix []string `bson:"suffix,omitempty" json:"suffix,omitempty"`
Period *Period `bson:"period,omitempty" json:"period,omitempty"`
}

type RecareHumanName struct {
Id *string `bson:"id,omitempty" json:"id,omitempty"`
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
Use *NameUse `bson:"use,omitempty" json:"use,omitempty"`
Text *string `bson:"text,omitempty" json:"text,omitempty"`
Family *EncryptedField `bson:"family,omitempty" json:"family,omitempty"`
Given *EncryptedField `bson:"given,omitempty" json:"given,omitempty"`
Prefix []string `bson:"prefix,omitempty" json:"prefix,omitempty"`
Suffix []string `bson:"suffix,omitempty" json:"suffix,omitempty"`
Period *Period `bson:"period,omitempty" json:"period,omitempty"`
}

type EncryptedField struct {
IV string `json:"iv,omitempty"`
Content string `json:"content,omitempty"`
Algo string `json:"algo,omitempty"`
}
58 changes: 58 additions & 0 deletions fhir-models/fhir/observation.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,44 @@ type Observation struct {
EffectiveTiming *Timing `bson:"effectiveTiming,omitempty" json:"effectiveTiming,omitempty"`
EffectiveInstant *bool `bson:"effectiveInstant,omitempty" json:"effectiveInstant,omitempty"`
}

type RecareObservation struct {
Id *string `bson:"id,omitempty" json:"id,omitempty"`
Meta *Meta `bson:"meta,omitempty" json:"meta,omitempty"`
ImplicitRules *string `bson:"implicitRules,omitempty" json:"implicitRules,omitempty"`
Language *string `bson:"language,omitempty" json:"language,omitempty"`
Text *Narrative `bson:"text,omitempty" json:"text,omitempty"`
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
ModifierExtension []Extension `bson:"modifierExtension,omitempty" json:"modifierExtension,omitempty"`
Identifier []Identifier `bson:"identifier,omitempty" json:"identifier,omitempty"`
BasedOn []Reference `bson:"basedOn,omitempty" json:"basedOn,omitempty"`
PartOf []Reference `bson:"partOf,omitempty" json:"partOf,omitempty"`
Status ObservationStatus `bson:"status" json:"status"`
Category []CodeableConcept `bson:"category,omitempty" json:"category,omitempty"`
Code CodeableConcept `bson:"code" json:"code"`
Subject *Reference `bson:"subject,omitempty" json:"subject,omitempty"`
Focus []Reference `bson:"focus,omitempty" json:"focus,omitempty"`
Encounter *Reference `bson:"encounter,omitempty" json:"encounter,omitempty"`
Issued *string `bson:"issued,omitempty" json:"issued,omitempty"`
Performer []Reference `bson:"performer,omitempty" json:"performer,omitempty"`
DataAbsentReason *CodeableConcept `bson:"dataAbsentReason,omitempty" json:"dataAbsentReason,omitempty"`
Interpretation []CodeableConcept `bson:"interpretation,omitempty" json:"interpretation,omitempty"`
Note []Annotation `bson:"note,omitempty" json:"note,omitempty"`
BodySite *CodeableConcept `bson:"bodySite,omitempty" json:"bodySite,omitempty"`
Method *CodeableConcept `bson:"method,omitempty" json:"method,omitempty"`
Specimen *Reference `bson:"specimen,omitempty" json:"specimen,omitempty"`
Device *Reference `bson:"device,omitempty" json:"device,omitempty"`
ReferenceRange []ObservationReferenceRange `bson:"referenceRange,omitempty" json:"referenceRange,omitempty"`
HasMember []Reference `bson:"hasMember,omitempty" json:"hasMember,omitempty"`
DerivedFrom []Reference `bson:"derivedFrom,omitempty" json:"derivedFrom,omitempty"`
Component []ObservationComponent `bson:"component,omitempty" json:"component,omitempty"`
ValueQuantity *RecareQuantity `bson:"valueQuantity,omitempty" json:"valueQuantity,omitempty"`
EffectiveDateTime *string `bson:"effectiveDateTime,omitempty" json:"effectiveDateTime,omitempty"`
EffectivePeriod *Period `bson:"effectivePeriod,omitempty" json:"effectivePeriod,omitempty"`
EffectiveTiming *Timing `bson:"effectiveTiming,omitempty" json:"effectiveTiming,omitempty"`
EffectiveInstant *bool `bson:"effectiveInstant,omitempty" json:"effectiveInstant,omitempty"`
}

type ObservationReferenceRange struct {
Id *string `bson:"id,omitempty" json:"id,omitempty"`
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
Expand Down Expand Up @@ -89,6 +127,18 @@ func (r Observation) MarshalJSON() ([]byte, error) {
})
}

type RecareOtherObservation RecareObservation

func (r RecareObservation) MarshalJSON() ([]byte, error) {
return json.Marshal(struct {
RecareOtherObservation
ResourceType string `json:"resourceType"`
}{
RecareOtherObservation: RecareOtherObservation(r),
ResourceType: "RecareObservation",
})
}

// UnmarshalObservation unmarshals a Observation.
func UnmarshalObservation(b []byte) (Observation, error) {
var observation Observation
Expand All @@ -97,3 +147,11 @@ func UnmarshalObservation(b []byte) (Observation, error) {
}
return observation, nil
}

func UnmarshalRecareObservation(b []byte) (RecareObservation, error) {
var observation RecareObservation
if err := json.Unmarshal(b, &observation); err != nil {
return observation, err
}
return observation, nil
}
45 changes: 45 additions & 0 deletions fhir-models/fhir/patient.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,31 @@ type Patient struct {
ManagingOrganization *Reference `bson:"managingOrganization,omitempty" json:"managingOrganization,omitempty"`
Link []PatientLink `bson:"link,omitempty" json:"link,omitempty"`
}

type RecarePatient struct {
Id *string `bson:"id,omitempty" json:"id,omitempty"`
Meta *Meta `bson:"meta,omitempty" json:"meta,omitempty"`
ImplicitRules *string `bson:"implicitRules,omitempty" json:"implicitRules,omitempty"`
Language *string `bson:"language,omitempty" json:"language,omitempty"`
Text *Narrative `bson:"text,omitempty" json:"text,omitempty"`
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
ModifierExtension []Extension `bson:"modifierExtension,omitempty" json:"modifierExtension,omitempty"`
Identifier []Identifier `bson:"identifier,omitempty" json:"identifier,omitempty"`
Active *bool `bson:"active,omitempty" json:"active,omitempty"`
Name []RecareHumanName `bson:"name,omitempty" json:"name,omitempty"`
Telecom []ContactPoint `bson:"telecom,omitempty" json:"telecom,omitempty"`
Gender *AdministrativeGender `bson:"gender,omitempty" json:"gender,omitempty"`
BirthDate *EncryptedField `bson:"birthDate,omitempty" json:"birthDate,omitempty"`
Address []Address `bson:"address,omitempty" json:"address,omitempty"`
MaritalStatus *CodeableConcept `bson:"maritalStatus,omitempty" json:"maritalStatus,omitempty"`
Photo []Attachment `bson:"photo,omitempty" json:"photo,omitempty"`
Contact []PatientContact `bson:"contact,omitempty" json:"contact,omitempty"`
Communication []PatientCommunication `bson:"communication,omitempty" json:"communication,omitempty"`
GeneralPractitioner []Reference `bson:"generalPractitioner,omitempty" json:"generalPractitioner,omitempty"`
ManagingOrganization *Reference `bson:"managingOrganization,omitempty" json:"managingOrganization,omitempty"`
Link []PatientLink `bson:"link,omitempty" json:"link,omitempty"`
}

type PatientContact struct {
Id *string `bson:"id,omitempty" json:"id,omitempty"`
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
Expand Down Expand Up @@ -82,6 +107,18 @@ func (r Patient) MarshalJSON() ([]byte, error) {
})
}

type RecareOtherPatient RecarePatient

func (r RecarePatient) MarshalJSON() ([]byte, error) {
return json.Marshal(struct {
RecareOtherPatient
ResourceType string `json:"resourceType"`
}{
RecareOtherPatient: RecareOtherPatient(r),
ResourceType: "RecarePatient",
})
}

// UnmarshalPatient unmarshals a Patient.
func UnmarshalPatient(b []byte) (Patient, error) {
var patient Patient
Expand All @@ -90,3 +127,11 @@ func UnmarshalPatient(b []byte) (Patient, error) {
}
return patient, nil
}

func UnmarshalRecarePatient(b []byte) (RecarePatient, error) {
var patient RecarePatient
if err := json.Unmarshal(b, &patient); err != nil {
return patient, err
}
return patient, nil
}
10 changes: 10 additions & 0 deletions fhir-models/fhir/quantity.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,13 @@ type Quantity struct {
System *string `bson:"system,omitempty" json:"system,omitempty"`
Code *string `bson:"code,omitempty" json:"code,omitempty"`
}

type RecareQuantity struct {
Id *string `bson:"id,omitempty" json:"id,omitempty"`
Extension []Extension `bson:"extension,omitempty" json:"extension,omitempty"`
Value *EncryptedField `bson:"value,omitempty" json:"value,omitempty"`
Comparator *QuantityComparator `bson:"comparator,omitempty" json:"comparator,omitempty"`
Unit *string `bson:"unit,omitempty" json:"unit,omitempty"`
System *string `bson:"system,omitempty" json:"system,omitempty"`
Code *string `bson:"code,omitempty" json:"code,omitempty"`
}

0 comments on commit c6fc5d8

Please sign in to comment.