diff --git a/Sources/ParseCareKit/Objects/CarePlan.swift b/Sources/ParseCareKit/Objects/CarePlan.swift index 0864941d5..4b2b8e526 100644 --- a/Sources/ParseCareKit/Objects/CarePlan.swift +++ b/Sources/ParseCareKit/Objects/CarePlan.swift @@ -105,7 +105,7 @@ public final class CarePlan: PCKVersionable, PCKSynchronizable { enum CodingKeys: String, CodingKey { case objectId, createdAt, updatedAt - case uuid, schemaVersion, createdDate, updatedDate, deletedDate, timezone, userInfo, groupIdentifier, tags, source, asset, remoteID, notes, logicalClock + case uuid, entityId, schemaVersion, createdDate, updatedDate, deletedDate, timezone, userInfo, groupIdentifier, tags, source, asset, remoteID, notes, logicalClock case previousVersionUUID, nextVersionUUID, effectiveDate case title, patient, patientUUID } @@ -328,10 +328,10 @@ extension CarePlan { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) if encodingForParse { - try container.encode(patient, forKey: .patient) + try container.encodeIfPresent(patient, forKey: .patient) } try container.encode(title, forKey: .title) - try container.encode(patientUUID, forKey: .patientUUID) + try container.encodeIfPresent(patientUUID, forKey: .patientUUID) try encodeVersionable(to: encoder) encodingForParse = true } diff --git a/Sources/ParseCareKit/Objects/Contact.swift b/Sources/ParseCareKit/Objects/Contact.swift index ce6e1b675..451b0648f 100644 --- a/Sources/ParseCareKit/Objects/Contact.swift +++ b/Sources/ParseCareKit/Objects/Contact.swift @@ -117,7 +117,7 @@ public final class Contact: PCKVersionable, PCKSynchronizable { enum CodingKeys: String, CodingKey { case objectId, createdAt, updatedAt - case uuid, schemaVersion, createdDate, updatedDate, deletedDate, timezone, userInfo, groupIdentifier, tags, source, asset, remoteID, notes, logicalClock + case uuid, entityId, schemaVersion, createdDate, updatedDate, deletedDate, timezone, userInfo, groupIdentifier, tags, source, asset, remoteID, notes, logicalClock case previousVersionUUID, nextVersionUUID, effectiveDate case carePlan, title, carePlanUUID, address, category, name, organization, role case emailAddresses, messagingNumbers, phoneNumbers, otherContactInfo @@ -349,20 +349,20 @@ extension Contact { var container = encoder.container(keyedBy: CodingKeys.self) if encodingForParse { - try container.encode(carePlan, forKey: .carePlan) + try container.encodeIfPresent(carePlan, forKey: .carePlan) } - try container.encode(title, forKey: .title) - try container.encode(carePlanUUID, forKey: .carePlanUUID) - try container.encode(address, forKey: .address) - try container.encode(category, forKey: .category) + try container.encodeIfPresent(title, forKey: .title) + try container.encodeIfPresent(carePlanUUID, forKey: .carePlanUUID) + try container.encodeIfPresent(address, forKey: .address) + try container.encodeIfPresent(category, forKey: .category) try container.encode(name, forKey: .name) - try container.encode(organization, forKey: .organization) - try container.encode(role, forKey: .role) - try container.encode(emailAddresses, forKey: .emailAddresses) - try container.encode(messagingNumbers, forKey: .messagingNumbers) - try container.encode(phoneNumbers, forKey: .phoneNumbers) - try container.encode(otherContactInfo, forKey: .otherContactInfo) + try container.encodeIfPresent(organization, forKey: .organization) + try container.encodeIfPresent(role, forKey: .role) + try container.encodeIfPresent(emailAddresses, forKey: .emailAddresses) + try container.encodeIfPresent(messagingNumbers, forKey: .messagingNumbers) + try container.encodeIfPresent(phoneNumbers, forKey: .phoneNumbers) + try container.encodeIfPresent(otherContactInfo, forKey: .otherContactInfo) try encodeVersionable(to: encoder) encodingForParse = true } diff --git a/Sources/ParseCareKit/Objects/Outcome.swift b/Sources/ParseCareKit/Objects/Outcome.swift index fb75baf1e..12598722c 100644 --- a/Sources/ParseCareKit/Objects/Outcome.swift +++ b/Sources/ParseCareKit/Objects/Outcome.swift @@ -427,8 +427,8 @@ extension Outcome { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) if encodingForParse { - try container.encode(task, forKey: .task) - try container.encode(date, forKey: .date) + try container.encodeIfPresent(task, forKey: .task) + try container.encodeIfPresent(date, forKey: .date) } try container.encode(taskUUID, forKey: .taskUUID) try container.encode(taskOccurrenceIndex, forKey: .taskOccurrenceIndex) diff --git a/Sources/ParseCareKit/Objects/Patient.swift b/Sources/ParseCareKit/Objects/Patient.swift index 241bd6d1d..df8ad33cf 100644 --- a/Sources/ParseCareKit/Objects/Patient.swift +++ b/Sources/ParseCareKit/Objects/Patient.swift @@ -98,17 +98,17 @@ public final class Patient: PCKVersionable, PCKSynchronizable { enum CodingKeys: String, CodingKey { case objectId, createdAt, updatedAt - case uuid, schemaVersion, createdDate, updatedDate, deletedDate, timezone, userInfo, groupIdentifier, tags, source, asset, remoteID, notes, logicalClock + case uuid, entityId, schemaVersion, createdDate, updatedDate, deletedDate, timezone, userInfo, groupIdentifier, tags, source, asset, remoteID, notes, logicalClock case previousVersionUUID, nextVersionUUID, effectiveDate case allergies, birthday, name, sex } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(allergies, forKey: .allergies) - try container.encode(birthday, forKey: .birthday) + try container.encodeIfPresent(allergies, forKey: .allergies) + try container.encodeIfPresent(birthday, forKey: .birthday) try container.encode(name, forKey: .name) - try container.encode(sex, forKey: .sex) + try container.encodeIfPresent(sex, forKey: .sex) try encodeVersionable(to: encoder) } diff --git a/Sources/ParseCareKit/Objects/Task.swift b/Sources/ParseCareKit/Objects/Task.swift index e4c8827cb..c0db51980 100644 --- a/Sources/ParseCareKit/Objects/Task.swift +++ b/Sources/ParseCareKit/Objects/Task.swift @@ -107,7 +107,7 @@ public final class Task: PCKVersionable, PCKSynchronizable { enum CodingKeys: String, CodingKey { case objectId, createdAt, updatedAt - case uuid, schemaVersion, createdDate, updatedDate, deletedDate, timezone, userInfo, groupIdentifier, tags, source, asset, remoteID, notes, logicalClock + case uuid, entityId, schemaVersion, createdDate, updatedDate, deletedDate, timezone, userInfo, groupIdentifier, tags, source, asset, remoteID, notes, logicalClock case previousVersionUUID, nextVersionUUID, effectiveDate case title, carePlan, carePlanUUID, impactsAdherence, instructions, schedule } @@ -352,10 +352,10 @@ extension Task { if encodingForParse { try container.encode(carePlan, forKey: .carePlan) } - try container.encode(title, forKey: .title) - try container.encode(carePlanUUID, forKey: .carePlanUUID) + try container.encodeIfPresent(title, forKey: .title) + try container.encodeIfPresent(carePlanUUID, forKey: .carePlanUUID) try container.encode(impactsAdherence, forKey: .impactsAdherence) - try container.encode(instructions, forKey: .instructions) + try container.encodeIfPresent(instructions, forKey: .instructions) try container.encode(schedule, forKey: .schedule) try encodeVersionable(to: encoder) encodingForParse = true diff --git a/Sources/ParseCareKit/Protocols/PCKObjectable.swift b/Sources/ParseCareKit/Protocols/PCKObjectable.swift index f5cffd827..d9d6850f0 100644 --- a/Sources/ParseCareKit/Protocols/PCKObjectable.swift +++ b/Sources/ParseCareKit/Protocols/PCKObjectable.swift @@ -197,7 +197,7 @@ extension PCKObjectable { var container = encoder.container(keyedBy: PCKCodingKeys.self) if encodingForParse { - if !(self is Note) { + if !(self is Note) || !(self is OutcomeValue) { try container.encodeIfPresent(entityId, forKey: .entityId) } try container.encodeIfPresent(ACL, forKey: .ACL)