Searching across related databses

Hello,
I have ‘patients’ and ‘admissions’ databases’ which are linked through ‘patientID’ field.

The ‘patients’ database includes age of each patient (record).

In the ‘admissions’ database I have a field, ‘admissionType’. It is details about whether the admission was emergency, elective or clinic appointment.

I want to find out all the patients below the age of 18 years who were admitted as ‘emergency’.

I have written a procedure to undertake this search:


    openfile "patients"

    select «Age» < 30 

    selectrecordsrelatedto "admissions","SOURCESUBSET",{admissionType = "Emergency"}

Well, my code does not work.

However, is there a way to do this search with ‘Find/Select’ menu dialogue rather than writing the code.

Thank you!

It could be done using a formula in the dialog.

image

I don’t have the appropriate databases to test this, but I think this code would work.

select Age < 30
selectrecordsrelatedto "admissions", "MODE", "selectwithin", "SOURCESUBSET", {admissionType = "Emergency"}

Not for nothing but just to point out you said you were looking for patients below the age of 18 but your select shows Age < 30.

Do you mean Age < 18?

@dave, Thank you!

The code worked nicely.

However, the formula did not seem to work.

The files (they contain dummy records) can be downloaded from:

The variable is lower caps, ‘age’

Thank you!

@designer Sorry for the typos. I mean <30 years.

@dave Thank you again for the formula. With slight modification, the formula worked:

age < 30 AND lookup(“admissions”,“PatientID”,PatientID,“admissionType”,“”) = “Emergency”