Gravitate Health FHIR Implementation Guide
0.1.0 - CI Build

Gravitate Health FHIR Implementation Guide, published by Gravitate Health Project. This guide is not an authorized publication; it is the continuous build for version 0.1.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/hl7-eu/gravitate-health/ and changes regularly. See the Directory of published versions

: pregnancy-lens - XML Representation

Draft as of 2024-06-12

Raw xml | Download


<Library xmlns="http://hl7.org/fhir">
  <id value="pregnancy-lens"/>
  <meta>
    <profile
             value="http://hl7.eu/fhir/ig/gravitate-health/StructureDefinition/lens"/>
  </meta>
  <text>
    <status value="generated"/>
    <div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: Library pregnancy-lens</b></p><a name="pregnancy-lens"> </a><a name="hcpregnancy-lens"> </a><a name="pregnancy-lens-en-US"> </a><h2>Parameters</h2><table class="grid"><tr><td/><td>in</td><td/><td/><td>CodeableConcept</td><td>parameter if it exists</td></tr></table><h2>Contents</h2><p>Lens for pregnancy: (<code>application/javascript</code>)</p><pre><code>let pvData = pv;
let htmlData = html;

let epiData = epi;
let ipsData = ips;

let getSpecification = () =&gt; {
    return &quot;1.0.0&quot;;
};

let annotationProcess = (listOfCategories, enhanceTag, document, response) =&gt; {
    listOfCategories.forEach((check) =&gt; {
        if (response.includes(check)) {
            let elements = document.getElementsByClassName(check);
            for (let i = 0; i &lt; elements.length; i++) {
                elements[i].classList.add(enhanceTag);
            }
            if (document.getElementsByTagName(&quot;head&quot;).length &gt; 0) {
                document.getElementsByTagName(&quot;head&quot;)[0].remove();
            }
            if (document.getElementsByTagName(&quot;body&quot;).length &gt; 0) {
                response = document.getElementsByTagName(&quot;body&quot;)[0].innerHTML;
                console.log(&quot;Response: &quot; + response);
            } else {
                console.log(&quot;Response: &quot; + document.documentElement.innerHTML);
                response = document.documentElement.innerHTML;
            }
        }
    });

    if (response == null || response == &quot;&quot;) {
        throw new Error(
            &quot;Annotation proccess failed: Returned empty or null response&quot;
        );
        //return htmlData
    } else {
        console.log(&quot;Response: &quot; + response);
        return response;
    }
}

let annotateHTMLsection = async (listOfCategories, enhanceTag) =&gt; {
    let response = htmlData;
    let document;

    if (typeof window === &quot;undefined&quot;) {
        let jsdom = await import(&quot;jsdom&quot;);
        let { JSDOM } = jsdom;
        let dom = new JSDOM(htmlData);
        document = dom.window.document;
        return annotationProcess(listOfCategories, enhanceTag, document, response);
    } else {
        document = window.document;
        return annotationProcess(listOfCategories, enhanceTag, document, response);
    }
};

let getIPSAge = (birthDate) =&gt; {
    let today = new Date();
    let birthDateParsed = new Date(birthDate);

    let ageMiliseconds = today - birthDateParsed;
    let age = Math.floor(ageMiliseconds / 31536000000);

    return age;
}

let enhance = async () =&gt; {
    //                  pregnancyCategory    breastfeedingCategory
    //                             SNOMED    SNOMED
    let listOfCategoriesToSearch = [&quot;W78&quot;, &quot;77386006&quot;, &quot;69840006&quot;]; //&quot;contra-indication-pregancy&quot;]

    // Get IPS gender and check if is female
    let gender;

    let enhanceTag;

    if (ips == &quot;&quot; || ips == null) {
        throw new Error(&quot;Failed to load IPS: the LEE is getting a empty IPS&quot;);
    }
    ips.entry.forEach((element) =&gt; {
        if (element.resource.resourceType == &quot;Patient&quot;) {
            gender = element.resource.gender;
            if (gender != &quot;female&quot; || getIPSAge(element.resource.birthDate) &gt;= 75) {
                enhanceTag = &quot;collapsed&quot;;
            } else {
                enhanceTag = &quot;highlight&quot;;
            }
        }
    });

    // ePI traslation from terminology codes to their human redable translations in the sections
    let compositions = 0;
    let categories = [];
    epi.entry.forEach((entry) =&gt; {
        if (entry.resource.resourceType == &quot;Composition&quot;) {
            compositions++;
            //Iterated through the Condition element searching for conditions
            entry.resource.extension.forEach((element) =&gt; {
                
                // Check if the position of the extension[1] is correct
                if (element.extension[1].url == &quot;concept&quot;) {
                    // Search through the different terminologies that may be avaible to check in the condition
                    if (element.extension[1].valueCodeableReference.concept != undefined) {
                        element.extension[1].valueCodeableReference.concept.coding.forEach(
                            (coding) =&gt; {
                                console.log(&quot;Extension: &quot; + element.extension[0].valueString + &quot;:&quot; + coding.code)
                                // Check if the code is in the list of categories to search
                                if (listOfCategoriesToSearch.includes(coding.code)) {
                                    // Check if the category is already in the list of categories
                                    categories.push(element.extension[0].valueString);
                                }
                            }
                        );
                    }
                }
            });
        }
    });

    if (compositions == 0) {
        throw new Error('Bad ePI: no category &quot;Composition&quot; found');
    }

    if (categories.length == 0) {
        // throw new Error(&quot;No categories found&quot;, categories);
        return htmlData;
    }
    //Focus (adds highlight class) the html applying every category found
    return await annotateHTMLsection(categories, enhanceTag);
};

return {
    enhance: enhance,
    getSpecification: getSpecification,
};
</code></pre></div>
  </text>
  <extension
             url="http://hl7.eu/fhir/ig/gravitate-health/StructureDefinition/lee-version">
    <valueString value="dev"/>
  </extension>
  <url value="http://hl7.eu/fhir/ig/gravitate-health/Library/mock-lib"/>
  <identifier>
    <system value="http://gravitate-health.lst.tfo.upm.es"/>
    <value value="pregnancy-lens"/>
  </identifier>
  <version value="0.1.0"/>
  <name value="pregnancy-lens">
    <extension url="http://hl7.org/fhir/StructureDefinition/translation">
      <extension url="lang">
        <valueCode value="es"/>
      </extension>
      <extension url="content">
        <valueString value="Lente para el embarazo"/>
      </extension>
    </extension>
  </name>
  <title value="pregnancy-lens">
    <extension url="http://hl7.org/fhir/StructureDefinition/translation">
      <extension url="lang">
        <valueCode value="es"/>
      </extension>
      <extension url="content">
        <valueString value="Lente para el embarazo"/>
      </extension>
    </extension>
  </title>
  <status value="draft"/>
  <experimental value="true"/>
  <type>
    <coding>
      <code value="logical-library"/>
    </coding>
  </type>
  <date value="2024-06-12T12:23:10.005Z"/>
  <publisher value="Gravitate Health Project"/>
  <contact>
    <name value="Gravitate Health Project"/>
    <telecom>
      <system value="url"/>
      <value value="https://www.gravitatehealth.eu/"/>
    </telecom>
  </contact>
  <contact>
    <name value="Gravitate Health Project"/>
    <telecom>
      <system value="url"/>
      <value value="https://www.gravitatehealth.eu/"/>
    </telecom>
  </contact>
  <description
               value="Lens that highlight or collapses pregnancy related information">
    <extension url="http://hl7.org/fhir/StructureDefinition/translation">
      <extension url="lang">
        <valueCode value="es"/>
      </extension>
      <extension url="content">
        <valueString
                     value="Lente que resalta o colapsa la información relacionada con el embarazo"/>
      </extension>
    </extension>
  </description>
  <purpose
           value="Collapse or highlight pregnancy related information on a preprocessed ePI.">
    <extension url="http://hl7.org/fhir/StructureDefinition/translation">
      <extension url="lang">
        <valueCode value="es"/>
      </extension>
      <extension url="content">
        <valueString
                     value="Colapsar o resaltar la información relacionada con el embarazo en un ePI preprocesado."/>
      </extension>
    </extension>
  </purpose>
  <usage
         value="You can import this lens directly to your FHIR Server which suports Library Resource type.">
    <extension url="http://hl7.org/fhir/StructureDefinition/translation">
      <extension url="lang">
        <valueCode value="es"/>
      </extension>
      <extension url="content">
        <valueString
                     value="Puedes importar esta lente directamente a tu servidor FHIR que soporte el tipo de recurso Library."/>
      </extension>
    </extension>
  </usage>
  <copyright value="© 2024 Gravitate Health"/>
  <parameter>
    <use value="in"/>
    <documentation value="parameter if it exists"/>
    <type value="CodeableConcept"/>
  </parameter>
  <content>
    <contentType value="application/javascript"/>
    <data
          value="bGV0IHB2RGF0YSA9IHB2OwpsZXQgaHRtbERhdGEgPSBodG1sOwoKbGV0IGVwaURhdGEgPSBlcGk7CmxldCBpcHNEYXRhID0gaXBzOwoKbGV0IGdldFNwZWNpZmljYXRpb24gPSAoKSA9PiB7CiAgICByZXR1cm4gIjEuMC4wIjsKfTsKCmxldCBhbm5vdGF0aW9uUHJvY2VzcyA9IChsaXN0T2ZDYXRlZ29yaWVzLCBlbmhhbmNlVGFnLCBkb2N1bWVudCwgcmVzcG9uc2UpID0+IHsKICAgIGxpc3RPZkNhdGVnb3JpZXMuZm9yRWFjaCgoY2hlY2spID0+IHsKICAgICAgICBpZiAocmVzcG9uc2UuaW5jbHVkZXMoY2hlY2spKSB7CiAgICAgICAgICAgIGxldCBlbGVtZW50cyA9IGRvY3VtZW50LmdldEVsZW1lbnRzQnlDbGFzc05hbWUoY2hlY2spOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGVsZW1lbnRzLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgICAgICBlbGVtZW50c1tpXS5jbGFzc0xpc3QuYWRkKGVuaGFuY2VUYWcpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChkb2N1bWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgiaGVhZCIpLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgIGRvY3VtZW50LmdldEVsZW1lbnRzQnlUYWdOYW1lKCJoZWFkIilbMF0ucmVtb3ZlKCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGRvY3VtZW50LmdldEVsZW1lbnRzQnlUYWdOYW1lKCJib2R5IikubGVuZ3RoID4gMCkgewogICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBkb2N1bWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgiYm9keSIpWzBdLmlubmVySFRNTDsKICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCJSZXNwb25zZTogIiArIHJlc3BvbnNlKTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCJSZXNwb25zZTogIiArIGRvY3VtZW50LmRvY3VtZW50RWxlbWVudC5pbm5lckhUTUwpOwogICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQuaW5uZXJIVE1MOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfSk7CgogICAgaWYgKHJlc3BvbnNlID09IG51bGwgfHwgcmVzcG9uc2UgPT0gIiIpIHsKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoCiAgICAgICAgICAgICJBbm5vdGF0aW9uIHByb2NjZXNzIGZhaWxlZDogUmV0dXJuZWQgZW1wdHkgb3IgbnVsbCByZXNwb25zZSIKICAgICAgICApOwogICAgICAgIC8vcmV0dXJuIGh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YWJsZVJlZmVyZW5jZS5jb25jZXB0LmNvZGluZy5mb3JFYWNoKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgKGNvZGluZykgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCJFeHRlbnNpb246ICIgKyBlbGVtZW50LmV4dGVuc2lvblswXS52YWx1ZVN0cmluZyArICI6IiArIGNvZGluZy5jb2RlKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIENoZWNrIGlmIHRoZSBjb2RlIGlzIGluIHRoZSBsaXN0IG9mIGNhdGVnb3JpZXMgdG8gc2VhcmNoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxpc3RPZkNhdGVnb3JpZXNUb1NlYXJjaC5pbmNsdWRlcyhjb2RpbmcuY29kZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gQ2hlY2sgaWYgdGhlIGNhdGVnb3J5IGlzIGFscmVhZHkgaW4gdGhlIGxpc3Qgb2YgY2F0ZWdvcmllcwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXRlZ29yaWVzLnB1c2goZWxlbWVudC5leHRlbnNpb25bMF0udmFsdWVTdHJpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pOwogICAgICAgIH0KICAgIH0pOwoKICAgIGlmIChjb21wb3NpdGlvbnMgPT0gMCkgewogICAgICAgIHRocm93IG5ldyBFcnJvcignQmFkIGVQSTogbm8gY2F0ZWdvcnkgIkNvbXBvc2l0aW9uIiBmb3VuZCcpOwogICAgfQoKICAgIGlmIChjYXRlZ29yaWVzLmxlbmd0aCA9PSAwKSB7CiAgICAgICAgLy8gdGhyb3cgbmV3IEVycm9yKCJObyBjYXRlZ29yaWVzIGZvdW5kIiwgY2F0ZWdvcmllcyk7CiAgICAgICAgcmV0dXJuIGh0bWxEYXRhOwogICAgfQogICAgLy9Gb2N1cyAoYWRkcyBoaWdobGlnaHQgY2xhc3MpIHRoZSBodG1sIGFwcGx5aW5nIGV2ZXJ5IGNhdGVnb3J5IGZvdW5kCiAgICByZXR1cm4gYXdhaXQgYW5ub3RhdGVIVE1Mc2VjdGlvbihjYXRlZ29yaWVzLCBlbmhhbmNlVGFnKTsKfTsKCnJldHVybiB7CiAgICBlbmhhbmNlOiBlbmhhbmNlLAogICAgZ2V0U3BlY2lmaWNhdGlvbjogZ2V0U3BlY2lmaWNhdGlvbiwKfTsK"/>
    <title value="Lens for pregnancy">
      <extension url="http://hl7.org/fhir/StructureDefinition/translation">
        <extension url="lang">
          <valueCode value="es"/>
        </extension>
        <extension url="content">
          <valueString value="Lente para el embarazo"/>
        </extension>
      </extension>
    </title>
  </content>
</Library>