lantanagroup / FHIR.js

Node.JS library for serializing/deserializing FHIR resources between JS/JSON and XML using various node.js XML libraries
Apache License 2.0
102 stars 29 forks source link

Deserialization of ValueSets with exclude rules to JSON is broken #52

Closed witrin closed 2 years ago

witrin commented 2 years ago

The test suite should be extended. I guess backbone elements with type references are not covered yet.

Given

<?xml version="1.0" encoding="UTF-8"?>
<ValueSet xmlns="http://hl7.org/fhir">
    <url value="https://fhir.kbv.de/ValueSet/KBV_VS_AW_Patient_VSDM_Gender" />
    <version value="1.2.0" />
    <name value="KBV_VS_AW_Patient_VSDM_Gender" />
    <status value="active" />
    <experimental value="false" />
    <date value="2018-10-06" />
    <publisher value="Kassenaerztliche Bundesvereinigung" />
    <contact>
        <telecom>
            <system value="url" />
            <value value="http://www.kbv.de" />
        </telecom>
    </contact>
    <description value="Genderauswahl zur Nutzung in VSDM Extension" />
    <copyright value="Kassenaerztliche Bundesvereinigung" />
    <compose>
        <include>
            <valueSet value="http://hl7.org/fhir/ValueSet/administrative-gender" />
        </include>
        <include>
            <valueSet value="http://fhir.de/ValueSet/gender-amtlich-de" />
        </include>
        <exclude>
            <system value="http://hl7.org/fhir/administrative-gender" />
            <concept>
                <code value="other" />
            </concept>
        </exclude>
    </compose>
</ValueSet>

Expected

{
    "resourceType": "ValueSet",
    "url": "https://fhir.kbv.de/ValueSet/KBV_VS_AW_Patient_VSDM_Gender",
    "version": "1.2.0",
    "name": "KBV_VS_AW_Patient_VSDM_Gender",
    "status": "active",
    "experimental": false,
    "date": "2018-10-06",
    "publisher": "Kassenaerztliche Bundesvereinigung",
    "contact": [
        {
            "telecom": [
                {
                    "system": "url",
                    "value": "http://www.kbv.de"
                }
            ]
        }
    ],
    "description": "Genderauswahl zur Nutzung in VSDM Extension",
    "copyright": "Kassenaerztliche Bundesvereinigung",
    "compose": {
        "include": [
            {
                "valueSet": [
                    "http://hl7.org/fhir/ValueSet/administrative-gender"
                ]
            },
            {
                "valueSet": [
                    "http://fhir.de/ValueSet/gender-amtlich-de"
                ]
            }
        ],
        "exclude": [
            {
                "system": "http://hl7.org/fhir/administrative-gender",
                "concept": [
                    {
                        "code": "other"
                    }
                ]
            }
        ]
    }
}

Actual

{
    "resourceType": "ValueSet",
    "url": "https://fhir.kbv.de/ValueSet/KBV_VS_AW_Patient_VSDM_Gender",
    "version": "1.2.0",
    "name": "KBV_VS_AW_Patient_VSDM_Gender",
    "status": "active",
    "experimental": false,
    "date": "2018-10-06",
    "publisher": "Kassenaerztliche Bundesvereinigung",
    "contact": [
        {
            "telecom": [
                {
                    "system": "url",
                    "value": "http://www.kbv.de"
                }
            ]
        }
    ],
    "description": "Genderauswahl zur Nutzung in VSDM Extension",
    "copyright": "Kassenaerztliche Bundesvereinigung",
    "compose": {
        "include": [
            {
                "system": "http://hl7.org/fhir/administrative-gender",
                "concept": [
                    {
                        "code": "other"
                    }
                ]
            }
        ]
    }
}
witrin commented 2 years ago

I also would like to suggest to exclude build results from version control.

seanmcilvenna commented 2 years ago

I was trying to test your changes, and found that your PR was based on a a bit of an older commit. I applied your change directly in this commit. I also created a unit test based on your comments above. I published this change to NPM as v4.10.2

I also would like to suggest to exclude build results from version control.

What do you mean by this?

witrin commented 2 years ago

What do you mean by this?

Build results are e.g. the output of the TypeScript compiler (.js, .d.ts). Such files should be not part of a git repository, just build them in a pipeline, test them, push them into a sink (e.g. npm registry) and throw them away.

seanmcilvenna commented 2 years ago

Ah... I keep the compiled .js files in the repo because WebStorm automatically compiles the .ts into .js, and I don't want to have a separate process to debug the code. I'd welcome a separate PR with the tsconfig.json, .gitignore changes needed to make that happen, along with some guidance on how to setup the IDE to make debugging easy :) I just don't have much time to figure that stuff out right now.