ppazos / cabolabs-ehrserver

Open platform to manage and share standardized clinical data, designed by @ppazos at CaboLabs Health Informatics.
https://cabolabs.com
Apache License 2.0
181 stars 110 forks source link

Creating instances in EhrCommitter #326

Closed JDSBCC closed 8 years ago

JDSBCC commented 8 years ago

Hi again,

I already generate an opt with template designer, but I saw that EHR committer doesnt work with opt but with intances xml. It's possible to generate this instances from the opt files? Or I need to create them manually?

ppazos commented 8 years ago

@JDSBCC It is possible to generate composition instances from an OPT but I didn't build such component yet at least in a generic way. On my EMRApp project you will find another example of an app that commits documents to the EHRServer, and it generates valid XML from data entered from the UI, with help of some metadata that is on the code itself: https://github.com/ppazos/cabolabs-emrapp

For the EHRCommitter, I generate sample instances by hand, validating against the XML schema and manually with the OPT.

So you have two options: write some code or create them manually, but you can base your code on the EMRApp.

Hope that helps.

JDSBCC commented 8 years ago

Hi, Im creating xml instances by hand and Im getting a Bad request in the commit function (CommitterController.groovy). This is my xml instance: https://feupload.fe.up.pt/get/upxPWRlYqpfHQEt

And this are the opt and oet files: https://feupload.fe.up.pt/get/B51VvmegND4L5Jj https://feupload.fe.up.pt/get/DYY8e8yDMB6Qf4w

I think is a xml error in some field but I dont know where. Can you take a look and see what am I doing wrong?

Thanks

JDSBCC commented 8 years ago

I already fix my xml (now it is validated by version schema). However I still have the same issue, bad request when I try to commit some data to ehr (Im using EHRcommitter). This is my new xml:

<?xml version="1.0" encoding="UTF-8"?><version xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.openehr.org/v1" xsi:type="ORIGINAL_VERSION">
    <contribution>
        <id xsi:type="HIER_OBJECT_ID">
            <value>[[CONTRIBUTION:::UUID:::ANY]]</value>
        </id>
        <namespace>EHR::COMMON</namespace>
        <type>CONTRIBUTION</type>
    </contribution>
    <commit_audit>
        <system_id>CABOLABS_EHR</system_id>
        <committer xsi:type="PARTY_IDENTIFIED">
            <external_ref>
                <id xsi:type="HIER_OBJECT_ID">
                    <value>cc193f71-f5fe-438a-87f9-81ecb302eede</value>
                </id>
                <namespace>DEMOGRAPHIC</namespace>
                <type>PERSON</type>
            </external_ref>
            <name>[[COMMITTER_NAME:::STRING:::Dr. House]]</name>
        </committer>
        <time_committed>
            <value>[[TIME_COMMITTED:::DATETIME:::NOW]]</value>
        </time_committed>
        <change_type>
            <value>creation</value>
            <defining_code>
                <terminology_id>
                    <value>openehr</value>
                </terminology_id>
                <code_string>249</code_string>
            </defining_code>
        </change_type>
    </commit_audit>
    <uid>
        <value>[[VERSION_ID:::VERSION_ID:::ANY]]</value>
    </uid>
    <data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" archetype_node_id="openEHR-EHR-CLUSTER.individual_personal.v1" xsi:type="CLUSTER">
        <name>
            <value>Demographic</value>
        </name>
        <uid xsi:type="HIER_OBJECT_ID">
            <value>[[COMPOSITION:::UUID:::ANY]]</value>
        </uid>
        <archetype_details>
            <archetype_id>
                <value>openEHR-EHR-CLUSTER.individual_personal.v1</value>
            </archetype_id>
            <template_id>
                <value>Demographic</value>
            </template_id>
            <rm_version>1.0.2</rm_version>
        </archetype_details>

        <items archetype_node_id="at0016" xsi:type="ELEMENT">
            <name>
                <value>Identifier</value>
            </name>
            <value xsi:type="DV_TEXT">
                        <value>[[IDENTIFIER:::STRING:::RANDOM]]</value>
            </value>
        </items>
    </data>
    <lifecycle_state>
        <value>completed</value>
        <defining_code>
            <terminology_id>
                <value>openehr</value>
            </terminology_id>
            <code_string>532</code_string>
        </defining_code>
    </lifecycle_state>
</version>
ppazos commented 8 years ago

@JDSBCC are you sending that directly or using the committer?

The "variable marks" there, like [[IDENTIFIER:::STRING:::RANDOM]] are transformed by the committer in data, that shouldn't reach the server.

Also, the server expects that inside a envelope, so the root element is "versions", that has many "version" children. Check the guide, page 19: http://www.cabolabs.com/en/projects

"Request body

The body should contain a set of versions in XML. Each version should be compliant with this XSD:

https://github.com/ppazos/cabolabs-ehrserver/blob/master/xsd/Version.xsd

Sample XML

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

<versions xmlns="http://schemas.openehr.org/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance">

<version xsi:type="ORIGINAL_VERSION">

..."

What do you get as a response from the server?

Are you testing with local EHRServer and local EHRCommitter?

JDSBCC commented 8 years ago

I'm using local EHRServer and local EHRCommiter. This time I tried the sample you have "test_commit_1.xml" and again I got bad request error. Error is here: https://feupload.fe.up.pt/get/ReVFKlA7X7zK1MJ

I also tried to validade "test_commit_1.xml" and the validator give me:

The Prefix "xsi" For Attribute "xsi:type" Associated With An Element Type "version" Is Not Bound.. Line '1', Column '38'.
The Prefix "xsi" For Attribute "xsi:type" Associated With An Element Type "version" Is Not Bound.

Im using this validator: http://www.freeformatter.com/xml-validator-xsd.html

By the way, Im putting xml in sample_instances folder. Is it the right place?

ppazos commented 8 years ago

@JDSBCC the stacktrace doesn't show the response, I need to see what is actually going into the server and the HTTP response on the wire. Can you capture the traffic using wireshark and send me the pcapng file? Knowing that will tell us where is the issue.

Also, did you uploaded your code to github? it would help to take a look.

About the XSD, please read my previous message carefully: ".... _Each version _should be compliant with this XSD ..."

The XML root is "versions" and it contains many "version", the XML won't validate since the XML validates each "version" not the "versions".

FYI: I'll create a single XSD to validate the whole XML soon. But for now you need to remove the "versions" object from the XML to validate against the XSD.

JDSBCC commented 8 years ago

Here is the traffic: traffic.zip

I don't know if I did right, I never used wireshark xD

And yes, I forgot to remove versions tag. There is no problem with xml now.

ppazos commented 8 years ago

@JDSBCC gotcha, the problem is the version.data on the XML you try to commit has xsi:type CLUSTER and should be COMPOSITION (the openEHR document representation), since the EHRServer works with documents. CLUSTER is a low-level data structure. To use it, you need to put it into an ADMIN_ENTRY (in your case because seems you want to send demographic data but not clinical data), and put the ADMIN_ENTRY in a COMPOSTIION. To that use the Template Designer. If this is just for testing don't bother looking for COMPO and ADMIN_ENTRY on the CKM, just create those archetypes in the Archetype Editor and then group them in the Template Designer (add slots to point to each other in the AE and the TD will see those dependencies).

With that done, you need to update the XML. I took the liberty of changing it as an example, but you'll need to update the archetype_node_id values depending on your archetypes and maybe the structure (if your archetypes define a different one). This XML validates against the schema, and if I put it into the "versions" envelope, the commit works OK (but since the EHRServer doesn't have the OPT with the right archetypes it will accept the commit but won't index it for querying, that's why the OPT is needed).

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<version xmlns="http://schemas.openehr.org/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ORIGINAL_VERSION">
    <contribution>
        <id xsi:type="HIER_OBJECT_ID">
            <value>ce9303d9-7e41-4830-b31d-c741918953e5</value>
        </id>
        <namespace>EHR::COMMON</namespace>
        <type>CONTRIBUTION</type>
    </contribution>
    <commit_audit>
        <system_id>CABOLABS_EHR</system_id>
        <committer xsi:type="PARTY_IDENTIFIED">
            <external_ref>
                <id xsi:type="HIER_OBJECT_ID">
                    <value>cc193f71-f5fe-438a-87f9-81ecb302eede</value>
                </id>
                <namespace>DEMOGRAPHIC</namespace>
                <type>PERSON</type>
            </external_ref>
            <name>Dr. House</name>
        </committer>
        <time_committed>
            <value>20140901T233114,065-0300</value>
        </time_committed>
        <change_type>
            <value>creation</value>
            <defining_code>
                <terminology_id>
                    <value>openehr</value>
                </terminology_id>
                <code_string>249</code_string>
            </defining_code>
        </change_type>
    </commit_audit>
    <uid>
        <value>ca763233-2a7e-4251-bfdd-a0fecbfa6807::EMR::1</value>
    </uid>
    <data xsi:type="COMPOSITION" archetype_node_id="openEHR-EHR-COMPOSITION.testcompo.v1">
       <name>
         <value>Test compo</value>
       </name>
       <archetype_details>
         <archetype_id>
           <value>openEHR-EHR-COMPOSITION.testcompo.v1</value>
         </archetype_id>
         <template_id>
           <value>Test template</value>
         </template_id>
         <rm_version>1.0.2</rm_version>
       </archetype_details>
       <language>
         <terminology_id>
           <value>ISO_639-1</value>
         </terminology_id>
         <code_string>es</code_string>
       </language>
       <territory>
         <terminology_id>
           <value>ISO_3166-1</value>
         </terminology_id>
         <code_string>UY</code_string>
       </territory>
       <category>
         <value>event</value>
         <defining_code>
           <terminology_id>
             <value>openehr</value>
           </terminology_id>
           <code_string>443</code_string>
         </defining_code>
       </category>
       <composer xsi:type="PARTY_IDENTIFIED">
         <external_ref>
           <id xsi:type="HIER_OBJECT_ID">
             <value>cc193f71-f5fe-438a-87f9-81ecb302eede</value>
           </id>
           <namespace>DEMOGRAPHIC</namespace>
           <type>PERSON</type>
         </external_ref>
         <name>Dr. House</name>
       </composer>
       <context>
         <start_time>
           <value>20160113T144434,417-0300</value>
         </start_time>
         <setting>
           <value>Hospital Montevideo</value>
           <defining_code>
             <terminology_id>
               <value>openehr</value>
             </terminology_id>
             <code_string>229</code_string>
           </defining_code>
         </setting>
       </context>
       <content xsi:type="ADMIN_ENTRY" archetype_node_id="openEHR-EHR-ADMIN_ENTRY.patient.v1">
         <name>
           <value>Patient</value>
         </name>
         <language>
           <terminology_id>
             <value>ISO_639-1</value>
           </terminology_id>
           <code_string>es</code_string>
         </language>
         <encoding>
           <terminology_id>
             <value>Unicode</value>
           </terminology_id>
           <code_string>UTF-8</code_string>
         </encoding>
         <subject xsi:type="PARTY_SELF" />
         <data xsi:type="ITEM_TREE" archetype_node_id="at0001">
           <name>
             <value>Patient data</value>
           </name>
           <items archetype_node_id="openEHR-EHR-CLUSTER.individual_personal.v1" xsi:type="CLUSTER">
                 <name>
                     <value>Demographic</value>
                 </name>
                 <uid xsi:type="HIER_OBJECT_ID">
                     <value>c91aefc8-9f4f-4d59-9f22-b3bb112d96dd</value>
                 </uid>
                 <archetype_details>
                     <archetype_id>
                         <value>openEHR-EHR-CLUSTER.individual_personal.v1</value>
                     </archetype_id>
                     <template_id>
                         <value>Demographic</value>
                     </template_id>
                     <rm_version>1.0.2</rm_version>
                 </archetype_details>
                 <items archetype_node_id="at0016" xsi:type="ELEMENT">
                     <name>
                         <value>Identifier</value>
                     </name>
                     <value xsi:type="DV_TEXT">
                         <value>ssdfgsdfgsdgfsdfgsdfgsdfggsd</value>
                     </value>
                 </items>
           </items>
         </data>
       </content>
    </data>
    <lifecycle_state>
        <value>completed</value>
        <defining_code>
            <terminology_id>
                <value>openehr</value>
            </terminology_id>
            <code_string>532</code_string>
        </defining_code>
    </lifecycle_state>
</version>

The full commit looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<versions xmlns="http://schemas.openehr.org/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<version xsi:type="ORIGINAL_VERSION">
    <contribution>
        <id xsi:type="HIER_OBJECT_ID">
            <value>ce9303d9-7e41-4830-b31d-c741918953e5</value>
        </id>
        <namespace>EHR::COMMON</namespace>
        <type>CONTRIBUTION</type>
    </contribution>
    <commit_audit>
        <system_id>CABOLABS_EHR</system_id>
        <committer xsi:type="PARTY_IDENTIFIED">
            <external_ref>
                <id xsi:type="HIER_OBJECT_ID">
                    <value>cc193f71-f5fe-438a-87f9-81ecb302eede</value>
                </id>
                <namespace>DEMOGRAPHIC</namespace>
                <type>PERSON</type>
            </external_ref>
            <name>Dr. House</name>
        </committer>
        <time_committed>
            <value>20140901T233114,065-0300</value>
        </time_committed>
        <change_type>
            <value>creation</value>
            <defining_code>
                <terminology_id>
                    <value>openehr</value>
                </terminology_id>
                <code_string>249</code_string>
            </defining_code>
        </change_type>
    </commit_audit>
    <uid>
        <value>ca763233-2a7e-4251-bfdd-a0fecbfa6807::EMR::1</value>
    </uid>
    <data xsi:type="COMPOSITION" archetype_node_id="openEHR-EHR-COMPOSITION.testcompo.v1">
       <name>
         <value>Test compo</value>
       </name>
       <archetype_details>
         <archetype_id>
           <value>openEHR-EHR-COMPOSITION.testcompo.v1</value>
         </archetype_id>
         <template_id>
           <value>Test template</value>
         </template_id>
         <rm_version>1.0.2</rm_version>
       </archetype_details>
       <language>
         <terminology_id>
           <value>ISO_639-1</value>
         </terminology_id>
         <code_string>es</code_string>
       </language>
       <territory>
         <terminology_id>
           <value>ISO_3166-1</value>
         </terminology_id>
         <code_string>UY</code_string>
       </territory>
       <category>
         <value>event</value>
         <defining_code>
           <terminology_id>
             <value>openehr</value>
           </terminology_id>
           <code_string>443</code_string>
         </defining_code>
       </category>
       <composer xsi:type="PARTY_IDENTIFIED">
         <external_ref>
           <id xsi:type="HIER_OBJECT_ID">
             <value>cc193f71-f5fe-438a-87f9-81ecb302eede</value>
           </id>
           <namespace>DEMOGRAPHIC</namespace>
           <type>PERSON</type>
         </external_ref>
         <name>Dr. House</name>
       </composer>
       <context>
         <start_time>
           <value>20160113T144434,417-0300</value>
         </start_time>
         <setting>
           <value>Hospital Montevideo</value>
           <defining_code>
             <terminology_id>
               <value>openehr</value>
             </terminology_id>
             <code_string>229</code_string>
           </defining_code>
         </setting>
       </context>
       <content xsi:type="ADMIN_ENTRY" archetype_node_id="openEHR-EHR-ADMIN_ENTRY.patient.v1">
         <name>
           <value>Patient</value>
         </name>
         <language>
           <terminology_id>
             <value>ISO_639-1</value>
           </terminology_id>
           <code_string>es</code_string>
         </language>
         <encoding>
           <terminology_id>
             <value>Unicode</value>
           </terminology_id>
           <code_string>UTF-8</code_string>
         </encoding>
         <subject xsi:type="PARTY_SELF" />
         <data xsi:type="ITEM_TREE" archetype_node_id="at0001">
           <name>
             <value>Patient data</value>
           </name>
           <items archetype_node_id="openEHR-EHR-CLUSTER.individual_personal.v1" xsi:type="CLUSTER">
                 <name>
                     <value>Demographic</value>
                 </name>
                 <uid xsi:type="HIER_OBJECT_ID">
                     <value>c91aefc8-9f4f-4d59-9f22-b3bb112d96dd</value>
                 </uid>
                 <archetype_details>
                     <archetype_id>
                         <value>openEHR-EHR-CLUSTER.individual_personal.v1</value>
                     </archetype_id>
                     <template_id>
                         <value>Demographic</value>
                     </template_id>
                     <rm_version>1.0.2</rm_version>
                 </archetype_details>
                 <items archetype_node_id="at0016" xsi:type="ELEMENT">
                     <name>
                         <value>Identifier</value>
                     </name>
                     <value xsi:type="DV_TEXT">
                         <value>ssdfgsdfgsdgfsdfgsdfgsdfggsd</value>
                     </value>
                 </items>
           </items>
         </data>
       </content>
    </data>
    <lifecycle_state>
        <value>completed</value>
        <defining_code>
            <terminology_id>
                <value>openehr</value>
            </terminology_id>
            <code_string>532</code_string>
        </defining_code>
    </lifecycle_state>
</version>
</versions>

And the response from the server is:

<result>
  <type>
    <code>AA</code>
    <codeSystem>HL7::TABLES::TABLE_8</codeSystem>
  </type>
  <message>Versions successfully committed to EHR 11111111-1111-1111-1111111111111111</message>
</result>

FYI: I created an issue to add an extra check for users trying to commit non-composition data: I created an issue to avoid commit problems: https://github.com/ppazos/cabolabs-ehrserver/issues/330

For testing, wireshark is ideal because you can see what is on the cable, the problem is it doesn't captures traffic from-to localhost, so I couldn't see the local HTTP traffic on your capture. For doing so, there is some config to do:

https://wiki.wireshark.org/CaptureSetup/Loopback https://www.youtube.com/watch?v=79dYdc9Is50

An alternative that would allow you to test requests and responses is to install the Insomnia REST Client (Chrome extension). I have an Insomnia project to test the EHRServer, but needs to be updated. I can do that on the weekend to help you developing/testing.

FYI: this is the file that needs to be updated (won't work as it is right now): https://github.com/ppazos/cabolabs-ehrserver/blob/master/ehrserver_rest_insomnia.json

ppazos commented 8 years ago

@JDSBCC if you need it we can have a quick skype or HO call to have you up and running quickly.

ppazos commented 8 years ago

@JDSBCC the insomnia tests were updated see #322 or the file directly https://github.com/ppazos/cabolabs-ehrserver/blob/master/ehrserver_rest_insomnia.json

To use it

  1. Install Insomnia REST Client Chrome Extension
  2. Import the JSON
  3. First run /login to get your token (by default it uses the admin user)
  4. Use the token in the Authorization header of all the requests as "Bearer $token" where $token is the one returned by /login

Some endpoints require organization uids, you can get those from the /profile endpoint

You will find 3 or 4 tests for /commit please update the uids when you commit because if you commit the same document twice, you will get an error from the EHRServer (of course that shouldn't affect the EHRServer).

JDSBCC commented 8 years ago

Hi, I didnt see everything you did yet but I can tell you, I tried insomnia and this is really helpfull. I didnt know it but I really like it =)

Im testing now all the stuff that you talk about this weekend. Thank you very much

JDSBCC commented 8 years ago

Hi, I already can commit some data and I can see it in the database, however some of it doesnt appear there. I think the problem is something around archetype and wrong tags of xml. Here is a part of xml:

<data xsi:type="ITEM_TREE" archetype_node_id="at0001">
                    <name>
                        <value>Patient data</value>
                    </name>
                    <items archetype_node_id="openEHR-EHR-CLUSTER.individual_personal.v1" xsi:type="CLUSTER">
                        <name>
                            <value>Demographic</value>
                        </name>
                        <uid xsi:type="HIER_OBJECT_ID">
                            <value>c91aefc8-9f4f-4d59-9f22-b3bb112d96dd</value>
                        </uid>
                        <archetype_details>
                            <archetype_id>
                                <value>openEHR-EHR-CLUSTER.individual_personal.v1</value>
                            </archetype_id>
                            <template_id>
                                <value>Demographic</value>
                            </template_id>
                            <rm_version>1.0.2</rm_version>
                        </archetype_details>

                        <items archetype_node_id="openEHR-EHR-CLUSTER.person_name.v1" xsi:type="CLUSTER">
                            <name>
                                <value>Name</value>
                            </name>
                            <uid xsi:type="HIER_OBJECT_ID">
                                <value>c91aefc9-9f4f-4d59-9f22-b3bb112d96dd</value>
                            </uid>
                            <archetype_details>
                                <archetype_id>
                                    <value>openEHR-EHR-CLUSTER.person_name.v1</value>
                                </archetype_id>
                                <template_id>
                                    <value>Demographic</value>
                                </template_id>
                                <rm_version>1.0.2</rm_version>
                            </archetype_details>

                            <items archetype_node_id="at0003" xsi:type="ELEMENT">
                                <name>
                                    <value>GivenName</value>
                                </name>
                                <value xsi:type="DV_TEXT">
                                    <value>Joao</value>
                                </value>
                            </items>

                            <items archetype_node_id="at0005" xsi:type="ELEMENT">
                                <name>
                                    <value>FamilyName</value>
                                </name>
                                <value xsi:type="DV_TEXT">
                                    <value>Correia</value>
                                </value>
                            </items>
                        </items>

                        <items archetype_node_id="at0016" xsi:type="ELEMENT">
                            <name>
                                <value>Identifier</value>
                            </name>
                            <value xsi:type="DV_TEXT">
                                <value>ssdfgsdfgsdgfsdfgsdfgsdfggsd</value>
                            </value>
                        </items>
                                                 .........

It's basically the same, the only difference is that I added person_name archetype. I also tried with another elements like Identifier and all work less person_name . Next is a part of adl individual_person:

definition
    CLUSTER[at0000] matches {   -- Individual's personal demographics
        items cardinality matches {1..*; unordered} matches {
            allow_archetype CLUSTER[at0013] occurrences matches {0..1} matches {    -- Name
                include
                    archetype_id/value matches {/openEHR-EHR-CLUSTER\.person_name\.v1/}
                exclude
                    archetype_id/value matches {/.*/}
            }
            ELEMENT[at0016] occurrences matches {0..1} matches {    -- Identifier
                value matches {
                    DV_TEXT matches {*}
                }
            }
            ELEMENT[at0007] occurrences matches {0..1} matches {    -- Date of Birth
                value matches {
                    DV_DATE_TIME matches {*}
                }
            }
            ELEMENT[at0017] occurrences matches {0..1} matches {    -- Sex
                value matches {
                    DV_CODED_TEXT matches {
                        defining_code matches {
                            [local::
                            at0020,     -- Male
                            at0021,     -- Female
                            at0022] -- Indeterminate
                        }
                    }
                }
            }
            ELEMENT[at0008] occurrences matches {0..1} matches {    -- Relationship to subject
                value matches {
                    DV_TEXT matches {*}
                }
            }
            allow_archetype CLUSTER[at0014] occurrences matches {0..*} matches {    -- Address details
                include
                    archetype_id/value matches {/openEHR-EHR-CLUSTER\.address\.v1/}
            }
            allow_archetype CLUSTER[at0015] occurrences matches {0..*} matches {    -- Telecom details
                include
                    archetype_id/value matches {/openEHR-EHR-CLUSTER\.telecom_details\.v1/}
                exclude
                    archetype_id/value matches {/.*/}
            }
            allow_archetype CLUSTER[at0018] occurrences matches {0..*} matches {    -- Ethnicity/Indigenous status 
                include
                    archetype_id/value matches {/.*/}
            }
            allow_archetype CLUSTER[at0019] occurrences matches {0..*} matches {    -- Entitlements
                include
                    archetype_id/value matches {/.*/}
            }
        }
    }
ppazos commented 8 years ago

@JDSBCC did you uploaded the correspondent OPT to the EHRServer?

For the first try I would recommend to use archetypes with less slots :)

JDSBCC commented 8 years ago

Yes and I already tried it with less slots and it worked. Just when I tried it _person_name _ archetype didnt work.

JDSBCC commented 8 years ago

Wait I did it. I forgot to add another item (cluster) before doing the simple items. Correction:

<items archetype_node_id="openEHR-EHR-CLUSTER.person_name.v1" xsi:type="CLUSTER">
                            <name>
                                <value>Name</value>
                            </name>
                            <uid xsi:type="HIER_OBJECT_ID">
                                <value>c91aefc9-9f4f-4d59-9f22-b3bb112d96dd</value>
                            </uid>
                            <archetype_details>
                                <archetype_id>
                                    <value>openEHR-EHR-CLUSTER.person_name.v1</value>
                                </archetype_id>
                                <template_id>
                                    <value>Demographic</value>
                                </template_id>
                                <rm_version>1.0.2</rm_version>
                            </archetype_details>

                            <items archetype_node_id="at0002" xsi:type="CLUSTER">
                                <name>
                                    <value>Name</value>
                                </name>
                                <uid xsi:type="HIER_OBJECT_ID">
                                    <value>c91aefc9-9f4f-4d59-9f22-b3bb112d96dd</value>
                                </uid>
                                <archetype_details>
                                    <archetype_id>
                                        <value>openEHR-EHR-CLUSTER.person_name.v1</value>
                                    </archetype_id>
                                    <template_id>
                                        <value>Demographic</value>
                                    </template_id>
                                    <rm_version>1.0.2</rm_version>
                                </archetype_details>

                                <items archetype_node_id="at0003" xsi:type="ELEMENT">
                                    <name>
                                        <value>GivenName</value>
                                    </name>
                                    <value xsi:type="DV_TEXT">
                                        <value>Joao</value>
                                    </value>
                                </items>

                                <items archetype_node_id="at0005" xsi:type="ELEMENT">
                                    <name>
                                        <value>FamilyName</value>
                                    </name>
                                    <value xsi:type="DV_TEXT">
                                        <value>Correia</value>
                                    </value>
                                </items>
                            </items>
ppazos commented 8 years ago

@JDSBCC all nodes that reference an archetype should have archetype_node_id = archetype id, your patient name node has archetype_node_id=at0002 and I think it should be openEHR-EHR-CLUSTER.person_name.v1

BTW, does the OPT reference the person_name \ archetype?

JDSBCC commented 8 years ago

Yes, but I already fixed this problem. Thank you =)

ppazos commented 8 years ago

@JDSBCC is it working?

Also, this is not required for children elements, we need that just for the root data element:

                            <uid xsi:type="HIER_OBJECT_ID">
                                <value>c91aefc9-9f4f-4d59-9f22-b3bb112d96dd</value>
                            </uid>
                            <archetype_details>
                                <archetype_id>
                                    <value>openEHR-EHR-CLUSTER.person_name.v1</value>
                                </archetype_id>
                                <template_id>
                                    <value>Demographic</value>
                                </template_id>
                                <rm_version>1.0.2</rm_version>
                            </archetype_details>
JDSBCC commented 8 years ago

Whoops. I didn´t see that. I will remove now. And yes I already tried with all archetypes I need and I can see all data I committed in the database so I think there is no more problems here (at least for now xD). BTW now I have to fill correctly all the xml with correct information and not random information like it is right now so, do you have some suggestion how can I fill it? Im using c# in my project. Thanks

JDSBCC commented 8 years ago

Im trying to create some organizations and patients before commit data with xml. Until now I dicovered that you use Bootsrap.groovy to insert the default data that I can see when I run EHRserver. My doubt is how can I generate uids. According to my research in your code you use String uid = java.util.UUID.randomUUID() as String and my doubt is right here. That code generate random uids diferent from each other or just generate random uids? ie randomUUID is 100% free of duplicates? (do you know if Guid.NewGuid in c# works in the same way?)

ppazos commented 8 years ago

@JDSBCC about filling data in the XML, check how the EHRCommitter does that, it just put data on marked fields in the XML.

Admins can create organizations from the GUI, no need to create them from the bootstrap. About UIDs, check the versions: https://en.wikipedia.org/wiki/Universally_unique_identifier

JDSBCC commented 8 years ago

Hi, Im trying to POST login with my program, however, when I try it I get The remote server returned an error: (401) Unauthorized. Probably is not a problem related to EHRserver but just for sure, am Im missing some information? There's no token here, so I have no idea why I am unauthorized to login. Login and the other requests are working well using Insomnia. Thanks

EDIT Just now I noticed that Im getting this message in console: .... class org.springframework.security.core.userdetails.UsernameNotFoundException but your authentication in json is: "authentication": { "_type": "basic", "username": "", "password": "" } So, why Im getting this error?

JDSBCC commented 8 years ago

I already fix the previous error. It was something with authentication token, I dont know what, but I changed it and it is working now. =)

ppazos commented 8 years ago

@JDSBCC check the login endpoint doc on the EHRServer guide page 15 found at http://cabolabs.com/en/projects

JDSBCC commented 8 years ago

I already did something like you do in EHRcommitter to fill my xml with correct information, but now I have another problem, when a value is null I got this error: capture This is the value Im talking about:

<items archetype_node_id="at0009" xsi:type="ELEMENT">
                            <name>
                                <value>Telefone 2</value>
                            </name>
                            <value xsi:type="DV_TEXT">
                                <value>[[:::TELEPHONE2:::]]</value>
                            </value>
                        </items>

This value should be optional as I defined in template. Do I need to add something to xml to make it optional? Or the error is another thing?

ppazos commented 8 years ago

@JDSBCC according the specs, http://www.openehr.org/releases/1.0.2/architecture/rm/data_types_im.pdf page 29, DV_TEXT.value can't be empty.

If you send something like this* you'll get an error on the EHRServer.

*

 <value xsi:type="DV_TEXT">
         <value></value>
  </value>

In the EHRServer, the validation error should not affect the rest of the indexing process. It would be desirable that the client app knows about that error, because right now is internal. I think we can modify the XSD a little to not allow empty data for the required fields. I need to check this with openEHR because the XSD is the standard one, maybe we need to change it at the openEHR level.

Still, the EHRServer behavior is correct, not so friendly, but correct. The client app should not send the DV_TEXT if it is not data, and can send a null_flavor if needed. Check http://www.openehr.org/releases/1.0.2/architecture/rm/data_structures_im.pdf page 21.

ppazos commented 8 years ago

@JDSBCC I created another project that generates XMLs from OPTs in the format needed by the EHRCommitter to create the UI and commit data to the EHRServer. Check the openEHR-OPT project in my github. There is a command line tood to create the instances. Might be useful.