Skip to content

Commit

Permalink
Switch to SMART clinical note
Browse files Browse the repository at this point in the history
- fixes chb#42
  • Loading branch information
Travers Franckle committed Dec 31, 2012
1 parent d6a45d1 commit 3f3ceed
Show file tree
Hide file tree
Showing 33 changed files with 1,147 additions and 468 deletions.
2 changes: 0 additions & 2 deletions indivo/accesscontrol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ def carenet_doc_access(principal, carenet, **unused_args):
views = [carenet_measurement_list,
carenet_procedure_list,
carenet_equipment_list,
carenet_simple_clinical_notes_list,
carenet_generic_list,
carenet_document_list,
carenet_document,
Expand All @@ -283,7 +282,6 @@ def record_doc_access(principal, record, **unused_args):
smart_generic_instance,
equipment_list,
generic_list,
simple_clinical_notes_list,
report_ccr,
record_document_list,
record_document_meta,
Expand Down
10 changes: 10 additions & 0 deletions indivo/data_models/core/clinical_note/example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from indivo.models import ClinicalNote

social_history_fact = ClinicalNote(
date="2012-05-17",
title="Telephone note",
format="http://purl.org/NET/mediatypes/text/plain",
value="Patient's mother telephoned to say that he no longer needs documentation of a sports physical for school",
provider_name_given="Josuha",
provider_name_family="Mandel",
)
9 changes: 9 additions & 0 deletions indivo/data_models/core/clinical_note/example.sdmj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"__modelname__": "ClinicalNote",
"date": "2012-05-17",
"title": "Telephone note",
"format": "http://purl.org/NET/mediatypes/text/plain",
"value": "Patient's mother telephoned to say that he no longer needs documentation of a sports physical for school",
"provider_name_given": "Josuha",
"provider_name_family": "Mandel",
}
10 changes: 10 additions & 0 deletions indivo/data_models/core/clinical_note/example.sdmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Models xmlns="http://indivo.org/vocab/xml/documents#">
<Model name="ClinicalNote">
<Field name="date">2012-05-17</Field>
<Field name="title">Telephone note</Field>
<Field name="format">http://purl.org/NET/mediatypes/text/plain</Field>
<Field name="value">Patient's mother telephoned to say that he no longer needs documentation of a sports physical for school</Field>
<Field name="provider_name_given">Josuha</Field>
<Field name="provider_name_family">Mandel</Field>
</Model>
</Models>
23 changes: 23 additions & 0 deletions indivo/data_models/core/clinical_note/extra.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from indivo.serializers import DataModelSerializers
from indivo.data_models.options import DataModelOptions
from indivo.lib.rdf import PatientGraph
from indivo.validators import ValueInSetValidator, ExactValueValidator, NonNullValidator

SNOMED_URI = 'http://purl.bioontology.org/ontology/SNOMEDCT/'

class ClinicalNoteSerializers(DataModelSerializers):

def to_rdf(queryset, result_count, record=None, carenet=None):
if not record:
record = carenet.record

graph = PatientGraph(record)
graph.addClinicalNoteList(queryset.iterator())
return graph.toRDF()

class ClinicalNoteOptions(DataModelOptions):
model_class_name = 'ClinicalNote'
serializers = ClinicalNoteSerializers
field_validators = {
'format': [NonNullValidator()],
}
10 changes: 10 additions & 0 deletions indivo/data_models/core/clinical_note/model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from indivo.models import Fact
from indivo.fields import ProviderField
from django.db import models

class ClinicalNote(Fact):
date = models.DateTimeField()
title = models.CharField(max_length=255, null=True)
format = models.CharField(max_length=255, null=True)
value = models.CharField(max_length=255, null=True)
provider = ProviderField()
22 changes: 0 additions & 22 deletions indivo/data_models/core/simple_clinical_note/example.py

This file was deleted.

20 changes: 0 additions & 20 deletions indivo/data_models/core/simple_clinical_note/example.sdmj

This file was deleted.

21 changes: 0 additions & 21 deletions indivo/data_models/core/simple_clinical_note/example.sdmx

This file was deleted.

21 changes: 0 additions & 21 deletions indivo/data_models/core/simple_clinical_note/model.py

This file was deleted.

20 changes: 0 additions & 20 deletions indivo/data_models/core/simple_clinical_note/model.sdml

This file was deleted.

38 changes: 34 additions & 4 deletions indivo/lib/rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,15 +388,45 @@ def addSocialHistoryList(self, histories):
g = self.g

for history in histories:
pnode = URIRef(history.uri())
g.add((pnode, RDF.type, SP['SocialHistory']))
hnode = URIRef(history.uri())
g.add((hnode, RDF.type, SP['SocialHistory']))

# optional
smoking_status = self._getCodedValueFromField(history, 'smoking_status', [SPCODE['SmokingStatus']])
if smoking_status:
g.add((pnode, SP['smokingStatus'], self.newCodedValue(smoking_status)))
g.add((hnode, SP['smokingStatus'], self.newCodedValue(smoking_status)))

self.addStatement(pnode)
self.addStatement(hnode)

def addClinicalNoteList(self, notes):
"""Add clinical notes to a patient's graph"""

g = self.g

for note in notes:
nnode = URIRef(note.uri())
g.add((nnode, RDF.type, SP['ClinicalNote']))

# required
document_with_format = BNode();
g.add((document_with_format, RDF.type, SP['DocumentWithFormat']))
g.add((document_with_format, DCTERMS['format'], Literal(note.format)))
if note.value:
g.add((document_with_format, DCTERMS['value'], Literal(note.value)))

g.add((nnode, DCTERMS['hasFormat'], document_with_format))

# optional
if note.date:
g.add((nnode, DCTERMS['date'], Literal(note.date)))
if note.title:
g.add((nnode, DCTERMS['title'], Literal(note.title)))

note_provider = self.provider(note, 'provider')
if note_provider:
g.add((nnode, SP['provider'], note_provider))

self.addStatement(nnode)

#####################################################
### Helper Methods for reusable low-level objects ###
Expand Down
Loading

0 comments on commit 3f3ceed

Please sign in to comment.