changeset 4563:a2faf7950f21

dentistry: Finished basic odontogram report / chart
author Luis Falcon <falcon@gnuhealth.org>
date Sat, 09 Jan 2021 21:40:28 +0000
parents f940fbd698cb
children 91c3472379cc
files tryton/health_dentistry/report/odontogram_report.fodt tryton/health_dentistry/report/odontogram_report.py
diffstat 2 files changed, 119 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/tryton/health_dentistry/report/odontogram_report.fodt
+++ b/tryton/health_dentistry/report/odontogram_report.fodt
@@ -1,28 +1,28 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <office:document xmlns:officeooo="http://openoffice.org/2009/office" xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rpt="http://openoffice.org/2005/report" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
- <office:meta><meta:generator>LibreOffice/7.0.3.1$Linux_X86_64 LibreOffice_project/00$Build-1</meta:generator><meta:creation-date>2008-06-07T15:26:29</meta:creation-date><dc:date>2008-08-27T16:57:45</dc:date><meta:editing-cycles>1</meta:editing-cycles><meta:editing-duration>PT0S</meta:editing-duration><meta:document-statistic meta:table-count="1" meta:image-count="0" meta:object-count="0" meta:page-count="1" meta:paragraph-count="5" meta:word-count="13" meta:character-count="100" meta:non-whitespace-character-count="89"/><meta:user-defined meta:name="Info 1"/><meta:user-defined meta:name="Info 2"/><meta:user-defined meta:name="Info 3"/><meta:user-defined meta:name="Info 4"/></office:meta>
+ <office:meta><meta:generator>LibreOffice/7.0.3.1$Linux_X86_64 LibreOffice_project/00$Build-1</meta:generator><meta:creation-date>2008-06-07T15:26:29</meta:creation-date><dc:date>2008-08-27T16:57:45</dc:date><meta:editing-cycles>1</meta:editing-cycles><meta:editing-duration>PT0S</meta:editing-duration><meta:document-statistic meta:table-count="1" meta:image-count="0" meta:object-count="0" meta:page-count="1" meta:paragraph-count="7" meta:word-count="20" meta:character-count="221" meta:non-whitespace-character-count="205"/><meta:user-defined meta:name="Info 1"/><meta:user-defined meta:name="Info 2"/><meta:user-defined meta:name="Info 3"/><meta:user-defined meta:name="Info 4"/></office:meta>
  <office:settings>
   <config:config-item-set config:name="ooo:view-settings">
-   <config:config-item config:name="ViewAreaTop" config:type="long">2235</config:config-item>
+   <config:config-item config:name="ViewAreaTop" config:type="long">0</config:config-item>
    <config:config-item config:name="ViewAreaLeft" config:type="long">0</config:config-item>
-   <config:config-item config:name="ViewAreaWidth" config:type="long">27210</config:config-item>
-   <config:config-item config:name="ViewAreaHeight" config:type="long">10836</config:config-item>
+   <config:config-item config:name="ViewAreaWidth" config:type="long">48976</config:config-item>
+   <config:config-item config:name="ViewAreaHeight" config:type="long">20533</config:config-item>
    <config:config-item config:name="ShowRedlineChanges" config:type="boolean">true</config:config-item>
    <config:config-item config:name="InBrowseMode" config:type="boolean">false</config:config-item>
    <config:config-item-map-indexed config:name="Views">
     <config:config-item-map-entry>
      <config:config-item config:name="ViewId" config:type="string">view2</config:config-item>
-     <config:config-item config:name="ViewLeft" config:type="long">9636</config:config-item>
-     <config:config-item config:name="ViewTop" config:type="long">5390</config:config-item>
+     <config:config-item config:name="ViewLeft" config:type="long">4648</config:config-item>
+     <config:config-item config:name="ViewTop" config:type="long">12051</config:config-item>
      <config:config-item config:name="VisibleLeft" config:type="long">0</config:config-item>
-     <config:config-item config:name="VisibleTop" config:type="long">2235</config:config-item>
-     <config:config-item config:name="VisibleRight" config:type="long">27208</config:config-item>
-     <config:config-item config:name="VisibleBottom" config:type="long">13069</config:config-item>
+     <config:config-item config:name="VisibleTop" config:type="long">0</config:config-item>
+     <config:config-item config:name="VisibleRight" config:type="long">48974</config:config-item>
+     <config:config-item config:name="VisibleBottom" config:type="long">20532</config:config-item>
      <config:config-item config:name="ZoomType" config:type="short">0</config:config-item>
      <config:config-item config:name="ViewLayoutColumns" config:type="short">0</config:config-item>
      <config:config-item config:name="ViewLayoutBookMode" config:type="boolean">false</config:config-item>
-     <config:config-item config:name="ZoomFactor" config:type="short">180</config:config-item>
+     <config:config-item config:name="ZoomFactor" config:type="short">100</config:config-item>
      <config:config-item config:name="IsSelectedFrame" config:type="boolean">false</config:config-item>
      <config:config-item config:name="AnchoredTextOverflowLegacy" config:type="boolean">false</config:config-item>
     </config:config-item-map-entry>
@@ -85,7 +85,7 @@
    <config:config-item config:name="ChartAutoUpdate" config:type="boolean">true</config:config-item>
    <config:config-item config:name="PrinterSetup" config:type="base64Binary"/>
    <config:config-item config:name="AddParaTableSpacingAtStart" config:type="boolean">true</config:config-item>
-   <config:config-item config:name="Rsid" config:type="int">3505227</config:config-item>
+   <config:config-item config:name="Rsid" config:type="int">3531918</config:config-item>
    <config:config-item config:name="EmbeddedDatabaseName" config:type="string"/>
    <config:config-item config:name="FieldAutoUpdate" config:type="boolean">true</config:config-item>
    <config:config-item config:name="OutlineLevelYieldsNumbering" config:type="boolean">false</config:config-item>
@@ -141,14 +141,17 @@
   <style:font-face style:name="Cantarell" svg:font-family="Cantarell" style:font-pitch="variable"/>
   <style:font-face style:name="Liberation Serif" svg:font-family="&apos;Liberation Serif&apos;" style:font-adornments="Bold" style:font-family-generic="roman" style:font-pitch="variable"/>
   <style:font-face style:name="Nimbus Roman No9 L" svg:font-family="&apos;Nimbus Roman No9 L&apos;" style:font-family-generic="roman" style:font-pitch="variable"/>
+  <style:font-face style:name="Liberation Sans1" svg:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="swiss" style:font-pitch="variable"/>
   <style:font-face style:name="Liberation Sans" svg:font-family="&apos;Liberation Sans&apos;" style:font-adornments="Regular" style:font-family-generic="swiss" style:font-pitch="variable"/>
   <style:font-face style:name="Nimbus Sans L" svg:font-family="&apos;Nimbus Sans L&apos;" style:font-family-generic="swiss" style:font-pitch="variable"/>
   <style:font-face style:name="DejaVu Sans" svg:font-family="&apos;DejaVu Sans&apos;" style:font-family-generic="system" style:font-pitch="variable"/>
+  <style:font-face style:name="Droid Sans Fallback" svg:font-family="&apos;Droid Sans Fallback&apos;" style:font-family-generic="system" style:font-pitch="variable"/>
+  <style:font-face style:name="FreeSans" svg:font-family="FreeSans" style:font-family-generic="system" style:font-pitch="variable"/>
  </office:font-face-decls>
  <office:styles>
   <style:default-style style:family="graphic">
    <style:graphic-properties svg:stroke-color="#000000" draw:fill-color="#99ccff" fo:wrap-option="no-wrap" draw:shadow-offset-x="0.1181in" draw:shadow-offset-y="0.1181in" draw:start-line-spacing-horizontal="0.1114in" draw:start-line-spacing-vertical="0.1114in" draw:end-line-spacing-horizontal="0.1114in" draw:end-line-spacing-vertical="0.1114in" style:flow-with-text="false"/>
-   <style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:writing-mode="lr-tb" style:font-independent-line-spacing="false">
+   <style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:font-independent-line-spacing="false">
     <style:tab-stops/>
    </style:paragraph-properties>
    <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Nimbus Roman No9 L" fo:font-size="12pt" fo:language="en" fo:country="US" style:letter-kerning="true" style:font-name-asian="DejaVu Sans" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="DejaVu Sans" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN"/>
@@ -369,32 +372,42 @@
    <style:text-properties style:font-name="Cantarell" fo:font-weight="bold" officeooo:paragraph-rsid="00258115" style:font-weight-asian="bold" style:font-weight-complex="bold"/>
   </style:style>
   <style:style style:name="P12" style:family="paragraph" style:parent-style-name="Table_20_Contents">
+   <style:paragraph-properties fo:text-align="start" style:justify-single-word="false"/>
+   <style:text-properties style:font-name="Cantarell" fo:font-weight="bold" officeooo:paragraph-rsid="00353ed2" style:font-weight-asian="bold" style:font-weight-complex="bold"/>
+  </style:style>
+  <style:style style:name="P13" style:family="paragraph" style:parent-style-name="Table_20_Contents">
    <style:paragraph-properties fo:text-align="end" style:justify-single-word="false"/>
    <style:text-properties style:font-name="Cantarell" fo:font-size="8pt" style:font-size-asian="8pt" style:font-size-complex="8pt"/>
   </style:style>
-  <style:style style:name="P13" style:family="paragraph" style:parent-style-name="Table_20_Contents">
+  <style:style style:name="P14" style:family="paragraph" style:parent-style-name="Table_20_Contents">
    <style:text-properties style:font-name="Cantarell" officeooo:paragraph-rsid="002247ba"/>
   </style:style>
-  <style:style style:name="P14" style:family="paragraph" style:parent-style-name="Table_20_Contents">
+  <style:style style:name="P15" style:family="paragraph" style:parent-style-name="Table_20_Contents">
    <style:text-properties style:font-name="Cantarell" fo:font-weight="normal" officeooo:paragraph-rsid="0026a93e" style:font-weight-asian="normal" style:font-weight-complex="normal"/>
   </style:style>
-  <style:style style:name="P15" style:family="paragraph" style:parent-style-name="Table_20_Contents">
+  <style:style style:name="P16" style:family="paragraph" style:parent-style-name="Table_20_Contents">
    <style:paragraph-properties fo:text-align="end" style:justify-single-word="false"/>
    <style:text-properties fo:color="#000000" loext:opacity="100%" style:font-name="Cantarell" fo:font-size="14pt" fo:font-weight="bold" style:font-size-asian="14pt" style:font-weight-asian="bold" style:font-size-complex="14pt" style:font-weight-complex="bold"/>
   </style:style>
-  <style:style style:name="P16" style:family="paragraph" style:parent-style-name="Frame_20_contents">
+  <style:style style:name="P17" style:family="paragraph" style:parent-style-name="Frame_20_contents">
    <style:paragraph-properties fo:text-align="start" style:justify-single-word="false"/>
   </style:style>
-  <style:style style:name="P17" style:family="paragraph" style:parent-style-name="Frame_20_contents">
+  <style:style style:name="P18" style:family="paragraph" style:parent-style-name="Frame_20_contents">
    <style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
   </style:style>
-  <style:style style:name="P18" style:family="paragraph" style:parent-style-name="Standard">
-   <style:paragraph-properties fo:text-align="start" style:justify-single-word="false"/>
+  <style:style style:name="P19" style:family="paragraph" style:parent-style-name="Header">
+   <style:paragraph-properties fo:text-align="end" style:justify-single-word="false"/>
+   <style:text-properties style:font-name="Cantarell" fo:font-size="8pt" fo:font-weight="normal" officeooo:rsid="0035e48e" officeooo:paragraph-rsid="0035e48e" style:font-size-asian="8pt" style:font-weight-asian="normal" style:font-size-complex="8pt" style:font-weight-complex="normal"/>
+  </style:style>
+  <style:style style:name="P20" style:family="paragraph" style:parent-style-name="Title">
+   <style:text-properties fo:color="#006666" loext:opacity="100%" style:font-name="Liberation Sans1" fo:font-size="28pt" fo:font-weight="bold" officeooo:rsid="0102ef5e" officeooo:paragraph-rsid="0035e48e" style:font-name-asian="Droid Sans Fallback" style:font-size-asian="28pt" style:font-weight-asian="bold" style:font-name-complex="FreeSans" style:font-size-complex="28pt" style:font-weight-complex="bold"/>
+  </style:style>
+  <style:style style:name="P21" style:family="paragraph" style:parent-style-name="Standard">
    <style:text-properties style:font-name="Cantarell"/>
   </style:style>
-  <style:style style:name="P19" style:family="paragraph" style:parent-style-name="Table_20_Contents">
-   <style:paragraph-properties fo:text-align="start" style:justify-single-word="false"/>
-   <style:text-properties style:font-name="Cantarell" fo:font-weight="bold" officeooo:paragraph-rsid="00353ed2" style:font-weight-asian="bold" style:font-weight-complex="bold"/>
+  <style:style style:name="P22" style:family="paragraph" style:parent-style-name="Table_20_Contents">
+   <style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
+   <style:text-properties style:font-name="Cantarell" fo:font-weight="bold" officeooo:rsid="0035e48e" officeooo:paragraph-rsid="0035e48e" style:font-weight-asian="bold" style:font-weight-complex="bold"/>
   </style:style>
   <style:style style:name="T1" style:family="text">
    <style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/>
@@ -417,6 +430,15 @@
   <style:style style:name="T7" style:family="text">
    <style:text-properties fo:color="#000000" loext:opacity="100%" style:font-name="Cantarell" fo:font-size="14pt" fo:font-weight="bold" style:font-size-asian="14pt" style:font-weight-asian="bold" style:font-size-complex="14pt" style:font-weight-complex="bold"/>
   </style:style>
+  <style:style style:name="T8" style:family="text">
+   <style:text-properties style:font-name="Cantarell"/>
+  </style:style>
+  <style:style style:name="T9" style:family="text">
+   <style:text-properties style:font-name="Cantarell" officeooo:rsid="01213232"/>
+  </style:style>
+  <style:style style:name="T10" style:family="text">
+   <style:text-properties style:font-name="Cantarell" officeooo:rsid="0035e48e"/>
+  </style:style>
   <style:style style:name="fr1" style:family="graphic" style:parent-style-name="Frame">
    <style:graphic-properties style:run-through="foreground" style:protect="none" style:wrap="dynamic" style:number-wrapped-paragraphs="no-limit" style:vertical-pos="from-top" style:vertical-rel="paragraph" style:horizontal-pos="center" style:horizontal-rel="paragraph" fo:padding="0.0591in" fo:border="none" draw:wrap-influence-on-position="once-concurrent" loext:allow-overlap="true">
     <style:columns fo:column-count="1" fo:column-gap="0in"/>
@@ -455,28 +477,30 @@
     <text:sequence-decl text:display-outline-level="0" text:name="Figure"/>
    </text:sequence-decls>
    <text:p text:style-name="P1"><text:placeholder text:placeholder-type="text">&lt;for each=&quot;patient in records&quot;&gt;</text:placeholder></text:p>
+   <text:p text:style-name="P20"><text:span text:style-name="T10">Odontogram</text:span></text:p>
    <table:table table:name="Tabla1" table:style-name="Tabla1">
     <table:table-column table:style-name="Tabla1.A"/>
     <table:table-column table:style-name="Tabla1.B"/>
     <table:table-row table:style-name="Tabla1.1">
      <table:table-cell table:style-name="Tabla1.A1" table:number-columns-spanned="2" office:value-type="string">
       <text:p text:style-name="P4"><text:span text:style-name="T4">Patient</text:span><text:span text:style-name="T1"> :</text:span> <text:s/><text:span text:style-name="T1"><text:placeholder text:placeholder-type="text">&lt;patient.rec_name&gt;</text:placeholder></text:span></text:p>
-      <text:p text:style-name="P15"><text:s/></text:p>
+      <text:p text:style-name="P16"><text:s/></text:p>
      </table:table-cell>
      <table:covered-table-cell/>
     </table:table-row>
-    <table:table-row table:style-name="TableLine94302511036944">
+    <table:table-row table:style-name="TableLine94302503256528">
      <table:table-cell table:style-name="Tabla1.A2" office:value-type="string">
-      <text:p text:style-name="P13"><text:span text:style-name="T5">PUID</text:span><text:span text:style-name="T1"> : </text:span><text:span text:style-name="T1"><text:placeholder text:placeholder-type="text">&lt;patient.name.ref or &apos;&apos;&gt;</text:placeholder></text:span></text:p>
+      <text:p text:style-name="P14"><text:span text:style-name="T5">PUID</text:span><text:span text:style-name="T1"> : </text:span><text:span text:style-name="T1"><text:placeholder text:placeholder-type="text">&lt;patient.name.ref or &apos;&apos;&gt;</text:placeholder></text:span></text:p>
      </table:table-cell>
      <table:table-cell table:style-name="Tabla1.B2" office:value-type="string">
-      <text:p text:style-name="P19"/>
+      <text:p text:style-name="P19">Print Date: <text:placeholder text:placeholder-type="text">&lt;format_date(datetime.date.today(), user.language)&gt;</text:placeholder><text:s/>at <text:placeholder text:placeholder-type="text">&lt;datetime.datetime.now().strftime(&apos;%H:%M:%S&apos;)&gt;</text:placeholder></text:p>
+      <text:p text:style-name="P22"/>
      </table:table-cell>
     </table:table-row>
    </table:table>
    <text:p text:style-name="P2"><draw:frame draw:style-name="fr1" draw:name="image: (patient_odontogram, &apos;image/png&apos;,&apos;6in&apos;,&apos;3in&apos;)" text:anchor-type="paragraph" svg:y="0.1047in" draw:z-index="0">
      <draw:text-box fo:min-height="1.5736in" fo:min-width="2.5146in">
-      <text:p text:style-name="P17"/>
+      <text:p text:style-name="P18"/>
      </draw:text-box>
     </draw:frame></text:p>
    <text:p text:style-name="P2"/>
--- a/tryton/health_dentistry/report/odontogram_report.py
+++ b/tryton/health_dentistry/report/odontogram_report.py
@@ -18,7 +18,7 @@
     radius = 37
     pieces = {
         '18': (37, 37), '17': (118, 37), '16': (199, 37), '15': (280, 37),
-        '14': (229, 37), '13': (310, 37), '12': (391, 37), '11': (472, 37),
+        '14': (361, 37), '13': (442, 37), '12': (523, 37), '11': (604, 37),
         '21': (744, 37), '22': (825, 37), '23': (906, 37), '24': (987, 37),
         '25': (1068, 37), '26': (1149, 37), '27': (1230, 37), '28': (1311, 37),
         '48': (37, 360), '47': (118, 360), '46': (199, 360), '45': (280, 360),
@@ -37,23 +37,19 @@
         }
 
     @classmethod
-    def plot_extraction(cls, piece, status, im):
-        missing_color = (5, 11, 50)  # deep blue
-        for_extraction_color = (90, 0, 15)  # red
+    def plot_extraction(cls, piece_center, status, im):
+        missing_color = "#0000ff"  # blue
+        for_extraction_color = "#ff0000"  # red
         if (status == 'M'):
             color = missing_color
         else:
             color = for_extraction_color
 
-        xcenter, ycenter = piece
+        xcenter, ycenter = piece_center
         llc = {'x': xcenter - 30, 'y': ycenter + 30}
         urc = {'x': xcenter + 30, 'y': ycenter - 30}
         ulc = {'x': xcenter - 30, 'y': ycenter - 30}
         lrc = {'x': xcenter + 30, 'y': ycenter + 30}
-
-        # We'll use this for the tooth filling.
-        # ImageDraw.floodfill(im, xy=piece, value=(255, 0, 255), thresh=200)
-
         draw = ImageDraw.Draw(im)
         draw.line((llc['x'], llc['y'], urc['x'], urc['y']),
                   fill=color, width=10)
@@ -64,6 +60,60 @@
         return (im)
 
     @classmethod
+    def plot_decayed(cls, tooth, piece_center, status, im):
+        x, y = piece_center
+        filling = (0, 0, 255)  # blue
+        decayed = (255, 0, 0)  # red
+
+        # Pick the color for decay of filling
+        if status['ts'] == 'D':
+            color = decayed
+        else:
+            color = filling
+
+        position = (x, y)  # Center of the tooth
+        draw = ImageDraw.Draw(im)
+
+        tregions = status.copy()
+        tregions.pop('ts')  # Delete ts element and focus on the tooth areas
+
+        # Set the section of the filling / decay
+        # Maxillar / upper region
+        if (tooth in range(11, 28) or tooth in range(51, 65)):
+            print(tooth, tregions)
+            for key in tregions.keys():
+                if (key in ['o', 'i']):  # Occlusal or Incisal
+                    position = (x, y)  # Center of the tooth
+                if (key == 'v'):  # Vestibular
+                    position = (x, y - 25)
+                if (key == 'p'):  # Palatine
+                    position = (x, y + 25)
+                if (key == 'd'):  # Distal
+                    position = (x - 25, y)
+                if (key == 'm'):  # Mesial
+                    position = (x + 25, y)
+
+                ImageDraw.floodfill(im, xy=position, value=color, thresh=200)
+
+        # Mandibular / lower region
+        if (tooth in range(31, 48) or tooth in range(71, 85)):
+            for key in tregions.keys():
+                if (key in ['o', 'i']):  # Occlusal or Incisal
+                    position = (x, y)  # Center of the tooth
+                if (key == 'l'):  # Lingual
+                    position = (x, y - 25)
+                if (key == 'v'):  # Vestibular
+                    position = (x, y + 25)
+                if (key == 'm'):  # Mesial
+                    position = (x - 25, y)
+                if (key == 'd'):  # Distal
+                    position = (x + 25, y)
+
+                ImageDraw.floodfill(im, xy=position, value=color, thresh=200)
+
+        return (im)
+
+    @classmethod
     def plot_odontogram(cls, dental_schema):
 
         # Get the template file from current module dir
@@ -72,8 +122,16 @@
         im = Image.open(filename)
 
         dschema = json.loads(dental_schema)
-        
+
         for tooth, values in dschema.items():
+            # Decayed or filled tooth
+            # Plot it first to avoid wrong surface filling if overlapping with
+            # other symbols
+            if (values['ts'] in ('D', 'F')):
+                status = dschema[tooth]  # Get all the keys (ts, o, m, d, ...)
+                cls.plot_decayed(int(tooth), cls.pieces[tooth], status, im)
+
+            # Missing or set for extraction tooth
             if (values['ts'] in ('M', 'E')):
                 status = values['ts']
                 cls.plot_extraction(cls.pieces[tooth], status, im)