-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstateLabReportingExamples2ToFsh.xslt
541 lines (498 loc) · 26.1 KB
/
stateLabReportingExamples2ToFsh.xslt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
<?xml version="1.0" encoding="UTF-8"?>
<!--
This XSLT will consume a CSV input file and convert it to a MeasureReport
against the selected Measure.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs f s uuid"
xmlns:uuid="http://www.uuid.org"
xmlns:s="https://github.com/FHIR/sushi" xmlns="http://hl7.org/fhir"
xmlns:f="http://hl7.org/fhir" version="2.0">
<xsl:output indent="yes" method="xml" omit-xml-declaration="yes"/>
<xsl:strip-space elements="*"/>
<!-- Limit the number of rows to convert, set to 0 to convert everything -->
<xsl:param name='count' select='2000'/>
<!-- set to the name of the mapping file
The mapping file should have the names of the CSV file columns in the first column
and the codes that they map to in the column row. Headers should for the first
row should be column,item e.g.:
column,item
deathIncrease,numC19died
hospitalizedCurrently,numC19HospPats
hospitalizedIncrease,numC19Pats
inIcuCurrently,numC19VentPats
numAcuteBeds,numBeds
numICUBeds,numICUBeds
numTotBeds,numTotBeds
numVent,numVent
numVentUse,numVentUse
-->
<xsl:param name="mapping" select="'Mapping.csv'"/>
<!-- Specifies the source of the input data. The first row
must be column names for the data. The second and subsequent
rows should be the data to convert to measurements -->
<xsl:param name="csvInputData" select="'njSampleData.csv'"/>
<!-- Set to the output format:
fsh To generate sushi output
xml To generate xml output
json Will also generate XML output, sorry, we aren't there yet.
-->
<xsl:param name="format" select="'xml'"/>
<!-- Set to the name of the measure to generate from the CSV input data file
This must be the name of a file from which the Measure resource can be
read so relevant material can be copied from it.
-->
<!--xsl:param name='measureResource' select='"Measure-CDCPatientImpactAndHospitalCapacity.xml"' /-->
<xsl:param name='measureResource' select='"Measure-FEMADailyHospitalCOVID19Reporting.xml"'/>
<!-- Load up some geodata for states (for generating example output) -->
<xsl:variable name="geo" select="document('US-States-Geocenters.xml')"/>
<!-- Set the BASE URL for saner IG artifacts (we changed it once) -->
<xsl:variable name="base" select="'http://hl7.org/fhir/us/saner/'"/>
<!-- Load up the mapping file and convert to XML for XSLT processing -->
<xsl:variable name="map">
<xsl:call-template name="getSheetAsXML">
<xsl:with-param name="names" select="('maps', 'map')"/>
<xsl:with-param name="attribute">value</xsl:with-param>
<xsl:with-param name="useFieldNames" select="true()"/>
<xsl:with-param name="pathToCSV" select="$mapping"/>
</xsl:call-template>
</xsl:variable>
<!-- Load up the Measure definition resource -->
<xsl:variable name="def" select='document($measureResource)'/>
<!-- Import CSV to XML utilities -->
<xsl:import href="CSVtoXML.xslt"/>
<!-- Import UUID Generation utilities -->
<xsl:import href="uuid.xslt"/>
<!-- Process the input -->
<xsl:template match="/">
<!-- Load the CSV file to process -->
<xsl:variable name="res">
<xsl:call-template name="getSheetAsXML">
<xsl:with-param name="names" select="('results', 'result')"/>
<xsl:with-param name="attribute">value</xsl:with-param>
<xsl:with-param name="useFieldNames" select="true()"/>
<xsl:with-param name="pathToCSV" select='$csvInputData'/>
</xsl:call-template>
</xsl:variable>
<!-- One could also load data from an XML file in a regular format -->
<!-- xsl:variable name="res" select="document('stateLabReportingData.xml')" /-->
<!-- iterator over rows -->
<xsl:for-each select="distinct-values($res/results/result[$count = 0 or position() < $count]/state/@value)">
<xsl:variable name="state" select="."/>
<!-- Load the geographic data for the state -->
<xsl:variable name="geoData" select="$geo/states/state[@PostalCode = $state]"/>
<!-- NOTE: For conversion, these should come from
existing Location and Organization records
-->
<xsl:message terminate="yes"></xsl:message>
<!-- Generate State Record body -->
<xsl:variable name="stateBody">
<xsl:copy-of select="s:string(('id'), ('states-',$state))"/>
<xsl:copy-of select="s:wrap('identifier',(
s:string(('identifier.system'), 'https://www.census.gov/geographies'),
s:string(('identifier.value'), $res/results/result[state/@value=$state][fips][1]/fips/@value))
)"/>
<xsl:if test='$geoData/@Lat and $geoData/@Long'>
<xsl:copy-of select="s:wrap('position',
(s:name(('position.latitude'), ($geoData/@Lat)),
s:name(('position.longitude'), ($geoData/@Long))
)
)"/>
</xsl:if>
</xsl:variable>
<!-- Generate the record -->
<xsl:copy-of
select="s:instance(concat('states-', $state), 'Location', concat('Example Location for the State of ', $geoData/@Name),
(s:string(('id'), ('states-',$state)),
s:wrap('identifier',(
s:string(('identifier.system'), 'https://www.census.gov/geographies'),
s:string(('identifier.value'), $res/results/result[state/@value=$state][fips][1]/fips/@value))),
s:wrap('position',
(s:name(('position.latitude'), ($geoData/@Lat)),
s:name(('position.longitude'), ($geoData/@Long))
)
)
)
)"/>
<xsl:copy-of
select="s:instance(concat($state, '-DPH'), 'Organization', concat('Example Organization for the ', $geoData/@Name, ' Department of Public Health'),
(s:string(('id'), ($state,'-DPH')), s:string(('name'), ($geoData/@Name, ' Department of Public Health')))
)"/>
</xsl:for-each>
<xsl:apply-templates select="$res/results/result[position() < $count]"/>
</xsl:template>
<xsl:template match="result">
<xsl:call-template name="result"/>
</xsl:template>
<xsl:function name="s:name">
<xsl:param name="f"/>
<xsl:param name="v"/>
<xsl:variable name="lastPart" select="translate(tokenize(string-join($f),'\.')[last()],'[]0123456789','')"/>
<xsl:choose>
<xsl:when test="$format = 'fsh'">
<xsl:text>* </xsl:text>
<xsl:value-of select="string-join($f, '')"/>
<xsl:text> = </xsl:text>
<xsl:value-of select="string-join($v, '')"/>
<xsl:text>
</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:element name="{$lastPart}">
<xsl:attribute name="value" select="string-join($v)"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xsl:function name="s:string">
<xsl:param name="f"/>
<xsl:param name="v"/>
<xsl:variable name="lastPart" select="translate(tokenize(string-join($f),'\.')[last()],'[]0123456789','')"/>
<xsl:choose>
<xsl:when test="$format = 'fsh'">
<xsl:text>* </xsl:text>
<xsl:value-of select="string-join($f, '')"/>
<xsl:text> = "</xsl:text>
<xsl:if test="contains(string-join($v, ''),'
')">""</xsl:if>
<xsl:value-of select="string-join($v, '')"/>
<xsl:if test="contains(string-join($v, ''),'
')">""</xsl:if>
<xsl:text>"
</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:element name="{$lastPart}">
<xsl:attribute name="value" select="string-join($v)"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xsl:function name="s:code">
<xsl:param name="f"/>
<xsl:param name="c"/>
<xsl:param name="s"/>
<xsl:variable name="lastPart" select="translate(tokenize(string-join($f),'\.')[last()],'[]0123456789','')"/>
<xsl:choose>
<xsl:when test="$format = 'fsh'">
<xsl:text>* </xsl:text><xsl:value-of select="string-join($f, '')"/><xsl:text> = </xsl:text>
<xsl:value-of select="$s"/>#<xsl:value-of select="string-join($c, '')"/>
<xsl:text>
</xsl:text>
</xsl:when>
<xsl:when test="not($s)">
<xsl:element name="{$lastPart}">
<xsl:attribute name="value" select="$c"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="{$lastPart}">
<xsl:attribute name="code" select="$c"/>
<xsl:attribute name="system" select="$s"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xsl:function name="s:def">
<xsl:param name="n"/>
<xsl:param name="v"/>
<xsl:variable name="lastPart" select="translate(tokenize(string-join($n),'\.')[last()],'[]0123456789','')"/>
<xsl:choose>
<xsl:when test="$format = 'fsh'">
<xsl:value-of select="concat($n, ': ',string-join($v, ''),'
')"/>
</xsl:when>
<xsl:otherwise>
<xsl:element name="def-{$lastPart}">
<xsl:attribute name="value" select="string-join($v, '')"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xsl:function name="s:instance">
<xsl:param name="n"/>
<xsl:param name="t"/>
<xsl:param name="d"/>
<xsl:param name="body"/>
<xsl:choose>
<xsl:when test="$format = 'fsh'">
<xsl:text>
</xsl:text>
<xsl:value-of select="s:def('Instance', $n)"/>
<xsl:value-of select="s:def('InstanceOf', $t)"/>
<xsl:value-of select="concat('Description : "',string-join($d, ''),'"
')"/>
<xsl:copy-of select="$body"/>
</xsl:when>
<xsl:otherwise>
<xsl:element name='{$t}'>
<xsl:attribute name="type" select="$t"/>
<xsl:attribute name="desc" select="$d"/>
<xsl:copy-of select="$body"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xsl:template name="result">
<!-- Take the data row, and compute some values into it -->
<!-- NOTE: We should be able to automate for
(numerator - sum(numerator-exclusion))/(denominator - sum(denominator-exclusion))
-->
<xsl:variable name="data">
<result xmlns="">
<xsl:copy-of select="*"/>
<xsl:variable name='num1' select='positive/@value'/>
<xsl:variable name='denom1' select='totalTestResults/@value'/>
<xsl:if test="$num1 and $denom1 > 0">
<positivePercent xmlns="" value='{round( 10000 * $num1 div $denom1) div 100}' unit='%'/>
</xsl:if>
<xsl:variable name='num2' select='positiveIncrease/@value'/>
<xsl:variable name='denom2' select='totalTestResultsIncrease/@value'/>
<xsl:if test="$num2 and $denom2 > 0">
<positiveIncreasePercent xmlns="" value='{round( 10000 * $num2 div $denom2) div 100}' unit='%'/>
</xsl:if>
</result>
</xsl:variable>
<!-- Generate Instance -->
<xsl:call-template name="createMeasureReportHeader">
<xsl:with-param name="state" select="state/@value"/>
<xsl:with-param name="date" select="date/@value"/>
<xsl:with-param name="def" select="$def"/>
<xsl:with-param name="fips" select="fips/@value"/>
<xsl:with-param name="body">
<xsl:apply-templates select="$def/f:Measure/f:group" mode="copyMeasureToReport">
<xsl:with-param name="values" select="$data"/>
</xsl:apply-templates>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:function name="s:wrap">
<xsl:param name="elemName"/>
<xsl:param name="body"/>
<xsl:choose>
<xsl:when test="$format='fsh'">
<xsl:copy-of select="$body"/>
</xsl:when>
<xsl:otherwise>
<xsl:element name="{$elemName}">
<xsl:copy-of select="$body"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xsl:template name="createMeasureReportHeader">
<xsl:param name="state"/>
<xsl:param name="date"/>
<xsl:param name="def"/>
<xsl:param name="fips"/>
<xsl:param name="body"/>
<xsl:variable name="measure" select="$def/f:Measure/f:id/@value"/>
<xsl:variable name="geoData" select="$geo/states/state[@PostalCode = $state]"/>
<xsl:variable name="exampleName" select="concat('Example', $state, '-', $date, '-', $measure)"/>
<xsl:variable name='measureBody'>
<!--xsl:value-of select="s:def('Usage', '#inline')"/-->
<xsl:copy-of select="s:string(('id'), ($exampleName))"/>
<xsl:copy-of select="
s:wrap('identifier',
(s:string(('identifier.system'), 'urn:ietf:rfc:3986'),
s:string(('identifier.value'), concat('urn:uuid:', lower-case(uuid:get-uuid($body))))
))"/>
<xsl:copy-of select="s:code(('status'), 'complete', null)"/>
<xsl:copy-of select="s:code(('type'), 'summary', null)"/>
<xsl:copy-of select="s:string(('measure'), ($def/f:Measure/f:url/@value))"/>
<xsl:variable name="geo">
<xsl:if test='$geoData/@Lat and $geoData/@Long'>
<xsl:choose>
<xsl:when test="$format='fsh'">
<xsl:copy-of
select="s:string(('subject.extension.url'), ('http://hl7.org/fhir/StructureDefinition/geolocation'))"/>
<xsl:copy-of select="s:string(('subject.extension.extension[0].url'), ('latitude'))"/>
<xsl:copy-of
select="s:name(('subject.extension.extension[0].valueDecimal'), ($geoData/@Lat))"/>
<xsl:copy-of select="s:string(('subject.extension.extension[1].url'), ('longitude'))"/>
<xsl:copy-of
select="s:name(('subject.extension.extension[1].valueDecimal'), ($geoData/@Long))"/>
</xsl:when>
<xsl:otherwise>
<extension url='http://hl7.org/fhir/StructureDefinition/geolocation'>
<extension url='latitude'>
<valueDecimal value='{$geoData/@Lat}'/>
</extension>
<extension url='longitude'>
<valueDecimal value='{$geoData/@Long}'/>
</extension>
</extension>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:variable>
<xsl:copy-of select="s:wrap('subject',
($geo, s:string(('subject.reference'), ('Location/states-', $state)),
s:string(('subject.display'), ('State of ', $geoData/@Name))
))"/>
<xsl:copy-of
select="s:string(('date'), (substring($date, 1, 4), '-', substring($date, 5, 2), '-', substring($date, 7, 2)))"/>
<xsl:copy-of select="s:wrap('reporter',
(s:string( ('reporter.reference'), ('Organization/', $state, '-DPH') ),
s:string(('reporter.display'), ($geoData/@Name, ' Department of Public Health'))
))"/>
<xsl:copy-of select="s:wrap('period',
(s:string(('period.start'), (substring($date, 1, 4), '-', substring($date, 5, 2), '-', substring($date, 7, 2))),
s:string(('period.end'), (substring($date, 1, 4), '-', substring($date, 5, 2), '-', substring($date, 7, 2)))
))"/>
<xsl:copy-of select="$body"/>
</xsl:variable>
<xsl:copy-of
select="s:instance(
($exampleName),
'MeasureReport',
('Example MeasureReport of ', $measure, ' for ', $state, ' on ', (substring($date, 5, 2), '/', substring($date, 7, 2), '/', substring($date, 1, 4))),
$measureBody)"/>
<!--xsl:choose>
<xsl:when test="$format='fsh'">
<xsl:copy-of select="$header"/>
<xsl:copy-of select="$body"/>
</xsl:when>
<xsl:otherwise>
<MeasureReport>
<xsl:copy-of select="$header"/>
<xsl:copy-of select="$body"/>
</MeasureReport>
</xsl:otherwise>
</xsl:choose-->
</xsl:template>
<xsl:function name="s:getName">
<xsl:param name="s"/>
<xsl:if test="lower-case(substring(local-name($s),1,1)) = substring(local-name($s),1,1)">
<xsl:variable name="p"><xsl:value-of select="s:getName($s/..)"/></xsl:variable>
<xsl:if test="string-length($p) != 0">
<xsl:value-of select="$p"/>
<xsl:text>.</xsl:text>
</xsl:if>
<xsl:value-of select="local-name($s)"/>
<xsl:if test="count($s/preceding-sibling::f:*[local-name() = local-name($s)]) != 0">
<xsl:text>[</xsl:text>
<xsl:value-of select="count($s/preceding-sibling::f:*[local-name() = local-name($s)])"/>
<xsl:text>]</xsl:text>
</xsl:if>
</xsl:if>
</xsl:function>
<xsl:template match="@value" mode="copyMeasureToReport">
<xsl:variable name="name" select="s:getName(..)"/>
<xsl:choose>
<xsl:when test="$format != 'fsh' and contains(local-name(../..), 'coding')">
<xsl:copy-of select="../.."/>
</xsl:when>
<xsl:when test="$format != 'fsh'">
<xsl:copy-of select=".."/>
</xsl:when>
<xsl:when test="contains(local-name(../..), 'coding')">
<xsl:value-of select="s:code(s:getName(../..), ., ../../f:system/@value)"/>
</xsl:when>
<xsl:when test="contains(lower-case(local-name(..)), 'code')">
<xsl:value-of select="s:code($name, ., null)"/>
</xsl:when>
<xsl:when test="contains(local-name(..), 'name') or contains(local-name(..), 'text') or contains(lower-case(local-name(..)), 'string')">
<xsl:value-of select="s:string($name, (.))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="s:name($name, .)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="@url" mode="copyMeasureToReport">
<xsl:choose>
<xsl:when test="$format='fsh'">
<xsl:value-of select="s:string((s:getName(..),'.url'), .)"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match='f:extension[@url="http://hl7.org/fhir/us/saner/StructureDefinition/MeasureGroupAttributes"]' mode="copyMeasureToReport">
<!-- Skip this extension, it's not needed in the report, just the measure -->
</xsl:template>
<!-- f:code[not(../f:coding)] | f:coding | f:text | -->
<xsl:template
match="f:group | f:population | (f:group|f:population)/f:code | f:stratifier | f:value | f:extension | f:valueCodeableConcept | f:valueString"
mode="copyMeasureToReport">
<xsl:param name="values"/>
<xsl:variable name="content">
<content>
<xsl:apply-templates select="@*" mode="copyMeasureToReport"/>
<xsl:choose>
<xsl:when test='self::f:code'>
<xsl:apply-templates select="f:coding/f:code/@value" mode="copyMeasureToReport"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="*" mode="copyMeasureToReport">
<xsl:with-param name="values" select="$values"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
<!-- If this is a group|population, we may need to output a measure score|count -->
<xsl:if test="self::f:group | self::f:population">
<xsl:variable name="score" select="f:code/f:coding[f:system/@value='http://hl7.org/fhir/us/saner/CodeSystem/PopulationSystem']/f:code/@value"/>
<xsl:variable name="mappedScore" select="$map/maps/map[item/@value=$score]/column/@value"/>
<xsl:variable name="v" select="$values/result/*[local-name()=string($mappedScore)]"/>
<!-- If this is a group, and the group reports a score and the score has a value -->
<xsl:variable name="n" select="s:getName(.)"/>
<xsl:choose>
<xsl:when test="self::f:group">
<xsl:choose>
<xsl:when test="not(f:measureScore)">
<!-- Don't try to report a measureScore that isn't defined -->
</xsl:when>
<xsl:when test="$v">
<xsl:copy-of select="s:name(($n, '.measureScore.value'), $v/@value)"/>
<xsl:if test='$v/@unit'>
<xsl:copy-of select="s:string(($n, '.measureScore.unit'), ($v/@unit))"/>
<xsl:copy-of
select="s:code(($n, '.measureScore.code'), $v/@unit, 'http://unitsofmeasure.org')"/>
</xsl:if>
</xsl:when>
<xsl:when test="$format='fsh'">
<xsl:copy-of
select="s:string(($n, '.measureScore.value.extension.url'), 'http://hl7.org/fhir/StructureDefinition/data-absent-reason')"/>
<xsl:copy-of select="s:name(($n, '.measureScore.value.extension.valueCode'),
concat('http://terminology.hl7.org/CodeSystem/data-absent-reason#',if (not($mappedScore)) then 'unsupported' else 'unknown'))"/>
</xsl:when>
<xsl:otherwise>
<measureScore>
<value>
<extension url='http://hl7.org/fhir/StructureDefinition/data-absent-reason'>
<valueCode value="{if (not($mappedScore)) then 'unsupported' else 'unknown'}"/>
</extension>
</value>
</measureScore>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="self::f:population">
<xsl:choose>
<xsl:when test="$v">
<xsl:copy-of select="s:name(($n,'.count'), $v/@value)"/>
</xsl:when>
<xsl:when test="$format = 'fsh'">
<xsl:copy-of select="s:string(($n, '.count.extension.url'), 'http://hl7.org/fhir/StructureDefinition/data-absent-reason')"/>
<xsl:copy-of select="s:name(($n, '.count.extension.valueCode'), 'http://terminology.hl7.org/CodeSystem/data-absent-reason#unsupported')"/>
</xsl:when>
<xsl:otherwise>
<count>
<extension url='http://hl7.org/fhir/StructureDefinition/data-absent-reason'>
<valueCode value="{if (not($mappedScore)) then 'unsupported' else 'unknown'}"/>
</extension>
</count>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:if>
</content>
</xsl:variable>
<xsl:choose>
<xsl:when test="$format='fsh'">
<xsl:value-of select="$content/f:content"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:copy-of select="$content/f:content/@*"/>
<xsl:copy-of select="$content/f:content/*"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>