hl7ch / cda-fhir-maps Goto Github PK
View Code? Open in Web Editor NEWMaps (FHIR Mapping Language) to transform documents from CDA to FHIR and back
License: Apache License 2.0
Maps (FHIR Mapping Language) to transform documents from CDA to FHIR and back
License: Apache License 2.0
Anwendungsinstruktion (Instruction au patient) → MedicationStatement.note and back
according to discussion in ch-emed-pmp
In the element Medication.ingredient a wrong URL is generated as CodeSystem
<system value="http://hl7.org/fhir/sid/atc"/>
<system value="http://www.whocc.no/atc"/>
<itemCodeableConcept>
<coding>
<system value="http://hl7.org/fhir/sid/atc"/>
<code value="C08CA01"/>
<display value="amlodipine"/>
</coding>
<text value="amlodipine"/>
</itemCodeableConcept>
Source CDA:
entry.observation.effectiveTime -> Type: IVL_TS
<effectiveTime value="20120204140000+0100" />
Target FHIR:
Observation.effective[x] -> Type: dateTime
<effectiveDateTime value="2012-02-04T14:00:00+01:00"/>
To be mapped in group PharmaceuticalAdviceItemEntryContentModule
in Map CdaChEmedToBundle
Request
@host = https://test.ahdis.ch/r4
POST {{host}}/StructureMap/$transform?source=http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCdaCh
Accept: application/fhir+xml;fhirVersion=4.0
Content-Type: application/fhir+xml;fhirVersion=4.0
< ./input/ch-core/1-ZuweisungZurRadiologischenDiagnostik.xml
Response
HTTP/1.1 406 Not Acceptable
X-Powered-By: HAPI FHIR 5.3.0-SNAPSHOT REST Server (FHIR Server; FHIR 4.0.1/R4)
X-Request-ID: ReQu4ZygqFQ6ThUm
Cache-Control: must-revalidate,no-cache,no-store
Date: Thu, 03 Dec 2020 14:29:42 GMT
Via: 1.1 google
Transfer-Encoding: chunked
Alt-Svc: clear
Connection: close
MedicationStatement.dosage.sequence:
<sequence v3:value="1"/>
(e.g. input\generated-files\ch-emed-2-3-MedicationTreatmentPlan.xml,
input\generated-files\ch-emed-2-7-MedicationCard.xml)
MedicationDispense.dosageInstruction.sequence:
<sequence v3:value="1"/>
(e.g. input\generated-files\ch-emed-2-4-MedicationDispense.xml)
MedicationRequest.dispenseRequest.numberOfRepeatsAllowed:
<numberOfRepeatsAllowed v3:value="2"/>
(e.g. input\generated-files\ch-emed-2-6-MedicationPrescription.xml)
group DosageInstructionsEntryDosageChange
entry.sequenceNumber as sequenceNumber -> dosage.sequence = sequenceNumber "sequenceNumber";
group PrescriptionItemEntryContentModule
src.repeatNumber as repeatNumber -> medicationRequest.dispenseRequest as dispenseRequest then {
repeatNumber -> dispenseRequest.numberOfRepeatsAllowed = repeatNumber "repeatNumber";
} "repeats";
Extension setID has been removed during STU2 Ballot. Composition.identifier should be mapped to ClinicalDocument.set and back. See hl7ch/ch-core#97 for additional information.
Original FHIR
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n<span id=\"co1\">\nKommentar zu Medication Treatment\n</span>\n</div>"
}
Transformed CDA
<text>
<content ID="co1">
Kommentar zu Medication Treatment
</content>
</text>
<text>
<reference value="#co1"/>
</text>
Generated JSON
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">Kommentar zu Medication Treatment</div>"
}
Transformed CDA
<text>Kommentar zu Medication Treatment</text>
<text>
<reference value="#<div xmlns="/>
</text>
CodeableConcept.text element is generated without value=
<code>
<coding>
<system value="urn:oid:2.51.1.1"/>
<code value="7680500440334"/>
<display value="NORVASC Tabl 10 mg"/>
</coding>
<text>NORVASC Tabl 10 mg</text>
</code>
input\maps\CdaChEmedMedicationPrescriptionDocumentToBundle.map
The ConceptMap http://hl7.org/fhir/R4/cm-administrative-gender-v3.html which is used in the transform is only an example instance. It is not provided in the core conformance package and we don't want to upload all examples on the transformation service.
Wenn ein "individuelles" CodeSystem kommt, wird es nicht gemappt.
(Spec: Snomed CT FHIR: extensible, CDA: SHALL)
Medication.ingredient
"ingredient": [{
"itemCodeableConcept": {
"coding": [{
"system": "http://chmed16af.emediplan.ch/fhir/CodeSystem/chmed16af-codesystem-substance",
"code": "205432",
"display": "Metoprolol tartrat"
}
],
"text": "Metoprolol tartrat"
},
<pharm:ingredient classCode="MMAT" determinerCode="KIND">
<pharm:code code="205432" displayName="Metoprolol tartrat"/>
from fhir to cda the practitioner.address and telecom is not assigned to the assignedAuthor
CDA requires the author.assignedAuthor, see spec.
Required elements for assignedAuthor are:
In the FHIR source these elements aren't required.
Note:
If there is a reference to a PractitionerRole from Composition.author the mapping doesn't work.
Examples:
siehe Issue: ahdis/ch-emed-pmp#1
Validation is not converting correctly:
If no value is entered in the element note in the CDA document (source), no text element is generated in the FHIR document (target). But in FHIR the Element note.text is required.
TBD in following maps:
Example: 1-2-MedicationDispense
Input (CDA):
<td ID="dis.1.note"></td>
Actual Output (FHIR):
<note>
<extension url="http://hl7.org/fhir/StructureDefinition/narrativeLink">
<valueUrl value="#dis.1.note"/>
</extension>
</note>
Target Output (FHIR):
<note>
<extension url="http://hl7.org/fhir/StructureDefinition/narrativeLink">
<valueUrl value="#dis.1.note"/>
</extension>
<text value="-"/>
</note>
Comment: An empty text element in FHIR is not valid. (Error from IG-Publisher: Primitive types must have a value that is not empty)
actual mapping section:
// source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.2
// target: Annotation note (e.g. http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationdispense.html)
group AnnotationComment(source section: Section, source act: Act, target note: Annotation) {
act -> note.text = (%section.text.substring(%section.text.indexOf(%act.text.reference.value.substring(1))).substring(%section.text.substring(%section.text.indexOf(%act.text.reference.value.substring(1))).indexOf('>')+1, %section.text.substring(%section.text.indexOf(%act.text.reference.value.substring(1))).indexOf('<')-%section.text.substring(%section.text.indexOf(%act.text.reference.value.substring(1))).indexOf('>')-1)) "idRef";
act.text as text then {
text.reference as reference then {
reference.value as value -> note.extension as ext then NarrativeLink(value, ext) "narrativeLink";
} "reference";
} "text";
}
Generate xmlns:xsi & xsi:type
CDA: entry.substanceAdministration.consumable.manufacturedProduct.manufacturedMaterial.pharm:ingredient
<pharm:ingredient classCode="ACTI">
<pharm:quantity>
<numerator unit="mg" value="10" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="PQ"/>
<denominator value="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="PQ"/>
</pharm:quantity>
<pharm:ingredient classCode="ACTI">
<pharm:quantity>
<numerator unit="mg" value="10"/>
<denominator value="1"/>
</pharm:quantity>
Source: CDA File
<name>Préparation magistrale</name>
CDA element name
should be transformed in FHIR element Medication.code.text
, currently missing
ch.fhir.ig.cda-fhir-maps#0.2.0 /
test
Das Mapping des PADV Kommentars ist folgendermassen definiert:
Der Wert, der bei FHIR Observation.note erwartet wird ist folgender:
<td ID="padv.1.note">Abgesetzt aufgrund UAW trockener Husten</td>
(Bsp. 2-2-PharmaceuticalAdvice)
Das Mapping von CDA->FHIR und FHIR->CDA ist noch offen. Wie kann das richtige Element aus dem Text evaluiert werden?
FHIR -> CDA:
If there is no Medication.amount there should be a nullFlavor for pharm:capacityQuantity
<pharm:capacityQuantity nullFlavor="NP"/>
see Spec
CDA requires the Timestamp of the authorship (author.time), see spec.
The mapping doesn't work for this example:
CDA:
author.assignedAuthor.assignedAuthoringDevice
FHIR:
ACTUAL = Composition.author -> Practitioner
TARGET = Composition.author -> Device
CDA and FHIR example from actual mapping here: 3-1-List-Cetirizine.zip
Device from CDA example:
<author>
<templateId root="2.16.756.5.30.1.1.10.9.23"/>
<functionCode code="COMPOSER" codeSystem="2.16.840.1.113883.5.88" codeSystemName="Participation Function" displayName="composer software"/>
<time value="20220810072849+0000"/>
<assignedAuthor>
<id root="2.51.1.3" extension="7601002860123"/>
<assignedAuthoringDevice>
<manufacturerModelName>CARA's PMP</manufacturerModelName>
<softwareName>PMP CARA v0.1</softwareName>
</assignedAuthoringDevice>
</assignedAuthor>
</author>
if the package amount is not specified pharm:asContent should not be generated (otherwise it gives a schematron error)
vice versa the gtin should be taken from manufacturedMaterial.code
The CDA and FHIR example are in the zip folder
CDA:
manufacturedMaterial.code 1..1
see spec:
The element SHALL be present and describes the code of the medication (GTIN). If it as magistral preparation/compound medicin nullFlavor SHALL be NA
FHIR Source file
only Medication.code.text
is required
TBD for Transformation
Generating this part for CDA:
<code code="7680460380107" codeSystem="2.51.1.1" codeSystemName="Global Trade Item Number" displayName="NA"/>
Medication List (CDA)
<reference typeCode="XCRPT">
<externalDocument>
<id root="363BCBFD-9192-47FA-BB16-878253FBC973"/>
</externalDocument>
</reference>
mapping to FHIR in these extensions:
extension:id -> id of the medication entry (e.g. MedicationStatement)
extension:externalDocumentId -> the CDA element above
source File FHIR
Composition.section:Medikamentenliste
no substanceAdministration.text.reference
is generated for cda
Change in CH Core:
EPRDataEnterer: valueReference only to Practitioner (not Person) #85
CDA-FHIR-Maps -> Change Reference from Person to Practitioner
group ChExtEprDataEnterer
rule dataEnterer
Quentin:
Please use the annotation comment to express the reason for the action in PADV OK, CHANGE, SUSPEND, CANCEL, REFUSE. For PADV COMMENT, the comment goes in the hl7:text element. I’ve updated the integration guide. It’ll be aggregated in the next version.
For CH EMED is it for all PADV in observation.note.text, we will map it according to the type to the correct CDA part.
Mapping defined in : https://docs.google.com/spreadsheets/d/17c6p-67TPhWcZz3a-GwvCugrg9LSm606tLR8QarL9Hw/edit?usp=sharing
Mapping from FHIR to CDA:
If no section id is included in the fhir bundle, a uuid for the cda document will be generated. Because uuid() is not a fhir path expression, upper() cannot be used.
// create section id if there is none in the fhir bundle (mapping source)
section as section where $this.extension.where(url='http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-sectionid').exists()=false
-> cdasection.id as id then {
section -> id.root = uuid() "section id";
} "extension";
Concerned are all Maps for the Medication Documents:
input\maps\BundleToCdaChEmedMedication...Document.map
templateId root="1.3.6.1.4.1.19376.1.9.1.3.6"
IHE PHARM Dosage Instructions
this is missing when mapping a pre from fhir to cda,
e.g. http://fhir.ch/ig/ch-emed/Bundle-2-6-MedicationPrescription.xml.html
Source MTP (Composition.section):
"section": [
{
"title": "Plan de traitement médicamenteux",
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "77604-7",
"display": "Medication treatment plan.brief"
}
]
},
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p id=\"refpdf\">Temesta Expidet cpr orodisp 1 mg, 0-0-0-1, durant 3 jours, raison: pour dormir</p></div>"
},
"entry": [
{
"reference": "MedicationStatement/1-3-MedStatTemesta"
}
]
},
{
"title": "Commentaire",
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "48767-8",
"display": "Annotation comment"
}
]
},
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">si aucune amélioration au bout de 3 jours, reprendre contact avec le médecin</div>"
}
}
]
Transformed CDA:
<component>
<section>
<templateId root="2.16.756.5.30.1.1.10.3.2"/>
<id root="4137D4F8-E966-425B-B383-E4933A80C8CE"/>
<code code="48767-8" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Annotation comment"/>
<title>Commentaire</title>
<text>si aucune amélioration au bout de 3 jours, reprendre contact avec le médecin</text>
<entry>
<act classCode="ACT" moodCode="EVN">
<templateId root="2.16.756.5.30.1.1.10.4.2"/>
<templateId root="2.16.840.1.113883.10.20.1.40"/>
<templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.2"/>
<code code="48767-8" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Annotation comment"/>
<text>
<reference value="#<div xmlns="/>
</text>
<statusCode code="completed"/>
</act>
</entry>
</section>
</component>
Map BundleToCdaChEmed (Line 43)
FHIR: source file
for mapping details see here
Map:
Mapping MedicationDispense as example
// quantity value (number of packages)
source.quantity as quantity -> medicationDispense.quantity as medDispQuantity then {
// IHE-DIS: If the product-element contains package information, the unit attribute is not be present
quantity.value as value -> medDispQuantity.value = value "value";
// IHE-DIS: If the product-element does not contain package information, the unit attribut is present and the value SHALL be out of the UCUM code system
quantity.unit as unit then {
unit -> medDispQuantity.unit = unit "unit";
unit -> medDispQuantity.system = 'http://unitsofmeasure.org' "ucum";
unit -> medDispQuantity.code = unit "code";
} "unit";
} "quantity";
Input (CDA, e.g. 1-2-MedicationDispense):
<quantity value="20" unit="mg"/>
Output (FHIR) -> element value in wrong order:
<quantity>
<unit value="mg"/>
<system value="http://unitsofmeasure.org"/>
<code value="mg"/>
<value value="20"/>
</quantity>
Target Output (FHIR):
<quantity>
<value value="20"/>
<unit value="mg"/>
<system value="http://unitsofmeasure.org"/>
<code value="mg"/>
</quantity>
Transformation of the FHIR-Document
<templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.7.1"/>
is missing in the transformed cda document for the marcoumar section
This element on entry level is not yet mapped.
CDA:
component.section.entry.substanceAdministration.author
<author>
<templateId root="2.16.756.5.30.1.1.10.9.23"/>
<time value="20190227110000+0100"/>
<assignedAuthor>
<id root="2.51.1.3" extension="7601000234322"/>
<assignedPerson>
<name>
<family>Hôpital</family>
<given>Docteur</given>
</name>
</assignedPerson>
</assignedAuthor>
</author>
FHIR:
MedicationStatement.informationSource
details see here in column D/E
CDA and FHIR example from actual mapping here: 3-1-List-Cetirizine.zip
Transformation from CDA to FHIR
actual mapping:
<doseQuantity value="40" unit="mg"/>
"doseAndRate": [{
"doseQuantity": {
"value": 40,
"code": "mg"
}
}
]
Validation error: qty-3: If a code for the unit is present, the system SHALL also be present [code.empty() or system.exists()]
target mapping:
"doseQuantity": {
"value": 40,
"unit": "mg",
"system": "http://unitsofmeasure.org",
"code": "mg"
},
See ahdis/chmed#13
Please add a nullFlavor if the country is missing:
<addr>
<country nullFlavor="NI"/>
<city>Zürich</city>
<postalCode>8003</postalCode>
<streetAddressLine>Wiesenstr. 12</streetAddressLine>
</addr>
Element hl7:addr
(https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.9.35&effectiveDate=2018-04-18T00:00:00&language=en-US)
View this comment in following Maps:
// FIXME: add fullUrl reference rule which for urn:uuid
Encoding problems have been noticed in the following cases:
CDA document:
<city>Zürich</city>
<family>Wegmüller</family>
<th>Präpartename</th>
FHIR document:
<family value="Wegmüller"/>
<city value="Zürich"/>
If no fullUrl on entries is existing, the IG publisher aborts the process with the following error message:
e.g. No fullUrl on entry 1 in Bundle 2-6-MedicationPrescription-FHIR
The element hl7:observation.hl7:entryRelationship is not mapped with these examples (spec):
Error:
(PharmaceuticalAdviceItemEntryContentModule): choice (hl7:entryRelationship[@typecode='REFR' and hl7:substanceAdministration[hl7:templateId[@root='2.16.756.5.30.1.1.10.4.45']]] or hl7:entryRelationship[@typecode='REFR' and hl7:supply[hl7:templateId[@root='2.16.756.5.30.1.1.10.4.46']]] or hl7:entryRelationship[@typecode='REFR' and hl7:substanceAdministration[hl7:templateId[@root='2.16.756.5.30.1.1.10.4.47']]]) does not contain enough elements [min 1x]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.