From e2bb6ff4ff9e4147ff63392d5a93f92e8926c904 Mon Sep 17 00:00:00 2001 From: ginrod Date: Fri, 4 Jul 2025 14:59:03 -0400 Subject: [PATCH 1/7] add MedicationAdministration.json schema with base schema (WIP) --- my_proof/schemas/MedicationAdministration.json | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 my_proof/schemas/MedicationAdministration.json diff --git a/my_proof/schemas/MedicationAdministration.json b/my_proof/schemas/MedicationAdministration.json new file mode 100644 index 0000000..4790a8c --- /dev/null +++ b/my_proof/schemas/MedicationAdministration.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "MedicationAdministration Schema", + "type": "object", + "required": ["id", "resourceType", "status", "medicationCodeableConcept", "subject"], + "properties": { + + } +} \ No newline at end of file From 9471f99deac916971018f1e16582ccfc99ec1515 Mon Sep 17 00:00:00 2001 From: ginrod Date: Fri, 4 Jul 2025 15:23:37 -0400 Subject: [PATCH 2/7] add MedicationAdministration schema properties --- .../schemas/MedicationAdministration.json | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/my_proof/schemas/MedicationAdministration.json b/my_proof/schemas/MedicationAdministration.json index 4790a8c..67d7758 100644 --- a/my_proof/schemas/MedicationAdministration.json +++ b/my_proof/schemas/MedicationAdministration.json @@ -4,6 +4,39 @@ "type": "object", "required": ["id", "resourceType", "status", "medicationCodeableConcept", "subject"], "properties": { - + "id": { + "type": "string" + }, + "resourceType": { + "const": "MedicationAdministration" + }, + "status": { + "const": "completed" + }, + "medication": { + "type": "object", + "required": ["concept"], + "properties": { + "concept": { + "type": "object", + "properties": { + "coding": { + "type": "array", + "properties": { + } + } + } + } + } + }, + "subject": { + "type": "object", + "required": ["reference"], + "properties": { + "reference": { + "type": "string" + } + } + } } } \ No newline at end of file From b60b439942cd90f675a93fa2e562e8983af3f80e Mon Sep 17 00:00:00 2001 From: ginrod Date: Fri, 4 Jul 2025 15:33:15 -0400 Subject: [PATCH 3/7] finishing schema for MA --- .../schemas/MedicationAdministration.json | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/my_proof/schemas/MedicationAdministration.json b/my_proof/schemas/MedicationAdministration.json index 67d7758..1ae1433 100644 --- a/my_proof/schemas/MedicationAdministration.json +++ b/my_proof/schemas/MedicationAdministration.json @@ -19,11 +19,28 @@ "properties": { "concept": { "type": "object", + "required": ["coding", "text"], "properties": { "coding": { "type": "array", - "properties": { + "items": { + "type": "object", + "required": ["system", "code"], + "properties": { + "system": { + "const": "http://www.nutridao.com/fhir/supplement" + }, + "code": { + "type": "string" + }, + "display": { + "type": "string" + } + } } + }, + "text": { + "type": "string" } } } @@ -35,6 +52,9 @@ "properties": { "reference": { "type": "string" + }, + "display": { + "type": "string" } } } From 3d1c37aaefb9a05cf815eb23cc09f868ff95b4ab Mon Sep 17 00:00:00 2001 From: ginrod Date: Fri, 4 Jul 2025 15:45:21 -0400 Subject: [PATCH 4/7] add descriptions --- .../schemas/MedicationAdministration.json | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/my_proof/schemas/MedicationAdministration.json b/my_proof/schemas/MedicationAdministration.json index 1ae1433..09ddae1 100644 --- a/my_proof/schemas/MedicationAdministration.json +++ b/my_proof/schemas/MedicationAdministration.json @@ -3,44 +3,54 @@ "title": "MedicationAdministration Schema", "type": "object", "required": ["id", "resourceType", "status", "medicationCodeableConcept", "subject"], + "description": "Describes the event of a patient consuming or otherwise being administered a medication. This may be as simple as swallowing a tablet or it may be a long running infusion. Related resources tie this event to the authorizing prescription, and the specific encounter between patient and health care practitioner.", "properties": { "id": { - "type": "string" + "type": "string", + "description": "Logical id of this artifact" }, "resourceType": { "const": "MedicationAdministration" }, "status": { - "const": "completed" + "const": "completed", + "description": "Will generally be set to show that the administration has been completed. For some long running administrations such as infusions, it is possible for an administration to be started but not completed or it may be paused while some other process is under way." }, "medication": { "type": "object", "required": ["concept"], + "description": "What was administered", "properties": { "concept": { "type": "object", "required": ["coding", "text"], + "description": "A reference to a concept - e.g. the information is identified by its general class to the degree of precision found in the terminology.", "properties": { "coding": { "type": "array", + "description": "A reference to a code defined by a terminology system.", "items": { "type": "object", "required": ["system", "code"], + "description": "Identity of the terminology system", "properties": { "system": { "const": "http://www.nutridao.com/fhir/supplement" }, "code": { - "type": "string" + "type": "string", + "description": "Symbol in syntax defined by the system" }, "display": { - "type": "string" + "type": "string", + "description": "Representation defined by the system" } } } }, "text": { - "type": "string" + "type": "string", + "description": "Plain text representation of the concept" } } } @@ -49,12 +59,15 @@ "subject": { "type": "object", "required": ["reference"], + "description": "Who received medication", "properties": { "reference": { - "type": "string" + "type": "string", + "description": "Literal reference, Relative, internal or absolute URL" }, "display": { - "type": "string" + "type": "string", + "description": "Text alternative for the resource reference" } } } From 746db69c908fb243fd0cf636710245cc6b638511 Mon Sep 17 00:00:00 2001 From: ginrod Date: Fri, 4 Jul 2025 15:47:28 -0400 Subject: [PATCH 5/7] delete google profile json schema --- my_proof/schemas/google-profile.json | 63 ---------------------------- 1 file changed, 63 deletions(-) delete mode 100644 my_proof/schemas/google-profile.json diff --git a/my_proof/schemas/google-profile.json b/my_proof/schemas/google-profile.json deleted file mode 100644 index 5dcb3ce..0000000 --- a/my_proof/schemas/google-profile.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Google Profile Schema", - "type": "object", - "required": ["userId", "email", "timestamp", "profile", "metadata"], - "properties": { - "userId": { - "type": "string", - "description": "Google user identifier" - }, - "email": { - "type": "string", - "format": "email", - "description": "User's email address" - }, - "timestamp": { - "type": "number", - "description": "Timestamp of the data collection in milliseconds" - }, - "profile": { - "type": "object", - "required": ["name"], - "properties": { - "name": { - "type": "string", - "description": "User's display name" - }, - "locale": { - "type": "string", - "description": "User's locale setting" - } - } - }, - "storage": { - "type": "object", - "properties": { - "percentUsed": { - "type": "number", - "description": "Percentage of storage used" - } - } - }, - "metadata": { - "type": "object", - "required": ["source", "collectionDate", "dataType"], - "properties": { - "source": { - "type": "string", - "description": "Source of the data" - }, - "collectionDate": { - "type": "string", - "format": "date-time", - "description": "Date when the data was collected" - }, - "dataType": { - "type": "string", - "description": "Type of data collected" - } - } - } - } -} \ No newline at end of file From 6c38c2712741fde5ade4895b4239f453ae43200d Mon Sep 17 00:00:00 2001 From: ginrod Date: Fri, 4 Jul 2025 17:14:26 -0400 Subject: [PATCH 6/7] fix "spotify" word from template --- my_proof/models/db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/my_proof/models/db.py b/my_proof/models/db.py index bc80800..ff883ae 100644 --- a/my_proof/models/db.py +++ b/my_proof/models/db.py @@ -1,4 +1,4 @@ -"""SQLAlchemy database models for storing Spotify contribution data""" +"""SQLAlchemy database models for storing nutritional supplement contribution data""" import datetime from sqlalchemy import Boolean, Column, ForeignKey, Integer, String, Float, DateTime, UniqueConstraint, ARRAY From 748deb5bab7a4e471178777e4f48a7b16be40e47 Mon Sep 17 00:00:00 2001 From: ginrod Date: Fri, 4 Jul 2025 17:21:05 -0400 Subject: [PATCH 7/7] point to MedicationAdministration schema --- my_proof/proof.py | 16 ++++++++-------- my_proof/utils/schema.py | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/my_proof/proof.py b/my_proof/proof.py index 959dbd4..c8ae80a 100644 --- a/my_proof/proof.py +++ b/my_proof/proof.py @@ -83,14 +83,14 @@ def generate(self) -> ProofResponse: self.proof_response.ownership * 0.1 ) - # Additional (public) properties to include in the proof about the data - self.proof_response.attributes = { - 'schema_type': schema_type, - 'user_email': input_data.get('email'), - 'user_id': input_data.get('userId'), - 'profile_name': input_data.get('profile', {}).get('name'), - 'verified_with_oauth': google_user is not None - } + # # Additional (public) properties to include in the proof about the data + # self.proof_response.attributes = { + # 'schema_type': schema_type, + # 'user_email': input_data.get('email'), + # 'user_id': input_data.get('userId'), + # 'profile_name': input_data.get('profile', {}).get('name'), + # 'verified_with_oauth': google_user is not None + # } # Additional metadata about the proof, written onchain self.proof_response.metadata = { diff --git a/my_proof/utils/schema.py b/my_proof/utils/schema.py index a039c9b..21765f4 100644 --- a/my_proof/utils/schema.py +++ b/my_proof/utils/schema.py @@ -7,18 +7,18 @@ def validate_schema(input_data: Dict[str, Any]) -> Tuple[str, bool]: """ - Validate input data against the Google profile schema using jsonschema. + Validate input data against the Medication Administration schema using jsonschema. Args: input_data: The JSON data to validate Returns: tuple[str, bool]: A tuple containing (schema_type, is_valid) - where schema_type is 'google-profile.json' + where schema_type is 'MedicationAdministration.json' and is_valid indicates if the schema validation passed """ try: - schema_type = 'google-profile.json' + schema_type = 'MedicationAdministration.json' # Load the schema schema_path = os.path.join(os.path.dirname(__file__), '..', 'schemas', schema_type)