use of org.hl7.fhir.r4b.model.ExpressionNode.Function in project cqf-ruler by DBCG.
the class Reflections method getFunction.
/**
* Generates a function to access a primitive property of the given
* BaseType.
*
* @param <BaseType> an IBase type
* @param <ReturnType> a return type for the Functions
* @param theBaseTypeClass the class of a the IBase type
* @param theChildName to create a function for
* @return a function for accessing the "theChildName" property of the
* BaseType
*/
@SuppressWarnings("unchecked")
public static <BaseType extends IBase, ReturnType extends List<? extends IBase>> Function<BaseType, ReturnType> getFunction(final Class<? extends BaseType> theBaseTypeClass, String theChildName) {
checkNotNull(theBaseTypeClass);
checkNotNull(theChildName);
IAccessor accessor = getAccessor(theBaseTypeClass, theChildName);
return r -> {
return (ReturnType) accessor.getValues(r);
};
}
use of org.hl7.fhir.r4b.model.ExpressionNode.Function in project cqf-ruler by DBCG.
the class ReflectionsTest method testGetNameLiteral.
@Test
public void testGetNameLiteral() {
Library library = new Library().setName("test");
Function<Library, String> getName = Reflections.getNameFunction(Library.class);
String name = getName.apply(library);
assertEquals("test", name);
}
use of org.hl7.fhir.r4b.model.ExpressionNode.Function in project cqf-ruler by DBCG.
the class ReflectionsTest method testGetVersion.
@Test
public void testGetVersion() {
Library library = new Library().setVersion("test");
Function<Library, String> getVersion = Reflections.getVersionFunction(library.getClass());
String version = getVersion.apply(library);
assertEquals("test", version);
}
use of org.hl7.fhir.r4b.model.ExpressionNode.Function in project hl7v2-fhir-converter by LinuxForHealth.
the class HL7OMLMessageTest method testOMLO21WithPatientWithPatientVisitAndMinimumOrder.
@Test
public void testOMLO21WithPatientWithPatientVisitAndMinimumOrder() throws IOException {
String hl7message = "MSH|^~\\&||Test System|||20210917110100||OML^O21^OML_O21|||2.6\r" + "PID|1||7659afb9-0dfc-d744-1f40-5b9314807108^^^^MR||Feeney^Sam^^^^^L|||M||||||||\r" + "PV1|1|O|||||||||||||||||2462201|||||||||||||||||||||||||20180520230000\r" + "ORC|NW|8125550e-04db-11ec-a9a8-086d41d421ca^^ID^UUID||||||||||\r";
String json = ftv.convert(hl7message, OPTIONS_PRETTYPRINT);
assertThat(json).isNotBlank();
IBaseResource bundleResource = context.getParser().parseResource(json);
assertThat(bundleResource).isNotNull();
Bundle b = (Bundle) bundleResource;
List<BundleEntryComponent> e = b.getEntry();
List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
// from PID
assertThat(patientResource).hasSize(1);
List<Resource> encounterResource = ResourceUtils.getResourceList(e, ResourceType.Encounter);
// from PV1
assertThat(encounterResource).hasSize(1);
// TODO: When function is added to create ServiceRequest from ORC then also check for ServiceRequest
// List<Resource> serviceResource = e.stream()
// .filter(v -> ResourceType.ServiceRequest == v.getResource().getResourceType())
// .map(BundleEntryComponent::getResource).collect(Collectors.toList());
// assertThat(serviceResource).hasSize(1);
// Confirm that there are no extra resources
// TODO: When ServiceRequest is added then this line should check for 3.
assertThat(e.size()).isEqualTo(2);
}
use of org.hl7.fhir.r4b.model.ExpressionNode.Function in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7DocumentReferenceFHIRConversionTest method doc_ref_ppr_test.
@ParameterizedTest
// Spot check for PPR messages
@ValueSource(strings = { "PPR^PC1" /* "PPR^PC2", "PPR^PC3" */
})
void doc_ref_ppr_test(String messageType) {
String documentReferenceMessage = "MSH|^~\\&|SendTest1|Sendfac1|Receiveapp1|Receivefac1|202101010000|security|" + messageType + "|1|P^I|2.6||||||ASCII||\r" + "PID|||1234^^^^MR||DOE^JANE^|||F|||||||||||||||||||||\r" + "PV1||I|6N^1234^A^GENHOS|||||||SUR|||||||0148^ANDERSON^CARL|S|1400|A|||||||||||||||||||SF|K||||199501102300\r" + "PRB|AD||202101010000|aortic stenosis|53692||2|||202101010000\r" + "OBX|1|NM|111^TotalProtein||7.5|gm/dl|5.9-8.4||||F\r" + "NTE|1|P|Problem Comments\r" + "ORC|NW|1000^OE|9999999^RX|||E|^Q6H^D10^^^R\r" + "OBR|1|TESTID|TESTID|||201801180346|201801180347||||||||||||||||||F||||||WEAKNESS||||||||||||\r" + // Next three lines create an attachment because OBX type TX
"OBX|1|TX|||ECHOCARDIOGRAPHIC REPORT||||||F|||202101010000|||\r" + "OBX|2|TX|||NORMAL LV CHAMBER SIZE WITH MILD CONCENTRIC LVH||||||F|||202101010000|||\r" + "OBX|3|TX|||HYPERDYNAMIC LV SYSTOLIC FUNCTION, VISUAL EF 80%||||||F|||202101010000|||\n";
DocumentReference documentRef = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
DocumentReference.DocumentReferenceContextComponent drContext = documentRef.getContext();
// Should contain a reference to the service request
assertThat(drContext.hasPeriod()).isFalse();
DocumentReference.DocumentReferenceContentComponent content = documentRef.getContentFirstRep();
// Currently always defaults to text/plain
assertThat(content.getAttachment().getContentType()).isEqualTo("text/plain");
// No TXA.7 in message
assertThat(content.getAttachment().getCreation()).isNull();
assertThat(content.getAttachment().hasData()).isTrue();
String decodedData = new String(Base64.getDecoder().decode(content.getAttachment().getDataElement().getValueAsString()));
assertThat(decodedData).isEqualTo("ECHOCARDIOGRAPHIC REPORT\nNORMAL LV CHAMBER SIZE WITH MILD CONCENTRIC LVH\nHYPERDYNAMIC LV SYSTOLIC FUNCTION, VISUAL EF 80%");
}
Aggregations