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 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/schemas/MedicationAdministration.json b/my_proof/schemas/MedicationAdministration.json new file mode 100644 index 0000000..09ddae1 --- /dev/null +++ b/my_proof/schemas/MedicationAdministration.json @@ -0,0 +1,75 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "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", + "description": "Logical id of this artifact" + }, + "resourceType": { + "const": "MedicationAdministration" + }, + "status": { + "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", + "description": "Symbol in syntax defined by the system" + }, + "display": { + "type": "string", + "description": "Representation defined by the system" + } + } + } + }, + "text": { + "type": "string", + "description": "Plain text representation of the concept" + } + } + } + } + }, + "subject": { + "type": "object", + "required": ["reference"], + "description": "Who received medication", + "properties": { + "reference": { + "type": "string", + "description": "Literal reference, Relative, internal or absolute URL" + }, + "display": { + "type": "string", + "description": "Text alternative for the resource reference" + } + } + } + } +} \ No newline at end of file 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 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)