Skip to content

Commit

Permalink
Clean up template conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellrgn committed Oct 17, 2024
1 parent 72e6103 commit 1e5cdbe
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 28 deletions.
20 changes: 9 additions & 11 deletions src/lib/resource-templates/AdvanceDirective.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,15 @@ Text:
-->

<b>Category:</b>
{#if resource.category && resource.category[0] && resource.category[0].coding && resource.category[0].coding[0]}
{resource.category[0].coding[0].display} (LOINC {resource.category[0].coding[0].code})
{/if}
{resource.category?.[0].coding?.[0].display} (LOINC {resource.category?.[0].coding?.[0].code})
<br />
<b>Type:</b>
<!-- 42348-3 is for "Advance Directive"; per cthon, it's presence here is redundant w/ category above. -->
{#if resource.type && resource.type.coding && resource.type.coding[0] && resource.type.coding[0].code != '42348-3'}
{resource.type.coding[0].display} (LOINC {resource.type.coding[0].code})
{#if resource.type?.coding?.[0]}
{resource.type?.coding?.[0].display} (LOINC {resource.type?.coding?.[0].code})
{/if}
{#if resource.type && resource.type.coding && resource.type.coding[1] && resource.type.coding[1].code != '42348-3'}
{resource.type.coding[1].display} (LOINC {resource.type.coding[1].code}).
{#if resource.type?.coding?.[1]}
{resource.type?.coding?.[1].display} (LOINC {resource.type?.coding?.[1].code})
{/if}
<br />
<b>Description:</b>
Expand All @@ -60,16 +58,16 @@ Text:
<br />
<b>Author:</b>
{#if resource.author && resource.author[0] && resource.author[0].display}
{resource.author[0].display}
{resource.author?.[0].display}
{/if}
<br />
<b>setId:</b>
{#if resource.identifier && resource.identifier[0] && resource.identifier[0].system && resource.identifier[0].system == 'https://mydirectives.com/standards/terminology/namingSystem/setId'}
{#if resource.identifier?.[0].system == 'https://mydirectives.com/standards/terminology/namingSystem/setId'}
{resource.identifier[0].value}
{/if}
<br />
<b>Version number:</b>
{#if resource.extension && resource.extension[0] && resource.extension[0].url && resource.extension[0].url == 'http://hl7.org/fhir/us/ccda/StructureDefinition/VersionNumber'}
{#if resource.extension?.[0].url == 'http://hl7.org/fhir/us/ccda/StructureDefinition/VersionNumber'}
<!-- As of the July '24 this is now a unix time stamp -->
{resource.extension[0].valueInteger}
{/if}
Expand Down Expand Up @@ -165,7 +163,7 @@ Text:
<!-- FIXME This iteration not ideal - should iterate whether pdf present or not, as created & pdfSignedDate (ill-named) actually refer to the larget context of the DR, not the pdf... as it stands the Personal Advance Care Plan Document won't show created/signed (bug), tho we don't care so much about that one in IPS.
-->
{#each resource.content as content}
{#if content.attachment && content.attachment.contentType === "application/pdf" && content.attachment.data}
{#if content.attachment.contentType === "application/pdf" && content.attachment.data}
{#await base64toBlob(content.attachment.data, content.attachment.contentType) then url}
{#if content.attachment && content.attachment.creation}
<b>Created:</b> {new Date(content.attachment.creation).toISOString().slice(0,10)}
Expand Down
8 changes: 2 additions & 6 deletions src/lib/resource-templates/AllergyIntolerance.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@

{#if resource.clinicalStatus || resource.verificationStatus}
<Badge color="primary">
{#if resource.clinicalStatus?.coding}
{resource.clinicalStatus?.coding[0].code ?? ''}
{/if}
{resource.clinicalStatus?.coding?.[0].code ?? ''}
{resource.clinicalStatus &&
resource.verificationStatus
? '/'
: ''}
{#if resource.verificationStatus?.coding}
{resource.verificationStatus?.coding[0].code ?? ''}
{/if}
{resource.verificationStatus?.coding?.[0].code ?? ''}
</Badge>
{/if}
<Badge color={badgeColor(resource.criticality ?? '')}>
Expand Down
10 changes: 3 additions & 7 deletions src/lib/resource-templates/Condition.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,17 @@

{#if resource.clinicalStatus || resource.verificationStatus}
<Badge color="primary">
{#if resource.clinicalStatus?.coding}
{resource.clinicalStatus?.coding[0].code ?? ''}
{/if}
{resource.clinicalStatus?.coding?.[0].code ?? ''}
{resource.clinicalStatus &&
resource.verificationStatus
? '/'
: ''}
{#if resource.verificationStatus?.coding}
{resource.verificationStatus?.coding[0].code ?? ''}
{/if}
{resource.verificationStatus?.coding?.[0].code ?? ''}
</Badge>
{/if}
<Badge color={badgeColor(resource.severity?.text ?? '')}>severity: {resource.severity?.text ?? 'unknown'}</Badge>
<br>
{#if resource.category && resource.category[0]}
{#if resource.category?.[0]}
{#if resource.category[0].coding}
<Badge color="primary">{resource.category[0].coding[0].system} : {resource.category[0].coding[0].code}</Badge>
<br />
Expand Down
6 changes: 3 additions & 3 deletions src/lib/resource-templates/Observation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
export let resource: Observation; // Define a prop to pass the data to the component
</script>

{#if resource.category && resource.category[0].coding}
{#if resource.category?.[0].coding}
<Badge color="primary">{resource.category[0].coding[0].code}</Badge><br>
{/if}
{#if resource.code}
Expand All @@ -21,8 +21,8 @@
<strong>{resource.code.text}: </strong>
{/if}
{/if}
{#if resource.valueCodeableConcept && resource.valueCodeableConcept.coding && resource.valueCodeableConcept.coding[0].display}
<strong>{resource.valueCodeableConcept.coding[0]?.display}</strong><br>
{#if resource.valueCodeableConcept?.coding?.[0].display}
<strong>{resource.valueCodeableConcept.coding[0].display}</strong><br>
{/if}
{#if resource.valueQuantity}
<strong>{resource.valueQuantity.value ?? ""} {resource.valueQuantity.unit ?? ""}</strong><br>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/resource-templates/OccupationalData.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
export let resource: Observation; // Define a prop to pass the data to the component
</script>

{#if resource.code && resource.code.coding && resource.code.coding[0].code}
{#if resource.code.coding?.[0].code}
{#if resource.code.coding[0].code === "74165-2"}
<strong>Employment Status</strong>
{#if resource.valueCodeableConcept?.coding?.[0].display}
Expand Down

0 comments on commit 1e5cdbe

Please sign in to comment.