-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad7a6f8
commit 6e46e84
Showing
168 changed files
with
89,271 additions
and
5 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
18 changes: 18 additions & 0 deletions
18
native/fhir-to-bal-lib/src/test/resources/ballerina.tests/test_constraints.bal
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,18 @@ | ||
import ballerina/constraint; | ||
import ballerina/test; | ||
|
||
@test:Config {} | ||
function testResourceElementConstraints() { | ||
USCoreCareTeam careTeam = { | ||
subject: { | ||
reference: "Patient/123" | ||
}, | ||
participant: [] | ||
}; | ||
USCoreCareTeam|constraint:Error validate = constraint:validate(careTeam, USCoreCareTeam); | ||
if validate is USCoreCareTeam { | ||
test:assertFail("careTeam should not be valid"); | ||
} else { | ||
test:assertTrue(true, "careTeam is not valid"); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
native/fhir-to-bal-lib/src/test/resources/ballerina.tests/test_extended_profiles.bal
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,71 @@ | ||
import ballerina/test; | ||
import ballerinax/health.fhir.r4; | ||
|
||
@test:Config {} | ||
function testSlicings() { | ||
|
||
USCorePulseOximetryProfileCodeCodingPulseOx pulseOx = {}; | ||
USCorePulseOximetryProfileCodeCodingO2Sat o2Sat = {}; | ||
|
||
USCorePulseOximetryProfileCategoryVSCat vsCat = {coding: [{}]}; | ||
|
||
USCorePulseOximetryProfile pulseOximetry = { | ||
id: "pulseOximetry", | ||
meta: { | ||
profile: ["http://hl7.org/fhir/us/core/StructureDefinition/us-core-pulse-oximetry"] | ||
}, | ||
status: "final", | ||
code: { coding: [ pulseOx, o2Sat ] }, | ||
subject: { | ||
reference: "Patient/123" | ||
}, | ||
effectiveDateTime: "2020-01-01T00:00:00Z", | ||
effectivePeriod: { | ||
'start: "2020-01-01T00:00:00Z", | ||
end: "2020-01-01T00:00:00Z" | ||
}, | ||
category: [vsCat] | ||
}; | ||
test:assertEquals(pulseOximetry.category[0], vsCat); | ||
} | ||
|
||
function testFixedValues() { | ||
|
||
USCorePulseOximetryProfileCodeCodingPulseOx pulseOx = {}; | ||
USCorePulseOximetryProfileCodeCodingO2Sat o2Sat = {}; | ||
|
||
USCorePulseOximetryProfileCategoryVSCat vsCat = {coding: [{}]}; | ||
|
||
USCorePulseOximetryProfile pulseOximetry = { | ||
id: "pulseOximetry", | ||
meta: { | ||
profile: ["http://hl7.org/fhir/us/core/StructureDefinition/us-core-pulse-oximetry"] | ||
}, | ||
status: "final", | ||
code: { coding: [ pulseOx, o2Sat ] }, | ||
subject: { | ||
reference: "Patient/123" | ||
}, | ||
effectiveDateTime: "2020-01-01T00:00:00Z", | ||
effectivePeriod: { | ||
'start: "2020-01-01T00:00:00Z", | ||
end: "2020-01-01T00:00:00Z" | ||
}, | ||
category: [vsCat] | ||
}; | ||
|
||
r4:CodeableConcept[]? category = pulseOximetry.category; | ||
|
||
if category is r4:CodeableConcept[] { | ||
r4:Coding[]? codings = category[0].coding; | ||
if codings is r4:Coding[] { | ||
r4:Coding coding = codings[0]; | ||
test:assertEquals(coding.system, "http://terminology.hl7.org/CodeSystem/observation-category"); | ||
test:assertEquals(coding.code, "vital-signs"); | ||
} else { | ||
test:assertFail("codings is not populated with fixed values"); | ||
} | ||
} else { | ||
test:assertFail("category is not populated with fixed values"); | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
native/fhir-to-bal-lib/src/test/resources/ballerina.tests/test_parse_and_serialize.bal
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,108 @@ | ||
import ballerina/test; | ||
import ballerinax/health.fhir.r4.parser; | ||
import ballerinax/health.fhir.r4; | ||
|
||
@test:Config {} | ||
function testParse() returns error? { | ||
json patientPayload = { | ||
"resourceType": "Patient", | ||
"id": "1", | ||
"meta": { | ||
"profile": [ | ||
"http://hl7.org.au/fhir/StructureDefinition/au-patient" | ||
] | ||
}, | ||
"identifier": [ | ||
{ | ||
"use": "usual", | ||
"type": { | ||
"coding": [ | ||
{ | ||
"system": "http://terminology.hl7.org/CodeSystem/v2-0203", | ||
"code": "MR" | ||
} | ||
] | ||
}, | ||
"system": "urn:oid:", | ||
"value": "57164", | ||
"_value": { | ||
"extension": [ | ||
{ | ||
"valueString": "57164", | ||
"url": "http://hl7.org/fhir/StructureDefinition/rendered-value" | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"active":true, | ||
"name":[ | ||
{ | ||
"use":"official", | ||
"family":"Chalmers", | ||
"given":[ | ||
"Peter", | ||
"James" | ||
] | ||
} | ||
], | ||
"gender":"male", | ||
"birthDate":"1974-12-25", | ||
"_birthDate": { | ||
"id": "314159", | ||
"extension" : [{ | ||
"url" : "http://example.org/fhir/StructureDefinition/text", | ||
"valueString" : "Easter 1970" | ||
}] | ||
}, | ||
"managingOrganization":{ | ||
"reference":"Organization/1" | ||
} | ||
}; | ||
|
||
r4:HumanName[] name = [{ | ||
family: "Chalmers", | ||
given: ["Peter", "James"], | ||
use: r4:official | ||
}]; | ||
|
||
anydata parsedResult = check parser:parse(patientPayload, USCorePatientProfile); | ||
USCorePatientProfile patientModel = check parsedResult.ensureType(); | ||
test:assertEquals(patientModel.name, name, "Patient name is not equal"); | ||
} | ||
|
||
@test:Config {} | ||
function testSerialize() { | ||
USCorePatientProfile patient = { | ||
meta: { | ||
profile: [PROFILE_BASE_USCOREPATIENTPROFILE] | ||
}, | ||
active: true, | ||
name: [{ | ||
family: "Doe", | ||
given: ["Jhon"], | ||
use: r4:official, | ||
prefix: ["Mr"] | ||
}], | ||
address: [{ | ||
line: ["652 S. Lantern Dr."], | ||
city: "New York", | ||
country: "United States", | ||
postalCode: "10022", | ||
'type: r4:physical, | ||
use: r4:home | ||
}], | ||
identifier: [{ | ||
system: "http://acme.org/mrns", | ||
value: "12345" | ||
}], | ||
gender: "unknown" | ||
}; | ||
r4:FHIRResourceEntity fhirEntity = new(patient); | ||
json|r4:FHIRSerializerError jsonResult = fhirEntity.toJson(); | ||
if jsonResult is json { | ||
test:assertEquals(true, patient.active); | ||
} else { | ||
test:assertFail("Error occurred while serializing the patient model"); | ||
} | ||
} |
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
Oops, something went wrong.