-
Notifications
You must be signed in to change notification settings - Fork 32
[ModelsR4] MedicationStatement crashing when medicationX is null #39
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
As per the source code, Medication is force unwrapping outside of optional chain block. class @MedicationStatement
Look's like we just need to set medication inside the if let statements.
Here's the code snippet and screenshot for reference.
var _t_medication: MedicationX? = nil
if let medicationCodeableConcept = try CodeableConcept(from: _container, forKeyIfPresent: .medicationCodeableConcept) {
if _t_medication != nil {
throw DecodingError.dataCorruptedError(forKey: .medicationCodeableConcept, in: _container, debugDescription: "More than one value provided for \"medication\"")
}
_t_medication = .codeableConcept(medicationCodeableConcept)
}
if let medicationReference = try Reference(from: _container, forKeyIfPresent: .medicationReference) {
if _t_medication != nil {
throw DecodingError.dataCorruptedError(forKey: .medicationReference, in: _container, debugDescription: "More than one value provided for \"medication\"")
}
_t_medication = .reference(medicationReference)
}
self.medication = _t_medication!

Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working