-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #193 from samply/develop
EHDS2, separating explorer API key from auth header CLA, thiserror version bump
- Loading branch information
Showing
12 changed files
with
204 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
define GeneticVariantCount: | ||
if InInitialPopulation then [Observation: Code '69548-6' from loinc] else {} as List <Observation> | ||
|
||
define GeneticVariantCode: | ||
First (from [Observation: Code '69548-6' from loinc] O return O.component.where(code.coding contains Code '48018-6' from loinc).value.coding.code.first()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
define InInitialPopulation: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
define ObservationList: | ||
if InInitialPopulation then [Observation] else {} as List<Observation> | ||
|
||
// Return the value in the given system for the given Observation | ||
define function ObservationValueCode(observation FHIR.Observation, system_var String): | ||
(observation.value as CodeableConcept).coding.where(system = system_var).code.first() | ||
|
||
// Check to see if there are any Observation resources with the | ||
// given system/value pair. | ||
define function ExistsObservationValueCode(system_var String, code_var String): | ||
exists from [Observation] O | ||
where ObservationValueCode(O, system_var) = code_var | ||
|
||
// Return the value associated with the extension with the given URL for the given Observation | ||
define function BaseObservationExtensionValue(observation FHIR.Observation, url_var String): | ||
observation.extension.where(url = url_var).value | ||
|
||
// Return the value of the Observation extension with the given URL | ||
define function ObservationExtensionValue(observation FHIR.Observation, url_var String): | ||
SensibleString(BaseObservationExtensionValue(observation, url_var)) | ||
|
||
define function ExistsObservationExtensionValue(url_var String, value_var String): | ||
exists from [Observation] O | ||
where ObservationExtensionValue(O, url_var) = value_var | ||
|
||
// Return the pathogen type for the given Observation | ||
define function PathogenCode(observation FHIR.Observation): | ||
ObservationValueCode(observation, 'https://ecdc.amr/pathogen-codes') | ||
|
||
// Check to see if there are any Observation resources with the | ||
// given pathogen type. | ||
define function ExistsPathogenCode(code_var String): | ||
ExistsObservationValueCode('https://ecdc.amr/pathogen-codes', code_var) | ||
|
||
// Return the antibiotic type for the given Observation | ||
define function AntibioticCode(observation FHIR.Observation): | ||
ObservationValueCode(observation, 'https://ecdc.amr/antibiotic-codes') | ||
|
||
// Check to see if there are any Observation resources with the | ||
// given antibiotic type. | ||
define function ExistsAntibioticCode(code_var String): | ||
ExistsObservationValueCode('https://ecdc.amr/antibiotic-codes', code_var) | ||
|
||
// Return the resistance type for the given Observation | ||
define function SirCode(observation FHIR.Observation): | ||
ObservationValueCode(observation, 'https://ecdc.amr/sir-codes') | ||
|
||
// Check to see if there are any Observation resources with the | ||
// given resistance type. | ||
define function ExistsSirCode(code_var String): | ||
ExistsObservationValueCode('https://ecdc.amr/sir-codes', code_var) | ||
|
||
// Return the data source for the given Observation | ||
define function DataSource(observation FHIR.Observation): | ||
ObservationExtensionValue(observation, 'https://ecdc.amr/fhir/StructureDefinition/ObservationDataSource') | ||
|
||
// Check to see if there are any Observation resources with the | ||
// given data source. | ||
define function ExistsDataSource(value_var String): | ||
ExistsObservationExtensionValue('https://ecdc.amr/fhir/StructureDefinition/ObservationDataSource', value_var) | ||
|
||
// Return the isolate ID for the given Observation | ||
define function IsolateId(observation FHIR.Observation): | ||
ObservationExtensionValue(observation, 'https://ecdc.amr/fhir/StructureDefinition/ObservationIsolateId') | ||
|
||
// Check to see if there are any Observation resources with the | ||
// given isolate ID. | ||
define function ExistsIsolateId(value_var String): | ||
ExistsObservationExtensionValue('https://ecdc.amr/fhir/StructureDefinition/ObservationIsolateId', value_var) | ||
|
||
// Return the patient type for the given Observation | ||
define function PatientType(observation FHIR.Observation): | ||
ObservationExtensionValue(observation, 'https://ecdc.amr/fhir/StructureDefinition/ObservationPatientType') | ||
|
||
// Check to see if there are any Observation resources with the | ||
// given patient type. | ||
define function ExistsPatientType(value_var String): | ||
ExistsObservationExtensionValue('https://ecdc.amr/fhir/StructureDefinition/ObservationPatientType', value_var) | ||
|
||
// Return the reference guidelines SIR for the given Observation | ||
define function ReferenceGuidelinesSir(observation FHIR.Observation): | ||
ObservationExtensionValue(observation, 'https://ecdc.amr/fhir/StructureDefinition/ObservationReferenceGuidelinesSIR') | ||
|
||
// Check to see if there are any Observation resources with the | ||
// given reference guidelines SIR. | ||
define function ExistsReferenceGuidelinesSir(value_var String): | ||
ExistsObservationExtensionValue('https://ecdc.amr/fhir/StructureDefinition/ObservationReferenceGuidelinesSIR', value_var) | ||
|
||
// Return the reporting country for the given Observation | ||
define function ReportingCountry(observation FHIR.Observation): | ||
ObservationExtensionValue(observation, 'https://ecdc.amr/fhir/StructureDefinition/ObservationReportingCountry') | ||
|
||
// Check to see if there are any Observation resources with the | ||
// given reporting country. | ||
define function ExistsReportingCountry(value_var String): | ||
ExistsObservationExtensionValue('https://ecdc.amr/fhir/StructureDefinition/ObservationReportingCountry', value_var) | ||
|
||
// Return the year from the date used for statistics | ||
define function YearDateUsedForStatistics(observation FHIR.Observation): | ||
year from observation.issued | ||
|
||
// Return the month from the date used for statistics | ||
define function MonthDateUsedForStatistics(observation FHIR.Observation): | ||
month from observation.issued | ||
|
||
// Return the year-month from the date used for statistics | ||
define function YearMonthDateUsedForStatistics(observation FHIR.Observation): | ||
ToString(YearDateUsedForStatistics(observation)) + '-' + ToString(MonthDateUsedForStatistics(observation)) | ||
|
||
// Return the the date valid from | ||
define function DateValidFrom(observation FHIR.Observation): | ||
ToDate(observation.effective as dateTime) | ||
|
||
// Return the year from the date valid from | ||
define function YearDateValidFrom(observation FHIR.Observation): | ||
year from DateValidFrom(observation) | ||
|
||
// Return the month from the date valid from | ||
define function MonthDateValidFrom(observation FHIR.Observation): | ||
month from DateValidFrom(observation) | ||
|
||
// Return the year-month from the date valid from | ||
define function YearMonthDateValidFrom(observation FHIR.Observation): | ||
ToString(YearDateValidFrom(observation)) + '-' + ToString(MonthDateValidFrom(observation)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Return the value of the Patient extension with the given URL. | ||
// Return "Unknown" if not available or empty. | ||
define function PatientExtensionValue(url_var String): | ||
SensibleString(Patient.extension.where(url = url_var).value) | ||
|
||
// Return gender of patient | ||
define Gender: | ||
SensibleString(Patient.gender) | ||
|
||
// Return age of patient, as an integer | ||
define AgeInYears: | ||
ToInteger(PatientExtensionValue('https://ecdc.amr/fhir/StructureDefinition/PatientAge')) | ||
|
||
// Round patient age to the nearest multiple of 10 (i/p for a histogram). | ||
// Return result as a string | ||
define AgeClass: | ||
ToString((AgeInYears div 10) * 10) | ||
|
||
// Return ID of hospital associated with patient | ||
define HospitalId: | ||
PatientExtensionValue('https://ecdc.amr/fhir/StructureDefinition/PatientHospitalId') | ||
|
||
// Return hospital unit type associated with patient | ||
define HospitalUnitType: | ||
PatientExtensionValue('https://ecdc.amr/fhir/StructureDefinition/PatientHospitalUnitType') | ||
|
||
// Return laboratory code associated with patient | ||
define LaboratoryCode: | ||
PatientExtensionValue('https://ecdc.amr/fhir/StructureDefinition/PatientLaboratoryCode') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
define SpecimenList: | ||
if InInitialPopulation then [Specimen] else {} as List<Specimen> | ||
|
||
// Return the isolate ID for the given Specimen | ||
define function SpecimenIsolateId(specimen FHIR.Specimen): | ||
SensibleString(specimen.id) | ||
|
||
// Check to see if there are any Specimen resources with the | ||
// given isolate ID. | ||
define function ExistsSpecimenIsolateId(id_var String): | ||
exists from [Specimen] S | ||
where SpecimenIsolateId(S) = id_var | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Return "val" if the supplied string value is sensible. | ||
// Return "Unknown" if null or empty. | ||
define function SensibleString(val String): | ||
if (val is null or val = '' or val = '-') | ||
then 'Unkown' | ||
else val | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters